Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 bool LocalFrame::shouldReuseDefaultView(const KURL& url) const | 711 bool LocalFrame::shouldReuseDefaultView(const KURL& url) const |
| 712 { | 712 { |
| 713 return loader().stateMachine()->isDisplayingInitialEmptyDocument() && docume nt()->isSecureTransitionTo(url); | 713 return loader().stateMachine()->isDisplayingInitialEmptyDocument() && docume nt()->isSecureTransitionTo(url); |
| 714 } | 714 } |
| 715 | 715 |
| 716 void LocalFrame::removeSpellingMarkersUnderWords(const Vector<String>& words) | 716 void LocalFrame::removeSpellingMarkersUnderWords(const Vector<String>& words) |
| 717 { | 717 { |
| 718 spellChecker().removeSpellingMarkersUnderWords(words); | 718 spellChecker().removeSpellingMarkersUnderWords(words); |
| 719 } | 719 } |
| 720 | 720 |
| 721 static bool scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view) | 721 static ScrollResult scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view) |
| 722 { | 722 { |
| 723 bool scrolledHorizontal = view.scroll(ScrollLeft, ScrollByPrecisePixel, delt a.width()); | 723 ScrollResultOneDimensional horizontal = view.scroll(ScrollLeft, ScrollByPrec isePixel, delta.width()); |
| 724 bool scrolledVertical = view.scroll(ScrollUp, ScrollByPrecisePixel, delta.he ight()); | 724 ScrollResultOneDimensional vertical = view.scroll(ScrollUp, ScrollByPreciseP ixel, delta.height()); |
| 725 return scrolledHorizontal || scrolledVertical; | 725 return ScrollResult((horizontal.didScroll || vertical.didScroll), horizontal .unusedScrollDelta, vertical.unusedScrollDelta); |
| 726 } | 726 } |
| 727 | 727 |
| 728 // Returns true if a scroll occurred. | 728 // Returns true if a scroll occurred. |
|
majidvp
2015/05/14 21:08:39
Please update the comment to reflect change.
MuVen
2015/05/26 09:58:35
Done.
| |
| 729 bool LocalFrame::applyScrollDelta(const FloatSize& delta, bool isScrollBegin) | 729 ScrollResult LocalFrame::applyScrollDelta(const FloatSize& delta, bool isScrollB egin) |
| 730 { | 730 { |
| 731 if (isScrollBegin) | 731 if (isScrollBegin) |
| 732 host()->topControls().scrollBegin(); | 732 host()->topControls().scrollBegin(); |
| 733 | 733 |
| 734 if (!view() || delta.isZero()) | 734 if (!view() || delta.isZero()) |
| 735 return false; | 735 return ScrollResult(false, delta.width(), delta.height()); |
| 736 | 736 |
| 737 FloatSize remainingDelta = delta; | 737 FloatSize remainingDelta = delta; |
| 738 | 738 |
| 739 // If this is main frame, allow top controls to scroll first. | 739 // If this is main frame, allow top controls to scroll first. |
| 740 if (shouldScrollTopControls(delta)) | 740 if (shouldScrollTopControls(delta)) |
| 741 remainingDelta = host()->topControls().scrollBy(remainingDelta); | 741 remainingDelta = host()->topControls().scrollBy(remainingDelta); |
| 742 | 742 |
| 743 if (remainingDelta.isZero()) | 743 if (remainingDelta.isZero()) |
| 744 return true; | 744 return ScrollResult(true); |
| 745 | 745 |
| 746 bool consumed = remainingDelta != delta; | 746 ScrollResult result = scrollAreaOnBothAxes(remainingDelta, *view()->scrollab leArea()); |
| 747 | 747 |
| 748 if (scrollAreaOnBothAxes(remainingDelta, *view()->scrollableArea())) | 748 if (result.didScroll) |
| 749 return true; | 749 return result; |
| 750 | 750 |
| 751 return consumed; | 751 remainingDelta.setWidth(result.unusedScrollDeltaX); |
| 752 remainingDelta.setHeight(result.unusedScrollDeltaY); | |
| 753 return ScrollResult(remainingDelta != delta, remainingDelta.width(), remaini ngDelta.height()); | |
|
majidvp
2015/05/14 21:08:39
This is more readable and avoids an extra construc
MuVen
2015/05/26 09:58:35
Done.
| |
| 752 } | 754 } |
| 753 | 755 |
| 754 bool LocalFrame::shouldScrollTopControls(const FloatSize& delta) const | 756 bool LocalFrame::shouldScrollTopControls(const FloatSize& delta) const |
| 755 { | 757 { |
| 756 if (!isMainFrame()) | 758 if (!isMainFrame()) |
| 757 return false; | 759 return false; |
| 758 | 760 |
| 759 // Always give the delta to the top controls if the scroll is in | 761 // Always give the delta to the top controls if the scroll is in |
| 760 // the direction to show the top controls. If it's in the | 762 // the direction to show the top controls. If it's in the |
| 761 // direction to hide the top controls, only give the delta to the | 763 // direction to hide the top controls, only give the delta to the |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 , m_textZoomFactor(parentTextZoomFactor(this)) | 819 , m_textZoomFactor(parentTextZoomFactor(this)) |
| 818 , m_inViewSourceMode(false) | 820 , m_inViewSourceMode(false) |
| 819 { | 821 { |
| 820 if (isLocalRoot()) | 822 if (isLocalRoot()) |
| 821 m_instrumentingAgents = InstrumentingAgents::create(); | 823 m_instrumentingAgents = InstrumentingAgents::create(); |
| 822 else | 824 else |
| 823 m_instrumentingAgents = localFrameRoot()->m_instrumentingAgents; | 825 m_instrumentingAgents = localFrameRoot()->m_instrumentingAgents; |
| 824 } | 826 } |
| 825 | 827 |
| 826 } // namespace blink | 828 } // namespace blink |
| OLD | NEW |