OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 void RenderListBox::layout() | 171 void RenderListBox::layout() |
172 { | 172 { |
173 StackStats::LayoutCheckPoint layoutCheckPoint; | 173 StackStats::LayoutCheckPoint layoutCheckPoint; |
174 RenderBlock::layout(); | 174 RenderBlock::layout(); |
175 | 175 |
176 if (m_vBar) { | 176 if (m_vBar) { |
177 bool enabled = numVisibleItems() < numItems(); | 177 bool enabled = numVisibleItems() < numItems(); |
178 m_vBar->setEnabled(enabled); | 178 m_vBar->setEnabled(enabled); |
179 m_vBar->setSteps(1, max(1, numVisibleItems() - 1), itemHeight()); | |
180 m_vBar->setProportion(numVisibleItems(), numItems()); | 179 m_vBar->setProportion(numVisibleItems(), numItems()); |
181 if (!enabled) { | 180 if (!enabled) { |
182 scrollToOffsetWithoutAnimation(VerticalScrollbar, 0); | 181 scrollToOffsetWithoutAnimation(VerticalScrollbar, 0); |
183 m_indexOffset = 0; | 182 m_indexOffset = 0; |
184 } | 183 } |
185 } | 184 } |
186 | 185 |
187 if (m_scrollToRevealSelectionAfterLayout) { | 186 if (m_scrollToRevealSelectionAfterLayout) { |
188 LayoutStateDisabler layoutStateDisabler(view()); | 187 LayoutStateDisabler layoutStateDisabler(view()); |
189 scrollToRevealSelection(); | 188 scrollToRevealSelection(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 616 |
618 void RenderListBox::valueChanged(unsigned listIndex) | 617 void RenderListBox::valueChanged(unsigned listIndex) |
619 { | 618 { |
620 HTMLSelectElement* element = selectElement(); | 619 HTMLSelectElement* element = selectElement(); |
621 element->setSelectedIndex(element->listToOptionIndex(listIndex)); | 620 element->setSelectedIndex(element->listToOptionIndex(listIndex)); |
622 element->dispatchFormControlChangeEvent(); | 621 element->dispatchFormControlChangeEvent(); |
623 } | 622 } |
624 | 623 |
625 int RenderListBox::scrollSize(ScrollbarOrientation orientation) const | 624 int RenderListBox::scrollSize(ScrollbarOrientation orientation) const |
626 { | 625 { |
627 return ((orientation == VerticalScrollbar) && m_vBar) ? (m_vBar->totalSize()
- m_vBar->visibleSize()) : 0; | 626 return orientation == VerticalScrollbar ? (numItems() - numVisibleItems()) :
0; |
628 } | 627 } |
629 | 628 |
630 int RenderListBox::scrollPosition(Scrollbar*) const | 629 IntPoint RenderListBox::scrollPosition() const |
631 { | 630 { |
632 return m_indexOffset; | 631 return IntPoint(0, m_indexOffset); |
633 } | 632 } |
634 | 633 |
635 void RenderListBox::setScrollOffset(const IntPoint& offset) | 634 void RenderListBox::setScrollOffset(const IntPoint& offset) |
636 { | 635 { |
637 scrollTo(offset.y()); | 636 scrollTo(offset.y()); |
638 } | 637 } |
639 | 638 |
640 void RenderListBox::scrollTo(int newOffset) | 639 void RenderListBox::scrollTo(int newOffset) |
641 { | 640 { |
642 if (newOffset == m_indexOffset) | 641 if (newOffset == m_indexOffset) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 if (!view) | 831 if (!view) |
833 return false; | 832 return false; |
834 return view->frameView()->scrollbarsCanBeActive(); | 833 return view->frameView()->scrollbarsCanBeActive(); |
835 } | 834 } |
836 | 835 |
837 IntPoint RenderListBox::maximumScrollPosition() const | 836 IntPoint RenderListBox::maximumScrollPosition() const |
838 { | 837 { |
839 return IntPoint(0, numItems() - numVisibleItems()); | 838 return IntPoint(0, numItems() - numVisibleItems()); |
840 } | 839 } |
841 | 840 |
| 841 bool RenderListBox::userInputScrollable(ScrollbarOrientation orientation) const |
| 842 { |
| 843 return orientation == VerticalScrollbar; |
| 844 } |
| 845 |
| 846 int RenderListBox::lineStep(ScrollbarOrientation) const |
| 847 { |
| 848 return 1; |
| 849 } |
| 850 |
| 851 int RenderListBox::pageStep(ScrollbarOrientation orientation) const |
| 852 { |
| 853 return max(1, numVisibleItems() - 1); |
| 854 } |
| 855 |
| 856 float RenderListBox::pixelStep(ScrollbarOrientation) const |
| 857 { |
| 858 return 1.0f / itemHeight(); |
| 859 } |
| 860 |
842 ScrollableArea* RenderListBox::enclosingScrollableArea() const | 861 ScrollableArea* RenderListBox::enclosingScrollableArea() const |
843 { | 862 { |
844 // FIXME: Return a RenderLayer that's scrollable. | 863 // FIXME: Return a RenderLayer that's scrollable. |
845 return 0; | 864 return 0; |
846 } | 865 } |
847 | 866 |
848 IntRect RenderListBox::scrollableAreaBoundingBox() const | 867 IntRect RenderListBox::scrollableAreaBoundingBox() const |
849 { | 868 { |
850 return absoluteBoundingBoxRect(); | 869 return absoluteBoundingBoxRect(); |
851 } | 870 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 907 |
889 if (m_vBar) | 908 if (m_vBar) |
890 m_vBar->styleChanged(); | 909 m_vBar->styleChanged(); |
891 | 910 |
892 // Force an update since we know the scrollbars have changed things. | 911 // Force an update since we know the scrollbars have changed things. |
893 if (document()->hasAnnotatedRegions()) | 912 if (document()->hasAnnotatedRegions()) |
894 document()->setAnnotatedRegionsDirty(true); | 913 document()->setAnnotatedRegionsDirty(true); |
895 } | 914 } |
896 | 915 |
897 } // namespace WebCore | 916 } // namespace WebCore |
OLD | NEW |