| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 return true; | 285 return true; |
| 286 } | 286 } |
| 287 | 287 |
| 288 HostWindow* PopupListBox::hostWindow() const | 288 HostWindow* PopupListBox::hostWindow() const |
| 289 { | 289 { |
| 290 // Our parent is the root ScrollView, so it is the one that has a | 290 // Our parent is the root ScrollView, so it is the one that has a |
| 291 // HostWindow. FrameView::hostWindow() works similarly. | 291 // HostWindow. FrameView::hostWindow() works similarly. |
| 292 return parent() ? parent()->hostWindow() : 0; | 292 return parent() ? parent()->hostWindow() : 0; |
| 293 } | 293 } |
| 294 | 294 |
| 295 bool PopupListBox::shouldPlaceVerticalScrollbarOnLeft() const |
| 296 { |
| 297 return m_popupClient->menuStyle().textDirection() == RTL; |
| 298 } |
| 299 |
| 295 // From HTMLSelectElement.cpp | 300 // From HTMLSelectElement.cpp |
| 296 static String stripLeadingWhiteSpace(const String& string) | 301 static String stripLeadingWhiteSpace(const String& string) |
| 297 { | 302 { |
| 298 int length = string.length(); | 303 int length = string.length(); |
| 299 int i; | 304 int i; |
| 300 for (i = 0; i < length; ++i) | 305 for (i = 0; i < length; ++i) |
| 301 if (string[i] != noBreakSpace | 306 if (string[i] != noBreakSpace |
| 302 && (string[i] <= 0x7F ? !isASCIISpace(string[i]) : (direction(string
[i]) != WhiteSpaceNeutral))) | 307 && (string[i] <= 0x7F ? !isASCIISpace(string[i]) : (direction(string
[i]) != WhiteSpaceNeutral))) |
| 303 break; | 308 break; |
| 304 | 309 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 selectIndex(index); | 357 selectIndex(index); |
| 353 return; | 358 return; |
| 354 } | 359 } |
| 355 } | 360 } |
| 356 } | 361 } |
| 357 | 362 |
| 358 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) | 363 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) |
| 359 { | 364 { |
| 360 // Adjust coords for scrolled frame. | 365 // Adjust coords for scrolled frame. |
| 361 IntRect r = intersection(rect, frameRect()); | 366 IntRect r = intersection(rect, frameRect()); |
| 362 int tx = x() - scrollX(); | 367 int tx = x() - scrollX() + ((shouldPlaceVerticalScrollbarOnLeft() && vertica
lScrollbar()) ? verticalScrollbar()->width() : 0); |
| 363 int ty = y() - scrollY(); | 368 int ty = y() - scrollY(); |
| 364 | 369 |
| 365 r.move(-tx, -ty); | 370 r.move(-tx, -ty); |
| 366 | 371 |
| 367 // Set clip rect to match revised damage rect. | 372 // Set clip rect to match revised damage rect. |
| 368 gc->save(); | 373 gc->save(); |
| 369 gc->translate(static_cast<float>(tx), static_cast<float>(ty)); | 374 gc->translate(static_cast<float>(tx), static_cast<float>(ty)); |
| 370 gc->clip(r); | 375 gc->clip(r); |
| 371 | 376 |
| 372 // FIXME: Can we optimize scrolling to not require repainting the entire | 377 // FIXME: Can we optimize scrolling to not require repainting the entire |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 return IntRect(0, m_items[index]->yOffset, visibleWidth(), getRowHeight(inde
x)); | 669 return IntRect(0, m_items[index]->yOffset, visibleWidth(), getRowHeight(inde
x)); |
| 665 } | 670 } |
| 666 | 671 |
| 667 void PopupListBox::invalidateRow(int index) | 672 void PopupListBox::invalidateRow(int index) |
| 668 { | 673 { |
| 669 if (index < 0) | 674 if (index < 0) |
| 670 return; | 675 return; |
| 671 | 676 |
| 672 // Invalidate in the window contents, as FramelessScrollView::invalidateRect | 677 // Invalidate in the window contents, as FramelessScrollView::invalidateRect |
| 673 // paints in the window coordinates. | 678 // paints in the window coordinates. |
| 674 invalidateRect(contentsToWindow(getRowBounds(index))); | 679 IntRect clipRect = contentsToWindow(getRowBounds(index)); |
| 680 if (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar()) |
| 681 clipRect.move(verticalScrollbar()->width(), 0); |
| 682 invalidateRect(clipRect); |
| 675 } | 683 } |
| 676 | 684 |
| 677 void PopupListBox::scrollToRevealRow(int index) | 685 void PopupListBox::scrollToRevealRow(int index) |
| 678 { | 686 { |
| 679 if (index < 0) | 687 if (index < 0) |
| 680 return; | 688 return; |
| 681 | 689 |
| 682 IntRect rowRect = getRowBounds(index); | 690 IntRect rowRect = getRowBounds(index); |
| 683 | 691 |
| 684 if (rowRect.y() < scrollY()) { | 692 if (rowRect.y() < scrollY()) { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 { | 937 { |
| 930 return numItems() && IntRect(0, 0, width(), height()).contains(point); | 938 return numItems() && IntRect(0, 0, width(), height()).contains(point); |
| 931 } | 939 } |
| 932 | 940 |
| 933 int PopupListBox::popupContentHeight() const | 941 int PopupListBox::popupContentHeight() const |
| 934 { | 942 { |
| 935 return height(); | 943 return height(); |
| 936 } | 944 } |
| 937 | 945 |
| 938 } // namespace WebCore | 946 } // namespace WebCore |
| OLD | NEW |