Diff
Modified: trunk/Source/WebCore/ChangeLog (168601 => 168602)
--- trunk/Source/WebCore/ChangeLog 2014-05-11 19:46:53 UTC (rev 168601)
+++ trunk/Source/WebCore/ChangeLog 2014-05-11 21:02:52 UTC (rev 168602)
@@ -1,3 +1,42 @@
+2014-05-11 Beth Dakin <bda...@apple.com>
+
+ Headers and footers are not positioned correctly with topContentInset
+ https://bugs.webkit.org/show_bug.cgi?id=132787
+ -and corresponding-
+ <rdar://problem/16641115>
+
+ Reviewed by Tim Horton.
+
+ Headers and footers need to take the inset into account, and they also need to
+ factor in the fact that the root layer moves around now too.
+
+ The existing yPositionForRootContentLayer() is actually the right calculation for
+ the header layer. The root content layer wants that value, but pushed down by the
+ header height. Now there are static functions for both of them and the footer to
+ avoid duplicated code in the three spots where we need this information.
+ * page/FrameView.cpp:
+ (WebCore::FrameView::yPositionForHeaderLayer):
+ (WebCore::FrameView::yPositionForRootContentLayer):
+ (WebCore::FrameView::yPositionForFooterLayer):
+ * page/FrameView.h:
+
+ Use the static functions to compute the layer positions.
+ * page/scrolling/AsyncScrollingCoordinator.cpp:
+ (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
+
+ How did headers ever work with this bug?? I don’t know. We need to return that
+ layer.
+ * page/scrolling/ScrollingCoordinator.cpp:
+ (WebCore::ScrollingCoordinator::headerLayerForFrameView):
+
+ Use the static functions to compute the layer positions.
+ * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeScrollingNodeMac::setScrollLayerPosition):
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+ (WebCore::RenderLayerCompositor::updateLayerForHeader):
+ (WebCore::RenderLayerCompositor::updateLayerForFooter):
+
2014-05-11 Zalan Bujtas <za...@apple.com>
Subpixel rendering[iOS]: <select> decoration is misaligned when the renderer is on subpixel position.
Modified: trunk/Source/WebCore/page/FrameView.cpp (168601 => 168602)
--- trunk/Source/WebCore/page/FrameView.cpp 2014-05-11 19:46:53 UTC (rev 168601)
+++ trunk/Source/WebCore/page/FrameView.cpp 2014-05-11 21:02:52 UTC (rev 168602)
@@ -1616,12 +1616,11 @@
return topContentInset - scrollY;
}
-float FrameView::yPositionForRootContentLayer(const FloatPoint& scrollPosition, float topContentInset)
+float FrameView::yPositionForHeaderLayer(const FloatPoint& scrollPosition, float topContentInset)
{
if (!topContentInset)
return 0;
- // The rootContentLayer should not move for negative scroll values.
float scrollY = std::max<float>(0, scrollPosition.y());
if (scrollY >= topContentInset)
@@ -1629,7 +1628,17 @@
return scrollY;
}
-
+
+float FrameView::yPositionForRootContentLayer(const FloatPoint& scrollPosition, float topContentInset, float headerHeight)
+{
+ return yPositionForHeaderLayer(scrollPosition, topContentInset) + headerHeight;
+}
+
+float FrameView::yPositionForFooterLayer(const FloatPoint& scrollPosition, float topContentInset, float totalContentsHeight, float footerHeight)
+{
+ return yPositionForHeaderLayer(scrollPosition, topContentInset) + totalContentsHeight - footerHeight;
+}
+
#if PLATFORM(IOS)
LayoutRect FrameView::rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements scrollBehavior)
{
Modified: trunk/Source/WebCore/page/FrameView.h (168601 => 168602)
--- trunk/Source/WebCore/page/FrameView.h 2014-05-11 19:46:53 UTC (rev 168601)
+++ trunk/Source/WebCore/page/FrameView.h 2014-05-11 21:02:52 UTC (rev 168602)
@@ -277,10 +277,12 @@
// Static function can be called from another thread.
static LayoutSize scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
- // These layers are positioned differently when there is a topContentInset. These value need to be computed
+ // These layers are positioned differently when there is a topContentInset, a header, or a footer. These value need to be computed
// on both the main thread and the scrolling thread.
static float yPositionForInsetClipLayer(const FloatPoint& scrollPosition, float topContentInset);
- static float yPositionForRootContentLayer(const FloatPoint& scrollPosition, float topContentInset);
+ static float yPositionForRootContentLayer(const FloatPoint& scrollPosition, float topContentInset, float headerHeight);
+ static float yPositionForHeaderLayer(const FloatPoint& scrollPosition, float topContentInset);
+ static float yPositionForFooterLayer(const FloatPoint& scrollPosition, float topContentInset, float totalContentsHeight, float footerHeight);
#if PLATFORM(IOS)
LayoutRect viewportConstrainedObjectsRect() const;
Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (168601 => 168602)
--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp 2014-05-11 19:46:53 UTC (rev 168601)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp 2014-05-11 21:02:52 UTC (rev 168602)
@@ -223,7 +223,10 @@
float topContentInset = frameView->topContentInset();
FloatPoint positionForInsetClipLayer = FloatPoint(0, FrameView::yPositionForInsetClipLayer(scrollPosition, topContentInset));
FloatPoint positionForContentsLayer = FloatPoint(scrolledContentsLayer->position().x(),
- FrameView::yPositionForRootContentLayer(scrollPosition, topContentInset));
+ FrameView::yPositionForRootContentLayer(scrollPosition, topContentInset, frameView->headerHeight()));
+ FloatPoint positionForHeaderLayer = FloatPoint(scrollOffsetForFixed.width(), FrameView::yPositionForHeaderLayer(scrollPosition, topContentInset));
+ FloatPoint positionForFooterLayer = FloatPoint(scrollOffsetForFixed.width(),
+ FrameView::yPositionForFooterLayer(scrollPosition, topContentInset, frameView->totalContentsSize().height(), frameView->footerHeight()));
if (programmaticScroll || scrollingLayerPositionAction == SetScrollingLayerPosition) {
scrollLayer->setPosition(-frameView->scrollPosition());
@@ -234,9 +237,9 @@
if (scrolledContentsLayer)
scrolledContentsLayer->setPosition(positionForContentsLayer);
if (headerLayer)
- headerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
+ headerLayer->setPosition(positionForHeaderLayer);
if (footerLayer)
- footerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), frameView->totalContentsSize().height() - frameView->footerHeight()));
+ footerLayer->setPosition(positionForFooterLayer);
} else {
scrollLayer->syncPosition(-frameView->scrollPosition());
if (counterScrollingLayer)
@@ -246,9 +249,9 @@
if (scrolledContentsLayer)
scrolledContentsLayer->syncPosition(positionForContentsLayer);
if (headerLayer)
- headerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
+ headerLayer->syncPosition(positionForHeaderLayer);
if (footerLayer)
- footerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), frameView->totalContentsSize().height() - frameView->footerHeight()));
+ footerLayer->syncPosition(positionForFooterLayer);
LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect();
syncChildPositions(viewportRect);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (168601 => 168602)
--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2014-05-11 19:46:53 UTC (rev 168601)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2014-05-11 21:02:52 UTC (rev 168602)
@@ -214,18 +214,18 @@
{
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor().scrollLayer();
- return 0;
+ return nullptr;
}
GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView* frameView)
{
#if ENABLE(RUBBER_BANDING)
if (RenderView* renderView = frameView->frame().contentRenderer())
- renderView->compositor().headerLayer();
- return 0;
+ return renderView->compositor().headerLayer();
+ return nullptr;
#else
UNUSED_PARAM(frameView);
- return 0;
+ return nullptr;
#endif
}
@@ -234,10 +234,10 @@
#if ENABLE(RUBBER_BANDING)
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor().footerLayer();
- return 0;
+ return nullptr;
#else
UNUSED_PARAM(frameView);
- return 0;
+ return nullptr;
#endif
}
@@ -245,21 +245,21 @@
{
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor().fixedRootBackgroundLayer();
- return 0;
+ return nullptr;
}
GraphicsLayer* ScrollingCoordinator::insetClipLayerForFrameView(FrameView* frameView)
{
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor().clipLayer();
- return 0;
+ return nullptr;
}
GraphicsLayer* ScrollingCoordinator::rootContentLayerForFrameView(FrameView* frameView)
{
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor().rootContentLayer();
- return 0;
+ return nullptr;
}
void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm (168601 => 168602)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm 2014-05-11 19:46:53 UTC (rev 168601)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm 2014-05-11 21:02:52 UTC (rev 168602)
@@ -359,7 +359,7 @@
if (m_insetClipLayer && m_scrolledContentsLayer && topContentInset) {
m_insetClipLayer.get().position = FloatPoint(0, FrameView::yPositionForInsetClipLayer(position, topContentInset));
m_scrolledContentsLayer.get().position = FloatPoint(m_scrolledContentsLayer.get().position.x,
- FrameView::yPositionForRootContentLayer(position, topContentInset));
+ FrameView::yPositionForRootContentLayer(position, topContentInset, headerHeight()));
}
if (m_headerLayer || m_footerLayer) {
@@ -371,10 +371,11 @@
horizontalScrollOffsetForBanner = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), 1, false, behaviorForFixed, headerHeight(), footerHeight()).width();
if (m_headerLayer)
- m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, 0);
+ m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForHeaderLayer(position, topContentInset));
if (m_footerLayer)
- m_footerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, totalContentsSize().height() - footerHeight());
+ m_footerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner,
+ FrameView::yPositionForFooterLayer(position, topContentInset, totalContentsSize().height(), footerHeight()));
}
if (m_verticalScrollbarPainter || m_horizontalScrollbarPainter) {
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (168601 => 168602)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2014-05-11 19:46:53 UTC (rev 168601)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2014-05-11 21:02:52 UTC (rev 168602)
@@ -1953,8 +1953,8 @@
if (m_rootContentLayer) {
const IntRect& documentRect = m_renderView.documentRect();
m_rootContentLayer->setSize(documentRect.size());
- m_rootContentLayer->setPosition(FloatPoint(documentRect.x(), documentRect.y() + m_renderView.frameView().headerHeight()
- + FrameView::yPositionForRootContentLayer(m_renderView.frameView().scrollPosition(), m_renderView.frameView().topContentInset())));
+ m_rootContentLayer->setPosition(FloatPoint(documentRect.x(), documentRect.y()
+ + FrameView::yPositionForRootContentLayer(m_renderView.frameView().scrollPosition(), m_renderView.frameView().topContentInset(), m_renderView.frameView().headerHeight())));
m_rootContentLayer->setAnchorPoint(FloatPoint3D());
}
if (m_clipLayer) {
@@ -2966,7 +2966,8 @@
m_renderView.frameView().addPaintPendingMilestones(DidFirstFlushForHeaderLayer);
}
- m_layerForHeader->setPosition(FloatPoint());
+ m_layerForHeader->setPosition(FloatPoint(0,
+ FrameView::yPositionForHeaderLayer(m_renderView.frameView().scrollPosition(), m_renderView.frameView().topContentInset())));
m_layerForHeader->setAnchorPoint(FloatPoint3D());
m_layerForHeader->setSize(FloatSize(m_renderView.frameView().visibleWidth(), m_renderView.frameView().headerHeight()));
@@ -3005,7 +3006,9 @@
m_scrollLayer->addChildBelow(m_layerForFooter.get(), m_rootContentLayer.get());
}
- m_layerForFooter->setPosition(FloatPoint(0, m_rootContentLayer->size().height() + m_renderView.frameView().headerHeight()));
+ float totalContentHeight = m_rootContentLayer->size().height() + m_renderView.frameView().headerHeight() + m_renderView.frameView().footerHeight();
+ m_layerForFooter->setPosition(FloatPoint(0, FrameView::yPositionForFooterLayer(m_renderView.frameView().scrollPosition(),
+ m_renderView.frameView().topContentInset(), totalContentHeight, m_renderView.frameView().footerHeight())));
m_layerForFooter->setAnchorPoint(FloatPoint3D());
m_layerForFooter->setSize(FloatSize(m_renderView.frameView().visibleWidth(), m_renderView.frameView().footerHeight()));