| 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 <memory> | 7 #include <memory> |
| 8 #include "core/dom/DOMNodeIds.h" | 8 #include "core/dom/DOMNodeIds.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "platform/graphics/CompositorElementId.h" | 11 #include "platform/graphics/CompositorElementId.h" |
| 12 #include "platform/wtf/PtrUtil.h" | 12 #include "platform/wtf/PtrUtil.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 Element* ElementForId(int element_id) { | 17 Element* ElementForId(int element_id) { |
| 18 Node* node = DOMNodeIds::NodeForId(element_id); | 18 Node* node = DOMNodeIds::NodeForId(element_id); |
| 19 ASSERT(node); | 19 DCHECK(node); |
| 20 if (!node) | 20 if (!node) |
| 21 return nullptr; | 21 return nullptr; |
| 22 ASSERT(node->IsElementNode()); | 22 DCHECK(node->IsElementNode()); |
| 23 if (!node->IsElementNode()) | 23 if (!node->IsElementNode()) |
| 24 return nullptr; | 24 return nullptr; |
| 25 return static_cast<Element*>(node); | 25 return static_cast<Element*>(node); |
| 26 } | 26 } |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 ScrollState* ScrollState::Create(ScrollStateInit init) { | 29 ScrollState* ScrollState::Create(ScrollStateInit init) { |
| 30 std::unique_ptr<ScrollStateData> scroll_state_data = | 30 std::unique_ptr<ScrollStateData> scroll_state_data = |
| 31 WTF::MakeUnique<ScrollStateData>(); | 31 WTF::MakeUnique<ScrollStateData>(); |
| 32 scroll_state_data->delta_x = init.deltaX(); | 32 scroll_state_data->delta_x = init.deltaX(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 data_->set_current_native_scrolling_element(CreateCompositorElementId( | 103 data_->set_current_native_scrolling_element(CreateCompositorElementId( |
| 104 DOMNodeIds::IdForNode(element), CompositorSubElementId::kScroll)); | 104 DOMNodeIds::IdForNode(element), CompositorSubElementId::kScroll)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ScrollState::SetCurrentNativeScrollingElementById(int element_id) { | 107 void ScrollState::SetCurrentNativeScrollingElementById(int element_id) { |
| 108 data_->set_current_native_scrolling_element( | 108 data_->set_current_native_scrolling_element( |
| 109 CreateCompositorElementId(element_id, CompositorSubElementId::kScroll)); | 109 CreateCompositorElementId(element_id, CompositorSubElementId::kScroll)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |