Changeset 89977 in webkit


Ignore:
Timestamp:
Jun 28, 2011 4:56:01 PM (13 years ago)
Author:
eae@chromium.org
Message:

2011-06-28 Emil A Eklund <eae@chromium.org>

Reviewed by Eric Seidel.

Switch RenderBox position/size to to new layout types
https://bugs.webkit.org/show_bug.cgi?id=63571

Switch location and size methods for RenderBox over to the new layout unit abstraction.

No new tests, no functionality changes.

  • rendering/RenderBox.cpp:
  • rendering/RenderBox.h:
  • rendering/RenderBoxModelObject.cpp:
  • rendering/RenderBoxModelObject.h:
  • rendering/RenderInline.cpp:
  • rendering/RenderInline.h:
  • rendering/RenderVideo.cpp:
  • rendering/RenderVideo.h:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89975 r89977  
     12011-06-28  Emil A Eklund  <eae@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Switch RenderBox position/size to to new layout types
     6        https://bugs.webkit.org/show_bug.cgi?id=63571
     7
     8        Switch location and size methods for RenderBox over to the new layout unit abstraction.
     9
     10        No new tests, no functionality changes.
     11
     12        * rendering/RenderBox.cpp:
     13        * rendering/RenderBox.h:
     14        * rendering/RenderBoxModelObject.cpp:
     15        * rendering/RenderBoxModelObject.h:
     16        * rendering/RenderInline.cpp:
     17        * rendering/RenderInline.h:
     18        * rendering/RenderVideo.cpp:
     19        * rendering/RenderVideo.h:
     20
    1212011-06-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    222
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r89974 r89977  
    404404// More IE extensions.  clientWidth and clientHeight represent the interior of an object
    405405// excluding border and scrollbar.
    406 int RenderBox::clientWidth() const
     406LayoutUnit RenderBox::clientWidth() const
    407407{
    408408    return width() - borderLeft() - borderRight() - verticalScrollbarWidth();
    409409}
    410410
    411 int RenderBox::clientHeight() const
     411LayoutUnit RenderBox::clientHeight() const
    412412{
    413413    return height() - borderTop() - borderBottom() - horizontalScrollbarHeight();
     
    715715}
    716716
    717 int RenderBox::computeBorderBoxLogicalWidth(int width) const
    718 {
    719     int bordersPlusPadding = borderAndPaddingLogicalWidth();
     717LayoutUnit RenderBox::computeBorderBoxLogicalWidth(LayoutUnit width) const
     718{
     719    LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth();
    720720    if (style()->boxSizing() == CONTENT_BOX)
    721721        return width + bordersPlusPadding;
     
    723723}
    724724
    725 int RenderBox::computeBorderBoxLogicalHeight(int height) const
    726 {
    727     int bordersPlusPadding = borderAndPaddingLogicalHeight();
     725LayoutUnit RenderBox::computeBorderBoxLogicalHeight(LayoutUnit height) const
     726{
     727    LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight();
    728728    if (style()->boxSizing() == CONTENT_BOX)
    729729        return height + bordersPlusPadding;
     
    731731}
    732732
    733 int RenderBox::computeContentBoxLogicalWidth(int width) const
     733LayoutUnit RenderBox::computeContentBoxLogicalWidth(LayoutUnit width) const
    734734{
    735735    if (style()->boxSizing() == BORDER_BOX)
     
    738738}
    739739
    740 int RenderBox::computeContentBoxLogicalHeight(int height) const
     740LayoutUnit RenderBox::computeContentBoxLogicalHeight(LayoutUnit height) const
    741741{
    742742    if (style()->boxSizing() == BORDER_BOX)
  • trunk/Source/WebCore/rendering/RenderBox.h

    r89974 r89977  
    4545    RenderBox* lastChildBox() const;
    4646
    47     int x() const { return m_frameRect.x(); }
    48     int y() const { return m_frameRect.y(); }
    49     int width() const { return m_frameRect.width(); }
    50     int height() const { return m_frameRect.height(); }
    51 
    52     void setX(int x) { m_frameRect.setX(x); }
    53     void setY(int y) { m_frameRect.setY(y); }
    54     void setWidth(int width) { m_frameRect.setWidth(width); }
    55     void setHeight(int height) { m_frameRect.setHeight(height); }
    56 
    57     int logicalLeft() const { return style()->isHorizontalWritingMode() ? x() : y(); }
    58     int logicalRight() const { return logicalLeft() + logicalWidth(); }
    59     int logicalTop() const { return style()->isHorizontalWritingMode() ? y() : x(); }
    60     int logicalBottom() const { return logicalTop() + logicalHeight(); }
    61     int logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); }
    62     int logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
    63 
    64     void setLogicalLeft(int left)
     47    LayoutUnit x() const { return m_frameRect.x(); }
     48    LayoutUnit y() const { return m_frameRect.y(); }
     49    LayoutUnit width() const { return m_frameRect.width(); }
     50    LayoutUnit height() const { return m_frameRect.height(); }
     51
     52    void setX(LayoutUnit x) { m_frameRect.setX(x); }
     53    void setY(LayoutUnit y) { m_frameRect.setY(y); }
     54    void setWidth(LayoutUnit width) { m_frameRect.setWidth(width); }
     55    void setHeight(LayoutUnit height) { m_frameRect.setHeight(height); }
     56
     57    LayoutUnit logicalLeft() const { return style()->isHorizontalWritingMode() ? x() : y(); }
     58    LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); }
     59    LayoutUnit logicalTop() const { return style()->isHorizontalWritingMode() ? y() : x(); }
     60    LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); }
     61    LayoutUnit logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); }
     62    LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
     63
     64    void setLogicalLeft(LayoutUnit left)
    6565    {
    6666        if (style()->isHorizontalWritingMode())
     
    6969            setY(left);
    7070    }
    71     void setLogicalTop(int top)
     71    void setLogicalTop(LayoutUnit top)
    7272    {
    7373        if (style()->isHorizontalWritingMode())
     
    7676            setX(top);
    7777    }
    78     void setLogicalLocation(const IntPoint& location)
     78    void setLogicalLocation(const LayoutPoint& location)
    7979    {
    8080        if (style()->isHorizontalWritingMode())
     
    8383            setLocation(location.transposedPoint());
    8484    }
    85     void setLogicalWidth(int size)
     85    void setLogicalWidth(LayoutUnit size)
    8686    {
    8787        if (style()->isHorizontalWritingMode())
     
    9090            setHeight(size);
    9191    }
    92     void setLogicalHeight(int size)
     92    void setLogicalHeight(LayoutUnit size)
    9393    {
    9494        if (style()->isHorizontalWritingMode())
     
    9797            setWidth(size);
    9898    }
    99     void setLogicalSize(const IntSize& size)
     99    void setLogicalSize(const LayoutSize& size)
    100100    {
    101101        if (style()->isHorizontalWritingMode())
     
    105105    }
    106106
    107     IntPoint location() const { return m_frameRect.location(); }
    108     IntSize locationOffset() const { return IntSize(x(), y()); }
    109     IntSize size() const { return m_frameRect.size(); }
    110 
    111     void setLocation(const IntPoint& location) { m_frameRect.setLocation(location); }
    112    
    113     void setSize(const IntSize& size) { m_frameRect.setSize(size); }
    114     void move(int dx, int dy) { m_frameRect.move(dx, dy); }
    115 
    116     IntRect frameRect() const { return m_frameRect; }
    117     void setFrameRect(const IntRect& rect) { m_frameRect = rect; }
    118 
    119     IntRect borderBoxRect() const { return IntRect(0, 0, width(), height()); }
    120     virtual IntRect borderBoundingBox() const { return borderBoxRect(); }
     107    LayoutPoint location() const { return m_frameRect.location(); }
     108    LayoutSize locationOffset() const { return LayoutSize(x(), y()); }
     109    LayoutSize size() const { return m_frameRect.size(); }
     110
     111    void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(location); }
     112   
     113    void setSize(const LayoutSize& size) { m_frameRect.setSize(size); }
     114    void move(LayoutUnit dx, LayoutUnit dy) { m_frameRect.move(dx, dy); }
     115
     116    LayoutRect frameRect() const { return m_frameRect; }
     117    void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; }
     118
     119    LayoutRect borderBoxRect() const { return LayoutRect(0, 0, width(), height()); }
     120    virtual LayoutRect borderBoundingBox() const { return borderBoxRect(); }
    121121
    122122    // The content area of the box (excludes padding and border).
    123     IntRect contentBoxRect() const { return IntRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
     123    LayoutRect contentBoxRect() const { return LayoutRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
    124124    // The content box in absolute coords. Ignores transforms.
    125     IntRect absoluteContentBox() const;
     125    LayoutRect absoluteContentBox() const;
    126126    // The content box converted to absolute coords (taking transforms into account).
    127127    FloatQuad absoluteContentQuad() const;
     
    170170                                int& logicalTopVisualOverflow, int& logicalBottomVisualOverflow);
    171171
    172     int contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
    173     int contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
    174     int contentLogicalWidth() const { return style()->isHorizontalWritingMode() ? contentWidth() : contentHeight(); }
    175     int contentLogicalHeight() const { return style()->isHorizontalWritingMode() ? contentHeight() : contentWidth(); }
     172    LayoutUnit contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
     173    LayoutUnit contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
     174    LayoutUnit contentLogicalWidth() const { return style()->isHorizontalWritingMode() ? contentWidth() : contentHeight(); }
     175    LayoutUnit contentLogicalHeight() const { return style()->isHorizontalWritingMode() ? contentHeight() : contentWidth(); }
    176176
    177177    // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow)
    178178    // to return the remaining width on a given line (and the height of a single line).
    179     virtual int offsetWidth() const { return width(); }
    180     virtual int offsetHeight() const { return height(); }
     179    virtual LayoutUnit offsetWidth() const { return width(); }
     180    virtual LayoutUnit offsetHeight() const { return height(); }
    181181
    182182    // More IE extensions.  clientWidth and clientHeight represent the interior of an object
    183183    // excluding border and scrollbar.  clientLeft/Top are just the borderLeftWidth and borderTopWidth.
    184     int clientLeft() const { return borderLeft(); }
    185     int clientTop() const { return borderTop(); }
    186     int clientWidth() const;
    187     int clientHeight() const;
    188     int clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); }
    189     int clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); }
    190     int clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); }
    191     IntRect clientBoxRect() const { return IntRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); }
     184    LayoutUnit clientLeft() const { return borderLeft(); }
     185    LayoutUnit clientTop() const { return borderTop(); }
     186    LayoutUnit clientWidth() const;
     187    LayoutUnit clientHeight() const;
     188    LayoutUnit clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); }
     189    LayoutUnit clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); }
     190    LayoutUnit clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); }
     191    LayoutRect clientBoxRect() const { return LayoutRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); }
    192192
    193193    // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
     
    255255    virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
    256256   
    257     int computeBorderBoxLogicalWidth(int width) const;
    258     int computeBorderBoxLogicalHeight(int height) const;
    259     int computeContentBoxLogicalWidth(int width) const;
    260     int computeContentBoxLogicalHeight(int height) const;
     257    LayoutUnit computeBorderBoxLogicalWidth(LayoutUnit width) const;
     258    LayoutUnit computeBorderBoxLogicalHeight(LayoutUnit height) const;
     259    LayoutUnit computeContentBoxLogicalWidth(LayoutUnit width) const;
     260    LayoutUnit computeContentBoxLogicalHeight(LayoutUnit height) const;
    261261
    262262    virtual void borderFitAdjust(IntRect&) const { } // Shrink the box in which the border paints if border-fit is set.
     
    468468private:
    469469    // The width/height of the contents + borders + padding.  The x/y location is relative to our container (which is not always our parent).
    470     IntRect m_frameRect;
     470    LayoutRect m_frameRect;
    471471
    472472protected:
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r89970 r89977  
    381381}
    382382
    383 int RenderBoxModelObject::relativePositionOffsetX() const
     383LayoutUnit RenderBoxModelObject::relativePositionOffsetX() const
    384384{
    385385    // Objects that shrink to avoid floats normally use available line width when computing containing block width.  However
     
    400400}
    401401
    402 int RenderBoxModelObject::relativePositionOffsetY() const
     402LayoutUnit RenderBoxModelObject::relativePositionOffsetY() const
    403403{
    404404    RenderBlock* containingBlock = this->containingBlock();
     
    425425}
    426426
    427 int RenderBoxModelObject::offsetLeft() const
     427LayoutUnit RenderBoxModelObject::offsetLeft() const
    428428{
    429429    // If the element is the HTML body element or does not have an associated box
     
    433433   
    434434    RenderBoxModelObject* offsetPar = offsetParent();
    435     int xPos = (isBox() ? toRenderBox(this)->x() : 0);
     435    LayoutUnit xPos = (isBox() ? toRenderBox(this)->x() : 0);
    436436   
    437437    // If the offsetParent of the element is null, or is the HTML body element,
     
    459459}
    460460
    461 int RenderBoxModelObject::offsetTop() const
     461LayoutUnit RenderBoxModelObject::offsetTop() const
    462462{
    463463    // If the element is the HTML body element or does not have an associated box
     
    467467   
    468468    RenderBoxModelObject* offsetPar = offsetParent();
    469     int yPos = (isBox() ? toRenderBox(this)->y() : 0);
     469    LayoutUnit yPos = (isBox() ? toRenderBox(this)->y() : 0);
    470470   
    471471    // If the offsetParent of the element is null, or is the HTML body element,
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r89970 r89977  
    5151    virtual void destroy();
    5252
    53     int relativePositionOffsetX() const;
    54     int relativePositionOffsetY() const;
    55     IntSize relativePositionOffset() const { return IntSize(relativePositionOffsetX(), relativePositionOffsetY()); }
    56     IntSize relativePositionLogicalOffset() const { return style()->isHorizontalWritingMode() ? relativePositionOffset() : relativePositionOffset().transposedSize(); }
     53    LayoutUnit relativePositionOffsetX() const;
     54    LayoutUnit relativePositionOffsetY() const;
     55    LayoutSize relativePositionOffset() const { return LayoutSize(relativePositionOffsetX(), relativePositionOffsetY()); }
     56    LayoutSize relativePositionLogicalOffset() const { return style()->isHorizontalWritingMode() ? relativePositionOffset() : relativePositionOffset().transposedSize(); }
    5757
    5858    // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow)
    5959    // to return the remaining width on a given line (and the height of a single line).
    60     virtual int offsetLeft() const;
    61     virtual int offsetTop() const;
    62     virtual int offsetWidth() const = 0;
    63     virtual int offsetHeight() const = 0;
     60    virtual LayoutUnit offsetLeft() const;
     61    virtual LayoutUnit offsetTop() const;
     62    virtual LayoutUnit offsetWidth() const = 0;
     63    virtual LayoutUnit offsetHeight() const = 0;
    6464
    6565    virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     
    7272
    7373    // This will work on inlines to return the bounding box of all of the lines' border boxes.
    74     virtual IntRect borderBoundingBox() const = 0;
     74    virtual LayoutRect borderBoundingBox() const = 0;
    7575
    7676    // Virtual since table cells override
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r89754 r89977  
    632632}
    633633
    634 int RenderInline::offsetLeft() const
    635 {
    636     int x = RenderBoxModelObject::offsetLeft();
     634LayoutUnit RenderInline::offsetLeft() const
     635{
     636    LayoutUnit x = RenderBoxModelObject::offsetLeft();
    637637    if (InlineBox* firstBox = firstLineBoxIncludingCulling())
    638638        x += firstBox->x();
     
    640640}
    641641
    642 int RenderInline::offsetTop() const
    643 {
    644     int y = RenderBoxModelObject::offsetTop();
     642LayoutUnit RenderInline::offsetTop() const
     643{
     644    LayoutUnit y = RenderBoxModelObject::offsetTop();
    645645    if (InlineBox* firstBox = firstLineBoxIncludingCulling())
    646646        y += firstBox->y();
  • trunk/Source/WebCore/rendering/RenderInline.h

    r89754 r89977  
    122122    virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasMask(); }
    123123
    124     virtual int offsetLeft() const;
    125     virtual int offsetTop() const;
    126     virtual int offsetWidth() const { return linesBoundingBox().width(); }
    127     virtual int offsetHeight() const { return linesBoundingBox().height(); }
     124    virtual LayoutUnit offsetLeft() const;
     125    virtual LayoutUnit offsetTop() const;
     126    virtual LayoutUnit offsetWidth() const { return linesBoundingBox().width(); }
     127    virtual LayoutUnit offsetHeight() const { return linesBoundingBox().height(); }
    128128
    129129    virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
     
    136136    virtual VisiblePosition positionForPoint(const IntPoint&);
    137137
    138     virtual IntRect borderBoundingBox() const
     138    virtual LayoutRect borderBoundingBox() const
    139139    {
    140         IntRect boundingBox = linesBoundingBox();
    141         return IntRect(0, 0, boundingBox.width(), boundingBox.height());
     140        LayoutRect boundingBox = linesBoundingBox();
     141        return LayoutRect(0, 0, boundingBox.width(), boundingBox.height());
    142142    }
    143143
  • trunk/Source/WebCore/rendering/RenderVideo.cpp

    r88505 r89977  
    301301}
    302302
    303 int RenderVideo::offsetLeft() const
     303LayoutUnit RenderVideo::offsetLeft() const
    304304{
    305305    if (const RenderBlock* block = rendererPlaceholder(this))
     
    308308}
    309309
    310 int RenderVideo::offsetTop() const
     310LayoutUnit RenderVideo::offsetTop() const
    311311{
    312312    if (const RenderBlock* block = rendererPlaceholder(this))
     
    315315}
    316316
    317 int RenderVideo::offsetWidth() const
     317LayoutUnit RenderVideo::offsetWidth() const
    318318{
    319319    if (const RenderBlock* block = rendererPlaceholder(this))
     
    322322}
    323323
    324 int RenderVideo::offsetHeight() const
     324LayoutUnit RenderVideo::offsetHeight() const
    325325{
    326326    if (const RenderBlock* block = rendererPlaceholder(this))
  • trunk/Source/WebCore/rendering/RenderVideo.h

    r88505 r89977  
    7676
    7777#if ENABLE(FULLSCREEN_API)
    78     virtual int offsetLeft() const;
    79     virtual int offsetTop() const;
    80     virtual int offsetWidth() const;
    81     virtual int offsetHeight() const;
     78    virtual LayoutUnit offsetLeft() const;
     79    virtual LayoutUnit offsetTop() const;
     80    virtual LayoutUnit offsetWidth() const;
     81    virtual LayoutUnit offsetHeight() const;
    8282#endif
    8383
Note: See TracChangeset for help on using the changeset viewer.