Changeset 195953 in webkit


Ignore:
Timestamp:
Jan 31, 2016 10:34:07 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Add resize event for HTMLMediaElement
https://bugs.webkit.org/show_bug.cgi?id=125715

Patch by Jeremy Jones <jeremyj@apple.com> on 2016-01-31
Reviewed by Darin Adler.
LayoutTests/imported/w3c:

Rebaselined test after moving 'resize' from DOMWindow.idl to GlobalEventHandlers.idl
per https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers

  • web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

Tests: http/tests/media/hls/hls-video-resize.html

media/video-resize.html

Move resize javascript event from DOMWindow.idl to GlobalEventHandlers.idl
per https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers

Post resize event from video element when metadata loads and when content size changes.

  • dom/GlobalEventHandlers.idl: Add onresize.
  • html/HTMLElement.cpp:

(WebCore::HTMLElement::createEventHandlerNameMap): Add onresizeAttr.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::setReadyState):
(WebCore::HTMLMediaElement::mediaPlayerSizeChanged):

  • html/HTMLMediaElement.h:

(WebCore::HTMLMediaElement::scheduleResizeEvent):
(WebCore::HTMLMediaElement::scheduleResizeEventIfSizeChanged):

  • html/HTMLVideoElement.cpp:

(WebCore::HTMLVideoElement::scheduleResizeEvent): Sechedule event.
(WebCore::HTMLVideoElement::scheduleResizeEventIfSizeChanged): Schedule event if size has changed.

  • html/HTMLVideoElement.h: Add declarations.
  • page/DOMWindow.idl: Remove onresize.

Source/WebInspectorUI:

Add a display name for "resize" event.

  • UserInterface/Models/ScriptTimelineRecord.js:

(WebInspector.ScriptTimelineRecord.EventType.displayName):

LayoutTests:

Update test for change: move resize javascript event from DOMWindow.idl to GlobalEventHandlers.idl
per https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers

  • fast/dom/event-handler-attributes-expected.txt: Rebaselined.
  • fast/dom/event-handler-attributes.html:

Move resize from uniqueWindowEvents to eventsInGlobalEventHandlers.

  • http/tests/media/hls/hls-video-resize-expected.txt: Added.
  • http/tests/media/hls/hls-video-resize.html: Added.
  • js/dom/dom-static-property-for-in-iteration-expected.txt: Rebaselined.
  • media/video-resize-expected.txt: Added.
  • media/video-resize.html: Added.
  • media/video-test.js:

(requiredEvents): Deleted global. Value is now captured by closure.
(waitForEventsAndCall): Remove dependence on global variable, and fix event observation leak.

Location:
trunk
Files:
4 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r195950 r195953  
     12016-01-31  Jeremy Jones  <jeremyj@apple.com>
     2
     3        Add resize event for HTMLMediaElement
     4        https://bugs.webkit.org/show_bug.cgi?id=125715
     5
     6        Reviewed by Darin Adler.
     7       
     8        Update test for change: move resize javascript event from DOMWindow.idl to GlobalEventHandlers.idl
     9        per https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers
     10
     11        * fast/dom/event-handler-attributes-expected.txt: Rebaselined.
     12        * fast/dom/event-handler-attributes.html:
     13            Move resize from uniqueWindowEvents to eventsInGlobalEventHandlers.
     14        * http/tests/media/hls/hls-video-resize-expected.txt: Added.
     15        * http/tests/media/hls/hls-video-resize.html: Added.
     16        * js/dom/dom-static-property-for-in-iteration-expected.txt: Rebaselined.
     17        * media/video-resize-expected.txt: Added.
     18        * media/video-resize.html: Added.
     19        * media/video-test.js:
     20        (requiredEvents): Deleted global. Value is now captured by closure.
     21        (waitForEventsAndCall): Remove dependence on global variable, and fix event observation leak.
     22
    1232016-01-31  Brent Fulgham  <bfulgham@apple.com>
    224
  • trunk/LayoutTests/fast/dom/event-handler-attributes-expected.txt

    r184616 r195953  
    149149PASS testScriptAttribute(document, "readystatechange") is "document"
    150150PASS testScriptAttribute(document, "reset") is "document"
     151PASS testScriptAttribute(document, "resize") is "document"
    151152PASS testScriptAttribute(document, "scroll") is "document"
    152153PASS testScriptAttribute(document, "search") is "document"
     
    181182PASS testScriptAttribute(document, "pageshow") is "none"
    182183PASS testScriptAttribute(document, "popstate") is "none"
    183 PASS testScriptAttribute(document, "resize") is "none"
    184184PASS testScriptAttribute(document, "storage") is "none"
    185185PASS testScriptAttribute(document, "transitionend") is "none"
     
    247247PASS testElementAttribute(element, "ratechange") is "target"
    248248PASS testElementAttribute(element, "reset") is "target"
     249PASS testElementAttribute(element, "resize") is "target"
    249250PASS testElementAttribute(element, "scroll") is "target"
    250251PASS testElementAttribute(element, "search") is "target"
     
    278279PASS testElementAttribute(element, "popstate") is "none"
    279280PASS testElementAttribute(element, "readystatechange") is "none"
    280 PASS testElementAttribute(element, "resize") is "none"
    281281PASS testElementAttribute(element, "selectionchange") is "none"
    282282PASS testElementAttribute(element, "storage") is "none"
     
    340340PASS testElementAttribute(inputElement, "ratechange") is "target"
    341341PASS testElementAttribute(inputElement, "reset") is "target"
     342PASS testElementAttribute(inputElement, "resize") is "target"
    342343PASS testElementAttribute(inputElement, "scroll") is "target"
    343344PASS testElementAttribute(inputElement, "search") is "target"
     
    371372PASS testElementAttribute(inputElement, "popstate") is "none"
    372373PASS testElementAttribute(inputElement, "readystatechange") is "none"
    373 PASS testElementAttribute(inputElement, "resize") is "none"
    374374PASS testElementAttribute(inputElement, "selectionchange") is "none"
    375375PASS testElementAttribute(inputElement, "storage") is "none"
     
    433433PASS testElementAttribute(audioElement, "ratechange") is "target"
    434434PASS testElementAttribute(audioElement, "reset") is "target"
     435PASS testElementAttribute(audioElement, "resize") is "target"
    435436PASS testElementAttribute(audioElement, "scroll") is "target"
    436437PASS testElementAttribute(audioElement, "search") is "target"
     
    464465PASS testElementAttribute(audioElement, "popstate") is "none"
    465466PASS testElementAttribute(audioElement, "readystatechange") is "none"
    466 PASS testElementAttribute(audioElement, "resize") is "none"
    467467PASS testElementAttribute(audioElement, "selectionchange") is "none"
    468468PASS testElementAttribute(audioElement, "storage") is "none"
     
    526526PASS testElementAttribute(videoElement, "ratechange") is "target"
    527527PASS testElementAttribute(videoElement, "reset") is "target"
     528PASS testElementAttribute(videoElement, "resize") is "target"
    528529PASS testElementAttribute(videoElement, "scroll") is "target"
    529530PASS testElementAttribute(videoElement, "search") is "target"
     
    557558PASS testElementAttribute(videoElement, "popstate") is "none"
    558559PASS testElementAttribute(videoElement, "readystatechange") is "none"
    559 PASS testElementAttribute(videoElement, "resize") is "none"
    560560PASS testElementAttribute(videoElement, "selectionchange") is "none"
    561561PASS testElementAttribute(videoElement, "storage") is "none"
     
    817817PASS testElementAttribute(rectElement, "ratechange") is "target"
    818818PASS testElementAttribute(rectElement, "reset") is "target"
     819PASS testElementAttribute(rectElement, "resize") is "target"
    819820PASS testElementAttribute(rectElement, "scroll") is "target"
    820821PASS testElementAttribute(rectElement, "search") is "target"
     
    848849PASS testElementAttribute(rectElement, "popstate") is "none"
    849850PASS testElementAttribute(rectElement, "readystatechange") is "none"
    850 PASS testElementAttribute(rectElement, "resize") is "none"
    851851PASS testElementAttribute(rectElement, "selectionchange") is "none"
    852852PASS testElementAttribute(rectElement, "storage") is "none"
     
    920920PASS testElementAttribute(nonHTMLElement, "readystatechange") is "none"
    921921FAIL testElementAttribute(nonHTMLElement, "reset") should be none. Was script: target; content: none.
    922 PASS testElementAttribute(nonHTMLElement, "resize") is "none"
     922FAIL testElementAttribute(nonHTMLElement, "resize") should be none. Was script: target; content: none.
    923923FAIL testElementAttribute(nonHTMLElement, "scroll") should be none. Was script: target; content: none.
    924924FAIL testElementAttribute(nonHTMLElement, "search") should be none. Was script: target; content: none.
  • trunk/LayoutTests/fast/dom/event-handler-attributes.html

    r187012 r195953  
    5757    "ratechange",
    5858    "reset",
     59    "resize",
    5960    "scroll",
    6061    "seeked",
     
    106107
    107108const uniqueWindowEvents = [
    108     "resize"
    109109];
    110110
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r195924 r195953  
     12016-01-31  Jeremy Jones  <jeremyj@apple.com>
     2
     3        Add resize event for HTMLMediaElement
     4        https://bugs.webkit.org/show_bug.cgi?id=125715
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaselined test after moving 'resize' from DOMWindow.idl to GlobalEventHandlers.idl
     9        per https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers
     10
     11        * web-platform-tests/html/dom/interfaces-expected.txt:
     12
    1132016-01-31  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt

    r195907 r195953  
    110110FAIL Document interface: attribute onratechange assert_equals: getter must be Function expected "function" but got "undefined"
    111111FAIL Document interface: attribute onreset assert_equals: getter must be Function expected "function" but got "undefined"
    112 FAIL Document interface: attribute onresize assert_true: The prototype object must have a property "onresize" expected true got false
     112FAIL Document interface: attribute onresize assert_equals: getter must be Function expected "function" but got "undefined"
    113113FAIL Document interface: attribute onscroll assert_equals: getter must be Function expected "function" but got "undefined"
    114114FAIL Document interface: attribute onseeked assert_equals: getter must be Function expected "function" but got "undefined"
     
    342342PASS Document interface: iframe.contentDocument must inherit property "onratechange" with the proper type (141)
    343343PASS Document interface: iframe.contentDocument must inherit property "onreset" with the proper type (142)
    344 FAIL Document interface: iframe.contentDocument must inherit property "onresize" with the proper type (143) assert_inherits: property "onresize" not found in prototype chain
     344PASS Document interface: iframe.contentDocument must inherit property "onresize" with the proper type (143)
    345345PASS Document interface: iframe.contentDocument must inherit property "onscroll" with the proper type (144)
    346346PASS Document interface: iframe.contentDocument must inherit property "onseeked" with the proper type (145)
     
    657657PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onratechange" with the proper type (141)
    658658PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onreset" with the proper type (142)
    659 FAIL Document interface: document.implementation.createDocument(null, "", null) must inherit property "onresize" with the proper type (143) assert_inherits: property "onresize" not found in prototype chain
     659PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onresize" with the proper type (143)
    660660PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onscroll" with the proper type (144)
    661661PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onseeked" with the proper type (145)
     
    939939FAIL HTMLElement interface: attribute onratechange assert_own_property: expected property "onratechange" missing
    940940FAIL HTMLElement interface: attribute onreset assert_own_property: expected property "onreset" missing
    941 FAIL HTMLElement interface: attribute onresize assert_true: The prototype object must have a property "onresize" expected true got false
     941FAIL HTMLElement interface: attribute onresize assert_own_property: expected property "onresize" missing
    942942FAIL HTMLElement interface: attribute onscroll assert_own_property: expected property "onscroll" missing
    943943FAIL HTMLElement interface: attribute onseeked assert_own_property: expected property "onseeked" missing
     
    10361036PASS HTMLElement interface: document.createElement("noscript") must inherit property "onratechange" with the proper type (79)
    10371037PASS HTMLElement interface: document.createElement("noscript") must inherit property "onreset" with the proper type (80)
    1038 FAIL HTMLElement interface: document.createElement("noscript") must inherit property "onresize" with the proper type (81) assert_inherits: property "onresize" not found in prototype chain
     1038PASS HTMLElement interface: document.createElement("noscript") must inherit property "onresize" with the proper type (81)
    10391039PASS HTMLElement interface: document.createElement("noscript") must inherit property "onscroll" with the proper type (82)
    10401040PASS HTMLElement interface: document.createElement("noscript") must inherit property "onseeked" with the proper type (83)
  • trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt

    r195778 r195953  
    112112PASS a["onratechange"] is null
    113113PASS a["onreset"] is null
     114PASS a["onresize"] is null
    114115PASS a["onscroll"] is null
    115116PASS a["onseeked"] is null
  • trunk/LayoutTests/media/video-test.js

    r183428 r195953  
    350350}
    351351
    352 var requiredEvents = [];
    353 
    354352function waitForEventsAndCall(eventList, func)
    355353{
     354    var requiredEvents = []
     355
    356356    function _eventCallback(event)
    357357    {
     
    359359            return;
    360360
    361         var index = requiredEvents.indexOf(event.type);
    362         if (index < 0)
     361        for (var index = 0; index < requiredEvents.length; index++) {
     362            if (requiredEvents[index][1] === event.type) {
     363                break;
     364            }
     365        }
     366        if (index >= requiredEvents.length)
    363367            return;
    364368
     369        requiredEvents[index][0].removeEventListener(event, _eventCallback);
    365370        requiredEvents.splice(index, 1);
    366371        if (requiredEvents.length)
     
    370375    }
    371376
    372     requiredEvents = [];
    373377    for (var i = 0; i < eventList.length; i++) {
    374         requiredEvents[i] = eventList[i][1];
    375         eventList[i][0].addEventListener(requiredEvents[i], _eventCallback, true);
     378        requiredEvents[i] = eventList[i].slice(0);
     379        requiredEvents[i][0].addEventListener(requiredEvents[i][1], _eventCallback, true);
    376380    }
    377381}
  • trunk/Source/WebCore/ChangeLog

    r195952 r195953  
     12016-01-31  Jeremy Jones  <jeremyj@apple.com>
     2
     3        Add resize event for HTMLMediaElement
     4        https://bugs.webkit.org/show_bug.cgi?id=125715
     5
     6        Reviewed by Darin Adler.
     7
     8        Tests: http/tests/media/hls/hls-video-resize.html
     9               media/video-resize.html
     10
     11        Move resize javascript event from DOMWindow.idl to GlobalEventHandlers.idl
     12        per https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers
     13
     14        Post resize event from video element when metadata loads and when content size changes.
     15
     16        * dom/GlobalEventHandlers.idl: Add onresize.
     17        * html/HTMLElement.cpp:
     18        (WebCore::HTMLElement::createEventHandlerNameMap): Add onresizeAttr.
     19        * html/HTMLMediaElement.cpp:
     20        (WebCore::HTMLMediaElement::setReadyState):
     21        (WebCore::HTMLMediaElement::mediaPlayerSizeChanged):
     22        * html/HTMLMediaElement.h:
     23        (WebCore::HTMLMediaElement::scheduleResizeEvent):
     24        (WebCore::HTMLMediaElement::scheduleResizeEventIfSizeChanged):
     25        * html/HTMLVideoElement.cpp:
     26        (WebCore::HTMLVideoElement::scheduleResizeEvent): Sechedule event.
     27        (WebCore::HTMLVideoElement::scheduleResizeEventIfSizeChanged): Schedule event if size has changed.
     28        * html/HTMLVideoElement.h: Add declarations.
     29        * page/DOMWindow.idl: Remove onresize.
     30
    1312016-01-31  Darin Adler  <darin@apple.com>
    232
  • trunk/Source/WebCore/dom/GlobalEventHandlers.idl

    r195778 r195953  
    8181    attribute EventHandler onratechange;
    8282    attribute EventHandler onreset;
    83     // attribute EventHandler onresize;
     83    attribute EventHandler onresize;
    8484    attribute EventHandler onscroll;
    8585    attribute EventHandler onseeked;
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r195501 r195953  
    315315        &onratechangeAttr,
    316316        &onresetAttr,
     317        &onresizeAttr,
    317318        &onscrollAttr,
    318319        &onsearchAttr,
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r195755 r195953  
    21512151        prepareMediaFragmentURI();
    21522152        scheduleEvent(eventNames().durationchangeEvent);
     2153        scheduleResizeEvent();
    21532154        scheduleEvent(eventNames().loadedmetadataEvent);
    21542155#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     
    44974498
    44984499    beginProcessingMediaPlayerCallback();
     4500    if (m_readyState > HAVE_NOTHING)
     4501        scheduleResizeEventIfSizeChanged();
    44994502    if (renderer())
    45004503        renderer()->updateFromElement();
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r195755 r195953  
    639639   
    640640    void scheduleTimeupdateEvent(bool periodicEvent);
     641    virtual void scheduleResizeEvent() { }
     642    virtual void scheduleResizeEventIfSizeChanged() { }
    641643
    642644    // loading
  • trunk/Source/WebCore/html/HTMLVideoElement.cpp

    r195487 r195953  
    187187}
    188188
     189void HTMLVideoElement::scheduleResizeEvent()
     190{
     191    m_lastReportedVideoWidth = videoWidth();
     192    m_lastReportedVideoHeight = videoHeight();
     193    scheduleEvent(eventNames().resizeEvent);
     194}
     195
     196void HTMLVideoElement::scheduleResizeEventIfSizeChanged()
     197{
     198    if (m_lastReportedVideoWidth == videoWidth() && m_lastReportedVideoHeight == videoHeight())
     199        return;
     200    scheduleResizeEvent();
     201}
     202
    189203bool HTMLVideoElement::isURLAttribute(const Attribute& attribute) const
    190204{
  • trunk/Source/WebCore/html/HTMLVideoElement.h

    r195487 r195953  
    4242    WEBCORE_EXPORT unsigned videoWidth() const;
    4343    WEBCORE_EXPORT unsigned videoHeight() const;
    44    
     44
    4545    // Fullscreen
    4646    void webkitEnterFullscreen(ExceptionCode&);
     
    9090    HTMLVideoElement(const QualifiedName&, Document&, bool);
    9191
     92    virtual void scheduleResizeEvent() override;
     93    virtual void scheduleResizeEventIfSizeChanged() override;
    9294    virtual bool rendererIsNeeded(const RenderStyle&) override;
    9395    virtual void didAttachRenderers() override;
     
    111113
    112114    AtomicString m_defaultPosterURL;
     115
     116    unsigned m_lastReportedVideoWidth { 0 };
     117    unsigned m_lastReportedVideoHeight { 0 };
    113118};
    114119
  • trunk/Source/WebCore/page/DOMWindow.idl

    r195907 r195953  
    216216    // Event Handlers
    217217
    218     // FIXME: This should be in GlobalEventHandlers.idl according to HTML5 - https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers
    219     [NotEnumerable] attribute EventHandler onresize;
    220 
    221218    // Unique to Element and DOMWindow
    222219    // FIXME: Should these be exposed on Document as well (and therefore moved to GlobalEventHandlers.idl)?
  • trunk/Source/WebInspectorUI/ChangeLog

    r195923 r195953  
     12016-01-31  Jeremy Jones  <jeremyj@apple.com>
     2
     3        Add resize event for HTMLMediaElement
     4        https://bugs.webkit.org/show_bug.cgi?id=125715
     5
     6        Reviewed by Darin Adler.
     7
     8        Add a display name for "resize" event.
     9
     10        * UserInterface/Models/ScriptTimelineRecord.js:
     11        (WebInspector.ScriptTimelineRecord.EventType.displayName):
     12
    1132016-01-30  Dave Hyatt  <hyatt@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js

    r195566 r195953  
    293293        nameMap.set("removestream", "Remove Stream");
    294294        nameMap.set("removetrack", "Remove Track");
     295        nameMap.set("resize", "Resize");
    295296        nameMap.set("securitypolicyviolation", "Security Policy Violation");
    296297        nameMap.set("selectionchange", "Selection Change");
Note: See TracChangeset for help on using the changeset viewer.