| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/page/scrolling/ScrollState.h" | 5 #include "core/page/scrolling/ScrollState.h" |
| 6 | 6 |
| 7 #include "core/dom/DOMNodeIds.h" | 7 #include "core/dom/DOMNodeIds.h" |
| 8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 Element* elementForId(int elementId) | 14 Element* elementForId(int elementId) |
| 15 { | 15 { |
| 16 Node* node = DOMNodeIds::nodeForId(elementId); | 16 Node* node = DOMNodeIds::nodeForId(elementId); |
| 17 ASSERT(node); | 17 ASSERT(node); |
| 18 if (!node) | 18 if (!node) |
| 19 return nullptr; | 19 return nullptr; |
| 20 ASSERT(node->isElementNode()); | 20 ASSERT(node->isElementNode()); |
| 21 if (!node->isElementNode()) | 21 if (!node->isElementNode()) |
| 22 return nullptr; | 22 return nullptr; |
| 23 return static_cast<Element*>(node); | 23 return static_cast<Element*>(node); |
| 24 } | 24 } |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 PassRefPtrWillBeRawPtr<ScrollState> ScrollState::create( | 27 RawPtr<ScrollState> ScrollState::create( |
| 28 double deltaX, double deltaY, double deltaGranularity, double velocityX, | 28 double deltaX, double deltaY, double deltaGranularity, double velocityX, |
| 29 double velocityY, bool inInertialPhase, | 29 double velocityY, bool inInertialPhase, |
| 30 bool isBeginning, bool isEnding, | 30 bool isBeginning, bool isEnding, |
| 31 bool fromUserInput, bool shouldPropagate, | 31 bool fromUserInput, bool shouldPropagate, |
| 32 bool deltaConsumedForScrollSequence) | 32 bool deltaConsumedForScrollSequence) |
| 33 { | 33 { |
| 34 OwnPtr<WebScrollStateData> data(adoptPtr(new WebScrollStateData(deltaX, delt
aY, deltaGranularity, velocityX, velocityY, | 34 OwnPtr<WebScrollStateData> data(adoptPtr(new WebScrollStateData(deltaX, delt
aY, deltaGranularity, velocityX, velocityY, |
| 35 inInertialPhase, isBeginning, isEnding, fromUserInput, shouldPropagate, | 35 inInertialPhase, isBeginning, isEnding, fromUserInput, shouldPropagate, |
| 36 deltaConsumedForScrollSequence))); | 36 deltaConsumedForScrollSequence))); |
| 37 return adoptRefWillBeNoop(new ScrollState(data.release())); | 37 return (new ScrollState(data.release())); |
| 38 } | 38 } |
| 39 | 39 |
| 40 PassRefPtrWillBeRawPtr<ScrollState> ScrollState::create(PassOwnPtr<WebScrollStat
eData> data) | 40 RawPtr<ScrollState> ScrollState::create(PassOwnPtr<WebScrollStateData> data) |
| 41 { | 41 { |
| 42 ScrollState* scrollState = new ScrollState(data); | 42 ScrollState* scrollState = new ScrollState(data); |
| 43 return adoptRefWillBeNoop(scrollState); | 43 return (scrollState); |
| 44 } | 44 } |
| 45 | 45 |
| 46 ScrollState::ScrollState(PassOwnPtr<WebScrollStateData> data) | 46 ScrollState::ScrollState(PassOwnPtr<WebScrollStateData> data) |
| 47 : m_data(data) | 47 : m_data(data) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ScrollState::consumeDelta(double x, double y, ExceptionState& exceptionStat
e) | 51 void ScrollState::consumeDelta(double x, double y, ExceptionState& exceptionStat
e) |
| 52 { | 52 { |
| 53 if ((m_data->deltaX > 0 && 0 > x) || (m_data->deltaX < 0 && 0 < x) || (m_dat
a->deltaY > 0 && 0 > y) || (m_data->deltaY < 0 && 0 < y)) { | 53 if ((m_data->deltaX > 0 && 0 > x) || (m_data->deltaX < 0 && 0 < x) || (m_dat
a->deltaY > 0 && 0 > y) || (m_data->deltaY < 0 && 0 < y)) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 { | 95 { |
| 96 return m_data->currentNativeScrollingElement; | 96 return m_data->currentNativeScrollingElement; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void ScrollState::setCurrentNativeScrollingElementById(int elementId) | 99 void ScrollState::setCurrentNativeScrollingElementById(int elementId) |
| 100 { | 100 { |
| 101 m_data->currentNativeScrollingElement = elementId; | 101 m_data->currentNativeScrollingElement = elementId; |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |