Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2018)

Side by Side Diff: Source/core/rendering/RenderBox.h

Issue 620753006: Rendering API cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address jchaffraix remarks Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 RenderBox* lastChildBox() const; 90 RenderBox* lastChildBox() const;
91 91
92 LayoutUnit x() const { return m_frameRect.x(); } 92 LayoutUnit x() const { return m_frameRect.x(); }
93 LayoutUnit y() const { return m_frameRect.y(); } 93 LayoutUnit y() const { return m_frameRect.y(); }
94 LayoutUnit width() const { return m_frameRect.width(); } 94 LayoutUnit width() const { return m_frameRect.width(); }
95 LayoutUnit height() const { return m_frameRect.height(); } 95 LayoutUnit height() const { return m_frameRect.height(); }
96 96
97 int pixelSnappedWidth() const { return m_frameRect.pixelSnappedWidth(); } 97 int pixelSnappedWidth() const { return m_frameRect.pixelSnappedWidth(); }
98 int pixelSnappedHeight() const { return m_frameRect.pixelSnappedHeight(); } 98 int pixelSnappedHeight() const { return m_frameRect.pixelSnappedHeight(); }
99 99
100 // These represent your location relative to your container as a physical of fset.
101 // In layout related methods you almost always want the logical location (e. g. x() and y()).
102 LayoutUnit top() const { return topLeftLocation().y(); }
103 LayoutUnit left() const { return topLeftLocation().x(); }
104
105 void setX(LayoutUnit x) { m_frameRect.setX(x); } 100 void setX(LayoutUnit x) { m_frameRect.setX(x); }
106 void setY(LayoutUnit y) { m_frameRect.setY(y); } 101 void setY(LayoutUnit y) { m_frameRect.setY(y); }
107 void setWidth(LayoutUnit width) { m_frameRect.setWidth(width); } 102 void setWidth(LayoutUnit width) { m_frameRect.setWidth(width); }
108 void setHeight(LayoutUnit height) { m_frameRect.setHeight(height); } 103 void setHeight(LayoutUnit height) { m_frameRect.setHeight(height); }
109 104
110 LayoutUnit logicalLeft() const { return style()->isHorizontalWritingMode() ? x() : y(); } 105 LayoutUnit logicalLeft() const { return style()->isHorizontalWritingMode() ? x() : y(); }
111 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } 106 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); }
112 LayoutUnit logicalTop() const { return style()->isHorizontalWritingMode() ? y() : x(); } 107 LayoutUnit logicalTop() const { return style()->isHorizontalWritingMode() ? y() : x(); }
113 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } 108 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); }
114 LayoutUnit logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); } 109 LayoutUnit logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); }
115 LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); } 110 LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
116 111
117 LayoutUnit constrainLogicalWidthByMinMax(LayoutUnit, LayoutUnit, RenderBlock *) const; 112 LayoutUnit constrainLogicalWidthByMinMax(LayoutUnit, LayoutUnit, RenderBlock *) const;
118 LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, LayoutUn it intrinsicContentHeight) const; 113 LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, LayoutUn it intrinsicContentHeight) const;
119 LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight , LayoutUnit intrinsicContentHeight) const; 114 LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight , LayoutUnit intrinsicContentHeight) const;
120 115
121 int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingM ode() ? pixelSnappedHeight() : pixelSnappedWidth(); } 116 int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingM ode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
122 int pixelSnappedLogicalWidth() const { return style()->isHorizontalWritingMo de() ? pixelSnappedWidth() : pixelSnappedHeight(); }
Julien - ping for review 2014/10/03 01:26:42 Let's keep this one for consistency.
123 117
124 void setLogicalLeft(LayoutUnit left) 118 void setLogicalLeft(LayoutUnit left)
125 { 119 {
126 if (style()->isHorizontalWritingMode()) 120 if (style()->isHorizontalWritingMode())
127 setX(left); 121 setX(left);
128 else 122 else
129 setY(left); 123 setY(left);
130 } 124 }
131 void setLogicalTop(LayoutUnit top) 125 void setLogicalTop(LayoutUnit top)
132 { 126 {
(...skipping 16 matching lines...) Expand all
149 else 143 else
150 setHeight(size); 144 setHeight(size);
151 } 145 }
152 void setLogicalHeight(LayoutUnit size) 146 void setLogicalHeight(LayoutUnit size)
153 { 147 {
154 if (style()->isHorizontalWritingMode()) 148 if (style()->isHorizontalWritingMode())
155 setHeight(size); 149 setHeight(size);
156 else 150 else
157 setWidth(size); 151 setWidth(size);
158 } 152 }
159 void setLogicalSize(const LayoutSize& size)
160 {
161 if (style()->isHorizontalWritingMode())
162 setSize(size);
163 else
164 setSize(size.transposedSize());
165 }
166 153
167 LayoutPoint location() const { return m_frameRect.location(); } 154 LayoutPoint location() const { return m_frameRect.location(); }
168 LayoutSize locationOffset() const { return LayoutSize(x(), y()); } 155 LayoutSize locationOffset() const { return LayoutSize(x(), y()); }
169 LayoutSize size() const { return m_frameRect.size(); } 156 LayoutSize size() const { return m_frameRect.size(); }
170 IntSize pixelSnappedSize() const { return m_frameRect.pixelSnappedSize(); } 157 IntSize pixelSnappedSize() const { return m_frameRect.pixelSnappedSize(); }
171 158
172 void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(loca tion); } 159 void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(loca tion); }
173 160
174 void setSize(const LayoutSize& size) { m_frameRect.setSize(size); } 161 void setSize(const LayoutSize& size) { m_frameRect.setSize(size); }
175 void move(LayoutUnit dx, LayoutUnit dy) { m_frameRect.move(dx, dy); } 162 void move(LayoutUnit dx, LayoutUnit dy) { m_frameRect.move(dx, dy); }
176 163
177 LayoutRect frameRect() const { return m_frameRect; } 164 LayoutRect frameRect() const { return m_frameRect; }
178 IntRect pixelSnappedFrameRect() const { return pixelSnappedIntRect(m_frameRe ct); }
179 void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; } 165 void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; }
180 166
181 LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); } 167 LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); }
182 LayoutRect paddingBoxRect() const { return LayoutRect(borderLeft(), borderTo p(), contentWidth() + paddingLeft() + paddingRight(), contentHeight() + paddingT op() + paddingBottom()); } 168 LayoutRect paddingBoxRect() const { return LayoutRect(borderLeft(), borderTo p(), contentWidth() + paddingLeft() + paddingRight(), contentHeight() + paddingT op() + paddingBottom()); }
183 IntRect pixelSnappedBorderBoxRect() const { return IntRect(IntPoint(), m_fra meRect.pixelSnappedSize()); } 169 IntRect pixelSnappedBorderBoxRect() const { return IntRect(IntPoint(), m_fra meRect.pixelSnappedSize()); }
184 virtual IntRect borderBoundingBox() const OVERRIDE FINAL { return pixelSnapp edBorderBoxRect(); } 170 virtual IntRect borderBoundingBox() const OVERRIDE FINAL { return pixelSnapp edBorderBoxRect(); }
185 171
186 // The content area of the box (excludes padding - and intrinsic padding for table cells, etc... - and border). 172 // The content area of the box (excludes padding - and intrinsic padding for table cells, etc... - and border).
187 LayoutRect contentBoxRect() const { return LayoutRect(borderLeft() + padding Left(), borderTop() + paddingTop(), contentWidth(), contentHeight()); } 173 LayoutRect contentBoxRect() const { return LayoutRect(borderLeft() + padding Left(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
188 // The content box in absolute coords. Ignores transforms. 174 // The content box in absolute coords. Ignores transforms.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 virtual LayoutUnit marginTop() const OVERRIDE { return m_marginBox.top(); } 269 virtual LayoutUnit marginTop() const OVERRIDE { return m_marginBox.top(); }
284 virtual LayoutUnit marginBottom() const OVERRIDE { return m_marginBox.bottom (); } 270 virtual LayoutUnit marginBottom() const OVERRIDE { return m_marginBox.bottom (); }
285 virtual LayoutUnit marginLeft() const OVERRIDE { return m_marginBox.left(); } 271 virtual LayoutUnit marginLeft() const OVERRIDE { return m_marginBox.left(); }
286 virtual LayoutUnit marginRight() const OVERRIDE { return m_marginBox.right() ; } 272 virtual LayoutUnit marginRight() const OVERRIDE { return m_marginBox.right() ; }
287 void setMarginTop(LayoutUnit margin) { m_marginBox.setTop(margin); } 273 void setMarginTop(LayoutUnit margin) { m_marginBox.setTop(margin); }
288 void setMarginBottom(LayoutUnit margin) { m_marginBox.setBottom(margin); } 274 void setMarginBottom(LayoutUnit margin) { m_marginBox.setBottom(margin); }
289 void setMarginLeft(LayoutUnit margin) { m_marginBox.setLeft(margin); } 275 void setMarginLeft(LayoutUnit margin) { m_marginBox.setLeft(margin); }
290 void setMarginRight(LayoutUnit margin) { m_marginBox.setRight(margin); } 276 void setMarginRight(LayoutUnit margin) { m_marginBox.setRight(margin); }
291 277
292 LayoutUnit marginLogicalLeft() const { return m_marginBox.logicalLeft(style( )->writingMode()); } 278 LayoutUnit marginLogicalLeft() const { return m_marginBox.logicalLeft(style( )->writingMode()); }
293 LayoutUnit marginLogicalRight() const { return m_marginBox.logicalRight(styl e()->writingMode()); }
Julien - ping for review 2014/10/03 01:26:42 Ditto.
294 279
295 virtual LayoutUnit marginBefore(const RenderStyle* overrideStyle = 0) const OVERRIDE FINAL { return m_marginBox.before((overrideStyle ? overrideStyle : styl e())->writingMode()); } 280 virtual LayoutUnit marginBefore(const RenderStyle* overrideStyle = 0) const OVERRIDE FINAL { return m_marginBox.before((overrideStyle ? overrideStyle : styl e())->writingMode()); }
296 virtual LayoutUnit marginAfter(const RenderStyle* overrideStyle = 0) const O VERRIDE FINAL { return m_marginBox.after((overrideStyle ? overrideStyle : style( ))->writingMode()); } 281 virtual LayoutUnit marginAfter(const RenderStyle* overrideStyle = 0) const O VERRIDE FINAL { return m_marginBox.after((overrideStyle ? overrideStyle : style( ))->writingMode()); }
297 virtual LayoutUnit marginStart(const RenderStyle* overrideStyle = 0) const O VERRIDE FINAL 282 virtual LayoutUnit marginStart(const RenderStyle* overrideStyle = 0) const O VERRIDE FINAL
298 { 283 {
299 const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style(); 284 const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
300 return m_marginBox.start(styleToUse->writingMode(), styleToUse->directio n()); 285 return m_marginBox.start(styleToUse->writingMode(), styleToUse->directio n());
301 } 286 }
302 virtual LayoutUnit marginEnd(const RenderStyle* overrideStyle = 0) const OVE RRIDE FINAL 287 virtual LayoutUnit marginEnd(const RenderStyle* overrideStyle = 0) const OVE RRIDE FINAL
303 { 288 {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 LayoutUnit availableHeight() const { return style()->isHorizontalWritingMode () ? availableLogicalHeight(IncludeMarginBorderPadding) : availableLogicalWidth( ); } 451 LayoutUnit availableHeight() const { return style()->isHorizontalWritingMode () ? availableLogicalHeight(IncludeMarginBorderPadding) : availableLogicalWidth( ); }
467 452
468 virtual int verticalScrollbarWidth() const; 453 virtual int verticalScrollbarWidth() const;
469 int horizontalScrollbarHeight() const; 454 int horizontalScrollbarHeight() const;
470 int instrinsicScrollbarLogicalWidth() const; 455 int instrinsicScrollbarLogicalWidth() const;
471 int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode () ? horizontalScrollbarHeight() : verticalScrollbarWidth(); } 456 int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode () ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
472 virtual bool scroll(ScrollDirection, ScrollGranularity, float delta = 1); 457 virtual bool scroll(ScrollDirection, ScrollGranularity, float delta = 1);
473 bool canBeScrolledAndHasScrollableArea() const; 458 bool canBeScrolledAndHasScrollableArea() const;
474 virtual bool canBeProgramaticallyScrolled() const; 459 virtual bool canBeProgramaticallyScrolled() const;
475 virtual void autoscroll(const IntPoint&); 460 virtual void autoscroll(const IntPoint&);
476 bool autoscrollInProgress() const;
477 bool canAutoscroll() const; 461 bool canAutoscroll() const;
478 IntSize calculateAutoscrollDirection(const IntPoint& windowPoint) const; 462 IntSize calculateAutoscrollDirection(const IntPoint& windowPoint) const;
479 static RenderBox* findAutoscrollable(RenderObject*); 463 static RenderBox* findAutoscrollable(RenderObject*);
480 virtual void stopAutoscroll() { } 464 virtual void stopAutoscroll() { }
481 virtual void panScroll(const IntPoint&); 465 virtual void panScroll(const IntPoint&);
482 466
483 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style() ->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); } 467 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style() ->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); }
484 bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style ()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); } 468 bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style ()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); }
485 bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY (); } 469 bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY (); }
486 470
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 if (UNLIKELY(inlineBoxWrapper() != 0)) 765 if (UNLIKELY(inlineBoxWrapper() != 0))
782 deleteLineBoxWrapper(); 766 deleteLineBoxWrapper();
783 } 767 }
784 768
785 ensureRareData().m_inlineBoxWrapper = boxWrapper; 769 ensureRareData().m_inlineBoxWrapper = boxWrapper;
786 } 770 }
787 771
788 } // namespace blink 772 } // namespace blink
789 773
790 #endif // RenderBox_h 774 #endif // RenderBox_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698