| 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 PaintLayer* ancestorOverflowLa
yer) const; |
| 157 void updateStickyPositionConstraints(PaintLayer* ancestorOverflowLayer) cons
t; |
| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 291 |
| 276 void contentChanged(ContentChangeType); | 292 void contentChanged(ContentChangeType); |
| 277 bool hasAcceleratedCompositing() const; | 293 bool hasAcceleratedCompositing() const; |
| 278 | 294 |
| 279 void computeLayerHitTestRects(LayerHitTestRects&) const override; | 295 void computeLayerHitTestRects(LayerHitTestRects&) const override; |
| 280 | 296 |
| 281 // Returns true if the background is painted opaque in the given rect. | 297 // Returns true if the background is painted opaque in the given rect. |
| 282 // The query rect is given in local coordinate system. | 298 // The query rect is given in local coordinate system. |
| 283 virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { re
turn false; } | 299 virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { re
turn false; } |
| 284 | 300 |
| 301 void invalidateScrollAncestorConstraints(); |
| 302 |
| 285 void invalidateTreeIfNeeded(PaintInvalidationState&) override; | 303 void invalidateTreeIfNeeded(PaintInvalidationState&) override; |
| 286 | 304 |
| 287 // Indicate that the contents of this layoutObject need to be repainted. Onl
y has an effect if compositing is being used, | 305 // Indicate that the contents of this layoutObject need to be repainted. Onl
y has an effect if compositing is being used, |
| 288 void setBackingNeedsPaintInvalidationInRect(const LayoutRect&, PaintInvalida
tionReason) const; // r is in the coordinate space of this layout object | 306 void setBackingNeedsPaintInvalidationInRect(const LayoutRect&, PaintInvalida
tionReason) const; // r is in the coordinate space of this layout object |
| 289 | 307 |
| 290 void invalidateDisplayItemClientOnBacking(const DisplayItemClient&, PaintInv
alidationReason) const; | 308 void invalidateDisplayItemClientOnBacking(const DisplayItemClient&, PaintInv
alidationReason) const; |
| 291 | 309 |
| 292 // http://www.w3.org/TR/css3-background/#body-background | 310 // http://www.w3.org/TR/css3-background/#body-background |
| 293 // <html> root element with no background steals background from its first <
body> child. | 311 // <html> root element with no background steals background from its first <
body> child. |
| 294 // The used background for such body element should be the initial value. (i
.e. transparent) | 312 // The used background for such body element should be the initial value. (i
.e. transparent) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 374 |
| 357 enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffective
Zoom }; | 375 enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffective
Zoom }; |
| 358 LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize&
scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const; | 376 LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize&
scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const; |
| 359 | 377 |
| 360 private: | 378 private: |
| 361 void createLayer(PaintLayerType); | 379 void createLayer(PaintLayerType); |
| 362 | 380 |
| 363 LayoutUnit computedCSSPadding(const Length&) const; | 381 LayoutUnit computedCSSPadding(const Length&) const; |
| 364 bool isBoxModelObject() const final { return true; } | 382 bool isBoxModelObject() const final { return true; } |
| 365 | 383 |
| 384 LayoutBoxModelObjectRareData& ensureRareData() |
| 385 { |
| 386 if (!m_rareData) |
| 387 m_rareData = adoptPtr(new LayoutBoxModelObjectRareData()); |
| 388 return *m_rareData.get(); |
| 389 } |
| 390 |
| 366 // The PaintLayer associated with this object. | 391 // The PaintLayer associated with this object. |
| 367 // |m_layer| can be nullptr depending on the return value of layerTypeRequir
ed(). | 392 // |m_layer| can be nullptr depending on the return value of layerTypeRequir
ed(). |
| 368 OwnPtr<PaintLayer> m_layer; | 393 OwnPtr<PaintLayer> m_layer; |
| 394 |
| 395 OwnPtr<LayoutBoxModelObjectRareData> m_rareData; |
| 369 }; | 396 }; |
| 370 | 397 |
| 371 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); | 398 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); |
| 372 | 399 |
| 373 } // namespace blink | 400 } // namespace blink |
| 374 | 401 |
| 375 #endif // LayoutBoxModelObject_h | 402 #endif // LayoutBoxModelObject_h |
| OLD | NEW |