Skip to content

[webview_flutter_dev] Change method name's first letter #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions packages/webview_flutter/tizen/src/webview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <Ecore_Input_Evas.h>
#include <Ecore_IMF_Evas.h>

std::string extractStringFromMap(const flutter::EncodableValue& arguments,
std::string ExtractStringFromMap(const flutter::EncodableValue& arguments,
const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
Expand All @@ -31,7 +31,7 @@ std::string extractStringFromMap(const flutter::EncodableValue& arguments,
}
return std::string();
}
int extractIntFromMap(const flutter::EncodableValue& arguments,
int ExtractIntFromMap(const flutter::EncodableValue& arguments,
const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
Expand All @@ -40,7 +40,7 @@ int extractIntFromMap(const flutter::EncodableValue& arguments,
}
return -1;
}
double extractDoubleFromMap(const flutter::EncodableValue& arguments,
double ExtractDoubleFromMap(const flutter::EncodableValue& arguments,
const char* key) {
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
Expand All @@ -59,11 +59,11 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
currentUrl_(initialUrl),
width_(width),
height_(height) {
setTextureId(FlutterRegisterExternalTexture(textureRegistrar_));
initWebView();
SetTextureId(FlutterRegisterExternalTexture(textureRegistrar_));
InitWebView();
auto channel =
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
getPluginRegistrar()->messenger(), getChannelName(),
GetPluginRegistrar()->messenger(), GetChannelName(),
&flutter::StandardMethodCodec::GetInstance());
channel->SetMethodCallHandler(
[webview = this](const auto& call, auto result) {
Expand All @@ -72,24 +72,24 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
webViewInstance_->LoadURL(currentUrl_);
}

WebView::~WebView() { dispose(); }
WebView::~WebView() { Dispose(); }

std::string WebView::getChannelName() {
return "plugins.flutter.io/webview_" + std::to_string(getViewId());
std::string WebView::GetChannelName() {
return "plugins.flutter.io/webview_" + std::to_string(GetViewId());
}

void WebView::dispose() {
FlutterUnregisterExternalTexture(textureRegistrar_, getTextureId());
void WebView::Dispose() {
FlutterUnregisterExternalTexture(textureRegistrar_, GetTextureId());

webViewInstance_->Destroy();
webViewInstance_ = nullptr;
}

void WebView::resize(double width, double height) {
LOG_DEBUG("WebView::resize width: %f height: %f \n", width, height);
void WebView::Resize(double width, double height) {
LOG_DEBUG("WebView::Resize width: %f height: %f \n", width, height);
}

void WebView::touch(int type, int button, double x, double y, double dx,
void WebView::Touch(int type, int button, double x, double y, double dx,
double dy) {
// LOG_DEBUG(
// "Widget::Native::Touch type[%s],btn[%d],x[%f],y[%f],dx[%f],dy[%f]",
Expand Down Expand Up @@ -117,7 +117,7 @@ void WebView::touch(int type, int button, double x, double y, double dx,
}
}

static LWE::KeyValue ecoreEventKeyToKeyValue(const char* ecoreKeyString,
static LWE::KeyValue EcoreEventKeyToKeyValue(const char* ecoreKeyString,
bool isShiftPressed) {
if (strcmp("Left", ecoreKeyString) == 0) {
return LWE::KeyValue::ArrowLeftKey;
Expand Down Expand Up @@ -302,7 +302,7 @@ static LWE::KeyValue ecoreEventKeyToKeyValue(const char* ecoreKeyString,
return LWE::KeyValue::UnidentifiedKey;
}

void WebView::dispatchKeyDownEvent(Ecore_Event_Key* keyEvent) {
void WebView::DispatchKeyDownEvent(Ecore_Event_Key* keyEvent) {
std::string keyName = keyEvent->keyname;
LOG_DEBUG("ECORE_EVENT_KEY_DOWN [%s, %d]\n", keyName.data(),
(keyEvent->modifiers & 1) || (keyEvent->modifiers & 2));
Expand All @@ -313,7 +313,7 @@ void WebView::dispatchKeyDownEvent(Ecore_Event_Key* keyEvent) {
// webViewInstance_->m_lastInputTime = Starfish::longTickCount();
// }

if (!isFocused()) {
if (!IsFocused()) {
LOG_DEBUG("ignore keydown because we dont have focus");
return;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ void WebView::dispatchKeyDownEvent(Ecore_Event_Key* keyEvent) {
}
}

auto keyValue = ecoreEventKeyToKeyValue(keyName.data(), false);
auto keyValue = EcoreEventKeyToKeyValue(keyName.data(), false);

// if (keyValue >= LWE::KeyValue::ArrowDownKey &&
// keyValue <= LWE::KeyValue::ArrowRightKey) {
Expand Down Expand Up @@ -385,12 +385,12 @@ void WebView::dispatchKeyDownEvent(Ecore_Event_Key* keyEvent) {
}
}

void WebView::dispatchKeyUpEvent(Ecore_Event_Key* keyEvent) {
void WebView::DispatchKeyUpEvent(Ecore_Event_Key* keyEvent) {
std::string keyName = keyEvent->keyname;
LOG_DEBUG("ECORE_EVENT_KEY_UP [%s, %d]\n", keyName.data(),
(keyEvent->modifiers & 1) || (keyEvent->modifiers & 2));

if (!isFocused()) {
if (!IsFocused()) {
LOG_DEBUG("ignore keyup because we dont have focus");
return;
}
Expand All @@ -400,7 +400,7 @@ void WebView::dispatchKeyUpEvent(Ecore_Event_Key* keyEvent) {
keyName = "Escape";
}
#endif
auto keyValue = ecoreEventKeyToKeyValue(keyName.data(), false);
auto keyValue = EcoreEventKeyToKeyValue(keyName.data(), false);

// if (keyValue >= LWE::KeyValue::ArrowDownKey &&
// keyValue <= LWE::KeyValue::ArrowRightKey) {
Expand All @@ -424,13 +424,13 @@ void WebView::dispatchKeyUpEvent(Ecore_Event_Key* keyEvent) {
p);
}

void WebView::clearFocus() { LOG_DEBUG("WebView::clearFocus \n"); }
void WebView::ClearFocus() { LOG_DEBUG("WebView::clearFocus \n"); }

void WebView::setDirection(int direction) {
LOG_DEBUG("WebView::setDirection direction: %d\n", direction);
void WebView::SetDirection(int direction) {
LOG_DEBUG("WebView::SetDirection direction: %d\n", direction);
}

void WebView::initWebView() {
void WebView::InitWebView() {
if (webViewInstance_ != nullptr) {
webViewInstance_->Destroy();
webViewInstance_ = nullptr;
Expand All @@ -456,7 +456,7 @@ void WebView::initWebView() {
webViewInstance_->RegisterOnRenderedHandler(
[this](LWE::WebContainer* c, LWE::WebContainer::RenderResult r) {
FlutterMarkExternalTextureFrameAvailable(textureRegistrar_,
getTextureId(), tbmSurface_);
GetTextureId(), tbmSurface_);
tbm_surface_destroy(tbmSurface_);
tbmSurface_ = nullptr;
});
Expand All @@ -479,8 +479,8 @@ void WebView::HandleMethodCall(
LOG_DEBUG("HandleMethodCall : %s \n ", methodName.c_str());

if (methodName.compare("loadUrl") == 0) {
currentUrl_ = extractStringFromMap(arguments, "url");
webViewInstance_->LoadURL(getCurrentUrl());
currentUrl_ = ExtractStringFromMap(arguments, "url");
webViewInstance_->LoadURL(GetCurrentUrl());
result->Success();
} else if (methodName.compare("updateSettings") == 0) {
result->NotImplemented();
Expand All @@ -498,7 +498,7 @@ void WebView::HandleMethodCall(
webViewInstance_->Reload();
result->Success();
} else if (methodName.compare("currentUrl") == 0) {
result->Success(flutter::EncodableValue(getCurrentUrl().c_str()));
result->Success(flutter::EncodableValue(GetCurrentUrl().c_str()));
} else if (methodName.compare("evaluateJavascript") == 0) {
result->NotImplemented();
} else if (methodName.compare("addJavascriptChannels") == 0) {
Expand Down
20 changes: 10 additions & 10 deletions packages/webview_flutter/tizen/src/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ class WebView : public PlatformView {
FlutterTextureRegistrar* textureRegistrar, double width,
double height, const std::string initialUrl);
~WebView();
virtual void dispose() override;
virtual void resize(double width, double height) override;
virtual void touch(int type, int button, double x, double y, double dx,
virtual void Dispose() override;
virtual void Resize(double width, double height) override;
virtual void Touch(int type, int button, double x, double y, double dx,
double dy) override;
virtual void setDirection(int direction) override;
virtual void clearFocus() override;
virtual void SetDirection(int direction) override;
virtual void ClearFocus() override;

// Key input event
virtual void dispatchKeyDownEvent(Ecore_Event_Key* key) override;
virtual void dispatchKeyUpEvent(Ecore_Event_Key* key) override;
virtual void DispatchKeyDownEvent(Ecore_Event_Key* key) override;
virtual void DispatchKeyUpEvent(Ecore_Event_Key* key) override;

private:
void HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
std::string getChannelName();
const std::string& getCurrentUrl() { return currentUrl_; }
void initWebView();
std::string GetChannelName();
const std::string& GetCurrentUrl() { return currentUrl_; }
void InitWebView();
FlutterTextureRegistrar* textureRegistrar_;
LWE::WebContainer* webViewInstance_;
std::string currentUrl_;
Expand Down
10 changes: 4 additions & 6 deletions packages/webview_flutter/tizen/src/webview_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ WebViewFactory::WebViewFactory(flutter::PluginRegistrar* registrar,
cachePath.c_str());
}

PlatformView* WebViewFactory::create(int viewId, double width, double height,
PlatformView* WebViewFactory::Create(int viewId, double width, double height,
const std::vector<uint8_t>& createParams) {
std::string initialUrl = "about:blank";
auto decoded_value = *getCodec().DecodeMessage(createParams);
auto decoded_value = *GetCodec().DecodeMessage(createParams);
if (std::holds_alternative<flutter::EncodableMap>(decoded_value)) {
flutter::EncodableMap createParams =
std::get<flutter::EncodableMap>(decoded_value);
Expand All @@ -41,10 +41,8 @@ PlatformView* WebViewFactory::create(int viewId, double width, double height,
initialUrl = std::get<std::string>(initialUrlValue);
}
}
return new WebView(getPluginRegistrar(), viewId, textureRegistrar_, width,
return new WebView(GetPluginRegistrar(), viewId, textureRegistrar_, width,
height, initialUrl);
}

void WebViewFactory::dispose() {
LWE::LWE::Finalize();
}
void WebViewFactory::Dispose() { LWE::LWE::Finalize(); }
4 changes: 2 additions & 2 deletions packages/webview_flutter/tizen/src/webview_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class WebViewFactory : public PlatformViewFactory {
public:
WebViewFactory(flutter::PluginRegistrar* registrar,
FlutterTextureRegistrar* textureRegistrar);
virtual void dispose() override ;
virtual PlatformView* create(
virtual void Dispose() override;
virtual PlatformView* Create(
int viewId, double width, double height,
const std::vector<uint8_t>& createParams) override;

Expand Down