Changeset 109512 in webkit


Ignore:
Timestamp:
Mar 1, 2012 10:33:00 PM (12 years ago)
Author:
morrita@google.com
Message:

Render overflow controls of an RTL element to its left-side.
https://bugs.webkit.org/show_bug.cgi?id=54623

This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
vertical scrollbars and resizers of RTL elements to their left side if
this new flag is enabled.

Patch by Hironori Bono <hbono@chromium.org> on 2012-03-01
Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: platform/chromium/fast/events/rtl-scrollbar.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::addOverflowFromPositionedObjects): Move child elements right.
(WebCore::RenderBlock::determineLogicalLeftPositionForChild): ditto.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::overflowClipRect): Move the content rectangle right.

  • rendering/RenderLayer.cpp:

(WebCore::cornerStart): Added a function that calculates the X position of a resizer.
(WebCore):
(WebCore::cornerRect): Use cornerStart to move a resizer.
(WebCore::RenderLayer::verticalScrollbarStart): Added a function that calculates
the X position of a vertical scrollbar.
(WebCore::RenderLayer::horizontalScrollbarStart): Added a function that calculates
the X position of a horizontal scrollbar.
(WebCore::RenderLayer::scrollbarOffset): Render a vertical scrollbar to the left side
and move a horizontal scrollbar right by the width of the vertical scrollbar.
(WebCore::RenderLayer::invalidateScrollbarRect): ditto.
(WebCore::RenderLayer::positionOverflowControls): ditto.
(WebCore::RenderLayer::hitTestOverflowControls): ditto.

  • rendering/RenderLayer.h:

(RenderLayer):

  • rendering/style/RenderStyle.h: Added shouldPlaceBlockDirectionScrollbarOnLogicalLeft,

which returns if we need to move a left scrollbar to its right side.

Source/WebKit/chromium:

  • features.gypi: Set WTF_USE_RTL_SCROLLBAR to 1 on Chromium.

LayoutTests:

  • platform/chromium/fast/events/rtl-scrollbar-expected.txt: Added.
  • platform/chromium/fast/events/rtl-scrollbar.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109510 r109512  
     12012-03-01  Hironori Bono  <hbono@chromium.org>
     2
     3        Render overflow controls of an RTL element to its left-side.
     4        https://bugs.webkit.org/show_bug.cgi?id=54623
     5
     6        This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
     7        vertical scrollbars and resizers of RTL elements to their left side if
     8        this new flag is enabled.
     9
     10        Reviewed by Ryosuke Niwa.
     11
     12        * platform/chromium/fast/events/rtl-scrollbar-expected.txt: Added.
     13        * platform/chromium/fast/events/rtl-scrollbar.html: Added.
     14
    1152012-03-01  Dirk Pranke  <dpranke@chromium.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r109503 r109512  
     12012-03-01  Hironori Bono  <hbono@chromium.org>
     2
     3        Render overflow controls of an RTL element to its left-side.
     4        https://bugs.webkit.org/show_bug.cgi?id=54623
     5
     6        This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
     7        vertical scrollbars and resizers of RTL elements to their left side if
     8        this new flag is enabled.
     9
     10        Reviewed by Ryosuke Niwa.
     11
     12        Test: platform/chromium/fast/events/rtl-scrollbar.html
     13
     14        * rendering/RenderBlock.cpp:
     15        (WebCore::RenderBlock::addOverflowFromPositionedObjects): Move child elements right.
     16        (WebCore::RenderBlock::determineLogicalLeftPositionForChild): ditto.
     17        * rendering/RenderBox.cpp:
     18        (WebCore::RenderBox::overflowClipRect): Move the content rectangle right.
     19        * rendering/RenderLayer.cpp:
     20        (WebCore::cornerStart): Added a function that calculates the X position of a resizer.
     21        (WebCore):
     22        (WebCore::cornerRect): Use cornerStart to move a resizer.
     23        (WebCore::RenderLayer::verticalScrollbarStart): Added a function that calculates
     24        the X position of a vertical scrollbar.
     25        (WebCore::RenderLayer::horizontalScrollbarStart): Added a function that calculates
     26        the X position of a horizontal scrollbar.
     27        (WebCore::RenderLayer::scrollbarOffset): Render a vertical scrollbar to the left side
     28        and move a horizontal scrollbar right by the width of the vertical scrollbar.
     29        (WebCore::RenderLayer::invalidateScrollbarRect): ditto.
     30        (WebCore::RenderLayer::positionOverflowControls): ditto.
     31        (WebCore::RenderLayer::hitTestOverflowControls): ditto.
     32        * rendering/RenderLayer.h:
     33        (RenderLayer):
     34        * rendering/style/RenderStyle.h: Added shouldPlaceBlockDirectionScrollbarOnLogicalLeft,
     35        which returns if we need to move a left scrollbar to its right side.
     36
    1372012-03-01  Kent Tamura  <tkent@chromium.org>
    238
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r109383 r109512  
    16531653       
    16541654        // Fixed positioned elements don't contribute to layout overflow, since they don't scroll with the content.
    1655         if (positionedObject->style()->position() != FixedPosition)
    1656             addOverflowFromChild(positionedObject);
     1655        if (positionedObject->style()->position() != FixedPosition) {
     1656            int x = positionedObject->x();
     1657            if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
     1658                x -= verticalScrollbarWidth();
     1659            addOverflowFromChild(positionedObject, IntSize(x, positionedObject->y()));
     1660        }
    16571661    }
    16581662}
     
    20502054{
    20512055    LayoutUnit startPosition = borderStart() + paddingStart();
     2056    if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
     2057        startPosition -= verticalScrollbarWidth();
    20522058    LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + availableLogicalWidth();
    20532059
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r109383 r109512  
    12331233
    12341234    // Subtract out scrollbars if we have them.
    1235     if (layer())
     1235     if (layer()) {
     1236        if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
     1237            clipRect.move(layer()->verticalScrollbarWidth(relevancy), 0);
    12361238        clipRect.contract(layer()->verticalScrollbarWidth(relevancy), layer()->horizontalScrollbarHeight(relevancy));
     1239     }
    12371240
    12381241    return clipRect;
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r109378 r109512  
    18351835}
    18361836
     1837static LayoutUnit cornerStart(const RenderLayer* layer, int minX, int maxX, int thickness)
     1838{
     1839    if (layer->renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
     1840        return minX + layer->renderer()->style()->borderLeftWidth();
     1841    return maxX - thickness - layer->renderer()->style()->borderRightWidth();
     1842}
     1843
    18371844static IntRect cornerRect(const RenderLayer* layer, const IntRect& bounds)
    18381845{
     
    18541861        verticalThickness = layer->horizontalScrollbar()->height();
    18551862    }
    1856     return IntRect(bounds.maxX() - horizontalThickness - layer->renderer()->style()->borderRightWidth(),
     1863    return IntRect(cornerStart(layer, bounds.x(), bounds.maxX(), horizontalThickness),
    18571864                   bounds.maxY() - verticalThickness - layer->renderer()->style()->borderBottomWidth(),
    18581865                   horizontalThickness, verticalThickness);
     
    19771984}
    19781985
     1986LayoutUnit RenderLayer::verticalScrollbarStart(int minX, int maxX) const
     1987{
     1988    const RenderBox* box = renderBox();
     1989    if (renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
     1990        return minX + box->borderLeft();
     1991    return maxX - box->borderRight() - m_vBar->width();
     1992}
     1993
     1994LayoutUnit RenderLayer::horizontalScrollbarStart(int minX) const
     1995{
     1996    const RenderBox* box = renderBox();
     1997    int x = minX + box->borderLeft();
     1998    if (renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
     1999        x += m_vBar ? m_vBar->width() : resizerCornerRect(this, box->borderBoxRect()).width();
     2000    return x;
     2001}
     2002
    19792003IntSize RenderLayer::scrollbarOffset(const Scrollbar* scrollbar) const
    19802004{
     
    19822006
    19832007    if (scrollbar == m_vBar.get())
    1984         return IntSize(box->width() - box->borderRight() - scrollbar->width(), box->borderTop());
     2008        return IntSize(verticalScrollbarStart(0, box->width()), box->borderTop());
    19852009
    19862010    if (scrollbar == m_hBar.get())
    1987         return IntSize(box->borderLeft(), box->height() - box->borderBottom() - scrollbar->height());
     2011        return IntSize(horizontalScrollbarStart(0), box->height() - box->borderBottom() - scrollbar->height());
    19882012   
    19892013    ASSERT_NOT_REACHED();
     
    20102034    ASSERT(box);
    20112035    if (scrollbar == m_vBar.get())
    2012         scrollRect.move(box->width() - box->borderRight() - scrollbar->width(), box->borderTop());
     2036        scrollRect.move(verticalScrollbarStart(0, box->width()), box->borderTop());
    20132037    else
    2014         scrollRect.move(box->borderLeft(), box->height() - box->borderBottom() - scrollbar->height());
     2038        scrollRect.move(horizontalScrollbarStart(0), box->height() - box->borderBottom() - scrollbar->height());
    20152039    renderer()->repaintRectangle(scrollRect);
    20162040}
     
    21772201    IntRect absBounds(borderBox.location() + offsetFromLayer, borderBox.size());
    21782202    if (m_vBar)
    2179         m_vBar->setFrameRect(IntRect(absBounds.maxX() - box->borderRight() - m_vBar->width(),
     2203        m_vBar->setFrameRect(IntRect(verticalScrollbarStart(absBounds.x(), absBounds.maxX()),
    21802204                                     absBounds.y() + box->borderTop(),
    21812205                                     m_vBar->width(),
     
    21832207
    21842208    if (m_hBar)
    2185         m_hBar->setFrameRect(IntRect(absBounds.x() + box->borderLeft(),
     2209        m_hBar->setFrameRect(IntRect(horizontalScrollbarStart(absBounds.x()),
    21862210                                     absBounds.maxY() - box->borderBottom() - m_hBar->height(),
    21872211                                     absBounds.width() - (box->borderLeft() + box->borderRight()) - scrollCorner.width(),
     
    25942618
    25952619    if (m_vBar && m_vBar->shouldParticipateInHitTesting()) {
    2596         LayoutRect vBarRect(box->width() - box->borderRight() - m_vBar->width(),
     2620        LayoutRect vBarRect(verticalScrollbarStart(0, box->width()),
    25972621                            box->borderTop(),
    25982622                            m_vBar->width(),
     
    26062630    resizeControlSize = max(resizeControlRect.width(), 0);
    26072631    if (m_hBar && m_hBar->shouldParticipateInHitTesting()) {
    2608         LayoutRect hBarRect(box->borderLeft(),
     2632        LayoutRect hBarRect(horizontalScrollbarStart(0),
    26092633                            box->height() - box->borderBottom() - m_hBar->height(),
    26102634                            box->width() - (box->borderLeft() + box->borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize),
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r108382 r109512  
    756756    }
    757757
     758    LayoutUnit verticalScrollbarStart(int minX, int maxX) const;
     759    LayoutUnit horizontalScrollbarStart(int minX) const;
     760
    758761protected:
    759762    // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r109311 r109512  
    970970#else
    971971    bool hasFilter() const { return false; }
     972#endif
     973
     974#if USE(RTL_SCROLLBAR)
     975    bool shouldPlaceBlockDirectionScrollbarOnLogicalLeft() const { return !isLeftToRightDirection() && isHorizontalWritingMode(); }
     976#else
     977    bool shouldPlaceBlockDirectionScrollbarOnLogicalLeft() const { return false; }
    972978#endif
    973979       
  • trunk/Source/WebKit/chromium/ChangeLog

    r109466 r109512  
     12012-03-01  Hironori Bono  <hbono@chromium.org>
     2
     3        Render overflow controls of an RTL element to its left-side.
     4        https://bugs.webkit.org/show_bug.cgi?id=54623
     5
     6        This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
     7        vertical scrollbars and resizers of RTL elements to their left side if
     8        this new flag is enabled.
     9
     10        Reviewed by Ryosuke Niwa.
     11
     12        * features.gypi: Set WTF_USE_RTL_SCROLLBAR to 1 on Chromium.
     13
    1142012-03-01  James Robinson  <jamesr@chromium.org>
    215
  • trunk/Source/WebKit/chromium/features.gypi

    r108474 r109512  
    107107      # in Debug or release_valgrind_build=1 builds.
    108108      'WTF_USE_OPENTYPE_SANITIZER=1',
     109      'WTF_USE_RTL_SCROLLBAR=1',
    109110      'WTF_USE_SKIA_TEXT=<(enable_skia_text)',
    110111      'WTF_USE_WEBP=1',
Note: See TracChangeset for help on using the changeset viewer.