Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 77 |
| 78 bool isUserInteractionEvent(Event* event) { | 78 bool isUserInteractionEvent(Event* event) { |
| 79 const AtomicString& type = event->type(); | 79 const AtomicString& type = event->type(); |
| 80 return type == EventTypeNames::mousedown || type == EventTypeNames::mouseup || | 80 return type == EventTypeNames::mousedown || type == EventTypeNames::mouseup || |
| 81 type == EventTypeNames::click || type == EventTypeNames::dblclick || | 81 type == EventTypeNames::click || type == EventTypeNames::dblclick || |
| 82 event->isKeyboardEvent() || event->isTouchEvent(); | 82 event->isKeyboardEvent() || event->isTouchEvent(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Sliders (the volume control and timeline) need to capture some additional | 85 // Sliders (the volume control and timeline) need to capture some additional |
| 86 // events used when dragging the thumb. | 86 // events used when dragging the thumb. |
| 87 // | |
| 88 // TODO(mustaq): Only used through EventTarget::keepEventInNode(), and | |
| 89 // MediaControlElements are the only descendants of EventTarget that return | |
| 90 // true for that method. Can we nuke the method? | |
|
mlamouri (slow - plz ping)
2017/01/24 02:06:51
I think it was created for that purpose. Any reaso
mustaq
2017/01/24 20:51:12
Removed the TODO. I wasn't sure if the special han
| |
| 87 bool isUserInteractionEventForSlider(Event* event, LayoutObject* layoutObject) { | 91 bool isUserInteractionEventForSlider(Event* event, LayoutObject* layoutObject) { |
| 88 // It is unclear if this can be converted to isUserInteractionEvent(), since | 92 // It is unclear if this can be converted to isUserInteractionEvent(), since |
| 89 // mouse* events seem to be eaten during a drag anyway. crbug.com/516416 . | 93 // mouse* events seem to be eaten during a drag anyway. crbug.com/516416 . |
| 90 if (isUserInteractionEvent(event)) | 94 if (isUserInteractionEvent(event)) |
| 91 return true; | 95 return true; |
| 92 | 96 |
| 93 // Some events are only captured during a slider drag. | 97 // Some events are only captured during a slider drag. |
| 94 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject)); | 98 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject)); |
| 95 if (!slider.isNull() && !slider.inDragMode()) | 99 if (!slider.isNull() && !slider.inDragMode()) |
| 96 return false; | 100 return false; |
| 97 | 101 |
| 98 const AtomicString& type = event->type(); | 102 const AtomicString& type = event->type(); |
| 99 return type == EventTypeNames::mouseover || | 103 return type == EventTypeNames::mouseover || |
| 100 type == EventTypeNames::mouseout || type == EventTypeNames::mousemove; | 104 type == EventTypeNames::mouseout || |
| 105 type == EventTypeNames::mousemove || | |
| 106 type == EventTypeNames::pointerover || | |
| 107 type == EventTypeNames::pointerout || | |
| 108 type == EventTypeNames::pointermove; | |
| 101 } | 109 } |
| 102 | 110 |
| 103 Element* elementFromCenter(Element& element) { | 111 Element* elementFromCenter(Element& element) { |
| 104 ClientRect* clientRect = element.getBoundingClientRect(); | 112 ClientRect* clientRect = element.getBoundingClientRect(); |
| 105 int centerX = | 113 int centerX = |
| 106 static_cast<int>((clientRect->left() + clientRect->right()) / 2); | 114 static_cast<int>((clientRect->left() + clientRect->right()) / 2); |
| 107 int centerY = | 115 int centerY = |
| 108 static_cast<int>((clientRect->top() + clientRect->bottom()) / 2); | 116 static_cast<int>((clientRect->top() + clientRect->bottom()) / 2); |
| 109 | 117 |
| 110 return element.document().elementFromPoint(centerX, centerY); | 118 return element.document().elementFromPoint(centerX, centerY); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 732 | 740 |
| 733 void MediaControlTimelineElement::defaultEventHandler(Event* event) { | 741 void MediaControlTimelineElement::defaultEventHandler(Event* event) { |
| 734 if (event->isMouseEvent() && | 742 if (event->isMouseEvent() && |
| 735 toMouseEvent(event)->button() != | 743 toMouseEvent(event)->button() != |
| 736 static_cast<short>(WebPointerProperties::Button::Left)) | 744 static_cast<short>(WebPointerProperties::Button::Left)) |
| 737 return; | 745 return; |
| 738 | 746 |
| 739 if (!isConnected() || !document().isActive()) | 747 if (!isConnected() || !document().isActive()) |
| 740 return; | 748 return; |
| 741 | 749 |
| 742 if (event->type() == EventTypeNames::mousedown) { | 750 if (event->type() == EventTypeNames::mousedown) { |
|
mlamouri (slow - plz ping)
2017/01/24 02:06:51
Should `pointerdown` be added?
mustaq
2017/01/24 20:51:12
This may cause double handling. Because each "phys
| |
| 743 Platform::current()->recordAction( | 751 Platform::current()->recordAction( |
| 744 UserMetricsAction("Media.Controls.ScrubbingBegin")); | 752 UserMetricsAction("Media.Controls.ScrubbingBegin")); |
| 745 mediaControls().beginScrubbing(); | 753 mediaControls().beginScrubbing(); |
| 746 } | 754 } |
| 747 | 755 |
| 748 if (event->type() == EventTypeNames::mouseup) { | 756 if (event->type() == EventTypeNames::mouseup) { |
|
mlamouri (slow - plz ping)
2017/01/24 02:06:51
ditto for `pointerup`?
mustaq
2017/01/24 20:51:12
Same as above: want to avoid double-handling.
| |
| 749 Platform::current()->recordAction( | 757 Platform::current()->recordAction( |
| 750 UserMetricsAction("Media.Controls.ScrubbingEnd")); | 758 UserMetricsAction("Media.Controls.ScrubbingEnd")); |
| 751 mediaControls().endScrubbing(); | 759 mediaControls().endScrubbing(); |
| 752 } | 760 } |
| 753 | 761 |
| 754 MediaControlInputElement::defaultEventHandler(event); | 762 MediaControlInputElement::defaultEventHandler(event); |
| 755 | 763 |
| 756 if (event->type() == EventTypeNames::mouseover || | 764 if (event->type() == EventTypeNames::input) { |
|
mlamouri (slow - plz ping)
2017/01/24 02:06:51
maybe an early return?
mustaq
2017/01/24 20:51:12
Done.
| |
| 757 event->type() == EventTypeNames::mouseout || | 765 double time = value().toDouble(); |
| 758 event->type() == EventTypeNames::mousemove) | |
| 759 return; | |
| 760 | 766 |
| 761 double time = value().toDouble(); | |
| 762 if (event->type() == EventTypeNames::input) { | |
| 763 // FIXME: This will need to take the timeline offset into consideration | 767 // FIXME: This will need to take the timeline offset into consideration |
| 764 // once that concept is supported, see https://crbug.com/312699 | 768 // once that concept is supported, see https://crbug.com/312699 |
| 765 if (mediaElement().seekable()->contain(time)) | 769 if (mediaElement().seekable()->contain(time)) |
| 766 mediaElement().setCurrentTime(time); | 770 mediaElement().setCurrentTime(time); |
| 771 | |
| 772 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject())); | |
| 773 if (!slider.isNull() && slider.inDragMode()) | |
| 774 mediaControls().updateCurrentTimeDisplay(); | |
| 767 } | 775 } |
| 768 | |
| 769 LayoutSliderItem slider = LayoutSliderItem(toLayoutSlider(layoutObject())); | |
| 770 if (!slider.isNull() && slider.inDragMode()) | |
| 771 mediaControls().updateCurrentTimeDisplay(); | |
| 772 } | 776 } |
| 773 | 777 |
| 774 bool MediaControlTimelineElement::willRespondToMouseClickEvents() { | 778 bool MediaControlTimelineElement::willRespondToMouseClickEvents() { |
| 775 return isConnected() && document().isActive(); | 779 return isConnected() && document().isActive(); |
| 776 } | 780 } |
| 777 | 781 |
| 778 void MediaControlTimelineElement::setPosition(double currentTime) { | 782 void MediaControlTimelineElement::setPosition(double currentTime) { |
| 779 setValue(String::number(currentTime)); | 783 setValue(String::number(currentTime)); |
| 780 | 784 |
| 781 if (LayoutObject* layoutObject = this->layoutObject()) | 785 if (LayoutObject* layoutObject = this->layoutObject()) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 806 slider->ensureUserAgentShadowRoot(); | 810 slider->ensureUserAgentShadowRoot(); |
| 807 slider->setType(InputTypeNames::range); | 811 slider->setType(InputTypeNames::range); |
| 808 slider->setAttribute(stepAttr, "any"); | 812 slider->setAttribute(stepAttr, "any"); |
| 809 slider->setAttribute(maxAttr, "1"); | 813 slider->setAttribute(maxAttr, "1"); |
| 810 slider->setShadowPseudoId( | 814 slider->setShadowPseudoId( |
| 811 AtomicString("-webkit-media-controls-volume-slider")); | 815 AtomicString("-webkit-media-controls-volume-slider")); |
| 812 return slider; | 816 return slider; |
| 813 } | 817 } |
| 814 | 818 |
| 815 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event) { | 819 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()) | 820 if (!isConnected() || !document().isActive()) |
| 822 return; | 821 return; |
| 823 | 822 |
| 824 MediaControlInputElement::defaultEventHandler(event); | 823 MediaControlInputElement::defaultEventHandler(event); |
| 825 | 824 |
| 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) | 825 if (event->type() == EventTypeNames::mousedown) |
|
mlamouri (slow - plz ping)
2017/01/24 02:06:51
`pointerdown`/`pointerup`?
| |
| 832 Platform::current()->recordAction( | 826 Platform::current()->recordAction( |
| 833 UserMetricsAction("Media.Controls.VolumeChangeBegin")); | 827 UserMetricsAction("Media.Controls.VolumeChangeBegin")); |
| 834 | 828 |
| 835 if (event->type() == EventTypeNames::mouseup) | 829 if (event->type() == EventTypeNames::mouseup) |
| 836 Platform::current()->recordAction( | 830 Platform::current()->recordAction( |
| 837 UserMetricsAction("Media.Controls.VolumeChangeEnd")); | 831 UserMetricsAction("Media.Controls.VolumeChangeEnd")); |
| 838 | 832 |
| 839 double volume = value().toDouble(); | 833 if (event->type() == EventTypeNames::input) { |
| 840 mediaElement().setVolume(volume); | 834 double volume = value().toDouble(); |
| 841 mediaElement().setMuted(false); | 835 mediaElement().setVolume(volume); |
| 836 mediaElement().setMuted(false); | |
| 837 } | |
| 842 } | 838 } |
| 843 | 839 |
| 844 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents() { | 840 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents() { |
| 845 if (!isConnected() || !document().isActive()) | 841 if (!isConnected() || !document().isActive()) |
| 846 return false; | 842 return false; |
| 847 | 843 |
| 848 return MediaControlInputElement::willRespondToMouseMoveEvents(); | 844 return MediaControlInputElement::willRespondToMouseMoveEvents(); |
| 849 } | 845 } |
| 850 | 846 |
| 851 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents() { | 847 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents() { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1045 MediaControlCurrentTimeDisplayElement* | 1041 MediaControlCurrentTimeDisplayElement* |
| 1046 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) { | 1042 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) { |
| 1047 MediaControlCurrentTimeDisplayElement* element = | 1043 MediaControlCurrentTimeDisplayElement* element = |
| 1048 new MediaControlCurrentTimeDisplayElement(mediaControls); | 1044 new MediaControlCurrentTimeDisplayElement(mediaControls); |
| 1049 element->setShadowPseudoId( | 1045 element->setShadowPseudoId( |
| 1050 AtomicString("-webkit-media-controls-current-time-display")); | 1046 AtomicString("-webkit-media-controls-current-time-display")); |
| 1051 return element; | 1047 return element; |
| 1052 } | 1048 } |
| 1053 | 1049 |
| 1054 } // namespace blink | 1050 } // namespace blink |
| OLD | NEW |