Changeset 198843 in webkit


Ignore:
Timestamp:
Mar 30, 2016 10:34:20 AM (8 years ago)
Author:
mmaxfield@apple.com
Message:

[OS X] [RTL Scrollbars] List boxes should obey RTL scrollbars
https://bugs.webkit.org/show_bug.cgi?id=155991

Reviewed by Darin Adler.

Source/WebCore:

List boxes were created before RenderLayers, and therefore don't share
the scollbar logic with them. Instead, they manage their own Scrollbars.
The placement logic needs to be updated to take RTL scrollbars into
account.

Tests: fast/scrolling/rtl-scrollbars-listbox-scroll.html

fast/scrolling/rtl-scrollbars-listbox-select-left.html
fast/scrolling/rtl-scrollbars-listbox-select-right.html
fast/scrolling/rtl-scrollbars-listbox-simple.html
fast/scrolling/rtl-scrollbars-listbox.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::contentBoxRect):

  • rendering/RenderBox.h:

(WebCore::RenderBox::contentBoxRect): Deleted.

  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::itemBoundingBoxRect):
(WebCore::RenderListBox::paintScrollbar):
(WebCore::RenderListBox::paintItemBackground):
(WebCore::RenderListBox::isPointInOverflowControl):
(WebCore::RenderListBox::listIndexAtOffset):
(WebCore::RenderListBox::nodeAtPoint):
(WebCore::RenderListBox::controlClipRect):
(WebCore::RenderListBox::invalidateScrollbarRect):
(WebCore::RenderListBox::convertFromScrollbarToContainingView):
(WebCore::RenderListBox::convertFromContainingViewToScrollbar):
(WebCore::RenderListBox::scrolledToTop):
(WebCore::RenderListBox::scrolledToBottom):

LayoutTests:

As with the previous patches, mark new tests as failing on all OSes that
don't support RTL scrollbars.

  • TestExpectations:
  • fast/scrolling/rtl-scrollbars-listbox-expected.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-scroll-expected.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-scroll.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-select-left-expected.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-select-left.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-select-right-expected.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-select-right.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-simple-expected-mismatch.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox-simple.html: Added.
  • fast/scrolling/rtl-scrollbars-listbox.html: Added.
Location:
trunk
Files:
10 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r198838 r198843  
     12016-03-30  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [OS X] [RTL Scrollbars] List boxes should obey RTL scrollbars
     4        https://bugs.webkit.org/show_bug.cgi?id=155991
     5
     6        Reviewed by Darin Adler.
     7
     8        As with the previous patches, mark new tests as failing on all OSes that
     9        don't support RTL scrollbars.
     10
     11        * TestExpectations:
     12        * fast/scrolling/rtl-scrollbars-listbox-expected.html: Added.
     13        * fast/scrolling/rtl-scrollbars-listbox-scroll-expected.html: Added.
     14        * fast/scrolling/rtl-scrollbars-listbox-scroll.html: Added.
     15        * fast/scrolling/rtl-scrollbars-listbox-select-left-expected.html: Added.
     16        * fast/scrolling/rtl-scrollbars-listbox-select-left.html: Added.
     17        * fast/scrolling/rtl-scrollbars-listbox-select-right-expected.html: Added.
     18        * fast/scrolling/rtl-scrollbars-listbox-select-right.html: Added.
     19        * fast/scrolling/rtl-scrollbars-listbox-simple-expected-mismatch.html: Added.
     20        * fast/scrolling/rtl-scrollbars-listbox-simple.html: Added.
     21        * fast/scrolling/rtl-scrollbars-listbox.html: Added.
     22
    1232016-03-30  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/LayoutTests/TestExpectations

    r198828 r198843  
    10141014fast/scrolling/rtl-scrollbars-iframe-scrolled.html [ ImageOnlyFailure ]
    10151015fast/scrolling/rtl-scrollbars-positioning.html [ ImageOnlyFailure ]
     1016fast/scrolling/rtl-scrollbars-listbox-scroll.html [ ImageOnlyFailure ]
     1017fast/scrolling/rtl-scrollbars-listbox-select-left.html [ ImageOnlyFailure ]
     1018fast/scrolling/rtl-scrollbars-listbox-select-right.html [ ImageOnlyFailure ]
     1019fast/scrolling/rtl-scrollbars-listbox-simple.html [ ImageOnlyFailure ]
     1020fast/scrolling/rtl-scrollbars-listbox.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r198841 r198843  
     12016-03-30  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [OS X] [RTL Scrollbars] List boxes should obey RTL scrollbars
     4        https://bugs.webkit.org/show_bug.cgi?id=155991
     5
     6        Reviewed by Darin Adler.
     7
     8        List boxes were created before RenderLayers, and therefore don't share
     9        the scollbar logic with them. Instead, they manage their own Scrollbars.
     10        The placement logic needs to be updated to take RTL scrollbars into
     11        account.
     12
     13        Tests: fast/scrolling/rtl-scrollbars-listbox-scroll.html
     14               fast/scrolling/rtl-scrollbars-listbox-select-left.html
     15               fast/scrolling/rtl-scrollbars-listbox-select-right.html
     16               fast/scrolling/rtl-scrollbars-listbox-simple.html
     17               fast/scrolling/rtl-scrollbars-listbox.html
     18
     19        * rendering/RenderBox.cpp:
     20        (WebCore::RenderBox::contentBoxRect):
     21        * rendering/RenderBox.h:
     22        (WebCore::RenderBox::contentBoxRect): Deleted.
     23        * rendering/RenderListBox.cpp:
     24        (WebCore::RenderListBox::itemBoundingBoxRect):
     25        (WebCore::RenderListBox::paintScrollbar):
     26        (WebCore::RenderListBox::paintItemBackground):
     27        (WebCore::RenderListBox::isPointInOverflowControl):
     28        (WebCore::RenderListBox::listIndexAtOffset):
     29        (WebCore::RenderListBox::nodeAtPoint):
     30        (WebCore::RenderListBox::controlClipRect):
     31        (WebCore::RenderListBox::invalidateScrollbarRect):
     32        (WebCore::RenderListBox::convertFromScrollbarToContainingView):
     33        (WebCore::RenderListBox::convertFromContainingViewToScrollbar):
     34        (WebCore::RenderListBox::scrolledToTop):
     35        (WebCore::RenderListBox::scrolledToBottom):
     36
    1372016-03-30  Myles C. Maxfield  <mmaxfield@apple.com>
    238
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r198828 r198843  
    691691}
    692692
     693LayoutRect RenderBox::contentBoxRect() const
     694{
     695    LayoutUnit x = borderLeft() + paddingLeft();
     696    if (layer() && layer()->verticalScrollbarIsOnLeft())
     697        x += verticalScrollbarWidth();
     698    LayoutUnit y = borderTop() + paddingTop();
     699    return LayoutRect(x, y, contentWidth(), contentHeight());
     700}
     701
    693702IntRect RenderBox::absoluteContentBox() const
    694703{
  • trunk/Source/WebCore/rendering/RenderBox.h

    r198771 r198843  
    159159
    160160    // The content area of the box (excludes padding - and intrinsic padding for table cells, etc... - and border).
    161     LayoutRect contentBoxRect() const { return LayoutRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
     161    LayoutRect contentBoxRect() const;
    162162    // The content box in absolute coords. Ignores transforms.
    163163    IntRect absoluteContentBox() const;
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r198841 r198843  
    266266LayoutRect RenderListBox::itemBoundingBoxRect(const LayoutPoint& additionalOffset, int index)
    267267{
    268     return LayoutRect(additionalOffset.x() + borderLeft() + paddingLeft(),
    269                    additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (index - m_indexOffset),
    270                    contentWidth(), itemHeight());
     268    LayoutUnit x = additionalOffset.x() + borderLeft() + paddingLeft();
     269    if (verticalScrollbarIsOnLeft() && m_vBar)
     270        x += m_vBar->occupiedWidth();
     271    LayoutUnit y = additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (index - m_indexOffset);
     272    return LayoutRect(x, y, contentWidth(), itemHeight());
    271273}
    272274   
     
    341343void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    342344{
    343     if (m_vBar) {
    344         IntRect scrollRect = snappedIntRect(paintOffset.x() + width() - borderRight() - m_vBar->width(),
    345             paintOffset.y() + borderTop(),
    346             m_vBar->width(),
    347             height() - (borderTop() + borderBottom()));
    348         m_vBar->setFrameRect(scrollRect);
    349         m_vBar->paint(paintInfo.context(), snappedIntRect(paintInfo.rect));
    350     }
     345    if (!m_vBar)
     346        return;
     347
     348    LayoutUnit left = paintOffset.x() + (verticalScrollbarIsOnLeft() ? borderLeft() : width() - borderRight() - m_vBar->width());
     349    LayoutUnit top = paintOffset.y() + borderTop();
     350    LayoutUnit width = m_vBar->width();
     351    LayoutUnit height = this->height() - (borderTop() + borderBottom());
     352    IntRect scrollRect = snappedIntRect(left, top, width, height);
     353    m_vBar->setFrameRect(scrollRect);
     354    m_vBar->paint(paintInfo.context(), snappedIntRect(paintInfo.rect));
    351355}
    352356
     
    432436
    433437    // Draw the background for this list box item
    434     if (itemStyle.visibility() != HIDDEN) {
    435         LayoutRect itemRect = itemBoundingBoxRect(paintOffset, listIndex);
    436         itemRect.intersect(controlClipRect(paintOffset));
    437         paintInfo.context().fillRect(snappedIntRect(itemRect), backColor);
    438     }
     438    if (itemStyle.visibility() == HIDDEN)
     439        return;
     440
     441    LayoutRect itemRect = itemBoundingBoxRect(paintOffset, listIndex);
     442    itemRect.intersect(controlClipRect(paintOffset));
     443    paintInfo.context().fillRect(snappedIntRect(itemRect), backColor);
    439444}
    440445
     
    444449        return false;
    445450
    446     LayoutRect vertRect(accumulatedOffset.x() + width() - borderRight() - m_vBar->width(),
    447                         accumulatedOffset.y() + borderTop(),
    448                         m_vBar->width(),
    449                         height() - borderTop() - borderBottom());
    450 
    451     if (vertRect.contains(locationInContainer)) {
    452         result.setScrollbar(m_vBar.get());
    453         return true;
    454     }
    455     return false;
     451    LayoutUnit x = accumulatedOffset.x() + (verticalScrollbarIsOnLeft() ? borderLeft() : width() - borderRight() - m_vBar->width());
     452    LayoutUnit y = accumulatedOffset.y() + borderTop();
     453    LayoutUnit width = m_vBar->width();
     454    LayoutUnit height = this->height() - borderTop() - borderBottom();
     455    LayoutRect vertRect(x, y, width, height);
     456
     457    if (!vertRect.contains(locationInContainer))
     458        return false;
     459
     460    result.setScrollbar(m_vBar.get());
     461    return true;
    456462}
    457463
     
    465471
    466472    int scrollbarWidth = m_vBar ? m_vBar->width() : 0;
    467     if (offset.width() < borderLeft() + paddingLeft() || offset.width() > width() - borderRight() - paddingRight() - scrollbarWidth)
     473    if (verticalScrollbarIsOnLeft() && (offset.width() < borderLeft() + paddingLeft() + scrollbarWidth || offset.width() > width() - borderRight() - paddingRight()))
     474        return -1;
     475    if (!verticalScrollbarIsOnLeft() && (offset.width() < borderLeft() + paddingLeft() || offset.width() > width() - borderRight() - paddingRight() - scrollbarWidth))
    468476        return -1;
    469477
     
    703711
    704712    for (int i = 0; i < size; ++i) {
    705         if (itemBoundingBoxRect(adjustedLocation, i).contains(locationInContainer.point())) {
    706             if (Element* node = listItems[i]) {
    707                 result.setInnerNode(node);
    708                 if (!result.innerNonSharedNode())
    709                     result.setInnerNonSharedNode(node);
    710                 result.setLocalPoint(locationInContainer.point() - toLayoutSize(adjustedLocation));
    711                 break;
    712             }
     713        if (!itemBoundingBoxRect(adjustedLocation, i).contains(locationInContainer.point()))
     714            continue;
     715        if (Element* node = listItems[i]) {
     716            result.setInnerNode(node);
     717            if (!result.innerNonSharedNode())
     718                result.setInnerNonSharedNode(node);
     719            result.setLocalPoint(locationInContainer.point() - toLayoutSize(adjustedLocation));
     720            break;
    713721        }
    714722    }
     
    720728{
    721729    LayoutRect clipRect = contentBoxRect();
     730    if (verticalScrollbarIsOnLeft() && (!layer() || !layer()->verticalScrollbarIsOnLeft()))
     731        clipRect.move(m_vBar->occupiedWidth(), 0);
    722732    clipRect.moveBy(additionalOffset);
    723733    return clipRect;
     
    733743{
    734744    IntRect scrollRect = rect;
    735     scrollRect.move(width() - borderRight() - scrollbar.width(), borderTop());
     745    scrollRect.move(verticalScrollbarIsOnLeft() ? borderLeft() : width() - borderRight() - scrollbar.width(), borderTop());
    736746    repaintRectangle(scrollRect);
    737747}
     
    740750{
    741751    IntRect rect = scrollbarRect;
    742     int scrollbarLeft = width() - borderRight() - scrollbar.width();
     752    int scrollbarLeft = verticalScrollbarIsOnLeft() ? borderLeft() : width() - borderRight() - scrollbar.width();
    743753    int scrollbarTop = borderTop();
    744754    rect.move(scrollbarLeft, scrollbarTop);
     
    749759{
    750760    IntRect rect = view().frameView().convertFromContainingViewToRenderer(this, parentRect);
    751     int scrollbarLeft = width() - borderRight() - scrollbar.width();
     761    int scrollbarLeft = verticalScrollbarIsOnLeft() ? borderLeft() : width() - borderRight() - scrollbar.width();
    752762    int scrollbarTop = borderTop();
    753763    rect.move(-scrollbarLeft, -scrollbarTop);
     
    758768{
    759769    IntPoint point = scrollbarPoint;
    760     int scrollbarLeft = width() - borderRight() - scrollbar.width();
     770    int scrollbarLeft = verticalScrollbarIsOnLeft() ? borderLeft() : width() - borderRight() - scrollbar.width();
    761771    int scrollbarTop = borderTop();
    762772    point.move(scrollbarLeft, scrollbarTop);
     
    767777{
    768778    IntPoint point = view().frameView().convertFromContainingViewToRenderer(this, parentPoint);
    769     int scrollbarLeft = width() - borderRight() - scrollbar.width();
     779    int scrollbarLeft = verticalScrollbarIsOnLeft() ? borderLeft() : width() - borderRight() - scrollbar.width();
    770780    int scrollbarTop = borderTop();
    771781    point.move(-scrollbarLeft, -scrollbarTop);
     
    881891bool RenderListBox::scrolledToTop() const
    882892{
     893    if (Scrollbar* vbar = verticalScrollbar())
     894    return vbar->value() <= 0;
     895
     896    return true;
     897}
     898
     899bool RenderListBox::scrolledToBottom() const
     900{
    883901    Scrollbar* vbar = verticalScrollbar();
    884902    if (!vbar)
    885903        return true;
    886    
    887     return vbar->value() <= 0;
    888 }
    889 
    890 bool RenderListBox::scrolledToBottom() const
    891 {
    892     Scrollbar* vbar = verticalScrollbar();
    893     if (!vbar)
    894         return true;
    895904
    896905    return vbar->value() >= vbar->maximum();
Note: See TracChangeset for help on using the changeset viewer.