- Revision
- 167253
- Author
- [email protected]
- Date
- 2014-04-14 10:27:59 -0700 (Mon, 14 Apr 2014)
Log Message
Make WK(Web)View magnification setters actually use view-relative positions
https://bugs.webkit.org/show_bug.cgi?id=131611
<rdar://problem/15965239>
Reviewed by Darin Adler.
* UIProcess/API/mac/WKView.mm:
(-[WKView setMagnification:centeredAtPoint:]):
(-[WKView setMagnification:]):
Use scalePageInViewCoordinates instead.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::scalePageInViewCoordinates):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scalePageInViewCoordinates):
(WebKit::WebPage::pageScaleFactor):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Add scalePageInViewCoordinates, which turns the scale centerpoint within the view
into what scalePage expects: a post-scale scroll offset.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (167252 => 167253)
--- trunk/Source/WebKit2/ChangeLog 2014-04-14 17:26:28 UTC (rev 167252)
+++ trunk/Source/WebKit2/ChangeLog 2014-04-14 17:27:59 UTC (rev 167253)
@@ -1,5 +1,29 @@
2014-04-14 Tim Horton <[email protected]>
+ Make WK(Web)View magnification setters actually use view-relative positions
+ https://bugs.webkit.org/show_bug.cgi?id=131611
+ <rdar://problem/15965239>
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView setMagnification:centeredAtPoint:]):
+ (-[WKView setMagnification:]):
+ Use scalePageInViewCoordinates instead.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::scalePageInViewCoordinates):
+ * UIProcess/WebPageProxy.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::scalePageInViewCoordinates):
+ (WebKit::WebPage::pageScaleFactor):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ Add scalePageInViewCoordinates, which turns the scale centerpoint within the view
+ into what scalePage expects: a post-scale scroll offset.
+
+2014-04-14 Tim Horton <[email protected]>
+
Support setting a background color on page overlays
https://bugs.webkit.org/show_bug.cgi?id=131600
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (167252 => 167253)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2014-04-14 17:26:28 UTC (rev 167252)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2014-04-14 17:27:59 UTC (rev 167253)
@@ -3869,13 +3869,13 @@
- (void)setMagnification:(double)magnification centeredAtPoint:(NSPoint)point
{
- _data->_page->scalePage(magnification, roundedIntPoint(point));
+ _data->_page->scalePageInViewCoordinates(magnification, roundedIntPoint(point));
}
- (void)setMagnification:(double)magnification
{
FloatPoint viewCenter(NSMidX([self bounds]), NSMidY([self bounds]));
- _data->_page->scalePage(magnification, roundedIntPoint(viewCenter));
+ _data->_page->scalePageInViewCoordinates(magnification, roundedIntPoint(viewCenter));
}
- (double)magnification
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (167252 => 167253)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-04-14 17:26:28 UTC (rev 167252)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-04-14 17:27:59 UTC (rev 167253)
@@ -1730,6 +1730,15 @@
m_process->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
}
+void WebPageProxy::scalePageInViewCoordinates(double scale, const IntPoint& centerInViewCoordinates)
+{
+ if (!isValid())
+ return;
+
+ m_pageScaleFactor = scale;
+ m_process->send(Messages::WebPage::ScalePageInViewCoordinates(scale, centerInViewCoordinates), m_pageID);
+}
+
void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
{
if (m_intrinsicDeviceScaleFactor == scaleFactor)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (167252 => 167253)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-04-14 17:26:28 UTC (rev 167252)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-04-14 17:27:59 UTC (rev 167253)
@@ -731,6 +731,7 @@
void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
void scalePage(double scale, const WebCore::IntPoint& origin);
+ void scalePageInViewCoordinates(double scale, const WebCore::IntPoint& centerInViewCoordinates);
double pageScaleFactor() const { return m_pageScaleFactor; }
float deviceScaleFactor() const;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (167252 => 167253)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2014-04-14 17:26:28 UTC (rev 167252)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2014-04-14 17:27:59 UTC (rev 167253)
@@ -1298,12 +1298,23 @@
send(Messages::WebPageProxy::PageScaleFactorDidChange(scale));
}
+void WebPage::scalePageInViewCoordinates(double scale, IntPoint centerInViewCoordinates)
+{
+ if (scale == pageScaleFactor())
+ return;
+
+ IntPoint scrollPositionAtNewScale = mainFrameView()->rootViewToContents(-centerInViewCoordinates);
+ double scaleRatio = scale / pageScaleFactor();
+ scrollPositionAtNewScale.scale(scaleRatio, scaleRatio);
+ scalePage(scale, scrollPositionAtNewScale);
+}
+
double WebPage::pageScaleFactor() const
{
PluginView* pluginView = pluginViewForFrame(&m_page->mainFrame());
if (pluginView && pluginView->handlesPageScaleFactor())
return pluginView->pageScaleFactor();
-
+
return m_page->pageScaleFactor();
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (167252 => 167253)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-04-14 17:26:28 UTC (rev 167252)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-04-14 17:27:59 UTC (rev 167253)
@@ -349,6 +349,7 @@
void windowScreenDidChange(uint64_t);
void scalePage(double scale, const WebCore::IntPoint& origin);
+ void scalePageInViewCoordinates(double scale, WebCore::IntPoint centerInViewCoordinates);
double pageScaleFactor() const;
void setUseFixedLayout(bool);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (167252 => 167253)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-04-14 17:26:28 UTC (rev 167252)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-04-14 17:27:59 UTC (rev 167253)
@@ -167,6 +167,7 @@
WindowScreenDidChange(uint64_t displayID)
ScalePage(double scale, WebCore::IntPoint origin)
+ ScalePageInViewCoordinates(double scale, WebCore::IntPoint centerInViewCoordinates)
SetUseFixedLayout(bool fixed)
SetFixedLayoutSize(WebCore::IntSize size)