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 int RenderListBox::scrollPosition(Scrollbar*) const |
631 { | 630 { |
632 return m_indexOffset; | 631 return m_indexOffset; |
633 } | 632 } |
634 | 633 |
634 IntPoint RenderListBox::scrollPosition() const | |
635 { | |
636 int x = 0; | |
637 int y = m_indexOffset; | |
638 return IntPoint(x, y); | |
aelias_OOO_until_Jul13
2013/06/19 22:25:12
nit: return IntPoint(0, m_indexOffset);
bokan
2013/06/19 23:50:58
Done.
| |
639 } | |
640 | |
635 void RenderListBox::setScrollOffset(const IntPoint& offset) | 641 void RenderListBox::setScrollOffset(const IntPoint& offset) |
636 { | 642 { |
637 scrollTo(offset.y()); | 643 scrollTo(offset.y()); |
638 } | 644 } |
639 | 645 |
640 void RenderListBox::scrollTo(int newOffset) | 646 void RenderListBox::scrollTo(int newOffset) |
641 { | 647 { |
642 if (newOffset == m_indexOffset) | 648 if (newOffset == m_indexOffset) |
643 return; | 649 return; |
644 | 650 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 if (!view) | 838 if (!view) |
833 return false; | 839 return false; |
834 return view->frameView()->scrollbarsCanBeActive(); | 840 return view->frameView()->scrollbarsCanBeActive(); |
835 } | 841 } |
836 | 842 |
837 IntPoint RenderListBox::maximumScrollPosition() const | 843 IntPoint RenderListBox::maximumScrollPosition() const |
838 { | 844 { |
839 return IntPoint(0, numItems() - numVisibleItems()); | 845 return IntPoint(0, numItems() - numVisibleItems()); |
840 } | 846 } |
841 | 847 |
848 bool RenderListBox::userInputScrollable(ScrollbarOrientation orientation) const | |
849 { | |
850 return orientation == VerticalScrollbar; | |
851 } | |
852 | |
853 int RenderListBox::lineStep(ScrollbarOrientation) const | |
854 { | |
855 return 1; | |
856 } | |
857 | |
858 int RenderListBox::pageStep(ScrollbarOrientation orientation) const | |
859 { | |
860 return max(1, numVisibleItems() - 1); | |
861 } | |
862 | |
863 float RenderListBox::pixelStep(ScrollbarOrientation) const | |
864 { | |
865 return 1.0f / itemHeight(); | |
866 } | |
867 | |
842 ScrollableArea* RenderListBox::enclosingScrollableArea() const | 868 ScrollableArea* RenderListBox::enclosingScrollableArea() const |
843 { | 869 { |
844 // FIXME: Return a RenderLayer that's scrollable. | 870 // FIXME: Return a RenderLayer that's scrollable. |
845 return 0; | 871 return 0; |
846 } | 872 } |
847 | 873 |
848 IntRect RenderListBox::scrollableAreaBoundingBox() const | 874 IntRect RenderListBox::scrollableAreaBoundingBox() const |
849 { | 875 { |
850 return absoluteBoundingBoxRect(); | 876 return absoluteBoundingBoxRect(); |
851 } | 877 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 | 914 |
889 if (m_vBar) | 915 if (m_vBar) |
890 m_vBar->styleChanged(); | 916 m_vBar->styleChanged(); |
891 | 917 |
892 // Force an update since we know the scrollbars have changed things. | 918 // Force an update since we know the scrollbars have changed things. |
893 if (document()->hasAnnotatedRegions()) | 919 if (document()->hasAnnotatedRegions()) |
894 document()->setAnnotatedRegionsDirty(true); | 920 document()->setAnnotatedRegionsDirty(true); |
895 } | 921 } |
896 | 922 |
897 } // namespace WebCore | 923 } // namespace WebCore |
OLD | NEW |