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

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

Issue 2647383004: Float layer should ignore offsets from ancestor inline layers under containing block (Closed)
Patch Set: - Created 3 years, 11 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
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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 IntRect lineBox = enclosingIntRect(inlineFlow->linesBoundingBox()); 775 IntRect lineBox = enclosingIntRect(inlineFlow->linesBoundingBox());
776 m_size = lineBox.size(); 776 m_size = lineBox.size();
777 } else if (LayoutBox* box = layoutBox()) { 777 } else if (LayoutBox* box = layoutBox()) {
778 IntSize newSize = pixelSnappedIntSize(box->size(), box->location()); 778 IntSize newSize = pixelSnappedIntSize(box->size(), box->location());
779 didResize = newSize != m_size; 779 didResize = newSize != m_size;
780 m_size = newSize; 780 m_size = newSize;
781 localPoint.moveBy(box->physicalLocation()); 781 localPoint.moveBy(box->physicalLocation());
782 } 782 }
783 783
784 if (!layoutObject()->isOutOfFlowPositioned() && 784 if (!layoutObject()->isOutOfFlowPositioned() &&
785 !layoutObject()->isColumnSpanAll() && layoutObject()->parent()) { 785 !layoutObject()->isColumnSpanAll()) {
786 // We must adjust our position by walking up the layout tree looking for the 786 // We must adjust our position by walking up the layout tree looking for the
787 // nearest enclosing object with a layer. 787 // nearest enclosing object with a layer.
788 LayoutObject* curr = layoutObject()->parent(); 788 LayoutObject* curr = layoutObject()->container();
789 while (curr && !curr->hasLayer()) { 789 while (curr && !curr->hasLayer()) {
790 if (curr->isBox() && !curr->isTableRow()) { 790 if (curr->isBox() && !curr->isTableRow()) {
791 // Rows and cells share the same coordinate space (that of the section). 791 // Rows and cells share the same coordinate space (that of the section).
792 // Omit them when computing our xpos/ypos. 792 // Omit them when computing our xpos/ypos.
793 localPoint.moveBy(toLayoutBox(curr)->physicalLocation()); 793 localPoint.moveBy(toLayoutBox(curr)->physicalLocation());
794 } 794 }
795 curr = curr->parent(); 795 curr = curr->container();
796 } 796 }
797 if (curr->isBox() && curr->isTableRow()) { 797 if (curr && curr->isTableRow()) {
798 // Put ourselves into the row coordinate space. 798 // Put ourselves into the row coordinate space.
799 localPoint.moveBy(-toLayoutBox(curr)->physicalLocation()); 799 localPoint.moveBy(-toLayoutBox(curr)->physicalLocation());
800 } 800 }
801 } 801 }
802 802
803 // Subtract our parent's scroll offset. 803 // Subtract our parent's scroll offset.
804 if (PaintLayer* containingLayer = 804 if (PaintLayer* containingLayer =
805 layoutObject()->isOutOfFlowPositioned() 805 layoutObject()->isOutOfFlowPositioned()
806 ? containingLayerForOutOfFlowPositioned() 806 ? containingLayerForOutOfFlowPositioned()
807 : nullptr) { 807 : nullptr) {
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 1411
1412 if (position == FixedPosition && 1412 if (position == FixedPosition &&
1413 (!ancestorLayer || ancestorLayer == layoutObject->view()->layer())) { 1413 (!ancestorLayer || ancestorLayer == layoutObject->view()->layer())) {
1414 // If the fixed layer's container is the root, just add in the offset of the 1414 // If the fixed layer's container is the root, just add in the offset of the
1415 // view. We can obtain this by calling localToAbsolute() on the LayoutView. 1415 // view. We can obtain this by calling localToAbsolute() on the LayoutView.
1416 FloatPoint absPos = layoutObject->localToAbsolute(); 1416 FloatPoint absPos = layoutObject->localToAbsolute();
1417 location += LayoutSize(absPos.x(), absPos.y()); 1417 location += LayoutSize(absPos.x(), absPos.y());
1418 return ancestorLayer; 1418 return ancestorLayer;
1419 } 1419 }
1420 1420
1421 PaintLayer* parentLayer; 1421 PaintLayer* parentLayer = nullptr;
1422 if (position == AbsolutePosition || position == FixedPosition) { 1422 if (position == AbsolutePosition || position == FixedPosition ||
1423 bool foundAncestorFirst; 1423 (layoutObject->isFloating() && layoutObject->parent() &&
1424 parentLayer = layer->containingLayerForOutOfFlowPositioned( 1424 !layoutObject->parent()->isLayoutBlockFlow())) {
1425 ancestorLayer, &foundAncestorFirst); 1425 bool foundAncestorFirst = false;
1426 if (layoutObject->isFloating()) {
1427 Optional<LayoutObject::AncestorSkipInfo> skipInfo;
1428 if (ancestorLayer)
1429 skipInfo.emplace(ancestorLayer->layoutObject());
1430 if (auto* containingBlock = layoutObject->containingBlock(
1431 ancestorLayer ? &*skipInfo : nullptr)) {
1432 parentLayer = containingBlock->enclosingLayer();
1433 foundAncestorFirst = ancestorLayer && skipInfo->ancestorSkipped();
1434 }
1435 } else {
1436 parentLayer = layer->containingLayerForOutOfFlowPositioned(
1437 ancestorLayer, &foundAncestorFirst);
1438 }
1426 1439
1427 if (foundAncestorFirst) { 1440 if (foundAncestorFirst) {
1428 // Found ancestorLayer before the container of the out-of-flow object, so 1441 // Found ancestorLayer before the container of the out-of-flow object, so
1429 // compute offset of both relative to the container and subtract. 1442 // compute offset of both relative to the container and subtract.
1430 1443
1431 LayoutPoint thisCoords; 1444 LayoutPoint thisCoords;
1432 layer->convertToLayerCoords(parentLayer, thisCoords); 1445 layer->convertToLayerCoords(parentLayer, thisCoords);
1433 1446
1434 LayoutPoint ancestorCoords; 1447 LayoutPoint ancestorCoords;
1435 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords); 1448 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords);
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 } 3234 }
3222 3235
3223 void showLayerTree(const blink::LayoutObject* layoutObject) { 3236 void showLayerTree(const blink::LayoutObject* layoutObject) {
3224 if (!layoutObject) { 3237 if (!layoutObject) {
3225 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3238 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3226 return; 3239 return;
3227 } 3240 }
3228 showLayerTree(layoutObject->enclosingLayer()); 3241 showLayerTree(layoutObject->enclosingLayer());
3229 } 3242 }
3230 #endif 3243 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698