Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1145)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1643663002: Conditionally create PaintLayer's scrollable area object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PaintLayerClipper
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 3bc1709ebb82d41630deda811a4c8265d7b1c927..7203d3d9ded29f0c4627fae5de9abcb948962546 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -255,14 +255,16 @@ void LayoutBox::styleDidChange(StyleDifference diff, const ComputedStyle* oldSty
// If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the
// new zoomed coordinate space.
- if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.effectiveZoom() && layer()) {
- if (int left = layer()->scrollableArea()->scrollXOffset()) {
+ if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.effectiveZoom()) {
+ PaintLayerScrollableArea* scrollableArea = this->scrollableArea();
+ ASSERT(scrollableArea);
+ if (int left = scrollableArea->scrollXOffset()) {
left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom();
- layer()->scrollableArea()->scrollToXOffset(left);
+ scrollableArea->scrollToXOffset(left);
}
- if (int top = layer()->scrollableArea()->scrollYOffset()) {
+ if (int top = scrollableArea->scrollYOffset()) {
top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom();
- layer()->scrollableArea()->scrollToYOffset(top);
+ scrollableArea->scrollToYOffset(top);
}
}
@@ -376,31 +378,7 @@ void LayoutBox::updateFromStyle()
LayoutBoxModelObject::updateFromStyle();
const ComputedStyle& styleToUse = styleRef();
- bool isViewObject = isLayoutView();
- bool rootLayerScrolls = document().settings() && document().settings()->rootLayerScrolls();
-
- // LayoutView of the main frame is resposible from painting base background.
- if (isViewObject && !document().ownerElement())
- setHasBoxDecorationBackground(true);
Xianzhu 2016/02/26 20:12:57 BTW the above three lines are moved into LayoutVie
-
setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating());
-
- bool boxHasOverflowClip = false;
- if (!styleToUse.isOverflowVisible() && isLayoutBlock() && (rootLayerScrolls || !isViewObject)) {
- // If overflow has been propagated to the viewport, it has no effect here.
- if (node() != document().viewportDefiningElement())
- boxHasOverflowClip = true;
- }
-
- if (boxHasOverflowClip != hasOverflowClip()) {
- // FIXME: This shouldn't be required if we tracked the visual overflow
- // generated by positioned children or self painting layers. crbug.com/345403
- for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibling())
- child->setMayNeedPaintInvalidation();
- }
-
- setHasOverflowClip(boxHasOverflowClip);
-
setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty());
setHasReflection(styleToUse.boxReflect());
}
@@ -461,7 +439,7 @@ int LayoutBox::pixelSnappedOffsetHeight() const
LayoutUnit LayoutBox::scrollWidth() const
{
if (hasOverflowClip())
- return layer()->scrollableArea()->scrollWidth();
+ return scrollableArea()->scrollWidth();
// For objects with visible overflow, this matches IE.
// FIXME: Need to work right with writing modes.
if (style()->isLeftToRightDirection())
@@ -472,7 +450,7 @@ LayoutUnit LayoutBox::scrollWidth() const
LayoutUnit LayoutBox::scrollHeight() const
{
if (hasOverflowClip())
- return layer()->scrollableArea()->scrollHeight();
+ return scrollableArea()->scrollHeight();
// For objects with visible overflow, this matches IE.
// FIXME: Need to work right with writing modes.
return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop());
@@ -480,12 +458,12 @@ LayoutUnit LayoutBox::scrollHeight() const
LayoutUnit LayoutBox::scrollLeft() const
{
- return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollXOffset()) : LayoutUnit();
+ return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollXOffset()) : LayoutUnit();
}
LayoutUnit LayoutBox::scrollTop() const
{
- return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollYOffset()) : LayoutUnit();
+ return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollYOffset()) : LayoutUnit();
}
int LayoutBox::pixelSnappedScrollWidth() const
@@ -496,7 +474,7 @@ int LayoutBox::pixelSnappedScrollWidth() const
int LayoutBox::pixelSnappedScrollHeight() const
{
if (hasOverflowClip())
- return snapSizeToPixel(layer()->scrollableArea()->scrollHeight(), location().y() + clientTop());
+ return snapSizeToPixel(scrollableArea()->scrollHeight(), location().y() + clientTop());
// For objects with visible overflow, this matches IE.
// FIXME: Need to work right with writing modes.
return snapSizeToPixel(scrollHeight(), location().y() + clientTop());
@@ -509,7 +487,7 @@ void LayoutBox::setScrollLeft(LayoutUnit newLeft)
DisableCompositingQueryAsserts disabler;
if (hasOverflowClip())
- layer()->scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, ScrollBehaviorAuto);
+ scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, ScrollBehaviorAuto);
}
void LayoutBox::setScrollTop(LayoutUnit newTop)
@@ -518,7 +496,7 @@ void LayoutBox::setScrollTop(LayoutUnit newTop)
DisableCompositingQueryAsserts disabler;
if (hasOverflowClip())
- layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, ScrollBehaviorAuto);
+ scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, ScrollBehaviorAuto);
}
void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBehavior)
@@ -528,7 +506,7 @@ void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe
DisableCompositingQueryAsserts disabler;
if (hasOverflowClip())
- layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, scrollBehavior);
+ scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, scrollBehavior);
}
// Returns true iff we are attempting an autoscroll inside an iframe with scrolling="no".
@@ -562,7 +540,7 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen
if (hasOverflowClip() && !restrictedByLineClamp) {
// Don't scroll to reveal an overflow layer that is restricted by the -webkit-line-clamp property.
// This will prevent us from revealing text hidden by the slider in Safari RSS.
- newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY, scrollType);
+ newRect = scrollableArea()->scrollIntoView(rect, alignX, alignY, scrollType);
} else if (!parentBox && canBeProgramaticallyScrolled()) {
if (FrameView* frameView = this->frameView()) {
HTMLFrameOwnerElement* ownerElement = document().ownerElement();
@@ -759,7 +737,7 @@ int LayoutBox::verticalScrollbarWidth() const
if (!hasOverflowClip() || style()->overflowY() == OOVERLAY)
return 0;
- return layer()->scrollableArea()->verticalScrollbarWidth();
+ return scrollableArea()->verticalScrollbarWidth();
}
int LayoutBox::horizontalScrollbarHeight() const
@@ -767,7 +745,7 @@ int LayoutBox::horizontalScrollbarHeight() const
if (!hasOverflowClip() || style()->overflowX() == OOVERLAY)
return 0;
- return layer()->scrollableArea()->horizontalScrollbarHeight();
+ return scrollableArea()->horizontalScrollbarHeight();
}
int LayoutBox::intrinsicScrollbarLogicalWidth() const
@@ -775,16 +753,16 @@ int LayoutBox::intrinsicScrollbarLogicalWidth() const
if (!hasOverflowClip())
return 0;
+ ASSERT(scrollableArea());
+
if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) {
- ASSERT(layer()->scrollableArea());
// Even with OSCROLL, the scrollbar may not exist (crbug.com/415031).
- return layer()->scrollableArea()->hasVerticalScrollbar() ? verticalScrollbarWidth() : 0;
+ return scrollableArea()->hasVerticalScrollbar() ? verticalScrollbarWidth() : 0;
}
if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) {
- ASSERT(layer()->scrollableArea());
// Even with OSCROLL, the scrollbar may not exist (crbug.com/415031).
- return layer()->scrollableArea()->hasHorizontalScrollbar() ? horizontalScrollbarHeight() : 0;
+ return scrollableArea()->hasHorizontalScrollbar() ? horizontalScrollbarHeight() : 0;
}
return 0;
@@ -795,10 +773,10 @@ ScrollResultOneDimensional LayoutBox::scroll(ScrollDirectionPhysical direction,
// Presumably the same issue as in setScrollTop. See crbug.com/343132.
DisableCompositingQueryAsserts disabler;
- if (!layer() || !layer()->scrollableArea())
+ if (!scrollableArea())
return ScrollResultOneDimensional(false);
- return layer()->scrollableArea()->userScroll(direction, granularity, delta);
+ return scrollableArea()->userScroll(direction, granularity, delta);
}
bool LayoutBox::canBeScrolledAndHasScrollableArea() const
@@ -942,11 +920,14 @@ void LayoutBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin
restrictedByLineClamp = !parent()->style()->lineClamp().isNone();
if (hasOverflowClip() && !restrictedByLineClamp) {
- DoubleSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOffset() + delta;
- layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp);
+ PaintLayerScrollableArea* scrollableArea = this->scrollableArea();
+ ASSERT(scrollableArea);
+
+ DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + delta;
+ scrollableArea->scrollToOffset(newScrollOffset, clamp);
// If this layer can't do the scroll we ask the next layer up that can scroll to try
- DoubleSize remainingScrollOffset = newScrollOffset - layer()->scrollableArea()->adjustedScrollOffset();
+ DoubleSize remainingScrollOffset = newScrollOffset - scrollableArea->adjustedScrollOffset();
if (!remainingScrollOffset.isZero() && parent()) {
if (LayoutBox* scrollableBox = enclosingScrollableBox())
scrollableBox->scrollByRecursively(remainingScrollOffset, clamp);
@@ -976,7 +957,7 @@ IntSize LayoutBox::scrolledContentOffset() const
ASSERT(hasOverflowClip());
ASSERT(hasLayer());
// FIXME: Return DoubleSize here. crbug.com/414283.
- return flooredIntSize(layer()->scrollableArea()->scrollOffset());
+ return flooredIntSize(scrollableArea()->scrollOffset());
}
void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const
@@ -1562,9 +1543,11 @@ LayoutRect LayoutBox::overflowClipRect(const LayoutPoint& location, OverlayScrol
void LayoutBox::excludeScrollbars(LayoutRect& rect, OverlayScrollbarSizeRelevancy relevancy) const
{
- if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
- rect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevancy), 0);
- rect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevancy), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy));
+ if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) {
+ if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+ rect.move(scrollableArea->verticalScrollbarWidth(relevancy), 0);
+ rect.contract(scrollableArea->verticalScrollbarWidth(relevancy), scrollableArea->horizontalScrollbarHeight(relevancy));
+ }
}
LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const
@@ -3761,13 +3744,11 @@ bool LayoutBox::avoidsFloats() const
bool LayoutBox::hasNonCompositedScrollbars() const
{
- if (PaintLayer* layer = this->layer()) {
- if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) {
- if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerForHorizontalScrollbar())
- return true;
- if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForVerticalScrollbar())
- return true;
- }
+ if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) {
+ if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerForHorizontalScrollbar())
+ return true;
+ if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForVerticalScrollbar())
+ return true;
}
return false;
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutScrollbarPart.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698