| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "modules/media_controls/elements/MediaControlElementsHelper.h" | 5 #include "modules/media_controls/elements/MediaControlElementsHelper.h" |
| 6 | 6 |
| 7 #include "core/events/Event.h" | 7 #include "core/events/Event.h" |
| 8 #include "core/layout/api/LayoutSliderItem.h" |
| 8 | 9 |
| 9 namespace blink { | 10 namespace blink { |
| 10 | 11 |
| 11 // static | 12 // static |
| 12 bool MediaControlElementsHelper::IsUserInteractionEvent(Event* event) { | 13 bool MediaControlElementsHelper::IsUserInteractionEvent(Event* event) { |
| 13 const AtomicString& type = event->type(); | 14 const AtomicString& type = event->type(); |
| 14 return type == EventTypeNames::mousedown || type == EventTypeNames::mouseup || | 15 return type == EventTypeNames::mousedown || type == EventTypeNames::mouseup || |
| 15 type == EventTypeNames::click || type == EventTypeNames::dblclick || | 16 type == EventTypeNames::click || type == EventTypeNames::dblclick || |
| 16 event->IsKeyboardEvent() || event->IsTouchEvent(); | 17 event->IsKeyboardEvent() || event->IsTouchEvent(); |
| 17 } | 18 } |
| 18 | 19 |
| 20 // static |
| 21 bool MediaControlElementsHelper::IsUserInteractionEventForSlider( |
| 22 Event* event, |
| 23 LayoutObject* layout_object) { |
| 24 // It is unclear if this can be converted to isUserInteractionEvent(), since |
| 25 // mouse* events seem to be eaten during a drag anyway, see |
| 26 // https://crbug.com/516416. |
| 27 if (IsUserInteractionEvent(event)) |
| 28 return true; |
| 29 |
| 30 // Some events are only captured during a slider drag. |
| 31 const LayoutSliderItem& slider = |
| 32 LayoutSliderItem(ToLayoutSlider(layout_object)); |
| 33 // TODO(crbug.com/695459#c1): LayoutSliderItem::inDragMode is incorrectly |
| 34 // false for drags that start from the track instead of the thumb. |
| 35 // Use SliderThumbElement::m_inDragMode and |
| 36 // SliderContainerElement::m_touchStarted instead. |
| 37 if (!slider.IsNull() && !slider.InDragMode()) |
| 38 return false; |
| 39 |
| 40 const AtomicString& type = event->type(); |
| 41 return type == EventTypeNames::mouseover || |
| 42 type == EventTypeNames::mouseout || |
| 43 type == EventTypeNames::mousemove || |
| 44 type == EventTypeNames::pointerover || |
| 45 type == EventTypeNames::pointerout || |
| 46 type == EventTypeNames::pointermove; |
| 47 } |
| 48 |
| 19 } // namespace blink | 49 } // namespace blink |
| OLD | NEW |