OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2009 Google Inc. All rights reserved. | 8 * Copyright (C) 2009 Google Inc. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 // implemented using flex box but should still support things like | 888 // implemented using flex box but should still support things like |
889 // first-line, first-letter and text-overflow. | 889 // first-line, first-letter and text-overflow. |
890 // The flex box and grid specs require that flex box and grid do not | 890 // The flex box and grid specs require that flex box and grid do not |
891 // support first-line|first-letter, though. | 891 // support first-line|first-letter, though. |
892 // TODO(cbiesinger): Remove when buttons are implemented with align-items | 892 // TODO(cbiesinger): Remove when buttons are implemented with align-items |
893 // instead of flex box. crbug.com/226252. | 893 // instead of flex box. crbug.com/226252. |
894 bool behavesLikeBlockContainer() const { | 894 bool behavesLikeBlockContainer() const { |
895 return isLayoutBlockFlow() || isLayoutButton(); | 895 return isLayoutBlockFlow() || isLayoutButton(); |
896 } | 896 } |
897 | 897 |
898 // May be optionally passed to container() and various other similar methods | |
899 // that search the ancestry for some sort of containing block. | |
900 struct AncestorSkipInfo { | |
901 AncestorSkipInfo() {} | |
Xianzhu
2017/01/15 23:05:05
Is the above constructor needed?
mstensho (USE GERRIT)
2017/01/16 09:34:04
Maybe it's not used at the moment, but it should b
| |
902 AncestorSkipInfo(const LayoutObject* ancestor) : ancestor(ancestor) {} | |
903 | |
904 void resetOutput() { | |
905 ancestorSkipped = false; | |
906 filterSkipped = false; | |
907 } | |
Xianzhu
2017/01/15 19:41:13
As we have default values for the fields, do we st
mstensho (USE GERRIT)
2017/01/15 21:09:25
There is a unit test that called container() twice
Xianzhu
2017/01/15 23:05:05
Agreed (about setAncestor() :) ).
mstensho (USE GERRIT)
2017/01/16 09:34:04
Done. Removed.
| |
908 void setAncestor(const LayoutObject* ancestor) { | |
909 this->ancestor = ancestor; | |
910 resetOutput(); | |
911 } | |
Xianzhu
2017/01/15 19:41:13
What's the purpose of this method?
mstensho (USE GERRIT)
2017/01/15 21:09:25
This will update this AncestorSkipInfo object base
Xianzhu
2017/01/15 23:05:05
I meant setAncestor() here. Sorry for the confusio
| |
912 void update(const LayoutObject&); | |
Xianzhu
2017/01/15 19:41:13
I'm a bit concerned about performance of this meth
mstensho (USE GERRIT)
2017/01/15 21:09:25
I was kind of assuming that it wasn't the common c
Xianzhu
2017/01/15 23:05:05
The difference is that pushing two pointers on the
mstensho (USE GERRIT)
2017/01/16 09:34:04
Done. Also made update() inline.
mstensho (USE GERRIT)
2017/01/16 14:39:02
This turned out to be tricky (see trybot failures
| |
913 | |
914 // Input: A potential ancestor to look for. If we walk past this one while | |
915 // walking the ancestry in search of some containing block, ancestorSkipped | |
916 // will be set to true. | |
917 const LayoutObject* ancestor = nullptr; | |
918 // Output: Set to true if |ancestor| was walked past while walking the | |
919 // ancestry. | |
920 bool ancestorSkipped = false; | |
921 // Output: Set to true if we walked past a filter object. This will be set | |
922 // regardless of the value of |ancestor|. | |
923 bool filterSkipped = false; | |
924 }; | |
925 | |
898 // This function returns the containing block of the object. | 926 // This function returns the containing block of the object. |
899 // Due to CSS being inconsistent, a containing block can be a relatively | 927 // Due to CSS being inconsistent, a containing block can be a relatively |
900 // positioned inline, thus we can't return a LayoutBlock from this function. | 928 // positioned inline, thus we can't return a LayoutBlock from this function. |
901 // | 929 // |
902 // This method is extremely similar to containingBlock(), but with a few | 930 // This method is extremely similar to containingBlock(), but with a few |
903 // notable exceptions. | 931 // notable exceptions. |
904 // (1) For normal flow elements, it just returns the parent. | 932 // (1) For normal flow elements, it just returns the parent. |
905 // (2) For absolute positioned elements, it will return a relative | 933 // (2) For absolute positioned elements, it will return a relative |
906 // positioned inline. containingBlock() simply skips relpositioned inlines | 934 // positioned inline. containingBlock() simply skips relpositioned inlines |
907 // and lets an enclosing block handle the layout of the positioned object. | 935 // and lets an enclosing block handle the layout of the positioned object. |
908 // This does mean that computePositionedLogicalWidth and | 936 // This does mean that computePositionedLogicalWidth and |
909 // computePositionedLogicalHeight have to use container(). | 937 // computePositionedLogicalHeight have to use container(). |
910 // | 938 // |
911 // Note that floating objects don't belong to either of the above exceptions. | 939 // Note that floating objects don't belong to either of the above exceptions. |
912 // | 940 // |
913 // This function should be used for any invalidation as it would correctly | 941 // This function should be used for any invalidation as it would correctly |
914 // walk the containing block chain. See e.g. markContainerChainForLayout. | 942 // walk the containing block chain. See e.g. markContainerChainForLayout. |
915 // It is also used for correctly sizing absolutely positioned elements | 943 // It is also used for correctly sizing absolutely positioned elements |
916 // (point 3 above). | 944 // (point 3 above). |
917 // | 945 LayoutObject* container(AncestorSkipInfo* = nullptr) const; |
918 // If |ancestor| and |ancestorSkipped| are not null, on return | |
919 // *ancestorSkipped is true if the layoutObject returned is an ancestor of | |
920 // |ancestor|. | |
921 LayoutObject* container(const LayoutBoxModelObject* ancestor = nullptr, | |
922 bool* ancestorSkipped = nullptr, | |
923 bool* filterSkipped = nullptr) const; | |
924 // Finds the container as if this object is fixed-position. | 946 // Finds the container as if this object is fixed-position. |
925 LayoutBlock* containerForFixedPosition( | 947 LayoutBlock* containerForFixedPosition(AncestorSkipInfo* = nullptr) const; |
926 const LayoutBoxModelObject* ancestor = nullptr, | |
927 bool* ancestorSkipped = nullptr, | |
928 bool* filterSkipped = nullptr) const; | |
929 // Finds the containing block as if this object is absolute-position. | 948 // Finds the containing block as if this object is absolute-position. |
930 LayoutBlock* containingBlockForAbsolutePosition( | 949 LayoutBlock* containingBlockForAbsolutePosition( |
931 const LayoutBoxModelObject* ancestor = nullptr, | 950 AncestorSkipInfo* = nullptr) const; |
932 bool* ancestorSkipped = nullptr, | |
933 bool* filterSkipped = nullptr) const; | |
934 | 951 |
935 virtual LayoutObject* hoverAncestor() const { return parent(); } | 952 virtual LayoutObject* hoverAncestor() const { return parent(); } |
936 | 953 |
937 Element* offsetParent(const Element* = nullptr) const; | 954 Element* offsetParent(const Element* = nullptr) const; |
938 | 955 |
939 void markContainerChainForLayout(bool scheduleRelayout = true, | 956 void markContainerChainForLayout(bool scheduleRelayout = true, |
940 SubtreeLayoutScope* = nullptr); | 957 SubtreeLayoutScope* = nullptr); |
941 void setNeedsLayout(LayoutInvalidationReasonForTracing, | 958 void setNeedsLayout(LayoutInvalidationReasonForTracing, |
942 MarkingBehavior = MarkContainerChain, | 959 MarkingBehavior = MarkContainerChain, |
943 SubtreeLayoutScope* = nullptr); | 960 SubtreeLayoutScope* = nullptr); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1112 // non-anonymous LayoutBlock. | 1129 // non-anonymous LayoutBlock. |
1113 // Note that in the previous examples, the returned LayoutBlock has no | 1130 // Note that in the previous examples, the returned LayoutBlock has no |
1114 // logical relationship to the original element. | 1131 // logical relationship to the original element. |
1115 // | 1132 // |
1116 // LayoutBlocks are the one that handle laying out positioned elements, | 1133 // LayoutBlocks are the one that handle laying out positioned elements, |
1117 // thus this function is important during layout, to insert the positioned | 1134 // thus this function is important during layout, to insert the positioned |
1118 // elements into the correct LayoutBlock. | 1135 // elements into the correct LayoutBlock. |
1119 // | 1136 // |
1120 // See container() for the function that returns the containing block. | 1137 // See container() for the function that returns the containing block. |
1121 // See LayoutBlock.h for some extra explanations on containing blocks. | 1138 // See LayoutBlock.h for some extra explanations on containing blocks. |
1122 LayoutBlock* containingBlock(const LayoutBoxModelObject* ancestor = nullptr, | 1139 LayoutBlock* containingBlock(AncestorSkipInfo* = nullptr) const; |
1123 bool* ancestorSkipped = nullptr, | |
1124 bool* filterSkipped = nullptr) const; | |
1125 | 1140 |
1126 bool canContainAbsolutePositionObjects() const { | 1141 bool canContainAbsolutePositionObjects() const { |
1127 return m_style->canContainAbsolutePositionObjects() || | 1142 return m_style->canContainAbsolutePositionObjects() || |
1128 canContainFixedPositionObjects(); | 1143 canContainFixedPositionObjects(); |
1129 } | 1144 } |
1130 bool canContainFixedPositionObjects() const { | 1145 bool canContainFixedPositionObjects() const { |
1131 return isLayoutView() || isSVGForeignObject() || | 1146 return isLayoutView() || isSVGForeignObject() || |
1132 (isLayoutBlock() && m_style->canContainFixedPositionObjects()); | 1147 (isLayoutBlock() && m_style->canContainFixedPositionObjects()); |
1133 } | 1148 } |
1134 | 1149 |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2028 // LayoutBox recomputeOverflow-capable. crbug.com/437012 and crbug.com/434700. | 2043 // LayoutBox recomputeOverflow-capable. crbug.com/437012 and crbug.com/434700. |
2029 inline void markAncestorsForOverflowRecalcIfNeeded(); | 2044 inline void markAncestorsForOverflowRecalcIfNeeded(); |
2030 | 2045 |
2031 inline void markAncestorsForPaintInvalidation(); | 2046 inline void markAncestorsForPaintInvalidation(); |
2032 | 2047 |
2033 inline void invalidateContainerPreferredLogicalWidths(); | 2048 inline void invalidateContainerPreferredLogicalWidths(); |
2034 | 2049 |
2035 void invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal( | 2050 void invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal( |
2036 const LayoutBoxModelObject& paintInvalidationContainer); | 2051 const LayoutBoxModelObject& paintInvalidationContainer); |
2037 | 2052 |
2038 LayoutObject* containerForAbsolutePosition( | 2053 LayoutObject* containerForAbsolutePosition(AncestorSkipInfo* = nullptr) const; |
2039 const LayoutBoxModelObject* ancestor = nullptr, | |
2040 bool* ancestorSkipped = nullptr, | |
2041 bool* filterSkipped = nullptr) const; | |
2042 | 2054 |
2043 const LayoutBoxModelObject* enclosingCompositedContainer() const; | 2055 const LayoutBoxModelObject* enclosingCompositedContainer() const; |
2044 | 2056 |
2045 LayoutFlowThread* locateFlowThreadContainingBlock() const; | 2057 LayoutFlowThread* locateFlowThreadContainingBlock() const; |
2046 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); | 2058 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); |
2047 | 2059 |
2048 ComputedStyle* cachedFirstLineStyle() const; | 2060 ComputedStyle* cachedFirstLineStyle() const; |
2049 StyleDifference adjustStyleDifference(StyleDifference) const; | 2061 StyleDifference adjustStyleDifference(StyleDifference) const; |
2050 | 2062 |
2051 Color selectionColor(int colorProperty, const GlobalPaintFlags) const; | 2063 Color selectionColor(int colorProperty, const GlobalPaintFlags) const; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2670 CORE_EXPORT void showLineTree(const blink::LayoutObject*); | 2682 CORE_EXPORT void showLineTree(const blink::LayoutObject*); |
2671 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); | 2683 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); |
2672 // We don't make object2 an optional parameter so that showLayoutTree | 2684 // We don't make object2 an optional parameter so that showLayoutTree |
2673 // can be called from gdb easily. | 2685 // can be called from gdb easily. |
2674 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, | 2686 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, |
2675 const blink::LayoutObject* object2); | 2687 const blink::LayoutObject* object2); |
2676 | 2688 |
2677 #endif | 2689 #endif |
2678 | 2690 |
2679 #endif // LayoutObject_h | 2691 #endif // LayoutObject_h |
OLD | NEW |