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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 146003002: Bindings for CSSOM View smooth scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments Created 6 years, 10 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
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 12 matching lines...) Expand all
23 * Boston, MA 02110-1301, USA. 23 * Boston, MA 02110-1301, USA.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/dom/Element.h" 27 #include "core/dom/Element.h"
28 28
29 #include "CSSValueKeywords.h" 29 #include "CSSValueKeywords.h"
30 #include "RuntimeEnabledFeatures.h" 30 #include "RuntimeEnabledFeatures.h"
31 #include "SVGNames.h" 31 #include "SVGNames.h"
32 #include "XMLNames.h" 32 #include "XMLNames.h"
33 #include "bindings/v8/Dictionary.h"
33 #include "bindings/v8/ExceptionState.h" 34 #include "bindings/v8/ExceptionState.h"
34 #include "core/accessibility/AXObjectCache.h" 35 #include "core/accessibility/AXObjectCache.h"
35 #include "core/animation/DocumentTimeline.h" 36 #include "core/animation/DocumentTimeline.h"
36 #include "core/animation/css/CSSAnimations.h" 37 #include "core/animation/css/CSSAnimations.h"
37 #include "core/css/CSSStyleSheet.h" 38 #include "core/css/CSSStyleSheet.h"
38 #include "core/css/CSSValuePool.h" 39 #include "core/css/CSSValuePool.h"
39 #include "core/css/PropertySetCSSStyleDeclaration.h" 40 #include "core/css/PropertySetCSSStyleDeclaration.h"
40 #include "core/css/StylePropertySet.h" 41 #include "core/css/StylePropertySet.h"
41 #include "core/css/parser/BisonCSSParser.h" 42 #include "core/css/parser/BisonCSSParser.h"
42 #include "core/css/resolver/StyleResolver.h" 43 #include "core/css/resolver/StyleResolver.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "core/inspector/InspectorInstrumentation.h" 89 #include "core/inspector/InspectorInstrumentation.h"
89 #include "core/page/FocusController.h" 90 #include "core/page/FocusController.h"
90 #include "core/page/Page.h" 91 #include "core/page/Page.h"
91 #include "core/page/PointerLockController.h" 92 #include "core/page/PointerLockController.h"
92 #include "core/rendering/FlowThreadController.h" 93 #include "core/rendering/FlowThreadController.h"
93 #include "core/rendering/RenderNamedFlowFragment.h" 94 #include "core/rendering/RenderNamedFlowFragment.h"
94 #include "core/rendering/RenderView.h" 95 #include "core/rendering/RenderView.h"
95 #include "core/rendering/RenderWidget.h" 96 #include "core/rendering/RenderWidget.h"
96 #include "core/svg/SVGDocumentExtensions.h" 97 #include "core/svg/SVGDocumentExtensions.h"
97 #include "core/svg/SVGElement.h" 98 #include "core/svg/SVGElement.h"
99 #include "platform/scroll/ScrollableArea.h"
98 #include "wtf/BitVector.h" 100 #include "wtf/BitVector.h"
99 #include "wtf/HashFunctions.h" 101 #include "wtf/HashFunctions.h"
100 #include "wtf/text/CString.h" 102 #include "wtf/text/CString.h"
101 #include "wtf/text/StringBuilder.h" 103 #include "wtf/text/StringBuilder.h"
102 #include "wtf/text/TextPosition.h" 104 #include "wtf/text/TextPosition.h"
103 105
104 namespace WebCore { 106 namespace WebCore {
105 107
106 using namespace HTMLNames; 108 using namespace HTMLNames;
107 using namespace XMLNames; 109 using namespace XMLNames;
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 if (!frame) 739 if (!frame)
738 return; 740 return;
739 FrameView* view = frame->view(); 741 FrameView* view = frame->view();
740 if (!view) 742 if (!view)
741 return; 743 return;
742 744
743 view->setScrollPosition(IntPoint(static_cast<int>(newLeft * frame->pageZ oomFactor()), view->scrollY())); 745 view->setScrollPosition(IntPoint(static_cast<int>(newLeft * frame->pageZ oomFactor()), view->scrollY()));
744 } 746 }
745 } 747 }
746 748
749 void Element::setScrollLeft(const Dictionary& scrollOptionsHorizontal, Exception State& exceptionState)
750 {
751 String scrollBehaviorString;
752 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
753 if (scrollOptionsHorizontal.get("behavior", scrollBehaviorString)) {
754 if (!ScrollableArea::scrollBehaviorFromString(scrollBehaviorString, scro llBehavior)) {
755 exceptionState.throwTypeError("The ScrollBehavior provided is invali d.");
756 return;
757 }
758 }
759
760 int position;
761 if (!scrollOptionsHorizontal.get("x", position)) {
762 exceptionState.throwTypeError("ScrollOptionsHorizontal must include an ' x' member.");
763 return;
764 }
765
766 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant ly.
767 setScrollLeft(position);
768 }
769
747 void Element::setScrollTop(int newTop) 770 void Element::setScrollTop(int newTop)
748 { 771 {
749 document().updateLayoutIgnorePendingStylesheets(); 772 document().updateLayoutIgnorePendingStylesheets();
750 773
751 if (document().documentElement() != this) { 774 if (document().documentElement() != this) {
752 if (RenderBox* rend = renderBox()) 775 if (RenderBox* rend = renderBox())
753 rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiv eZoom())); 776 rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiv eZoom()));
754 return; 777 return;
755 } 778 }
756 779
757 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 780 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
758 if (document().inQuirksMode()) 781 if (document().inQuirksMode())
759 return; 782 return;
760 783
761 Frame* frame = document().frame(); 784 Frame* frame = document().frame();
762 if (!frame) 785 if (!frame)
763 return; 786 return;
764 FrameView* view = frame->view(); 787 FrameView* view = frame->view();
765 if (!view) 788 if (!view)
766 return; 789 return;
767 790
768 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(newTo p * frame->pageZoomFactor()))); 791 view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(newTo p * frame->pageZoomFactor())));
769 } 792 }
770 } 793 }
771 794
795 void Element::setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionSta te& exceptionState)
796 {
797 String scrollBehaviorString;
798 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
799 if (scrollOptionsVertical.get("behavior", scrollBehaviorString)) {
800 if (!ScrollableArea::scrollBehaviorFromString(scrollBehaviorString, scro llBehavior)) {
801 exceptionState.throwTypeError("The ScrollBehavior provided is invali d.");
802 return;
803 }
804 }
805
806 int position;
807 if (!scrollOptionsVertical.get("y", position)) {
808 exceptionState.throwTypeError("ScrollOptionsVertical must include a 'y' member.");
809 return;
810 }
811
812 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant ly.
813 setScrollTop(position);
814 }
815
772 int Element::scrollWidth() 816 int Element::scrollWidth()
773 { 817 {
774 document().updateLayoutIgnorePendingStylesheets(); 818 document().updateLayoutIgnorePendingStylesheets();
775 if (RenderBox* rend = renderBox()) 819 if (RenderBox* rend = renderBox())
776 return adjustForAbsoluteZoom(rend->scrollWidth(), rend); 820 return adjustForAbsoluteZoom(rend->scrollWidth(), rend);
777 return 0; 821 return 0;
778 } 822 }
779 823
780 int Element::scrollHeight() 824 int Element::scrollHeight()
781 { 825 {
(...skipping 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3682 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3639 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3683 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3640 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3684 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3641 return false; 3685 return false;
3642 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3686 if (FullscreenElementStack::isActiveFullScreenElement(this))
3643 return false; 3687 return false;
3644 return true; 3688 return true;
3645 } 3689 }
3646 3690
3647 } // namespace WebCore 3691 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698