// being created occurs).
virtual void DidCreateNewDocument() {}
virtual void DidCreateDocumentElement() {}
+#if BUILDFLAG(IS_EFL)
+ virtual void DidUpdateMainFrameLayout() {}
+#endif
// TODO(dgozman): replace next two methods with DidFinishNavigation.
// DidCommitProvisionalLoad is only called for new-document navigations.
// Use DidFinishSameDocumentNavigation for same-document navigations.
UpdateEncoding(frame_, frame_->View()->PageEncoding().Utf8());
}
+#if BUILDFLAG(IS_EFL)
+void RenderFrameImpl::DidUpdateMainFrameLayout() {
+ for (auto& observer : observers_)
+ observer.DidUpdateMainFrameLayout();
+}
+#endif
+
void RenderFrameImpl::RunScriptsAtDocumentReady() {
DCHECK(initialized_);
GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this);
blink::WebDocumentLoader* document_loader) override;
void DidClearWindowObject() override;
void DidCreateDocumentElement() override;
+#if BUILDFLAG(IS_EFL)
+ void DidUpdateMainFrameLayout() override;
+#endif
void RunScriptsAtDocumentElementAvailable() override;
void DidReceiveTitle(const blink::WebString& title) override;
void DidDispatchDOMContentLoadedEvent() override;
// This method may not invalidate the frame, nor execute JavaScript code.
virtual void DidCreateDocumentElement() {}
+#if BUILDFLAG(IS_EFL)
+ virtual void DidUpdateMainFrameLayout() {}
+#endif
+
// Like |didCreateDocumentElement|, except this method may run JavaScript
// code (and possibly invalidate the frame).
virtual void RunScriptsAtDocumentElementAvailable() {}
if (!web_view_client_)
return;
+#if BUILDFLAG(IS_EFL)
+ if (MainFrameImpl() && MainFrameImpl()->Client())
+ MainFrameImpl()->Client()->DidUpdateMainFrameLayout();
+#endif
+
for (auto& observer : observers_)
observer.DidUpdateMainFrameLayout();
needs_preferred_size_update_ = true;
return y;
}
+gfx::Rect RWHVAuraOffscreenHelperEfl::GetViewBoundsInPix() const {
+ int x, y, w, h;
+ evas_object_geometry_get(content_image_, &x, &y, &w, &h);
+ return gfx::Rect(x, y, w, h);
+}
+
+const gfx::Size RWHVAuraOffscreenHelperEfl::GetScrollableSize() const {
+ int width = 0;
+ int height = 0;
+ gfx::Rect viewport_size = GetViewBoundsInPix();
+ if (scaled_contents_size_.width() > viewport_size.width()) {
+ width = scaled_contents_size_.width() - viewport_size.width();
+ // When device scale factor is larger than 1.0, content size is ceiled up
+ // during converting pixel to dip in RenderWidgetHostViewEfl::GetViewBounds.
+ // So we ignore when scroll size is 1. It is also same for height.
+ // Please refer to https://review.tizen.org/gerrit/#/c/74044/.
+ if (device_scale_factor_ > 1.0f && width == 1)
+ width = 0;
+ }
+ if (scaled_contents_size_.height() > viewport_size.height()) {
+ height = scaled_contents_size_.height() - viewport_size.height();
+ if (device_scale_factor_ > 1.0f && height == 1)
+ height = 0;
+ }
+
+ return gfx::Size(width, height);
+}
+
} // namespace content
void SetCustomViewportSize(const gfx::Size& size);
gfx::Size GetPhysicalBackingSize() const;
gfx::Rect GetViewBoundsInPix() const;
+ const gfx::Size GetScrollableSize() const;
+ void SetScaledContentSize(const gfx::SizeF& size) {
+ scaled_contents_size_ = size;
+ }
int GetTopControlsHeight();
void Focus(bool focus);
web_view_->InvokeWebAppCapableGetCallback(capable, callback_id);
}
- void OnDidChangeContentsSize(int width, int height) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- if (web_view_)
- web_view_->DidChangeContentsSize(width, height);
- }
-
void OnSelectionTextStyleState(const SelectionStylePrams& params) {
if (web_view_)
web_view_->OnQuerySelectionStyleReply(params);
}
- void OnDidChangePageScaleFactor(double scale_factor) {
- if (web_view_)
- web_view_->DidChangePageScaleFactor(scale_factor);
- }
-
void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id) {
if (web_view_)
web_view_->OnMHTMLContentGet(mhtml_content, callback_id);
case EwkHostMsg_WebAppIconUrlGet::ID:
case EwkHostMsg_WebAppIconUrlsGet::ID:
case EwkHostMsg_WebAppCapableGet::ID:
- case EwkHostMsg_DidChangeContentsSize::ID:
*thread = BrowserThread::UI;
break;
}
WebViewBrowserMessageFilterPrivate::OnWebAppIconUrlsGet)
IPC_MESSAGE_FORWARD(EwkHostMsg_WebAppCapableGet, private_,
WebViewBrowserMessageFilterPrivate::OnWebAppCapableGet)
- IPC_MESSAGE_FORWARD(EwkHostMsg_DidChangeContentsSize, private_,
- WebViewBrowserMessageFilterPrivate::OnDidChangeContentsSize)
IPC_MESSAGE_FORWARD(EwkViewMsg_SelectionTextStyleState, private_,
WebViewBrowserMessageFilterPrivate::OnSelectionTextStyleState)
IPC_MESSAGE_FORWARD(EwkHostMsg_ReadMHTMLData, private_,
WebViewBrowserMessageFilterPrivate::OnMHTMLContentGet)
- IPC_MESSAGE_FORWARD(EwkHostMsg_DidChangePageScaleFactor, private_,
- WebViewBrowserMessageFilterPrivate::OnDidChangePageScaleFactor)
IPC_MESSAGE_FORWARD(EwkHostMsg_DidChangeMaxScrollOffset, private_,
WebViewBrowserMessageFilterPrivate::OnDidChangeMaxScrollOffset)
IPC_MESSAGE_FORWARD(EwkHostMsg_DidChangeScrollOffset, private_,
std::string, /* policy */
Ewk_CSP_Header_Type /* header type */)
-IPC_MESSAGE_ROUTED3(EwkViewMsg_Scale,
- double, /* scale factor */
- int, /* center x */
- int /* center y */)
-
IPC_MESSAGE_ROUTED1(EwkHostMsg_DidPrintPagesToPdf,
DidPrintPagesParams /* pdf document parameters */)
std::string, /* Mhtml text */
int /* callback id */)
-IPC_MESSAGE_ROUTED1(EwkHostMsg_DidChangePageScaleFactor,
- double /* page scale factor */)
-
IPC_MESSAGE_ROUTED1(EwkViewMsg_SetDrawsTransparentBackground,
bool /* enabled */)
#endif
}
-void EWebView::SetScale(double scale_factor, int x, int y) {
-#if !defined(EWK_BRINGUP) // FIXME: m94 bringup
- RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
+void EWebView::SetScale(double scale_factor) {
// Do not cache |scale_factor| here as it may be discarded by Blink's
// minimumPageScaleFactor and maximumPageScaleFactor.
// |scale_factor| is cached as responde to DidChangePageScaleFactor.
- render_view_host->Send(new EwkViewMsg_Scale(render_view_host->GetRoutingID(),
- scale_factor, x, y));
-#endif
+ WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents_.get());
+ wci->GetPrimaryMainFrame()->GetAssociatedLocalMainFrame()->SetScaleFactor(
+ scale_factor);
}
bool EWebView::GetScrollPosition(int* x, int* y) const {
-#if !defined(USE_AURA)
- if (!rwhv()) {
- LOG(ERROR) << "rwhv() returns nullptr";
+ if (!rwhva()) {
+ LOG(ERROR) << "rwhva() returns nullptr";
return false;
}
-#endif
if (scroll_detector_->IsScrollOffsetChanged()) {
if (x)
*x = previous_scroll_position_.x();
}
void EWebView::ChangeScroll(int& x, int& y) {
-#if !defined(USE_AURA)
- if (!rwhv()) {
- LOG(ERROR) << "rwhv() returns nullptr";
+ if (!rwhva()) {
+ LOG(ERROR) << "rwhva() returns nullptr";
return;
}
-#endif
int max_x = 0;
int max_y = 0;
GetScrollSize(&max_x, &max_y);
void EWebView::DidChangeContentsSize(int width, int height) {
contents_size_ = gfx::Size(width, height);
SmartCallback<EWebViewCallbacks::ContentsSizeChanged>().call();
+ SetScaledContentsSize();
}
const Eina_Rectangle EWebView::GetContentsSize() const {
return rect;
}
-void EWebView::GetScrollSize(int* width, int* height) {
- if (width)
- *width = 0;
- if (height)
- *height = 0;
+void EWebView::SetScaledContentsSize() {
+ if (!rwhva())
+ return; // LCOV_EXCL_LINE
- Eina_Rectangle last_view_port =
- WebViewDelegateEwk::GetInstance().GetLastUsedViewPortArea(evas_object());
- int scaled_content_width =
- static_cast<int>(contents_size_.width() * page_scale_factor_);
- int scaled_content_height =
- static_cast<int>(contents_size_.height() * page_scale_factor_);
+ const float device_scale_factor =
+ display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+ gfx::SizeF scaled_contents_size = gfx::ConvertSizeToPixels(
+ contents_size_, device_scale_factor * page_scale_factor_);
+ rwhva()->offscreen_helper()->SetScaledContentSize(scaled_contents_size);
+}
- if (width && scaled_content_width > last_view_port.w)
- *width = scaled_content_width - last_view_port.w;
- if (height && scaled_content_height > last_view_port.h)
- *height = scaled_content_height - last_view_port.h;
+void EWebView::GetScrollSize(int* width, int* height) {
+ int w = 0, h = 0;
+ if (width) {
+ *width = (rwhva() &&
+ (w = rwhva()->offscreen_helper()->GetScrollableSize().width()))
+ ? w
+ : 0;
+ }
+ if (height) {
+ *height = (rwhva() &&
+ (h = rwhva()->offscreen_helper()->GetScrollableSize().height()))
+ ? h
+ : 0;
+ }
}
void EWebView::MoveCaret(const gfx::Point& point) {
#if !defined(USE_AURA)
GetWebContentsViewEfl()->SetPageScaleFactor(scale_factor);
#endif
+ SetScaledContentsSize();
}
inline JavaScriptDialogManagerEfl* EWebView::GetJavaScriptDialogManagerEfl() {
void HandleLongPressGesture(const content::ContextMenuParams&);
void ShowContextMenu(const content::ContextMenuParams&);
void CancelContextMenu(int request_id);
- void SetScale(double scale_factor, int x, int y);
+ void SetScale(double scale_factor);
bool GetScrollPosition(int* x, int* y) const;
void SetScroll(int x, int y);
void UrlRequestSet(const char* url,
void ExitFullscreen();
double GetScale();
void DidChangePageScaleFactor(double scale_factor);
+ void SetScaledContentsSize();
void SetJavaScriptAlertCallback(Ewk_View_JavaScript_Alert_Callback callback,
void* user_data);
void JavaScriptAlertReply();
Eina_Bool ewk_view_scale_set(Evas_Object* view, double scale_factor, int x, int y)
{
- // TODO: We should implement AC in order to work this API normally.
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
- impl->SetScale(scale_factor, x, y);
+ impl->SetScale(scale_factor);
+ impl->SetScroll(x, y);
return EINA_TRUE;
}
double ewk_view_scale_get(const Evas_Object *view)
{
- // TODO: We should implement AC in order to work this API normally.
EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
return impl->GetScale();
}
#endif
}
+void RenderFrameObserverEfl::DidUpdateMainFrameLayout() {
+ blink::WebView* view = render_frame()->GetWebView();
+ if (!view || !view->MainFrame() || !view->MainFrame()->IsWebLocalFrame())
+ return;
+
+ gfx::Size contents_size =
+ view->MainFrame()->ToWebLocalFrame()->DocumentSize();
+
+ // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a
+ // 0x0 size (this happens during initial load).
+ if (contents_size.IsEmpty()) {
+ contents_size = render_frame()
+ ->GetWebView()
+ ->ContentsPreferredMinimumSize();
+ }
+
+ if (contents_size == last_sent_contents_size_)
+ return;
+
+ last_sent_contents_size_ = contents_size;
+ Send(new EwkHostMsg_DidChangeContentsSize(render_frame()->GetRoutingID(),
+ contents_size.width(),
+ contents_size.height()));
+}
+
void RenderFrameObserverEfl::WillSubmitForm(
const blink::WebFormElement& form) {
GURL url(blink::WebStringToGURL(form.Action()));
int world_id) override;
void WillReleaseScriptContext(v8::Handle<v8::Context> context,
int world_id) override;
+ void DidUpdateMainFrameLayout() override;
private:
void OnSelectPopupMenuItems(bool canceled,
gfx::Size max_scroll_offset_;
gfx::Size last_scroll_offset_;
+ gfx::Size last_sent_contents_size_;
};
} // namespace content
IPC_MESSAGE_HANDLER(EwkHostMsg_WrtMessage, OnWrtPluginMessage)
IPC_MESSAGE_HANDLER_DELAY_REPLY(EwkHostMsg_WrtSyncMessage,
OnWrtPluginSyncMessage)
+ IPC_MESSAGE_HANDLER(EwkHostMsg_DidChangeContentsSize,
+ OnDidChangeContentsSize)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
}
}
+void WebContentsDelegateEfl::OnPageScaleFactorChanged(float page_scale_factor) {
+ web_view_->DidChangePageScaleFactor(page_scale_factor);
+}
+
+void WebContentsDelegateEfl::OnDidChangeContentsSize(int width, int height) {
+ web_view_->DidChangeContentsSize(width, height);
+}
+
} // namespace content
void LoadProgressChanged(double progress) override;
void DidFinishLoad(RenderFrameHost* render_frame_host,
const GURL& validated_url) override;
+ void OnPageScaleFactorChanged(float page_scale_factor) override;
void DidFailLoad(RenderFrameHost* render_frame_host,
const GURL& validated_url,
void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
IPC::Message* reply);
+ void OnDidChangeContentsSize(int width, int height);
void OnDidGetManifest(Ewk_View_Request_Manifest_Callback callback,
void* user_data,
static const char*const sample;
};
-const char*const utc_blink_ewk_view_scale_set::sample="/common/sample.html";
+const char* const utc_blink_ewk_view_scale_set::sample =
+ "/common/sample_2.html";
/**
* @brief Positive test case of ewk_view_scale_set(). Page is loaded, APIs for setting scale and retrieving its value are called.
const double getScaleFactor = ewk_view_scale_get(GetEwkWebView());
- if (scaleFactor != getScaleFactor)
+ Evas_Coord getCenterX = 0, getCenterY = 0;
+ ewk_view_scroll_pos_get(GetEwkWebView(), &getCenterX, &getCenterY);
+
+ if (scaleFactor != getScaleFactor || centerX != getCenterX ||
+ centerY != getCenterY)
result = EINA_FALSE;
utc_check_eq(result, EINA_TRUE);