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

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

Issue 988823003: Use scroll customization primitives for touch scrolling (behind REF). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address rbyers' nit. Created 5 years, 9 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
« no previous file with comments | « Source/core/frame/LocalFrame.h ('k') | Source/core/page/EventHandler.h » ('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) 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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 bool LocalFrame::shouldReuseDefaultView(const KURL& url) const 721 bool LocalFrame::shouldReuseDefaultView(const KURL& url) const
722 { 722 {
723 return loader().stateMachine()->isDisplayingInitialEmptyDocument() && docume nt()->isSecureTransitionTo(url); 723 return loader().stateMachine()->isDisplayingInitialEmptyDocument() && docume nt()->isSecureTransitionTo(url);
724 } 724 }
725 725
726 void LocalFrame::removeSpellingMarkersUnderWords(const Vector<String>& words) 726 void LocalFrame::removeSpellingMarkersUnderWords(const Vector<String>& words)
727 { 727 {
728 spellChecker().removeSpellingMarkersUnderWords(words); 728 spellChecker().removeSpellingMarkersUnderWords(words);
729 } 729 }
730 730
731 static bool scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view)
732 {
733 bool scrolledHorizontal = view.scroll(ScrollLeft, ScrollByPrecisePixel, delt a.width());
734 bool scrolledVertical = view.scroll(ScrollUp, ScrollByPrecisePixel, delta.he ight());
735 return scrolledHorizontal || scrolledVertical;
736 }
737
738 // Returns true if a scroll occurred.
739 bool LocalFrame::applyScrollDelta(const FloatSize& delta, bool isScrollBegin)
740 {
741 if (isScrollBegin)
742 host()->topControls().scrollBegin();
743
744 if (!view() || delta.isZero())
745 return false;
746
747 // If this is main frame, allow top controls to scroll first.
748 bool giveToTopControls = false;
749 if (isMainFrame()) {
750 // Always give the delta to the top controls if the scroll is in
751 // the direction to show the top controls. If it's in the
752 // direction to hide the top controls, only give the delta to the
753 // top controls when the frame can scroll.
754 giveToTopControls = delta.height() > 0
755 || view()->scrollPosition().y() < view()->maximumScrollPosition().y( );
756 }
757
758 FloatSize remainingDelta = delta;
759 if (giveToTopControls)
760 remainingDelta = host()->topControls().scrollBy(remainingDelta);
761
762 if (remainingDelta.isZero())
763 return true;
764
765 bool consumed = remainingDelta != delta;
766
767 if (scrollAreaOnBothAxes(remainingDelta, *view()))
768 return true;
769
770 // If this is the main frame and it didn't scroll, propagate up to the pinch viewport.
771 if (!isMainFrame())
772 return consumed;
773
774 if (scrollAreaOnBothAxes(remainingDelta, page()->frameHost().pinchViewport() ))
775 return true;
776
777 return consumed;
778 }
779
731 #if ENABLE(OILPAN) 780 #if ENABLE(OILPAN)
732 void LocalFrame::registerPluginElement(HTMLPlugInElement* plugin) 781 void LocalFrame::registerPluginElement(HTMLPlugInElement* plugin)
733 { 782 {
734 m_pluginElements.add(plugin); 783 m_pluginElements.add(plugin);
735 } 784 }
736 785
737 void LocalFrame::unregisterPluginElement(HTMLPlugInElement* plugin) 786 void LocalFrame::unregisterPluginElement(HTMLPlugInElement* plugin)
738 { 787 {
739 ASSERT(m_pluginElements.contains(plugin)); 788 ASSERT(m_pluginElements.contains(plugin));
740 m_pluginElements.remove(plugin); 789 m_pluginElements.remove(plugin);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 // We detach the FrameView's custom scroll bars as early as 839 // We detach the FrameView's custom scroll bars as early as
791 // possible to prevent m_doc->detach() from messing with the view 840 // possible to prevent m_doc->detach() from messing with the view
792 // such that its scroll bars won't be torn down. 841 // such that its scroll bars won't be torn down.
793 // 842 //
794 // FIXME: We should revisit this. 843 // FIXME: We should revisit this.
795 if (m_view) 844 if (m_view)
796 m_view->prepareForDetach(); 845 m_view->prepareForDetach();
797 } 846 }
798 847
799 } // namespace blink 848 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/LocalFrame.h ('k') | Source/core/page/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698