From 684881e57a5bd54f465b54bd494c57241efc8ebd Mon Sep 17 00:00:00 2001 From: Changhyup Jwa Date: Mon, 30 Sep 2013 15:26:21 +0900 Subject: [PATCH] Suspend URL until view size is calculated [Title] Suspend URL until view size is calculated [Issue#] N_SE-51169, 51201 [Problem] Sometimes JS window.innerHeight returns incorrect height [Cause] JS runs before view size is calculated [Solution] Suspend URL load until view size is calculated Change-Id: I7b5413daf58fa48fc4cd85e92cad31f94d47f6ed --- Source/WTF/wtf/Platform.h | 2 ++ Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h | 11 +++++++++ .../WebKit2/UIProcess/API/efl/PageClientImpl.cpp | 26 +++++----------------- Source/WebKit2/UIProcess/API/efl/PageClientImpl.h | 6 ++--- Source/WebKit2/UIProcess/API/efl/ewk_view.cpp | 25 ++++++++++++++++----- 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h index 0e8139c..f59a8e8 100644 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -807,6 +807,8 @@ com) : Patch to do not adjust cover rect as fixed pixel size*/ #define ENABLE_TIZEN_WEBKIT2_FORM_DATABASE 1 /* Changhyup Jwa(ch.jwa@samsung.com) : Form database support */ +#define ENABLE_TIZEN_WEBKIT2_SUSPEND_LOADING_URL 1 /* Changhyup Jwa(ch.jwa@samsung.com) : Suspend loading URL while view size is empty */ + #define ENABLE_TIZEN_RESET_CACHEDFRAME_CONTENTSIZE_ON_NAVIGATION 1 /* Divakar.A (divakar.a@samsung.com) : Resetting contentSize of CachedFrameView on navigation. This flag will be removed once latest opensource merge is done. */ #define ENABLE_TIZEN_CSP 1 /* Seonae Kim(sunaeluv.kim@samsung.com) : Support CSP to provide EWK API to web applicatoin */ diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h index 1491f80..1c71ef3 100755 --- a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h @@ -194,6 +194,12 @@ public: bool isVisible() const; const char* url() const { return m_url; } + +#if ENABLE(TIZEN_WEBKIT2_SUSPEND_LOADING_URL) + const char* suspendedURL() { return m_suspendedURL; } + void setSuspendedURL(const char* url) { m_suspendedURL = url; } +#endif + const char* faviconURL() const { return m_faviconURL; } const char* title() const; WebKit::InputMethodContextEfl* inputMethodContext(); @@ -518,6 +524,11 @@ private: WKEinaSharedString m_cursorGroup; WKEinaSharedString m_faviconURL; WKEinaSharedString m_url; + +#if ENABLE(TIZEN_WEBKIT2_SUSPEND_LOADING_URL) + WKEinaSharedString m_suspendedURL; +#endif + mutable WKEinaSharedString m_title; WKEinaSharedString m_theme; mutable WKEinaSharedString m_customEncoding; diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index b306e20..a2a07f3 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -187,28 +187,17 @@ double PageClientImpl::adjustScaleWithViewport(double scale) } #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) -void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle) +void PageClientImpl::updateViewportSize(const IntSize& viewportSize) { #if ENABLE(TIZEN_DLOG_SUPPORT) - TIZEN_LOGI(" view size: [%d, %d], angle: [%d]", viewportSize.width(), viewportSize.height(), angle); + TIZEN_LOGI(" view size: [%d, %d]", viewportSize.width(), viewportSize.height()); #endif // update viewport size of webkit m_visibleContentRect.setSize(viewportSize); - m_viewImpl->page()->setViewportSize(viewportSize); -} - -void PageClientImpl::updateVisibleContentRectSize(const IntSize& size) -{ - // update visible content rect's size and scroll position - m_visibleContentRect.setSize(size); m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor); m_viewImpl->setScrollPosition(m_visibleContentRect.location()); - -#if ENABLE(TIZEN_DLOG_SUPPORT) - TIZEN_LOGI("size: [%d, %d], visibleContentRect: [%d, %d, %d, %d]", size.width(), size.height(), - m_visibleContentRect.x(), m_visibleContentRect.y(), m_visibleContentRect.width(), m_visibleContentRect.height()); -#endif + m_viewImpl->page()->setViewportSize(viewportSize); } #endif @@ -1503,12 +1492,7 @@ PageClientEvasGL::~PageClientEvasGL() m_viewImpl->page()->close(); } -void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle) -{ - PageClientImpl::updateViewportSize(viewportSize, angle); -} - -void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size) +void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize) { if (m_surface) { evas_gl_surface_destroy(m_evasGL, m_surface); @@ -1516,7 +1500,7 @@ void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size } setTargetSurface(); - PageClientImpl::updateVisibleContentRectSize(size); + PageClientImpl::updateViewportSize(viewportSize); } void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect) diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h index 311fc18..5c58d30 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h @@ -115,8 +115,7 @@ public: ViewportConstraints computeViewportConstraints(const WebCore::ViewportAttributes&); double adjustScaleWithViewport(double); #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) - TIZEN_VIRTUAL void updateViewportSize(const WebCore::IntSize&, const int); - TIZEN_VIRTUAL void updateVisibleContentRectSize(const WebCore::IntSize&); + TIZEN_VIRTUAL void updateViewportSize(const WebCore::IntSize&); #endif void prepareRestoredVisibleContectRect(); void initializeVisibleContentRect(); @@ -489,8 +488,7 @@ public: } ~PageClientEvasGL(); - virtual void updateViewportSize(const WebCore::IntSize&, const int); - virtual void updateVisibleContentRectSize(const WebCore::IntSize&); + virtual void updateViewportSize(const WebCore::IntSize&); virtual void setViewNeedsDisplay(const WebCore::IntRect&); virtual void displayViewport(); virtual void drawContents(); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index 4f3a6b3..5e1ef7f 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -928,9 +928,6 @@ static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_ EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl); #if ENABLE(TIZEN_WEBKIT2_TILED_AC) evas_object_image_native_surface_set(smartData->image, 0); - - Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas); - impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee)); #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION) if (!ewk_view_is_opengl_backend(ewkView)) _ewk_view_composite(smartData); @@ -1000,7 +997,7 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) #endif #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR) Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas); - impl->pageClient->updateVisibleContentRectSize(IntSize(width, height)); + impl->pageClient->updateViewportSize(IntSize(width, height)); if (ewk_view_is_opengl_backend(ewkView)) impl->pageClient->displayViewport(); #endif @@ -1009,6 +1006,15 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) impl->pageClient->frameRectChanged(); #endif } + +#if ENABLE(TIZEN_WEBKIT2_SUSPEND_LOADING_URL) + // Load URL if it's suspended + if (impl->suspendedURL()) { + TIZEN_LOGI("load suspended URL: %s, time: %f", impl->suspendedURL() ? impl->suspendedURL() : "NULL", ecore_time_get() * 1000); + ewk_view_url_set(ewkView, impl->suspendedURL()); + impl->setSuspendedURL(0); + } +#endif #endif // #if OS(TIZEN) } @@ -1414,6 +1420,15 @@ Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url) EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(url, false); +#if ENABLE(TIZEN_WEBKIT2_SUSPEND_LOADING_URL) + // Suspend loading URL before view size is calculated + if (!smartData->view.w || !smartData->view.h) { + impl->setSuspendedURL(url); + TIZEN_LOGI("suspended URL: %s, time: %f", impl->suspendedURL() ? impl->suspendedURL() : "NULL", ecore_time_get() * 1000); + return true; + } +#endif + impl->pageProxy->loadURL(String::fromUTF8(url)); impl->informURLChange(); @@ -4860,7 +4875,7 @@ void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle) impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize()); impl->pageClient->setWaitFrameOfNewViewortSize(true); ewk_view_suspend(ewkView); - impl->pageClient->updateViewportSize(IntSize(width, height), angle); + impl->pageClient->updateViewportSize(IntSize(width, height)); #endif } -- 2.7.4