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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 ASSERT(element->hasTagName(HTMLNames::selectTag)); | 93 ASSERT(element->hasTagName(HTMLNames::selectTag)); |
94 | 94 |
95 if (FrameView* frameView = frame()->view()) | 95 if (FrameView* frameView = frame()->view()) |
96 frameView->addScrollableArea(this); | 96 frameView->addScrollableArea(this); |
97 } | 97 } |
98 | 98 |
99 RenderListBox::~RenderListBox() | 99 RenderListBox::~RenderListBox() |
100 { | 100 { |
101 setHasVerticalScrollbar(false); | 101 setHasVerticalScrollbar(false); |
102 | 102 |
103 if (FrameView* frameView = frame()->view()) | 103 if (FrameView* frameView = frame()->view()) { |
104 frameView->removeScrollableArea(this); | 104 frameView->removeScrollableArea(this); |
| 105 frameView->removeAnimatingScrollableArea(this); |
| 106 } |
105 } | 107 } |
106 | 108 |
107 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no in
sertion point | 109 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no in
sertion point |
108 // to prevent children from rendering. | 110 // to prevent children from rendering. |
109 bool RenderListBox::isChildAllowed(RenderObject* object, RenderStyle*) const | 111 bool RenderListBox::isChildAllowed(RenderObject* object, RenderStyle*) const |
110 { | 112 { |
111 return object->isAnonymous() && !object->isRenderFullScreen(); | 113 return object->isAnonymous() && !object->isRenderFullScreen(); |
112 } | 114 } |
113 | 115 |
114 inline HTMLSelectElement* RenderListBox::selectElement() const | 116 inline HTMLSelectElement* RenderListBox::selectElement() const |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 int RenderListBox::scrollHeight() const | 692 int RenderListBox::scrollHeight() const |
691 { | 693 { |
692 return max(pixelSnappedClientHeight(), roundToInt(listHeight())); | 694 return max(pixelSnappedClientHeight(), roundToInt(listHeight())); |
693 } | 695 } |
694 | 696 |
695 int RenderListBox::scrollLeft() const | 697 int RenderListBox::scrollLeft() const |
696 { | 698 { |
697 return 0; | 699 return 0; |
698 } | 700 } |
699 | 701 |
700 void RenderListBox::setScrollLeft(int) | 702 void RenderListBox::setScrollLeft(int, ScrollBehavior) |
701 { | 703 { |
702 } | 704 } |
703 | 705 |
704 int RenderListBox::scrollTop() const | 706 int RenderListBox::scrollTop() const |
705 { | 707 { |
706 return m_indexOffset * itemHeight(); | 708 return m_indexOffset * itemHeight(); |
707 } | 709 } |
708 | 710 |
709 void RenderListBox::setScrollTop(int newTop) | 711 void RenderListBox::setScrollTop(int newTop, ScrollBehavior scrollBehavior) |
710 { | 712 { |
| 713 cancelProgrammaticScrollAnimation(); |
| 714 |
711 // Determine an index and scroll to it. | 715 // Determine an index and scroll to it. |
712 int index = newTop / itemHeight(); | 716 int index = newTop / itemHeight(); |
713 if (index < 0 || index >= numItems() || index == m_indexOffset) | 717 if (index < 0 || index >= numItems() || index == m_indexOffset) |
714 return; | 718 return; |
715 | 719 |
716 scrollToOffsetWithoutAnimation(VerticalScrollbar, index); | 720 if (scrollBehavior == ScrollBehaviorAuto) |
| 721 scrollBehavior = style()->scrollBehavior(); |
| 722 if (scrollBehavior == ScrollBehaviorSmooth) |
| 723 programmaticallyScrollSmoothlyToOffset(FloatPoint(0, index)); |
| 724 else |
| 725 scrollToOffsetWithoutAnimation(VerticalScrollbar, index); |
717 } | 726 } |
718 | 727 |
719 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, HitTestAction hitTestAction) | 728 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, HitTestAction hitTestAction) |
720 { | 729 { |
721 if (!RenderBlock::nodeAtPoint(request, result, locationInContainer, accumula
tedOffset, hitTestAction)) | 730 if (!RenderBlock::nodeAtPoint(request, result, locationInContainer, accumula
tedOffset, hitTestAction)) |
722 return false; | 731 return false; |
723 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 732 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
724 int size = numItems(); | 733 int size = numItems(); |
725 LayoutPoint adjustedLocation = accumulatedOffset + location(); | 734 LayoutPoint adjustedLocation = accumulatedOffset + location(); |
726 | 735 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 } | 875 } |
867 | 876 |
868 bool RenderListBox::scrollbarsCanBeActive() const | 877 bool RenderListBox::scrollbarsCanBeActive() const |
869 { | 878 { |
870 RenderView* view = this->view(); | 879 RenderView* view = this->view(); |
871 if (!view) | 880 if (!view) |
872 return false; | 881 return false; |
873 return view->frameView()->scrollbarsCanBeActive(); | 882 return view->frameView()->scrollbarsCanBeActive(); |
874 } | 883 } |
875 | 884 |
| 885 bool RenderListBox::registerForAnimation() |
| 886 { |
| 887 if (FrameView* frameView = frame()->view()) |
| 888 return frameView->addAnimatingScrollableArea(this); |
| 889 return false; |
| 890 } |
| 891 |
| 892 void RenderListBox::deregisterForAnimation() |
| 893 { |
| 894 if (FrameView* frameView = frame()->view()) |
| 895 frameView->removeAnimatingScrollableArea(this); |
| 896 } |
| 897 |
| 898 bool RenderListBox::scheduleAnimation() |
| 899 { |
| 900 if (FrameView* frameView = frame()->view()) |
| 901 return frameView->scheduleAnimation(); |
| 902 return false; |
| 903 } |
| 904 |
876 IntPoint RenderListBox::minimumScrollPosition() const | 905 IntPoint RenderListBox::minimumScrollPosition() const |
877 { | 906 { |
878 return IntPoint(); | 907 return IntPoint(); |
879 } | 908 } |
880 | 909 |
881 IntPoint RenderListBox::maximumScrollPosition() const | 910 IntPoint RenderListBox::maximumScrollPosition() const |
882 { | 911 { |
883 return IntPoint(0, std::max(numItems() - numVisibleItems(), 0)); | 912 return IntPoint(0, std::max(numItems() - numVisibleItems(), 0)); |
884 } | 913 } |
885 | 914 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 | 986 |
958 if (m_vBar) | 987 if (m_vBar) |
959 m_vBar->styleChanged(); | 988 m_vBar->styleChanged(); |
960 | 989 |
961 // Force an update since we know the scrollbars have changed things. | 990 // Force an update since we know the scrollbars have changed things. |
962 if (document().hasAnnotatedRegions()) | 991 if (document().hasAnnotatedRegions()) |
963 document().setAnnotatedRegionsDirty(true); | 992 document().setAnnotatedRegionsDirty(true); |
964 } | 993 } |
965 | 994 |
966 } // namespace WebCore | 995 } // namespace WebCore |
OLD | NEW |