| 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/input/TouchActionUtil.h" | 5 #include "core/input/TouchActionUtil.h" |
| 6 | 6 |
| 7 #include "core/dom/Node.h" | 7 #include "core/dom/Node.h" |
| 8 #include "core/html/HTMLFrameOwnerElement.h" | 8 #include "core/html/HTMLFrameOwnerElement.h" |
| 9 #include "core/layout/LayoutBox.h" | 9 #include "core/layout/LayoutBox.h" |
| 10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 TouchAction ComputeEffectiveTouchAction(const Node& node) { | 47 TouchAction ComputeEffectiveTouchAction(const Node& node) { |
| 48 // Start by permitting all actions, then walk the elements supporting | 48 // Start by permitting all actions, then walk the elements supporting |
| 49 // touch-action from the target node up to root document, exclude any | 49 // touch-action from the target node up to root document, exclude any |
| 50 // prohibited actions at or below the element that supports them. | 50 // prohibited actions at or below the element that supports them. |
| 51 // I.e. pan-related actions are considered up to the nearest scroller, | 51 // I.e. pan-related actions are considered up to the nearest scroller, |
| 52 // and zoom related actions are considered up to the root. | 52 // and zoom related actions are considered up to the root. |
| 53 TouchAction effective_touch_action = kTouchActionAuto; | 53 TouchAction effective_touch_action = TouchAction::kTouchActionAuto; |
| 54 TouchAction handled_touch_actions = kTouchActionNone; | 54 TouchAction handled_touch_actions = TouchAction::kTouchActionNone; |
| 55 for (const Node* cur_node = &node; cur_node; | 55 for (const Node* cur_node = &node; cur_node; |
| 56 cur_node = ParentNodeAcrossFrames(cur_node)) { | 56 cur_node = ParentNodeAcrossFrames(cur_node)) { |
| 57 if (LayoutObject* layout_object = cur_node->GetLayoutObject()) { | 57 if (LayoutObject* layout_object = cur_node->GetLayoutObject()) { |
| 58 if (SupportsTouchAction(*layout_object)) { | 58 if (SupportsTouchAction(*layout_object)) { |
| 59 TouchAction action = layout_object->Style()->GetTouchAction(); | 59 TouchAction action = layout_object->Style()->GetTouchAction(); |
| 60 action |= handled_touch_actions; | 60 action |= handled_touch_actions; |
| 61 effective_touch_action &= action; | 61 effective_touch_action &= action; |
| 62 if (effective_touch_action == kTouchActionNone) | 62 if (effective_touch_action == TouchAction::kTouchActionNone) |
| 63 break; | 63 break; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // If we've reached an ancestor that supports panning, stop allowing | 66 // If we've reached an ancestor that supports panning, stop allowing |
| 67 // panning to be disabled. | 67 // panning to be disabled. |
| 68 if ((layout_object->IsBox() && | 68 if ((layout_object->IsBox() && |
| 69 ToLayoutBox(layout_object)->ScrollsOverflow()) || | 69 ToLayoutBox(layout_object)->ScrollsOverflow()) || |
| 70 layout_object->IsLayoutView()) | 70 layout_object->IsLayoutView()) |
| 71 handled_touch_actions |= kTouchActionPan; | 71 handled_touch_actions |= TouchAction::kTouchActionPan; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 return effective_touch_action; | 74 return effective_touch_action; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace TouchActionUtil | 77 } // namespace TouchActionUtil |
| 78 } // namespace blink | 78 } // namespace blink |
| OLD | NEW |