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. Used to |
| 900 // determine if we skipped certain objects while walking the ancestry. |
| 901 class AncestorSkipInfo { |
| 902 public: |
| 903 AncestorSkipInfo(const LayoutObject* ancestor, bool checkForFilters = false) |
| 904 : m_ancestor(ancestor), m_checkForFilters(checkForFilters) {} |
| 905 |
| 906 // Update skip info output based on the layout object passed. |
| 907 void update(const LayoutObject& object) { |
| 908 if (&object == m_ancestor) |
| 909 m_ancestorSkipped = true; |
| 910 if (m_checkForFilters && object.hasFilterInducingProperty()) |
| 911 m_filterSkipped = true; |
| 912 } |
| 913 |
| 914 // TODO(mstensho): Get rid of this. It's just a temporary thing to retain |
| 915 // old behavior in LayoutObject::container(). |
| 916 void resetOutput() { |
| 917 m_ancestorSkipped = false; |
| 918 m_filterSkipped = false; |
| 919 } |
| 920 |
| 921 bool ancestorSkipped() const { return m_ancestorSkipped; } |
| 922 bool filterSkipped() const { |
| 923 DCHECK(m_checkForFilters); |
| 924 return m_filterSkipped; |
| 925 } |
| 926 |
| 927 private: |
| 928 // Input: A potential ancestor to look for. If we walk past this one while |
| 929 // walking the ancestry in search of some containing block, ancestorSkipped |
| 930 // will be set to true. |
| 931 const LayoutObject* m_ancestor; |
| 932 // Input: When set, we'll check if we skip objects with filter inducing |
| 933 // properties. |
| 934 bool m_checkForFilters; |
| 935 |
| 936 // Output: Set to true if |ancestor| was walked past while walking the |
| 937 // ancestry. |
| 938 bool m_ancestorSkipped = false; |
| 939 // Output: Set to true if we walked past a filter object. This will be set |
| 940 // regardless of the value of |ancestor|. |
| 941 bool m_filterSkipped = false; |
| 942 }; |
| 943 |
898 // This function returns the containing block of the object. | 944 // This function returns the containing block of the object. |
899 // Due to CSS being inconsistent, a containing block can be a relatively | 945 // 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. | 946 // positioned inline, thus we can't return a LayoutBlock from this function. |
901 // | 947 // |
902 // This method is extremely similar to containingBlock(), but with a few | 948 // This method is extremely similar to containingBlock(), but with a few |
903 // notable exceptions. | 949 // notable exceptions. |
904 // (1) For normal flow elements, it just returns the parent. | 950 // (1) For normal flow elements, it just returns the parent. |
905 // (2) For absolute positioned elements, it will return a relative | 951 // (2) For absolute positioned elements, it will return a relative |
906 // positioned inline. containingBlock() simply skips relpositioned inlines | 952 // positioned inline. containingBlock() simply skips relpositioned inlines |
907 // and lets an enclosing block handle the layout of the positioned object. | 953 // and lets an enclosing block handle the layout of the positioned object. |
908 // This does mean that computePositionedLogicalWidth and | 954 // This does mean that computePositionedLogicalWidth and |
909 // computePositionedLogicalHeight have to use container(). | 955 // computePositionedLogicalHeight have to use container(). |
910 // | 956 // |
911 // Note that floating objects don't belong to either of the above exceptions. | 957 // Note that floating objects don't belong to either of the above exceptions. |
912 // | 958 // |
913 // This function should be used for any invalidation as it would correctly | 959 // This function should be used for any invalidation as it would correctly |
914 // walk the containing block chain. See e.g. markContainerChainForLayout. | 960 // walk the containing block chain. See e.g. markContainerChainForLayout. |
915 // It is also used for correctly sizing absolutely positioned elements | 961 // It is also used for correctly sizing absolutely positioned elements |
916 // (point 3 above). | 962 // (point 3 above). |
917 // | 963 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. | 964 // Finds the container as if this object is fixed-position. |
925 LayoutBlock* containerForFixedPosition( | 965 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. | 966 // Finds the containing block as if this object is absolute-position. |
930 LayoutBlock* containingBlockForAbsolutePosition( | 967 LayoutBlock* containingBlockForAbsolutePosition( |
931 const LayoutBoxModelObject* ancestor = nullptr, | 968 AncestorSkipInfo* = nullptr) const; |
932 bool* ancestorSkipped = nullptr, | |
933 bool* filterSkipped = nullptr) const; | |
934 | 969 |
935 virtual LayoutObject* hoverAncestor() const { return parent(); } | 970 virtual LayoutObject* hoverAncestor() const { return parent(); } |
936 | 971 |
937 Element* offsetParent(const Element* = nullptr) const; | 972 Element* offsetParent(const Element* = nullptr) const; |
938 | 973 |
939 void markContainerChainForLayout(bool scheduleRelayout = true, | 974 void markContainerChainForLayout(bool scheduleRelayout = true, |
940 SubtreeLayoutScope* = nullptr); | 975 SubtreeLayoutScope* = nullptr); |
941 void setNeedsLayout(LayoutInvalidationReasonForTracing, | 976 void setNeedsLayout(LayoutInvalidationReasonForTracing, |
942 MarkingBehavior = MarkContainerChain, | 977 MarkingBehavior = MarkContainerChain, |
943 SubtreeLayoutScope* = nullptr); | 978 SubtreeLayoutScope* = nullptr); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 // non-anonymous LayoutBlock. | 1147 // non-anonymous LayoutBlock. |
1113 // Note that in the previous examples, the returned LayoutBlock has no | 1148 // Note that in the previous examples, the returned LayoutBlock has no |
1114 // logical relationship to the original element. | 1149 // logical relationship to the original element. |
1115 // | 1150 // |
1116 // LayoutBlocks are the one that handle laying out positioned elements, | 1151 // LayoutBlocks are the one that handle laying out positioned elements, |
1117 // thus this function is important during layout, to insert the positioned | 1152 // thus this function is important during layout, to insert the positioned |
1118 // elements into the correct LayoutBlock. | 1153 // elements into the correct LayoutBlock. |
1119 // | 1154 // |
1120 // See container() for the function that returns the containing block. | 1155 // See container() for the function that returns the containing block. |
1121 // See LayoutBlock.h for some extra explanations on containing blocks. | 1156 // See LayoutBlock.h for some extra explanations on containing blocks. |
1122 LayoutBlock* containingBlock(const LayoutBoxModelObject* ancestor = nullptr, | 1157 LayoutBlock* containingBlock(AncestorSkipInfo* = nullptr) const; |
1123 bool* ancestorSkipped = nullptr, | |
1124 bool* filterSkipped = nullptr) const; | |
1125 | 1158 |
1126 bool canContainAbsolutePositionObjects() const { | 1159 bool canContainAbsolutePositionObjects() const { |
1127 return m_style->canContainAbsolutePositionObjects() || | 1160 return m_style->canContainAbsolutePositionObjects() || |
1128 canContainFixedPositionObjects(); | 1161 canContainFixedPositionObjects(); |
1129 } | 1162 } |
1130 bool canContainFixedPositionObjects() const { | 1163 bool canContainFixedPositionObjects() const { |
1131 return isLayoutView() || isSVGForeignObject() || | 1164 return isLayoutView() || isSVGForeignObject() || |
1132 (isLayoutBlock() && m_style->canContainFixedPositionObjects()); | 1165 (isLayoutBlock() && m_style->canContainFixedPositionObjects()); |
1133 } | 1166 } |
1134 | 1167 |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 // LayoutBox recomputeOverflow-capable. crbug.com/437012 and crbug.com/434700. | 2061 // LayoutBox recomputeOverflow-capable. crbug.com/437012 and crbug.com/434700. |
2029 inline void markAncestorsForOverflowRecalcIfNeeded(); | 2062 inline void markAncestorsForOverflowRecalcIfNeeded(); |
2030 | 2063 |
2031 inline void markAncestorsForPaintInvalidation(); | 2064 inline void markAncestorsForPaintInvalidation(); |
2032 | 2065 |
2033 inline void invalidateContainerPreferredLogicalWidths(); | 2066 inline void invalidateContainerPreferredLogicalWidths(); |
2034 | 2067 |
2035 void invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal( | 2068 void invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal( |
2036 const LayoutBoxModelObject& paintInvalidationContainer); | 2069 const LayoutBoxModelObject& paintInvalidationContainer); |
2037 | 2070 |
2038 LayoutObject* containerForAbsolutePosition( | 2071 LayoutObject* containerForAbsolutePosition(AncestorSkipInfo* = nullptr) const; |
2039 const LayoutBoxModelObject* ancestor = nullptr, | |
2040 bool* ancestorSkipped = nullptr, | |
2041 bool* filterSkipped = nullptr) const; | |
2042 | 2072 |
2043 const LayoutBoxModelObject* enclosingCompositedContainer() const; | 2073 const LayoutBoxModelObject* enclosingCompositedContainer() const; |
2044 | 2074 |
2045 LayoutFlowThread* locateFlowThreadContainingBlock() const; | 2075 LayoutFlowThread* locateFlowThreadContainingBlock() const; |
2046 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); | 2076 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); |
2047 | 2077 |
2048 ComputedStyle* cachedFirstLineStyle() const; | 2078 ComputedStyle* cachedFirstLineStyle() const; |
2049 StyleDifference adjustStyleDifference(StyleDifference) const; | 2079 StyleDifference adjustStyleDifference(StyleDifference) const; |
2050 | 2080 |
2051 Color selectionColor(int colorProperty, const GlobalPaintFlags) const; | 2081 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*); | 2700 CORE_EXPORT void showLineTree(const blink::LayoutObject*); |
2671 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); | 2701 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); |
2672 // We don't make object2 an optional parameter so that showLayoutTree | 2702 // We don't make object2 an optional parameter so that showLayoutTree |
2673 // can be called from gdb easily. | 2703 // can be called from gdb easily. |
2674 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, | 2704 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, |
2675 const blink::LayoutObject* object2); | 2705 const blink::LayoutObject* object2); |
2676 | 2706 |
2677 #endif | 2707 #endif |
2678 | 2708 |
2679 #endif // LayoutObject_h | 2709 #endif // LayoutObject_h |
OLD | NEW |