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. All r
ights reserved. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 13 matching lines...) Expand all Loading... |
24 */ | 24 */ |
25 | 25 |
26 #ifndef LayoutObject_h | 26 #ifndef LayoutObject_h |
27 #define LayoutObject_h | 27 #define LayoutObject_h |
28 | 28 |
29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/DocumentLifecycle.h" | 31 #include "core/dom/DocumentLifecycle.h" |
32 #include "core/dom/Element.h" | 32 #include "core/dom/Element.h" |
33 #include "core/editing/PositionWithAffinity.h" | 33 #include "core/editing/PositionWithAffinity.h" |
34 #include "core/fetch/ImageResourceClient.h" | 34 #include "core/fetch/ImageResourceObserver.h" |
35 #include "core/html/HTMLElement.h" | 35 #include "core/html/HTMLElement.h" |
36 #include "core/inspector/InspectorTraceEvents.h" | 36 #include "core/inspector/InspectorTraceEvents.h" |
37 #include "core/layout/HitTestRequest.h" | 37 #include "core/layout/HitTestRequest.h" |
38 #include "core/layout/LayoutObjectChildList.h" | 38 #include "core/layout/LayoutObjectChildList.h" |
39 #include "core/layout/PaintInvalidationState.h" | 39 #include "core/layout/PaintInvalidationState.h" |
40 #include "core/layout/ScrollAlignment.h" | 40 #include "core/layout/ScrollAlignment.h" |
41 #include "core/layout/SubtreeLayoutScope.h" | 41 #include "core/layout/SubtreeLayoutScope.h" |
42 #include "core/layout/api/HitTestAction.h" | 42 #include "core/layout/api/HitTestAction.h" |
43 #include "core/layout/api/SelectionState.h" | 43 #include "core/layout/api/SelectionState.h" |
44 #include "core/layout/compositing/CompositingState.h" | 44 #include "core/layout/compositing/CompositingState.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // the ancestors all the way to the enclosing relayout boundary in order to do a
correct layout. | 143 // the ancestors all the way to the enclosing relayout boundary in order to do a
correct layout. |
144 // | 144 // |
145 // Due to the high cost of layout, a lot of effort is done to avoid doing full l
ayouts of nodes. | 145 // Due to the high cost of layout, a lot of effort is done to avoid doing full l
ayouts of nodes. |
146 // This is why there are several types of layout available to bypass the complex
operations. See the | 146 // This is why there are several types of layout available to bypass the complex
operations. See the |
147 // comments on the layout booleans in LayoutObjectBitfields below about the diff
erent layouts. | 147 // comments on the layout booleans in LayoutObjectBitfields below about the diff
erent layouts. |
148 // | 148 // |
149 // To save memory, especially for the common child class LayoutText, LayoutObjec
t doesn't provide | 149 // To save memory, especially for the common child class LayoutText, LayoutObjec
t doesn't provide |
150 // storage for children. Descendant classes that do allow children have to have
a LayoutObjectChildList | 150 // storage for children. Descendant classes that do allow children have to have
a LayoutObjectChildList |
151 // member that stores the actual children and override virtualChildren(). | 151 // member that stores the actual children and override virtualChildren(). |
152 // | 152 // |
153 // LayoutObject is an ImageResourceClient, which means that it gets notified whe
n associated images | 153 // LayoutObject is an ImageResourceObserver, which means that it gets notified w
hen associated images |
154 // are changed. This is used for 2 main use cases: | 154 // are changed. This is used for 2 main use cases: |
155 // - reply to 'background-image' as we need to invalidate the background in this
case. | 155 // - reply to 'background-image' as we need to invalidate the background in this
case. |
156 // (See https://drafts.csswg.org/css-backgrounds-3/#the-background-image) | 156 // (See https://drafts.csswg.org/css-backgrounds-3/#the-background-image) |
157 // - image (LayoutImage, LayoutSVGImage) or video (LayoutVideo) objects that are
placeholders for | 157 // - image (LayoutImage, LayoutSVGImage) or video (LayoutVideo) objects that are
placeholders for |
158 // displaying them. | 158 // displaying them. |
159 // | 159 // |
160 // | 160 // |
161 // ***** LIFETIME ***** | 161 // ***** LIFETIME ***** |
162 // | 162 // |
163 // LayoutObjects are fully owned by their associated DOM node. In other words, | 163 // LayoutObjects are fully owned by their associated DOM node. In other words, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // because only boxes implementing the full box model have a need for them. | 197 // because only boxes implementing the full box model have a need for them. |
198 // Because LayoutBlockFlow's intrinsic widths rely on the underlying text | 198 // Because LayoutBlockFlow's intrinsic widths rely on the underlying text |
199 // content, LayoutBlockFlow may call LayoutText::computePreferredLogicalWidths. | 199 // content, LayoutBlockFlow may call LayoutText::computePreferredLogicalWidths. |
200 // | 200 // |
201 // The 2 widths are computed lazily during layout when the getters are called. | 201 // The 2 widths are computed lazily during layout when the getters are called. |
202 // The computation is done by calling computePreferredLogicalWidths() behind the | 202 // The computation is done by calling computePreferredLogicalWidths() behind the |
203 // scene. The boolean used to control the lazy recomputation is | 203 // scene. The boolean used to control the lazy recomputation is |
204 // preferredLogicalWidthsDirty. | 204 // preferredLogicalWidthsDirty. |
205 // | 205 // |
206 // See the individual getters below for more details about what each width is. | 206 // See the individual getters below for more details about what each width is. |
207 class CORE_EXPORT LayoutObject : public ImageResourceClient, public DisplayItemC
lient { | 207 class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
mClient { |
208 friend class LayoutObjectChildList; | 208 friend class LayoutObjectChildList; |
209 WTF_MAKE_NONCOPYABLE(LayoutObject); | 209 WTF_MAKE_NONCOPYABLE(LayoutObject); |
210 public: | 210 public: |
211 // Anonymous objects should pass the document as their node, and they will t
hen automatically be | 211 // Anonymous objects should pass the document as their node, and they will t
hen automatically be |
212 // marked as anonymous in the constructor. | 212 // marked as anonymous in the constructor. |
213 explicit LayoutObject(Node*); | 213 explicit LayoutObject(Node*); |
214 ~LayoutObject() override; | 214 ~LayoutObject() override; |
215 | 215 |
216 // Returns the name of the layout object. | 216 // Returns the name of the layout object. |
217 virtual const char* name() const = 0; | 217 virtual const char* name() const = 0; |
218 | 218 |
219 // Returns the decorated name used by run-layout-tests. The name contains th
e name of the object | 219 // Returns the decorated name used by run-layout-tests. The name contains th
e name of the object |
220 // along with extra information about the layout object state (e.g. position
ing). | 220 // along with extra information about the layout object state (e.g. position
ing). |
221 String decoratedName() const; | 221 String decoratedName() const; |
222 | 222 |
223 // DisplayItemClient methods. | 223 // DisplayItemClient methods. |
224 LayoutRect visualRect() const override; | 224 LayoutRect visualRect() const override; |
225 String debugName() const final; | 225 String debugName() const override; |
226 | 226 |
227 LayoutObject* parent() const { return m_parent; } | 227 LayoutObject* parent() const { return m_parent; } |
228 bool isDescendantOf(const LayoutObject*) const; | 228 bool isDescendantOf(const LayoutObject*) const; |
229 | 229 |
230 LayoutObject* previousSibling() const { return m_previous; } | 230 LayoutObject* previousSibling() const { return m_previous; } |
231 LayoutObject* nextSibling() const { return m_next; } | 231 LayoutObject* nextSibling() const { return m_next; } |
232 | 232 |
233 LayoutObject* slowFirstChild() const | 233 LayoutObject* slowFirstChild() const |
234 { | 234 { |
235 if (const LayoutObjectChildList* children = virtualChildren()) | 235 if (const LayoutObjectChildList* children = virtualChildren()) |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 | 1168 |
1169 virtual bool isCombineText() const { return false; } | 1169 virtual bool isCombineText() const { return false; } |
1170 | 1170 |
1171 virtual int caretMinOffset() const; | 1171 virtual int caretMinOffset() const; |
1172 virtual int caretMaxOffset() const; | 1172 virtual int caretMaxOffset() const; |
1173 | 1173 |
1174 virtual int previousOffset(int current) const; | 1174 virtual int previousOffset(int current) const; |
1175 virtual int previousOffsetForBackwardDeletion(int current) const; | 1175 virtual int previousOffsetForBackwardDeletion(int current) const; |
1176 virtual int nextOffset(int current) const; | 1176 virtual int nextOffset(int current) const; |
1177 | 1177 |
1178 // ImageResourceClient override. | 1178 // ImageResourceObserver override. |
1179 void imageChanged(ImageResource*, const IntRect* = nullptr) final; | 1179 void imageChanged(ImageResource*, const IntRect* = nullptr) final; |
1180 bool willRenderImage(ImageResource*) final; | 1180 bool willRenderImage() final; |
1181 bool getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy&) final; | 1181 bool getImageAnimationPolicy(ImageAnimationPolicy&) final; |
1182 | 1182 |
1183 // Sub-classes that have an associated image need to override this function | 1183 // Sub-classes that have an associated image need to override this function |
1184 // to get notified of any image change. | 1184 // to get notified of any image change. |
1185 virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { } | 1185 virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { } |
1186 | 1186 |
1187 void selectionStartEnd(int& spos, int& epos) const; | 1187 void selectionStartEnd(int& spos, int& epos) const; |
1188 | 1188 |
1189 void remove() | 1189 void remove() |
1190 { | 1190 { |
1191 if (parent()) | 1191 if (parent()) |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 void showTree(const blink::LayoutObject*); | 2109 void showTree(const blink::LayoutObject*); |
2110 void showLineTree(const blink::LayoutObject*); | 2110 void showLineTree(const blink::LayoutObject*); |
2111 void showLayoutTree(const blink::LayoutObject* object1); | 2111 void showLayoutTree(const blink::LayoutObject* object1); |
2112 // We don't make object2 an optional parameter so that showLayoutTree | 2112 // We don't make object2 an optional parameter so that showLayoutTree |
2113 // can be called from gdb easily. | 2113 // can be called from gdb easily. |
2114 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec
t* object2); | 2114 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec
t* object2); |
2115 | 2115 |
2116 #endif | 2116 #endif |
2117 | 2117 |
2118 #endif // LayoutObject_h | 2118 #endif // LayoutObject_h |
OLD | NEW |