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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 selectIndex(index); | 342 selectIndex(index); |
343 return; | 343 return; |
344 } | 344 } |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) | 348 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) |
349 { | 349 { |
350 // Adjust coords for scrolled frame. | 350 // Adjust coords for scrolled frame. |
351 IntRect r = intersection(rect, frameRect()); | 351 IntRect r = intersection(rect, frameRect()); |
352 int tx = x() - scrollX() + ((shouldPlaceVerticalScrollbarOnLeft() && vertica
lScrollbar()) ? verticalScrollbar()->width() : 0); | 352 int tx = x() - scrollX() + ((shouldPlaceVerticalScrollbarOnLeft() && vertica
lScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) ? verticalScrollbar(
)->width() : 0); |
353 int ty = y() - scrollY(); | 353 int ty = y() - scrollY(); |
354 | 354 |
355 r.move(-tx, -ty); | 355 r.move(-tx, -ty); |
356 | 356 |
357 // Set clip rect to match revised damage rect. | 357 // Set clip rect to match revised damage rect. |
358 gc->save(); | 358 gc->save(); |
359 gc->translate(static_cast<float>(tx), static_cast<float>(ty)); | 359 gc->translate(static_cast<float>(tx), static_cast<float>(ty)); |
360 gc->clip(r); | 360 gc->clip(r); |
361 | 361 |
362 // FIXME: Can we optimize scrolling to not require repainting the entire | 362 // FIXME: Can we optimize scrolling to not require repainting the entire |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 } | 589 } |
590 | 590 |
591 void PopupListBox::invalidateRow(int index) | 591 void PopupListBox::invalidateRow(int index) |
592 { | 592 { |
593 if (index < 0) | 593 if (index < 0) |
594 return; | 594 return; |
595 | 595 |
596 // Invalidate in the window contents, as FramelessScrollView::invalidateRect | 596 // Invalidate in the window contents, as FramelessScrollView::invalidateRect |
597 // paints in the window coordinates. | 597 // paints in the window coordinates. |
598 IntRect clipRect = contentsToWindow(getRowBounds(index)); | 598 IntRect clipRect = contentsToWindow(getRowBounds(index)); |
599 if (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar()) | 599 if (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar() && !vertical
Scrollbar()->isOverlayScrollbar()) |
600 clipRect.move(verticalScrollbar()->width(), 0); | 600 clipRect.move(verticalScrollbar()->width(), 0); |
601 invalidateRect(clipRect); | 601 invalidateRect(clipRect); |
602 } | 602 } |
603 | 603 |
604 void PopupListBox::scrollToRevealRow(int index) | 604 void PopupListBox::scrollToRevealRow(int index) |
605 { | 605 { |
606 if (index < 0) | 606 if (index < 0) |
607 return; | 607 return; |
608 | 608 |
609 IntRect rowRect = getRowBounds(index); | 609 IntRect rowRect = getRowBounds(index); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 m_visibleRows = i; | 766 m_visibleRows = i; |
767 break; | 767 break; |
768 } | 768 } |
769 | 769 |
770 windowHeight += rowHeight; | 770 windowHeight += rowHeight; |
771 } | 771 } |
772 | 772 |
773 // Set our widget and scrollable contents sizes. | 773 // Set our widget and scrollable contents sizes. |
774 int scrollbarWidth = 0; | 774 int scrollbarWidth = 0; |
775 if (m_visibleRows < numItems()) { | 775 if (m_visibleRows < numItems()) { |
776 scrollbarWidth = ScrollbarTheme::theme()->scrollbarThickness(); | 776 if (!ScrollbarTheme::theme()->usesOverlayScrollbars()) |
| 777 scrollbarWidth = ScrollbarTheme::theme()->scrollbarThickness(); |
777 | 778 |
778 // Use minEndOfLinePadding when there is a scrollbar so that we use | 779 // Use minEndOfLinePadding when there is a scrollbar so that we use |
779 // as much as (lineEndPaddingWidth - minEndOfLinePadding) padding | 780 // as much as (lineEndPaddingWidth - minEndOfLinePadding) padding |
780 // space for scrollbar and allow user to use CSS padding to make the | 781 // space for scrollbar and allow user to use CSS padding to make the |
781 // popup listbox align with the select element. | 782 // popup listbox align with the select element. |
782 paddingWidth = paddingWidth - lineEndPaddingWidth + minEndOfLinePadding; | 783 paddingWidth = paddingWidth - lineEndPaddingWidth + minEndOfLinePadding; |
783 } | 784 } |
784 | 785 |
785 int windowWidth = baseWidth + scrollbarWidth + paddingWidth; | 786 int windowWidth = baseWidth + scrollbarWidth + paddingWidth; |
786 if (windowWidth > m_maxWindowWidth) { | 787 if (windowWidth > m_maxWindowWidth) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 { | 819 { |
819 return numItems() && IntRect(0, 0, width(), height()).contains(point); | 820 return numItems() && IntRect(0, 0, width(), height()).contains(point); |
820 } | 821 } |
821 | 822 |
822 int PopupListBox::popupContentHeight() const | 823 int PopupListBox::popupContentHeight() const |
823 { | 824 { |
824 return height(); | 825 return height(); |
825 } | 826 } |
826 | 827 |
827 } // namespace blink | 828 } // namespace blink |
OLD | NEW |