Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: Source/core/rendering/RenderListBox.cpp

Issue 134443003: Implement CSSOM Smooth Scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ASSERT(isHTMLSelectElement(element)); 92 ASSERT(isHTMLSelectElement(element));
93 93
94 if (FrameView* frameView = frame()->view()) 94 if (FrameView* frameView = frame()->view())
95 frameView->addScrollableArea(this); 95 frameView->addScrollableArea(this);
96 } 96 }
97 97
98 RenderListBox::~RenderListBox() 98 RenderListBox::~RenderListBox()
99 { 99 {
100 setHasVerticalScrollbar(false); 100 setHasVerticalScrollbar(false);
101 101
102 if (FrameView* frameView = frame()->view()) 102 if (FrameView* frameView = frame()->view()) {
103 frameView->removeScrollableArea(this); 103 frameView->removeScrollableArea(this);
104 frameView->removeAnimatingScrollableArea(this);
105 }
104 } 106 }
105 107
106 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no in sertion point 108 // FIXME: Instead of this hack we should add a ShadowRoot to <select> with no in sertion point
107 // to prevent children from rendering. 109 // to prevent children from rendering.
108 bool RenderListBox::isChildAllowed(RenderObject* object, RenderStyle*) const 110 bool RenderListBox::isChildAllowed(RenderObject* object, RenderStyle*) const
109 { 111 {
110 return object->isAnonymous() && !object->isRenderFullScreen(); 112 return object->isAnonymous() && !object->isRenderFullScreen();
111 } 113 }
112 114
113 inline HTMLSelectElement* RenderListBox::selectElement() const 115 inline HTMLSelectElement* RenderListBox::selectElement() const
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 LayoutUnit RenderListBox::scrollHeight() const 704 LayoutUnit RenderListBox::scrollHeight() const
703 { 705 {
704 return std::max(clientHeight(), listHeight()); 706 return std::max(clientHeight(), listHeight());
705 } 707 }
706 708
707 LayoutUnit RenderListBox::scrollLeft() const 709 LayoutUnit RenderListBox::scrollLeft() const
708 { 710 {
709 return 0; 711 return 0;
710 } 712 }
711 713
712 void RenderListBox::setScrollLeft(LayoutUnit) 714 void RenderListBox::setScrollLeft(LayoutUnit, ScrollBehavior)
713 { 715 {
714 } 716 }
715 717
716 LayoutUnit RenderListBox::scrollTop() const 718 LayoutUnit RenderListBox::scrollTop() const
717 { 719 {
718 return m_indexOffset * itemHeight(); 720 return m_indexOffset * itemHeight();
719 } 721 }
720 722
721 void RenderListBox::setScrollTop(LayoutUnit newTop) 723 void RenderListBox::setScrollTop(LayoutUnit newTop, ScrollBehavior scrollBehavio r)
722 { 724 {
725 cancelProgrammaticScrollAnimation();
726
723 // Determine an index and scroll to it. 727 // Determine an index and scroll to it.
724 int index = newTop / itemHeight(); 728 int index = newTop / itemHeight();
725 if (index < 0 || index >= numItems() || index == m_indexOffset) 729 if (index < 0 || index >= numItems() || index == m_indexOffset)
726 return; 730 return;
727 731
728 scrollToOffsetWithoutAnimation(VerticalScrollbar, index); 732 if (scrollBehavior == ScrollBehaviorAuto)
733 scrollBehavior = style()->scrollBehavior();
734 if (scrollBehavior == ScrollBehaviorSmooth)
735 programmaticallyScrollSmoothlyToOffset(FloatPoint(0, index));
736 else
737 scrollToOffsetWithoutAnimation(VerticalScrollbar, index);
729 } 738 }
730 739
731 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction) 740 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction)
732 { 741 {
733 if (!RenderBlockFlow::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, hitTestAction)) 742 if (!RenderBlockFlow::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, hitTestAction))
734 return false; 743 return false;
735 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select Element()->listItems(); 744 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select Element()->listItems();
736 int size = numItems(); 745 int size = numItems();
737 LayoutPoint adjustedLocation = accumulatedOffset + location(); 746 LayoutPoint adjustedLocation = accumulatedOffset + location();
738 747
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } 887 }
879 888
880 bool RenderListBox::scrollbarsCanBeActive() const 889 bool RenderListBox::scrollbarsCanBeActive() const
881 { 890 {
882 RenderView* view = this->view(); 891 RenderView* view = this->view();
883 if (!view) 892 if (!view)
884 return false; 893 return false;
885 return view->frameView()->scrollbarsCanBeActive(); 894 return view->frameView()->scrollbarsCanBeActive();
886 } 895 }
887 896
897 void RenderListBox::registerForAnimation()
898 {
899 frameView()->addAnimatingScrollableArea(this);
900 }
901
902 void RenderListBox::deregisterForAnimation()
903 {
904 if (FrameView* frameView = this->frameView())
905 frameView->removeAnimatingScrollableArea(this);
906 }
907
908 bool RenderListBox::scheduleAnimation()
909 {
910 return frameView()->scheduleAnimation();
911 }
912
888 IntPoint RenderListBox::minimumScrollPosition() const 913 IntPoint RenderListBox::minimumScrollPosition() const
889 { 914 {
890 return IntPoint(); 915 return IntPoint();
891 } 916 }
892 917
893 IntPoint RenderListBox::maximumScrollPosition() const 918 IntPoint RenderListBox::maximumScrollPosition() const
894 { 919 {
895 return IntPoint(0, std::max(numItems() - numVisibleItems(), 0)); 920 return IntPoint(0, std::max(numItems() - numVisibleItems(), 0));
896 } 921 }
897 922
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 { 1043 {
1019 return itemBoundingBoxRectInternal(point, listIndexToRenderListBoxIndex(inde x)); 1044 return itemBoundingBoxRectInternal(point, listIndexToRenderListBoxIndex(inde x));
1020 } 1045 }
1021 1046
1022 bool RenderListBox::scrollToRevealElementAtListIndex(int index) 1047 bool RenderListBox::scrollToRevealElementAtListIndex(int index)
1023 { 1048 {
1024 return scrollToRevealElementAtListIndexInternal(listIndexToRenderListBoxInde x(index)); 1049 return scrollToRevealElementAtListIndexInternal(listIndexToRenderListBoxInde x(index));
1025 } 1050 }
1026 1051
1027 } // namespace WebCore 1052 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderListBox.h ('k') | Source/core/rendering/RenderTextControlSingleLine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698