Index: Source/WebCore/rendering/RenderLayer.cpp |
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp |
index c4787b98c1b85f14ef32d7096cf2f4c121f39b59..6ebd73f815b9bb75c1c95fbc3f4d8bf7e0d27dee 100644 |
--- a/Source/WebCore/rendering/RenderLayer.cpp |
+++ b/Source/WebCore/rendering/RenderLayer.cpp |
@@ -146,9 +146,10 @@ RenderLayer::RenderLayer(RenderLayerModelObject* renderer) |
, m_hasSelfPaintingLayerDescendant(false) |
, m_hasSelfPaintingLayerDescendantDirty(false) |
, m_hasOutOfFlowPositionedDescendant(false) |
- , m_hasOutOfFlowPositionedDescendantDirty(true) |
+ , m_hasOutOfFlowPositionedDescendantDirty(false) |
, m_needsCompositedScrolling(false) |
, m_descendantsAreContiguousInStackingOrder(false) |
hartmanng
2013/04/10 17:34:05
should be true by default
Ian Vollick
2013/04/11 16:36:03
Done.
|
+ , m_descendantsAreContiguousInStackingOrderDirty(false) |
, m_isRootLayer(renderer->isRenderView()) |
, m_usedTransparency(false) |
, m_paintingInsideReflection(false) |
@@ -595,11 +596,10 @@ bool RenderLayer::acceleratedCompositingForOverflowScrollEnabled() const |
// And we would conclude that C could be promoted. |
void RenderLayer::updateDescendantsAreContiguousInStackingOrder() |
{ |
- if (!isStackingContext() || !acceleratedCompositingForOverflowScrollEnabled()) |
+ if (!m_descendantsAreContiguousInStackingOrderDirty || !isStackingContext() || !acceleratedCompositingForOverflowScrollEnabled()) { |
+ m_descendantsAreContiguousInStackingOrderDirty = false; |
return; |
- |
- ASSERT(!m_normalFlowListDirty); |
- ASSERT(!m_zOrderListsDirty); |
+ } |
OwnPtr<Vector<RenderLayer*> > posZOrderList; |
OwnPtr<Vector<RenderLayer*> > negZOrderList; |
@@ -635,10 +635,14 @@ void RenderLayer::updateDescendantsAreContiguousInStackingOrder() |
int count = 0; |
bool firstIteration = true; |
updateDescendantsAreContiguousInStackingOrderRecursive(lookup, minIndex, maxIndex, count, firstIteration); |
+ |
+ m_descendantsAreContiguousInStackingOrderDirty = false; |
} |
void RenderLayer::updateDescendantsAreContiguousInStackingOrderRecursive(const HashMap<const RenderLayer*, int>& lookup, int& minIndex, int& maxIndex, int& count, bool firstIteration) |
{ |
+ m_descendantsAreContiguousInStackingOrderDirty = false; |
+ |
if (isStackingContext() && !firstIteration) { |
if (lookup.contains(this)) { |
minIndex = std::min(minIndex, lookup.get(this)); |
@@ -661,11 +665,7 @@ void RenderLayer::updateDescendantsAreContiguousInStackingOrderRecursive(const H |
} |
if (!isStackingContext()) { |
- bool newValue = maxIndex - minIndex == count; |
- bool didUpdate = newValue != m_descendantsAreContiguousInStackingOrder; |
- m_descendantsAreContiguousInStackingOrder = newValue; |
- if (didUpdate) |
- updateNeedsCompositedScrolling(); |
+ m_descendantsAreContiguousInStackingOrder = maxIndex - minIndex == count; |
} |
} |
@@ -971,6 +971,7 @@ bool RenderLayer::canBeStackingContainer() const |
if (isStackingContext() || !stackingContainer()) |
return true; |
+ ASSERT(!m_descendantsAreContiguousInStackingOrderDirty); |
return m_descendantsAreContiguousInStackingOrder; |
} |
@@ -1051,7 +1052,7 @@ void RenderLayer::updateDescendantDependentFlags(HashSet<const RenderObject*>* o |
bool hasVisibleDescendant = child->m_hasVisibleContent || child->m_hasVisibleDescendant; |
bool hasSelfPaintingLayerDescendant = child->isSelfPaintingLayer() || child->hasSelfPaintingLayerDescendant(); |
- bool hasOutOfFlowPositionedDescendant = !childOutOfFlowDescendantContainingBlocks.isEmpty(); |
+ bool hasOutOfFlowPositionedDescendant = !childOutOfFlowDescendantContainingBlocks.isEmpty() || child->hasOutOfFlowPositionedDescendant(); |
m_hasVisibleDescendant |= hasVisibleDescendant; |
m_hasSelfPaintingLayerDescendant |= hasSelfPaintingLayerDescendant; |
@@ -1066,10 +1067,6 @@ void RenderLayer::updateDescendantDependentFlags(HashSet<const RenderObject*>* o |
m_visibleDescendantStatusDirty = false; |
m_hasSelfPaintingLayerDescendantDirty = false; |
- |
- if (m_hasOutOfFlowPositionedDescendantDirty) |
- updateNeedsCompositedScrolling(); |
- |
m_hasOutOfFlowPositionedDescendantDirty = false; |
} |
@@ -1677,6 +1674,7 @@ void RenderLayer::addChild(RenderLayer* child, RenderLayer* beforeChild) |
// case where we're building up generated content layers. This is ok, since the lists will start |
// off dirty in that case anyway. |
child->dirtyStackingContainerZOrderLists(); |
+ child->m_descendantsAreContiguousInStackingOrderDirty = true; |
} |
child->updateDescendantDependentFlags(); |
@@ -1710,11 +1708,12 @@ RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) |
if (oldChild->isNormalFlowOnly()) |
dirtyNormalFlowList(); |
- if (!oldChild->isNormalFlowOnly() || oldChild->firstChild()) { |
+ if (!oldChild->isNormalFlowOnly() || oldChild->firstChild()) { |
// Dirty the z-order list in which we are contained. When called via the |
// reattachment process in removeOnlyThisLayer, the layer may already be disconnected |
// from the main layer tree, so we need to null-check the |stackingContainer| value. |
oldChild->dirtyStackingContainerZOrderLists(); |
+ m_descendantsAreContiguousInStackingOrderDirty = true; |
} |
if ((oldChild->renderer() && oldChild->renderer()->isOutOfFlowPositioned()) || oldChild->hasOutOfFlowPositionedDescendant()) |
@@ -1723,7 +1722,7 @@ RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) |
oldChild->setPreviousSibling(0); |
oldChild->setNextSibling(0); |
oldChild->setParent(0); |
- |
+ |
oldChild->updateDescendantDependentFlags(); |
if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) |
dirtyAncestorChainVisibleDescendantStatus(); |
@@ -1939,46 +1938,57 @@ bool RenderLayer::usesCompositedScrolling() const |
bool RenderLayer::needsCompositedScrolling() const |
{ |
+ ASSERT(!m_descendantsAreContiguousInStackingOrderDirty); |
+ ASSERT(!m_hasOutOfFlowPositionedDescendantDirty); |
return m_needsCompositedScrolling; |
} |
void RenderLayer::updateNeedsCompositedScrolling() |
{ |
- bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; |
+ bool needsCompositedScrolling = false; |
FrameView* frameView = renderer()->view()->frameView(); |
- if (!frameView || !frameView->containsScrollableArea(this)) |
- m_needsCompositedScrolling = false; |
- else { |
+ if (frameView && frameView->containsScrollableArea(this)) { |
bool forceUseCompositedScrolling = acceleratedCompositingForOverflowScrollEnabled() |
&& canBeStackingContainer() |
&& !hasOutOfFlowPositionedDescendant(); |
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) |
- m_needsCompositedScrolling = forceUseCompositedScrolling || renderer()->style()->useTouchOverflowScrolling(); |
+ needsCompositedScrolling = forceUseCompositedScrolling || renderer()->style()->useTouchOverflowScrolling(); |
#else |
- m_needsCompositedScrolling = forceUseCompositedScrolling; |
+ needsCompositedScrolling = forceUseCompositedScrolling; |
#endif |
- // We gather a boolean value for use with Google UMA histograms to |
- // quantify the actual effects of a set of patches attempting to |
- // relax composited scrolling requirements, thereby increasing the |
- // number of composited overflow divs. |
- if (acceleratedCompositingForOverflowScrollEnabled()) |
- HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScrolling", m_needsCompositedScrolling, 2); |
} |
- if (oldNeedsCompositedScrolling != m_needsCompositedScrolling) { |
- updateSelfPaintingLayer(); |
- if (isStackingContainer()) |
- dirtyZOrderLists(); |
- else |
- clearZOrderLists(); |
+ setNeedsCompositedScrolling(needsCompositedScrolling); |
+} |
+ |
+void RenderLayer::setNeedsCompositedScrolling(bool needsCompositedScrolling) |
+{ |
+ // We gather a boolean value for use with Google UMA histograms to |
+ // quantify the actual effects of a set of patches attempting to |
+ // relax composited scrolling requirements, thereby increasing the |
+ // number of composited overflow divs. |
+ if (acceleratedCompositingForOverflowScrollEnabled()) |
+ HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScrolling", needsCompositedScrolling, 2); |
hartmanng
2013/04/10 17:34:05
this should only be set for scrollable divs, not a
Ian Vollick
2013/04/11 16:36:03
Done.
|
- dirtyStackingContainerZOrderLists(); |
+ if (m_needsCompositedScrolling == needsCompositedScrolling) |
+ return; |
- compositor()->setShouldReevaluateCompositingAfterLayout(); |
- compositor()->setCompositingLayersNeedRebuild(); |
- } |
+ m_needsCompositedScrolling = needsCompositedScrolling; |
+ |
+ updateIsNormalFlowOnly(); |
+ updateSelfPaintingLayer(); |
+ |
+ if (isStackingContainer()) |
+ dirtyZOrderLists(); |
+ else |
+ clearZOrderLists(); |
+ |
+ dirtyStackingContainerZOrderLists(); |
+ |
+ compositor()->setShouldReevaluateCompositingAfterLayout(); |
+ compositor()->setCompositingLayersNeedRebuild(); |
} |
static inline int adjustedScrollDelta(int beginningDelta) { |
@@ -2273,7 +2283,7 @@ void RenderLayer::updateCompositingLayersAfterScroll() |
// repositioning, so update compositing layers from there. |
if (RenderLayer* compositingAncestor = stackingContainer()->enclosingCompositingLayer()) { |
if (compositor()->compositingConsultsOverlap()) { |
- if (usesCompositedScrolling() && !hasOutOfFlowPositionedDescendant()) |
+ if (usesCompositedScrolling()) |
compositor()->updateCompositingLayers(CompositingUpdateOnCompositedScroll, compositingAncestor); |
else |
compositor()->updateCompositingLayers(CompositingUpdateOnScroll, compositingAncestor); |
@@ -3108,10 +3118,6 @@ void RenderLayer::updateScrollInfoAfterLayout() |
if (originalScrollOffset != scrollOffset()) |
scrollToOffsetWithoutAnimation(IntPoint(scrollOffset())); |
- |
- // Composited scrolling may need to be enabled or disabled if the amount of overflow changed. |
- if (renderer()->view() && compositor()->updateLayerCompositingState(this)) |
- compositor()->setCompositingLayersNeedRebuild(); |
} |
bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const |
@@ -5496,7 +5502,6 @@ static inline bool compareZIndex(RenderLayer* first, RenderLayer* second) |
void RenderLayer::dirtyZOrderLists() |
{ |
ASSERT(m_layerListMutationAllowed); |
- ASSERT(isStackingContainer()); |
if (m_posZOrderList) |
m_posZOrderList->clear(); |
@@ -5504,6 +5509,8 @@ void RenderLayer::dirtyZOrderLists() |
m_negZOrderList->clear(); |
m_zOrderListsDirty = true; |
+ m_descendantsAreContiguousInStackingOrderDirty = true; |
+ |
if (!renderer()->documentBeingDestroyed()) { |
compositor()->setCompositingLayersNeedRebuild(); |
if (acceleratedCompositingForOverflowScrollEnabled()) |
@@ -5513,9 +5520,11 @@ void RenderLayer::dirtyZOrderLists() |
void RenderLayer::dirtyStackingContainerZOrderLists() |
hartmanng
2013/04/10 17:34:05
rename to dirtyStackingContextZOrderLists. Also ad
Ian Vollick
2013/04/11 16:36:03
I think the function name still works, but I expla
|
{ |
- RenderLayer* sc = stackingContainer(); |
- if (sc) |
- sc->dirtyZOrderLists(); |
+ for (RenderLayer* layer = parent(); layer; layer = layer->parent()) { |
+ layer->dirtyZOrderLists(); |
+ if (layer->isStackingContext()) |
+ break; |
+ } |
} |
void RenderLayer::dirtyNormalFlowList() |
@@ -5526,6 +5535,7 @@ void RenderLayer::dirtyNormalFlowList() |
m_normalFlowList->clear(); |
m_normalFlowListDirty = true; |
+ m_descendantsAreContiguousInStackingOrderDirty = true; |
if (!renderer()->documentBeingDestroyed()) { |
compositor()->setCompositingLayersNeedRebuild(); |
if (acceleratedCompositingForOverflowScrollEnabled()) |
@@ -5628,7 +5638,7 @@ void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior |
void RenderLayer::updateLayerListsIfNeeded() |
{ |
- bool shouldUpdateDescendantsAreContiguousInStackingOrder = isStackingContext() && (m_zOrderListsDirty || m_normalFlowListDirty); |
+ bool shouldUpdateDescendantsAreContiguousInStackingOrder = acceleratedCompositingForOverflowScrollEnabled() && isStackingContext() && (m_zOrderListsDirty || m_normalFlowListDirty) && m_descendantsAreContiguousInStackingOrderDirty; |
updateZOrderLists(); |
updateNormalFlowList(); |
@@ -5724,6 +5734,19 @@ bool RenderLayer::shouldBeNormalFlowOnly() const |
; |
} |
+void RenderLayer::updateIsNormalFlowOnly() |
+{ |
+ bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
+ if (isNormalFlowOnly == m_isNormalFlowOnly) |
+ return; |
+ |
+ m_isNormalFlowOnly = isNormalFlowOnly; |
+ RenderLayer* p = parent(); |
+ if (p) |
+ p->dirtyNormalFlowList(); |
+ dirtyStackingContainerZOrderLists(); |
+} |
+ |
bool RenderLayer::shouldBeSelfPaintingLayer() const |
{ |
return !isNormalFlowOnly() |
@@ -5808,27 +5831,19 @@ bool RenderLayer::isVisuallyNonEmpty() const |
void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldStyle) |
{ |
- if (!oldStyle) |
- return; |
+ bool wasStackingContext = oldStyle ? isStackingContext(oldStyle) : false; |
+ EVisibility oldVisibility = oldStyle ? oldStyle->visibility() : VISIBLE; |
+ int oldZIndex = oldStyle ? oldStyle->zIndex() : 0; |
- bool wasStackingContext = isStackingContext(oldStyle); |
+ // FIXME: RenderLayer already handles visibility changes through our visiblity dirty bits. This logic could |
+ // likely be folded along with the rest. |
bool isStackingContext = this->isStackingContext(); |
- if (isStackingContext != wasStackingContext) { |
- dirtyStackingContainerZOrderLists(); |
- if (isStackingContext) |
- dirtyZOrderLists(); |
- else |
- clearZOrderLists(); |
+ if (isStackingContext == wasStackingContext && oldVisibility == renderer()->style()->visibility() && oldZIndex == renderer()->style()->zIndex()) |
return; |
- } |
- // FIXME: RenderLayer already handles visibility changes through our visiblity dirty bits. This logic could |
- // likely be folded along with the rest. |
- if (oldStyle->zIndex() != renderer()->style()->zIndex() || oldStyle->visibility() != renderer()->style()->visibility()) { |
- dirtyStackingContainerZOrderLists(); |
- if (isStackingContext) |
- dirtyZOrderLists(); |
- } |
+ dirtyStackingContainerZOrderLists(); |
+ if (isStackingContainer()) |
+ dirtyZOrderLists(); |
} |
static bool overflowRequiresScrollbar(EOverflow overflow) |
@@ -5885,7 +5900,6 @@ void RenderLayer::setAncestorChainHasOutOfFlowPositionedDescendant(RenderObject* |
layer->m_hasOutOfFlowPositionedDescendantDirty = false; |
layer->m_hasOutOfFlowPositionedDescendant = true; |
- layer->updateNeedsCompositedScrolling(); |
if (layer->renderer() && layer->renderer() == containingBlock) |
break; |
@@ -5894,7 +5908,9 @@ void RenderLayer::setAncestorChainHasOutOfFlowPositionedDescendant(RenderObject* |
void RenderLayer::dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus() |
{ |
- m_hasOutOfFlowPositionedDescendantDirty = true; |
+ if (m_hasOutOfFlowPositionedDescendant) |
+ m_hasOutOfFlowPositionedDescendantDirty = true; |
+ |
if (parent()) |
parent()->dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus(); |
} |
@@ -5902,10 +5918,12 @@ void RenderLayer::dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus() |
void RenderLayer::updateOutOfFlowPositioned(const RenderStyle* oldStyle) |
{ |
bool wasOutOfFlowPositioned = oldStyle && (oldStyle->position() == AbsolutePosition || oldStyle->position() == FixedPosition); |
- if (parent() && ((renderer() && renderer()->isOutOfFlowPositioned()) != wasOutOfFlowPositioned)) { |
- parent()->dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus(); |
- if (!renderer()->documentBeingDestroyed() && acceleratedCompositingForOverflowScrollEnabled()) |
- compositor()->setShouldReevaluateCompositingAfterLayout(); |
+ bool isOutOfFlowPositioned = renderer()->isOutOfFlowPositioned(); |
+ if (parent() && isOutOfFlowPositioned != wasOutOfFlowPositioned) { |
+ if (isOutOfFlowPositioned) |
+ parent()->setAncestorChainHasOutOfFlowPositionedDescendant(renderer()->containingBlock()); |
+ else |
+ parent()->dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus(); |
} |
} |
@@ -5989,15 +6007,6 @@ void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* |
void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) |
{ |
- bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
- if (isNormalFlowOnly != m_isNormalFlowOnly) { |
- m_isNormalFlowOnly = isNormalFlowOnly; |
- RenderLayer* p = parent(); |
- if (p) |
- p->dirtyNormalFlowList(); |
- dirtyStackingContainerZOrderLists(); |
- } |
- |
if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->marqueeBehavior() != MNONE && renderer()->isBox()) { |
if (!m_marquee) |
m_marquee = adoptPtr(new RenderMarquee(this)); |
@@ -6010,6 +6019,7 @@ void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) |
updateScrollbarsAfterStyleChange(oldStyle); |
updateStackingContextsAfterStyleChange(oldStyle); |
+ |
// Overlay scrollbars can make this layer self-painting so we need |
// to recompute the bit once scrollbars have been updated. |
updateSelfPaintingLayer(); |
@@ -6047,16 +6057,18 @@ void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) |
updateFilters(oldStyle, renderer()->style()); |
#endif |
- updateNeedsCompositedScrolling(); |
- |
- const RenderStyle* newStyle = renderer()->style(); |
- if (compositor()->updateLayerCompositingState(this) |
- || needsCompositingLayersRebuiltForClip(oldStyle, newStyle) |
- || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) |
- || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintWithFilters)) |
- compositor()->setCompositingLayersNeedRebuild(); |
- else if (isComposited()) |
- backing()->updateGraphicsLayerGeometry(); |
+// FIXME(vollick) this requires updates that won't happen until after layout. |
+// Will this just fall out of the updateCompositingLayers call that will be |
+// coming anyway? |
+// const RenderStyle* newStyle = renderer()->style(); |
+// if (compositor()->updateLayerCompositingState(this) |
+// || needsCompositingLayersRebuiltForClip(oldStyle, newStyle) |
+// || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) |
+// || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintWithFilters)) |
+// compositor()->setCompositingLayersNeedRebuild(); |
+// else if (isComposited()) |
+// backing()->updateGraphicsLayerGeometry(); |
+// |
} |
void RenderLayer::updateScrollableAreaSet(bool hasOverflow) |
@@ -6073,8 +6085,10 @@ void RenderLayer::updateScrollableAreaSet(bool hasOverflow) |
if (HTMLFrameOwnerElement* owner = frame->ownerElement()) |
isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToHitTesting(); |
- if (hasOverflow && isVisibleToHitTest ? frameView->addScrollableArea(this) : frameView->removeScrollableArea(this)) |
- updateNeedsCompositedScrolling(); |
+ if (hasOverflow && isVisibleToHitTest) |
hartmanng
2013/04/10 17:34:05
frameView->{add,remove}ScrollableArea() no longer
hartmanng
2013/04/12 03:51:42
I think you missed this comment
|
+ frameView->addScrollableArea(this); |
+ else |
+ frameView->removeScrollableArea(this); |
} |
void RenderLayer::updateScrollCornerStyle() |