OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved. | 4 * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved. |
5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef LayoutBoxModelObject_h | 24 #ifndef LayoutBoxModelObject_h |
25 #define LayoutBoxModelObject_h | 25 #define LayoutBoxModelObject_h |
26 | 26 |
27 #include "core/CoreExport.h" | 27 #include "core/CoreExport.h" |
28 #include "core/layout/LayoutObject.h" | 28 #include "core/layout/LayoutObject.h" |
| 29 #include "core/page/scrolling/StickyPositionScrollingConstraints.h" |
29 #include "core/style/ShadowData.h" | 30 #include "core/style/ShadowData.h" |
30 #include "platform/geometry/LayoutRect.h" | 31 #include "platform/geometry/LayoutRect.h" |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 | 34 |
34 class LineLayoutBoxModel; | 35 class LineLayoutBoxModel; |
35 class PaintLayer; | 36 class PaintLayer; |
36 class PaintLayerScrollableArea; | 37 class PaintLayerScrollableArea; |
37 | 38 |
38 enum PaintLayerType { | 39 enum PaintLayerType { |
(...skipping 18 matching lines...) Expand all Loading... |
57 }; | 58 }; |
58 | 59 |
59 enum ContentChangeType { | 60 enum ContentChangeType { |
60 ImageChanged, | 61 ImageChanged, |
61 CanvasChanged, | 62 CanvasChanged, |
62 CanvasContextChanged | 63 CanvasContextChanged |
63 }; | 64 }; |
64 | 65 |
65 class InlineFlowBox; | 66 class InlineFlowBox; |
66 | 67 |
| 68 struct LayoutBoxModelObjectRareData { |
| 69 WTF_MAKE_NONCOPYABLE(LayoutBoxModelObjectRareData); |
| 70 USING_FAST_MALLOC(LayoutBoxModelObjectRareData); |
| 71 public: |
| 72 LayoutBoxModelObjectRareData() {} |
| 73 |
| 74 StickyPositionScrollingConstraints m_stickyPositionScrollingConstraints; |
| 75 }; |
| 76 |
67 // This class is the base class for all CSS objects. | 77 // This class is the base class for all CSS objects. |
68 // | 78 // |
69 // All CSS objects follow the box model object. See THE BOX MODEL section in | 79 // All CSS objects follow the box model object. See THE BOX MODEL section in |
70 // LayoutBox for more information. | 80 // LayoutBox for more information. |
71 // | 81 // |
72 // This class actually doesn't have the box model but it exposes some common | 82 // This class actually doesn't have the box model but it exposes some common |
73 // functions or concepts that sub-classes can extend upon. For example, there | 83 // functions or concepts that sub-classes can extend upon. For example, there |
74 // are accessors for margins, borders, paddings and borderBoundingBox(). | 84 // are accessors for margins, borders, paddings and borderBoundingBox(). |
75 // | 85 // |
76 // The reason for this partial implementation is that the 2 classes inheriting | 86 // The reason for this partial implementation is that the 2 classes inheriting |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 public: | 144 public: |
135 LayoutBoxModelObject(ContainerNode*); | 145 LayoutBoxModelObject(ContainerNode*); |
136 ~LayoutBoxModelObject() override; | 146 ~LayoutBoxModelObject() override; |
137 | 147 |
138 // This is the only way layers should ever be destroyed. | 148 // This is the only way layers should ever be destroyed. |
139 void destroyLayer(); | 149 void destroyLayer(); |
140 | 150 |
141 LayoutSize relativePositionOffset() const; | 151 LayoutSize relativePositionOffset() const; |
142 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon
talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose
dSize(); } | 152 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon
talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose
dSize(); } |
143 | 153 |
| 154 // Populates StickyPositionConstraints, setting the sticky box rect, contain
ing block rect and updating |
| 155 // the constraint offsets according to the available space. |
| 156 FloatRect computeStickyConstrainingRect() const; |
| 157 void updateStickyPositionConstraints() const; |
| 158 LayoutSize stickyPositionOffset() const; |
| 159 |
144 LayoutSize offsetForInFlowPosition() const; | 160 LayoutSize offsetForInFlowPosition() const; |
145 | 161 |
146 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin
es (LayoutFlow) | 162 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin
es (LayoutFlow) |
147 // to return the remaining width on a given line (and the height of a single
line). | 163 // to return the remaining width on a given line (and the height of a single
line). |
148 virtual LayoutUnit offsetLeft() const; | 164 virtual LayoutUnit offsetLeft() const; |
149 virtual LayoutUnit offsetTop() const; | 165 virtual LayoutUnit offsetTop() const; |
150 virtual LayoutUnit offsetWidth() const = 0; | 166 virtual LayoutUnit offsetWidth() const = 0; |
151 virtual LayoutUnit offsetHeight() const = 0; | 167 virtual LayoutUnit offsetHeight() const = 0; |
152 | 168 |
153 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } | 169 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 LayoutBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con
st; | 339 LayoutBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con
st; |
324 | 340 |
325 void addOutlineRectsForNormalChildren(Vector<LayoutRect>&, const LayoutPoint
& additionalOffset, IncludeBlockVisualOverflowOrNot) const; | 341 void addOutlineRectsForNormalChildren(Vector<LayoutRect>&, const LayoutPoint
& additionalOffset, IncludeBlockVisualOverflowOrNot) const; |
326 void addOutlineRectsForDescendant(const LayoutObject& descendant, Vector<Lay
outRect>&, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot)
const; | 342 void addOutlineRectsForDescendant(const LayoutObject& descendant, Vector<Lay
outRect>&, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot)
const; |
327 | 343 |
328 void addLayerHitTestRects(LayerHitTestRects&, const PaintLayer*, const Layou
tPoint&, const LayoutRect&) const override; | 344 void addLayerHitTestRects(LayerHitTestRects&, const PaintLayer*, const Layou
tPoint&, const LayoutRect&) const override; |
329 | 345 |
330 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid
e; | 346 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid
e; |
331 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; | 347 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; |
332 | 348 |
| 349 void invalidateStickyConstraints(); |
| 350 |
333 public: | 351 public: |
334 // These functions are only used internally to manipulate the layout tree st
ructure via remove/insert/appendChildNode. | 352 // These functions are only used internally to manipulate the layout tree st
ructure via remove/insert/appendChildNode. |
335 // Since they are typically called only to move objects around within anonym
ous blocks (which only have layers in | 353 // Since they are typically called only to move objects around within anonym
ous blocks (which only have layers in |
336 // the case of column spans), the default for fullRemoveInsert is false rath
er than true. | 354 // the case of column spans), the default for fullRemoveInsert is false rath
er than true. |
337 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, LayoutObject* beforeChild, bool fullRemoveInsert = false); | 355 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, LayoutObject* beforeChild, bool fullRemoveInsert = false); |
338 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, bool fullRemoveInsert = false) | 356 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, bool fullRemoveInsert = false) |
339 { | 357 { |
340 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert); | 358 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert); |
341 } | 359 } |
342 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo
veInsert = false) | 360 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo
veInsert = false) |
(...skipping 11 matching lines...) Expand all Loading... |
354 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse
rt); | 372 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse
rt); |
355 } | 373 } |
356 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb
ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe
moveInsert = false); | 374 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb
ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe
moveInsert = false); |
357 | 375 |
358 private: | 376 private: |
359 void createLayer(PaintLayerType); | 377 void createLayer(PaintLayerType); |
360 | 378 |
361 LayoutUnit computedCSSPadding(const Length&) const; | 379 LayoutUnit computedCSSPadding(const Length&) const; |
362 bool isBoxModelObject() const final { return true; } | 380 bool isBoxModelObject() const final { return true; } |
363 | 381 |
| 382 LayoutBoxModelObjectRareData& ensureRareData() |
| 383 { |
| 384 if (!m_rareData) |
| 385 m_rareData = adoptPtr(new LayoutBoxModelObjectRareData()); |
| 386 return *m_rareData.get(); |
| 387 } |
| 388 |
364 // The PaintLayer associated with this object. | 389 // The PaintLayer associated with this object. |
365 // |m_layer| can be nullptr depending on the return value of layerTypeRequir
ed(). | 390 // |m_layer| can be nullptr depending on the return value of layerTypeRequir
ed(). |
366 OwnPtr<PaintLayer> m_layer; | 391 OwnPtr<PaintLayer> m_layer; |
| 392 |
| 393 OwnPtr<LayoutBoxModelObjectRareData> m_rareData; |
367 }; | 394 }; |
368 | 395 |
369 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); | 396 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); |
370 | 397 |
371 } // namespace blink | 398 } // namespace blink |
372 | 399 |
373 #endif // LayoutBoxModelObject_h | 400 #endif // LayoutBoxModelObject_h |
OLD | NEW |