Changeset 19037 in webkit


Ignore:
Timestamp:
Jan 22, 2007 5:36:22 PM (17 years ago)
Author:
weinig
Message:

LayoutTests:

Reviewed by Darin.

  • fast/forms/listbox-selection-2-expected.checksum: Added.
  • fast/forms/listbox-selection-2-expected.png: Added.
  • fast/forms/listbox-selection-2-expected.txt: Added.
  • fast/forms/listbox-selection-2.html: Added.

WebCore:

Reviewed by Darin.

Test: fast/forms/listbox-selection-2.html

  • rendering/RenderListBox.cpp: (WebCore::RenderListBox::numVisibleItems): Changed height() to contentHeight() since items are visible only in the content box. (WebCore::RenderListBox::listIndexAtOffset): Adjusted for vertical padding and borders. Changed to return -1 instead of the last item's index if the given offset is below the last item. (WebCore::RenderListBox::autoscroll): Adjusted for vertical padding and borders. (WebCore::RenderListBox::controlClipRect): Changed to return the content box since items should not spill into the padding box. This change is the reason the test generates pixel results.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19036 r19037  
     12007-01-22  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=12344
     6          NativeListBox: item hit testing does not account for top padding and border
     7
     8        * fast/forms/listbox-selection-2-expected.checksum: Added.
     9        * fast/forms/listbox-selection-2-expected.png: Added.
     10        * fast/forms/listbox-selection-2-expected.txt: Added.
     11        * fast/forms/listbox-selection-2.html: Added.
     12
    1132007-01-22  Justin Garcia  <justin.garcia@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r19036 r19037  
     12007-01-22  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=12344
     6          NativeListBox: item hit testing does not account for top padding and border
     7
     8        Test: fast/forms/listbox-selection-2.html
     9
     10        * rendering/RenderListBox.cpp:
     11        (WebCore::RenderListBox::numVisibleItems): Changed height() to contentHeight()
     12        since items are visible only in the content box.
     13        (WebCore::RenderListBox::listIndexAtOffset): Adjusted for vertical padding and
     14        borders. Changed to return -1 instead of the last item's index if the given offset
     15        is below the last item.
     16        (WebCore::RenderListBox::autoscroll): Adjusted for vertical padding and borders.
     17        (WebCore::RenderListBox::controlClipRect): Changed to return the content box since
     18        items should not spill into the padding box. This change is the reason the test
     19        generates pixel results.
     20
    1212007-01-22  Justin Garcia  <justin.garcia@apple.com>
    222
  • trunk/WebCore/rendering/RenderListBox.cpp

    r19033 r19037  
    206206{
    207207    // Only count fully visible rows. But don't return 0 even if only part of a row shows.
    208     return max(1, (height() + rowSpacing) / itemHeight());
     208    return max(1, (contentHeight() + rowSpacing) / itemHeight());
    209209}
    210210
     
    374374int RenderListBox::listIndexAtOffset(int offsetX, int offsetY)
    375375{
    376     if (numItems() > 0) {
    377         int newOffset = max(0, offsetY / itemHeight()) + m_indexOffset;
    378         newOffset = min(max(0, newOffset), numItems() - 1);
    379         int scrollbarWidth = m_vBar ? m_vBar->width() : 0;
    380         if (offsetX >= borderLeft() + paddingLeft() && offsetX < absoluteBoundingBoxRect().width() - borderRight() - paddingRight() - scrollbarWidth)
    381             return newOffset;
    382     }
    383            
    384     return -1;
     376    if (!numItems())
     377        return -1;
     378
     379    if (offsetY < borderTop() + paddingTop() || offsetY > height() - paddingBottom() - borderBottom())
     380        return -1;
     381
     382    int scrollbarWidth = m_vBar ? m_vBar->width() : 0;
     383    if (offsetX < borderLeft() + paddingLeft() || offsetX > width() - borderRight() - paddingRight() - scrollbarWidth)
     384        return -1;
     385
     386    int newOffset = (offsetY - borderTop() - paddingTop()) / itemHeight() + m_indexOffset;
     387    return newOffset < numItems() ? newOffset : -1;
    385388}
    386389
     
    398401    int rows = numVisibleItems();
    399402    int offset = m_indexOffset;
    400     if (offsetY < 0 && scrollToRevealElementAtListIndex(offset - 1))
     403    if (offsetY < borderTop() + paddingTop() && scrollToRevealElementAtListIndex(offset - 1))
    401404        endIndex = offset - 1;
    402     else if (offsetY > absoluteBoundingBoxRect().height() && scrollToRevealElementAtListIndex(offset + rows))
     405    else if (offsetY > height() - paddingBottom() - borderBottom() && scrollToRevealElementAtListIndex(offset + rows))
    403406        endIndex = offset + rows - 1;
    404407    else
     
    517520IntRect RenderListBox::controlClipRect(int tx, int ty) const
    518521{
    519     // Clip to the padding box, since we have a scrollbar inside the padding box.
    520     return IntRect(tx + borderLeft(), ty + borderTop(), clientWidth(), clientHeight());
     522    IntRect clipRect = contentBox();
     523    clipRect.move(tx, ty);
     524    return clipRect;
    521525}
    522526
Note: See TracChangeset for help on using the changeset viewer.