Changeset 150371 in webkit
- Timestamp:
- May 20, 2013 9:47:07 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r150370 r150371 1 2013-05-20 Antoine Quint <graouts@apple.com> 2 3 [Mac] captions menu should behave more like a menu 4 https://bugs.webkit.org/show_bug.cgi?id=116436 5 6 Reviewed by Eric Carlson. 7 8 New test that checks that the caption menu hides when clicking outside 9 of the bounds of the media element. 10 11 * media/video-controls-captions-trackmenu-hide-on-click-outside-expected.txt: Added. 12 * media/video-controls-captions-trackmenu-hide-on-click-outside.html: Added. 13 * platform/efl/TestExpectations: 14 * platform/gtk/TestExpectations: 15 * platform/qt/TestExpectations: 16 * platform/win/TestExpectations: 17 1 18 2013-05-18 Rashmi Shyamasundar <rashmi.s2@samsung.com> 2 19 -
trunk/LayoutTests/platform/efl/TestExpectations
r150368 r150371 1619 1619 webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ] 1620 1620 webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click.html [ Skip ] 1621 webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click-outside.html [ Skip ] 1621 1622 webkit.org/b/101670 media/track/track-user-preferences.html [ Skip ] 1622 1623 -
trunk/LayoutTests/platform/gtk/TestExpectations
r150275 r150371 745 745 webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ] 746 746 webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click.html [ Skip ] 747 webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click-outside.html [ Skip ] 747 748 webkit.org/b/101670 media/track/track-user-preferences.html [ Skip ] 748 749 -
trunk/LayoutTests/platform/qt/TestExpectations
r150250 r150371 2598 2598 webkit.org/b/101670 media/video-controls-captions-trackmenu-localized.html [ Skip ] 2599 2599 webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click.html [ Skip ] 2600 webkit.org/b/101670 media/video-controls-captions-trackmenu-hide-on-click-outside.html [ Skip ] 2600 2601 webkit.org/b/101670 media/track/track-user-preferences.html [ Skip ] 2601 2602 -
trunk/LayoutTests/platform/win/TestExpectations
r150090 r150371 2560 2560 media/video-controls-captions-trackmenu.html 2561 2561 media/video-controls-captions-trackmenu-hide-on-click.html 2562 media/video-controls-captions-trackmenu-hide-on-click-outside.html 2562 2563 media/video-controls-visible-exiting-fullscreen.html 2563 2564 -
trunk/Source/WebCore/ChangeLog
r150370 r150371 1 2013-05-20 Antoine Quint <graouts@apple.com> 2 3 [Mac] captions menu should behave more like a menu 4 https://bugs.webkit.org/show_bug.cgi?id=116436 5 6 Reviewed by Eric Carlson. 7 8 Let the captions menu behave more like a native Mac menu by hiding it when 9 clicking anywhere on the page and preventing the page from scrolling when 10 attempting to scroll the captions menu when it cannot scroll in the requested 11 direction. 12 13 Test: media/video-controls-captions-trackmenu-hide-on-click-outside.html 14 15 * dom/EventListener.h: 16 Add the new MediaControlsAppleEventListenerType. 17 18 * html/shadow/MediaControlsApple.cpp: 19 (WebCore::MediaControlsApple::defaultEventHandler): 20 (WebCore::MediaControlsApple::hide): 21 (WebCore::MediaControlsApple::makeTransparent): 22 (WebCore::MediaControlsApple::changedClosedCaptionsVisibility): 23 (WebCore::MediaControlsApple::reportedError): 24 (WebCore::MediaControlsApple::toggleClosedCaptionTrackList): 25 Use the hideClosedCaptionTrackList() and showClosedCaptionTrackList() 26 methods to hide and show the captions menu instead of calling hide() 27 and show() directly on m_closedCaptionsContainer. 28 29 (WebCore::MediaControlsApple::showClosedCaptionTrackList): 30 Show the m_closedCaptionsContainer and register a "mousewheel" event 31 listener on it as well as a "click" event listener on the entire document. 32 33 (WebCore::MediaControlsApple::hideClosedCaptionTrackList): 34 Hide the m_closedCaptionsContainer and remove the "mousewheel" event 35 listener on it as well as the "click" event listener on the entire document. 36 37 (WebCore::MediaControlsApple::shouldClosedCaptionsContainerPreventPageScrolling): 38 New private utility to determine whether the m_closedCaptionsContainer can scroll 39 in the provided scroll direction. 40 41 (WebCore::MediaControlsApple::eventListener): 42 Obtain the event listener used for "mousewheel" and "click" event handlers. 43 44 (WebCore::MediaControlsAppleEventListener::handleEvent): 45 Event handler for the "mousewheel" and "click" events. If we get a "click" event, we 46 toggle the captions menu visibility and if we get a "mousewheel" event, we call into 47 shouldClosedCaptionsContainerPreventPageScrolling() to see if we can scroll in the 48 current scroll direction, and if not prevent the event from resulting in a scroll by 49 calling preventDefault(). 50 51 (WebCore::MediaControlsAppleEventListener::operator==): 52 Required for the successful subclassing of EventListener. 53 54 * html/shadow/MediaControlsApple.h: 55 (MediaControlsAppleEventListener): 56 (WebCore::MediaControlsAppleEventListener::create): 57 (WebCore::MediaControlsAppleEventListener::cast): 58 (WebCore::MediaControlsAppleEventListener::MediaControlsAppleEventListener): 59 New subclass of EventListener required to provide a custom event listener for the 60 "mousewheel" and "click" events registered in showClosedCaptionTrackList() and 61 hideClosedCaptionTrackList(). 62 1 63 2013-05-18 Rashmi Shyamasundar <rashmi.s2@samsung.com> 2 64 -
trunk/Source/WebCore/dom/EventListener.h
r147795 r150371 44 44 GObjectEventListenerType, 45 45 NativeEventListenerType, 46 SVGTRefTargetEventListenerType 46 SVGTRefTargetEventListenerType, 47 MediaControlsAppleEventListenerType 47 48 }; 48 49 -
trunk/Source/WebCore/html/shadow/MediaControlsApple.cpp
r149942 r150371 39 39 #include "RenderTheme.h" 40 40 #include "Text.h" 41 #include "WheelEvent.h" 41 42 42 43 #if ENABLE(VIDEO_TRACK) … … 279 280 if (event->type() == eventNames().clickEvent) { 280 281 if (m_closedCaptionsContainer && m_closedCaptionsContainer->isShowing()) { 281 m_closedCaptionsContainer->hide();282 hideClosedCaptionTrackList(); 282 283 event->setDefaultHandled(); 283 284 } … … 292 293 m_volumeSliderContainer->hide(); 293 294 if (m_closedCaptionsContainer) 294 m_closedCaptionsContainer->hide();295 hideClosedCaptionTrackList(); 295 296 } 296 297 … … 300 301 m_volumeSliderContainer->hide(); 301 302 if (m_closedCaptionsContainer) 302 m_closedCaptionsContainer->hide();303 hideClosedCaptionTrackList(); 303 304 } 304 305 … … 307 308 MediaControls::changedClosedCaptionsVisibility(); 308 309 if (m_closedCaptionsContainer && m_closedCaptionsContainer->isShowing()) 309 m_closedCaptionsContainer->hide();310 hideClosedCaptionTrackList(); 310 311 311 312 } … … 415 416 m_toggleClosedCaptionsButton->hide(); 416 417 if (m_closedCaptionsContainer) 417 m_closedCaptionsContainer->hide();418 hideClosedCaptionTrackList(); 418 419 } 419 420 … … 499 500 if (m_closedCaptionsContainer) { 500 501 if (m_closedCaptionsContainer->isShowing()) 501 m_closedCaptionsContainer->hide();502 hideClosedCaptionTrackList(); 502 503 else { 503 504 if (m_closedCaptionsTrackList) 504 505 m_closedCaptionsTrackList->updateDisplay(); 505 m_closedCaptionsContainer->show();506 showClosedCaptionTrackList(); 506 507 } 507 508 } 509 } 510 511 void MediaControlsApple::showClosedCaptionTrackList() 512 { 513 if (!m_closedCaptionsContainer || m_closedCaptionsContainer->isShowing()) 514 return; 515 516 m_closedCaptionsContainer->show(); 517 518 RefPtr<EventListener> listener = eventListener(); 519 m_closedCaptionsContainer->addEventListener(eventNames().mousewheelEvent, listener, true); 520 document()->addEventListener(eventNames().clickEvent, listener, true); 521 } 522 523 void MediaControlsApple::hideClosedCaptionTrackList() 524 { 525 if (!m_closedCaptionsContainer || !m_closedCaptionsContainer->isShowing()) 526 return; 527 528 m_closedCaptionsContainer->hide(); 529 530 EventListener* listener = eventListener().get(); 531 m_closedCaptionsContainer->removeEventListener(eventNames().mousewheelEvent, listener, true); 532 document()->removeEventListener(eventNames().clickEvent, listener, true); 533 } 534 535 bool MediaControlsApple::shouldClosedCaptionsContainerPreventPageScrolling(int wheelDeltaY) 536 { 537 int scrollTop = m_closedCaptionsContainer->scrollTop(); 538 // Scrolling down. 539 if (wheelDeltaY < 0 && (scrollTop + m_closedCaptionsContainer->offsetHeight()) >= m_closedCaptionsContainer->scrollHeight()) 540 return true; 541 // Scrolling up. 542 if (wheelDeltaY > 0 && scrollTop <= 0) 543 return true; 544 return false; 508 545 } 509 546 … … 518 555 } 519 556 557 PassRefPtr<MediaControlsAppleEventListener> MediaControlsApple::eventListener() 558 { 559 if (!m_eventListener) 560 m_eventListener = MediaControlsAppleEventListener::create(this); 561 return m_eventListener; 562 } 563 564 // -------- 565 566 void MediaControlsAppleEventListener::handleEvent(ScriptExecutionContext*, Event* event) 567 { 568 if (event->type() == eventNames().clickEvent && !m_mediaControls->contains(event->target()->toNode())) 569 m_mediaControls->toggleClosedCaptionTrackList(); 570 571 if (event->type() == eventNames().mousewheelEvent && event->hasInterface(eventNames().interfaceForWheelEvent)) { 572 WheelEvent* wheelEvent = static_cast<WheelEvent*>(event); 573 if (m_mediaControls->shouldClosedCaptionsContainerPreventPageScrolling(wheelEvent->wheelDeltaY())) 574 event->preventDefault(); 575 } 576 } 577 578 bool MediaControlsAppleEventListener::operator==(const EventListener& listener) 579 { 580 if (const MediaControlsAppleEventListener* mediaControlsAppleEventListener = MediaControlsAppleEventListener::cast(&listener)) 581 return m_mediaControls == mediaControlsAppleEventListener->m_mediaControls; 582 return false; 583 } 584 520 585 } 521 586 -
trunk/Source/WebCore/html/shadow/MediaControlsApple.h
r142774 r150371 34 34 namespace WebCore { 35 35 36 class MediaControlsApple; 37 38 class MediaControlsAppleEventListener : public EventListener { 39 public: 40 static PassRefPtr<MediaControlsAppleEventListener> create(MediaControlsApple* mediaControls) { return adoptRef(new MediaControlsAppleEventListener(mediaControls)); } 41 static const MediaControlsAppleEventListener* cast(const EventListener* listener) 42 { 43 return listener->type() == MediaControlsAppleEventListenerType 44 ? static_cast<const MediaControlsAppleEventListener*>(listener) 45 : 0; 46 } 47 48 virtual bool operator==(const EventListener& other); 49 50 private: 51 MediaControlsAppleEventListener(MediaControlsApple* mediaControls) 52 : EventListener(MediaControlsAppleEventListenerType) 53 , m_mediaControls(mediaControls) 54 { 55 } 56 57 virtual void handleEvent(ScriptExecutionContext*, Event*); 58 59 MediaControlsApple* m_mediaControls; 60 }; 61 36 62 class MediaControlsApple : public MediaControls { 37 63 public: … … 63 89 virtual void closedCaptionTracksChanged() OVERRIDE; 64 90 91 bool shouldClosedCaptionsContainerPreventPageScrolling(int wheelDeltaY); 92 65 93 private: 66 94 MediaControlsApple(Document*); 67 95 68 96 virtual void defaultEventHandler(Event*) OVERRIDE; 97 PassRefPtr<MediaControlsAppleEventListener> eventListener(); 98 99 void showClosedCaptionTrackList(); 100 void hideClosedCaptionTrackList(); 69 101 70 102 MediaControlRewindButtonElement* m_rewindButton; … … 82 114 MediaControlFullscreenVolumeSliderElement* m_fullScreenVolumeSlider; 83 115 MediaControlFullscreenVolumeMaxButtonElement* m_fullScreenMaxVolumeButton; 116 RefPtr<MediaControlsAppleEventListener> m_eventListener; 84 117 }; 85 118
Note: See TracChangeset
for help on using the changeset viewer.