Title: [232044] trunk/Source
Revision
232044
Author
[email protected]
Date
2018-05-21 20:11:30 -0700 (Mon, 21 May 2018)

Log Message

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

Patch by Chris Nardi <[email protected]> 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:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232043 => 232044)


--- trunk/Source/WebCore/ChangeLog	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebCore/ChangeLog	2018-05-22 03:11:30 UTC (rev 232044)
@@ -1,3 +1,24 @@
+2018-05-21  Chris Nardi  <[email protected]>
+
+        Remove dead exception in MediaList.appendMedium
+        https://bugs.webkit.org/show_bug.cgi?id=185278
+
+        Reviewed by Chris Dumez.
+
+        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:
+
 2018-05-21  Chris Dumez  <[email protected]>
 
         File's structured serialization should serialize lastModified attribute

Modified: trunk/Source/WebCore/css/MediaList.cpp (232043 => 232044)


--- trunk/Source/WebCore/css/MediaList.cpp	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebCore/css/MediaList.cpp	2018-05-22 03:11:30 UTC (rev 232044)
@@ -96,13 +96,13 @@
     
     // Only continue if exactly one media query is found, as described above.
     if (result->m_queries.size() != 1)
-        return true;
+        return false;
     
     // If comparing with any of the media queries in the collection of media
     // queries returns true terminate these steps.
     for (size_t i = 0; i < m_queries.size(); ++i) {
         if (m_queries[i] == result->m_queries[0])
-            return true;
+            return false;
     }
     
     m_queries.append(result->m_queries[0]);
@@ -204,18 +204,14 @@
     return { };
 }
 
-ExceptionOr<void> MediaList::appendMedium(const String& medium)
+void MediaList::appendMedium(const String& medium)
 {
     CSSStyleSheet::RuleMutationScope mutationScope(m_parentRule);
 
-    bool success = m_mediaQueries->add(medium);
-    if (!success) {
-        // FIXME: Should this really be InvalidCharacterError?
-        return Exception { InvalidCharacterError };
-    }
+    if (!m_mediaQueries->add(medium))
+        return;
     if (m_parentStyleSheet)
         m_parentStyleSheet->didMutate();
-    return { };
 }
 
 void MediaList::reattach(MediaQuerySet* mediaQueries)

Modified: trunk/Source/WebCore/css/MediaList.h (232043 => 232044)


--- trunk/Source/WebCore/css/MediaList.h	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebCore/css/MediaList.h	2018-05-22 03:11:30 UTC (rev 232044)
@@ -90,7 +90,7 @@
     unsigned length() const { return m_mediaQueries->queryVector().size(); }
     WEBCORE_EXPORT String item(unsigned index) const;
     WEBCORE_EXPORT ExceptionOr<void> deleteMedium(const String& oldMedium);
-    WEBCORE_EXPORT ExceptionOr<void> appendMedium(const String& newMedium);
+    WEBCORE_EXPORT void appendMedium(const String& newMedium);
 
     String mediaText() const { return m_mediaQueries->mediaText(); }
     WEBCORE_EXPORT ExceptionOr<void> setMediaText(const String&);

Modified: trunk/Source/WebCore/css/MediaList.idl (232043 => 232044)


--- trunk/Source/WebCore/css/MediaList.idl	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebCore/css/MediaList.idl	2018-05-22 03:11:30 UTC (rev 232044)
@@ -35,5 +35,5 @@
     getter DOMString? item(unsigned long index);
 
     [MayThrowException] void deleteMedium(DOMString oldMedium);
-    [MayThrowException] void appendMedium(DOMString newMedium);
+    void appendMedium(DOMString newMedium);
 };

Modified: trunk/Source/WebKit/ChangeLog (232043 => 232044)


--- trunk/Source/WebKit/ChangeLog	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebKit/ChangeLog	2018-05-22 03:11:30 UTC (rev 232044)
@@ -1,3 +1,15 @@
+2018-05-21  Chris Nardi  <[email protected]>
+
+        Remove dead exception in MediaList.appendMedium
+        https://bugs.webkit.org/show_bug.cgi?id=185278
+
+        Reviewed by Chris Dumez.
+
+        Remove code pertaining to an exception being thrown by appendMedium().
+
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp:
+        (webkit_dom_media_list_append_medium):
+
 2018-05-21  Aditya Keerthi  <[email protected]>
 
         [iOS] Click events only fire once when editing

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp (232043 => 232044)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp	2018-05-22 03:11:30 UTC (rev 232044)
@@ -194,11 +194,7 @@
     g_return_if_fail(!error || !*error);
     WebCore::MediaList* item = WebKit::core(self);
     WTF::String convertedNewMedium = WTF::String::fromUTF8(newMedium);
-    auto result = item->appendMedium(convertedNewMedium);
-    if (result.hasException()) {
-        auto description = WebCore::DOMException::description(result.releaseException().code());
-        g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
-    }
+    item->appendMedium(convertedNewMedium);
 }
 
 gchar* webkit_dom_media_list_get_media_text(WebKitDOMMediaList* self)

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (232043 => 232044)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-05-22 03:11:30 UTC (rev 232044)
@@ -1,3 +1,15 @@
+2018-05-21  Chris Nardi  <[email protected]>
+
+        Remove dead exception in MediaList.appendMedium
+        https://bugs.webkit.org/show_bug.cgi?id=185278
+
+        Reviewed by Chris Dumez.
+
+        Remove code pertaining to an exception being thrown by appendMedium().
+
+        * DOM/DOMMediaList.mm:
+        (-[DOMMediaList appendMedium:]):
+
 2018-05-21  Jer Noble  <[email protected]>
 
         Complete fix for enabling modern EME by default

Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMMediaList.mm (232043 => 232044)


--- trunk/Source/WebKitLegacy/mac/DOM/DOMMediaList.mm	2018-05-22 02:24:18 UTC (rev 232043)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMMediaList.mm	2018-05-22 03:11:30 UTC (rev 232044)
@@ -85,7 +85,7 @@
 - (void)appendMedium:(NSString *)newMedium
 {
     WebCore::JSMainThreadNullState state;
-    raiseOnDOMError(IMPL->appendMedium(newMedium));
+    IMPL->appendMedium(newMedium);
 }
 
 @end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to