Changeset 232044 in webkit


Ignore:
Timestamp:
May 21, 2018 8:11:30 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Remove dead exception in MediaList.appendMedium
https://bugs.webkit.org/show_bug.cgi?id=185278

Patch by Chris Nardi <cnardi@chromium.org> on 2018-05-21
Reviewed by Chris Dumez.

Source/WebCore:

MediaList.appendMedium was able to throw an exception, but MediaQuerySet::add() always
returned true, making it impossible for that exception to be thrown. This matched the
spec, as |appendMedium| is not specified to throw an exception. Remove the dead code
surrounding the exception, and make MediaQuerySet::add() return false if the medium is
not added.

No new/modified tests as there should be no functional changes.

  • css/MediaList.cpp:

(WebCore::MediaQuerySet::add):
(WebCore::MediaList::appendMedium):

  • css/MediaList.h:
  • css/MediaList.idl:

Source/WebKit:

Remove code pertaining to an exception being thrown by appendMedium().

  • WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp:

(webkit_dom_media_list_append_medium):

Source/WebKitLegacy/mac:

Remove code pertaining to an exception being thrown by appendMedium().

  • DOM/DOMMediaList.mm:

(-[DOMMediaList appendMedium:]):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r232043 r232044  
     12018-05-21  Chris Nardi  <cnardi@chromium.org>
     2
     3        Remove dead exception in MediaList.appendMedium
     4        https://bugs.webkit.org/show_bug.cgi?id=185278
     5
     6        Reviewed by Chris Dumez.
     7
     8        MediaList.appendMedium was able to throw an exception, but MediaQuerySet::add() always
     9        returned true, making it impossible for that exception to be thrown. This matched the
     10        spec, as |appendMedium| is not specified to throw an exception. Remove the dead code
     11        surrounding the exception, and make MediaQuerySet::add() return false if the medium is
     12        not added.
     13
     14        No new/modified tests as there should be no functional changes.
     15
     16        * css/MediaList.cpp:
     17        (WebCore::MediaQuerySet::add):
     18        (WebCore::MediaList::appendMedium):
     19        * css/MediaList.h:
     20        * css/MediaList.idl:
     21
    1222018-05-21  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/css/MediaList.cpp

    r229654 r232044  
    9797    // Only continue if exactly one media query is found, as described above.
    9898    if (result->m_queries.size() != 1)
    99         return true;
     99        return false;
    100100   
    101101    // If comparing with any of the media queries in the collection of media
     
    103103    for (size_t i = 0; i < m_queries.size(); ++i) {
    104104        if (m_queries[i] == result->m_queries[0])
    105             return true;
     105            return false;
    106106    }
    107107   
     
    205205}
    206206
    207 ExceptionOr<void> MediaList::appendMedium(const String& medium)
     207void MediaList::appendMedium(const String& medium)
    208208{
    209209    CSSStyleSheet::RuleMutationScope mutationScope(m_parentRule);
    210210
    211     bool success = m_mediaQueries->add(medium);
    212     if (!success) {
    213         // FIXME: Should this really be InvalidCharacterError?
    214         return Exception { InvalidCharacterError };
    215     }
     211    if (!m_mediaQueries->add(medium))
     212        return;
    216213    if (m_parentStyleSheet)
    217214        m_parentStyleSheet->didMutate();
    218     return { };
    219215}
    220216
  • trunk/Source/WebCore/css/MediaList.h

    r229654 r232044  
    9191    WEBCORE_EXPORT String item(unsigned index) const;
    9292    WEBCORE_EXPORT ExceptionOr<void> deleteMedium(const String& oldMedium);
    93     WEBCORE_EXPORT ExceptionOr<void> appendMedium(const String& newMedium);
     93    WEBCORE_EXPORT void appendMedium(const String& newMedium);
    9494
    9595    String mediaText() const { return m_mediaQueries->mediaText(); }
  • trunk/Source/WebCore/css/MediaList.idl

    r222429 r232044  
    3636
    3737    [MayThrowException] void deleteMedium(DOMString oldMedium);
    38     [MayThrowException] void appendMedium(DOMString newMedium);
     38    void appendMedium(DOMString newMedium);
    3939};
  • trunk/Source/WebKit/ChangeLog

    r232040 r232044  
     12018-05-21  Chris Nardi  <cnardi@chromium.org>
     2
     3        Remove dead exception in MediaList.appendMedium
     4        https://bugs.webkit.org/show_bug.cgi?id=185278
     5
     6        Reviewed by Chris Dumez.
     7
     8        Remove code pertaining to an exception being thrown by appendMedium().
     9
     10        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp:
     11        (webkit_dom_media_list_append_medium):
     12
    1132018-05-21  Aditya Keerthi  <akeerthi@apple.com>
    214
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp

    r229973 r232044  
    195195    WebCore::MediaList* item = WebKit::core(self);
    196196    WTF::String convertedNewMedium = WTF::String::fromUTF8(newMedium);
    197     auto result = item->appendMedium(convertedNewMedium);
    198     if (result.hasException()) {
    199         auto description = WebCore::DOMException::description(result.releaseException().code());
    200         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
    201     }
     197    item->appendMedium(convertedNewMedium);
    202198}
    203199
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r232024 r232044  
     12018-05-21  Chris Nardi  <cnardi@chromium.org>
     2
     3        Remove dead exception in MediaList.appendMedium
     4        https://bugs.webkit.org/show_bug.cgi?id=185278
     5
     6        Reviewed by Chris Dumez.
     7
     8        Remove code pertaining to an exception being thrown by appendMedium().
     9
     10        * DOM/DOMMediaList.mm:
     11        (-[DOMMediaList appendMedium:]):
     12
    1132018-05-21  Jer Noble  <jer.noble@apple.com>
    214
  • trunk/Source/WebKitLegacy/mac/DOM/DOMMediaList.mm

    r207396 r232044  
    8686{
    8787    WebCore::JSMainThreadNullState state;
    88     raiseOnDOMError(IMPL->appendMedium(newMedium));
     88    IMPL->appendMedium(newMedium);
    8989}
    9090
Note: See TracChangeset for help on using the changeset viewer.