1. This patch segregates existing common functionalities in RWHVAuraOffscreenHelperEfl
so it can be used during both onscreen & offscreen rendering modes
2. Added safety checks before using offscreen_helper in non offscreen
rendering mode
3. Suppressed several build time warnings
Reference: https://review.tizen.org/gerrit/285132
Change-Id: I4922a60b2b9504a4c7c62b6f3a9c858cb385eafb
Signed-off-by: Surya Kumar <surya.kumar7@samsung.com>
if (!view)
return;
- view->offscreen_helper()->EvasToBlinkCords(x, y, view_x, view_y);
+ if (auto offscreen_helper = view->offscreen_helper())
+ offscreen_helper->EvasToBlinkCords(x, y, view_x, view_y);
gfx::Rect rect(*view_x, *view_y, 0, 0);
rect.Offset(GetViewBoundsInScreenCoordinates().OffsetFromOrigin());
*view_x = rect.x();
auto view =
static_cast<RenderWidgetHostViewAura*>(delegate_->AccessibilityGetView());
- if (!view)
+ if (!view || !view->offscreen_helper())
return;
if (!view->offscreen_helper()->HasFocus())
host()->render_frame_metadata_provider()->AddObserver(this);
#if BUILDFLAG(IS_EFL)
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableOffscreenRendering)) {
- offscreen_helper_ =
- std::make_unique<RWHVAuraOffscreenHelperEfl>(this, &web_contents);
- }
+ efl_helper_ =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableOffscreenRendering)
+ ? std::make_unique<RWHVAuraOffscreenHelperEfl>(this, &web_contents)
+ : std::make_unique<RWHVAuraCommonHelperEfl>(this, &web_contents);
#endif
}
parent_view->AddChild(GetNativeView());
#if BUILDFLAG(IS_EFL)
- if (offscreen_helper_)
- offscreen_helper_->SetAuraParentWindow(parent_view);
+ efl_helper_->SetAuraParentWindow(parent_view);
#endif
device_scale_factor_ = GetDeviceScaleFactor();
window_->Focus();
#if BUILDFLAG(IS_EFL)
- if (offscreen_helper_)
- offscreen_helper_->Focus(true);
+ efl_helper_->Focus(true);
#endif
}
#if BUILDFLAG(IS_EFL)
void RenderWidgetHostViewAura::BackgroundColorReceived(int callback_id,
SkColor bg_color) {
- if (offscreen_helper_)
- offscreen_helper_->BackgroundColorReceived(callback_id, bg_color);
+ efl_helper_->BackgroundColorReceived(callback_id, bg_color);
}
void RenderWidgetHostViewAura::DidGetContentSnapshot(const SkBitmap& bitmap,
int request_id) {
- if (offscreen_helper_)
- offscreen_helper_->DidGetContentSnapshot(bitmap, request_id);
+ efl_helper_->DidGetContentSnapshot(bitmap, request_id);
}
void RenderWidgetHostViewAura::DidHandleKeyEvent(
blink::WebInputEvent::Type input_event_type,
bool processed) {
- if (offscreen_helper_)
- offscreen_helper_->DidHandleKeyEvent(input_event_type, processed);
+ efl_helper_->DidHandleKeyEvent(input_event_type, processed);
}
void RenderWidgetHostViewAura::SelectionChanged(const std::u16string& text,
size_t offset,
const gfx::Range& range) {
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
-
- if (offscreen_helper_)
- offscreen_helper_->SelectionChanged(text, offset, range);
+ efl_helper_->SelectionChanged(text, offset, range);
}
void RenderWidgetHostViewAura::TextInputStateChanged(
const ui::mojom::TextInputState& params) {
RenderWidgetHostViewBase::TextInputStateChanged(params);
-
- if (offscreen_helper_)
- offscreen_helper_->TextInputStateChanged(params);
+ efl_helper_->TextInputStateChanged(params);
}
#endif
visibility_ == Visibility::OCCLUDED);
#if BUILDFLAG(IS_EFL)
- if (offscreen_helper_)
- offscreen_helper_->Hide();
+ efl_helper_->Hide();
#endif
if (!host()->is_hidden()) {
gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() {
#if BUILDFLAG(IS_EFL)
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableOffscreenRendering) &&
- offscreen_helper_) {
- return offscreen_helper_->GetVisibleViewportSize();
- }
+ if (efl_helper_->IsOffscreenMode())
+ return efl_helper_->GetVisibleViewportSize();
#endif
gfx::Rect requested_rect(GetRequestedRendererSize());
requested_rect.Inset(insets_);
UpdateScreenInfo();
#if BUILDFLAG(IS_EFL)
- if (offscreen_helper_)
- offscreen_helper_->Show();
+ efl_helper_->Show();
#endif
// If the viz::LocalSurfaceId is invalid, we may have been evicted,
if (overscroll_controller_)
overscroll_controller_->OnDidOverscroll(params);
#if BUILDFLAG(IS_EFL)
- if (offscreen_helper_)
- offscreen_helper_->DidOverscroll(params);
+ efl_helper_->DidOverscroll(params);
#endif
}
#if BUILDFLAG(IS_EFL)
if (touch.event.GetType() == blink::WebInputEvent::Type::kTouchStart)
- offscreen_helper_->SetTouchStartConsumed(result == ui::ER_HANDLED);
+ efl_helper_->SetTouchStartConsumed(result == ui::ER_HANDLED);
if (touch.event.GetType() == blink::WebInputEvent::Type::kTouchEnd)
- offscreen_helper_->SetTouchEndConsumed(result == ui::ER_HANDLED);
+ efl_helper_->SetTouchEndConsumed(result == ui::ER_HANDLED);
#endif
// Only send acks for one changed touch point.
has_composition_text_ = false;
#if defined(USE_EFL)
- if (offscreen_helper_) {
- offscreen_helper_->FocusedNodeChanged(
- editable
+ efl_helper_->FocusedNodeChanged(
+ editable
#if BUILDFLAG(IS_TIZEN_TV)
- ,
- is_radio_or_checkbox, password_input_minlength, input_maxlength
+ ,
+ is_radio_or_checkbox, password_input_minlength, input_maxlength
#endif
- ,
- is_content_editable);
- }
+ ,
+ is_content_editable);
#endif
#if BUILDFLAG(IS_WIN)
void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
last_pointer_type_ = event->details().primary_pointer_type();
#if BUILDFLAG(IS_EFL)
- // Gesture event will be processed and forwarded via offscreen helper.
- if (offscreen_helper_) {
- offscreen_helper_->OnGestureEvent(event);
- return;
- }
+ // Gesture event will be processed and forwarded via efl helper.
+ efl_helper_->OnGestureEvent(event);
+ return;
#endif
event_handler_->OnGestureEvent(event);
}
}
#if BUILDFLAG(IS_EFL)
+RWHVAuraOffscreenHelperEfl* RenderWidgetHostViewAura::offscreen_helper() {
+ if (!efl_helper_->IsOffscreenMode()) {
+ DLOG(INFO) << "Onscreen rendering mode is set";
+ return nullptr;
+ }
+
+ return static_cast<RWHVAuraOffscreenHelperEfl*>(efl_helper_.get());
+}
+
void RenderWidgetHostViewAura::DidChangeInputType(bool is_password_field) {
- if (offscreen_helper_)
- offscreen_helper_->DidChangeInputType(is_password_field);
+ efl_helper_->DidChangeInputType(is_password_field);
}
void RenderWidgetHostViewAura::OnGetFocusedNodeBounds(const gfx::RectF& rect) {
- if (offscreen_helper_)
- offscreen_helper_->OnGetFocusedNodeBounds(rect);
+ efl_helper_->OnGetFocusedNodeBounds(rect);
}
void RenderWidgetHostViewAura::OnGetMainFrameScrollbarVisible(int callback_id,
bool visible) {
- if (offscreen_helper_)
- offscreen_helper_->OnGetMainFrameScrollbarVisible(callback_id, visible);
+ efl_helper_->OnGetMainFrameScrollbarVisible(callback_id, visible);
}
#endif
DCHECK(delegated_frame_host_) << "Cannot be invoked during destruction.";
#if BUILDFLAG(IS_EFL)
- if (offscreen_helper_)
- offscreen_helper_->AuraChildWindowAdded();
+ efl_helper_->AuraChildWindowAdded();
#endif
window_->GetHost()->AddObserver(this);
#if BUILDFLAG(IS_EFL)
void DidChangeInputType(bool is_password_field) override;
aura::Window* window() { return window_; }
- RWHVAuraOffscreenHelperEfl* offscreen_helper() {
- return offscreen_helper_.get();
- }
+ RWHVAuraOffscreenHelperEfl* offscreen_helper();
void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) override;
void DidHandleKeyEvent(blink::WebInputEvent::Type input_event,
bool processed) override;
absl::optional<display::ScopedDisplayObserver> display_observer_;
#if BUILDFLAG(IS_EFL)
- std::unique_ptr<RWHVAuraOffscreenHelperEfl> offscreen_helper_;
+ std::unique_ptr<RWHVAuraCommonHelperEfl> efl_helper_;
#endif
base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_{this};
#if BUILDFLAG(IS_TIZEN)
// Notifes the delegate to enter into drag state.
- void EnterDragState(RenderViewHost* render_view_host);
+ void EnterDragState(RenderViewHost* render_view_host) override;
#endif
// Misc non-view stuff -------------------------------------------------------
"//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.cc",
"//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.h",
+ "//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc",
+ "//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h",
"//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc",
"//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h",
"//tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.cc",
#include <Elementary.h>
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/selection/selection_controller_efl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view_aura.h"
#include "tizen_src/chromium_impl/tizen/system_info.h"
// But according to wcs TC(21~23) context_menu should be displayed,
// when touchevent is consumed. So we should show context_menu again when
// touchevent is consumed.
- if (rwhva->offscreen_helper()->IsTouchstartConsumed() ||
- rwhva->offscreen_helper()->IsTouchendConsumed()) {
+ if (rwhva->offscreen_helper() &&
+ (rwhva->offscreen_helper()->IsTouchstartConsumed() ||
+ rwhva->offscreen_helper()->IsTouchendConsumed())) {
evas_object_show(menu_controller->popup_);
return;
}
ConvertRectToPixels(gfx::Rect(selection_rect), device_scale));
// Consider a webview offset.
- selection_rect_dip.Offset(
- rwhva()->offscreen_helper()->GetViewBoundsInPix().OffsetFromOrigin());
+ if (rwhva()->offscreen_helper()) {
+ selection_rect_dip.Offset(
+ rwhva()->offscreen_helper()->GetViewBoundsInPix().OffsetFromOrigin());
+ }
auto visible_viewport_rect = controller->GetVisibleViewportRect();
RenderViewHost* render_view_host = web_contents_.GetRenderViewHost();
RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>(
render_view_host->GetWidget()->GetView());
- return view ? view->offscreen_helper()->GetSelectionController() : 0;
+ return (view && view->offscreen_helper())
+ ? view->offscreen_helper()->GetSelectionController() : 0;
}
const char* ContextMenuControllerBase::GetSelectedText() {
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "content/browser/renderer_host/rwhv_aura_common_helper_efl.h"
+
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/selection/selection_controller_efl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/browser/web_contents/web_contents_view_aura.h"
+#include "content/common/cursors/webcursor_efl.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "content/public/browser/render_widget_host_helper.h"
+#include "tizen/system_info.h"
+#include "ui/aura/window_tree_host_platform.h"
+#include "ui/base/clipboard/clipboard_helper_efl.h"
+#include "ui/base/ime/linux/input_method_auralinux.h"
+#include "ui/display/screen.h"
+#include "ui/ozone/platform/efl/efl_event_handler.h"
+#include "ui/ozone/platform/efl/efl_input_method_context.h"
+#include "ui/ozone/platform/efl/im_context_efl.h"
+#include "ui/platform_window/platform_window.h"
+
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "ewk/efl_integration/common/application_type.h"
+#endif
+
+namespace content {
+
+namespace {
+
+blink::WebGestureEvent MakeWebGestureEventFromUIEvent(
+ const ui::GestureEvent& event) {
+ return ui::CreateWebGestureEvent(
+ event.details(), event.time_stamp(), event.location_f(),
+ event.root_location_f(), event.flags(), event.unique_touch_event_id());
+}
+
+ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) {
+ if (!event.TimeStamp().since_origin().InMicroseconds())
+ return ui::LatencyInfo();
+
+ // The latency number should only be added if the timestamp is valid.
+ ui::LatencyInfo latency_info;
+ const int64_t time_micros = event.TimeStamp().since_origin().InMicroseconds();
+ latency_info.AddLatencyNumberWithTimestamp(
+ ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
+ base::TimeTicks() + base::Microseconds(time_micros));
+ return latency_info;
+}
+
+class RenderWidgetHostHelperAura : public RenderWidgetHostHelper {
+ public:
+ explicit RenderWidgetHostHelperAura(RWHVAuraCommonHelperEfl* rwhv_helper)
+ : rwhv_helper_(rwhv_helper) {}
+ ~RenderWidgetHostHelperAura() override = default;
+
+ bool HasRenderWidgetHost() const override {
+ return !!rwhv_helper_->GetRenderWidgetHostImpl();
+ }
+
+ void ExtendSelectionAndDelete(int32_t before, int32_t after) override {
+ auto* handler = GetFrameWidgetInputHandler();
+ if (!handler)
+ return;
+
+ handler->ExtendSelectionAndDelete(before, after);
+ }
+
+ void SetCompositionFromExistingText(
+ int32_t start,
+ int32_t end,
+ const std::vector<ui::ImeTextSpan>& ime_text_spans) override {
+ auto* handler = GetFrameWidgetInputHandler();
+ if (!handler)
+ return;
+
+ handler->SetCompositionFromExistingText(start, end, ime_text_spans);
+ }
+
+ void ImeCommitText(const std::u16string& text,
+ const std::vector<ui::ImeTextSpan>& ime_text_spans,
+ const gfx::Range& replacement_range,
+ int relative_cursor_pos) override {
+ auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+ if (!rwhi)
+ return;
+
+ rwhi->ImeCommitText(text, ime_text_spans, replacement_range,
+ relative_cursor_pos);
+ }
+
+ void ImeFinishComposingText(bool keep_selection) override {
+ auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+ if (!rwhi)
+ return;
+
+ rwhi->ImeFinishComposingText(keep_selection);
+ }
+
+ void ImeSetComposition(const std::u16string& text,
+ const std::vector<ui::ImeTextSpan>& ime_text_spans,
+ const gfx::Range& replacement_range,
+ int selection_start,
+ int selection_end) override {
+ auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+ if (!rwhi)
+ return;
+
+ rwhi->ImeSetComposition(text, ime_text_spans, replacement_range,
+ selection_start, selection_end);
+ }
+
+ bool ExistsSelectedText() override {
+ auto* controller = rwhv_helper_->GetSelectionController();
+ if (!controller)
+ return false;
+
+ return controller->ExistsSelectedText();
+ }
+
+ bool ImeHandleKeyEventEnabled() override { return true; }
+
+ gfx::Size GetPhysicalBackingSize() const override {
+ return rwhv_helper_->GetPhysicalBackingSize();
+ }
+
+ Evas_Object* EwkView() const override { return rwhv_helper_->ewk_view(); }
+
+ bool IsOffscreenMode() const override {
+ return rwhv_helper_->IsOffscreenMode();
+ }
+
+ private:
+ blink::mojom::FrameWidgetInputHandler* GetFrameWidgetInputHandler() const {
+ auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+ if (!rwhi)
+ return nullptr;
+
+ return rwhi->GetFrameWidgetInputHandler();
+ }
+
+ RWHVAuraCommonHelperEfl* rwhv_helper_;
+};
+
+} // namespace
+
+RWHVAuraCommonHelperEfl::RWHVAuraCommonHelperEfl(
+ RenderWidgetHostViewAura* rwhva, WebContents* web_contents)
+ : rwhv_aura_(rwhva), web_contents_(web_contents),
+ rwh_helper_(std::make_unique<RenderWidgetHostHelperAura>(this)) {
+ device_scale_factor_ =
+ display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+}
+
+RWHVAuraCommonHelperEfl::~RWHVAuraCommonHelperEfl() = default;
+
+void RWHVAuraCommonHelperEfl::DidChangeInputType(bool is_password_field) {
+ web_contents_->GetDelegate()->DidChangeInputType(is_password_field);
+}
+
+void RWHVAuraCommonHelperEfl::OnSelectionRectReceived(
+ const gfx::Rect& selection_rect) {
+ if (web_contents_) {
+ WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
+ WebContentsViewAura* wcva =
+ static_cast<WebContentsViewAura*>(wc->GetView());
+ wcva->wcva_helper()->OnSelectionRectReceived(selection_rect);
+ }
+}
+
+void RWHVAuraCommonHelperEfl::OnMouseOrTouchEvent(ui::Event* event) {
+ if (event->type() == ui::ET_MOUSE_PRESSED ||
+ event->type() == ui::ET_TOUCH_PRESSED) {
+ FocusRWHVA();
+ }
+}
+
+void RWHVAuraCommonHelperEfl::DidHandleKeyEvent(
+ blink::WebInputEvent::Type input_event_type,
+ bool processed) {
+ if (!GetIMContextEfl())
+ return;
+
+ bool is_keydown = false;
+ switch (input_event_type) {
+ case blink::WebInputEvent::Type::kRawKeyDown:
+ case blink::WebInputEvent::Type::kKeyDown:
+ is_keydown = true;
+ case blink::WebInputEvent::Type::kKeyUp:
+ GetIMContextEfl()->HandleKeyEvent(is_keydown, processed);
+ }
+}
+
+void RWHVAuraCommonHelperEfl::SelectionChanged(const std::u16string& text,
+ size_t offset,
+ const gfx::Range& range) {
+ if (range.start() == range.end() && GetIMContextEfl())
+ GetIMContextEfl()->SetCaretPosition(range.start());
+
+ if (!GetSelectionController())
+ return;
+
+ std::u16string selectedText;
+ if (!text.empty() && !range.is_empty())
+ selectedText = rwhv_aura_->GetSelectedText();
+}
+
+Evas_Object* RWHVAuraCommonHelperEfl::ewk_view() const {
+ auto wci = static_cast<WebContentsImpl*>(web_contents_);
+ if (!wci)
+ return nullptr;
+
+ return static_cast<Evas_Object*>(wci->ewk_view());
+}
+
+void RWHVAuraCommonHelperEfl::FocusRWHVA() {
+ if (!rwhv_aura_->HasFocus())
+ rwhv_aura_->Focus();
+}
+
+void RWHVAuraCommonHelperEfl::SetPageVisibility(bool visible) {
+ LOG(INFO) << __FUNCTION__ << ", visible : " << visible;
+ if (visible) {
+ // Triggers RWHVA::ShowWithVisibility followed by RWHVAHelperEfl::Show
+ web_contents_->WasShown();
+ } else {
+ // Triggers RWHVA::Hide followed by RWHVAHelperEfl::Hide
+ web_contents_->WasHidden();
+ }
+}
+
+bool RWHVAuraCommonHelperEfl::HasSelectableText() {
+ // If the last character of textarea is '\n', We can assume an extra '\n'.
+ // Actually when you insert line break by ENTER key, '\n\n' is stored in
+ // textarea. And If you press delete key, only a '\n' character will be stored
+ // although there is no visible and selectable character in textarea. That's
+ // why we should check whether selection_text contains only one line break.
+ // Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-2230
+ //
+ // Please see below commit for more information.
+ // https://codereview.chromium.org/1785603002
+ std::u16string selection_text = rwhv_aura_->GetSelectedText();
+ return !selection_text.empty() &&
+ base::UTF16ToUTF8(selection_text).compare("\n") != 0;
+}
+
+RenderWidgetHostImpl* RWHVAuraCommonHelperEfl::GetRenderWidgetHostImpl() {
+ return rwhv_aura_->host();
+}
+
+ui::EflEventHandler* RWHVAuraCommonHelperEfl::GetEventHandler() {
+ aura::WindowTreeHost* window_host = rwhv_aura_->window()->GetHost();
+ if (!window_host)
+ return nullptr;
+
+ return static_cast<aura::WindowTreeHostPlatform*>(window_host)
+ ->platform_window()
+ ->GetEventHandler();
+}
+
+ui::IMContextEfl* RWHVAuraCommonHelperEfl::GetIMContextEfl() {
+ // im_context_efl_ is always nullptr on desktop efl.
+#if BUILDFLAG(IS_TIZEN)
+ if (!im_context_efl_) {
+ if (GetEventHandler() && GetEventHandler()->GetIMContextEfl()) {
+ im_context_efl_ = GetEventHandler()->GetIMContextEfl();
+ im_context_efl_->SetRWHHelper(rwh_helper_.get());
+ return im_context_efl_;
+ }
+ LOG(ERROR) << "im_context_efl_ is not set";
+ }
+#endif
+ return im_context_efl_;
+}
+
+gfx::NativeView RWHVAuraCommonHelperEfl::GetNativeView() {
+ return rwhv_aura_->GetNativeView();
+}
+
+void RWHVAuraCommonHelperEfl::TextInputStateChanged(
+ const ui::mojom::TextInputState& params) {
+ auto im_context = GetIMContextEfl();
+ if (!im_context) {
+ LOG(ERROR) << "im_context is nullptr";
+ return;
+ }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (!rwhv_aura_->IsShowing() || !HasFocus())
+#else
+ if (!rwhv_aura_->IsShowing())
+#endif
+ return;
+
+ bool show_ime_if_needed = params.show_ime_if_needed;
+
+ if (show_ime_if_needed && !params.is_user_action)
+ show_ime_if_needed = false;
+
+ // Prevent scroll and zoom for autofocus'ed elements.
+ if (show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
+ // If webview isn't resized yet, return previous IME state.
+ bool is_ime_show = im_context->WebViewWillBeResized()
+ ? !im_context->IsVisible()
+ : im_context->IsVisible();
+ if (im_context && !is_ime_show)
+ is_scrolling_needed_ = true;
+ }
+
+ if (im_context) {
+ im_context->SetIsInFormTag(params.is_in_form_tag);
+#if BUILDFLAG(IS_TIZEN_TV)
+ im_context->UpdateInputMethodState(
+ params.type, params.can_compose_inline, show_ime_if_needed,
+ password_input_minlength_, input_maxlength_);
+#else
+ im_context->UpdateInputMethodState(params.type, params.can_compose_inline,
+ show_ime_if_needed);
+#endif
+ }
+}
+
+void RWHVAuraCommonHelperEfl::FocusedNodeChanged(
+ bool editable
+#if BUILDFLAG(IS_TIZEN_TV)
+ ,
+ bool is_radio_or_checkbox,
+ int password_input_minlength,
+ int input_maxlength
+#endif
+ ,
+ bool is_content_editable) {
+ is_content_editable_ = is_content_editable;
+#if defined(USE_WAYLAND)
+ ClipboardHelperEfl::GetInstance()->SetContentEditable(is_content_editable);
+#endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+ radio_or_checkbox_focused_ = is_radio_or_checkbox;
+ password_input_minlength_ = password_input_minlength;
+ input_maxlength_ = input_maxlength;
+#endif
+
+ auto im_context = GetIMContextEfl();
+ if (im_context && is_focused_node_editable_) {
+ // focus out from an editable node,
+ // need reset ime context.
+ // or else will cause previous preedit text be copied.
+ if (im_context->IsVisible()) {
+ im_context->CancelComposition();
+ } else {
+ // add ime focus out when focus out from an editable node.
+ im_context->OnFocusOut();
+ }
+ }
+ is_focused_node_editable_ = editable;
+}
+
+void RWHVAuraCommonHelperEfl::OnGetMainFrameScrollbarVisible(
+ int callback_id, bool visible) {
+ web_contents_->GetDelegate()->OnGetMainFrameScrollbarVisible(callback_id,
+ visible);
+}
+
+void RWHVAuraCommonHelperEfl::OnGetFocusedNodeBounds(
+ const gfx::RectF& rect) {
+ web_contents_->GetDelegate()->OnDidChangeFocusedNodeBounds(rect);
+}
+
+void RWHVAuraCommonHelperEfl::BackgroundColorReceived(
+ int callback_id, SkColor bg_color) {
+ web_contents_->GetDelegate()->BackgroundColorReceived(callback_id, bg_color);
+}
+
+void RWHVAuraCommonHelperEfl::SetTouchEventsEnabled(bool enabled) {
+ if (auto* event_handler = GetEventHandler())
+ event_handler->SetTouchEventsEnabled(enabled);
+}
+
+bool RWHVAuraCommonHelperEfl::TouchEventsEnabled() {
+ if (auto* event_handler = GetEventHandler())
+ return event_handler->TouchEventsEnabled();
+
+ return false;
+}
+
+void RWHVAuraCommonHelperEfl::OnGestureEvent(ui::GestureEvent* event) {
+ if (event->type() == ui::ET_GESTURE_BEGIN)
+ HandleGestureBegin();
+ else if (event->type() == ui::ET_GESTURE_END)
+ HandleGestureEnd();
+
+ blink::WebGestureEvent gesture_event = MakeWebGestureEventFromUIEvent(*event);
+ gesture_event.SetPositionInWidget(event->location_f());
+ gesture_event.SetPositionInScreen(event->root_location_f());
+ SendGestureEvent(gesture_event);
+
+ event->SetHandled();
+}
+
+void RWHVAuraCommonHelperEfl::SendGestureEvent(
+ blink::WebGestureEvent& event) {
+ HandleGesture(event);
+ blink::WebInputEvent::Type event_type = event.GetType();
+ if (magnifier_ &&
+ event_type == blink::WebInputEvent::Type::kGestureScrollUpdate) {
+ return;
+ }
+
+ // TODO: In this case, double tap should be filtered in
+ // TouchDispositionGestureFilter. (See http://goo.gl/5G8PWJ)
+ if (event_type == blink::WebInputEvent::Type::kGestureDoubleTap &&
+ touchend_consumed_) {
+ return;
+ }
+
+ if (event_type != blink::WebInputEvent::Type::kUndefined) {
+ rwhv_aura_->host()->ForwardGestureEventWithLatencyInfo(
+ event, CreateLatencyInfo(event));
+ }
+}
+
+void RWHVAuraCommonHelperEfl::HandleGesture(blink::WebGestureEvent& event) {
+ SelectionControllerEfl* controller = GetSelectionController();
+ if (controller)
+ controller->HandleGesture(event);
+
+ blink::WebInputEvent::Type event_type = event.GetType();
+ RenderWidgetHostOwnerDelegate* owner_delegate =
+ rwhv_aura_->host()->owner_delegate();
+ if (!owner_delegate)
+ return;
+
+ if (!owner_delegate->GetWebkitPreferencesForWidget().text_zoom_enabled &&
+ (event_type == blink::WebInputEvent::Type::kGesturePinchBegin ||
+ event_type == blink::WebInputEvent::Type::kGesturePinchEnd)) {
+ return;
+ }
+
+ if (!owner_delegate->GetWebkitPreferencesForWidget()
+ .double_tap_to_zoom_enabled &&
+ event_type == blink::WebInputEvent::Type::kGestureDoubleTap) {
+ return;
+ }
+
+ if (event_type == blink::WebInputEvent::Type::kGestureTap ||
+ event_type == blink::WebInputEvent::Type::kGestureTapCancel) {
+ float size = 32.0f; // Default value
+
+#if BUILDFLAG(IS_TIZEN)
+ if (IsMobileProfile())
+ size = elm_config_finger_size_get() / device_scale_factor_;
+#endif
+
+ event.data.tap.width = size;
+ event.data.tap.height = size;
+ }
+}
+
+void RWHVAuraCommonHelperEfl::DidOverscroll(
+ const ui::DidOverscrollParams& params) {
+ if (web_contents_) {
+ WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
+ WebContentsViewAura* wcva =
+ static_cast<WebContentsViewAura*>(wc->GetView());
+ wcva->wcva_helper()->OnOverscrolled(params.accumulated_overscroll,
+ params.latest_overscroll_delta);
+ }
+}
+
+} // namespace content
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
+#define CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
+
+#include <Evas.h>
+
+#include "base/callback.h"
+#include "content/common/cursors/webcursor.h"
+#include "third_party/blink/public/common/input/web_input_event.h"
+#include "third_party/blink/public/common/input/web_gesture_event.h"
+#include "ui/base/ime/mojom/text_input_state.mojom-forward.h"
+#include "ui/events/event.h"
+#include "ui/gfx/geometry/size_f.h"
+#include "ui/gfx/range/range.h"
+
+#if BUILDFLAG(IS_TIZEN_TV)
+#define DEFAULT_MAX_LENGTH std::numeric_limits<int>::max()
+#endif
+
+namespace ui {
+class EflEventHandler;
+class IMContextEfl;
+struct DidOverscrollParams;
+} // namespace ui
+
+namespace content {
+
+class RenderWidgetHostHelper;
+class RenderWidgetHostImpl;
+class RenderWidgetHostViewAura;
+class SelectionControllerEfl;
+class WebContents;
+class WebContentsDelegate;
+
+class CONTENT_EXPORT RWHVAuraCommonHelperEfl {
+ public:
+ RWHVAuraCommonHelperEfl(
+ RenderWidgetHostViewAura* rwhva, WebContents* web_contents);
+ virtual ~RWHVAuraCommonHelperEfl();
+
+ virtual void SetAuraParentWindow(gfx::NativeView parent_view) {}
+ virtual void AuraChildWindowAdded() {}
+ virtual void NotifySwap(const size_t texture_id) {}
+ virtual void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) {}
+ virtual void Show() {}
+ virtual void Hide() {}
+ virtual void Focus(bool focus) {}
+ virtual bool HasFocus() { return false; }
+ virtual gfx::Size GetVisibleViewportSize() { return gfx::Size(); }
+ virtual gfx::Size GetPhysicalBackingSize() const { return gfx::Size(); }
+ virtual void HandleGestureBegin() {}
+ virtual void HandleGestureEnd() {}
+ virtual void HandleGesture(blink::WebGestureEvent& event);
+ virtual void DidOverscroll(const ui::DidOverscrollParams& params);
+ virtual gfx::Rect GetViewBounds() { return gfx::Rect(); }
+
+ bool IsOffscreenMode() { return is_offscreen_mode_; }
+ Evas_Object* ewk_view() const;
+ SelectionControllerEfl* GetSelectionController() const {
+ return selection_controller_.get();
+ }
+ RenderWidgetHostImpl* GetRenderWidgetHostImpl();
+ gfx::NativeView GetNativeView();
+ WebContents* GetWebContents() { return web_contents_; }
+ void SetPageVisibility(bool visible);
+
+ bool HasSelectableText();
+ void set_magnifier(bool status) { magnifier_ = status; }
+ bool IsTouchstartConsumed() const { return touchstart_consumed_; }
+ bool IsTouchendConsumed() const { return touchend_consumed_; }
+ void SetTouchStartConsumed(bool touchstart_consumed) {
+ touchstart_consumed_ = touchstart_consumed;
+ }
+ void SetTouchEndConsumed(bool touchend_consumed) {
+ touchend_consumed_ = touchend_consumed;
+ }
+ void SetTouchEventsEnabled(bool enabled);
+ bool TouchEventsEnabled();
+ bool IsFocusedNodeContentEditable() const { return is_content_editable_; }
+
+ void OnMouseOrTouchEvent(ui::Event* event);
+ void FocusedNodeChanged(bool editable,
+#if BUILDFLAG(IS_TIZEN_TV)
+ bool is_radio_or_checkbox,
+ int password_input_minlength,
+ int input_maxlength,
+#endif
+ bool is_content_editable);
+
+ void OnGestureEvent(ui::GestureEvent* event);
+ void DidChangeInputType(bool is_password_field);
+ void BackgroundColorReceived(int callback_id, SkColor bg_color);
+ void OnGetFocusedNodeBounds(const gfx::RectF& rect);
+ void DidHandleKeyEvent(
+ blink::WebInputEvent::Type input_event_type, bool processed);
+ void SelectionChanged(
+ const std::u16string& text, size_t offset, const gfx::Range& range);
+ void OnGetMainFrameScrollbarVisible(int callback_id, bool visible);
+ void TextInputStateChanged(const ui::mojom::TextInputState& params);
+ void OnSelectionRectReceived(const gfx::Rect& selection_rect);
+
+ protected:
+ void SetOffscreenMode() { is_offscreen_mode_ = true; }
+ RenderWidgetHostViewAura* rwhva() { return rwhv_aura_; }
+ ui::IMContextEfl* GetIMContextEfl();
+ void FocusRWHVA();
+ void SendGestureEvent(blink::WebGestureEvent& event);
+
+ float device_scale_factor_ = 1.0f;
+
+ private:
+ ui::EflEventHandler* GetEventHandler();
+
+ bool is_focused_node_editable_ = false;
+ bool is_scrolling_needed_ = false;
+ bool touchstart_consumed_ = false;
+ bool touchend_consumed_ = false;
+
+ ui::IMContextEfl* im_context_efl_ = nullptr;
+ RenderWidgetHostViewAura* rwhv_aura_ = nullptr;
+ WebContents* web_contents_ = nullptr;
+ std::unique_ptr<SelectionControllerEfl> selection_controller_;
+
+ bool magnifier_ = false;
+ bool is_content_editable_ = false;
+ bool is_offscreen_mode_ = false;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+ bool radio_or_checkbox_focused_ = false;
+ int password_input_minlength_ = -1;
+ int input_maxlength_ = DEFAULT_MAX_LENGTH;
+#endif
+
+ std::unique_ptr<RenderWidgetHostHelper> rwh_helper_;
+
+ RWHVAuraCommonHelperEfl(const RWHVAuraCommonHelperEfl&) = delete;
+ RWHVAuraCommonHelperEfl& operator=(const RWHVAuraCommonHelperEfl&) = delete;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
#include "base/base_switches.h"
#include "content/browser/renderer_host/edge_effect.h"
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/selection/selection_controller_efl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view_aura.h"
#include "content/public/browser/render_widget_host_helper.h"
-#include "content/public/browser/web_contents_delegate.h"
#include "ecore_x_wayland_wrapper.h"
#include "gpu/command_buffer/service/texture_base.h"
#include "skia/ext/image_operations.h"
namespace content {
-namespace {
-
-blink::WebGestureEvent MakeWebGestureEventFromUIEvent(
- const ui::GestureEvent& event) {
- return ui::CreateWebGestureEvent(
- event.details(), event.time_stamp(), event.location_f(),
- event.root_location_f(), event.flags(), event.unique_touch_event_id());
-}
-
-ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) {
- if (!event.TimeStamp().since_origin().InMicroseconds())
- return ui::LatencyInfo();
-
- // The latency number should only be added if the timestamp is valid.
- ui::LatencyInfo latency_info;
- const int64_t time_micros = event.TimeStamp().since_origin().InMicroseconds();
- latency_info.AddLatencyNumberWithTimestamp(
- ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
- base::TimeTicks() + base::Microseconds(time_micros));
- return latency_info;
-}
-
-} // namespace
-
// If the first frame is not prepared after load is finished,
// delay getting the snapshot by 100ms.
static const int kSnapshotProcessDelay = 100;
RWHVAuraOffscreenHelperEfl::RWHVAuraOffscreenHelperEfl(
RenderWidgetHostViewAura* rwhva,
WebContents* web_contents)
- : rwhv_aura_(rwhva),
- web_contents_(web_contents),
- rwh_helper_(std::make_unique<RenderWidgetHostHelperAura>(this)) {
+ : RWHVAuraCommonHelperEfl(rwhva, web_contents) {
+ SetOffscreenMode();
Initialize();
}
void RWHVAuraOffscreenHelperEfl::Initialize() {
parent_view_ =
- static_cast<WebContentsImpl*>(web_contents_)->GetEflNativeView();
+ static_cast<WebContentsImpl*>(GetWebContents())->GetEflNativeView();
evas_ = evas_object_evas_get(parent_view_);
InitEvasGL();
snapshot_timer_.reset(new base::OneShotTimer);
}
-void RWHVAuraOffscreenHelperEfl::SetAuraParentWindow(
- gfx::NativeView parent_window) {
- aura_parent_window_ = parent_window;
-}
-
void RWHVAuraOffscreenHelperEfl::AuraChildWindowAdded() {
- aura::WindowTreeHost* window_host = rwhv_aura_->window()->GetHost();
+ aura::WindowTreeHost* window_host = rwhva()->window()->GetHost();
if (!window_host)
return;
RWHVAuraOffscreenHelperEfl* thiz =
static_cast<RWHVAuraOffscreenHelperEfl*>(data);
gfx::Rect new_bounds(thiz->CreateNativeSurface());
- aura::WindowTreeHost* window_host = thiz->rwhv_aura_->window()->GetHost();
+ aura::WindowTreeHost* window_host = thiz->rwhva()->window()->GetHost();
if (window_host)
window_host->SetBoundsInPixels(new_bounds);
evas_gl_make_current(evas_gl_, 0, 0);
}
-void RWHVAuraOffscreenHelperEfl::DidChangeInputType(bool is_password_field) {
- web_contents_->GetDelegate()->DidChangeInputType(is_password_field);
-}
-
-void RWHVAuraOffscreenHelperEfl::OnSelectionRectReceived(
- const gfx::Rect& selection_rect) {
- if (web_contents_) {
- WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
- WebContentsViewAura* wcva =
- static_cast<WebContentsViewAura*>(wc->GetView());
- wcva->wcva_helper()->OnSelectionRectReceived(selection_rect);
- }
-}
-
void RWHVAuraOffscreenHelperEfl::PaintTextureToSurface(GLuint texture_id) {
int x, y, width = 0, height = 0;
evas_object_geometry_get(parent_view_, &x, &y, &width, &height);
void* event_info) {
RWHVAuraOffscreenHelperEfl* thiz =
static_cast<RWHVAuraOffscreenHelperEfl*>(data);
- aura::WindowTreeHost* window_host = thiz->rwhv_aura_->window()->GetHost();
+ aura::WindowTreeHost* window_host = thiz->rwhva()->window()->GetHost();
if (!window_host || !window_host->window())
return;
thiz->GetRenderWidgetHostImpl()->Blur();
}
-void RWHVAuraOffscreenHelperEfl::OnMouseOrTouchEvent(ui::Event* event) {
- if (event->type() == ui::ET_MOUSE_PRESSED ||
- event->type() == ui::ET_TOUCH_PRESSED) {
- FocusRWHVA();
- }
-}
-
-void RWHVAuraOffscreenHelperEfl::DidHandleKeyEvent(
- blink::WebInputEvent::Type input_event_type,
- bool processed) {
- if (!GetIMContextEfl())
- return;
-
- bool is_keydown = false;
- switch (input_event_type) {
- case blink::WebInputEvent::Type::kRawKeyDown:
- case blink::WebInputEvent::Type::kKeyDown:
- is_keydown = true;
- case blink::WebInputEvent::Type::kKeyUp:
- GetIMContextEfl()->HandleKeyEvent(is_keydown, processed);
- }
-}
-
-void RWHVAuraOffscreenHelperEfl::SelectionChanged(const std::u16string& text,
- size_t offset,
- const gfx::Range& range) {
- if (range.start() == range.end() && GetIMContextEfl())
- GetIMContextEfl()->SetCaretPosition(range.start());
-
- if (!GetSelectionController())
- return;
-
- std::u16string selectedText;
- if (!text.empty() && !range.is_empty())
- selectedText = rwhv_aura_->GetSelectedText();
-}
-
void RWHVAuraOffscreenHelperEfl::EvasToBlinkCords(int x,
int y,
int* view_x,
if (!callback)
return;
- if (rwhv_aura_->IsShowing() && evas_focus_get(evas_))
+ if (rwhva()->IsShowing() && evas_focus_get(evas_))
callback->Run(GetSnapshot(snapshot_area, scale_factor));
screen_capture_cb_map_.Remove(request_id);
}
}
const gfx::Rect window_rect = gfx::ToEnclosingRect(gfx::ConvertRectToPixels(
- rwhv_aura_->GetBoundsInRootWindow(), device_scale_factor_));
+ rwhva()->GetBoundsInRootWindow(), device_scale_factor_));
// |view_rect| is absolute coordinate of webview.
gfx::Rect view_rect = GetViewBoundsInPix();
int request_id = screen_capture_cb_map_.Add(base::WrapUnique(cb));
- if (rwhv_aura_->IsShowing() && evas_focus_get(evas_)) {
+ if (rwhva()->IsShowing() && evas_focus_get(evas_)) {
// Create a snapshot task that will be executed after frame
// is generated and drawn to surface.
snapshot_task_list_.push_back(base::BindOnce(
base::Unretained(this)));
} else {
// Sends message to renderer to capture the content snapshot of the view.
- rwhv_aura_->host()->RequestContentSnapshot(snapshot_area, scale_factor,
+ rwhva()->host()->RequestContentSnapshot(snapshot_area, scale_factor,
request_id);
}
}
screen_capture_cb_map_.Remove(request_id);
}
-Evas_Object* RWHVAuraOffscreenHelperEfl::ewk_view() const {
- auto wci = static_cast<WebContentsImpl*>(web_contents_);
- if (!wci)
- return nullptr;
-
- return static_cast<Evas_Object*>(wci->ewk_view());
-}
-
-void RWHVAuraOffscreenHelperEfl::FocusRWHVA() {
- if (!rwhv_aura_->HasFocus())
- rwhv_aura_->Focus();
-}
-
void RWHVAuraOffscreenHelperEfl::Show() {
evas_object_show(content_image_elm_host_);
}
if (custom_viewport_size_ != size) {
custom_viewport_size_ = size;
// Take the view port change into account.
- rwhv_aura_->host()->SynchronizeVisualProperties();
+ rwhva()->host()->SynchronizeVisualProperties();
}
}
gfx::ConvertRectToDips(GetViewBoundsInPix(), device_scale_factor_));
}
-void RWHVAuraOffscreenHelperEfl::SetPageVisibility(bool visible) {
- LOG(INFO) << __FUNCTION__ << ", visible : " << visible;
- if (visible) {
- // Triggers RWHVA::ShowWithVisibility followed by RWHVAHelperEfl::Show
- web_contents_->WasShown();
- } else {
- // Triggers RWHVA::Hide followed by RWHVAHelperEfl::Hide
- web_contents_->WasHidden();
- }
-}
-
-RenderWidgetHostImpl* RWHVAuraOffscreenHelperEfl::GetRenderWidgetHostImpl() {
- return rwhv_aura_->host();
-}
-
-ui::EflEventHandler* RWHVAuraOffscreenHelperEfl::GetEventHandler() {
- aura::WindowTreeHost* window_host = rwhv_aura_->window()->GetHost();
- if (!window_host)
- return nullptr;
-
- return static_cast<aura::WindowTreeHostPlatform*>(window_host)
- ->platform_window()
- ->GetEventHandler();
-}
-
-ui::IMContextEfl* RWHVAuraOffscreenHelperEfl::GetIMContextEfl() {
- // im_context_efl_ is always nullptr on desktop efl.
-#if BUILDFLAG(IS_TIZEN)
- if (!im_context_efl_) {
- im_context_efl_ =
- GetEventHandler() ? GetEventHandler()->GetIMContextEfl() : nullptr;
- if (im_context_efl_)
- im_context_efl_->SetRWHHelper(rwh_helper_.get());
- else
- LOG(ERROR) << "im_context_efl_ is not set";
- }
-#endif
- return im_context_efl_;
-}
-
-gfx::NativeView RWHVAuraOffscreenHelperEfl::GetNativeView() {
- return rwhv_aura_->GetNativeView();
-}
-
gfx::Point RWHVAuraOffscreenHelperEfl::ConvertPointInViewPix(gfx::Point point) {
return gfx::ToFlooredPoint(
gfx::ScalePoint(gfx::PointF(point), device_scale_factor_));
}
-void RWHVAuraOffscreenHelperEfl::TextInputStateChanged(
- const ui::mojom::TextInputState& params) {
- auto im_context = GetIMContextEfl();
- if (!im_context) {
- LOG(ERROR) << "im_context is nullptr";
- return;
- }
-
-#if BUILDFLAG(IS_TIZEN_TV)
- if (!rwhv_aura_->IsShowing() || !HasFocus())
-#else
- if (!rwhv_aura_->IsShowing())
-#endif
- return;
-
- bool show_ime_if_needed = params.show_ime_if_needed;
-
- if (show_ime_if_needed && !params.is_user_action)
- show_ime_if_needed = false;
-
- // Prevent scroll and zoom for autofocus'ed elements.
- if (show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
- // If webview isn't resized yet, return previous IME state.
- bool is_ime_show = im_context->WebViewWillBeResized()
- ? !im_context->IsVisible()
- : im_context->IsVisible();
- if (im_context && !is_ime_show)
- is_scrolling_needed_ = true;
- }
-
- if (im_context) {
- im_context->SetIsInFormTag(params.is_in_form_tag);
-#if BUILDFLAG(IS_TIZEN_TV)
- im_context->UpdateInputMethodState(
- params.type, params.can_compose_inline, show_ime_if_needed,
- password_input_minlength_, input_maxlength_);
-#else
- im_context->UpdateInputMethodState(params.type, params.can_compose_inline,
- show_ime_if_needed);
-#endif
- }
-}
-
void RWHVAuraOffscreenHelperEfl::MoveCaret(const gfx::Point& point) {
- if (auto* delegate = rwhv_aura_->host()->delegate()) {
+ if (auto* delegate = rwhva()->host()->delegate()) {
delegate->MoveCaret(gfx::Point(point.x() / device_scale_factor_,
point.y() / device_scale_factor_));
}
int view_x, view_y;
EvasToBlinkCords(touch_point.x(), touch_point.y(), &view_x, &view_y);
- rwhv_aura_->host()->SelectClosestWord(view_x, view_y);
-}
-
-bool RWHVAuraOffscreenHelperEfl::HasSelectableText() {
- // If the last character of textarea is '\n', We can assume an extra '\n'.
- // Actually when you insert line break by ENTER key, '\n\n' is stored in
- // textarea. And If you press delete key, only a '\n' character will be stored
- // although there is no visible and selectable character in textarea. That's
- // why we should check whether selection_text contains only one line break.
- // Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-2230
- //
- // Please see below commit for more information.
- // https://codereview.chromium.org/1785603002
- std::u16string selection_text = rwhv_aura_->GetSelectedText();
- return !selection_text.empty() &&
- base::UTF16ToUTF8(selection_text).compare("\n") != 0;
-}
-
-void RWHVAuraOffscreenHelperEfl::FocusedNodeChanged(
- bool editable
-#if BUILDFLAG(IS_TIZEN_TV)
- ,
- bool is_radio_or_checkbox,
- int password_input_minlength,
- int input_maxlength
-#endif
- ,
- bool is_content_editable) {
- is_content_editable_ = is_content_editable;
-#if defined(USE_WAYLAND)
- ClipboardHelperEfl::GetInstance()->SetContentEditable(is_content_editable);
-#endif
-
-#if BUILDFLAG(IS_TIZEN_TV)
- radio_or_checkbox_focused_ = is_radio_or_checkbox;
- password_input_minlength_ = password_input_minlength;
- input_maxlength_ = input_maxlength;
-#endif
-
- auto im_context = GetIMContextEfl();
- if (im_context && is_focused_node_editable_) {
- // focus out from an editable node,
- // need reset ime context.
- // or else will cause previous preedit text be copied.
- if (im_context->IsVisible()) {
- im_context->CancelComposition();
- } else {
- // add ime focus out when focus out from an editable node.
- im_context->OnFocusOut();
- }
- }
- is_focused_node_editable_ = editable;
+ rwhva()->host()->SelectClosestWord(view_x, view_y);
}
gfx::Size RWHVAuraOffscreenHelperEfl::GetPhysicalBackingSize() const {
}
#endif
-void RWHVAuraOffscreenHelperEfl::OnGetMainFrameScrollbarVisible(int callback_id,
- bool visible) {
- web_contents_->GetDelegate()->OnGetMainFrameScrollbarVisible(callback_id,
- visible);
-}
-
-void RWHVAuraOffscreenHelperEfl::OnGetFocusedNodeBounds(
- const gfx::RectF& rect) {
- web_contents_->GetDelegate()->OnDidChangeFocusedNodeBounds(rect);
-}
-
-void RWHVAuraOffscreenHelperEfl::BackgroundColorReceived(int callback_id,
- SkColor bg_color) {
- web_contents_->GetDelegate()->BackgroundColorReceived(callback_id, bg_color);
-}
-
-void RWHVAuraOffscreenHelperEfl::SetTouchEventsEnabled(bool enabled) {
- if (auto* event_handler = GetEventHandler())
- event_handler->SetTouchEventsEnabled(enabled);
-}
-
-bool RWHVAuraOffscreenHelperEfl::TouchEventsEnabled() {
- if (auto* event_handler = GetEventHandler())
- return event_handler->TouchEventsEnabled();
-
- return false;
-}
-
EdgeEffect& RWHVAuraOffscreenHelperEfl::EnsureEdgeEffect() {
if (!edge_effect_) {
edge_effect_ = base::WrapUnique(new EdgeEffect(content_image_));
EnsureEdgeEffect().Disable();
}
-void RWHVAuraOffscreenHelperEfl::OnGestureEvent(ui::GestureEvent* event) {
- if (event->type() == ui::ET_GESTURE_BEGIN)
- HandleGestureBegin();
- else if (event->type() == ui::ET_GESTURE_END)
- HandleGestureEnd();
-
- blink::WebGestureEvent gesture_event = MakeWebGestureEventFromUIEvent(*event);
- gesture_event.SetPositionInWidget(event->location_f());
- gesture_event.SetPositionInScreen(event->root_location_f());
- SendGestureEvent(gesture_event);
-
- event->SetHandled();
-}
-
-void RWHVAuraOffscreenHelperEfl::SendGestureEvent(
- blink::WebGestureEvent& event) {
- HandleGesture(event);
- blink::WebInputEvent::Type event_type = event.GetType();
- if (magnifier_ &&
- event_type == blink::WebInputEvent::Type::kGestureScrollUpdate) {
- return;
- }
-
- // TODO: In this case, double tap should be filtered in
- // TouchDispositionGestureFilter. (See http://goo.gl/5G8PWJ)
- if (event_type == blink::WebInputEvent::Type::kGestureDoubleTap &&
- touchend_consumed_) {
- return;
- }
-
- if (event_type != blink::WebInputEvent::Type::kUndefined) {
- rwhv_aura_->host()->ForwardGestureEventWithLatencyInfo(
- event, CreateLatencyInfo(event));
- }
-}
-
-void RWHVAuraOffscreenHelperEfl::set_magnifier(bool status) {
- magnifier_ = status;
-}
-
void RWHVAuraOffscreenHelperEfl::GetMagnifierSnapshot(
gfx::Rect snapshot_area,
float scale_factor,
gfx::Rect view_rect = GetViewBoundsInPix();
// Adjust snapshot rect for email app
- auto visible_viewport_rect = selection_controller_->GetVisibleViewportRect();
+ auto visible_viewport_rect =
+ GetSelectionController()->GetVisibleViewportRect();
int hidden_view_width = visible_viewport_rect.x() - view_rect.x();
int hidden_view_height = visible_viewport_rect.y() - view_rect.y();
if (hidden_view_height || hidden_view_width) {
}
void RWHVAuraOffscreenHelperEfl::HandleGesture(blink::WebGestureEvent& event) {
- SelectionControllerEfl* controller = GetSelectionController();
- if (controller)
- controller->HandleGesture(event);
+ RWHVAuraCommonHelperEfl::HandleGesture(event);
blink::WebInputEvent::Type event_type = event.GetType();
- RenderWidgetHostOwnerDelegate* owner_delegate =
- rwhv_aura_->host()->owner_delegate();
- if (!owner_delegate)
- return;
-
- if (!owner_delegate->GetWebkitPreferencesForWidget().text_zoom_enabled &&
- (event_type == blink::WebInputEvent::Type::kGesturePinchBegin ||
- event_type == blink::WebInputEvent::Type::kGesturePinchEnd)) {
- return;
- }
-
- if (!owner_delegate->GetWebkitPreferencesForWidget()
- .double_tap_to_zoom_enabled &&
- event_type == blink::WebInputEvent::Type::kGestureDoubleTap) {
- return;
- }
-
- if (event_type == blink::WebInputEvent::Type::kGestureTap ||
- event_type == blink::WebInputEvent::Type::kGestureTapCancel) {
- float size = 32.0f; // Default value
-
-#if BUILDFLAG(IS_TIZEN)
- if (IsMobileProfile())
- size = elm_config_finger_size_get() / device_scale_factor_;
-#endif
-
- event.data.tap.width = size;
- event.data.tap.height = size;
- }
if (event_type == blink::WebInputEvent::Type::kGestureTapDown) {
// Webkit does not stop a fling-scroll on tap-down. So explicitly send an
void RWHVAuraOffscreenHelperEfl::DidOverscroll(
const ui::DidOverscrollParams& params) {
- if (web_contents_) {
- WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
- WebContentsViewAura* wcva =
- static_cast<WebContentsViewAura*>(wc->GetView());
- wcva->wcva_helper()->OnOverscrolled(params.accumulated_overscroll,
- params.latest_overscroll_delta);
- }
+ RWHVAuraCommonHelperEfl::DidOverscroll(params);
const gfx::Vector2dF& accumulated_overscroll = params.accumulated_overscroll;
const gfx::Vector2dF& latest_overscroll_delta =
EnsureEdgeEffect().UpdateRect();
}
-void RWHVAuraOffscreenHelperEfl::SetTouchStartConsumed(
- bool touchstart_consumed) {
- touchstart_consumed_ = touchstart_consumed;
-}
-void RWHVAuraOffscreenHelperEfl::SetTouchEndConsumed(bool touchend_consumed) {
- touchend_consumed_ = touchend_consumed;
-}
} // namespace content
#include <list>
-#include <Evas.h>
#include <Evas_GL.h>
#include <Ecore.h>
#include <Ecore_Input.h>
#include <Elementary.h>
-#include "base/callback.h"
#include "base/containers/id_map.h"
#include "base/timer/timer.h"
-#include "content/browser/selection/selection_controller_efl.h"
-#include "content/common/cursors/webcursor.h"
-#include "third_party/blink/public/common/input/web_input_event.h"
-#include "ui/base/ime/mojom/text_input_state.mojom-forward.h"
-#include "ui/events/event.h"
-#include "ui/gfx/geometry/size_f.h"
+#include "content/browser/renderer_host/rwhv_aura_common_helper_efl.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/range/range.h"
-
-#if BUILDFLAG(IS_TIZEN_TV)
-#define DEFAULT_MAX_LENGTH std::numeric_limits<int>::max()
-#endif
-
-namespace ui {
-class EflEventHandler;
-class IMContextEfl;
-struct DidOverscrollParams;
-} // namespace ui
namespace content {
void* user_data);
typedef base::OnceCallback<void()> SnapshotTask;
-class RenderWidgetHostHelper;
-class RenderWidgetHostImpl;
-class RenderWidgetHostViewAura;
class ScreenshotCapturedCallback;
-class WebContents;
-class WebContentsDelegate;
class EdgeEffect;
-class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
+class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl
+ : public RWHVAuraCommonHelperEfl {
public:
using OnFocusCallback = base::RepeatingCallback<void(void)>;
RWHVAuraOffscreenHelperEfl(RenderWidgetHostViewAura* rwhva,
WebContents* web_contents);
- ~RWHVAuraOffscreenHelperEfl();
-
- void SetAuraParentWindow(gfx::NativeView parent_window);
- void AuraChildWindowAdded();
- void NotifySwap(const size_t texture_id);
- void BackgroundColorReceived(int callback_id, SkColor bg_color);
- void Show();
- void Hide();
- void OnGetMainFrameScrollbarVisible(int callback_id, bool visible);
-
- gfx::Size GetVisibleViewportSize();
- gfx::Rect GetViewBounds();
- void SetCustomViewportSize(const gfx::Size& size);
- gfx::Size GetPhysicalBackingSize() const;
- void OnGetFocusedNodeBounds(const gfx::RectF& rect);
+ ~RWHVAuraOffscreenHelperEfl() override;
- void SetTouchStartConsumed(bool touchstart_consumed);
- void SetTouchEndConsumed(bool touchend_consumed);
- bool IsTouchstartConsumed() const { return touchstart_consumed_; }
- bool IsTouchendConsumed() const { return touchend_consumed_; }
-
- void SetTouchEventsEnabled(bool enabled);
- bool TouchEventsEnabled();
+ // RWHVAuraCommonHelperEfl overrides
+ void SetAuraParentWindow(gfx::NativeView parent_window) override {
+ aura_parent_window_ = parent_window;
+ }
+ void AuraChildWindowAdded() override;
+ void NotifySwap(const size_t texture_id) override;
+ void Show() override;
+ void Hide() override;
+ gfx::Size GetVisibleViewportSize() override;
+ gfx::Rect GetViewBounds() override;
+ gfx::Size GetPhysicalBackingSize() const override;
+ void HandleGestureBegin() override;
+ void HandleGestureEnd() override;
+ void HandleGesture(blink::WebGestureEvent& event) override;
+ void DidOverscroll(const ui::DidOverscrollParams& params) override;
+ void Focus(bool focus) override;
+ bool HasFocus() override;
+ void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) override;
+ void SetCustomViewportSize(const gfx::Size& size);
bool GetHorizontalPanningHold() const { return horizontal_panning_hold_; }
void SetHorizontalPanningHold(bool hold) { horizontal_panning_hold_ = hold; }
bool GetVerticalPanningHold() const { return vertical_panning_hold_; }
void SetVerticalPanningHold(bool hold) { vertical_panning_hold_ = hold; }
- void DidChangeInputType(bool is_password_field);
- void OnSelectionRectReceived(const gfx::Rect& selection_rect);
-
#if BUILDFLAG(IS_TIZEN_TV)
void DrawLabel(Evas_Object* image, Eina_Rectangle rect);
void ClearLabels();
}
int GetTopControlsHeight();
- void DidOverscroll(const ui::DidOverscrollParams& params);
#if BUILDFLAG(IS_TIZEN)
void OnEdgeEffectForUIF(bool, bool, bool, bool);
#endif
- void Focus(bool focus);
- bool HasFocus();
- void SetPageVisibility(bool visible);
- void TextInputStateChanged(const ui::mojom::TextInputState& params);
- void FocusedNodeChanged(bool editable
-#if BUILDFLAG(IS_TIZEN_TV)
- ,
- bool is_radio_or_checkbox,
- int password_input_minlength,
- int input_maxlength
-#endif
- ,
- bool is_content_editable);
-
// |snapshot_area| is relative coordinate system based on Webview.
// (0,0) is top left corner.
Evas_Object* GetSnapshot(const gfx::Rect& snapshot_area,
Screenshot_Captured_Callback callback,
void* user_data,
float scale_factor = 1.0);
- void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id);
- RenderWidgetHostViewAura* rwhva() { return rwhv_aura_; }
- void OnGestureEvent(ui::GestureEvent* event);
EdgeEffect& EnsureEdgeEffect();
void UpdateEdgeEffect();
- void HandleGestureBegin();
- void HandleGestureEnd();
- void SendGestureEvent(blink::WebGestureEvent& event);
- void HandleGesture(blink::WebGestureEvent& event);
- void OnMouseOrTouchEvent(ui::Event* event);
- void DidHandleKeyEvent(blink::WebInputEvent::Type input_event_type,
- bool processed);
- void SelectionChanged(const std::u16string& text,
- size_t offset,
- const gfx::Range& range);
- SelectionControllerEfl* GetSelectionController() const {
- return selection_controller_.get();
- }
void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
- Evas_Object* ewk_view() const;
Evas_Object* content_image() const { return content_image_; }
Evas_Object* content_image_elm_host() const {
return content_image_elm_host_;
}
gfx::Point ConvertPointInViewPix(gfx::Point point);
- RenderWidgetHostImpl* GetRenderWidgetHostImpl();
- gfx::NativeView GetNativeView();
- WebContents* GetWebContents() { return web_contents_; }
void SetFocusInOutCallbacks(const OnFocusCallback& on_focus_in,
const OnFocusCallback& on_focus_out);
-
- bool IsFocusedNodeContentEditable() const { return is_content_editable_; }
-
void MoveCaret(const gfx::Point& point);
void SelectClosestWord(const gfx::Point& touch_point);
- bool HasSelectableText();
- void set_magnifier(bool status);
void RequestMagnifierSnapshotAsync(const Eina_Rectangle rect,
Screenshot_Captured_Callback callback,
void* user_data,
void Initialize();
void InitializeProgram();
void PaintTextureToSurface(GLuint texture_id);
- void FocusRWHVA();
void InitEvasGL();
gfx::Size CreateNativeSurface();
float scale_factor,
std::unique_ptr<ScreenshotCapturedCallback> cb);
- ui::EflEventHandler* GetEventHandler();
- ui::IMContextEfl* GetIMContextEfl();
-
Evas* evas_ = nullptr;
Evas_GL* evas_gl_ = nullptr;
Evas_GL_API* evas_gl_api_ = nullptr;
gfx::NativeView aura_parent_window_ = nullptr;
int rotation_ = 0;
- float device_scale_factor_ = 1.0f;
gfx::SizeF scaled_contents_size_;
gfx::Size custom_viewport_size_;
int input_maxlength_ = DEFAULT_MAX_LENGTH;
std::vector<Evas_Object*> voice_manager_labels_;
#endif
- bool is_focused_node_editable_ = false;
- bool is_scrolling_needed_ = false;
-
- ui::IMContextEfl* im_context_efl_ = nullptr;
- RenderWidgetHostViewAura* rwhv_aura_ = nullptr;
- WebContents* web_contents_ = nullptr;
- std::unique_ptr<SelectionControllerEfl> selection_controller_;
std::unique_ptr<RenderWidgetHostHelper> rwh_helper_;
bool horizontal_panning_hold_ = false;
bool vertical_panning_hold_ = false;
- bool magnifier_ = false;
-
- bool touchstart_consumed_ = false;
- bool touchend_consumed_ = false;
-
OnFocusCallback on_focus_in_callback_;
OnFocusCallback on_focus_out_callback_;
- bool is_content_editable_ = false;
std::unique_ptr<EdgeEffect> edge_effect_;
// Magnifier snapshot requests are not added to snapshot_task_list_, because
// we only care about the last one if they piled up - we can only display
left_rect_ = left_rect;
right_rect_ = right_rect;
- //context params suppose to be global - related to evas not the web view
+ if (!rwhva_->offscreen_helper())
+ return ret;
+
+ // Context params suppose to be global - related to evas not the web view
gfx::Rect view_bounds = rwhva_->offscreen_helper()->GetViewBoundsInPix();
ret |= (context_params_->x != (left_rect_.x() + (view_bounds.x())));
ret |= (context_params_->y != (left_rect_.y() + view_bounds.y()));
status_ = enable;
// invoke CB only if mode actually changed
- if (invoke_cb_at_end && rwhva_->offscreen_helper()->ewk_view())
+ if (invoke_cb_at_end && rwhva_->offscreen_helper() &&
+ rwhva_->offscreen_helper()->ewk_view()) {
evas_object_smart_callback_call(rwhva_->offscreen_helper()->ewk_view(),
"textselection,mode", &status_);
+ }
}
}
}
content::WebContents* SelectionControllerEfl::web_contents() const {
- return rwhva_->offscreen_helper()->GetWebContents();
+ return rwhva_->offscreen_helper()
+ ? rwhva_->offscreen_helper()->GetWebContents()
+ : nullptr;
}
SelectionControllerEfl::SelectionControllerEfl(RenderWidgetHostViewAura* rwhva)
input_handle_(
new SelectionHandleEfl(*this, SelectionHandleEfl::HANDLE_TYPE_INPUT)),
magnifier_(new SelectionMagnifierEfl(this)) {
- evas_object_event_callback_add(rwhva_->offscreen_helper()->content_image(),
- EVAS_CALLBACK_MOVE,
- &EvasParentViewMoveCallback, this);
+ if (rwhva_->offscreen_helper()) {
+ evas_object_event_callback_add(rwhva_->offscreen_helper()->content_image(),
+ EVAS_CALLBACK_MOVE,
+ &EvasParentViewMoveCallback, this);
+ }
#if BUILDFLAG(IS_TIZEN)
vconf_notify_key_changed(VCONFKEY_LANGSET, PlatformLanguageChanged, this);
#endif
ClearSelectionViaEWebView();
HideHandleAndContextMenu();
- evas_object_event_callback_del(rwhva_->offscreen_helper()->content_image(),
- EVAS_CALLBACK_MOVE,
- &EvasParentViewMoveCallback);
+ if (rwhva_->offscreen_helper()) {
+ evas_object_event_callback_del(rwhva_->offscreen_helper()->content_image(),
+ EVAS_CALLBACK_MOVE,
+ &EvasParentViewMoveCallback);
+ }
}
void SelectionControllerEfl::SetSelectionStatus(bool enable) {
// In case of the selected text contains only line break and no other
// characters, we should use caret selection mode.
if (GetSelectionEditable() && !handle_being_dragged_ && rwhva_ &&
- rwhva_->GetSelectedText() == (u"\n")) {
+ rwhva_->GetSelectedText() == (u"\n") && rwhva_->offscreen_helper()) {
rwhva_->offscreen_helper()->MoveCaret(
selection_data_->GetLeftRect().origin());
is_caret_mode_forced_ = true;
}
void SelectionControllerEfl::ToggleCaretAfterSelection() {
- if (!GetCaretSelectionStatus() && GetSelectionEditable()) {
+ if (!GetCaretSelectionStatus() && GetSelectionEditable() &&
+ rwhva_->offscreen_helper()) {
rwhva_->offscreen_helper()->MoveCaret(
selection_data_->GetRightRect().origin());
ClearSelection();
// the visible part contains selection rects.
auto visible_viewport_rect = GetVisibleViewportRect();
if (!visible_viewport_rect.IsEmpty() ||
- rwhva_->offscreen_helper()->GetTopControlsHeight() > 0) {
+ (rwhva_->offscreen_helper() &&
+ rwhva_->offscreen_helper()->GetTopControlsHeight() > 0)) {
auto view_offset =
rwhva_->offscreen_helper()->GetViewBoundsInPix().OffsetFromOrigin();
is_start_selection_visible =
content::ContextMenuParams convertedParams =
*(selection_data_->GetContextMenuParams());
- int blinkX, blinkY;
- rwhva_->offscreen_helper()->EvasToBlinkCords(
- convertedParams.x, convertedParams.y, &blinkX, &blinkY);
- convertedParams.x = blinkX;
- convertedParams.y = blinkY;
+ if (rwhva_->offscreen_helper()) {
+ int blinkX, blinkY;
+ rwhva_->offscreen_helper()->EvasToBlinkCords(
+ convertedParams.x, convertedParams.y, &blinkX, &blinkY);
+ convertedParams.x = blinkX;
+ convertedParams.y = blinkY;
+ }
// TODO(a1.gomes): In case of EWK apps, the call below end up calling
// EWebView::ShowContextMenu. We have to make sure parameters
return;
// FIXME : Check the text Direction later
- gfx::Rect view_bounds = rwhva_->offscreen_helper()->GetViewBoundsInPix();
+ gfx::Rect view_bounds = rwhva_->offscreen_helper()
+ ? rwhva_->offscreen_helper()->GetViewBoundsInPix()
+ : gfx::Rect();
selection_change_reason_ = Reason::HandleDragged;
switch (handle->Type()) {
case SelectionHandleEfl::HANDLE_TYPE_INPUT: {
- rwhva_->offscreen_helper()->MoveCaret(handle->GetBasePosition());
+ if (rwhva_->offscreen_helper())
+ rwhva_->offscreen_helper()->MoveCaret(handle->GetBasePosition());
return;
}
case SelectionHandleEfl::HANDLE_TYPE_LEFT:
web_contents()->GetRenderWidgetHostView());
gfx::Point point = gfx::Point(x, y);
- if (rwhva)
+ if (rwhva && rwhva_->offscreen_helper())
point = rwhva->offscreen_helper()->ConvertPointInViewPix(point);
switch (type) {
case ui::ET_GESTURE_LONG_PRESS: {
// If one long press on an empty form, do not enter selection mode.
// Instead, context menu will be shown if needed for clipboard actions.
if (params.selection_text.empty() &&
- !(rwhva_ && !rwhva_->offscreen_helper()->HasSelectableText()) &&
+ !(rwhva_ && rwhva_->offscreen_helper() &&
+ !rwhva_->offscreen_helper()->HasSelectableText()) &&
!ClipboardHelperEfl::GetInstance()->CanPasteFromSystemClipboard()) {
long_mouse_press_ = false;
selection_change_reason_ = Reason::Irrelevant;
const gfx::Point& touch_point) {
Clear();
- gfx::Rect view_bounds = rwhva_->offscreen_helper()->GetViewBoundsInPix();
+ gfx::Rect view_bounds = rwhva_->offscreen_helper()
+ ? rwhva_->offscreen_helper()->GetViewBoundsInPix()
+ : gfx::Rect();
magnifier_->HandleLongPress(gfx::Point(touch_point.x() + view_bounds.x(),
touch_point.y() + view_bounds.y()),
selection_data_->IsInEditField());
}
void SelectionControllerEfl::HandleLongPressMoveEvent(const gfx::Point& touch_point) {
- if (rwhva_)
+ if (rwhva_ && rwhva_->offscreen_helper())
rwhva_->offscreen_helper()->SelectClosestWord(touch_point);
}
}
gfx::Rect SelectionControllerEfl::GetVisibleViewportRect() const {
+ if (!rwhva_->offscreen_helper())
+ return gfx::Rect();
+
if (custom_visible_view_rect_.IsEmpty())
return rwhva_->offscreen_helper()->GetViewBoundsInPix();
pressed_(false),
is_top_(false),
handle_type_(type) {
+ if (!controller_.rwhva()->offscreen_helper())
+ return;
+
Evas* evas = evas_object_evas_get(
controller_.rwhva()->offscreen_helper()->content_image());
handle_ = edje_object_add(evas);
}
void SelectionHandleEfl::ChangeObjectDirection(HandleDirection direction) {
+ if (!controller_.rwhva()->offscreen_helper())
+ return;
+
TRACE_EVENT2("selection,efl", __PRETTY_FUNCTION__,
"handle type", handle_type_, "direction", direction);
}
void SelectionHandleEfl::MoveObject(const gfx::Point& point, bool ignore_parent_view_offset) {
+ if (!controller_.rwhva()->offscreen_helper())
+ return;
+
gfx::Rect view_bounds =
controller_.rwhva()->offscreen_helper()->GetViewBoundsInPix();
int handle_x = point.x() + view_bounds.x();
SelectionMagnifierEfl::SelectionMagnifierEfl(
content::SelectionControllerEfl* controller)
: controller_(controller), content_image_(0), shown_(false) {
+ if (!controller_->rwhva()->offscreen_helper())
+ return;
+
base::FilePath edj_dir;
base::FilePath magnifier_edj;
base::PathService::Get(PathsEfl::EDJE_RESOURCE_DIR, &edj_dir);
void SelectionMagnifierEfl::HandleLongPress(const gfx::Point& touch_point,
bool is_in_edit_field) {
+ if (!controller_->rwhva()->offscreen_helper())
+ return;
+
evas_object_event_callback_add(
controller_->rwhva()->offscreen_helper()->content_image(),
EVAS_CALLBACK_MOUSE_MOVE, OnAnimatorMove, this);
}
void SelectionMagnifierEfl::DisconnectCallbacks() {
+ if (!controller_->rwhva()->offscreen_helper())
+ return;
+
evas_object_event_callback_del(
controller_->rwhva()->offscreen_helper()->content_image(),
EVAS_CALLBACK_MOUSE_MOVE, OnAnimatorMove);
}
void SelectionMagnifierEfl::OnAnimatorMove() {
+ if (!controller_->rwhva()->offscreen_helper())
+ return;
+
Evas_Coord_Point point;
evas_pointer_canvas_xy_get(
evas_object_evas_get(
rect.w = content_rect.width();
rect.h = content_rect.height();
- controller_->rwhva()->offscreen_helper()->RequestMagnifierSnapshotAsync(
- rect, MagnifierGetSnapshotCb, this);
+ if (controller_->rwhva()->offscreen_helper()) {
+ controller_->rwhva()->offscreen_helper()->RequestMagnifierSnapshotAsync(
+ rect, MagnifierGetSnapshotCb, this);
+ }
}
void SelectionMagnifierEfl::Move(const gfx::Point& location) {
shown_ = true;
evas_object_show(container_);
+
+ if (!controller_->rwhva()->offscreen_helper())
+ return;
+
controller_->rwhva()->offscreen_helper()->set_magnifier(true);
if (controller_->rwhva()->offscreen_helper()->ewk_view()) {
evas_object_smart_callback_call(
shown_ = false;
evas_object_hide(content_image_);
evas_object_hide(container_);
+
+ if (!controller_->rwhva()->offscreen_helper())
+ return;
+
controller_->rwhva()->offscreen_helper()->set_magnifier(false);
if (controller_->rwhva()->offscreen_helper()->ewk_view()) {
evas_object_smart_callback_call(
// API defined `SelectionControllerEfl`
virtual bool ExistsSelectedText() = 0;
- // APIs defined in `RenderWidgetHostViewAuraHelperEfl`
+ // APIs defined in `RWHVAuraCommonHelperEfl`
virtual bool ImeHandleKeyEventEnabled() = 0;
virtual gfx::Size GetPhysicalBackingSize() const = 0;
virtual Evas_Object* EwkView() const = 0;
+
+ virtual bool IsOffscreenMode() const = 0;
};
} // namespace content
}
bool IMContextEfl::WebViewWillBeResized() {
- if (!context_ || !rwh_helper_)
+ if (!context_ || !rwh_helper_ || !rwh_helper_->IsOffscreenMode())
return false;
return IsVisible()
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
}
+ if (!rwhva->offscreen_helper())
+ return element_bounds;
+
gfx::Vector2d view_offset =
gfx::ToEnclosingRect(
gfx::ConvertRectToDips(
web_view_->ResetContextMenuController();
auto rwhva = static_cast<RenderWidgetHostViewAura*>(
web_contents_.GetRenderWidgetHostView());
- if (rwhva) {
+ if (rwhva && rwhva->offscreen_helper() &&
+ rwhva->offscreen_helper()->GetSelectionController()) {
auto selection_controller =
rwhva->offscreen_helper()->GetSelectionController();
- if (selection_controller)
- selection_controller->ClearSelection();
+ selection_controller->ClearSelection();
}
}
}
bool left) {
auto* rwhva = static_cast<RenderWidgetHostViewAura*>(
web_contents_.GetRenderWidgetHostView());
- if (rwhva)
+ if (rwhva && rwhva->offscreen_helper())
rwhva->offscreen_helper()->OnEdgeEffectForUIF(top, bottom, right, left);
}
#endif