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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 1840113005: Move viewport actions into an ApplyScroll callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "core/layout/HitTestResult.h" 55 #include "core/layout/HitTestResult.h"
56 #include "core/layout/LayoutView.h" 56 #include "core/layout/LayoutView.h"
57 #include "core/layout/api/LayoutViewItem.h" 57 #include "core/layout/api/LayoutViewItem.h"
58 #include "core/layout/compositing/PaintLayerCompositor.h" 58 #include "core/layout/compositing/PaintLayerCompositor.h"
59 #include "core/loader/FrameLoadRequest.h" 59 #include "core/loader/FrameLoadRequest.h"
60 #include "core/loader/FrameLoaderClient.h" 60 #include "core/loader/FrameLoaderClient.h"
61 #include "core/loader/NavigationScheduler.h" 61 #include "core/loader/NavigationScheduler.h"
62 #include "core/page/ChromeClient.h" 62 #include "core/page/ChromeClient.h"
63 #include "core/page/FocusController.h" 63 #include "core/page/FocusController.h"
64 #include "core/page/Page.h" 64 #include "core/page/Page.h"
65 #include "core/page/scrolling/ScrollState.h"
66 #include "core/page/scrolling/ScrollStateCallback.h"
65 #include "core/page/scrolling/ScrollingCoordinator.h" 67 #include "core/page/scrolling/ScrollingCoordinator.h"
66 #include "core/paint/ObjectPainter.h" 68 #include "core/paint/ObjectPainter.h"
67 #include "core/paint/PaintInfo.h" 69 #include "core/paint/PaintInfo.h"
68 #include "core/paint/PaintLayer.h" 70 #include "core/paint/PaintLayer.h"
69 #include "core/paint/TransformRecorder.h" 71 #include "core/paint/TransformRecorder.h"
70 #include "core/svg/SVGDocumentExtensions.h" 72 #include "core/svg/SVGDocumentExtensions.h"
71 #include "platform/DragImage.h" 73 #include "platform/DragImage.h"
72 #include "platform/PluginScriptForbiddenScope.h" 74 #include "platform/PluginScriptForbiddenScope.h"
73 #include "platform/RuntimeEnabledFeatures.h" 75 #include "platform/RuntimeEnabledFeatures.h"
74 #include "platform/ScriptForbiddenScope.h" 76 #include "platform/ScriptForbiddenScope.h"
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 return false; 759 return false;
758 760
759 return document()->isSecureTransitionTo(url); 761 return document()->isSecureTransitionTo(url);
760 } 762 }
761 763
762 void LocalFrame::removeSpellingMarkersUnderWords(const Vector<String>& words) 764 void LocalFrame::removeSpellingMarkersUnderWords(const Vector<String>& words)
763 { 765 {
764 spellChecker().removeSpellingMarkersUnderWords(words); 766 spellChecker().removeSpellingMarkersUnderWords(words);
765 } 767 }
766 768
767 ScrollResult LocalFrame::applyScrollDelta(ScrollGranularity granularity, const F loatSize& delta, bool isScrollBegin)
768 {
769 if (isScrollBegin)
770 host()->topControls().scrollBegin();
771
772 if (!view() || delta.isZero())
773 return ScrollResult(false, false, delta.width(), delta.height());
774
775 FloatSize remainingDelta = delta;
776
777 // If this is main frame, allow top controls to scroll first.
778 if (shouldScrollTopControls(granularity, delta))
779 remainingDelta = host()->topControls().scrollBy(remainingDelta);
780
781 if (remainingDelta.isZero())
782 return ScrollResult(delta.width(), delta.height(), 0.0f, 0.0f);
783
784 ScrollResult result = view()->getScrollableArea()->userScroll(granularity, r emainingDelta);
785 result.didScrollX = result.didScrollX || (remainingDelta.width() != delta.wi dth());
786 result.didScrollY = result.didScrollY || (remainingDelta.height() != delta.h eight());
787
788 return result;
789 }
790
791 bool LocalFrame::shouldScrollTopControls(ScrollGranularity granularity, const Fl oatSize& delta) const
792 {
793 if (!isMainFrame())
794 return false;
795
796 if (granularity != ScrollByPixel && granularity != ScrollByPrecisePixel)
797 return false;
798
799 // Always give the delta to the top controls if the scroll is in
800 // the direction to show the top controls. If it's in the
801 // direction to hide the top controls, only give the delta to the
802 // top controls when the frame can scroll.
803 DoublePoint maximumScrollPosition =
804 host()->visualViewport().maximumScrollPositionDouble() +
805 toDoubleSize(view()->maximumScrollPositionDouble());
806 DoublePoint scrollPosition = host()->visualViewport()
807 .visibleRectInDocument().location();
808 return delta.height() < 0 || scrollPosition.y() < maximumScrollPosition.y();
809 }
810
811 String LocalFrame::localLayerTreeAsText(unsigned flags) const 769 String LocalFrame::localLayerTreeAsText(unsigned flags) const
812 { 770 {
813 if (!contentLayoutObject()) 771 if (!contentLayoutObject())
814 return String(); 772 return String();
815 773
816 return contentLayoutObject()->compositor()->layerTreeAsText(static_cast<Laye rTreeFlags>(flags)); 774 return contentLayoutObject()->compositor()->layerTreeAsText(static_cast<Laye rTreeFlags>(flags));
817 } 775 }
818 776
819 bool LocalFrame::shouldThrottleRendering() const 777 bool LocalFrame::shouldThrottleRendering() const
820 { 778 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 { 829 {
872 m_frame->disableNavigation(); 830 m_frame->disableNavigation();
873 } 831 }
874 832
875 FrameNavigationDisabler::~FrameNavigationDisabler() 833 FrameNavigationDisabler::~FrameNavigationDisabler()
876 { 834 {
877 m_frame->enableNavigation(); 835 m_frame->enableNavigation();
878 } 836 }
879 837
880 } // namespace blink 838 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698