1 // Copyright 2015 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_API_LINE_LAYOUT_BOX_MODEL_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_API_LINE_LAYOUT_BOX_MODEL_H_ 7 8 #include "third_party/blink/renderer/core/layout/api/line_layout_item.h" 9 #include "third_party/blink/renderer/core/layout/layout_box_model_object.h" 10 #include "third_party/blink/renderer/platform/geometry/layout_unit.h" 11 12 namespace blink { 13 14 class LayoutBoxModelObject; 15 16 class LineLayoutBoxModel : public LineLayoutItem { 17 public: LineLayoutBoxModel(LayoutBoxModelObject * layout_box)18 explicit LineLayoutBoxModel(LayoutBoxModelObject* layout_box) 19 : LineLayoutItem(layout_box) {} 20 LineLayoutBoxModel(const LineLayoutItem & item)21 explicit LineLayoutBoxModel(const LineLayoutItem& item) 22 : LineLayoutItem(item) { 23 SECURITY_DCHECK(!item || item.IsBoxModelObject()); 24 } 25 LineLayoutBoxModel(std::nullptr_t)26 explicit LineLayoutBoxModel(std::nullptr_t) : LineLayoutItem(nullptr) {} 27 28 LineLayoutBoxModel() = default; 29 30 // TODO(dgrogan) Remove. Implement API methods that proxy to the PaintLayer. Layer()31 PaintLayer* Layer() const { return ToBoxModel()->Layer(); } 32 33 LayoutUnit LineHeight( 34 bool first_line, 35 LineDirectionMode line_direction_mode, 36 LinePositionMode line_position_mode = kPositionOnContainingLine) const { 37 return ToBoxModel()->LineHeight(first_line, line_direction_mode, 38 line_position_mode); 39 } 40 41 LayoutUnit BaselinePosition( 42 FontBaseline font_baseline, 43 bool first_line, 44 LineDirectionMode line_direction_mode, 45 LinePositionMode line_position_mode = kPositionOnContainingLine) const { 46 return ToBoxModel()->BaselinePosition( 47 font_baseline, first_line, line_direction_mode, line_position_mode); 48 } 49 HasSelfPaintingLayer()50 bool HasSelfPaintingLayer() const { 51 return ToBoxModel()->HasSelfPaintingLayer(); 52 } 53 MarginTop()54 LayoutUnit MarginTop() const { return ToBoxModel()->MarginTop(); } 55 MarginBottom()56 LayoutUnit MarginBottom() const { return ToBoxModel()->MarginBottom(); } 57 MarginLeft()58 LayoutUnit MarginLeft() const { return ToBoxModel()->MarginLeft(); } 59 MarginRight()60 LayoutUnit MarginRight() const { return ToBoxModel()->MarginRight(); } 61 62 LayoutUnit MarginBefore(const ComputedStyle* other_style = nullptr) const { 63 return ToBoxModel()->MarginBefore(other_style); 64 } 65 66 LayoutUnit MarginAfter(const ComputedStyle* other_style = nullptr) const { 67 return ToBoxModel()->MarginAfter(other_style); 68 } 69 MarginOver()70 LayoutUnit MarginOver() const { return ToBoxModel()->MarginOver(); } 71 MarginUnder()72 LayoutUnit MarginUnder() const { return ToBoxModel()->MarginUnder(); } 73 PaddingTop()74 LayoutUnit PaddingTop() const { return ToBoxModel()->PaddingTop(); } 75 PaddingBottom()76 LayoutUnit PaddingBottom() const { return ToBoxModel()->PaddingBottom(); } 77 PaddingLeft()78 LayoutUnit PaddingLeft() const { return ToBoxModel()->PaddingLeft(); } 79 PaddingRight()80 LayoutUnit PaddingRight() const { return ToBoxModel()->PaddingRight(); } 81 PaddingBefore()82 LayoutUnit PaddingBefore() const { return ToBoxModel()->PaddingBefore(); } 83 PaddingAfter()84 LayoutUnit PaddingAfter() const { return ToBoxModel()->PaddingAfter(); } 85 BorderTop()86 LayoutUnit BorderTop() const { return ToBoxModel()->BorderTop(); } 87 BorderBottom()88 LayoutUnit BorderBottom() const { return ToBoxModel()->BorderBottom(); } 89 BorderLeft()90 LayoutUnit BorderLeft() const { return ToBoxModel()->BorderLeft(); } 91 BorderRight()92 LayoutUnit BorderRight() const { return ToBoxModel()->BorderRight(); } 93 BorderBefore()94 LayoutUnit BorderBefore() const { return ToBoxModel()->BorderBefore(); } 95 BorderAfter()96 LayoutUnit BorderAfter() const { return ToBoxModel()->BorderAfter(); } 97 RelativePositionLogicalOffset()98 LayoutSize RelativePositionLogicalOffset() const { 99 return ToBoxModel()->RelativePositionLogicalOffset(); 100 } 101 HasInlineDirectionBordersOrPadding()102 bool HasInlineDirectionBordersOrPadding() const { 103 return ToBoxModel()->HasInlineDirectionBordersOrPadding(); 104 } 105 BorderAndPaddingOver()106 LayoutUnit BorderAndPaddingOver() const { 107 return ToBoxModel()->BorderAndPaddingOver(); 108 } 109 BorderAndPaddingUnder()110 LayoutUnit BorderAndPaddingUnder() const { 111 return ToBoxModel()->BorderAndPaddingUnder(); 112 } 113 BorderAndPaddingLogicalHeight()114 LayoutUnit BorderAndPaddingLogicalHeight() const { 115 return ToBoxModel()->BorderAndPaddingLogicalHeight(); 116 } 117 OffsetForInFlowPosition()118 PhysicalOffset OffsetForInFlowPosition() const { 119 return ToBoxModel()->OffsetForInFlowPosition(); 120 } 121 122 private: ToBoxModel()123 LayoutBoxModelObject* ToBoxModel() { 124 return ToLayoutBoxModelObject(GetLayoutObject()); 125 } ToBoxModel()126 const LayoutBoxModelObject* ToBoxModel() const { 127 return ToLayoutBoxModelObject(GetLayoutObject()); 128 } 129 }; 130 131 } // namespace blink 132 133 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_API_LINE_LAYOUT_BOX_MODEL_H_ 134