Commit daa44c12 authored by mikhail.pozdnyakov@intel.com's avatar mikhail.pozdnyakov@intel.com
Browse files

[WK2][EFL] WebView should own page position and scale factor

https://bugs.webkit.org/show_bug.cgi?id=111075

Reviewed by Andreas Kling.

View content position and content scale factor should belong to WebView
rather than to EwkView as it decreases EwkView usage inside EFL-agnostic
WebView and improves WebView encapsulation.

* UIProcess/API/C/efl/WKView.cpp:
(WKViewGetContentScaleFactor):
(WKViewSetContentScaleFactor):

    New WKView API was added to set and get content scale factor.
    The view content scale factor is not the same as page scale factor:
    it always applies to content but not necessarily applies to the page.
    The view content scale factor is calculated by viewport controller
    and applies immediately for painting in UI process. Page scale factor
    is updated later after the frame is rendered to accomplish the pending
    scale change.

(WKViewGetContentPosition):
(WKViewSetContentPosition):

    New WKView API was added to set and get content position.
    Content position is set in UI units.

* UIProcess/API/C/efl/WKView.h:
* UIProcess/API/efl/EwkView.cpp:
(EwkView::EwkView):
* UIProcess/API/efl/EwkView.h:
(EwkView):
* UIProcess/efl/PageViewportControllerClientEfl.cpp:
(WebKit::PageViewportControllerClientEfl::setViewportPosition):
(WebKit::PageViewportControllerClientEfl::setPageScaleFactor):
* UIProcess/efl/WebView.cpp:
(WebKit::WebView::WebView):
(WebKit::WebView::paintToCairoSurface):
(WebKit::WebView::transformToScene):
(WebKit::WebView::updateViewportSize):
(WebKit::WebView::pageDidRequestScroll):
* UIProcess/efl/WebView.h:
(WebKit::WebView::setContentScaleFactor):
(WebKit::WebView::contentScaleFactor):
(WebView):
(WebKit::WebView::setContentPosition):
(WebKit::WebView::contentPosition):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147741 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 60a29804
2013-04-05 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
[WK2][EFL] WebView should own page position and scale factor
https://bugs.webkit.org/show_bug.cgi?id=111075
Reviewed by Andreas Kling.
View content position and content scale factor should belong to WebView
rather than to EwkView as it decreases EwkView usage inside EFL-agnostic
WebView and improves WebView encapsulation.
* UIProcess/API/C/efl/WKView.cpp:
(WKViewGetContentScaleFactor):
(WKViewSetContentScaleFactor):
New WKView API was added to set and get content scale factor.
The view content scale factor is not the same as page scale factor:
it always applies to content but not necessarily applies to the page.
The view content scale factor is calculated by viewport controller
and applies immediately for painting in UI process. Page scale factor
is updated later after the frame is rendered to accomplish the pending
scale change.
(WKViewGetContentPosition):
(WKViewSetContentPosition):
New WKView API was added to set and get content position.
Content position is set in UI units.
* UIProcess/API/C/efl/WKView.h:
* UIProcess/API/efl/EwkView.cpp:
(EwkView::EwkView):
* UIProcess/API/efl/EwkView.h:
(EwkView):
* UIProcess/efl/PageViewportControllerClientEfl.cpp:
(WebKit::PageViewportControllerClientEfl::setViewportPosition):
(WebKit::PageViewportControllerClientEfl::setPageScaleFactor):
* UIProcess/efl/WebView.cpp:
(WebKit::WebView::WebView):
(WebKit::WebView::paintToCairoSurface):
(WebKit::WebView::transformToScene):
(WebKit::WebView::updateViewportSize):
(WebKit::WebView::pageDidRequestScroll):
* UIProcess/efl/WebView.h:
(WebKit::WebView::setContentScaleFactor):
(WebKit::WebView::contentScaleFactor):
(WebView):
(WebKit::WebView::setContentPosition):
(WebKit::WebView::contentPosition):
2013-04-05 Alberto Garcia <agarcia@igalia.com>
 
[GTK][WK2] WebKitLoaderClient: add missing initializers
......@@ -75,6 +75,27 @@ void WKViewSetIsVisible(WKViewRef viewRef, bool isVisible)
toImpl(viewRef)->setVisible(isVisible);
}
float WKViewGetContentScaleFactor(WKViewRef viewRef)
{
return toImpl(viewRef)->contentScaleFactor();
}
void WKViewSetContentScaleFactor(WKViewRef viewRef, float scale)
{
toImpl(viewRef)->setContentScaleFactor(scale);
}
WKPoint WKViewGetContentPosition(WKViewRef viewRef)
{
const WebCore::FloatPoint& result = toImpl(viewRef)->contentPosition();
return WKPointMake(result.x(), result.y());
}
void WKViewSetContentPosition(WKViewRef viewRef, WKPoint position)
{
toImpl(viewRef)->setContentPosition(WebCore::FloatPoint(position.x, position.y));
}
void WKViewSetUserViewportTranslation(WKViewRef viewRef, double tx, double ty)
{
toImpl(viewRef)->setUserViewportTranslation(tx, ty);
......
......@@ -64,6 +64,12 @@ WK_EXPORT void WKViewSetIsFocused(WKViewRef, bool);
WK_EXPORT bool WKViewIsVisible(WKViewRef);
WK_EXPORT void WKViewSetIsVisible(WKViewRef, bool);
WK_EXPORT float WKViewGetContentScaleFactor(WKViewRef);
WK_EXPORT void WKViewSetContentScaleFactor(WKViewRef, float);
WK_EXPORT WKPoint WKViewGetContentPosition(WKViewRef);
WK_EXPORT void WKViewSetContentPosition(WKViewRef, WKPoint);
WK_EXPORT void WKViewSetUserViewportTranslation(WKViewRef, double tx, double ty);
WK_EXPORT WKPoint WKViewUserViewportToContents(WKViewRef, WKPoint);
......
......@@ -251,7 +251,6 @@ EwkView::EwkView(WKViewRef view, Evas_Object* evasObject)
, m_vibrationClient(VibrationClientEfl::create(this))
#endif
, m_backForwardList(EwkBackForwardList::create(WKPageGetBackForwardList(wkPage())))
, m_pageScaleFactor(1)
, m_settings(EwkSettings::create(this))
, m_cursorIdentifier(0)
, m_mouseEventsEnabled(false)
......
......@@ -188,12 +188,6 @@ public:
// FIXME: Remove when possible.
WebKit::WebView* webView();
void setPageScaleFactor(float scaleFactor) { m_pageScaleFactor = scaleFactor; }
float pageScaleFactor() const { return m_pageScaleFactor; }
void setPagePosition(const WebCore::FloatPoint& position) { m_pagePosition = position; }
const WebCore::FloatPoint pagePosition() const { return m_pagePosition; }
// FIXME: needs refactoring (split callback invoke)
void informURLChange();
......@@ -261,8 +255,6 @@ private:
OwnPtr<WebKit::VibrationClientEfl> m_vibrationClient;
#endif
OwnPtr<EwkBackForwardList> m_backForwardList;
float m_pageScaleFactor;
WebCore::FloatPoint m_pagePosition;
OwnPtr<EwkSettings> m_settings;
RefPtr<EwkWindowFeatures> m_windowFeatures;
const void* m_cursorIdentifier; // This is an address, do not free it.
......
......@@ -51,15 +51,16 @@ void PageViewportControllerClientEfl::setViewportPosition(const WebCore::FloatPo
m_contentPosition = contentsPoint;
FloatPoint pos(contentsPoint);
pos.scale(m_view->pageScaleFactor(), m_view->pageScaleFactor());
m_view->setPagePosition(pos);
float scaleFactor = WKViewGetContentScaleFactor(m_view->wkView());
pos.scale(scaleFactor, scaleFactor);
WKViewSetContentPosition(m_view->wkView(), WKPointMake(pos.x(), pos.y()));
m_controller->didChangeContentsVisibility(m_contentPosition, m_view->pageScaleFactor());
m_controller->didChangeContentsVisibility(m_contentPosition, scaleFactor);
}
void PageViewportControllerClientEfl::setPageScaleFactor(float newScale)
{
m_view->setPageScaleFactor(newScale);
WKViewSetContentScaleFactor(m_view->wkView(), newScale);
}
void PageViewportControllerClientEfl::didChangeVisibleContents()
......
......@@ -56,6 +56,7 @@ WebView::WebView(WebContext* context, WebPageGroup* pageGroup)
, m_page(context->createWebPage(this, pageGroup))
, m_focused(false)
, m_visible(false)
, m_contentScaleFactor(1.0)
{
m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
m_page->pageGroup()->preferences()->setForceCompositingMode(true);
......@@ -153,10 +154,10 @@ void WebView::paintToCairoSurface(cairo_surface_t* surface)
PlatformContextCairo context(cairo_create(surface));
const FloatPoint& pagePosition = m_ewkView->pagePosition();
double effectiveScale = m_page->deviceScaleFactor() * m_ewkView->pageScaleFactor();
const FloatPoint& position = contentPosition();
double effectiveScale = m_page->deviceScaleFactor() * contentScaleFactor();
cairo_matrix_t transform = { effectiveScale, 0, 0, effectiveScale, -pagePosition.x() * m_page->deviceScaleFactor(), -pagePosition.y() * m_page->deviceScaleFactor() };
cairo_matrix_t transform = { effectiveScale, 0, 0, effectiveScale, - position.x() * m_page->deviceScaleFactor(), - position.y() * m_page->deviceScaleFactor() };
cairo_set_matrix(context.cr(), &transform);
scene->paintToGraphicsContext(&context);
......@@ -247,10 +248,10 @@ AffineTransform WebView::transformToScene() const
{
TransformationMatrix transform = m_userViewportTransform;
const FloatPoint& pagePosition = m_ewkView->pagePosition();
const FloatPoint& position = contentPosition();
transform.scale(m_page->deviceScaleFactor());
transform.translate(-pagePosition.x(), -pagePosition.y());
transform.scale(m_ewkView->pageScaleFactor());
transform.translate(-position.x(), -position.y());
transform.scale(contentScaleFactor());
return transform.toAffineTransform();
}
......@@ -273,7 +274,7 @@ void WebView::updateViewportSize()
if (DrawingAreaProxy* drawingArea = page()->drawingArea()) {
// Web Process expects sizes in UI units, and not raw device units.
drawingArea->setSize(roundedIntSize(dipSize()), IntSize());
drawingArea->setVisibleContentsRect(FloatRect(m_ewkView->pagePosition(), dipSize()), FloatPoint());
drawingArea->setVisibleContentsRect(FloatRect(contentPosition(), dipSize()), FloatPoint());
}
}
......@@ -541,8 +542,8 @@ void WebView::pageDidRequestScroll(const IntPoint& position)
return;
}
FloatPoint uiPosition(position);
uiPosition.scale(m_ewkView->pageScaleFactor(), m_ewkView->pageScaleFactor());
m_ewkView->setPagePosition(uiPosition);
uiPosition.scale(contentScaleFactor(), contentScaleFactor());
setContentPosition(uiPosition);
m_ewkView->scheduleUpdateDisplay();
}
......
......@@ -66,6 +66,12 @@ public:
bool isVisible() const { return m_visible; }
void setVisible(bool);
void setContentScaleFactor(float scaleFactor) { m_contentScaleFactor = scaleFactor; }
float contentScaleFactor() const { return m_contentScaleFactor; }
void setContentPosition(const WebCore::FloatPoint& position) { m_contentPosition = position; }
const WebCore::FloatPoint& contentPosition() const { return m_contentPosition; }
void setUserViewportTranslation(double tx, double ty);
WebCore::IntPoint userViewportToContents(const WebCore::IntPoint&) const;
......@@ -193,6 +199,8 @@ private:
WebCore::IntSize m_size; // Size in device units.
bool m_focused;
bool m_visible;
float m_contentScaleFactor;
WebCore::FloatPoint m_contentPosition; // Position in UI units.
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment