| 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. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // | 74 // |
| 75 // All CSS objects follow the box model object. See THE BOX MODEL section in | 75 // All CSS objects follow the box model object. See THE BOX MODEL section in |
| 76 // LayoutBox for more information. | 76 // LayoutBox for more information. |
| 77 // | 77 // |
| 78 // This class actually doesn't have the box model but it exposes some common | 78 // This class actually doesn't have the box model but it exposes some common |
| 79 // functions or concepts that sub-classes can extend upon. For example, there | 79 // functions or concepts that sub-classes can extend upon. For example, there |
| 80 // are accessors for margins, borders, paddings and borderBoundingBox(). | 80 // are accessors for margins, borders, paddings and borderBoundingBox(). |
| 81 // | 81 // |
| 82 // The reason for this partial implementation is that the 2 classes inheriting | 82 // The reason for this partial implementation is that the 2 classes inheriting |
| 83 // from it (LayoutBox and LayoutInline) have different requirements but need to | 83 // from it (LayoutBox and LayoutInline) have different requirements but need to |
| 84 // have a PaintLayer. | 84 // have a PaintLayer. For a full implementation of the box model, see LayoutBox. |
| 85 // For a full implementation of the box model, see LayoutBox. | |
| 86 // | 85 // |
| 87 // An important member of this class is PaintLayer. This class is | 86 // An important member of this class is PaintLayer, which is stored in a rare- |
| 88 // central to painting and hit-testing (see its class comment). | 87 // data pattern (see: Layer()). PaintLayers are instantiated for several reasons |
| 89 // PaintLayers are instantiated for several reasons based on the | 88 // based on the return value of layerTypeRequired(). |
| 90 // return value of layerTypeRequired(). | |
| 91 // Interestingly, most SVG objects inherit from LayoutSVGModelObject and thus | 89 // Interestingly, most SVG objects inherit from LayoutSVGModelObject and thus |
| 92 // can't have a PaintLayer. This is an unfortunate artifact of our | 90 // can't have a PaintLayer. This is an unfortunate artifact of our |
| 93 // design as it limits code sharing and prevents hardware accelerating SVG | 91 // design as it limits code sharing and prevents hardware accelerating SVG |
| 94 // (the current design require a PaintLayer for compositing). | 92 // (the current design require a PaintLayer for compositing). |
| 95 // | 93 // |
| 96 // | 94 // |
| 97 // ***** COORDINATE SYSTEMS ***** | 95 // ***** COORDINATE SYSTEMS ***** |
| 98 // | 96 // |
| 99 // In order to fully understand LayoutBoxModelObject and the inherited classes, | 97 // In order to fully understand LayoutBoxModelObject and the inherited classes, |
| 100 // we need to introduce the concept of coordinate systems. | 98 // we need to introduce the concept of coordinate systems. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 int PixelSnappedOffsetLeft(const Element* parent) const { | 169 int PixelSnappedOffsetLeft(const Element* parent) const { |
| 172 return RoundToInt(OffsetLeft(parent)); | 170 return RoundToInt(OffsetLeft(parent)); |
| 173 } | 171 } |
| 174 int PixelSnappedOffsetTop(const Element* parent) const { | 172 int PixelSnappedOffsetTop(const Element* parent) const { |
| 175 return RoundToInt(OffsetTop(parent)); | 173 return RoundToInt(OffsetTop(parent)); |
| 176 } | 174 } |
| 177 virtual int PixelSnappedOffsetWidth(const Element*) const; | 175 virtual int PixelSnappedOffsetWidth(const Element*) const; |
| 178 virtual int PixelSnappedOffsetHeight(const Element*) const; | 176 virtual int PixelSnappedOffsetHeight(const Element*) const; |
| 179 | 177 |
| 180 bool HasSelfPaintingLayer() const; | 178 bool HasSelfPaintingLayer() const; |
| 181 PaintLayer* Layer() const { return layer_.get(); } | 179 PaintLayer* Layer() const { |
| 180 return GetRarePaintData() ? GetRarePaintData()->Layer() : nullptr; |
| 181 } |
| 182 // The type of PaintLayer to instantiate. Any value returned from this |
| 183 // function other than NoPaintLayer will lead to a PaintLayer being created. |
| 184 virtual PaintLayerType LayerTypeRequired() const = 0; |
| 182 PaintLayerScrollableArea* GetScrollableArea() const; | 185 PaintLayerScrollableArea* GetScrollableArea() const; |
| 183 | 186 |
| 184 virtual void UpdateFromStyle(); | 187 virtual void UpdateFromStyle(); |
| 185 | 188 |
| 186 // The type of PaintLayer to instantiate. Any value returned from this | |
| 187 // function other than NoPaintLayer will populate |m_layer|. | |
| 188 virtual PaintLayerType LayerTypeRequired() const = 0; | |
| 189 | |
| 190 // This will work on inlines to return the bounding box of all of the lines' | 189 // This will work on inlines to return the bounding box of all of the lines' |
| 191 // border boxes. | 190 // border boxes. |
| 192 virtual IntRect BorderBoundingBox() const = 0; | 191 virtual IntRect BorderBoundingBox() const = 0; |
| 193 | 192 |
| 194 virtual LayoutRect VisualOverflowRect() const = 0; | 193 virtual LayoutRect VisualOverflowRect() const = 0; |
| 195 | 194 |
| 196 // Checks if this box, or any of it's descendants, or any of it's | 195 // Checks if this box, or any of it's descendants, or any of it's |
| 197 // continuations, will take up space in the layout of the page. | 196 // continuations, will take up space in the layout of the page. |
| 198 bool HasNonEmptyLayoutSize() const; | 197 bool HasNonEmptyLayoutSize() const; |
| 199 bool UsesCompositedScrolling() const; | 198 bool UsesCompositedScrolling() const; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 MoveChildrenTo(to_box_model_object, start_child, end_child, 0, | 527 MoveChildrenTo(to_box_model_object, start_child, end_child, 0, |
| 529 full_remove_insert); | 528 full_remove_insert); |
| 530 } | 529 } |
| 531 virtual void MoveChildrenTo(LayoutBoxModelObject* to_box_model_object, | 530 virtual void MoveChildrenTo(LayoutBoxModelObject* to_box_model_object, |
| 532 LayoutObject* start_child, | 531 LayoutObject* start_child, |
| 533 LayoutObject* end_child, | 532 LayoutObject* end_child, |
| 534 LayoutObject* before_child, | 533 LayoutObject* before_child, |
| 535 bool full_remove_insert = false); | 534 bool full_remove_insert = false); |
| 536 | 535 |
| 537 private: | 536 private: |
| 538 void CreateLayer(); | 537 void CreateLayerAfterStyleChange(); |
| 539 | 538 |
| 540 LayoutUnit ComputedCSSPadding(const Length&) const; | 539 LayoutUnit ComputedCSSPadding(const Length&) const; |
| 541 bool IsBoxModelObject() const final { return true; } | 540 bool IsBoxModelObject() const final { return true; } |
| 542 | 541 |
| 543 LayoutBoxModelObjectRareData& EnsureRareData() { | 542 LayoutBoxModelObjectRareData& EnsureRareData() { |
| 544 if (!rare_data_) | 543 if (!rare_data_) |
| 545 rare_data_ = WTF::MakeUnique<LayoutBoxModelObjectRareData>(); | 544 rare_data_ = WTF::MakeUnique<LayoutBoxModelObjectRareData>(); |
| 546 return *rare_data_.get(); | 545 return *rare_data_.get(); |
| 547 } | 546 } |
| 548 | 547 |
| 549 // The PaintLayer associated with this object. |m_layer| can be nullptr | |
| 550 // depending on the return value of layerTypeRequired(). | |
| 551 std::unique_ptr<PaintLayer> layer_; | |
| 552 | |
| 553 std::unique_ptr<LayoutBoxModelObjectRareData> rare_data_; | 548 std::unique_ptr<LayoutBoxModelObjectRareData> rare_data_; |
| 554 }; | 549 }; |
| 555 | 550 |
| 556 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, IsBoxModelObject()); | 551 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, IsBoxModelObject()); |
| 557 | 552 |
| 558 } // namespace blink | 553 } // namespace blink |
| 559 | 554 |
| 560 #endif // LayoutBoxModelObject_h | 555 #endif // LayoutBoxModelObject_h |
| OLD | NEW |