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

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

Issue 2622273003: Fixed volume slider element event handling (Closed)
Patch Set: mlamouri's comments. Created 3 years, 10 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 | « third_party/WebKit/Source/core/html/shadow/MediaControlElementTypes.h ('k') | 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 } 750 }
747 751
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::input)
757 event->type() == EventTypeNames::mouseout ||
758 event->type() == EventTypeNames::mousemove)
759 return; 761 return;
760 762
761 double time = value().toDouble(); 763 double time = value().toDouble();
762 if (event->type() == EventTypeNames::input) { 764
763 // FIXME: This will need to take the timeline offset into consideration 765 // FIXME: This will need to take the timeline offset into consideration
764 // once that concept is supported, see https://crbug.com/312699 766 // once that concept is supported, see https://crbug.com/312699
765 if (mediaElement().seekable()->contain(time)) 767 if (mediaElement().seekable()->contain(time))
766 mediaElement().setCurrentTime(time); 768 mediaElement().setCurrentTime(time);
767 }
768 769
769 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject())); 770 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject()));
770 if (!slider.isNull() && slider.inDragMode()) 771 if (!slider.isNull() && slider.inDragMode())
771 mediaControls().updateCurrentTimeDisplay(); 772 mediaControls().updateCurrentTimeDisplay();
772 } 773 }
773 774
774 bool MediaControlTimelineElement::willRespondToMouseClickEvents() { 775 bool MediaControlTimelineElement::willRespondToMouseClickEvents() {
775 return isConnected() && document().isActive(); 776 return isConnected() && document().isActive();
776 } 777 }
777 778
(...skipping 28 matching lines...) Expand all
806 slider->ensureUserAgentShadowRoot(); 807 slider->ensureUserAgentShadowRoot();
807 slider->setType(InputTypeNames::range); 808 slider->setType(InputTypeNames::range);
808 slider->setAttribute(stepAttr, "any"); 809 slider->setAttribute(stepAttr, "any");
809 slider->setAttribute(maxAttr, "1"); 810 slider->setAttribute(maxAttr, "1");
810 slider->setShadowPseudoId( 811 slider->setShadowPseudoId(
811 AtomicString("-webkit-media-controls-volume-slider")); 812 AtomicString("-webkit-media-controls-volume-slider"));
812 return slider; 813 return slider;
813 } 814 }
814 815
815 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event) { 816 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()) 817 if (!isConnected() || !document().isActive())
822 return; 818 return;
823 819
824 MediaControlInputElement::defaultEventHandler(event); 820 MediaControlInputElement::defaultEventHandler(event);
825 821
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) 822 if (event->type() == EventTypeNames::mousedown)
832 Platform::current()->recordAction( 823 Platform::current()->recordAction(
833 UserMetricsAction("Media.Controls.VolumeChangeBegin")); 824 UserMetricsAction("Media.Controls.VolumeChangeBegin"));
834 825
835 if (event->type() == EventTypeNames::mouseup) 826 if (event->type() == EventTypeNames::mouseup)
836 Platform::current()->recordAction( 827 Platform::current()->recordAction(
837 UserMetricsAction("Media.Controls.VolumeChangeEnd")); 828 UserMetricsAction("Media.Controls.VolumeChangeEnd"));
838 829
839 double volume = value().toDouble(); 830 if (event->type() == EventTypeNames::input) {
840 mediaElement().setVolume(volume); 831 double volume = value().toDouble();
841 mediaElement().setMuted(false); 832 mediaElement().setVolume(volume);
833 mediaElement().setMuted(false);
834 }
842 } 835 }
843 836
844 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents() { 837 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents() {
845 if (!isConnected() || !document().isActive()) 838 if (!isConnected() || !document().isActive())
846 return false; 839 return false;
847 840
848 return MediaControlInputElement::willRespondToMouseMoveEvents(); 841 return MediaControlInputElement::willRespondToMouseMoveEvents();
849 } 842 }
850 843
851 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents() { 844 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents() {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 MediaControlCurrentTimeDisplayElement* 1038 MediaControlCurrentTimeDisplayElement*
1046 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) { 1039 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) {
1047 MediaControlCurrentTimeDisplayElement* element = 1040 MediaControlCurrentTimeDisplayElement* element =
1048 new MediaControlCurrentTimeDisplayElement(mediaControls); 1041 new MediaControlCurrentTimeDisplayElement(mediaControls);
1049 element->setShadowPseudoId( 1042 element->setShadowPseudoId(
1050 AtomicString("-webkit-media-controls-current-time-display")); 1043 AtomicString("-webkit-media-controls-current-time-display"));
1051 return element; 1044 return element;
1052 } 1045 }
1053 1046
1054 } // namespace blink 1047 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/shadow/MediaControlElementTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698