| Index: third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp
|
| index 56f2ac372f8d6d4c522ac91ddad70933705e95f9..2029517178a5053aa33dc75f08a8c6b0d49c1114 100644
|
| --- a/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp
|
| +++ b/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp
|
| @@ -35,6 +35,7 @@
|
| #include "core/dom/TaskRunnerHelper.h"
|
| #include "core/dom/Text.h"
|
| #include "core/dom/shadow/ShadowRoot.h"
|
| +#include "core/events/KeyboardEvent.h"
|
| #include "core/events/MouseEvent.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/frame/Settings.h"
|
| @@ -46,9 +47,12 @@
|
| #include "core/html/HTMLVideoElement.h"
|
| #include "core/html/TimeRanges.h"
|
| #include "core/html/shadow/MediaControls.h"
|
| +#include "core/html/shadow/ShadowElementNames.h"
|
| #include "core/html/track/TextTrackList.h"
|
| #include "core/input/EventHandler.h"
|
| +#include "core/layout/LayoutBoxModelObject.h"
|
| #include "core/layout/api/LayoutSliderItem.h"
|
| +#include "core/page/ChromeClient.h"
|
| #include "core/page/Page.h"
|
| #include "platform/EventDispatchForbiddenScope.h"
|
| #include "platform/Histogram.h"
|
| @@ -56,6 +60,7 @@
|
| #include "platform/text/PlatformLocale.h"
|
| #include "public/platform/Platform.h"
|
| #include "public/platform/UserMetricsAction.h"
|
| +#include "public/platform/WebScreenInfo.h"
|
|
|
| namespace blink {
|
|
|
| @@ -94,6 +99,10 @@ bool isUserInteractionEventForSlider(Event* event, LayoutObject* layoutObject) {
|
|
|
| // Some events are only captured during a slider drag.
|
| LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject));
|
| + // TODO(crbug.com/695459#c1): LayoutSliderItem::inDragMode is incorrectly
|
| + // false for drags that start from the track instead of the thumb.
|
| + // Use SliderThumbElement::m_inDragMode and
|
| + // SliderContainerElement::m_touchStarted instead.
|
| if (!slider.isNull() && !slider.inDragMode())
|
| return false;
|
|
|
| @@ -790,16 +799,38 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event) {
|
| if (!isConnected() || !document().isActive())
|
| return;
|
|
|
| - if (event->type() == EventTypeNames::mousedown) {
|
| - Platform::current()->recordAction(
|
| - UserMetricsAction("Media.Controls.ScrubbingBegin"));
|
| + // TODO(crbug.com/706504): These should listen for pointerdown/up.
|
| + if (event->type() == EventTypeNames::mousedown)
|
| mediaControls().beginScrubbing();
|
| + if (event->type() == EventTypeNames::mouseup)
|
| + mediaControls().endScrubbing();
|
| +
|
| + // Only respond to main button of primary pointer(s).
|
| + if (event->isPointerEvent() && toPointerEvent(event)->isPrimary() &&
|
| + toPointerEvent(event)->button() ==
|
| + static_cast<short>(WebPointerProperties::Button::Left)) {
|
| + if (event->type() == EventTypeNames::pointerdown) {
|
| + Platform::current()->recordAction(
|
| + UserMetricsAction("Media.Controls.ScrubbingBegin"));
|
| + mediaControls().beginScrubbing();
|
| + Element* thumb = userAgentShadowRoot()->getElementById(
|
| + ShadowElementNames::sliderThumb());
|
| + bool startedFromThumb = thumb && thumb == event->target()->toNode();
|
| + m_metrics.startGesture(startedFromThumb);
|
| + }
|
| + if (event->type() == EventTypeNames::pointerup) {
|
| + Platform::current()->recordAction(
|
| + UserMetricsAction("Media.Controls.ScrubbingEnd"));
|
| + mediaControls().endScrubbing();
|
| + m_metrics.recordEndGesture(timelineWidth(), mediaElement().duration());
|
| + }
|
| }
|
|
|
| - if (event->type() == EventTypeNames::mouseup) {
|
| - Platform::current()->recordAction(
|
| - UserMetricsAction("Media.Controls.ScrubbingEnd"));
|
| - mediaControls().endScrubbing();
|
| + if (event->type() == EventTypeNames::keydown) {
|
| + m_metrics.startKey();
|
| + }
|
| + if (event->type() == EventTypeNames::keyup && event->isKeyboardEvent()) {
|
| + m_metrics.recordEndKey(timelineWidth(), toKeyboardEvent(event)->keyCode());
|
| }
|
|
|
| MediaControlInputElement::defaultEventHandler(event);
|
| @@ -816,6 +847,8 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event) {
|
| if (time > duration)
|
| time = duration;
|
|
|
| + m_metrics.onInput(mediaElement().currentTime(), time);
|
| +
|
| // FIXME: This will need to take the timeline offset into consideration
|
| // once that concept is supported, see https://crbug.com/312699
|
| if (mediaElement().seekable()->contain(time))
|
| @@ -844,10 +877,24 @@ void MediaControlTimelineElement::setDuration(double duration) {
|
| layoutObject->setShouldDoFullPaintInvalidation();
|
| }
|
|
|
| +void MediaControlTimelineElement::onPlaying() {
|
| + Frame* frame = document().frame();
|
| + if (!frame)
|
| + return;
|
| + m_metrics.recordPlaying(frame->chromeClient().screenInfo().orientationType,
|
| + mediaElement().isFullscreen(), timelineWidth());
|
| +}
|
| +
|
| bool MediaControlTimelineElement::keepEventInNode(Event* event) {
|
| return isUserInteractionEventForSlider(event, layoutObject());
|
| }
|
|
|
| +int MediaControlTimelineElement::timelineWidth() {
|
| + if (LayoutBoxModelObject* box = layoutBoxModelObject())
|
| + return box->offsetWidth().round();
|
| + return 0;
|
| +}
|
| +
|
| // ----------------------------
|
|
|
| MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(
|
|
|