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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2767133003: Fix position of layer with floating ancestor within inline parent layer (Closed)
Patch Set: - Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/PaintLayerTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 transformAncestor() ? transformAncestor()->layoutObject() : nullptr, 914 transformAncestor() ? transformAncestor()->layoutObject() : nullptr,
915 transformState, 0); 915 transformState, 0);
916 transformState.flatten(); 916 transformState.flatten();
917 return LayoutPoint(transformState.lastPlanarPoint()); 917 return LayoutPoint(transformState.lastPlanarPoint());
918 } 918 }
919 919
920 PaintLayer* PaintLayer::compositingContainer() const { 920 PaintLayer* PaintLayer::compositingContainer() const {
921 if (!stackingNode()->isStacked()) { 921 if (!stackingNode()->isStacked()) {
922 // Floats have special painting order, which has complicated semantics. 922 // Floats have special painting order, which has complicated semantics.
923 // See the comments around FloatObject::setShouldPaint. 923 // See the comments around FloatObject::setShouldPaint.
924 if (!isSelfPaintingLayer() && m_layoutObject->isFloating() && 924 if (!isSelfPaintingLayer() && m_layoutObject->isFloating() &&
chrishtr 2017/03/22 23:23:33 Do you need to fix this one too?
Xianzhu 2017/03/22 23:25:17 I would like to keep this as-is, as the compositin
925 m_layoutObject->parent() && 925 m_layoutObject->parent() &&
926 !m_layoutObject->parent()->isLayoutBlockFlow()) 926 !m_layoutObject->parent()->isLayoutBlockFlow())
927 return m_layoutObject->containingBlock()->enclosingLayer(); 927 return m_layoutObject->containingBlock()->enclosingLayer();
928 928
929 return parent(); 929 return parent();
930 } 930 }
931 if (PaintLayerStackingNode* ancestorStackingNode = 931 if (PaintLayerStackingNode* ancestorStackingNode =
932 stackingNode()->ancestorStackingContextNode()) 932 stackingNode()->ancestorStackingContextNode())
933 return ancestorStackingNode->layer(); 933 return ancestorStackingNode->layer();
934 return nullptr; 934 return nullptr;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 if (position == FixedPosition && 1414 if (position == FixedPosition &&
1415 (!ancestorLayer || ancestorLayer == layoutObject->view()->layer())) { 1415 (!ancestorLayer || ancestorLayer == layoutObject->view()->layer())) {
1416 // If the fixed layer's container is the root, just add in the offset of the 1416 // If the fixed layer's container is the root, just add in the offset of the
1417 // view. We can obtain this by calling localToAbsolute() on the LayoutView. 1417 // view. We can obtain this by calling localToAbsolute() on the LayoutView.
1418 FloatPoint absPos = layoutObject->localToAbsolute(); 1418 FloatPoint absPos = layoutObject->localToAbsolute();
1419 location += LayoutSize(absPos.x(), absPos.y()); 1419 location += LayoutSize(absPos.x(), absPos.y());
1420 return ancestorLayer; 1420 return ancestorLayer;
1421 } 1421 }
1422 1422
1423 PaintLayer* parentLayer = nullptr; 1423 PaintLayer* parentLayer = nullptr;
1424 if (position == AbsolutePosition || position == FixedPosition || 1424 bool isOutOfFlowPositioned =
1425 (layoutObject->isFloating() && layoutObject->parent() && 1425 position == AbsolutePosition || position == FixedPosition;
1426 !layoutObject->parent()->isLayoutBlockFlow())) { 1426 if (isOutOfFlowPositioned ||
1427 // If the parent layer is not a block, there might be floating objects
1428 // between this layer (included) and parent layer which need to escape the
1429 // inline parent to find the actual containing layer through the
1430 // containing block chain.
1431 (layer->parent() && !layer->parent()->layoutObject()->isLayoutBlock())) {
1427 bool foundAncestorFirst = false; 1432 bool foundAncestorFirst = false;
1428 if (layoutObject->isFloating()) { 1433 if (!isOutOfFlowPositioned) {
1429 Optional<LayoutObject::AncestorSkipInfo> skipInfo; 1434 Optional<LayoutObject::AncestorSkipInfo> skipInfo;
1430 if (ancestorLayer) 1435 if (ancestorLayer)
1431 skipInfo.emplace(ancestorLayer->layoutObject()); 1436 skipInfo.emplace(ancestorLayer->layoutObject());
1432 if (auto* containingBlock = layoutObject->containingBlock( 1437
1433 ancestorLayer ? &*skipInfo : nullptr)) { 1438 const LayoutObject* object = layoutObject;
1434 parentLayer = containingBlock->enclosingLayer(); 1439 while (auto* container =
1435 foundAncestorFirst = ancestorLayer && skipInfo->ancestorSkipped(); 1440 object->container(ancestorLayer ? &*skipInfo : nullptr)) {
1441 foundAncestorFirst |= ancestorLayer && skipInfo->ancestorSkipped();
1442 if (container->hasLayer()) {
1443 parentLayer = toLayoutBoxModelObject(container)->layer();
1444 break;
1445 }
1446 object = container;
1436 } 1447 }
1437 } else { 1448 } else {
1438 parentLayer = layer->containingLayerForOutOfFlowPositioned( 1449 parentLayer = layer->containingLayerForOutOfFlowPositioned(
1439 ancestorLayer, &foundAncestorFirst); 1450 ancestorLayer, &foundAncestorFirst);
1440 } 1451 }
1441 1452
1442 if (foundAncestorFirst) { 1453 if (foundAncestorFirst) {
1443 // Found ancestorLayer before the container of the out-of-flow object, so 1454 // Found ancestorLayer before the container of the out-of-flow object, so
1444 // compute offset of both relative to the container and subtract. 1455 // compute offset of both relative to the container and subtract.
1445 1456
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 } 3231 }
3221 3232
3222 void showLayerTree(const blink::LayoutObject* layoutObject) { 3233 void showLayerTree(const blink::LayoutObject* layoutObject) {
3223 if (!layoutObject) { 3234 if (!layoutObject) {
3224 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3235 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3225 return; 3236 return;
3226 } 3237 }
3227 showLayerTree(layoutObject->enclosingLayer()); 3238 showLayerTree(layoutObject->enclosingLayer());
3228 } 3239 }
3229 #endif 3240 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/PaintLayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698