Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp

Issue 2622273003: Fixed volume slider element event handling (Closed)
Patch Set: Remvoed logs, added a TODO. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (isUserInteractionEvent(event)) 90 if (isUserInteractionEvent(event))
91 return true; 91 return true;
92 92
93 // Some events are only captured during a slider drag. 93 // Some events are only captured during a slider drag.
94 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject)); 94 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject));
95 if (!slider.isNull() && !slider.inDragMode()) 95 if (!slider.isNull() && !slider.inDragMode())
96 return false; 96 return false;
97 97
98 const AtomicString& type = event->type(); 98 const AtomicString& type = event->type();
99 return type == EventTypeNames::mouseover || 99 return type == EventTypeNames::mouseover ||
100 type == EventTypeNames::mouseout || type == EventTypeNames::mousemove; 100 type == EventTypeNames::mouseout ||
101 type == EventTypeNames::mousemove ||
102 type == EventTypeNames::pointerover ||
103 type == EventTypeNames::pointerout ||
104 type == EventTypeNames::pointermove;
101 } 105 }
102 106
103 Element* elementFromCenter(Element& element) { 107 Element* elementFromCenter(Element& element) {
104 ClientRect* clientRect = element.getBoundingClientRect(); 108 ClientRect* clientRect = element.getBoundingClientRect();
105 int centerX = 109 int centerX =
106 static_cast<int>((clientRect->left() + clientRect->right()) / 2); 110 static_cast<int>((clientRect->left() + clientRect->right()) / 2);
107 int centerY = 111 int centerY =
108 static_cast<int>((clientRect->top() + clientRect->bottom()) / 2); 112 static_cast<int>((clientRect->top() + clientRect->bottom()) / 2);
109 113
110 return element.document().elementFromPoint(centerX, centerY); 114 return element.document().elementFromPoint(centerX, centerY);
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 if (event->type() == EventTypeNames::mouseup) { 752 if (event->type() == EventTypeNames::mouseup) {
749 Platform::current()->recordAction( 753 Platform::current()->recordAction(
750 UserMetricsAction("Media.Controls.ScrubbingEnd")); 754 UserMetricsAction("Media.Controls.ScrubbingEnd"));
751 mediaControls().endScrubbing(); 755 mediaControls().endScrubbing();
752 } 756 }
753 757
754 MediaControlInputElement::defaultEventHandler(event); 758 MediaControlInputElement::defaultEventHandler(event);
755 759
756 if (event->type() == EventTypeNames::mouseover || 760 if (event->type() == EventTypeNames::mouseover ||
757 event->type() == EventTypeNames::mouseout || 761 event->type() == EventTypeNames::mouseout ||
758 event->type() == EventTypeNames::mousemove) 762 event->type() == EventTypeNames::mousemove ||
763 event->type() == EventTypeNames::pointerover ||
764 event->type() == EventTypeNames::pointerout ||
765 event->type() == EventTypeNames::pointermove)
liberato (no reviews please) 2017/01/11 16:07:26 can we (eventually) just ignore mouse* here in fav
mustaq 2017/01/11 17:34:35 I totally agree, will add a TODO. It would involve
mustaq 2017/01/11 21:24:58 Done.
759 return; 766 return;
760 767
761 double time = value().toDouble(); 768 double time = value().toDouble();
762 if (event->type() == EventTypeNames::input) { 769 if (event->type() == EventTypeNames::input) {
763 // FIXME: This will need to take the timeline offset into consideration 770 // FIXME: This will need to take the timeline offset into consideration
764 // once that concept is supported, see https://crbug.com/312699 771 // once that concept is supported, see https://crbug.com/312699
765 if (mediaElement().seekable()->contain(time)) 772 if (mediaElement().seekable()->contain(time))
766 mediaElement().setCurrentTime(time); 773 mediaElement().setCurrentTime(time);
767 } 774 }
768 775
776 // TODO(mustaq): On a single click, this block is executed 5 or 6 times
777 // depending on whether the slider position has been changed or not, once for
778 // each of these events: pointerdown, mousedown, (input?), pointerup, mouseup,
779 // DOMActive, click. Perhaps we only care about the "input" event (as in
780 // MediaControlVolumeSliderElement::defaultEventHandler)?
769 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject())); 781 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject()));
770 if (!slider.isNull() && slider.inDragMode()) 782 if (!slider.isNull() && slider.inDragMode())
771 mediaControls().updateCurrentTimeDisplay(); 783 mediaControls().updateCurrentTimeDisplay();
772 } 784 }
773 785
774 bool MediaControlTimelineElement::willRespondToMouseClickEvents() { 786 bool MediaControlTimelineElement::willRespondToMouseClickEvents() {
775 return isConnected() && document().isActive(); 787 return isConnected() && document().isActive();
776 } 788 }
777 789
778 void MediaControlTimelineElement::setPosition(double currentTime) { 790 void MediaControlTimelineElement::setPosition(double currentTime) {
(...skipping 27 matching lines...) Expand all
806 slider->ensureUserAgentShadowRoot(); 818 slider->ensureUserAgentShadowRoot();
807 slider->setType(InputTypeNames::range); 819 slider->setType(InputTypeNames::range);
808 slider->setAttribute(stepAttr, "any"); 820 slider->setAttribute(stepAttr, "any");
809 slider->setAttribute(maxAttr, "1"); 821 slider->setAttribute(maxAttr, "1");
810 slider->setShadowPseudoId( 822 slider->setShadowPseudoId(
811 AtomicString("-webkit-media-controls-volume-slider")); 823 AtomicString("-webkit-media-controls-volume-slider"));
812 return slider; 824 return slider;
813 } 825 }
814 826
815 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event) { 827 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event) {
816 if (event->isMouseEvent() &&
817 toMouseEvent(event)->button() !=
818 static_cast<short>(WebPointerProperties::Button::Left))
819 return;
820
821 if (!isConnected() || !document().isActive()) 828 if (!isConnected() || !document().isActive())
822 return; 829 return;
823 830
824 MediaControlInputElement::defaultEventHandler(event); 831 MediaControlInputElement::defaultEventHandler(event);
825 832
826 if (event->type() == EventTypeNames::mouseover ||
827 event->type() == EventTypeNames::mouseout ||
828 event->type() == EventTypeNames::mousemove)
829 return;
830
831 if (event->type() == EventTypeNames::mousedown) 833 if (event->type() == EventTypeNames::mousedown)
832 Platform::current()->recordAction( 834 Platform::current()->recordAction(
833 UserMetricsAction("Media.Controls.VolumeChangeBegin")); 835 UserMetricsAction("Media.Controls.VolumeChangeBegin"));
834 836
835 if (event->type() == EventTypeNames::mouseup) 837 if (event->type() == EventTypeNames::mouseup)
836 Platform::current()->recordAction( 838 Platform::current()->recordAction(
837 UserMetricsAction("Media.Controls.VolumeChangeEnd")); 839 UserMetricsAction("Media.Controls.VolumeChangeEnd"));
838 840
839 double volume = value().toDouble(); 841 if (event->type() == EventTypeNames::input) {
840 mediaElement().setVolume(volume); 842 double volume = value().toDouble();
841 mediaElement().setMuted(false); 843 mediaElement().setVolume(volume);
844 mediaElement().setMuted(false);
845 }
842 } 846 }
843 847
844 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents() { 848 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents() {
845 if (!isConnected() || !document().isActive()) 849 if (!isConnected() || !document().isActive())
846 return false; 850 return false;
847 851
848 return MediaControlInputElement::willRespondToMouseMoveEvents(); 852 return MediaControlInputElement::willRespondToMouseMoveEvents();
849 } 853 }
850 854
851 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents() { 855 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents() {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 MediaControlCurrentTimeDisplayElement* 1045 MediaControlCurrentTimeDisplayElement*
1042 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) { 1046 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) {
1043 MediaControlCurrentTimeDisplayElement* element = 1047 MediaControlCurrentTimeDisplayElement* element =
1044 new MediaControlCurrentTimeDisplayElement(mediaControls); 1048 new MediaControlCurrentTimeDisplayElement(mediaControls);
1045 element->setShadowPseudoId( 1049 element->setShadowPseudoId(
1046 AtomicString("-webkit-media-controls-current-time-display")); 1050 AtomicString("-webkit-media-controls-current-time-display"));
1047 return element; 1051 return element;
1048 } 1052 }
1049 1053
1050 } // namespace blink 1054 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698