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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 617 |
619 void RenderListBox::valueChanged(unsigned listIndex) | 618 void RenderListBox::valueChanged(unsigned listIndex) |
620 { | 619 { |
621 HTMLSelectElement* element = selectElement(); | 620 HTMLSelectElement* element = selectElement(); |
622 element->setSelectedIndex(element->listToOptionIndex(listIndex)); | 621 element->setSelectedIndex(element->listToOptionIndex(listIndex)); |
623 element->dispatchFormControlChangeEvent(); | 622 element->dispatchFormControlChangeEvent(); |
624 } | 623 } |
625 | 624 |
626 int RenderListBox::scrollSize(ScrollbarOrientation orientation) const | 625 int RenderListBox::scrollSize(ScrollbarOrientation orientation) const |
627 { | 626 { |
628 return ((orientation == VerticalScrollbar) && m_vBar) ? (m_vBar->totalSize()
- m_vBar->visibleSize()) : 0; | 627 return orientation == VerticalScrollbar ? (numItems() - numVisibleItems()) :
0; |
629 } | 628 } |
630 | 629 |
631 int RenderListBox::scrollPosition(Scrollbar*) const | 630 IntPoint RenderListBox::scrollPosition() const |
632 { | 631 { |
633 return m_indexOffset; | 632 return IntPoint(0, m_indexOffset); |
634 } | 633 } |
635 | 634 |
636 void RenderListBox::setScrollOffset(const IntPoint& offset) | 635 void RenderListBox::setScrollOffset(const IntPoint& offset) |
637 { | 636 { |
638 scrollTo(offset.y()); | 637 scrollTo(offset.y()); |
639 } | 638 } |
640 | 639 |
641 void RenderListBox::scrollTo(int newOffset) | 640 void RenderListBox::scrollTo(int newOffset) |
642 { | 641 { |
643 if (newOffset == m_indexOffset) | 642 if (newOffset == m_indexOffset) |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 827 } |
829 | 828 |
830 bool RenderListBox::scrollbarsCanBeActive() const | 829 bool RenderListBox::scrollbarsCanBeActive() const |
831 { | 830 { |
832 RenderView* view = this->view(); | 831 RenderView* view = this->view(); |
833 if (!view) | 832 if (!view) |
834 return false; | 833 return false; |
835 return view->frameView()->scrollbarsCanBeActive(); | 834 return view->frameView()->scrollbarsCanBeActive(); |
836 } | 835 } |
837 | 836 |
| 837 IntPoint RenderListBox::minimumScrollPosition() const |
| 838 { |
| 839 return IntPoint(); |
| 840 } |
| 841 |
838 IntPoint RenderListBox::maximumScrollPosition() const | 842 IntPoint RenderListBox::maximumScrollPosition() const |
839 { | 843 { |
840 return IntPoint(0, numItems() - numVisibleItems()); | 844 return IntPoint(0, numItems() - numVisibleItems()); |
841 } | 845 } |
842 | 846 |
| 847 bool RenderListBox::userInputScrollable(ScrollbarOrientation orientation) const |
| 848 { |
| 849 return orientation == VerticalScrollbar; |
| 850 } |
| 851 |
| 852 int RenderListBox::lineStep(ScrollbarOrientation) const |
| 853 { |
| 854 return 1; |
| 855 } |
| 856 |
| 857 int RenderListBox::pageStep(ScrollbarOrientation orientation) const |
| 858 { |
| 859 return max(1, numVisibleItems() - 1); |
| 860 } |
| 861 |
| 862 float RenderListBox::pixelStep(ScrollbarOrientation) const |
| 863 { |
| 864 return 1.0f / itemHeight(); |
| 865 } |
| 866 |
843 ScrollableArea* RenderListBox::enclosingScrollableArea() const | 867 ScrollableArea* RenderListBox::enclosingScrollableArea() const |
844 { | 868 { |
845 // FIXME: Return a RenderLayer that's scrollable. | 869 // FIXME: Return a RenderLayer that's scrollable. |
846 return 0; | 870 return 0; |
847 } | 871 } |
848 | 872 |
849 IntRect RenderListBox::scrollableAreaBoundingBox() const | 873 IntRect RenderListBox::scrollableAreaBoundingBox() const |
850 { | 874 { |
851 return absoluteBoundingBoxRect(); | 875 return absoluteBoundingBoxRect(); |
852 } | 876 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 913 |
890 if (m_vBar) | 914 if (m_vBar) |
891 m_vBar->styleChanged(); | 915 m_vBar->styleChanged(); |
892 | 916 |
893 // Force an update since we know the scrollbars have changed things. | 917 // Force an update since we know the scrollbars have changed things. |
894 if (document()->hasAnnotatedRegions()) | 918 if (document()->hasAnnotatedRegions()) |
895 document()->setAnnotatedRegionsDirty(true); | 919 document()->setAnnotatedRegionsDirty(true); |
896 } | 920 } |
897 | 921 |
898 } // namespace WebCore | 922 } // namespace WebCore |
OLD | NEW |