| 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" | |
| 30 #include "core/style/ShadowData.h" | 29 #include "core/style/ShadowData.h" |
| 31 #include "platform/geometry/LayoutRect.h" | 30 #include "platform/geometry/LayoutRect.h" |
| 32 | 31 |
| 33 namespace blink { | 32 namespace blink { |
| 34 | 33 |
| 35 class LineLayoutBoxModel; | 34 class LineLayoutBoxModel; |
| 36 class PaintLayer; | 35 class PaintLayer; |
| 37 class PaintLayerScrollableArea; | 36 class PaintLayerScrollableArea; |
| 38 | 37 |
| 39 enum PaintLayerType { | 38 enum PaintLayerType { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 enum ContentChangeType { | 59 enum ContentChangeType { |
| 61 ImageChanged, | 60 ImageChanged, |
| 62 CanvasChanged, | 61 CanvasChanged, |
| 63 CanvasContextChanged | 62 CanvasContextChanged |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 class InlineFlowBox; | 65 class InlineFlowBox; |
| 67 | 66 |
| 68 struct LayoutBoxModelObjectRareData { | |
| 69 WTF_MAKE_NONCOPYABLE(LayoutBoxModelObjectRareData); | |
| 70 USING_FAST_MALLOC(LayoutBoxModelObjectRareData); | |
| 71 public: | |
| 72 LayoutBoxModelObjectRareData() {} | |
| 73 | |
| 74 StickyPositionScrollingConstraints m_stickyPositionScrollingConstraints; | |
| 75 }; | |
| 76 | |
| 77 // This class is the base class for all CSS objects. | 67 // This class is the base class for all CSS objects. |
| 78 // | 68 // |
| 79 // All CSS objects follow the box model object. See THE BOX MODEL section in | 69 // All CSS objects follow the box model object. See THE BOX MODEL section in |
| 80 // LayoutBox for more information. | 70 // LayoutBox for more information. |
| 81 // | 71 // |
| 82 // This class actually doesn't have the box model but it exposes some common | 72 // This class actually doesn't have the box model but it exposes some common |
| 83 // functions or concepts that sub-classes can extend upon. For example, there | 73 // functions or concepts that sub-classes can extend upon. For example, there |
| 84 // are accessors for margins, borders, paddings and borderBoundingBox(). | 74 // are accessors for margins, borders, paddings and borderBoundingBox(). |
| 85 // | 75 // |
| 86 // The reason for this partial implementation is that the 2 classes inheriting | 76 // 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... |
| 144 public: | 134 public: |
| 145 LayoutBoxModelObject(ContainerNode*); | 135 LayoutBoxModelObject(ContainerNode*); |
| 146 ~LayoutBoxModelObject() override; | 136 ~LayoutBoxModelObject() override; |
| 147 | 137 |
| 148 // This is the only way layers should ever be destroyed. | 138 // This is the only way layers should ever be destroyed. |
| 149 void destroyLayer(); | 139 void destroyLayer(); |
| 150 | 140 |
| 151 LayoutSize relativePositionOffset() const; | 141 LayoutSize relativePositionOffset() const; |
| 152 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon
talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose
dSize(); } | 142 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon
talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose
dSize(); } |
| 153 | 143 |
| 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 | |
| 160 LayoutSize offsetForInFlowPosition() const; | 144 LayoutSize offsetForInFlowPosition() const; |
| 161 | 145 |
| 162 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin
es (LayoutFlow) | 146 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin
es (LayoutFlow) |
| 163 // to return the remaining width on a given line (and the height of a single
line). | 147 // to return the remaining width on a given line (and the height of a single
line). |
| 164 virtual LayoutUnit offsetLeft() const; | 148 virtual LayoutUnit offsetLeft() const; |
| 165 virtual LayoutUnit offsetTop() const; | 149 virtual LayoutUnit offsetTop() const; |
| 166 virtual LayoutUnit offsetWidth() const = 0; | 150 virtual LayoutUnit offsetWidth() const = 0; |
| 167 virtual LayoutUnit offsetHeight() const = 0; | 151 virtual LayoutUnit offsetHeight() const = 0; |
| 168 | 152 |
| 169 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } | 153 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 LayoutBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con
st; | 321 LayoutBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con
st; |
| 338 | 322 |
| 339 void addOutlineRectsForNormalChildren(Vector<LayoutRect>&, const LayoutPoint
& additionalOffset, IncludeBlockVisualOverflowOrNot) const; | 323 void addOutlineRectsForNormalChildren(Vector<LayoutRect>&, const LayoutPoint
& additionalOffset, IncludeBlockVisualOverflowOrNot) const; |
| 340 void addOutlineRectsForDescendant(const LayoutObject& descendant, Vector<Lay
outRect>&, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot)
const; | 324 void addOutlineRectsForDescendant(const LayoutObject& descendant, Vector<Lay
outRect>&, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot)
const; |
| 341 | 325 |
| 342 void addLayerHitTestRects(LayerHitTestRects&, const PaintLayer*, const Layou
tPoint&, const LayoutRect&) const override; | 326 void addLayerHitTestRects(LayerHitTestRects&, const PaintLayer*, const Layou
tPoint&, const LayoutRect&) const override; |
| 343 | 327 |
| 344 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid
e; | 328 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid
e; |
| 345 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; | 329 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; |
| 346 | 330 |
| 347 void invalidateStickyConstraints(); | |
| 348 | |
| 349 public: | 331 public: |
| 350 // These functions are only used internally to manipulate the layout tree st
ructure via remove/insert/appendChildNode. | 332 // These functions are only used internally to manipulate the layout tree st
ructure via remove/insert/appendChildNode. |
| 351 // Since they are typically called only to move objects around within anonym
ous blocks (which only have layers in | 333 // Since they are typically called only to move objects around within anonym
ous blocks (which only have layers in |
| 352 // the case of column spans), the default for fullRemoveInsert is false rath
er than true. | 334 // the case of column spans), the default for fullRemoveInsert is false rath
er than true. |
| 353 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, LayoutObject* beforeChild, bool fullRemoveInsert = false); | 335 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, LayoutObject* beforeChild, bool fullRemoveInsert = false); |
| 354 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, bool fullRemoveInsert = false) | 336 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, bool fullRemoveInsert = false) |
| 355 { | 337 { |
| 356 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert); | 338 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert); |
| 357 } | 339 } |
| 358 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo
veInsert = false) | 340 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo
veInsert = false) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 370 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse
rt); | 352 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse
rt); |
| 371 } | 353 } |
| 372 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb
ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe
moveInsert = false); | 354 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb
ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe
moveInsert = false); |
| 373 | 355 |
| 374 private: | 356 private: |
| 375 void createLayer(PaintLayerType); | 357 void createLayer(PaintLayerType); |
| 376 | 358 |
| 377 LayoutUnit computedCSSPadding(const Length&) const; | 359 LayoutUnit computedCSSPadding(const Length&) const; |
| 378 bool isBoxModelObject() const final { return true; } | 360 bool isBoxModelObject() const final { return true; } |
| 379 | 361 |
| 380 LayoutBoxModelObjectRareData& ensureRareData() | |
| 381 { | |
| 382 if (!m_rareData) | |
| 383 m_rareData = adoptPtr(new LayoutBoxModelObjectRareData()); | |
| 384 return *m_rareData.get(); | |
| 385 } | |
| 386 | |
| 387 // The PaintLayer associated with this object. | 362 // The PaintLayer associated with this object. |
| 388 // |m_layer| can be nullptr depending on the return value of layerTypeRequir
ed(). | 363 // |m_layer| can be nullptr depending on the return value of layerTypeRequir
ed(). |
| 389 OwnPtr<PaintLayer> m_layer; | 364 OwnPtr<PaintLayer> m_layer; |
| 390 | |
| 391 OwnPtr<LayoutBoxModelObjectRareData> m_rareData; | |
| 392 }; | 365 }; |
| 393 | 366 |
| 394 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); | 367 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); |
| 395 | 368 |
| 396 } // namespace blink | 369 } // namespace blink |
| 397 | 370 |
| 398 #endif // LayoutBoxModelObject_h | 371 #endif // LayoutBoxModelObject_h |
| OLD | NEW |