| OLD | NEW |
| 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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 870 |
| 871 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor, | 871 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor, |
| 872 bool* skippedAncestor) const { | 872 bool* skippedAncestor) const { |
| 873 // If we have specified an ancestor, surely the caller needs to know whether | 873 // If we have specified an ancestor, surely the caller needs to know whether |
| 874 // we skipped it. | 874 // we skipped it. |
| 875 DCHECK(!ancestor || skippedAncestor); | 875 DCHECK(!ancestor || skippedAncestor); |
| 876 if (skippedAncestor) | 876 if (skippedAncestor) |
| 877 *skippedAncestor = false; | 877 *skippedAncestor = false; |
| 878 | 878 |
| 879 LayoutObject& layoutObject = this->layoutObject(); | 879 LayoutObject& layoutObject = this->layoutObject(); |
| 880 // Column span need to find the containing layer through its containing block. | |
| 881 // TODO(wangxianzhu): This can be combined with the loop handing possible | |
| 882 // floating objects. | |
| 883 if (layoutObject.isColumnSpanAll()) { | |
| 884 Optional<LayoutObject::AncestorSkipInfo> skipInfo; | |
| 885 if (skippedAncestor) | |
| 886 skipInfo.emplace(&ancestor->layoutObject()); | |
| 887 if (auto containingBlock = layoutObject.containingBlock( | |
| 888 skippedAncestor ? &*skipInfo : nullptr)) { | |
| 889 if (skippedAncestor && skipInfo->ancestorSkipped()) | |
| 890 *skippedAncestor = true; | |
| 891 return containingBlock->enclosingLayer(); | |
| 892 } | |
| 893 return nullptr; | |
| 894 } | |
| 895 | |
| 896 if (layoutObject.isOutOfFlowPositioned()) { | 880 if (layoutObject.isOutOfFlowPositioned()) { |
| 897 auto canContainThisLayer = | 881 auto canContainThisLayer = |
| 898 layoutObject.isFixedPositioned() | 882 layoutObject.isFixedPositioned() |
| 899 ? &LayoutObject::canContainFixedPositionObjects | 883 ? &LayoutObject::canContainFixedPositionObjects |
| 900 : &LayoutObject::canContainAbsolutePositionObjects; | 884 : &LayoutObject::canContainAbsolutePositionObjects; |
| 901 | 885 |
| 902 PaintLayer* curr = parent(); | 886 PaintLayer* curr = parent(); |
| 903 while (curr && !((&curr->layoutObject())->*canContainThisLayer)()) { | 887 while (curr && !((&curr->layoutObject())->*canContainThisLayer)()) { |
| 904 if (skippedAncestor && curr == ancestor) | 888 if (skippedAncestor && curr == ancestor) |
| 905 *skippedAncestor = true; | 889 *skippedAncestor = true; |
| 906 curr = curr->parent(); | 890 curr = curr->parent(); |
| 907 } | 891 } |
| 908 return curr; | 892 return curr; |
| 909 } | 893 } |
| 910 | 894 |
| 911 // If the parent layer is not a block, there might be floating objects | 895 // If the parent layer is not a block, there might be floating objects |
| 912 // between this layer (included) and parent layer which need to escape the | 896 // between this layer (included) and parent layer which need to escape the |
| 913 // inline parent to find the actual containing layer through the containing | 897 // inline parent to find the actual containing layer through the containing |
| 914 // block chain. | 898 // block chain. |
| 915 if (!parent() || parent()->layoutObject().isLayoutBlock()) | 899 // Column span need to find the containing layer through its containing block. |
| 900 if ((!parent() || parent()->layoutObject().isLayoutBlock()) && |
| 901 !layoutObject.isColumnSpanAll()) |
| 916 return parent(); | 902 return parent(); |
| 917 | 903 |
| 918 // This is a universal approach to find containing layer, but is slower than | 904 // This is a universal approach to find containing layer, but is slower than |
| 919 // the earlier code. | 905 // the earlier code. |
| 920 Optional<LayoutObject::AncestorSkipInfo> skipInfo; | 906 Optional<LayoutObject::AncestorSkipInfo> skipInfo; |
| 921 if (skippedAncestor) | 907 if (skippedAncestor) |
| 922 skipInfo.emplace(&ancestor->layoutObject()); | 908 skipInfo.emplace(&ancestor->layoutObject()); |
| 923 auto* object = &layoutObject; | 909 auto* object = &layoutObject; |
| 924 while (auto* container = | 910 while (auto* container = |
| 925 object->container(skippedAncestor ? &*skipInfo : nullptr)) { | 911 object->container(skippedAncestor ? &*skipInfo : nullptr)) { |
| (...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3252 } | 3238 } |
| 3253 | 3239 |
| 3254 void showLayerTree(const blink::LayoutObject* layoutObject) { | 3240 void showLayerTree(const blink::LayoutObject* layoutObject) { |
| 3255 if (!layoutObject) { | 3241 if (!layoutObject) { |
| 3256 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; | 3242 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; |
| 3257 return; | 3243 return; |
| 3258 } | 3244 } |
| 3259 showLayerTree(layoutObject->enclosingLayer()); | 3245 showLayerTree(layoutObject->enclosingLayer()); |
| 3260 } | 3246 } |
| 3261 #endif | 3247 #endif |
| OLD | NEW |