| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 } | 826 } |
| 828 | 827 |
| 829 bool RenderListBox::scrollbarsCanBeActive() const | 828 bool RenderListBox::scrollbarsCanBeActive() const |
| 830 { | 829 { |
| 831 RenderView* view = this->view(); | 830 RenderView* view = this->view(); |
| 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 |
| 836 IntPoint RenderListBox::minimumScrollPosition() const |
| 837 { |
| 838 return IntPoint(); |
| 839 } |
| 840 |
| 837 IntPoint RenderListBox::maximumScrollPosition() const | 841 IntPoint RenderListBox::maximumScrollPosition() const |
| 838 { | 842 { |
| 839 return IntPoint(0, numItems() - numVisibleItems()); | 843 return IntPoint(0, numItems() - numVisibleItems()); |
| 840 } | 844 } |
| 841 | 845 |
| 846 bool RenderListBox::userInputScrollable(ScrollbarOrientation orientation) const |
| 847 { |
| 848 return orientation == VerticalScrollbar; |
| 849 } |
| 850 |
| 851 int RenderListBox::lineStep(ScrollbarOrientation) const |
| 852 { |
| 853 return 1; |
| 854 } |
| 855 |
| 856 int RenderListBox::pageStep(ScrollbarOrientation orientation) const |
| 857 { |
| 858 return max(1, numVisibleItems() - 1); |
| 859 } |
| 860 |
| 861 float RenderListBox::pixelStep(ScrollbarOrientation) const |
| 862 { |
| 863 return 1.0f / itemHeight(); |
| 864 } |
| 865 |
| 842 ScrollableArea* RenderListBox::enclosingScrollableArea() const | 866 ScrollableArea* RenderListBox::enclosingScrollableArea() const |
| 843 { | 867 { |
| 844 // FIXME: Return a RenderLayer that's scrollable. | 868 // FIXME: Return a RenderLayer that's scrollable. |
| 845 return 0; | 869 return 0; |
| 846 } | 870 } |
| 847 | 871 |
| 848 IntRect RenderListBox::scrollableAreaBoundingBox() const | 872 IntRect RenderListBox::scrollableAreaBoundingBox() const |
| 849 { | 873 { |
| 850 return absoluteBoundingBoxRect(); | 874 return absoluteBoundingBoxRect(); |
| 851 } | 875 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 912 |
| 889 if (m_vBar) | 913 if (m_vBar) |
| 890 m_vBar->styleChanged(); | 914 m_vBar->styleChanged(); |
| 891 | 915 |
| 892 // Force an update since we know the scrollbars have changed things. | 916 // Force an update since we know the scrollbars have changed things. |
| 893 if (document()->hasAnnotatedRegions()) | 917 if (document()->hasAnnotatedRegions()) |
| 894 document()->setAnnotatedRegionsDirty(true); | 918 document()->setAnnotatedRegionsDirty(true); |
| 895 } | 919 } |
| 896 | 920 |
| 897 } // namespace WebCore | 921 } // namespace WebCore |
| OLD | NEW |