Move many miscellaneous classes from ExceptionCode to Exception
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Oct 2016 07:00:10 +0000 (07:00 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Oct 2016 07:00:10 +0000 (07:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163645

Reviewed by Ryosuke Niwa.

Source/WebCore:

* bindings/js/JSCryptoCustom.cpp:
(WebCore::JSCrypto::getRandomValues): Use propagateException.
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::handlePostMessage): Ditto.
(WebCore::JSDOMWindow::setTimeout): Use toJSNumber.
(WebCore::JSDOMWindow::setInterval): Ditto.
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::nameGetter): Use propagateException.
(WebCore::JSStorage::deleteProperty): Ditto.
(WebCore::JSStorage::getOwnPropertyNames): Ditto.
(WebCore::JSStorage::putDelegate): Ditto.

* loader/appcache/DOMApplicationCache.cpp:
(WebCore::DOMApplicationCache::update): Use ExceptionOr.
(WebCore::DOMApplicationCache::swapCache): Ditto.
* loader/appcache/DOMApplicationCache.h: Update for above changes.
* loader/appcache/DOMApplicationCache.idl: Use non-legacy exceptions.

* page/Crypto.cpp:
(WebCore::Crypto::getRandomValues): Use ExceptionOr.
(WebCore::Crypto::webkitSubtle): Ditto.
* page/Crypto.h: Updated for above changes.
* page/Crypto.idl: Use non-legacy exceptions.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::DOMWindow): Initialize many data members in
the class definition instead of here.
(WebCore::DOMWindow::page): Use nullptr.
(WebCore::DOMWindow::screen): Ditto.
(WebCore::DOMWindow::crypto): Ditto.
(WebCore::DOMWindow::locationbar): Ditto.
(WebCore::DOMWindow::menubar): Ditto.
(WebCore::DOMWindow::personalbar): Ditto.
(WebCore::DOMWindow::scrollbars): Ditto.
(WebCore::DOMWindow::statusbar): Ditto.
(WebCore::DOMWindow::toolbar): Ditto.
(WebCore::DOMWindow::applicationCache): Ditto.
(WebCore::DOMWindow::sessionStorage): Use ExceptionOr.
(WebCore::DOMWindow::localStorage): Ditto.
(WebCore::DOMWindow::postMessage): Ditto.
(WebCore::DOMWindow::frameElement): Use nullptr.
(WebCore::DOMWindow::self): Ditto.
(WebCore::DOMWindow::opener): Ditto.
(WebCore::DOMWindow::parent): Ditto.
(WebCore::DOMWindow::top): Ditto.
(WebCore::DOMWindow::getComputedStyle): Use Ref.
(WebCore::DOMWindow::setTimeout): Use ExceptionOr.
(WebCore::DOMWindow::setInterval): Ditto.
(WebCore::didAddStorageEventListener): Use a reference instead of a
pointer, and ignore return value instead of using IGNORE_EXCEPTION.
(WebCore::DOMWindow::addEventListener): Pass reference to function above.
(WebCore::DOMWindow::dispatchEvent): Use enum class version of PageStatus.
* page/DOMWindow.h: Updated for changes above. Also changed indentatation.
* page/DOMWindow.idl: Use non-legacy exceptions.

* page/EventSource.cpp:
(WebCore::EventSource::create): Use ExceptionOr.
* page/EventSource.h: Updated for change above.
* page/EventSource.idl: Use non-legacy exception.

* page/Location.cpp:
(WebCore::Location::setProtocol): Use ExceptionOr.
* page/Location.h: Updated for change above.
* page/Location.idl: Use non-legacy exception.

* page/Performance.cpp:
(WebCore::Performance::Performance): Remove unnecessary initialization of
smart pointer to null, and moved initialization of m_resourceTimingBufferSize
to the header.
(WebCore::Performance::navigation): Made non-const and return a reference.
(WebCore::Performance::timing): Ditto.
(WebCore::Performance::addResourceTiming): Change LoadTiming argument to use
a const& instead of passing in a copy.
(WebCore::Performance::webkitMark): Use ExceptionOr and make_unique.
(WebCore::Performance::webkitClearMarks): Ditto.
(WebCore::Performance::webkitMeasure): Ditto.
(WebCore::Performance::webkitClearMeasures): Ditto.
(WebCore::Performance::reduceTimeResolution): Use std::floor.
* page/Performance.h: Updated for above changes. Removed unneeded includes.
Made more things private. Removed unneeded reference counting of UserTiming.
* page/Performance.idl: Use non-legacy exceptions.

* page/PerformanceUserTiming.cpp:
(WebCore::restrictedMarkFunction): Removed unneeded class name.
(WebCore::UserTiming::UserTiming): Take a reference instead of a pointer.
(WebCore::UserTiming::mark): Use ExceptionOr.
(WebCore::UserTiming::findExistingMarkStartTime): Ditto.
(WebCore::UserTiming::measure): Ditto.
(WebCore::getEntrySequenceByName): Simplified code using HashMap::get.
* page/PerformanceUserTiming.h: Updated for above changes. Removed reference
counting since this is a single-owner object.

* page/UserMessageHandler.cpp:
(WebCore::UserMessageHandler::postMessage): Use ExceptionOr.
* page/UserMessageHandler.h: Updated for above change.
* page/UserMessageHandler.idl: Use non-legacy exception.

* storage/Storage.cpp:
(WebCore::Storage::length): Use ExceptionOr.
(WebCore::Storage::key): Ditto.
(WebCore::Storage::getItem): Ditto.
(WebCore::Storage::setItem): Ditto.
(WebCore::Storage::removeItem): Ditto.
(WebCore::Storage::clear): Ditto.
(WebCore::Storage::contains): Ditto.
* storage/Storage.h: Updated for above change.
* storage/Storage.idl: Use non-legacy exceptions.

* storage/StorageEventDispatcher.cpp:
(WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames):
Updated for ExceptionOr.
(WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames): Ditto.

Source/WebKit/win:

* DOMCoreClasses.cpp:
(DOMDocument::getComputedStyle): Use ptr instead of get since the return
value is now Ref instead of RefPtr.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207522 268f45cc-cd09-0410-ab3c-d52691b4dbfc

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCryptoCustom.cpp
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSStorageCustom.cpp
Source/WebCore/loader/appcache/DOMApplicationCache.cpp
Source/WebCore/loader/appcache/DOMApplicationCache.h
Source/WebCore/loader/appcache/DOMApplicationCache.idl
Source/WebCore/page/Crypto.cpp
Source/WebCore/page/Crypto.h
Source/WebCore/page/Crypto.idl
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/DOMWindow.idl
Source/WebCore/page/EventSource.cpp
Source/WebCore/page/EventSource.h
Source/WebCore/page/EventSource.idl
Source/WebCore/page/Location.cpp
Source/WebCore/page/Location.h
Source/WebCore/page/Location.idl
Source/WebCore/page/Performance.cpp
Source/WebCore/page/Performance.h
Source/WebCore/page/Performance.idl
Source/WebCore/page/PerformanceUserTiming.cpp
Source/WebCore/page/PerformanceUserTiming.h
Source/WebCore/page/UserMessageHandler.cpp
Source/WebCore/page/UserMessageHandler.h
Source/WebCore/page/UserMessageHandler.idl
Source/WebCore/storage/Storage.cpp
Source/WebCore/storage/Storage.h
Source/WebCore/storage/Storage.idl
Source/WebCore/storage/StorageEventDispatcher.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMCoreClasses.cpp

index d98a858..eb4a4d5 100644 (file)
@@ -1,5 +1,125 @@
 2016-10-18  Darin Adler  <darin@apple.com>
 
+        Move many miscellaneous classes from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163645
+
+        Reviewed by Ryosuke Niwa.
+
+        * bindings/js/JSCryptoCustom.cpp:
+        (WebCore::JSCrypto::getRandomValues): Use propagateException.
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::handlePostMessage): Ditto.
+        (WebCore::JSDOMWindow::setTimeout): Use toJSNumber.
+        (WebCore::JSDOMWindow::setInterval): Ditto.
+        * bindings/js/JSStorageCustom.cpp:
+        (WebCore::JSStorage::nameGetter): Use propagateException.
+        (WebCore::JSStorage::deleteProperty): Ditto.
+        (WebCore::JSStorage::getOwnPropertyNames): Ditto.
+        (WebCore::JSStorage::putDelegate): Ditto.
+
+        * loader/appcache/DOMApplicationCache.cpp:
+        (WebCore::DOMApplicationCache::update): Use ExceptionOr.
+        (WebCore::DOMApplicationCache::swapCache): Ditto.
+        * loader/appcache/DOMApplicationCache.h: Update for above changes.
+        * loader/appcache/DOMApplicationCache.idl: Use non-legacy exceptions.
+
+        * page/Crypto.cpp:
+        (WebCore::Crypto::getRandomValues): Use ExceptionOr.
+        (WebCore::Crypto::webkitSubtle): Ditto.
+        * page/Crypto.h: Updated for above changes.
+        * page/Crypto.idl: Use non-legacy exceptions.
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::DOMWindow): Initialize many data members in
+        the class definition instead of here.
+        (WebCore::DOMWindow::page): Use nullptr.
+        (WebCore::DOMWindow::screen): Ditto.
+        (WebCore::DOMWindow::crypto): Ditto.
+        (WebCore::DOMWindow::locationbar): Ditto.
+        (WebCore::DOMWindow::menubar): Ditto.
+        (WebCore::DOMWindow::personalbar): Ditto.
+        (WebCore::DOMWindow::scrollbars): Ditto.
+        (WebCore::DOMWindow::statusbar): Ditto.
+        (WebCore::DOMWindow::toolbar): Ditto.
+        (WebCore::DOMWindow::applicationCache): Ditto.
+        (WebCore::DOMWindow::sessionStorage): Use ExceptionOr.
+        (WebCore::DOMWindow::localStorage): Ditto.
+        (WebCore::DOMWindow::postMessage): Ditto.
+        (WebCore::DOMWindow::frameElement): Use nullptr.
+        (WebCore::DOMWindow::self): Ditto.
+        (WebCore::DOMWindow::opener): Ditto.
+        (WebCore::DOMWindow::parent): Ditto.
+        (WebCore::DOMWindow::top): Ditto.
+        (WebCore::DOMWindow::getComputedStyle): Use Ref.
+        (WebCore::DOMWindow::setTimeout): Use ExceptionOr.
+        (WebCore::DOMWindow::setInterval): Ditto.
+        (WebCore::didAddStorageEventListener): Use a reference instead of a
+        pointer, and ignore return value instead of using IGNORE_EXCEPTION.
+        (WebCore::DOMWindow::addEventListener): Pass reference to function above.
+        (WebCore::DOMWindow::dispatchEvent): Use enum class version of PageStatus.
+        * page/DOMWindow.h: Updated for changes above. Also changed indentatation.
+        * page/DOMWindow.idl: Use non-legacy exceptions.
+
+        * page/EventSource.cpp:
+        (WebCore::EventSource::create): Use ExceptionOr.
+        * page/EventSource.h: Updated for change above.
+        * page/EventSource.idl: Use non-legacy exception.
+
+        * page/Location.cpp:
+        (WebCore::Location::setProtocol): Use ExceptionOr.
+        * page/Location.h: Updated for change above.
+        * page/Location.idl: Use non-legacy exception.
+
+        * page/Performance.cpp:
+        (WebCore::Performance::Performance): Remove unnecessary initialization of
+        smart pointer to null, and moved initialization of m_resourceTimingBufferSize
+        to the header.
+        (WebCore::Performance::navigation): Made non-const and return a reference.
+        (WebCore::Performance::timing): Ditto.
+        (WebCore::Performance::addResourceTiming): Change LoadTiming argument to use
+        a const& instead of passing in a copy.
+        (WebCore::Performance::webkitMark): Use ExceptionOr and make_unique.
+        (WebCore::Performance::webkitClearMarks): Ditto.
+        (WebCore::Performance::webkitMeasure): Ditto.
+        (WebCore::Performance::webkitClearMeasures): Ditto.
+        (WebCore::Performance::reduceTimeResolution): Use std::floor.
+        * page/Performance.h: Updated for above changes. Removed unneeded includes.
+        Made more things private. Removed unneeded reference counting of UserTiming.
+        * page/Performance.idl: Use non-legacy exceptions.
+
+        * page/PerformanceUserTiming.cpp:
+        (WebCore::restrictedMarkFunction): Removed unneeded class name.
+        (WebCore::UserTiming::UserTiming): Take a reference instead of a pointer.
+        (WebCore::UserTiming::mark): Use ExceptionOr.
+        (WebCore::UserTiming::findExistingMarkStartTime): Ditto.
+        (WebCore::UserTiming::measure): Ditto.
+        (WebCore::getEntrySequenceByName): Simplified code using HashMap::get.
+        * page/PerformanceUserTiming.h: Updated for above changes. Removed reference
+        counting since this is a single-owner object.
+
+        * page/UserMessageHandler.cpp:
+        (WebCore::UserMessageHandler::postMessage): Use ExceptionOr.
+        * page/UserMessageHandler.h: Updated for above change.
+        * page/UserMessageHandler.idl: Use non-legacy exception.
+
+        * storage/Storage.cpp:
+        (WebCore::Storage::length): Use ExceptionOr.
+        (WebCore::Storage::key): Ditto.
+        (WebCore::Storage::getItem): Ditto.
+        (WebCore::Storage::setItem): Ditto.
+        (WebCore::Storage::removeItem): Ditto.
+        (WebCore::Storage::clear): Ditto.
+        (WebCore::Storage::contains): Ditto.
+        * storage/Storage.h: Updated for above change.
+        * storage/Storage.idl: Use non-legacy exceptions.
+
+        * storage/StorageEventDispatcher.cpp:
+        (WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames):
+        Updated for ExceptionOr.
+        (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames): Ditto.
+
+2016-10-18  Darin Adler  <darin@apple.com>
+
         Move internal testing classes from ExceptionCode to Exception
         https://bugs.webkit.org/show_bug.cgi?id=163553
 
index 48f70b6..f2b1c71 100644 (file)
@@ -45,17 +45,11 @@ JSValue JSCrypto::getRandomValues(ExecState& state)
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
 
     JSValue buffer = state.argument(0);
-    RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(buffer);
+    auto arrayBufferView = toArrayBufferView(buffer);
     if (!arrayBufferView)
         return throwTypeError(&state, scope);
 
-    ExceptionCode ec = 0;
-    wrapped().getRandomValues(arrayBufferView.get(), ec);
-
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
-    }
+    propagateException(state, scope, wrapped().getRandomValues(*arrayBufferView));
 
     return buffer;
 }
index 12a6ace..7b36eae 100644 (file)
@@ -526,15 +526,12 @@ static JSValue handlePostMessage(DOMWindow& impl, ExecState& state)
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     auto message = SerializedScriptValue::create(state, state.uncheckedArgument(0), messagePorts, WTFMove(arrayBuffers));
-
     RETURN_IF_EXCEPTION(scope, JSValue());
 
     String targetOrigin = valueToUSVStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(targetOriginArgIndex));
     RETURN_IF_EXCEPTION(scope, JSValue());
 
-    ExceptionCode ec = 0;
-    impl.postMessage(WTFMove(message), WTFMove(messagePorts), targetOrigin, callerDOMWindow(&state), ec);
-    setDOMException(&state, ec);
+    propagateException(state, scope, impl.postMessage(message.releaseNonNull(), WTFMove(messagePorts), targetOrigin, callerDOMWindow(&state)));
 
     return jsUndefined();
 }
@@ -552,20 +549,14 @@ JSValue JSDOMWindow::setTimeout(ExecState& state)
     if (UNLIKELY(state.argumentCount() < 1))
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
 
-    ContentSecurityPolicy* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
-    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
+    auto* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
+    auto action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
     RETURN_IF_EXCEPTION(scope, JSValue());
-
     if (!action)
         return jsNumber(0);
 
     int delay = state.argument(1).toInt32(&state);
-
-    ExceptionCode ec = 0;
-    int result = wrapped().setTimeout(WTFMove(action), delay, ec);
-    setDOMException(&state, ec);
-
-    return jsNumber(result);
+    return toJSNumber(state, scope, wrapped().setTimeout(WTFMove(action), delay));
 }
 
 JSValue JSDOMWindow::setInterval(ExecState& state)
@@ -576,19 +567,14 @@ JSValue JSDOMWindow::setInterval(ExecState& state)
     if (UNLIKELY(state.argumentCount() < 1))
         return throwException(&state, scope, createNotEnoughArgumentsError(&state));
 
-    ContentSecurityPolicy* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
-    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
+    auto* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
+    auto action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
     RETURN_IF_EXCEPTION(scope, JSValue());
-    int delay = state.argument(1).toInt32(&state);
-
     if (!action)
         return jsNumber(0);
 
-    ExceptionCode ec = 0;
-    int result = wrapped().setInterval(WTFMove(action), delay, ec);
-    setDOMException(&state, ec);
-
-    return jsNumber(result);
+    int delay = state.argument(1).toInt32(&state);
+    return toJSNumber(state, scope, wrapped().setInterval(WTFMove(action), delay));
 }
 
 DOMWindow* JSDOMWindow::toWrapped(JSValue value)
index 1f8fe17..82e3c28 100644 (file)
@@ -35,40 +35,42 @@ using namespace JSC;
 
 namespace WebCore {
 
-bool JSStorage::nameGetter(ExecState* exec, PropertyName propertyName, JSValue& value)
+bool JSStorage::nameGetter(ExecState* state, PropertyName propertyName, JSValue& value)
 {
     if (propertyName.isSymbol())
         return false;
 
-    ExceptionCode ec = 0;
-    String item = wrapped().getItem(propertyNameToString(propertyName), ec);
-    setDOMException(exec, ec);
+    auto item = wrapped().getItem(propertyNameToString(propertyName));
+    if (item.hasException())
+        propagateException(*state, item.releaseException());
 
-    if (item.isNull())
+    auto string = item.releaseReturnValue();
+    if (string.isNull())
         return false;
 
-    value = jsStringWithCache(exec, item);
+    value = jsStringWithCache(state, string);
     return true;
 }
 
-bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
+bool JSStorage::deleteProperty(JSCell* cell, ExecState* state, PropertyName propertyName)
 {
-    JSStorage* thisObject = jsCast<JSStorage*>(cell);
+    auto& thisObject = *jsCast<JSStorage*>(cell);
+
     // Only perform the custom delete if the object doesn't have a native property by this name.
     // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
     // the native property slots manually.
-    PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
+    PropertySlot slot(&thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
 
-    JSValue prototype = thisObject->getPrototypeDirect();
-    if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
-        return Base::deleteProperty(thisObject, exec, propertyName);
+    JSValue prototype = thisObject.getPrototypeDirect();
+    if (prototype.isObject() && asObject(prototype)->getPropertySlot(state, propertyName, slot))
+        return Base::deleteProperty(&thisObject, state, propertyName);
 
     if (propertyName.isSymbol())
-        return Base::deleteProperty(thisObject, exec, propertyName);
+        return Base::deleteProperty(&thisObject, state, propertyName);
 
-    ExceptionCode ec = 0;
-    thisObject->wrapped().removeItem(propertyNameToString(propertyName), ec);
-    setDOMException(exec, ec);
+    VM& vm = state->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    propagateException(*state, scope, thisObject.wrapped().removeItem(propertyNameToString(propertyName)));
     return true;
 }
 
@@ -77,28 +79,33 @@ bool JSStorage::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned pr
     return deleteProperty(cell, exec, Identifier::from(exec, propertyName));
 }
 
-void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
+void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
 {
-    VM& vm = exec->vm();
+    VM& vm = state->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    JSStorage* thisObject = jsCast<JSStorage*>(object);
-    ExceptionCode ec = 0;
-    unsigned length = thisObject->wrapped().length(ec);
-    setDOMException(exec, ec);
-    RETURN_IF_EXCEPTION(scope, void());
+    auto& thisObject = *jsCast<JSStorage*>(object);
+    auto lengthResult = thisObject.wrapped().length();
+    if (lengthResult.hasException()) {
+        propagateException(*state, scope, lengthResult.releaseException());
+        return;
+    }
+    unsigned length = lengthResult.releaseReturnValue();
     for (unsigned i = 0; i < length; ++i) {
-        propertyNames.add(Identifier::fromString(exec, thisObject->wrapped().key(i, ec)));
-        setDOMException(exec, ec);
-        RETURN_IF_EXCEPTION(scope, void());
+        auto keyResult = thisObject.wrapped().key(i);
+        if (keyResult.hasException()) {
+            propagateException(*state, scope, lengthResult.releaseException());
+            return;
+        }
+        propertyNames.add(Identifier::fromString(state, keyResult.releaseReturnValue()));
     }
         
-    Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
+    Base::getOwnPropertyNames(&thisObject, state, propertyNames, mode);
 }
 
-bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult)
+bool JSStorage::putDelegate(ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult)
 {
-    VM& vm = exec->vm();
+    VM& vm = state->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     // Only perform the custom put if the object doesn't have a native property by this name.
@@ -107,13 +114,13 @@ bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue
     PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
 
     JSValue prototype = this->getPrototypeDirect();
-    if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
+    if (prototype.isObject() && asObject(prototype)->getPropertySlot(state, propertyName, slot))
         return false;
 
     if (propertyName.isSymbol())
         return false;
 
-    String stringValue = value.toString(exec)->value(exec);
+    String stringValue = value.toString(state)->value(state);
     if (UNLIKELY(scope.exception())) {
         // The return value indicates whether putDelegate() should handle the put operation (which
         // if true, tells the caller not to execute the generic put). It does not indicate whether
@@ -123,10 +130,9 @@ bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue
         return true;
     }
 
-    ExceptionCode ec = 0;
-    wrapped().setItem(propertyNameToString(propertyName), stringValue, ec);
-    setDOMException(exec, ec);
-    putResult = !ec;
+    auto setItemResult = wrapped().setItem(propertyNameToString(propertyName), stringValue);
+    putResult = !setItemResult.hasException();
+    propagateException(*state, scope, WTFMove(setItemResult));
     return true;
 }
 
index a7c0777..4d0eef2 100644 (file)
@@ -82,18 +82,20 @@ unsigned short DOMApplicationCache::status() const
     return cacheHost->status();
 }
 
-void DOMApplicationCache::update(ExceptionCode& ec)
+ExceptionOr<void> DOMApplicationCache::update()
 {
-    ApplicationCacheHost* cacheHost = applicationCacheHost();
+    auto* cacheHost = applicationCacheHost();
     if (!cacheHost || !cacheHost->update())
-        ec = INVALID_STATE_ERR;
+        return Exception { INVALID_STATE_ERR };
+    return { };
 }
 
-void DOMApplicationCache::swapCache(ExceptionCode& ec)
+ExceptionOr<void> DOMApplicationCache::swapCache()
 {
-    ApplicationCacheHost* cacheHost = applicationCacheHost();
+    auto* cacheHost = applicationCacheHost();
     if (!cacheHost || !cacheHost->swapCache())
-        ec = INVALID_STATE_ERR;
+        return Exception { INVALID_STATE_ERR };
+    return { };
 }
 
 void DOMApplicationCache::abort()
index 30e6ae2..3f20d8c 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef DOMApplicationCache_h
-#define DOMApplicationCache_h
+#pragma once
 
 #include "ApplicationCacheHost.h"
 #include "DOMWindowProperty.h"
 #include "EventTarget.h"
+#include "ExceptionOr.h"
 #include "ScriptWrappable.h"
-#include <wtf/Forward.h>
 #include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
 #include <wtf/text/AtomicStringHash.h>
 
 namespace WebCore {
@@ -50,8 +48,8 @@ public:
     void willDestroyGlobalObjectInFrame() override;
 
     unsigned short status() const;
-    void update(ExceptionCode&);
-    void swapCache(ExceptionCode&);
+    ExceptionOr<void> update();
+    ExceptionOr<void> swapCache();
     void abort();
 
     using RefCounted<DOMApplicationCache>::ref;
@@ -72,5 +70,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // DOMApplicationCache_h
index 716eba0..1799f2e 100644 (file)
@@ -37,8 +37,8 @@
     const unsigned short OBSOLETE = 5;
     readonly attribute unsigned short status;
 
-    [MayThrowLegacyException] void update();
-    [MayThrowLegacyException] void swapCache();
+    [MayThrowException] void update();
+    [MayThrowException] void swapCache();
     void abort();
 
     attribute EventHandler onchecking;
index 25a6d92..be3872f 100644 (file)
@@ -52,37 +52,34 @@ Crypto::~Crypto()
 {
 }
 
-void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
+ExceptionOr<void> Crypto::getRandomValues(ArrayBufferView& array)
 {
-    if (!array || !JSC::isInt(array->getType())) {
-        ec = TYPE_MISMATCH_ERR;
-        return;
-    }
-    if (array->byteLength() > 65536) {
-        ec = QUOTA_EXCEEDED_ERR;
-        return;
-    }
-    cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
+    if (!isInt(array.getType()))
+        return Exception { TYPE_MISMATCH_ERR };
+    if (array.byteLength() > 65536)
+        return Exception { QUOTA_EXCEEDED_ERR };
+    cryptographicallyRandomValues(array.baseAddress(), array.byteLength());
+    return { };
 }
 
 #if ENABLE(SUBTLE_CRYPTO)
+
 SubtleCrypto& Crypto::subtle()
 {
     return m_subtle;
 }
 
-WebKitSubtleCrypto* Crypto::webkitSubtle(ExceptionCode& ec)
+ExceptionOr<WebKitSubtleCrypto*> Crypto::webkitSubtle()
 {
-    if (!isMainThread()) {
-        ec = NOT_SUPPORTED_ERR;
-        return 0;
-    }
+    if (!isMainThread())
+        return Exception { NOT_SUPPORTED_ERR };
 
     if (!m_webkitSubtle)
         m_webkitSubtle = WebKitSubtleCrypto::create(*downcast<Document>(scriptExecutionContext()));
 
     return m_webkitSubtle.get();
 }
+
 #endif
 
 }
index d64ae4b..9034e61 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef Crypto_h
-#define Crypto_h
+#pragma once
 
 #include "ContextDestructionObserver.h"
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "ExceptionOr.h"
 
 namespace JSC {
 class ArrayBufferView;
@@ -41,24 +38,21 @@ class ArrayBufferView;
 
 namespace WebCore {
 
-typedef int ExceptionCode;
-
-class Document;
-class WebKitSubtleCrypto;
 class SubtleCrypto;
+class WebKitSubtleCrypto;
 
 class Crypto : public ContextDestructionObserver, public RefCounted<Crypto> {
 public:
     static Ref<Crypto> create(ScriptExecutionContext& context) { return adoptRef(*new Crypto(context)); }
     virtual ~Crypto();
 
-    void getRandomValues(JSC::ArrayBufferView*, ExceptionCode&);
+    ExceptionOr<void> getRandomValues(JSC::ArrayBufferView&);
 
 #if ENABLE(SUBTLE_CRYPTO)
     SubtleCrypto& subtle();
 
     // Will be deprecated.
-    WebKitSubtleCrypto* webkitSubtle(ExceptionCode&);
+    ExceptionOr<WebKitSubtleCrypto*> webkitSubtle();
 #endif
 
 private:
@@ -73,5 +67,3 @@ private:
 };
 
 }
-
-#endif
index 0d33596..24fb5cb 100644 (file)
@@ -32,8 +32,8 @@
     GenerateIsReachable=ImplScriptExecutionContext,
 ] interface Crypto {
     [Conditional=SUBTLE_CRYPTO] readonly attribute SubtleCrypto subtle;
-    [Custom, MayThrowLegacyException] ArrayBufferView getRandomValues(ArrayBufferView array);
+    [Custom, MayThrowException] ArrayBufferView getRandomValues(ArrayBufferView array);
 
     // Will be deprecated.
-    [Conditional=SUBTLE_CRYPTO, GetterMayThrowLegacyException] readonly attribute WebKitSubtleCrypto webkitSubtle;
+    [Conditional=SUBTLE_CRYPTO, GetterMayThrowException] readonly attribute WebKitSubtleCrypto webkitSubtle;
 };
index e1e0880..7206292 100644 (file)
@@ -406,19 +406,7 @@ void DOMWindow::setCanShowModalDialogOverride(bool allow)
 DOMWindow::DOMWindow(Document* document)
     : ContextDestructionObserver(document)
     , FrameDestructionObserver(document->frame())
-    , m_shouldPrintWhenFinishedLoading(false)
-    , m_suspendedForDocumentSuspension(false)
-    , m_lastPageStatus(PageStatusNone)
     , m_weakPtrFactory(this)
-#if PLATFORM(IOS)
-    , m_scrollEventListenerCount(0)
-#endif
-#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
-    , m_touchEventListenerCount(0)
-#endif
-#if ENABLE(GAMEPAD)
-    , m_gamepadEventListenerCount(0)
-#endif
 {
     ASSERT(frame());
     ASSERT(DOMWindow::document());
@@ -488,7 +476,7 @@ RefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media)
 
 Page* DOMWindow::page()
 {
-    return frame() ? frame()->page() : 0;
+    return frame() ? frame()->page() : nullptr;
 }
 
 void DOMWindow::frameDestroyed()
@@ -537,6 +525,7 @@ void DOMWindow::willDetachDocumentFromFrame()
 }
 
 #if ENABLE(GAMEPAD)
+
 void DOMWindow::incrementGamepadEventListenerCount()
 {
     if (++m_gamepadEventListenerCount == 1)
@@ -550,6 +539,7 @@ void DOMWindow::decrementGamepadEventListenerCount()
     if (!--m_gamepadEventListenerCount)
         GamepadManager::singleton().unregisterDOMWindow(this);
 }
+
 #endif
 
 void DOMWindow::registerProperty(DOMWindowProperty* property)
@@ -635,15 +625,18 @@ bool DOMWindow::isCurrentlyDisplayedInFrame() const
 }
 
 #if ENABLE(CUSTOM_ELEMENTS)
+
 CustomElementRegistry& DOMWindow::ensureCustomElementRegistry()
 {
     if (!m_customElementRegistry)
         m_customElementRegistry = CustomElementRegistry::create(*this);
     return *m_customElementRegistry;
 }
+
 #endif
 
 #if ENABLE(ORIENTATION_EVENTS)
+
 int DOMWindow::orientation() const
 {
     if (!m_frame)
@@ -651,12 +644,13 @@ int DOMWindow::orientation() const
 
     return m_frame->orientation();
 }
+
 #endif
 
 Screen* DOMWindow::screen() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_screen)
         m_screen = Screen::create(m_frame);
     return m_screen.get();
@@ -675,7 +669,7 @@ Crypto* DOMWindow::crypto() const
 {
     // FIXME: Why is crypto not available when the window is not currently displayed in a frame?
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_crypto)
         m_crypto = Crypto::create(*document());
     return m_crypto.get();
@@ -684,7 +678,7 @@ Crypto* DOMWindow::crypto() const
 BarProp* DOMWindow::locationbar() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_locationbar)
         m_locationbar = BarProp::create(m_frame, BarProp::Locationbar);
     return m_locationbar.get();
@@ -693,7 +687,7 @@ BarProp* DOMWindow::locationbar() const
 BarProp* DOMWindow::menubar() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_menubar)
         m_menubar = BarProp::create(m_frame, BarProp::Menubar);
     return m_menubar.get();
@@ -702,7 +696,7 @@ BarProp* DOMWindow::menubar() const
 BarProp* DOMWindow::personalbar() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_personalbar)
         m_personalbar = BarProp::create(m_frame, BarProp::Personalbar);
     return m_personalbar.get();
@@ -711,7 +705,7 @@ BarProp* DOMWindow::personalbar() const
 BarProp* DOMWindow::scrollbars() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_scrollbars)
         m_scrollbars = BarProp::create(m_frame, BarProp::Scrollbars);
     return m_scrollbars.get();
@@ -720,7 +714,7 @@ BarProp* DOMWindow::scrollbars() const
 BarProp* DOMWindow::statusbar() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_statusbar)
         m_statusbar = BarProp::create(m_frame, BarProp::Statusbar);
     return m_statusbar.get();
@@ -729,7 +723,7 @@ BarProp* DOMWindow::statusbar() const
 BarProp* DOMWindow::toolbar() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_toolbar)
         m_toolbar = BarProp::create(m_frame, BarProp::Toolbar);
     return m_toolbar.get();
@@ -745,7 +739,7 @@ PageConsoleClient* DOMWindow::console() const
 DOMApplicationCache* DOMWindow::applicationCache() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_applicationCache)
         m_applicationCache = DOMApplicationCache::create(m_frame);
     return m_applicationCache.get();
@@ -761,6 +755,7 @@ Navigator* DOMWindow::navigator() const
 }
 
 #if ENABLE(WEB_TIMING)
+
 Performance* DOMWindow::performance() const
 {
     if (!isCurrentlyDisplayedInFrame())
@@ -769,6 +764,7 @@ Performance* DOMWindow::performance() const
         m_performance = Performance::create(*m_frame);
     return m_performance.get();
 }
+
 #endif
 
 double DOMWindow::nowTimestamp() const
@@ -790,6 +786,7 @@ Location* DOMWindow::location() const
 }
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
+
 bool DOMWindow::shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld& world)
 {
     if (!m_frame)
@@ -821,67 +818,58 @@ WebKitNamespace* DOMWindow::webkitNamespace() const
         m_webkitNamespace = WebKitNamespace::create(*m_frame, page->userContentProvider());
     return m_webkitNamespace.get();
 }
+
 #endif
 
-Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const
+ExceptionOr<Storage*> DOMWindow::sessionStorage() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
 
-    Document* document = this->document();
+    auto* document = this->document();
     if (!document)
-        return 0;
+        return nullptr;
 
-    if (!document->securityOrigin()->canAccessSessionStorage(document->topOrigin())) {
-        ec = SECURITY_ERR;
-        return 0;
-    }
+    if (!document->securityOrigin()->canAccessSessionStorage(document->topOrigin()))
+        return Exception { SECURITY_ERR };
 
     if (m_sessionStorage) {
-        if (!m_sessionStorage->area().canAccessStorage(m_frame)) {
-            ec = SECURITY_ERR;
-            return 0;
-        }
+        if (!m_sessionStorage->area().canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
         return m_sessionStorage.get();
     }
 
-    Page* page = document->page();
+    auto* page = document->page();
     if (!page)
-        return 0;
+        return nullptr;
 
     auto storageArea = page->sessionStorage()->storageArea(document->securityOrigin());
-    if (!storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return 0;
-    }
+    if (!storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     m_sessionStorage = Storage::create(m_frame, WTFMove(storageArea));
     return m_sessionStorage.get();
 }
 
-Storage* DOMWindow::localStorage(ExceptionCode& ec) const
+ExceptionOr<Storage*> DOMWindow::localStorage() const
 {
     if (!isCurrentlyDisplayedInFrame())
         return nullptr;
 
-    Document* document = this->document();
+    auto* document = this->document();
     if (!document)
         return nullptr;
 
-    if (!document->securityOrigin()->canAccessLocalStorage(nullptr)) {
-        ec = SECURITY_ERR;
-        return nullptr;
-    }
+    if (!document->securityOrigin()->canAccessLocalStorage(nullptr))
+        return Exception { SECURITY_ERR };
 
-    Page* page = document->page();
+    auto* page = document->page();
     // FIXME: We should consider supporting access/modification to local storage
     // after calling window.close(). See <https://bugs.webkit.org/show_bug.cgi?id=135330>.
     if (!page || !page->isClosing()) {
         if (m_localStorage) {
-            if (!m_localStorage->area().canAccessStorage(m_frame)) {
-                ec = SECURITY_ERR;
-                return nullptr;
-            }
+            if (!m_localStorage->area().canAccessStorage(m_frame))
+                return Exception { SECURITY_ERR };
             return m_localStorage.get();
         }
     }
@@ -897,19 +885,17 @@ Storage* DOMWindow::localStorage(ExceptionCode& ec) const
 
     auto storageArea = page->storageNamespaceProvider().localStorageArea(*document);
 
-    if (!storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return nullptr;
-    }
+    if (!storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     m_localStorage = Storage::create(m_frame, WTFMove(storageArea));
     return m_localStorage.get();
 }
 
-void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&& ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec)
+ExceptionOr<void> DOMWindow::postMessage(Ref<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, const String& targetOrigin, DOMWindow& source)
 {
     if (!isCurrentlyDisplayedInFrame())
-        return;
+        return { };
 
     Document* sourceDocument = source.document();
 
@@ -918,27 +904,26 @@ void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, Vector<Re
     RefPtr<SecurityOrigin> target;
     if (targetOrigin == "/") {
         if (!sourceDocument)
-            return;
+            return { };
         target = sourceDocument->securityOrigin();
     } else if (targetOrigin != "*") {
         target = SecurityOrigin::createFromString(targetOrigin);
         // It doesn't make sense target a postMessage at a unique origin
         // because there's no way to represent a unique origin in a string.
-        if (target->isUnique()) {
-            ec = SYNTAX_ERR;
-            return;
-        }
+        if (target->isUnique())
+            return Exception { SYNTAX_ERR };
     }
 
+    ExceptionCode ec = 0;
     auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
     if (ec)
-        return;
+        return Exception { ec };
 
     // Capture the source of the message.  We need to do this synchronously
     // in order to capture the source of the message correctly.
     if (!sourceDocument)
-        return;
-    String sourceOrigin = sourceDocument->securityOrigin()->toString();
+        return { };
+    auto sourceOrigin = sourceDocument->securityOrigin()->toString();
 
     // Capture stack trace only when inspector front-end is loaded as it may be time consuming.
     RefPtr<ScriptCallStack> stackTrace;
@@ -946,8 +931,10 @@ void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, Vector<Re
         stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture);
 
     // Schedule the message.
-    PostMessageTimer* timer = new PostMessageTimer(*this, message, sourceOrigin, source, WTFMove(channels), WTFMove(target), WTFMove(stackTrace));
+    auto* timer = new PostMessageTimer(*this, PassRefPtr<SerializedScriptValue> { WTFMove(message) }, sourceOrigin, source, WTFMove(channels), WTFMove(target), WTFMove(stackTrace));
     timer->startOneShot(0);
+
+    return { };
 }
 
 void DOMWindow::postMessageTimerFired(PostMessageTimer& timer)
@@ -986,7 +973,7 @@ DOMSelection* DOMWindow::getSelection()
 Element* DOMWindow::frameElement() const
 {
     if (!m_frame)
-        return 0;
+        return nullptr;
 
     return m_frame->ownerElement();
 }
@@ -1361,7 +1348,7 @@ void DOMWindow::setDefaultStatus(const String& string)
 DOMWindow* DOMWindow::self() const
 {
     if (!m_frame)
-        return 0;
+        return nullptr;
 
     return m_frame->document()->domWindow();
 }
@@ -1369,11 +1356,11 @@ DOMWindow* DOMWindow::self() const
 DOMWindow* DOMWindow::opener() const
 {
     if (!m_frame)
-        return 0;
+        return nullptr;
 
     Frame* opener = m_frame->loader().opener();
     if (!opener)
-        return 0;
+        return nullptr;
 
     return opener->document()->domWindow();
 }
@@ -1381,7 +1368,7 @@ DOMWindow* DOMWindow::opener() const
 DOMWindow* DOMWindow::parent() const
 {
     if (!m_frame)
-        return 0;
+        return nullptr;
 
     Frame* parent = m_frame->tree().parent();
     if (parent)
@@ -1393,11 +1380,11 @@ DOMWindow* DOMWindow::parent() const
 DOMWindow* DOMWindow::top() const
 {
     if (!m_frame)
-        return 0;
+        return nullptr;
 
     Page* page = m_frame->page();
     if (!page)
-        return 0;
+        return nullptr;
 
     return m_frame->tree().top().document()->domWindow();
 }
@@ -1417,13 +1404,13 @@ RefPtr<StyleMedia> DOMWindow::styleMedia() const
     return m_media;
 }
 
-RefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element& element, const String& pseudoElt) const
+Ref<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element& element, const String& pseudoElt) const
 {
     return CSSComputedStyleDeclaration::create(element, false, pseudoElt);
 }
 
 // FIXME: Drop this overload once <rdar://problem/28016778> has been fixed.
-RefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Document&, const String&, ExceptionCode& ec)
+ExceptionOr<RefPtr<CSSStyleDeclaration>> DOMWindow::getComputedStyle(Document&, const String&)
 {
 #if PLATFORM(MAC)
     if (MacApplication::isAppStore()) {
@@ -1431,8 +1418,7 @@ RefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Document&, const String&
         return nullptr;
     }
 #endif
-    ec = TypeError;
-    return nullptr;
+    return Exception { TypeError };
 }
 
 RefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const String& pseudoElement, bool authorOnly) const
@@ -1631,13 +1617,11 @@ void DOMWindow::resizeTo(float width, float height) const
     page->chrome().setWindowRect(adjustWindowRect(page, update));
 }
 
-int DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout, ExceptionCode& ec)
+ExceptionOr<int> DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    ScriptExecutionContext* context = scriptExecutionContext();
-    if (!context) {
-        ec = INVALID_ACCESS_ERR;
-        return -1;
-    }
+    auto* context = scriptExecutionContext();
+    if (!context)
+        return ExceptionCode { INVALID_ACCESS_ERR };
     return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), true);
 }
 
@@ -1665,13 +1649,11 @@ void DOMWindow::clearTimeout(int timeoutId)
     DOMTimer::removeById(*context, timeoutId);
 }
 
-int DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, ExceptionCode& ec)
+ExceptionOr<int> DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    ScriptExecutionContext* context = scriptExecutionContext();
-    if (!context) {
-        ec = INVALID_ACCESS_ERR;
-        return -1;
-    }
+    auto* context = scriptExecutionContext();
+    if (!context)
+        return ExceptionCode { INVALID_ACCESS_ERR };
     return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), false);
 }
 
@@ -1684,6 +1666,7 @@ void DOMWindow::clearInterval(int timeoutId)
 }
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
+
 int DOMWindow::requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback)
 {
     callback->m_useLegacyTimeBase = false;
@@ -1705,16 +1688,17 @@ void DOMWindow::cancelAnimationFrame(int id)
     if (Document* d = document())
         d->cancelAnimationFrame(id);
 }
+
 #endif
 
-static void didAddStorageEventListener(DOMWindow* window)
+static void didAddStorageEventListener(DOMWindow& window)
 {
     // Creating these WebCore::Storage objects informs the system that we'd like to receive
     // notifications about storage events that might be triggered in other processes. Rather
     // than subscribe to these notifications explicitly, we subscribe to them implicitly to
     // simplify the work done by the system. 
-    window->localStorage(IGNORE_EXCEPTION);
-    window->sessionStorage(IGNORE_EXCEPTION);
+    window.localStorage();
+    window.sessionStorage();
 }
 
 bool DOMWindow::isSameSecurityOriginAsMainFrame() const
@@ -1745,7 +1729,7 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, Ref<EventListene
         else if (eventNames().isTouchEventType(eventType))
             document->didAddTouchEventHandler(*document);
         else if (eventType == eventNames().storageEvent)
-            didAddStorageEventListener(this);
+            didAddStorageEventListener(*this);
     }
 
     if (eventType == eventNames().unloadEvent)
@@ -1806,6 +1790,7 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, Ref<EventListene
 }
 
 #if PLATFORM(IOS)
+
 void DOMWindow::incrementScrollEventListenersCount()
 {
     Document* document = this->document();
@@ -1825,6 +1810,7 @@ void DOMWindow::decrementScrollEventListenersCount()
             frame->page()->chrome().client().setNeedsScrollNotifications(frame, false);
     }
 }
+
 #endif
 
 void DOMWindow::resetAllGeolocationPermission()
@@ -1938,13 +1924,13 @@ bool DOMWindow::dispatchEvent(Event& event, EventTarget* target)
     // <http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-pageshow>.
     if (event.eventInterface() == PageTransitionEventInterfaceType) {
         if (event.type() == eventNames().pageshowEvent) {
-            if (m_lastPageStatus == PageStatusShown)
+            if (m_lastPageStatus == PageStatus::Shown)
                 return true; // Event was previously dispatched; do not fire a duplicate event.
-            m_lastPageStatus = PageStatusShown;
+            m_lastPageStatus = PageStatus::Shown;
         } else if (event.type() == eventNames().pagehideEvent) {
-            if (m_lastPageStatus == PageStatusHidden)
+            if (m_lastPageStatus == PageStatus::Hidden)
                 return true; // Event was previously dispatched; do not fire a duplicate event.
-            m_lastPageStatus = PageStatusHidden;
+            m_lastPageStatus = PageStatus::Hidden;
         }
     }
 
index cdb2329..6b965df 100644 (file)
@@ -29,6 +29,7 @@
 #include "Base64Utilities.h"
 #include "ContextDestructionObserver.h"
 #include "EventTarget.h"
+#include "ExceptionOr.h"
 #include "FrameDestructionObserver.h"
 #include "ScrollToOptions.h"
 #include "Supplementable.h"
@@ -45,397 +46,391 @@ class ScriptCallStack;
 
 namespace WebCore {
 
-    class BarProp;
-    class CSSRuleList;
-    class CSSStyleDeclaration;
-    class Crypto;
-    class CustomElementRegistry;
-    class DOMApplicationCache;
-    class DOMSelection;
-    class DOMURL;
-    class DOMWindowProperty;
-    class DOMWrapperWorld;
-    class Database;
-    class DatabaseCallback;
-    class Document;
-    class Element;
-    class EventListener;
-    class FloatRect;
-    class Frame;
-    class History;
-    class IDBFactory;
-    class Location;
-    class MediaQueryList;
-    class MessageEvent;
-    class Navigator;
-    class Node;
-    class Page;
-    class PageConsoleClient;
-    class Performance;
-    class PostMessageTimer;
-    class ScheduledAction;
-    class Screen;
-    class SecurityOrigin;
-    class SerializedScriptValue;
-    class Storage;
-    class StyleMedia;
-    class WebKitNamespace;
-    class WebKitPoint;
+class BarProp;
+class CSSRuleList;
+class CSSStyleDeclaration;
+class Crypto;
+class CustomElementRegistry;
+class DOMApplicationCache;
+class DOMSelection;
+class DOMURL;
+class DOMWindowProperty;
+class DOMWrapperWorld;
+class Database;
+class DatabaseCallback;
+class Document;
+class Element;
+class EventListener;
+class FloatRect;
+class Frame;
+class History;
+class IDBFactory;
+class Location;
+class MediaQueryList;
+class MessageEvent;
+class Navigator;
+class Node;
+class Page;
+class PageConsoleClient;
+class Performance;
+class PostMessageTimer;
+class RequestAnimationFrameCallback;
+class ScheduledAction;
+class Screen;
+class SecurityOrigin;
+class SerializedScriptValue;
+class Storage;
+class StyleMedia;
+class WebKitNamespace;
+class WebKitPoint;
+
+struct WindowFeatures;
+
+enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
+
+// FIXME: DOMWindow shouldn't subclass FrameDestructionObserver and instead should get to Frame via its Document.
+class DOMWindow final
+    : public RefCounted<DOMWindow>
+    , public EventTargetWithInlineData
+    , public ContextDestructionObserver
+    , public FrameDestructionObserver
+    , public Base64Utilities
+    , public Supplementable<DOMWindow> {
+public:
+    static Ref<DOMWindow> create(Document* document) { return adoptRef(*new DOMWindow(document)); }
+    WEBCORE_EXPORT virtual ~DOMWindow();
+
+    // In some rare cases, we'll reuse a DOMWindow for a new Document. For example,
+    // when a script calls window.open("..."), the browser gives JavaScript a window
+    // synchronously but kicks off the load in the window asynchronously. Web sites
+    // expect that modifications that they make to the window object synchronously
+    // won't be blown away when the network load commits. To make that happen, we
+    // "securely transition" the existing DOMWindow to the Document that results from
+    // the network load. See also SecurityContext::isSecureTransitionTo.
+    void didSecureTransitionTo(Document*);
+
+    EventTargetInterface eventTargetInterface() const override { return DOMWindowEventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); }
+
+    DOMWindow* toDOMWindow() override;
+
+    void registerProperty(DOMWindowProperty*);
+    void unregisterProperty(DOMWindowProperty*);
+
+    void resetUnlessSuspendedForDocumentSuspension();
+    void suspendForDocumentSuspension();
+    void resumeFromDocumentSuspension();
+
+    RefPtr<MediaQueryList> matchMedia(const String&);
+
+    WEBCORE_EXPORT unsigned pendingUnloadEventListeners() const;
+
+    WEBCORE_EXPORT static bool dispatchAllPendingBeforeUnloadEvents();
+    WEBCORE_EXPORT static void dispatchAllPendingUnloadEvents();
+
+    static FloatRect adjustWindowRect(Page*, const FloatRect& pendingChanges);
+
+    bool allowPopUp(); // Call on first window, not target window.
+    static bool allowPopUp(Frame* firstFrame);
+    static bool canShowModalDialog(const Frame*);
+    WEBCORE_EXPORT void setCanShowModalDialogOverride(bool);
+
+    Screen* screen() const;
+    History* history() const;
+    Crypto* crypto() const;
+    BarProp* locationbar() const;
+    BarProp* menubar() const;
+    BarProp* personalbar() const;
+    BarProp* scrollbars() const;
+    BarProp* statusbar() const;
+    BarProp* toolbar() const;
+    Navigator* navigator() const;
+    Navigator* clientInformation() const { return navigator(); }
+
+    Location* location() const;
+    void setLocation(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& location, SetLocationLocking = LockHistoryBasedOnGestureState);
+
+    DOMSelection* getSelection();
+
+    Element* frameElement() const;
+
+    WEBCORE_EXPORT void focus(bool allowFocus = false);
+    void focus(DOMWindow& callerWindow);
+    void blur();
+    WEBCORE_EXPORT void close();
+    void close(Document&);
+    void print();
+    void stop();
 
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-    class RequestAnimationFrameCallback;
-#endif
-
-    struct WindowFeatures;
-
-    typedef int ExceptionCode;
-
-    enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
-
-    // FIXME: DOMWindow shouldn't subclass FrameDestructionObserver and instead should get to Frame via its Document.
-    class DOMWindow final
-        : public RefCounted<DOMWindow>
-        , public EventTargetWithInlineData
-        , public ContextDestructionObserver
-        , public FrameDestructionObserver
-        , public Base64Utilities
-        , public Supplementable<DOMWindow> {
-    public:
-        static Ref<DOMWindow> create(Document* document) { return adoptRef(*new DOMWindow(document)); }
-        WEBCORE_EXPORT virtual ~DOMWindow();
-
-        // In some rare cases, we'll re-used a DOMWindow for a new Document. For example,
-        // when a script calls window.open("..."), the browser gives JavaScript a window
-        // synchronously but kicks off the load in the window asynchronously. Web sites
-        // expect that modifications that they make to the window object synchronously
-        // won't be blown away when the network load commits. To make that happen, we
-        // "securely transition" the existing DOMWindow to the Document that results from
-        // the network load. See also SecurityContext::isSecureTransitionTo.
-        void didSecureTransitionTo(Document*);
-
-        EventTargetInterface eventTargetInterface() const override { return DOMWindowEventTargetInterfaceType; }
-        ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); }
-
-        DOMWindow* toDOMWindow() override;
-
-        void registerProperty(DOMWindowProperty*);
-        void unregisterProperty(DOMWindowProperty*);
-
-        void resetUnlessSuspendedForDocumentSuspension();
-        void suspendForDocumentSuspension();
-        void resumeFromDocumentSuspension();
-
-        RefPtr<MediaQueryList> matchMedia(const String&);
-
-        WEBCORE_EXPORT unsigned pendingUnloadEventListeners() const;
+    WEBCORE_EXPORT RefPtr<DOMWindow> open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow);
 
-        WEBCORE_EXPORT static bool dispatchAllPendingBeforeUnloadEvents();
-        WEBCORE_EXPORT static void dispatchAllPendingUnloadEvents();
+    void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, std::function<void(DOMWindow&)> prepareDialogFunction);
 
-        static FloatRect adjustWindowRect(Page*, const FloatRect& pendingChanges);
+    void alert(const String& message = emptyString());
+    bool confirm(const String& message);
+    String prompt(const String& message, const String& defaultValue);
 
-        bool allowPopUp(); // Call on first window, not target window.
-        static bool allowPopUp(Frame* firstFrame);
-        static bool canShowModalDialog(const Frame*);
-        WEBCORE_EXPORT void setCanShowModalDialogOverride(bool);
+    bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
 
-        Screen* screen() const;
-        History* history() const;
-        Crypto* crypto() const;
-        BarProp* locationbar() const;
-        BarProp* menubar() const;
-        BarProp* personalbar() const;
-        BarProp* scrollbars() const;
-        BarProp* statusbar() const;
-        BarProp* toolbar() const;
-        Navigator* navigator() const;
-        Navigator* clientInformation() const { return navigator(); }
+    bool offscreenBuffering() const;
 
-        Location* location() const;
-        void setLocation(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& location,
-            SetLocationLocking = LockHistoryBasedOnGestureState);
+    int outerHeight() const;
+    int outerWidth() const;
+    int innerHeight() const;
+    int innerWidth() const;
+    int screenX() const;
+    int screenY() const;
+    int screenLeft() const { return screenX(); }
+    int screenTop() const { return screenY(); }
+    int scrollX() const;
+    int scrollY() const;
 
-        DOMSelection* getSelection();
+    bool closed() const;
 
-        Element* frameElement() const;
+    unsigned length() const;
 
-        WEBCORE_EXPORT void focus(bool allowFocus = false);
-        void focus(DOMWindow& callerWindow);
-        void blur();
-        WEBCORE_EXPORT void close();
-        void close(Document&);
-        void print();
-        void stop();
+    String name() const;
+    void setName(const String&);
 
-        WEBCORE_EXPORT RefPtr<DOMWindow> open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString,
-            DOMWindow& activeWindow, DOMWindow& firstWindow);
+    String status() const;
+    void setStatus(const String&);
+    String defaultStatus() const;
+    void setDefaultStatus(const String&);
 
-        void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, std::function<void (DOMWindow&)> prepareDialogFunction);
+    // Self-referential attributes
 
-        void alert(const String& message = emptyString());
-        bool confirm(const String& message);
-        String prompt(const String& message, const String& defaultValue);
+    DOMWindow* self() const;
+    DOMWindow* window() const { return self(); }
+    DOMWindow* frames() const { return self(); }
 
-        bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
+    DOMWindow* opener() const;
+    DOMWindow* parent() const;
+    DOMWindow* top() const;
 
-        bool offscreenBuffering() const;
+    // DOM Level 2 AbstractView Interface
 
-        int outerHeight() const;
-        int outerWidth() const;
-        int innerHeight() const;
-        int innerWidth() const;
-        int screenX() const;
-        int screenY() const;
-        int screenLeft() const { return screenX(); }
-        int screenTop() const { return screenY(); }
-        int scrollX() const;
-        int scrollY() const;
+    WEBCORE_EXPORT Document* document() const;
 
-        bool closed() const;
+    // CSSOM View Module
 
-        unsigned length() const;
+    RefPtr<StyleMedia> styleMedia() const;
 
-        String name() const;
-        void setName(const String&);
+    // DOM Level 2 Style Interface
 
-        String status() const;
-        void setStatus(const String&);
-        String defaultStatus() const;
-        void setDefaultStatus(const String&);
+    WEBCORE_EXPORT Ref<CSSStyleDeclaration> getComputedStyle(Element&, const String& pseudoElt) const;
+    ExceptionOr<RefPtr<CSSStyleDeclaration>> getComputedStyle(Document&, const String& pseudoElt);
 
-        // Self-referential attributes
+    // WebKit extensions
 
-        DOMWindow* self() const;
-        DOMWindow* window() const { return self(); }
-        DOMWindow* frames() const { return self(); }
+    WEBCORE_EXPORT RefPtr<CSSRuleList> getMatchedCSSRules(Element*, const String& pseudoElt, bool authorOnly = true) const;
+    double devicePixelRatio() const;
 
-        DOMWindow* opener() const;
-        DOMWindow* parent() const;
-        DOMWindow* top() const;
+    RefPtr<WebKitPoint> webkitConvertPointFromPageToNode(Node*, const WebKitPoint*) const;
+    RefPtr<WebKitPoint> webkitConvertPointFromNodeToPage(Node*, const WebKitPoint*) const;
 
-        // DOM Level 2 AbstractView Interface
+    PageConsoleClient* console() const;
 
-        WEBCORE_EXPORT Document* document() const;
+    void printErrorMessage(const String&);
+    String crossDomainAccessErrorMessage(const DOMWindow& activeWindow);
 
-        // CSSOM View Module
+    ExceptionOr<void> postMessage(Ref<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, const String& targetOrigin, DOMWindow& source);
+    void postMessageTimerFired(PostMessageTimer&);
+    void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>);
 
-        RefPtr<StyleMedia> styleMedia() const;
+    void languagesChanged();
 
-        // DOM Level 2 Style Interface
+    void scrollBy(const ScrollToOptions&) const;
+    void scrollBy(double x, double y) const;
+    void scrollTo(const ScrollToOptions&) const;
+    void scrollTo(double x, double y) const;
 
-        WEBCORE_EXPORT RefPtr<CSSStyleDeclaration> getComputedStyle(Element&, const String& pseudoElt) const;
-        RefPtr<CSSStyleDeclaration> getComputedStyle(Document&, const String& pseudoElt, ExceptionCode&);
+    void moveBy(float x, float y) const;
+    void moveTo(float x, float y) const;
 
-        // WebKit extensions
+    void resizeBy(float x, float y) const;
+    void resizeTo(float width, float height) const;
 
-        WEBCORE_EXPORT RefPtr<CSSRuleList> getMatchedCSSRules(Element*, const String& pseudoElt, bool authorOnly = true) const;
-        double devicePixelRatio() const;
+    // Timers
+    ExceptionOr<int> setTimeout(std::unique_ptr<ScheduledAction>, int timeout);
+    void clearTimeout(int timeoutId);
+    ExceptionOr<int> setInterval(std::unique_ptr<ScheduledAction>, int timeout);
+    void clearInterval(int timeoutId);
 
-        RefPtr<WebKitPoint> webkitConvertPointFromPageToNode(Node*, const WebKitPoint*) const;
-        RefPtr<WebKitPoint> webkitConvertPointFromNodeToPage(Node*, const WebKitPoint*) const;
-
-        PageConsoleClient* console() const;
-
-        void printErrorMessage(const String&);
-        String crossDomainAccessErrorMessage(const DOMWindow& activeWindow);
-
-        void postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&&, const String& targetOrigin, DOMWindow& source, ExceptionCode&);
-        void postMessageTimerFired(PostMessageTimer&);
-        void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>);
-
-        void languagesChanged();
-
-        void scrollBy(const ScrollToOptions&) const;
-        void scrollBy(double x, double y) const;
-        void scrollTo(const ScrollToOptions&) const;
-        void scrollTo(double x, double y) const;
-
-        void moveBy(float x, float y) const;
-        void moveTo(float x, float y) const;
-
-        void resizeBy(float x, float y) const;
-        void resizeTo(float width, float height) const;
-
-        // Timers
-        int setTimeout(std::unique_ptr<ScheduledAction>, int timeout, ExceptionCode&);
-        void clearTimeout(int timeoutId);
-        int setInterval(std::unique_ptr<ScheduledAction>, int timeout, ExceptionCode&);
-        void clearInterval(int timeoutId);
-
-        // WebKit animation extensions
+    // WebKit animation extensions
 #if ENABLE(REQUEST_ANIMATION_FRAME)
-        int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
-        int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
-        void cancelAnimationFrame(int id);
+    int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
+    int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
+    void cancelAnimationFrame(int id);
 #endif
 
-        // Events
-        // EventTarget API
-        bool addEventListener(const AtomicString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
-        bool removeEventListener(const AtomicString& eventType, EventListener&, const ListenerOptions&) override;
-        void removeAllEventListeners() override;
+    // Events
+    // EventTarget API
+    bool addEventListener(const AtomicString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
+    bool removeEventListener(const AtomicString& eventType, EventListener&, const ListenerOptions&) override;
+    void removeAllEventListeners() override;
 
-        using EventTarget::dispatchEvent;
-        bool dispatchEvent(Event&, EventTarget*);
+    using EventTarget::dispatchEvent;
+    bool dispatchEvent(Event&, EventTarget*);
 
-        void dispatchLoadEvent();
+    void dispatchLoadEvent();
 
-        void captureEvents();
-        void releaseEvents();
+    void captureEvents();
+    void releaseEvents();
 
-        void finishedLoading();
+    void finishedLoading();
 
-        using RefCounted<DOMWindow>::ref;
-        using RefCounted<DOMWindow>::deref;
+    using RefCounted<DOMWindow>::ref;
+    using RefCounted<DOMWindow>::deref;
 
-        // HTML 5 key/value storage
-        Storage* sessionStorage(ExceptionCode&) const;
-        Storage* localStorage(ExceptionCode&) const;
-        Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
-        Storage* optionalLocalStorage() const { return m_localStorage.get(); }
+    // HTML 5 key/value storage
+    ExceptionOr<Storage*> sessionStorage() const;
+    ExceptionOr<Storage*> localStorage() const;
+    Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
+    Storage* optionalLocalStorage() const { return m_localStorage.get(); }
 
-        DOMApplicationCache* applicationCache() const;
-        DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); }
+    DOMApplicationCache* applicationCache() const;
+    DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); }
 
 #if ENABLE(CUSTOM_ELEMENTS)
-        CustomElementRegistry* customElementRegistry() { return m_customElementRegistry.get(); }
-        CustomElementRegistry& ensureCustomElementRegistry();
+    CustomElementRegistry* customElementRegistry() { return m_customElementRegistry.get(); }
+    CustomElementRegistry& ensureCustomElementRegistry();
 #endif
 
 #if ENABLE(ORIENTATION_EVENTS)
-        // This is the interface orientation in degrees. Some examples are:
-        //  0 is straight up; -90 is when the device is rotated 90 clockwise;
-        //  90 is when rotated counter clockwise.
-        int orientation() const;
+    // This is the interface orientation in degrees. Some examples are:
+    //  0 is straight up; -90 is when the device is rotated 90 clockwise;
+    //  90 is when rotated counter clockwise.
+    int orientation() const;
 #endif
 
 #if ENABLE(WEB_TIMING)
-        Performance* performance() const;
+    Performance* performance() const;
 #endif
-        double nowTimestamp() const;
+    double nowTimestamp() const;
 
 #if PLATFORM(IOS)
-        void incrementScrollEventListenersCount();
-        void decrementScrollEventListenersCount();
-        unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; }
+    void incrementScrollEventListenersCount();
+    void decrementScrollEventListenersCount();
+    unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; }
 #endif
 
-        void resetAllGeolocationPermission();
+    void resetAllGeolocationPermission();
 
 #if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
-        bool hasTouchEventListeners() const { return m_touchEventListenerCount > 0; }
+    bool hasTouchEventListeners() const { return m_touchEventListenerCount > 0; }
 #endif
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
-        bool shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld&);
-        WebKitNamespace* webkitNamespace() const;
+    bool shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld&);
+    WebKitNamespace* webkitNamespace() const;
 #endif
 
-        // FIXME: When this DOMWindow is no longer the active DOMWindow (i.e.,
-        // when its document is no longer the document that is displayed in its
-        // frame), we would like to zero out m_frame to avoid being confused
-        // by the document that is currently active in m_frame.
-        bool isCurrentlyDisplayedInFrame() const;
+    // FIXME: When this DOMWindow is no longer the active DOMWindow (i.e.,
+    // when its document is no longer the document that is displayed in its
+    // frame), we would like to zero out m_frame to avoid being confused
+    // by the document that is currently active in m_frame.
+    bool isCurrentlyDisplayedInFrame() const;
 
-        void willDetachDocumentFromFrame();
-        void willDestroyCachedFrame();
+    void willDetachDocumentFromFrame();
+    void willDestroyCachedFrame();
 
-        void enableSuddenTermination();
-        void disableSuddenTermination();
+    void enableSuddenTermination();
+    void disableSuddenTermination();
 
-        WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
 
-    private:
-        explicit DOMWindow(Document*);
+private:
+    explicit DOMWindow(Document*);
 
-        Page* page();
-        bool allowedToChangeWindowGeometry() const;
+    Page* page();
+    bool allowedToChangeWindowGeometry() const;
 
-        void frameDestroyed() override;
-        void willDetachPage() override;
+    void frameDestroyed() override;
+    void willDetachPage() override;
 
-        void refEventTarget() override { ref(); }
-        void derefEventTarget() override { deref(); }
+    void refEventTarget() override { ref(); }
+    void derefEventTarget() override { deref(); }
 
-        static RefPtr<Frame> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, std::function<void (DOMWindow&)> prepareDialogFunction = nullptr);
-        bool isInsecureScriptAccess(DOMWindow& activeWindow, const String& urlString);
+    static RefPtr<Frame> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, std::function<void(DOMWindow&)> prepareDialogFunction = nullptr);
+    bool isInsecureScriptAccess(DOMWindow& activeWindow, const String& urlString);
 
-        void resetDOMWindowProperties();
-        void disconnectDOMWindowProperties();
-        void reconnectDOMWindowProperties();
-        void willDestroyDocumentInFrame();
+    void resetDOMWindowProperties();
+    void disconnectDOMWindowProperties();
+    void reconnectDOMWindowProperties();
+    void willDestroyDocumentInFrame();
 
-        bool isSameSecurityOriginAsMainFrame() const;
+    bool isSameSecurityOriginAsMainFrame() const;
 
 #if ENABLE(GAMEPAD)
-        void incrementGamepadEventListenerCount();
-        void decrementGamepadEventListenerCount();
+    void incrementGamepadEventListenerCount();
+    void decrementGamepadEventListenerCount();
 #endif
 
-        bool m_shouldPrintWhenFinishedLoading;
-        bool m_suspendedForDocumentSuspension;
-        Optional<bool> m_canShowModalDialogOverride;
+    bool m_shouldPrintWhenFinishedLoading { false };
+    bool m_suspendedForDocumentSuspension { false };
+    Optional<bool> m_canShowModalDialogOverride;
 
-        HashSet<DOMWindowProperty*> m_properties;
+    HashSet<DOMWindowProperty*> m_properties;
 
-        mutable RefPtr<Crypto> m_crypto;
-        mutable RefPtr<History> m_history;
-        mutable RefPtr<BarProp> m_locationbar;
-        mutable RefPtr<StyleMedia> m_media;
-        mutable RefPtr<BarProp> m_menubar;
-        mutable RefPtr<Navigator> m_navigator;
-        mutable RefPtr<BarProp> m_personalbar;
-        mutable RefPtr<Screen> m_screen;
-        mutable RefPtr<BarProp> m_scrollbars;
-        mutable RefPtr<DOMSelection> m_selection;
-        mutable RefPtr<BarProp> m_statusbar;
-        mutable RefPtr<BarProp> m_toolbar;
-        mutable RefPtr<Location> m_location;
+    mutable RefPtr<Crypto> m_crypto;
+    mutable RefPtr<History> m_history;
+    mutable RefPtr<BarProp> m_locationbar;
+    mutable RefPtr<StyleMedia> m_media;
+    mutable RefPtr<BarProp> m_menubar;
+    mutable RefPtr<Navigator> m_navigator;
+    mutable RefPtr<BarProp> m_personalbar;
+    mutable RefPtr<Screen> m_screen;
+    mutable RefPtr<BarProp> m_scrollbars;
+    mutable RefPtr<DOMSelection> m_selection;
+    mutable RefPtr<BarProp> m_statusbar;
+    mutable RefPtr<BarProp> m_toolbar;
+    mutable RefPtr<Location> m_location;
 
-        String m_status;
-        String m_defaultStatus;
+    String m_status;
+    String m_defaultStatus;
 
-        enum PageStatus { PageStatusNone, PageStatusShown, PageStatusHidden };
-        PageStatus m_lastPageStatus;
+    enum class PageStatus { None, Shown, Hidden };
+    PageStatus m_lastPageStatus { PageStatus::None };
 
-        WeakPtrFactory<DOMWindow> m_weakPtrFactory;
+    WeakPtrFactory<DOMWindow> m_weakPtrFactory;
 
 #if PLATFORM(IOS)
-        unsigned m_scrollEventListenerCount;
+    unsigned m_scrollEventListenerCount { 0 };
 #endif
 
 #if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
-        unsigned m_touchEventListenerCount;
+    unsigned m_touchEventListenerCount { 0 };
 #endif
 
 #if ENABLE(GAMEPAD)
-        unsigned m_gamepadEventListenerCount;
+    unsigned m_gamepadEventListenerCount { 0 };
 #endif
-        mutable RefPtr<Storage> m_sessionStorage;
-        mutable RefPtr<Storage> m_localStorage;
-        mutable RefPtr<DOMApplicationCache> m_applicationCache;
+
+    mutable RefPtr<Storage> m_sessionStorage;
+    mutable RefPtr<Storage> m_localStorage;
+    mutable RefPtr<DOMApplicationCache> m_applicationCache;
 
 #if ENABLE(CUSTOM_ELEMENTS)
-        RefPtr<CustomElementRegistry> m_customElementRegistry;
+    RefPtr<CustomElementRegistry> m_customElementRegistry;
 #endif
 
 #if ENABLE(WEB_TIMING)
-        mutable RefPtr<Performance> m_performance;
+    mutable RefPtr<Performance> m_performance;
 #endif
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
-        mutable RefPtr<WebKitNamespace> m_webkitNamespace;
+    mutable RefPtr<WebKitNamespace> m_webkitNamespace;
 #endif
-    };
+};
 
-    inline String DOMWindow::status() const
-    {
-        return m_status;
-    }
+inline String DOMWindow::status() const
+{
+    return m_status;
+}
 
-    inline String DOMWindow::defaultStatus() const
-    {
-        return m_defaultStatus;
-    }
+inline String DOMWindow::defaultStatus() const
+{
+    return m_defaultStatus;
+}
 
 } // namespace WebCore
index ca98f61..ea0859a 100644 (file)
     [NewObject] CSSStyleDeclaration getComputedStyle(Element element, optional DOMString? pseudoElement = null);
 
     // FIXME: Drop the following overload of getComputedStyle once <rdar://problem/28020681> has been fixed.
-    [NewObject, MayThrowLegacyException] CSSStyleDeclaration getComputedStyle(Document document, optional DOMString? pseudoElement = null);
+    [NewObject, MayThrowException] CSSStyleDeclaration? getComputedStyle(Document document, optional DOMString? pseudoElement = null);
 
     CSSRuleList getMatchedCSSRules(optional Element? element = null, optional DOMString? pseudoElement = null);
 
 
     readonly attribute DOMApplicationCache applicationCache;
 
-    [GetterMayThrowLegacyException] readonly attribute Storage sessionStorage;
-    [GetterMayThrowLegacyException] readonly attribute Storage localStorage;
+    [GetterMayThrowException] readonly attribute Storage sessionStorage;
+    [GetterMayThrowException] readonly attribute Storage localStorage;
 
     // This is the interface orientation in degrees. Some examples:
     // 0 when straight up; -90 when rotated 90 degrees clockwise; 90 counter clockwise.
     [Conditional=ORIENTATION_EVENTS] readonly attribute long orientation;
 
-    [DoNotCheckSecurity, Custom, MayThrowLegacyException, ForwardDeclareInHeader] void postMessage(SerializedScriptValue message, USVString targetOrigin, optional Array messagePorts);
+    [DoNotCheckSecurity, Custom, MayThrowException, ForwardDeclareInHeader] void postMessage(SerializedScriptValue message, USVString targetOrigin, optional Array messagePorts);
 
     [Conditional=WEB_TIMING, Replaceable] readonly attribute Performance performance;
 
index f702aa7..4742288 100644 (file)
@@ -58,24 +58,19 @@ inline EventSource::EventSource(ScriptExecutionContext& context, const URL& url,
 {
 }
 
-RefPtr<EventSource> EventSource::create(ScriptExecutionContext& context, const String& url, const Init& eventSourceInit, ExceptionCode& ec)
+ExceptionOr<Ref<EventSource>> EventSource::create(ScriptExecutionContext& context, const String& url, const Init& eventSourceInit)
 {
-    if (url.isEmpty()) {
-        ec = SYNTAX_ERR;
-        return nullptr;
-    }
+    if (url.isEmpty())
+        return Exception { SYNTAX_ERR };
 
     URL fullURL = context.completeURL(url);
-    if (!fullURL.isValid()) {
-        ec = SYNTAX_ERR;
-        return nullptr;
-    }
+    if (!fullURL.isValid())
+        return Exception { SYNTAX_ERR };
 
-    // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
+    // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is resolved.
     if (!context.shouldBypassMainWorldContentSecurityPolicy() && !context.contentSecurityPolicy()->allowConnectToSource(fullURL)) {
         // FIXME: Should this be throwing an exception?
-        ec = SECURITY_ERR;
-        return nullptr;
+        return Exception { SECURITY_ERR };
     }
 
     auto source = adoptRef(*new EventSource(context, fullURL, eventSourceInit));
index 96a0ded..03aec2b 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "ActiveDOMObject.h"
 #include "EventTarget.h"
+#include "ExceptionOr.h"
 #include "URL.h"
 #include "ThreadableLoaderClient.h"
 #include "Timer.h"
@@ -50,13 +51,13 @@ public:
     struct Init {
         bool withCredentials;
     };
-    static RefPtr<EventSource> create(ScriptExecutionContext&, const String& url, const Init&, ExceptionCode&);
+    static ExceptionOr<Ref<EventSource>> create(ScriptExecutionContext&, const String& url, const Init&);
     virtual ~EventSource();
 
     const String& url() const;
     bool withCredentials() const;
 
-    typedef short State;
+    using State = short;
     static const State CONNECTING = 0;
     static const State OPEN = 1;
     static const State CLOSED = 2;
index 324e2bc..9624360 100644 (file)
@@ -34,7 +34,7 @@
     ActiveDOMObject,
     Constructor(USVString url, optional EventSourceInit eventSourceInitDict),
     ConstructorCallWith=ScriptExecutionContext,
-    ConstructorMayThrowLegacyException,
+    ConstructorMayThrowException,
 ] interface EventSource : EventTarget {
     readonly attribute USVString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
     readonly attribute USVString url;
index 00e8beb..39f82eb 100644 (file)
@@ -158,16 +158,15 @@ void Location::setHref(DOMWindow& activeWindow, DOMWindow& firstWindow, const St
     setLocation(activeWindow, firstWindow, url);
 }
 
-void Location::setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& protocol, ExceptionCode& ec)
+ExceptionOr<void> Location::setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& protocol)
 {
     if (!m_frame)
-        return;
+        return { };
     URL url = m_frame->document()->url();
-    if (!url.setProtocol(protocol)) {
-        ec = SYNTAX_ERR;
-        return;
-    }
+    if (!url.setProtocol(protocol))
+        return Exception { SYNTAX_ERR };
     setLocation(activeWindow, firstWindow, url.string());
+    return { };
 }
 
 void Location::setHost(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& host)
index d8b53eb..34ad95d 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef Location_h
-#define Location_h
+#pragma once
 
 #include "DOMStringList.h"
 #include "DOMWindowProperty.h"
+#include "ExceptionOr.h"
 #include "ScriptWrappable.h"
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -54,7 +52,7 @@ public:
     void replace(DOMWindow& activeWindow, DOMWindow& firstWindow, const String&);
     void reload(DOMWindow& activeWindow);
 
-    void setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String&, ExceptionCode&);
+    ExceptionOr<void> setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String&);
     String protocol() const;
     void setHost(DOMWindow& activeWindow, DOMWindow& firstWindow, const String&);
     String host() const;
@@ -83,5 +81,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // Location_h
index 052c8bc..e435eeb 100644 (file)
@@ -48,7 +48,7 @@
     [CallWith=ActiveWindow, ForwardDeclareInHeader] void reload();
 
     // URI decomposition attributes
-    [SetterCallWith=ActiveWindow&FirstWindow, SetterMayThrowLegacyException] attribute USVString protocol;
+    [SetterCallWith=ActiveWindow&FirstWindow, SetterMayThrowException] attribute USVString protocol;
     [SetterCallWith=ActiveWindow&FirstWindow] attribute USVString host;
     [SetterCallWith=ActiveWindow&FirstWindow] attribute USVString hostname;
     [SetterCallWith=ActiveWindow&FirstWindow] attribute USVString port;
index 11b8647..b8849a8 100644 (file)
@@ -31,9 +31,9 @@
  */
 
 #include "config.h"
+#include "Performance.h"
 
 #if ENABLE(WEB_TIMING)
-#include "Performance.h"
 
 #include "Document.h"
 #include "DocumentLoader.h"
 
 namespace WebCore {
 
-static const size_t defaultResourceTimingBufferSize = 150;
-
 Performance::Performance(Frame& frame)
     : DOMWindowProperty(&frame)
-    , m_resourceTimingBufferSize(defaultResourceTimingBufferSize)
     , m_referenceTime(frame.document()->loader() ? frame.document()->loader()->timing().referenceMonotonicTime() : monotonicallyIncreasingTime())
-#if ENABLE(USER_TIMING)
-    , m_userTiming(nullptr)
-#endif // ENABLE(USER_TIMING)
 {
     ASSERT(m_referenceTime);
 }
@@ -73,20 +67,18 @@ ScriptExecutionContext* Performance::scriptExecutionContext() const
     return frame()->document();
 }
 
-PerformanceNavigation* Performance::navigation() const
+PerformanceNavigation& Performance::navigation()
 {
     if (!m_navigation)
         m_navigation = PerformanceNavigation::create(m_frame);
-
-    return m_navigation.get();
+    return *m_navigation;
 }
 
-PerformanceTiming* Performance::timing() const
+PerformanceTiming& Performance::timing()
 {
     if (!m_timing)
         m_timing = PerformanceTiming::create(m_frame);
-
-    return m_timing.get();
+    return *m_timing;
 }
 
 Vector<RefPtr<PerformanceEntry>> Performance::getEntries() const
@@ -164,7 +156,7 @@ void Performance::setResourceTimingBufferSize(unsigned size)
         dispatchEvent(Event::create(eventNames().resourcetimingbufferfullEvent, false, false));
 }
 
-void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const URL& originalURL, const ResourceResponse& response, LoadTiming loadTiming)
+void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const URL& originalURL, const ResourceResponse& response, const LoadTiming& loadTiming)
 {
     if (isResourceTimingBufferFull())
         return;
@@ -183,33 +175,32 @@ bool Performance::isResourceTimingBufferFull()
 }
 
 #if ENABLE(USER_TIMING)
-void Performance::webkitMark(const String& markName, ExceptionCode& ec)
+
+ExceptionOr<void> Performance::webkitMark(const String& markName)
 {
-    ec = 0;
     if (!m_userTiming)
-        m_userTiming = UserTiming::create(this);
-    m_userTiming->mark(markName, ec);
+        m_userTiming = std::make_unique<UserTiming>(*this);
+    return m_userTiming->mark(markName);
 }
 
 void Performance::webkitClearMarks(const String& markName)
 {
     if (!m_userTiming)
-        m_userTiming = UserTiming::create(this);
+        m_userTiming = std::make_unique<UserTiming>(*this);
     m_userTiming->clearMarks(markName);
 }
 
-void Performance::webkitMeasure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode& ec)
+ExceptionOr<void> Performance::webkitMeasure(const String& measureName, const String& startMark, const String& endMark)
 {
-    ec = 0;
     if (!m_userTiming)
-        m_userTiming = UserTiming::create(this);
-    m_userTiming->measure(measureName, startMark, endMark, ec);
+        m_userTiming = std::make_unique<UserTiming>(*this);
+    return m_userTiming->measure(measureName, startMark, endMark);
 }
 
 void Performance::webkitClearMeasures(const String& measureName)
 {
     if (!m_userTiming)
-        m_userTiming = UserTiming::create(this);
+        m_userTiming = std::make_unique<UserTiming>(*this);
     m_userTiming->clearMeasures(measureName);
 }
 
@@ -224,7 +215,7 @@ double Performance::now() const
 double Performance::reduceTimeResolution(double seconds)
 {
     const double resolutionSeconds = 0.000005;
-    return floor(seconds / resolutionSeconds) * resolutionSeconds;
+    return std::floor(seconds / resolutionSeconds) * resolutionSeconds;
 }
 
 } // namespace WebCore
index 9da954d..2b9b1b7 100644 (file)
 
 #include "DOMWindowProperty.h"
 #include "EventTarget.h"
-#include "PerformanceNavigation.h"
-#include "PerformanceTiming.h"
-#include "ScriptWrappable.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "ExceptionOr.h"
 
 namespace WebCore {
 
 class Document;
 class LoadTiming;
 class PerformanceEntry;
-class ResourceRequest;
+class PerformanceNavigation;
+class PerformanceTiming;
 class ResourceResponse;
-class UserTiming;
 class URL;
+class UserTiming;
 
 class Performance final : public RefCounted<Performance>, public DOMWindowProperty, public EventTargetWithInlineData {
 public:
     static Ref<Performance> create(Frame& frame) { return adoptRef(*new Performance(frame)); }
     ~Performance();
 
-    EventTargetInterface eventTargetInterface() const override { return PerformanceEventTargetInterfaceType; }
-    ScriptExecutionContext* scriptExecutionContext() const override;
-
-    PerformanceNavigation* navigation() const;
-    PerformanceTiming* timing() const;
+    PerformanceNavigation& navigation();
+    PerformanceTiming& timing();
     double now() const;
 
     Vector<RefPtr<PerformanceEntry>> getEntries() const;
@@ -72,39 +65,44 @@ public:
     void clearResourceTimings();
     void setResourceTimingBufferSize(unsigned);
 
-    void addResourceTiming(const String& initiatorName, Document*, const URL& originalURL, const ResourceResponse&, LoadTiming);
+    void addResourceTiming(const String& initiatorName, Document*, const URL& originalURL, const ResourceResponse&, const LoadTiming&);
 
-    using RefCounted<Performance>::ref;
-    using RefCounted<Performance>::deref;
+    using RefCounted::ref;
+    using RefCounted::deref;
 
 #if ENABLE(USER_TIMING)
-    void webkitMark(const String& markName, ExceptionCode&);
+    ExceptionOr<void> webkitMark(const String& markName);
     void webkitClearMarks(const String& markName);
 
-    void webkitMeasure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode&);
+    ExceptionOr<void> webkitMeasure(const String& measureName, const String& startMark, const String& endMark);
     void webkitClearMeasures(const String& measureName);
-#endif // ENABLE(USER_TIMING)
+#endif
 
     static double reduceTimeResolution(double seconds);
 
 private:
     explicit Performance(Frame&);
 
-    void refEventTarget() override { ref(); }
-    void derefEventTarget() override { deref(); }
+    EventTargetInterface eventTargetInterface() const final { return PerformanceEventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const final;
+
+    void refEventTarget() final { ref(); }
+    void derefEventTarget() final { deref(); }
+
     bool isResourceTimingBufferFull();
 
     mutable RefPtr<PerformanceNavigation> m_navigation;
     mutable RefPtr<PerformanceTiming> m_timing;
 
+    // https://w3c.github.io/resource-timing/#extensions-performance-interface recommends size of 150.
     Vector<RefPtr<PerformanceEntry>> m_resourceTimingBuffer;
-    unsigned m_resourceTimingBufferSize;
+    unsigned m_resourceTimingBufferSize { 150 };
 
     double m_referenceTime;
 
 #if ENABLE(USER_TIMING)
-    RefPtr<UserTiming> m_userTiming;
-#endif // ENABLE(USER_TIMING)
+    std::unique_ptr<UserTiming> m_userTiming;
+#endif
 };
 
 }
index 998b1e0..5dd0d01 100644 (file)
@@ -41,7 +41,6 @@
     [EnabledAtRuntime=ResourceTiming] PerformanceEntryList getEntriesByType(DOMString entryType);
     [EnabledAtRuntime=ResourceTiming] PerformanceEntryList getEntriesByName(DOMString name, optional DOMString entryType);
 
-
     [EnabledAtRuntime=ResourceTiming] void clearResourceTimings();
     [EnabledAtRuntime=ResourceTiming] void setResourceTimingBufferSize(unsigned long maxSize);
 
 
     // See http://www.w3.org/TR/2012/CR-user-timing-20120726/
 #if defined(ENABLE_USER_TIMING) && ENABLE_USER_TIMING
-    [MayThrowLegacyException] void webkitMark(DOMString markName);
-    void webkitClearMarks(optional  DOMString markName);
+    [MayThrowException] void webkitMark(DOMString markName);
+    void webkitClearMarks(optional DOMString markName);
 
-    [MayThrowLegacyException] void webkitMeasure(DOMString measureName, optional DOMString startMark, optional DOMString endMark);
+    [MayThrowException] void webkitMeasure(DOMString measureName, optional DOMString startMark, optional DOMString endMark);
     void webkitClearMeasures(optional DOMString measureName);
 #endif
 
index 5c85fd1..899901d 100644 (file)
 
 #if ENABLE(USER_TIMING)
 
+#include "ExceptionCode.h"
 #include "Performance.h"
+#include "PerformanceEntry.h"
 #include "PerformanceMark.h"
 #include "PerformanceMeasure.h"
+#include <array>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/dtoa/utils.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
 namespace {
 
+typedef unsigned long long (PerformanceTiming::*NavigationTimingFunction)() const;
+
 static NavigationTimingFunction restrictedMarkFunction(const String& markName)
 {
     using MapPair = std::pair<ASCIILiteral, NavigationTimingFunction>;
     static const std::array<MapPair, 21> pairs = { {
-        MapPair{ ASCIILiteral("navigationStart"), &PerformanceTiming::navigationStart },
-        MapPair{ ASCIILiteral("unloadEventStart"), &PerformanceTiming::unloadEventStart },
-        MapPair{ ASCIILiteral("unloadEventEnd"), &PerformanceTiming::unloadEventEnd },
-        MapPair{ ASCIILiteral("redirectStart"), &PerformanceTiming::redirectStart },
-        MapPair{ ASCIILiteral("redirectEnd"), &PerformanceTiming::redirectEnd },
-        MapPair{ ASCIILiteral("fetchStart"), &PerformanceTiming::fetchStart },
-        MapPair{ ASCIILiteral("domainLookupStart"), &PerformanceTiming::domainLookupStart },
-        MapPair{ ASCIILiteral("domainLookupEnd"), &PerformanceTiming::domainLookupEnd },
-        MapPair{ ASCIILiteral("connectStart"), &PerformanceTiming::connectStart },
-        MapPair{ ASCIILiteral("connectEnd"), &PerformanceTiming::connectEnd },
-        MapPair{ ASCIILiteral("secureConnectionStart"), &PerformanceTiming::secureConnectionStart },
-        MapPair{ ASCIILiteral("requestStart"), &PerformanceTiming::requestStart },
-        MapPair{ ASCIILiteral("responseStart"), &PerformanceTiming::responseStart },
-        MapPair{ ASCIILiteral("responseEnd"), &PerformanceTiming::responseEnd },
-        MapPair{ ASCIILiteral("domLoading"), &PerformanceTiming::domLoading },
-        MapPair{ ASCIILiteral("domInteractive"), &PerformanceTiming::domInteractive },
-        MapPair{ ASCIILiteral("domContentLoadedEventStart"), &PerformanceTiming::domContentLoadedEventStart },
-        MapPair{ ASCIILiteral("domContentLoadedEventEnd"), &PerformanceTiming::domContentLoadedEventEnd },
-        MapPair{ ASCIILiteral("domComplete"), &PerformanceTiming::domComplete },
-        MapPair{ ASCIILiteral("loadEventStart"), &PerformanceTiming::loadEventStart },
-        MapPair{ ASCIILiteral("loadEventEnd"), &PerformanceTiming::loadEventEnd },
+        { ASCIILiteral("navigationStart"), &PerformanceTiming::navigationStart },
+        { ASCIILiteral("unloadEventStart"), &PerformanceTiming::unloadEventStart },
+        { ASCIILiteral("unloadEventEnd"), &PerformanceTiming::unloadEventEnd },
+        { ASCIILiteral("redirectStart"), &PerformanceTiming::redirectStart },
+        { ASCIILiteral("redirectEnd"), &PerformanceTiming::redirectEnd },
+        { ASCIILiteral("fetchStart"), &PerformanceTiming::fetchStart },
+        { ASCIILiteral("domainLookupStart"), &PerformanceTiming::domainLookupStart },
+        { ASCIILiteral("domainLookupEnd"), &PerformanceTiming::domainLookupEnd },
+        { ASCIILiteral("connectStart"), &PerformanceTiming::connectStart },
+        { ASCIILiteral("connectEnd"), &PerformanceTiming::connectEnd },
+        { ASCIILiteral("secureConnectionStart"), &PerformanceTiming::secureConnectionStart },
+        { ASCIILiteral("requestStart"), &PerformanceTiming::requestStart },
+        { ASCIILiteral("responseStart"), &PerformanceTiming::responseStart },
+        { ASCIILiteral("responseEnd"), &PerformanceTiming::responseEnd },
+        { ASCIILiteral("domLoading"), &PerformanceTiming::domLoading },
+        { ASCIILiteral("domInteractive"), &PerformanceTiming::domInteractive },
+        { ASCIILiteral("domContentLoadedEventStart"), &PerformanceTiming::domContentLoadedEventStart },
+        { ASCIILiteral("domContentLoadedEventEnd"), &PerformanceTiming::domContentLoadedEventEnd },
+        { ASCIILiteral("domComplete"), &PerformanceTiming::domComplete },
+        { ASCIILiteral("loadEventStart"), &PerformanceTiming::loadEventStart },
+        { ASCIILiteral("loadEventEnd"), &PerformanceTiming::loadEventEnd },
     } };
 
     static NeverDestroyed<HashMap<String, NavigationTimingFunction>> map;
@@ -77,7 +81,7 @@ static NavigationTimingFunction restrictedMarkFunction(const String& markName)
 
 } // namespace anonymous
 
-UserTiming::UserTiming(Performance* performance)
+UserTiming::UserTiming(Performance& performance)
     : m_performance(performance)
 {
 }
@@ -102,16 +106,13 @@ static void clearPeformanceEntries(PerformanceEntryMap& performanceEntryMap, con
     performanceEntryMap.remove(name);
 }
 
-void UserTiming::mark(const String& markName, ExceptionCode& ec)
+ExceptionOr<void> UserTiming::mark(const String& markName)
 {
-    ec = 0;
-    if (restrictedMarkFunction(markName)) {
-        ec = SYNTAX_ERR;
-        return;
-    }
+    if (restrictedMarkFunction(markName))
+        return Exception { SYNTAX_ERR };
 
-    double startTime = m_performance->now();
-    insertPerformanceEntry(m_marksMap, PerformanceMark::create(markName, startTime));
+    insertPerformanceEntry(m_marksMap, PerformanceMark::create(markName, m_performance.now()));
+    return { };
 }
 
 void UserTiming::clearMarks(const String& markName)
@@ -119,48 +120,47 @@ void UserTiming::clearMarks(const String& markName)
     clearPeformanceEntries(m_marksMap, markName);
 }
 
-double UserTiming::findExistingMarkStartTime(const String& markName, ExceptionCode& ec)
+ExceptionOr<double> UserTiming::findExistingMarkStartTime(const String& markName)
 {
-    ec = 0;
-
     if (m_marksMap.contains(markName))
         return m_marksMap.get(markName).last()->startTime();
 
     if (auto function = restrictedMarkFunction(markName)) {
-        double value = static_cast<double>((m_performance->timing()->*(function))());
-        if (!value) {
-            ec = INVALID_ACCESS_ERR;
-            return 0.0;
-        }
-        return value - m_performance->timing()->navigationStart();
+        double value = static_cast<double>((m_performance.timing().*(function))());
+        if (!value)
+            return Exception { INVALID_ACCESS_ERR };
+        return value - m_performance.timing().navigationStart();
     }
 
-    ec = SYNTAX_ERR;
-    return 0.0;
+    return Exception { SYNTAX_ERR };
 }
 
-void UserTiming::measure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode& ec)
+ExceptionOr<void> UserTiming::measure(const String& measureName, const String& startMark, const String& endMark)
 {
     double startTime = 0.0;
     double endTime = 0.0;
 
     if (startMark.isNull())
-        endTime = m_performance->now();
+        endTime = m_performance.now();
     else if (endMark.isNull()) {
-        endTime = m_performance->now();
-        startTime = findExistingMarkStartTime(startMark, ec);
-        if (ec)
-            return;
+        endTime = m_performance.now();
+        auto startMarkResult = findExistingMarkStartTime(startMark);
+        if (startMarkResult.hasException())
+            return startMarkResult.releaseException();
+        endTime = startMarkResult.releaseReturnValue();
     } else {
-        endTime = findExistingMarkStartTime(endMark, ec);
-        if (ec)
-            return;
-        startTime = findExistingMarkStartTime(startMark, ec);
-        if (ec)
-            return;
+        auto endMarkResult = findExistingMarkStartTime(endMark);
+        if (endMarkResult.hasException())
+            return endMarkResult.releaseException();
+        auto startMarkResult = findExistingMarkStartTime(startMark);
+        if (startMarkResult.hasException())
+            return startMarkResult.releaseException();
+        startTime = startMarkResult.releaseReturnValue();
+        endTime = endMarkResult.releaseReturnValue();
     }
 
     insertPerformanceEntry(m_measuresMap, PerformanceMeasure::create(measureName, startTime, endTime));
+    return { };
 }
 
 void UserTiming::clearMeasures(const String& measureName)
@@ -168,43 +168,35 @@ void UserTiming::clearMeasures(const String& measureName)
     clearPeformanceEntries(m_measuresMap, measureName);
 }
 
-static Vector<RefPtr<PerformanceEntry> > convertToEntrySequence(const PerformanceEntryMap& performanceEntryMap)
+static Vector<RefPtr<PerformanceEntry>> convertToEntrySequence(const PerformanceEntryMap& performanceEntryMap)
 {
-    Vector<RefPtr<PerformanceEntry> > entries;
-
+    Vector<RefPtr<PerformanceEntry>> entries;
     for (auto& entry : performanceEntryMap.values())
         entries.appendVector(entry);
-
     return entries;
 }
 
-static Vector<RefPtr<PerformanceEntry> > getEntrySequenceByName(const PerformanceEntryMap& performanceEntryMap, const String& name)
+static Vector<RefPtr<PerformanceEntry>> getEntrySequenceByName(const PerformanceEntryMap& performanceEntryMap, const String& name)
 {
-    Vector<RefPtr<PerformanceEntry> > entries;
-
-    PerformanceEntryMap::const_iterator it = performanceEntryMap.find(name);
-    if (it != performanceEntryMap.end())
-        entries.appendVector(it->value);
-
-    return entries;
+    return performanceEntryMap.get(name);
 }
 
-Vector<RefPtr<PerformanceEntry> > UserTiming::getMarks() const
+Vector<RefPtr<PerformanceEntry>> UserTiming::getMarks() const
 {
     return convertToEntrySequence(m_marksMap);
 }
 
-Vector<RefPtr<PerformanceEntry> > UserTiming::getMarks(const String& name) const
+Vector<RefPtr<PerformanceEntry>> UserTiming::getMarks(const String& name) const
 {
     return getEntrySequenceByName(m_marksMap, name);
 }
 
-Vector<RefPtr<PerformanceEntry> > UserTiming::getMeasures() const
+Vector<RefPtr<PerformanceEntry>> UserTiming::getMeasures() const
 {
     return convertToEntrySequence(m_measuresMap);
 }
 
-Vector<RefPtr<PerformanceEntry> > UserTiming::getMeasures(const String& name) const
+Vector<RefPtr<PerformanceEntry>> UserTiming::getMeasures(const String& name) const
 {
     return getEntrySequenceByName(m_measuresMap, name);
 }
index 8247eef..4e54eab 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef PerformanceUserTiming_h
-#define PerformanceUserTiming_h
+#pragma once
 
 #if ENABLE(USER_TIMING)
 
-#include "ExceptionCode.h"
-#include "Performance.h"
-#include "PerformanceTiming.h"
+#include "ExceptionOr.h"
 #include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
 #include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
 class Performance;
 class PerformanceEntry;
 
-typedef unsigned long long (PerformanceTiming::*NavigationTimingFunction)() const;
-typedef HashMap<String, Vector<RefPtr<PerformanceEntry> > > PerformanceEntryMap;
+using PerformanceEntryMap = HashMap<String, Vector<RefPtr<PerformanceEntry>>>;
 
-class UserTiming : public RefCounted<UserTiming> {
+class UserTiming {
 public:
-    static Ref<UserTiming> create(Performance* performance) { return adoptRef(*new UserTiming(performance)); }
+    explicit UserTiming(Performance&);
 
-    void mark(const String& markName, ExceptionCode&);
+    ExceptionOr<void> mark(const String& markName);
     void clearMarks(const String& markName);
 
-    void measure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode&);
+    ExceptionOr<void> measure(const String& measureName, const String& startMark, const String& endMark);
     void clearMeasures(const String& measureName);
 
-    Vector<RefPtr<PerformanceEntry> > getMarks() const;
-    Vector<RefPtr<PerformanceEntry> > getMeasures() const;
+    Vector<RefPtr<PerformanceEntry>> getMarks() const;
+    Vector<RefPtr<PerformanceEntry>> getMeasures() const;
 
-    Vector<RefPtr<PerformanceEntry> > getMarks(const String& name) const;
-    Vector<RefPtr<PerformanceEntry> > getMeasures(const String& name) const;
+    Vector<RefPtr<PerformanceEntry>> getMarks(const String& name) const;
+    Vector<RefPtr<PerformanceEntry>> getMeasures(const String& name) const;
 
 private:
-    explicit UserTiming(Performance*);
+    ExceptionOr<double> findExistingMarkStartTime(const String& markName);
 
-    double findExistingMarkStartTime(const String& markName, ExceptionCode&);
-    Performance* m_performance;
+    Performance& m_performance;
     PerformanceEntryMap m_marksMap;
     PerformanceEntryMap m_measuresMap;
 };
@@ -72,5 +65,3 @@ private:
 }
 
 #endif // ENABLE(USER_TIMING)
-
-#endif // !defined(PerformanceUserTiming_h)
index 9a52d60..0ff70e2 100644 (file)
@@ -44,16 +44,15 @@ UserMessageHandler::~UserMessageHandler()
 {
 }
 
-void UserMessageHandler::postMessage(PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec)
+ExceptionOr<void> UserMessageHandler::postMessage(RefPtr<SerializedScriptValue>&& value)
 {
     // Check to see if the descriptor has been removed. This can happen if the host application has
     // removed the named message handler at the WebKit2 API level.
-    if (!m_descriptor) {
-        ec = INVALID_ACCESS_ERR;
-        return;
-    }
+    if (!m_descriptor)
+        return Exception { INVALID_ACCESS_ERR };
 
     m_descriptor->didPostMessage(*this, value.get());
+    return { };
 }
 
 } // namespace WebCore
index 512a114..94affb5 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef UserMessageHandler_h
-#define UserMessageHandler_h
+#pragma once
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
 
+#include "ExceptionOr.h"
 #include "FrameDestructionObserver.h"
 #include "UserMessageHandlerDescriptor.h"
 
 namespace WebCore {
 
-typedef int ExceptionCode;
-
 class UserMessageHandler : public RefCounted<UserMessageHandler>, public FrameDestructionObserver {
 public:
     static Ref<UserMessageHandler> create(Frame& frame, UserMessageHandlerDescriptor& descriptor)
@@ -43,7 +41,7 @@ public:
     }
     virtual ~UserMessageHandler();
 
-    void postMessage(PassRefPtr<SerializedScriptValue>, ExceptionCode&);
+    ExceptionOr<void> postMessage(RefPtr<SerializedScriptValue>&&);
 
     UserMessageHandlerDescriptor* descriptor() { return m_descriptor.get(); }
     void invalidateDescriptor() { m_descriptor = nullptr; }
@@ -57,4 +55,3 @@ private:
 } // namespace WebCore
 
 #endif // ENABLE(USER_MESSAGE_HANDLERS)
-#endif // UserMessageHandler_h
index cf8c335..776c182 100644 (file)
@@ -26,5 +26,5 @@
 [
     Conditional=USER_MESSAGE_HANDLERS
 ] interface UserMessageHandler {
-    [MayThrowLegacyException] void postMessage(SerializedScriptValue message);
+    [MayThrowException] void postMessage(SerializedScriptValue message);
 };
index 5ebdf38..b86f69c 100644 (file)
@@ -57,13 +57,10 @@ Storage::~Storage()
     m_storageArea->decrementAccessCount();
 }
 
-unsigned Storage::length(ExceptionCode& ec) const
+ExceptionOr<unsigned> Storage::length() const
 {
-    ec = 0;
-    if (!m_storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return 0;
-    }
+    if (!m_storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     if (isDisabledByPrivateBrowsing())
         return 0;
@@ -71,12 +68,10 @@ unsigned Storage::length(ExceptionCode& ec) const
     return m_storageArea->length();
 }
 
-String Storage::key(unsigned index, ExceptionCode& ec) const
+ExceptionOr<String> Storage::key(unsigned index) const
 {
-    if (!m_storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return String();
-    }
+    if (!m_storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     if (isDisabledByPrivateBrowsing())
         return String();
@@ -84,12 +79,10 @@ String Storage::key(unsigned index, ExceptionCode& ec) const
     return m_storageArea->key(index);
 }
 
-String Storage::getItem(const String& key, ExceptionCode& ec) const
+ExceptionOr<String> Storage::getItem(const String& key) const
 {
-    if (!m_storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return String();
-    }
+    if (!m_storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     if (isDisabledByPrivateBrowsing())
         return String();
@@ -97,57 +90,49 @@ String Storage::getItem(const String& key, ExceptionCode& ec) const
     return m_storageArea->item(key);
 }
 
-void Storage::setItem(const String& key, const String& value, ExceptionCode& ec)
+ExceptionOr<void> Storage::setItem(const String& key, const String& value)
 {
-    if (!m_storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return;
-    }
+    if (!m_storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
-    if (isDisabledByPrivateBrowsing()) {
-        ec = QUOTA_EXCEEDED_ERR;
-        return;
-    }
+    if (isDisabledByPrivateBrowsing())
+        return Exception { QUOTA_EXCEEDED_ERR };
 
     bool quotaException = false;
     m_storageArea->setItem(m_frame, key, value, quotaException);
-
     if (quotaException)
-        ec = QUOTA_EXCEEDED_ERR;
+        return Exception { QUOTA_EXCEEDED_ERR };
+    return { };
 }
 
-void Storage::removeItem(const String& key, ExceptionCode& ec)
+ExceptionOr<void> Storage::removeItem(const String& key)
 {
-    if (!m_storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return;
-    }
+    if (!m_storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     if (isDisabledByPrivateBrowsing())
-        return;
+        return { };
 
     m_storageArea->removeItem(m_frame, key);
+    return { };
 }
 
-void Storage::clear(ExceptionCode& ec)
+ExceptionOr<void> Storage::clear()
 {
-    if (!m_storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return;
-    }
+    if (!m_storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     if (isDisabledByPrivateBrowsing())
-        return;
+        return { };
 
     m_storageArea->clear(m_frame);
+    return { };
 }
 
-bool Storage::contains(const String& key, ExceptionCode& ec) const
+ExceptionOr<bool> Storage::contains(const String& key) const
 {
-    if (!m_storageArea->canAccessStorage(m_frame)) {
-        ec = SECURITY_ERR;
-        return false;
-    }
+    if (!m_storageArea->canAccessStorage(m_frame))
+        return Exception { SECURITY_ERR };
 
     if (isDisabledByPrivateBrowsing())
         return false;
index 46f0267..5df3ae9 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef Storage_h
-#define Storage_h
+#pragma once
 
 #include "DOMWindowProperty.h"
+#include "ExceptionOr.h"
 #include "ScriptWrappable.h"
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
 class Frame;
 class StorageArea;
 
-typedef int ExceptionCode;
-
 class Storage : public ScriptWrappable, public RefCounted<Storage>, public DOMWindowProperty {
 public:
     static Ref<Storage> create(Frame*, RefPtr<StorageArea>&&);
     ~Storage();
 
-    unsigned length(ExceptionCode&) const;
-    String key(unsigned index, ExceptionCode&) const;
-    String getItem(const String& key, ExceptionCode&) const;
-    void setItem(const String& key, const String& value, ExceptionCode&);
-    void removeItem(const String& key, ExceptionCode&);
-    void clear(ExceptionCode&);
-    bool contains(const String& key, ExceptionCode&) const;
+    ExceptionOr<unsigned> length() const;
+    ExceptionOr<String> key(unsigned index) const;
+    ExceptionOr<String> getItem(const String& key) const;
+    ExceptionOr<void> setItem(const String& key, const String& value);
+    ExceptionOr<void> removeItem(const String& key);
+    ExceptionOr<void> clear();
+    ExceptionOr<bool> contains(const String& key) const;
 
     StorageArea& area() const { return *m_storageArea; }
 
@@ -63,5 +58,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // Storage_h
index b084f7d..3d4aa56 100644 (file)
     CustomNamedSetter,
     SkipVTableValidation,
 ] interface Storage {
-    [GetterMayThrowLegacyException] readonly attribute unsigned long length;
-    [MayThrowLegacyException] DOMString? key(unsigned long index);
-    [MayThrowLegacyException] getter DOMString? getItem(DOMString key);
-    [MayThrowLegacyException] void setItem(DOMString key, DOMString data);
-    [MayThrowLegacyException] void removeItem(DOMString key);
-    [MayThrowLegacyException] void clear();
+    [GetterMayThrowException] readonly attribute unsigned long length;
+    [MayThrowException] DOMString? key(unsigned long index);
+    [MayThrowException] getter DOMString? getItem(DOMString key);
+    [MayThrowException] void setItem(DOMString key, DOMString data);
+    [MayThrowException] void removeItem(DOMString key);
+    [MayThrowException] void clear();
 };
 
index 7cb42a7..ec501fe 100644 (file)
@@ -79,10 +79,9 @@ void StorageEventDispatcher::dispatchSessionStorageEventsToFrames(Page& page, co
     InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, SessionStorage, securityOrigin, &page);
 
     for (auto& frame : frames) {
-        ExceptionCode ec = 0;
-        Storage* storage = frame->document()->domWindow()->sessionStorage(ec);
-        if (!ec)
-            frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+        auto result = frame->document()->domWindow()->sessionStorage();
+        if (!result.hasException())
+            frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, result.releaseReturnValue()));
     }
 }
 
@@ -92,10 +91,9 @@ void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageG
         InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStorage, securityOrigin, page);
 
     for (auto& frame : frames) {
-        ExceptionCode ec = 0;
-        Storage* storage = frame->document()->domWindow()->localStorage(ec);
-        if (!ec)
-            frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+        auto result = frame->document()->domWindow()->localStorage();
+        if (!result.hasException())
+            frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, result.releaseReturnValue()));
     }
 }
 
index f7572f0..6273a0f 100644 (file)
@@ -1,3 +1,14 @@
+2016-10-18  Darin Adler  <darin@apple.com>
+
+        Move many miscellaneous classes from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163645
+
+        Reviewed by Ryosuke Niwa.
+
+        * DOMCoreClasses.cpp:
+        (DOMDocument::getComputedStyle): Use ptr instead of get since the return
+        value is now Ref instead of RefPtr.
+
 2016-10-18  Anders Carlsson  <andersca@apple.com>
 
         Try to fix the Windows build.
index ca23cf1..db10f0b 100644 (file)
@@ -803,7 +803,7 @@ HRESULT DOMDocument::getComputedStyle(_In_opt_ IDOMElement* elt, _In_ BSTR pseud
     if (!dv)
         return E_FAIL;
     
-    *result = DOMCSSStyleDeclaration::createInstance(dv->getComputedStyle(*element, pseudoEltString.impl()).get());
+    *result = DOMCSSStyleDeclaration::createInstance(dv->getComputedStyle(*element, pseudoEltString.impl()).ptr());
     return *result ? S_OK : E_FAIL;
 }