⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 100042 in webkit


Ignore:
Timestamp:
Nov 11, 2011, 3:54:58 PM (15 years ago)
Author:
eae@chromium.org
Message:

Round offsetWidth/Height/Top/Left and client* before returning instead of flooring the values in the binding code

Location:
branches/subpixellayout/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/subpixellayout/Source/WebCore/dom/Element.cpp

    r99784 r100042  
    345345{
    346346    document()->updateLayoutIgnorePendingStylesheets();
    347     if (RenderBoxModelObject* rend = renderBoxModelObject()) {
    348         LayoutUnit adjustForIntRounding = rend->offsetLeft() - rend->offsetLeft().floor();
    349         return roundf(adjustForAbsoluteZoom(rend->offsetWidth() + adjustForIntRounding, rend));
    350     }
     347    if (RenderBoxModelObject* rend = renderBoxModelObject())
     348        return adjustForAbsoluteZoom(rend->offsetWidth(), rend);
    351349    return 0;
    352350}
     
    355353{
    356354    document()->updateLayoutIgnorePendingStylesheets();
    357     if (RenderBoxModelObject* rend = renderBoxModelObject()) {
    358         LayoutUnit adjustForIntRounding = rend->offsetTop() - rend->offsetTop().floor();
    359         return roundf(adjustForAbsoluteZoom(rend->offsetHeight() + adjustForIntRounding, rend));
    360     }
     355    if (RenderBoxModelObject* rend = renderBoxModelObject())
     356        return adjustForAbsoluteZoom(rend->offsetHeight(), rend);
    361357    return 0;
    362358}
     
    376372
    377373    if (RenderBox* rend = renderBox())
    378         return roundf(adjustForAbsoluteZoom(rend->clientLeft(), rend));
     374        return adjustForAbsoluteZoom(rend->clientLeft(), rend);
    379375    return 0;
    380376}
     
    385381
    386382    if (RenderBox* rend = renderBox())
    387         return roundf(adjustForAbsoluteZoom(rend->clientTop(), rend));
     383        return adjustForAbsoluteZoom(rend->clientTop(), rend);
    388384    return 0;
    389385}
     
    400396        if (FrameView* view = document()->view()) {
    401397            if (RenderView* renderView = document()->renderView())
    402                 return roundf(adjustForAbsoluteZoom(view->layoutWidth(), renderView));
     398                return adjustForAbsoluteZoom(view->layoutWidth(), renderView);
    403399        }
    404400    }
    405401   
    406     if (RenderBox* rend = renderBox()) {
    407         LayoutUnit adjustForIntRounding = rend->clientLeft() - rend->clientLeft().floor();
    408         return roundf(adjustForAbsoluteZoom(rend->clientWidth() + adjustForIntRounding, rend));
    409     }
     402    if (RenderBox* rend = renderBox())
     403        return adjustForAbsoluteZoom(rend->clientWidth(), rend);
    410404    return 0;
    411405}
     
    423417        if (FrameView* view = document()->view()) {
    424418            if (RenderView* renderView = document()->renderView())
    425                 return roundf(adjustForAbsoluteZoom(view->layoutHeight(), renderView));
     419                return adjustForAbsoluteZoom(view->layoutHeight(), renderView);
    426420        }
    427421    }
    428422   
    429     if (RenderBox* rend = renderBox()) {
    430         LayoutUnit adjustForIntRounding = rend->clientTop() - rend->clientTop().floor();
    431         return roundf(adjustForAbsoluteZoom(rend->clientHeight() + adjustForIntRounding, rend));
    432     }
     423    if (RenderBox* rend = renderBox())
     424        return adjustForAbsoluteZoom(rend->clientHeight(), rend);
    433425    return 0;
    434426}
     
    446438    document()->updateLayoutIgnorePendingStylesheets();
    447439    if (RenderBox* rend = renderBox())
    448         return roundf(adjustForAbsoluteZoom(rend->scrollTop(), rend));
     440        return adjustForAbsoluteZoom(rend->scrollTop(), rend);
    449441    return 0;
    450442}
     
    468460    document()->updateLayoutIgnorePendingStylesheets();
    469461    if (RenderBox* rend = renderBox()) {
    470         return roundf(adjustForAbsoluteZoom(rend->scrollWidth(), rend));
     462        return adjustForAbsoluteZoom(rend->scrollWidth(), rend);
    471463    }
    472464    return 0;
     
    477469    document()->updateLayoutIgnorePendingStylesheets();
    478470    if (RenderBox* rend = renderBox()) {
    479         return roundf(adjustForAbsoluteZoom(rend->scrollHeight(), rend));
     471        return adjustForAbsoluteZoom(rend->scrollHeight(), rend);
    480472    }
    481473    return 0;
  • branches/subpixellayout/Source/WebCore/rendering/RenderBox.cpp

    r99908 r100042  
    466466// More IE extensions.  clientWidth and clientHeight represent the interior of an object
    467467// excluding border and scrollbar.
    468 LayoutUnit RenderBox::clientWidth() const
    469 {
    470     return width() - borderLeft() - borderRight() - verticalScrollbarWidth();
    471 }
    472 
    473 LayoutUnit RenderBox::clientHeight() const
    474 {
    475     return height() - borderTop() - borderBottom() - horizontalScrollbarHeight();
     468int RenderBox::clientWidth() const
     469{
     470    return (width() - borderLeft() - borderRight() - verticalScrollbarWidth()).round();
     471}
     472
     473int RenderBox::clientHeight() const
     474{
     475    return (height() - borderTop() - borderBottom() - horizontalScrollbarHeight()).round();
    476476}
    477477
     
    483483    // FIXME: Need to work right with writing modes.
    484484    if (style()->isLeftToRightDirection())
    485         return max(clientWidth(), maxXLayoutOverflow() - borderLeft());
    486     return clientWidth() - min<int>(0, minXLayoutOverflow() - borderLeft());
     485        return max(clientWidth(), (maxXLayoutOverflow() - borderLeft()).round());
     486    return clientWidth() - min(0, (minXLayoutOverflow() - borderLeft()).round());
    487487}
    488488
  • branches/subpixellayout/Source/WebCore/rendering/RenderBox.h

    r99259 r100042  
    181181    // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow)
    182182    // to return the remaining width on a given line (and the height of a single line).
    183     virtual LayoutUnit offsetWidth() const { return width(); }
    184     virtual LayoutUnit offsetHeight() const { return height(); }
     183    virtual int offsetWidth() const { return width(); }
     184    virtual int offsetHeight() const { return height(); }
    185185
    186186    // More IE extensions.  clientWidth and clientHeight represent the interior of an object
    187187    // excluding border and scrollbar.  clientLeft/Top are just the borderLeftWidth and borderTopWidth.
    188     LayoutUnit clientLeft() const { return borderLeft(); }
    189     LayoutUnit clientTop() const { return borderTop(); }
    190     LayoutUnit clientWidth() const;
    191     LayoutUnit clientHeight() const;
    192     LayoutUnit clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); }
    193     LayoutUnit clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); }
    194     LayoutUnit clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); }
    195     LayoutRect clientBoxRect() const { return LayoutRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); }
     188    int clientLeft() const { return borderLeft().round(); }
     189    int clientTop() const { return borderTop().round(); }
     190    int clientWidth() const;
     191    int clientHeight() const;
     192    int clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); }
     193    int clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); }
     194    int clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); }
     195    IntRect clientBoxRect() const { return IntRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); }
    196196
    197197    // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
  • branches/subpixellayout/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r99908 r100042  
    432432}
    433433
    434 LayoutUnit RenderBoxModelObject::offsetLeft() const
     434int RenderBoxModelObject::offsetLeft() const
    435435{
    436436    // If the element is the HTML body element or does not have an associated box
     
    463463    }
    464464
    465     return xPos;
    466 }
    467 
    468 LayoutUnit RenderBoxModelObject::offsetTop() const
     465    return xPos.round();
     466}
     467
     468int RenderBoxModelObject::offsetTop() const
    469469{
    470470    // If the element is the HTML body element or does not have an associated box
     
    496496        }
    497497    }
    498     return yPos;
     498    return yPos.round();
    499499}
    500500
  • branches/subpixellayout/Source/WebCore/rendering/RenderBoxModelObject.h

    r98872 r100042  
    5656    // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow)
    5757    // to return the remaining width on a given line (and the height of a single line).
    58     virtual LayoutUnit offsetLeft() const;
    59     virtual LayoutUnit offsetTop() const;
    60     virtual LayoutUnit offsetWidth() const = 0;
    61     virtual LayoutUnit offsetHeight() const = 0;
     58    virtual int offsetLeft() const;
     59    virtual int offsetTop() const;
     60    virtual int offsetWidth() const = 0;
     61    virtual int offsetHeight() const = 0;
    6262
    6363    virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
  • branches/subpixellayout/Source/WebCore/rendering/RenderInline.cpp

    r98165 r100042  
    638638}
    639639
    640 LayoutUnit RenderInline::offsetLeft() const
    641 {
    642     LayoutUnit x = RenderBoxModelObject::offsetLeft();
     640int RenderInline::offsetLeft() const
     641{
     642    int x = RenderBoxModelObject::offsetLeft();
    643643    if (InlineBox* firstBox = firstLineBoxIncludingCulling())
    644644        x += firstBox->x();
     
    646646}
    647647
    648 LayoutUnit RenderInline::offsetTop() const
    649 {
    650     LayoutUnit y = RenderBoxModelObject::offsetTop();
     648int RenderInline::offsetTop() const
     649{
     650    int y = RenderBoxModelObject::offsetTop();
    651651    if (InlineBox* firstBox = firstLineBoxIncludingCulling())
    652652        y += firstBox->y();
  • branches/subpixellayout/Source/WebCore/rendering/RenderInline.h

    r96859 r100042  
    122122    virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasMask(); }
    123123
    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(); }
     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(); }
    128128
    129129    virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
  • branches/subpixellayout/Source/WebCore/rendering/RenderListBox.cpp

    r99784 r100042  
    651651int RenderListBox::scrollHeight() const
    652652{
    653     return max(clientHeight(), listHeight());
     653    return max(clientHeight(), listHeight().round());
    654654}
    655655
  • branches/subpixellayout/Source/WebCore/rendering/RenderVideo.cpp

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

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