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

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

Issue 2761413002: Fix position of floating layer whose containing block is also floating (Closed)
Patch Set: TODO in GraphicsLayerUpdater 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
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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 863
864 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor, 864 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor,
865 bool* skippedAncestor) const { 865 bool* skippedAncestor) const {
866 // If we have specified an ancestor, surely the caller needs to know whether 866 // If we have specified an ancestor, surely the caller needs to know whether
867 // we skipped it. 867 // we skipped it.
868 DCHECK(!ancestor || skippedAncestor); 868 DCHECK(!ancestor || skippedAncestor);
869 if (skippedAncestor) 869 if (skippedAncestor)
870 *skippedAncestor = false; 870 *skippedAncestor = false;
871 871
872 LayoutObject& layoutObject = this->layoutObject(); 872 LayoutObject& layoutObject = this->layoutObject();
873 if (layoutObject.isColumnSpanAll() || 873 // Column span need to find the containing layer through its containing block.
874 layoutObject.isFloatingWithNonContainingBlockParent()) { 874 // TODO(wangxianzhu): This can be combined with the loop handing possible
875 // floating objects.
876 if (layoutObject.isColumnSpanAll()) {
875 Optional<LayoutObject::AncestorSkipInfo> skipInfo; 877 Optional<LayoutObject::AncestorSkipInfo> skipInfo;
876 if (skippedAncestor) 878 if (skippedAncestor)
877 skipInfo.emplace(&ancestor->layoutObject()); 879 skipInfo.emplace(&ancestor->layoutObject());
878 if (auto containingBlock = layoutObject.containingBlock( 880 if (auto containingBlock = layoutObject.containingBlock(
879 skippedAncestor ? &*skipInfo : nullptr)) { 881 skippedAncestor ? &*skipInfo : nullptr)) {
880 if (skippedAncestor && skipInfo->ancestorSkipped()) 882 if (skippedAncestor && skipInfo->ancestorSkipped())
881 *skippedAncestor = true; 883 *skippedAncestor = true;
882 return containingBlock->enclosingLayer(); 884 return containingBlock->enclosingLayer();
883 } 885 }
884 return nullptr; 886 return nullptr;
885 } 887 }
886 888
887 if (layoutObject.isOutOfFlowPositioned()) { 889 if (layoutObject.isOutOfFlowPositioned()) {
888 auto canContainThisLayer = 890 auto canContainThisLayer =
889 layoutObject.isFixedPositioned() 891 layoutObject.isFixedPositioned()
890 ? &LayoutObject::canContainFixedPositionObjects 892 ? &LayoutObject::canContainFixedPositionObjects
891 : &LayoutObject::canContainAbsolutePositionObjects; 893 : &LayoutObject::canContainAbsolutePositionObjects;
892 894
893 PaintLayer* curr = parent(); 895 PaintLayer* curr = parent();
894 while (curr && !((&curr->layoutObject())->*canContainThisLayer)()) { 896 while (curr && !((&curr->layoutObject())->*canContainThisLayer)()) {
895 if (skippedAncestor && curr == ancestor) 897 if (skippedAncestor && curr == ancestor)
896 *skippedAncestor = true; 898 *skippedAncestor = true;
897 curr = curr->parent(); 899 curr = curr->parent();
898 } 900 }
899 return curr; 901 return curr;
900 } 902 }
901 903
902 return parent(); 904 // If the parent layer is not a block, there might be floating objects
905 // between this layer (included) and parent layer which need to escape the
906 // inline parent to find the actual containing layer through the containing
907 // block chain.
908 if (!parent() || parent()->layoutObject().isLayoutBlock())
909 return parent();
910
911 // This is a universal approach to find containing layer, but is slower than
912 // the earlier code.
913 Optional<LayoutObject::AncestorSkipInfo> skipInfo;
914 if (skippedAncestor)
915 skipInfo.emplace(&ancestor->layoutObject());
916 auto* object = &layoutObject;
917 while (auto* container =
918 object->container(skippedAncestor ? &*skipInfo : nullptr)) {
919 if (skippedAncestor && skipInfo->ancestorSkipped())
920 *skippedAncestor = true;
921 if (container->hasLayer())
922 return toLayoutBoxModelObject(container)->layer();
923 object = container;
924 }
925 return nullptr;
903 } 926 }
904 927
905 PaintLayer* PaintLayer::enclosingTransformedAncestor() const { 928 PaintLayer* PaintLayer::enclosingTransformedAncestor() const {
906 PaintLayer* curr = parent(); 929 PaintLayer* curr = parent();
907 while (curr && !curr->isRootLayer() && !curr->transform()) 930 while (curr && !curr->isRootLayer() && !curr->transform())
908 curr = curr->parent(); 931 curr = curr->parent();
909 932
910 return curr; 933 return curr;
911 } 934 }
912 935
(...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after
3222 } 3245 }
3223 3246
3224 void showLayerTree(const blink::LayoutObject* layoutObject) { 3247 void showLayerTree(const blink::LayoutObject* layoutObject) {
3225 if (!layoutObject) { 3248 if (!layoutObject) {
3226 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3249 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3227 return; 3250 return;
3228 } 3251 }
3229 showLayerTree(layoutObject->enclosingLayer()); 3252 showLayerTree(layoutObject->enclosingLayer());
3230 } 3253 }
3231 #endif 3254 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698