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

Unified Diff: Source/core/paint/DeprecatedPaintLayer.cpp

Issue 1199673003: Have enclosingPositionedAncestor() detect whether it walked past a certain ancestor. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: code review Created 5 years, 6 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
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/DeprecatedPaintLayer.cpp
diff --git a/Source/core/paint/DeprecatedPaintLayer.cpp b/Source/core/paint/DeprecatedPaintLayer.cpp
index 35816c7fce8fc8f7916048454bae7897b8e2df9d..2528b19e239a5f3ea3d696e002b33202dd620e51 100644
--- a/Source/core/paint/DeprecatedPaintLayer.cpp
+++ b/Source/core/paint/DeprecatedPaintLayer.cpp
@@ -773,9 +773,7 @@ bool DeprecatedPaintLayer::updateLayerPosition()
}
// Subtract our parent's scroll offset.
- if (layoutObject()->isOutOfFlowPositioned() && enclosingPositionedAncestor()) {
- DeprecatedPaintLayer* positionedParent = enclosingPositionedAncestor();
-
+ if (DeprecatedPaintLayer* positionedParent = layoutObject()->isOutOfFlowPositioned() ? enclosingPositionedAncestor() : nullptr) {
// For positioned layers, we subtract out the enclosing positioned layer's scroll offset.
if (positionedParent->layoutObject()->hasOverflowClip()) {
IntSize offset = positionedParent->layoutBox()->scrolledContentOffset();
@@ -844,19 +842,28 @@ static inline bool isFixedPositionedContainer(DeprecatedPaintLayer* layer)
return layer->isRootLayer() || layer->hasTransformRelatedProperty();
}
-DeprecatedPaintLayer* DeprecatedPaintLayer::enclosingPositionedAncestor() const
+DeprecatedPaintLayer* DeprecatedPaintLayer::enclosingPositionedAncestor(const DeprecatedPaintLayer* ancestor, bool* skippedAncestor) const
{
+ ASSERT(!ancestor || skippedAncestor); // If we have specified an ancestor, surely the caller needs to know whether we skipped it.
+ if (skippedAncestor)
+ *skippedAncestor = false;
if (layoutObject()->style()->position() == FixedPosition) {
DeprecatedPaintLayer* curr = parent();
- while (curr && !isFixedPositionedContainer(curr))
+ while (curr && !isFixedPositionedContainer(curr)) {
+ if (skippedAncestor && curr == ancestor)
+ *skippedAncestor = true;
curr = curr->parent();
+ }
return curr;
}
DeprecatedPaintLayer* curr = parent();
- while (curr && !curr->isPositionedContainer())
+ while (curr && !curr->isPositionedContainer()) {
+ if (skippedAncestor && curr == ancestor)
+ *skippedAncestor = true;
curr = curr->parent();
+ }
return curr;
}
@@ -1320,31 +1327,18 @@ static inline const DeprecatedPaintLayer* accumulateOffsetTowardsAncestor(const
DeprecatedPaintLayer* parentLayer;
if (position == AbsolutePosition) {
- // Do what enclosingPositionedAncestor() does, but check for ancestorLayer along the way.
- parentLayer = layer->parent();
- bool foundAncestorFirst = false;
- while (parentLayer) {
- if (parentLayer->isPositionedContainer())
- break;
-
- if (parentLayer == ancestorLayer) {
- foundAncestorFirst = true;
- break;
- }
-
- parentLayer = parentLayer->parent();
- }
+ bool foundAncestorFirst;
+ parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAncestorFirst);
if (foundAncestorFirst) {
// Found ancestorLayer before the abs. positioned container, so compute offset of both relative
- // to enclosingPositionedAncestor and subtract.
- DeprecatedPaintLayer* positionedAncestor = parentLayer->enclosingPositionedAncestor();
+ // to the positioned ancestor and subtract.
LayoutPoint thisCoords;
- layer->convertToLayerCoords(positionedAncestor, thisCoords);
+ layer->convertToLayerCoords(parentLayer, thisCoords);
LayoutPoint ancestorCoords;
- ancestorLayer->convertToLayerCoords(positionedAncestor, ancestorCoords);
+ ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords);
location += (thisCoords - ancestorCoords);
return ancestorLayer;
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698