const base::FilePath& filename) {
blink_widget_->PrintToPdf(width, height, filename);
}
+
+void RenderWidgetHostImpl::SetMainFrameScrollbarVisible(bool visible) {
+ blink_widget_->SetMainFrameScrollbarVisible(visible);
+}
+
+void RenderWidgetHostImpl::RequestMainFrameScrollbarVisible(int callback_id) {
+ blink_widget_->RequestMainFrameScrollbarVisible(
+ base::BindOnce(&RenderWidgetHostImpl::OnGetMainFrameScrollbarVisible,
+ weak_factory_.GetWeakPtr(), callback_id));
+}
+
+void RenderWidgetHostImpl::OnGetMainFrameScrollbarVisible(int callback_id,
+ bool visible) {
+ if (!view_)
+ return;
+ view_->OnGetMainFrameScrollbarVisible(callback_id, visible);
+}
#endif
#if defined(TIZEN_VIDEO_HOLE)
void OnGetFocusedNodeBounds(const gfx::RectF& rect);
void SetLongPollingGlobalTimeout(uint64_t timeout);
void PrintToPdf(int width, int height, const base::FilePath& filename);
+ void SetMainFrameScrollbarVisible(bool visible);
+ void RequestMainFrameScrollbarVisible(int callback_id);
+ void OnGetMainFrameScrollbarVisible(int callback_id, bool visible);
#endif
#if defined(TIZEN_VIDEO_HOLE)
if (offscreen_helper_)
offscreen_helper_->OnGetFocusedNodeBounds(rect);
}
+
+void RenderWidgetHostViewAura::OnGetMainFrameScrollbarVisible(int callback_id,
+ bool visible) {
+ if (offscreen_helper_)
+ offscreen_helper_->OnGetMainFrameScrollbarVisible(callback_id, visible);
+}
#endif
////////////////////////////////////////////////////////////////////////////////
void TextInputStateChanged(const ui::mojom::TextInputState& params) override;
void BackgroundColorReceived(int callback_id, SkColor bg_color) override;
void OnGetFocusedNodeBounds(const gfx::RectF& rect) override;
+ void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) override;
#endif
protected:
virtual void BackgroundColorReceived(int callback_id, SkColor bg_color) {}
virtual void OnGetFocusedNodeBounds(const gfx::RectF&) {}
+
+ virtual void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) {}
#endif
// This method will reset the fallback to the first surface after navigation.
virtual void BackgroundColorReceived(int callback_id, SkColor bg_color) {}
virtual void OnDidChangeFocusedNodeBounds(
const gfx::RectF& focused_node_bounds) {}
+ virtual void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) {}
#endif
#if BUILDFLAG(IS_ANDROID)
UpdateScreenRects(gfx.mojom.Rect widget_screen_rect,
gfx.mojom.Rect window_screen_rect) => ();
+ [EnableIf=is_efl]
+ SetMainFrameScrollbarVisible(bool visible);
+
+ [EnableIf=is_efl]
+ RequestMainFrameScrollbarVisible() => (bool visible);
+
[EnableIf=is_efl]
GetBackgroundColor() => (skia.mojom.SkColor bg_color);
virtual gfx::PointF GetScrollOffset() const = 0;
virtual void SetScrollOffset(const gfx::PointF&) = 0;
+#if BUILDFLAG(IS_EFL)
+ // If set to false, do not draw scrollbars on this frame's view.
+ virtual void ChangeScrollbarVisibility(bool) = 0;
+ virtual bool HasHorizontalScrollbar() const = 0;
+ virtual bool HasVerticalScrollbar() const = 0;
+#endif
+
// The size of the document in this frame.
virtual gfx::Size DocumentSize() const = 0;
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/rect_f.h"
+#if BUILDFLAG(IS_EFL)
+#include "third_party/blink/renderer/core/scroll/scrollbar_theme_overlay.h"
+#include "third_party/blink/renderer/core/scroll/scrollbar_theme_overlay_mobile.h"
+#endif
+
// Used to check for dirty layouts violating document lifecycle rules.
// If arg evaluates to true, the program will continue. If arg evaluates to
// false, program will crash if DCHECK_IS_ON() or return false from the current
});
}
+#if BUILDFLAG(IS_EFL)
+void LocalFrameView::ChangeScrollbarVisibility(bool visible) {
+ has_visible_scrollbars_ = visible;
+
+ if (!frame_ && !frame_->IsMainFrame())
+ return;
+
+ const VisualViewport& visual_viewport =
+ frame_->GetPage()->GetVisualViewport();
+
+ int horizontal_scrollbar_width = 0;
+ int horizontal_scrollbar_height = 0;
+ int vertical_scrollbar_width = 0;
+ int vertical_scrollbar_height = 0;
+
+ if (visible) {
+ auto& theme = ScrollbarThemeOverlayMobile::GetInstance();
+
+ const int scrollbar_thickness = theme.ScrollbarThickness(
+ visual_viewport.ScaleFromDIP(), EScrollbarWidth::kAuto);
+ horizontal_scrollbar_width =
+ visual_viewport.Size().width() - scrollbar_thickness;
+ horizontal_scrollbar_height = scrollbar_thickness;
+
+ vertical_scrollbar_width = scrollbar_thickness;
+ vertical_scrollbar_height =
+ visual_viewport.Size().height() - scrollbar_thickness;
+ }
+
+ cc::Layer* scrollbar_graphics_layer =
+ visual_viewport.LayerForHorizontalScrollbar();
+ if (scrollbar_graphics_layer) {
+ scrollbar_graphics_layer->SetBounds(
+ gfx::Size(horizontal_scrollbar_width, horizontal_scrollbar_height));
+ }
+
+ scrollbar_graphics_layer = visual_viewport.LayerForVerticalScrollbar();
+ if (scrollbar_graphics_layer) {
+ scrollbar_graphics_layer->SetBounds(
+ gfx::Size(vertical_scrollbar_width, vertical_scrollbar_height));
+ }
+}
+#endif
} // namespace blink
void SetLayoutOverflowSize(const gfx::Size&);
+#if BUILDFLAG(IS_EFL)
+ void ChangeScrollbarVisibility(bool);
+ bool HasVisibleScrollbars() { return has_visible_scrollbars_; }
+#endif
+
bool DidFirstLayout() const;
bool LifecycleUpdatesActive() const;
void SetLifecycleUpdatesThrottledForTesting(bool throttled = true);
bool can_have_scrollbars_;
bool in_post_lifecycle_steps_ = false;
+#if BUILDFLAG(IS_EFL)
+ bool has_visible_scrollbars_ = true;
+#endif
+
bool has_pending_layout_;
LayoutSubtreeRootList layout_subtree_root_list_;
DepthOrderedLayoutObjectList orthogonal_writing_mode_root_list_;
scrollbar_layer->SetIsDrawable(true);
}
+#if BUILDFLAG(IS_EFL)
+ if (IsActiveViewport() && LocalMainFrame().View() &&
+ !LocalMainFrame().View()->HasVisibleScrollbars()) {
+ scrollbar_layer->SetBounds(gfx::Size(0, 0));
+ return;
+ }
+#endif
scrollbar_layer->SetBounds(
orientation == kHorizontalScrollbar
? gfx::Size(size_.width() - ScrollbarThickness(),
width, height, filename,
content::RenderFrame::FromWebFrame(focused_frame));
}
+
+void WebFrameWidgetImpl::SetMainFrameScrollbarVisible(bool visible) {
+ blink::WebView* view = View();
+ if (!view || !view->MainFrame() || !view->MainFrame()->ToWebLocalFrame())
+ return;
+
+ view->MainFrame()->ToWebLocalFrame()->ChangeScrollbarVisibility(visible);
+}
+
+bool WebFrameWidgetImpl::RequestMainFrameScrollbarVisible(bool& visible) {
+ blink::WebView* view = View();
+ if (!view || !view->MainFrame() || !view->MainFrame()->ToWebLocalFrame())
+ return false;
+
+ auto local_frame = view->MainFrame()->ToWebLocalFrame();
+ visible = local_frame->HasHorizontalScrollbar() ||
+ local_frame->HasVerticalScrollbar();
+ return true;
+}
#endif
#if BUILDFLAG(IS_TIZEN)
void PrintToPdf(uint32_t width,
uint32_t height,
const base::FilePath& filename) override;
+ void SetMainFrameScrollbarVisible(bool visible) override;
+ bool RequestMainFrameScrollbarVisible(bool& visible) override;
#endif
#if defined(TIZEN_VIDEO_HOLE)
void SetVideoHoleForRender(bool enable) override;
Client()->DidFinishLoadForPrinting();
}
+#if BUILDFLAG(IS_EFL)
+void WebLocalFrameImpl::ChangeScrollbarVisibility(bool visible) {
+ if (LocalFrameView* view = GetFrameView())
+ view->ChangeScrollbarVisibility(visible);
+}
+
+bool WebLocalFrameImpl::HasHorizontalScrollbar() const {
+ return GetFrame() && GetFrame()->View() &&
+ GetFrame()->View()->LayoutViewport()->HasHorizontalScrollbar();
+}
+
+bool WebLocalFrameImpl::HasVerticalScrollbar() const {
+ return GetFrame() && GetFrame()->View() &&
+ GetFrame()->View()->LayoutViewport()->HasVerticalScrollbar();
+}
+#endif
+
HitTestResult WebLocalFrameImpl::HitTestResultForVisualViewportPos(
const gfx::Point& pos_in_viewport) {
gfx::Point root_frame_point(
void ReloadImage(const WebNode&) override;
bool IsAllowedToDownload() const override;
bool IsCrossOriginToOutermostMainFrame() const override;
+#if BUILDFLAG(IS_EFL)
+ void ChangeScrollbarVisibility(bool) override;
+ bool HasHorizontalScrollbar() const override;
+ bool HasVerticalScrollbar() const override;
+#endif
+
bool FindForTesting(int identifier,
const WebString& search_text,
bool match_case,
std::move(callback).Run(client_->UpdateFocusedNodeBounds());
}
+void WidgetBase::SetMainFrameScrollbarVisible(bool visible) {
+ client_->SetMainFrameScrollbarVisible(visible);
+}
+
+void WidgetBase::RequestMainFrameScrollbarVisible(
+ RequestMainFrameScrollbarVisibleCallback callback) {
+ bool visible = false;
+ if (client_->RequestMainFrameScrollbarVisible(visible))
+ std::move(callback).Run(visible);
+}
+
void WidgetBase::SetLongPollingGlobalTimeout(uint64_t timeout) {
client_->SetLongPollingGlobalTimeout(timeout);
}
void PrintToPdf(uint32_t width,
uint32_t height,
const base::FilePath& filename) override;
+ void SetMainFrameScrollbarVisible(bool visible) override;
+ void RequestMainFrameScrollbarVisible(
+ RequestMainFrameScrollbarVisibleCallback callback) override;
#endif
#if defined(TIZEN_VIDEO_HOLE)
void SetVideoHoleForRender(bool enable) override;
virtual void PrintToPdf(uint32_t width,
uint32_t height,
const base::FilePath& filename) {}
+ virtual void SetMainFrameScrollbarVisible(bool visible) {}
+ virtual bool RequestMainFrameScrollbarVisible(bool& visible) { return false; }
#endif
#if defined(TIZEN_VIDEO_HOLE)
virtual void SetVideoHoleForRender(bool enable) {}
}
#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 BackgroundColorReceived(int callback_id, SkColor bg_color);
void Show();
void Hide();
+ void OnGetMainFrameScrollbarVisible(int callback_id, bool visible);
gfx::Size GetVisibleViewportSize();
gfx::Rect GetViewBounds();
web_contents_->ClosePage();
}
+bool EWebView::SetMainFrameScrollbarVisible(bool visible) {
+ if (web_contents_->GetPrimaryMainFrame()->IsRenderFrameLive() && rwhva())
+ rwhva()->host()->SetMainFrameScrollbarVisible(visible);
+ return true;
+}
+
+bool EWebView::GetMainFrameScrollbarVisible(
+ Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback callback,
+ void* user_data) {
+ if (!rwhva())
+ return false;
+
+ MainFrameScrollbarVisibleGetCallback* callback_ptr =
+ new MainFrameScrollbarVisibleGetCallback;
+ callback_ptr->Set(callback, user_data);
+ int callback_id =
+ main_frame_scrollbar_visible_callback_map_.Add(callback_ptr);
+ rwhva()->host()->RequestMainFrameScrollbarVisible(callback_id);
+ return true;
+}
+
+void EWebView::InvokeMainFrameScrollbarVisibleCallback(int callback_id,
+ bool visible) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&EWebView::InvokeMainFrameScrollbarVisibleCallback,
+ base::Unretained(this), visible, callback_id));
+ return;
+ }
+
+ MainFrameScrollbarVisibleGetCallback* callback =
+ main_frame_scrollbar_visible_callback_map_.Lookup(callback_id);
+ if (!callback)
+ return;
+
+ main_frame_scrollbar_visible_callback_map_.Remove(callback_id);
+ callback->Run(evas_object(), visible);
+ main_frame_scrollbar_visible_callback_map_.Remove(callback_id);
+}
+
void EWebView::OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
const gfx::Vector2dF& latest_overscroll_delta) {
const gfx::Vector2dF old_overscroll =
content::ContextMenuControllerEfl* GetContextMenuController() {
return context_menu_.get();
}
+
+ bool SetMainFrameScrollbarVisible(bool visible);
+ bool GetMainFrameScrollbarVisible(
+ Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback callback,
+ void* user_data);
+ void InvokeMainFrameScrollbarVisibleCallback(int callback_id, bool visible);
+
void ResetContextMenuController();
Eina_Bool AddJavaScriptMessageHandler(Evas_Object* view,
Ewk_View_Script_Message_Cb callback,
return false;
}
-Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* o, Eina_Bool visible)
-{
- LOG_EWK_API_MOCKUP();
- return false;
+Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewk_view,
+ Eina_Bool visible) {
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
+ return impl->SetMainFrameScrollbarVisible(!!visible);
+}
+
+Eina_Bool ewk_view_main_frame_scrollbar_visible_get(
+ Evas_Object* ewk_view,
+ Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback callback,
+ void* user_data) {
+ EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
+
+ return impl->GetMainFrameScrollbarVisible(callback, user_data);
}
Eina_Bool ewk_view_set_custom_device_pixel_ratio(Evas_Object* ewkView, Eina_Bool enabled)
}
}
+void WebContentsDelegateEfl::OnGetMainFrameScrollbarVisible(int callback_id,
+ bool visible) {
+ web_view_->InvokeMainFrameScrollbarVisibleCallback(callback_id, visible);
+}
} // namespace content
int active_match_ordinal,
bool final_update) override;
void DidRenderFrame() override;
+
+ void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) override;
void RequestCertificateConfirm(
WebContents* web_contents,
int cert_error,
"utc_blink_ewk_view_javascript_confirm_reply_func.cpp",
"utc_blink_ewk_view_load_progress_get_func.cpp",
"utc_blink_ewk_view_main_frame_get_func.cpp",
+ "utc_blink_ewk_view_main_frame_scrollbar_visible_set_func.cpp",
"utc_blink_ewk_view_mhtml_data_get_func.cpp",
"utc_blink_ewk_view_notification_permission_callback_set_func.cpp",
"utc_blink_ewk_view_orientation_send_func.cpp",
--- /dev/null
+// Copyright 2022 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "utc_blink_ewk_base.h"
+
+class utc_blink_ewk_view_main_frame_scrollbar_visible_set
+ : public utc_blink_ewk_base {
+ protected:
+ void PostSetUp() override {
+ evas_object_smart_callback_add(GetEwkWebView(), "contents,size,changed",
+ ContentsSizeChanged, this);
+ }
+
+ void PreTearDown() override {
+ evas_object_smart_callback_del(GetEwkWebView(), "contents,size,changed",
+ ContentsSizeChanged);
+ }
+
+ static void ContentsSizeChanged(void* data,
+ Evas_Object* eObject,
+ void* dataFinished) {
+ if (data) {
+ static_cast<utc_blink_ewk_view_main_frame_scrollbar_visible_set*>(data)
+ ->EventLoopStop(Success);
+ }
+ }
+
+ static void ScrollbarVisibleGetCallback(Evas_Object* eObject,
+ Eina_Bool visible,
+ void* data) {
+ utc_check_ne(data, nullptr);
+ utc_blink_ewk_view_main_frame_scrollbar_visible_set* owner = nullptr;
+ OwnerFromVoid(data, &owner);
+ utc_message("[ScrollbarVisibleGetCallback] :: visible = %s\n",
+ visible == EINA_TRUE ? "EINA_TRUE" : "EINA_FALSE");
+ utc_check_eq(owner->expected_visible_, visible);
+ owner->EventLoopStop(Success);
+ }
+
+ protected:
+ Eina_Bool expected_visible_;
+};
+
+TEST_F(utc_blink_ewk_view_main_frame_scrollbar_visible_set, TURN_OFF) {
+ Eina_Bool ret = EINA_FALSE;
+
+ // Loading the page triggers a call to ContentsSizeChanged callback.
+ utc_check_eq(EINA_TRUE, ewk_view_url_set(
+ GetEwkWebView(),
+ GetResourceUrl("common/sample_2.html").c_str()));
+ utc_check_eq(Success, EventLoopStart());
+
+ // Initially the scrollbar is visible.
+ expected_visible_ = EINA_TRUE;
+ ret = ewk_view_main_frame_scrollbar_visible_get(
+ GetEwkWebView(), ScrollbarVisibleGetCallback, this);
+ utc_check_eq(ret, EINA_TRUE);
+ utc_check_eq(Success, EventLoopStart());
+
+ // Check that changing scrollbar visiblity triggers "contents,size,changed"
+ // callback. Indeed at this point only ContentsSizeChanged callback can stop
+ // the next call to EventLoopStart.
+ ret = ewk_view_main_frame_scrollbar_visible_set(GetEwkWebView(), false);
+ utc_check_eq(ret, EINA_TRUE);
+ utc_check_eq(Success, EventLoopStart());
+
+ // Check that the scrollbar is not visible.
+ expected_visible_ = EINA_FALSE;
+ ret = ewk_view_main_frame_scrollbar_visible_get(
+ GetEwkWebView(), ScrollbarVisibleGetCallback, this);
+ utc_check_eq(ret, EINA_TRUE);
+ utc_check_eq(Success, EventLoopStart());
+
+ // Make the scrollbar visible again.
+ ret = ewk_view_main_frame_scrollbar_visible_set(GetEwkWebView(), true);
+ utc_check_eq(ret, EINA_TRUE);
+ utc_check_eq(Success, EventLoopStart());
+ expected_visible_ = EINA_TRUE;
+ ret = ewk_view_main_frame_scrollbar_visible_get(
+ GetEwkWebView(), ScrollbarVisibleGetCallback, this);
+ utc_check_eq(ret, EINA_TRUE);
+ utc_check_eq(Success, EventLoopStart());
+}