Title: [186786] trunk/Source
- Revision
- 186786
- Author
- [email protected]
- Date
- 2015-07-13 15:24:10 -0700 (Mon, 13 Jul 2015)
Log Message
[iOS WK2] When choosing an initial viewport scale, take overflow on the <body> into account
https://bugs.webkit.org/show_bug.cgi?id=146918
rdar://problem/9222837
Reviewed by Tim Horton.
Use as input to the viewport scaling algorithm a contents size from the FrameView
that takes overflow on the viewport renderer into account. This prevents unexpected
viewports scaling on pages that have content that overflows their expressed contents size,
but apply overflow to the <body>.
Source/WebCore:
* page/FrameView.cpp:
(WebCore::FrameView::contentsSizeRespectingOverflow): Look for overflow:hidden on each axis of
the m_viewportRenderer, which is computed post-layout by calculateScrollbarModesForLayout()
and is used for scrollbar logic on OS X. Clip unscaledDocumentRect on each axis, and then
apply page scale.
* page/FrameView.h:
Source/WebKit2:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mainFrameDidLayout): Use contentsSizeRespectingOverflow(),
rather than raw contentsSize(), to determine scaling.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (186785 => 186786)
--- trunk/Source/WebCore/ChangeLog 2015-07-13 22:16:54 UTC (rev 186785)
+++ trunk/Source/WebCore/ChangeLog 2015-07-13 22:24:10 UTC (rev 186786)
@@ -1,3 +1,23 @@
+2015-07-13 Simon Fraser <[email protected]>
+
+ [iOS WK2] When choosing an initial viewport scale, take overflow on the <body> into account
+ https://bugs.webkit.org/show_bug.cgi?id=146918
+ rdar://problem/9222837
+
+ Reviewed by Tim Horton.
+
+ Use as input to the viewport scaling algorithm a contents size from the FrameView
+ that takes overflow on the viewport renderer into account. This prevents unexpected
+ viewports scaling on pages that have content that overflows their expressed contents size,
+ but apply overflow to the <body>.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::contentsSizeRespectingOverflow): Look for overflow:hidden on each axis of
+ the m_viewportRenderer, which is computed post-layout by calculateScrollbarModesForLayout()
+ and is used for scrollbar logic on OS X. Clip unscaledDocumentRect on each axis, and then
+ apply page scale.
+ * page/FrameView.h:
+
2015-07-13 Brent Fulgham <[email protected]>
Update WebCore Features.json
Modified: trunk/Source/WebCore/page/FrameView.cpp (186785 => 186786)
--- trunk/Source/WebCore/page/FrameView.cpp 2015-07-13 22:16:54 UTC (rev 186785)
+++ trunk/Source/WebCore/page/FrameView.cpp 2015-07-13 22:24:10 UTC (rev 186786)
@@ -617,6 +617,29 @@
setContentsSize(size);
}
+IntSize FrameView::contentsSizeRespectingOverflow() const
+{
+ RenderView* renderView = this->renderView();
+ if (!renderView || !m_viewportRenderer || !is<RenderBox>(m_viewportRenderer) || !frame().isMainFrame())
+ return contentsSize();
+
+ ASSERT(frame().view() == this);
+
+ FloatRect contentRect = renderView->unscaledDocumentRect();
+ RenderBox& viewportRendererBox = downcast<RenderBox>(*m_viewportRenderer);
+
+ if (m_viewportRenderer->style().overflowX() == OHIDDEN)
+ contentRect.setWidth(std::min<float>(contentRect.width(), viewportRendererBox.frameRect().width()));
+
+ if (m_viewportRenderer->style().overflowY() == OHIDDEN)
+ contentRect.setHeight(std::min<float>(contentRect.height(), viewportRendererBox.frameRect().height()));
+
+ if (renderView->hasTransform())
+ contentRect = renderView->layer()->currentTransform().mapRect(contentRect);
+
+ return IntSize(contentRect.size());
+}
+
void FrameView::applyOverflowToViewport(RenderElement* renderer, ScrollbarMode& hMode, ScrollbarMode& vMode)
{
// Handle the overflow:hidden/scroll case for the body/html elements. WinIE treats
Modified: trunk/Source/WebCore/page/FrameView.h (186785 => 186786)
--- trunk/Source/WebCore/page/FrameView.h 2015-07-13 22:16:54 UTC (rev 186785)
+++ trunk/Source/WebCore/page/FrameView.h 2015-07-13 22:24:10 UTC (rev 186786)
@@ -105,6 +105,8 @@
virtual void setContentsSize(const IntSize&) override;
virtual void updateContentsSize() override;
+ WEBCORE_EXPORT IntSize contentsSizeRespectingOverflow() const;
+
void layout(bool allowSubtree = true);
WEBCORE_EXPORT bool didFirstLayout() const;
void layoutTimerFired();
Modified: trunk/Source/WebKit2/ChangeLog (186785 => 186786)
--- trunk/Source/WebKit2/ChangeLog 2015-07-13 22:16:54 UTC (rev 186785)
+++ trunk/Source/WebKit2/ChangeLog 2015-07-13 22:24:10 UTC (rev 186786)
@@ -1,3 +1,20 @@
+2015-07-13 Simon Fraser <[email protected]>
+
+ [iOS WK2] When choosing an initial viewport scale, take overflow on the <body> into account
+ https://bugs.webkit.org/show_bug.cgi?id=146918
+ rdar://problem/9222837
+
+ Reviewed by Tim Horton.
+
+ Use as input to the viewport scaling algorithm a contents size from the FrameView
+ that takes overflow on the viewport renderer into account. This prevents unexpected
+ viewports scaling on pages that have content that overflows their expressed contents size,
+ but apply overflow to the <body>.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::mainFrameDidLayout): Use contentsSizeRespectingOverflow(),
+ rather than raw contentsSize(), to determine scaling.
+
2015-07-13 Dan Bernstein <[email protected]>
Fixed the build.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (186785 => 186786)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-07-13 22:16:54 UTC (rev 186785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-07-13 22:24:10 UTC (rev 186786)
@@ -3508,7 +3508,7 @@
#endif
#if PLATFORM(IOS)
if (FrameView* frameView = mainFrameView()) {
- IntSize newContentSize = frameView->contentsSize();
+ IntSize newContentSize = frameView->contentsSizeRespectingOverflow();
if (m_viewportConfiguration.contentsSize() != newContentSize) {
m_viewportConfiguration.setContentsSize(newContentSize);
viewportConfigurationChanged();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes