Changeset 207522 in webkit


Ignore:
Timestamp:
Oct 19, 2016 12:00:10 AM (7 years ago)
Author:
Darin Adler
Message:

Move many miscellaneous classes from ExceptionCode to Exception
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.

Location:
trunk/Source
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207521 r207522  
     12016-10-18  Darin Adler  <darin@apple.com>
     2
     3        Move many miscellaneous classes from ExceptionCode to Exception
     4        https://bugs.webkit.org/show_bug.cgi?id=163645
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * bindings/js/JSCryptoCustom.cpp:
     9        (WebCore::JSCrypto::getRandomValues): Use propagateException.
     10        * bindings/js/JSDOMWindowCustom.cpp:
     11        (WebCore::handlePostMessage): Ditto.
     12        (WebCore::JSDOMWindow::setTimeout): Use toJSNumber.
     13        (WebCore::JSDOMWindow::setInterval): Ditto.
     14        * bindings/js/JSStorageCustom.cpp:
     15        (WebCore::JSStorage::nameGetter): Use propagateException.
     16        (WebCore::JSStorage::deleteProperty): Ditto.
     17        (WebCore::JSStorage::getOwnPropertyNames): Ditto.
     18        (WebCore::JSStorage::putDelegate): Ditto.
     19
     20        * loader/appcache/DOMApplicationCache.cpp:
     21        (WebCore::DOMApplicationCache::update): Use ExceptionOr.
     22        (WebCore::DOMApplicationCache::swapCache): Ditto.
     23        * loader/appcache/DOMApplicationCache.h: Update for above changes.
     24        * loader/appcache/DOMApplicationCache.idl: Use non-legacy exceptions.
     25
     26        * page/Crypto.cpp:
     27        (WebCore::Crypto::getRandomValues): Use ExceptionOr.
     28        (WebCore::Crypto::webkitSubtle): Ditto.
     29        * page/Crypto.h: Updated for above changes.
     30        * page/Crypto.idl: Use non-legacy exceptions.
     31
     32        * page/DOMWindow.cpp:
     33        (WebCore::DOMWindow::DOMWindow): Initialize many data members in
     34        the class definition instead of here.
     35        (WebCore::DOMWindow::page): Use nullptr.
     36        (WebCore::DOMWindow::screen): Ditto.
     37        (WebCore::DOMWindow::crypto): Ditto.
     38        (WebCore::DOMWindow::locationbar): Ditto.
     39        (WebCore::DOMWindow::menubar): Ditto.
     40        (WebCore::DOMWindow::personalbar): Ditto.
     41        (WebCore::DOMWindow::scrollbars): Ditto.
     42        (WebCore::DOMWindow::statusbar): Ditto.
     43        (WebCore::DOMWindow::toolbar): Ditto.
     44        (WebCore::DOMWindow::applicationCache): Ditto.
     45        (WebCore::DOMWindow::sessionStorage): Use ExceptionOr.
     46        (WebCore::DOMWindow::localStorage): Ditto.
     47        (WebCore::DOMWindow::postMessage): Ditto.
     48        (WebCore::DOMWindow::frameElement): Use nullptr.
     49        (WebCore::DOMWindow::self): Ditto.
     50        (WebCore::DOMWindow::opener): Ditto.
     51        (WebCore::DOMWindow::parent): Ditto.
     52        (WebCore::DOMWindow::top): Ditto.
     53        (WebCore::DOMWindow::getComputedStyle): Use Ref.
     54        (WebCore::DOMWindow::setTimeout): Use ExceptionOr.
     55        (WebCore::DOMWindow::setInterval): Ditto.
     56        (WebCore::didAddStorageEventListener): Use a reference instead of a
     57        pointer, and ignore return value instead of using IGNORE_EXCEPTION.
     58        (WebCore::DOMWindow::addEventListener): Pass reference to function above.
     59        (WebCore::DOMWindow::dispatchEvent): Use enum class version of PageStatus.
     60        * page/DOMWindow.h: Updated for changes above. Also changed indentatation.
     61        * page/DOMWindow.idl: Use non-legacy exceptions.
     62
     63        * page/EventSource.cpp:
     64        (WebCore::EventSource::create): Use ExceptionOr.
     65        * page/EventSource.h: Updated for change above.
     66        * page/EventSource.idl: Use non-legacy exception.
     67
     68        * page/Location.cpp:
     69        (WebCore::Location::setProtocol): Use ExceptionOr.
     70        * page/Location.h: Updated for change above.
     71        * page/Location.idl: Use non-legacy exception.
     72
     73        * page/Performance.cpp:
     74        (WebCore::Performance::Performance): Remove unnecessary initialization of
     75        smart pointer to null, and moved initialization of m_resourceTimingBufferSize
     76        to the header.
     77        (WebCore::Performance::navigation): Made non-const and return a reference.
     78        (WebCore::Performance::timing): Ditto.
     79        (WebCore::Performance::addResourceTiming): Change LoadTiming argument to use
     80        a const& instead of passing in a copy.
     81        (WebCore::Performance::webkitMark): Use ExceptionOr and make_unique.
     82        (WebCore::Performance::webkitClearMarks): Ditto.
     83        (WebCore::Performance::webkitMeasure): Ditto.
     84        (WebCore::Performance::webkitClearMeasures): Ditto.
     85        (WebCore::Performance::reduceTimeResolution): Use std::floor.
     86        * page/Performance.h: Updated for above changes. Removed unneeded includes.
     87        Made more things private. Removed unneeded reference counting of UserTiming.
     88        * page/Performance.idl: Use non-legacy exceptions.
     89
     90        * page/PerformanceUserTiming.cpp:
     91        (WebCore::restrictedMarkFunction): Removed unneeded class name.
     92        (WebCore::UserTiming::UserTiming): Take a reference instead of a pointer.
     93        (WebCore::UserTiming::mark): Use ExceptionOr.
     94        (WebCore::UserTiming::findExistingMarkStartTime): Ditto.
     95        (WebCore::UserTiming::measure): Ditto.
     96        (WebCore::getEntrySequenceByName): Simplified code using HashMap::get.
     97        * page/PerformanceUserTiming.h: Updated for above changes. Removed reference
     98        counting since this is a single-owner object.
     99
     100        * page/UserMessageHandler.cpp:
     101        (WebCore::UserMessageHandler::postMessage): Use ExceptionOr.
     102        * page/UserMessageHandler.h: Updated for above change.
     103        * page/UserMessageHandler.idl: Use non-legacy exception.
     104
     105        * storage/Storage.cpp:
     106        (WebCore::Storage::length): Use ExceptionOr.
     107        (WebCore::Storage::key): Ditto.
     108        (WebCore::Storage::getItem): Ditto.
     109        (WebCore::Storage::setItem): Ditto.
     110        (WebCore::Storage::removeItem): Ditto.
     111        (WebCore::Storage::clear): Ditto.
     112        (WebCore::Storage::contains): Ditto.
     113        * storage/Storage.h: Updated for above change.
     114        * storage/Storage.idl: Use non-legacy exceptions.
     115
     116        * storage/StorageEventDispatcher.cpp:
     117        (WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames):
     118        Updated for ExceptionOr.
     119        (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames): Ditto.
     120
    11212016-10-18  Darin Adler  <darin@apple.com>
    2122
  • trunk/Source/WebCore/bindings/js/JSCryptoCustom.cpp

    r205198 r207522  
    4646
    4747    JSValue buffer = state.argument(0);
    48     RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(buffer);
     48    auto arrayBufferView = toArrayBufferView(buffer);
    4949    if (!arrayBufferView)
    5050        return throwTypeError(&state, scope);
    5151
    52     ExceptionCode ec = 0;
    53     wrapped().getRandomValues(arrayBufferView.get(), ec);
    54 
    55     if (ec) {
    56         setDOMException(&state, ec);
    57         return jsUndefined();
    58     }
     52    propagateException(state, scope, wrapped().getRandomValues(*arrayBufferView));
    5953
    6054    return buffer;
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r207505 r207522  
    527527
    528528    auto message = SerializedScriptValue::create(state, state.uncheckedArgument(0), messagePorts, WTFMove(arrayBuffers));
    529 
    530529    RETURN_IF_EXCEPTION(scope, JSValue());
    531530
     
    533532    RETURN_IF_EXCEPTION(scope, JSValue());
    534533
    535     ExceptionCode ec = 0;
    536     impl.postMessage(WTFMove(message), WTFMove(messagePorts), targetOrigin, callerDOMWindow(&state), ec);
    537     setDOMException(&state, ec);
     534    propagateException(state, scope, impl.postMessage(message.releaseNonNull(), WTFMove(messagePorts), targetOrigin, callerDOMWindow(&state)));
    538535
    539536    return jsUndefined();
     
    553550        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    554551
    555     ContentSecurityPolicy* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
    556     std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
    557     RETURN_IF_EXCEPTION(scope, JSValue());
    558 
     552    auto* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
     553    auto action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
     554    RETURN_IF_EXCEPTION(scope, JSValue());
    559555    if (!action)
    560556        return jsNumber(0);
    561557
    562558    int delay = state.argument(1).toInt32(&state);
    563 
    564     ExceptionCode ec = 0;
    565     int result = wrapped().setTimeout(WTFMove(action), delay, ec);
    566     setDOMException(&state, ec);
    567 
    568     return jsNumber(result);
     559    return toJSNumber(state, scope, wrapped().setTimeout(WTFMove(action), delay));
    569560}
    570561
     
    577568        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    578569
    579     ContentSecurityPolicy* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
    580     std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
    581     RETURN_IF_EXCEPTION(scope, JSValue());
    582     int delay = state.argument(1).toInt32(&state);
    583 
     570    auto* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
     571    auto action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
     572    RETURN_IF_EXCEPTION(scope, JSValue());
    584573    if (!action)
    585574        return jsNumber(0);
    586575
    587     ExceptionCode ec = 0;
    588     int result = wrapped().setInterval(WTFMove(action), delay, ec);
    589     setDOMException(&state, ec);
    590 
    591     return jsNumber(result);
     576    int delay = state.argument(1).toInt32(&state);
     577    return toJSNumber(state, scope, wrapped().setInterval(WTFMove(action), delay));
    592578}
    593579
  • trunk/Source/WebCore/bindings/js/JSStorageCustom.cpp

    r206386 r207522  
    3636namespace WebCore {
    3737
    38 bool JSStorage::nameGetter(ExecState* exec, PropertyName propertyName, JSValue& value)
     38bool JSStorage::nameGetter(ExecState* state, PropertyName propertyName, JSValue& value)
    3939{
    4040    if (propertyName.isSymbol())
    4141        return false;
    4242
    43     ExceptionCode ec = 0;
    44     String item = wrapped().getItem(propertyNameToString(propertyName), ec);
    45     setDOMException(exec, ec);
     43    auto item = wrapped().getItem(propertyNameToString(propertyName));
     44    if (item.hasException())
     45        propagateException(*state, item.releaseException());
    4646
    47     if (item.isNull())
     47    auto string = item.releaseReturnValue();
     48    if (string.isNull())
    4849        return false;
    4950
    50     value = jsStringWithCache(exec, item);
     51    value = jsStringWithCache(state, string);
    5152    return true;
    5253}
    5354
    54 bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
     55bool JSStorage::deleteProperty(JSCell* cell, ExecState* state, PropertyName propertyName)
    5556{
    56     JSStorage* thisObject = jsCast<JSStorage*>(cell);
     57    auto& thisObject = *jsCast<JSStorage*>(cell);
     58
    5759    // Only perform the custom delete if the object doesn't have a native property by this name.
    5860    // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
    5961    // the native property slots manually.
    60     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
     62    PropertySlot slot(&thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
    6163
    62     JSValue prototype = thisObject->getPrototypeDirect();
    63     if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
    64         return Base::deleteProperty(thisObject, exec, propertyName);
     64    JSValue prototype = thisObject.getPrototypeDirect();
     65    if (prototype.isObject() && asObject(prototype)->getPropertySlot(state, propertyName, slot))
     66        return Base::deleteProperty(&thisObject, state, propertyName);
    6567
    6668    if (propertyName.isSymbol())
    67         return Base::deleteProperty(thisObject, exec, propertyName);
     69        return Base::deleteProperty(&thisObject, state, propertyName);
    6870
    69     ExceptionCode ec = 0;
    70     thisObject->wrapped().removeItem(propertyNameToString(propertyName), ec);
    71     setDOMException(exec, ec);
     71    VM& vm = state->vm();
     72    auto scope = DECLARE_THROW_SCOPE(vm);
     73    propagateException(*state, scope, thisObject.wrapped().removeItem(propertyNameToString(propertyName)));
    7274    return true;
    7375}
     
    7880}
    7981
    80 void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     82void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
    8183{
    82     VM& vm = exec->vm();
     84    VM& vm = state->vm();
    8385    auto scope = DECLARE_THROW_SCOPE(vm);
    8486
    85     JSStorage* thisObject = jsCast<JSStorage*>(object);
    86     ExceptionCode ec = 0;
    87     unsigned length = thisObject->wrapped().length(ec);
    88     setDOMException(exec, ec);
    89     RETURN_IF_EXCEPTION(scope, void());
     87    auto& thisObject = *jsCast<JSStorage*>(object);
     88    auto lengthResult = thisObject.wrapped().length();
     89    if (lengthResult.hasException()) {
     90        propagateException(*state, scope, lengthResult.releaseException());
     91        return;
     92    }
     93    unsigned length = lengthResult.releaseReturnValue();
    9094    for (unsigned i = 0; i < length; ++i) {
    91         propertyNames.add(Identifier::fromString(exec, thisObject->wrapped().key(i, ec)));
    92         setDOMException(exec, ec);
    93         RETURN_IF_EXCEPTION(scope, void());
     95        auto keyResult = thisObject.wrapped().key(i);
     96        if (keyResult.hasException()) {
     97            propagateException(*state, scope, lengthResult.releaseException());
     98            return;
     99        }
     100        propertyNames.add(Identifier::fromString(state, keyResult.releaseReturnValue()));
    94101    }
    95102       
    96     Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
     103    Base::getOwnPropertyNames(&thisObject, state, propertyNames, mode);
    97104}
    98105
    99 bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult)
     106bool JSStorage::putDelegate(ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult)
    100107{
    101     VM& vm = exec->vm();
     108    VM& vm = state->vm();
    102109    auto scope = DECLARE_THROW_SCOPE(vm);
    103110
     
    108115
    109116    JSValue prototype = this->getPrototypeDirect();
    110     if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
     117    if (prototype.isObject() && asObject(prototype)->getPropertySlot(state, propertyName, slot))
    111118        return false;
    112119
     
    114121        return false;
    115122
    116     String stringValue = value.toString(exec)->value(exec);
     123    String stringValue = value.toString(state)->value(state);
    117124    if (UNLIKELY(scope.exception())) {
    118125        // The return value indicates whether putDelegate() should handle the put operation (which
     
    124131    }
    125132
    126     ExceptionCode ec = 0;
    127     wrapped().setItem(propertyNameToString(propertyName), stringValue, ec);
    128     setDOMException(exec, ec);
    129     putResult = !ec;
     133    auto setItemResult = wrapped().setItem(propertyNameToString(propertyName), stringValue);
     134    putResult = !setItemResult.hasException();
     135    propagateException(*state, scope, WTFMove(setItemResult));
    130136    return true;
    131137}
  • trunk/Source/WebCore/loader/appcache/DOMApplicationCache.cpp

    r192848 r207522  
    8383}
    8484
    85 void DOMApplicationCache::update(ExceptionCode& ec)
     85ExceptionOr<void> DOMApplicationCache::update()
    8686{
    87     ApplicationCacheHost* cacheHost = applicationCacheHost();
     87    auto* cacheHost = applicationCacheHost();
    8888    if (!cacheHost || !cacheHost->update())
    89         ec = INVALID_STATE_ERR;
     89        return Exception { INVALID_STATE_ERR };
     90    return { };
    9091}
    9192
    92 void DOMApplicationCache::swapCache(ExceptionCode& ec)
     93ExceptionOr<void> DOMApplicationCache::swapCache()
    9394{
    94     ApplicationCacheHost* cacheHost = applicationCacheHost();
     95    auto* cacheHost = applicationCacheHost();
    9596    if (!cacheHost || !cacheHost->swapCache())
    96         ec = INVALID_STATE_ERR;
     97        return Exception { INVALID_STATE_ERR };
     98    return { };
    9799}
    98100
  • trunk/Source/WebCore/loader/appcache/DOMApplicationCache.h

    r204466 r207522  
    2424 */
    2525
    26 #ifndef DOMApplicationCache_h
    27 #define DOMApplicationCache_h
     26#pragma once
    2827
    2928#include "ApplicationCacheHost.h"
    3029#include "DOMWindowProperty.h"
    3130#include "EventTarget.h"
     31#include "ExceptionOr.h"
    3232#include "ScriptWrappable.h"
    33 #include <wtf/Forward.h>
    3433#include <wtf/HashMap.h>
    35 #include <wtf/RefCounted.h>
    3634#include <wtf/text/AtomicStringHash.h>
    3735
     
    5149
    5250    unsigned short status() const;
    53     void update(ExceptionCode&);
    54     void swapCache(ExceptionCode&);
     51    ExceptionOr<void> update();
     52    ExceptionOr<void> swapCache();
    5553    void abort();
    5654
     
    7371
    7472} // namespace WebCore
    75 
    76 #endif // DOMApplicationCache_h
  • trunk/Source/WebCore/loader/appcache/DOMApplicationCache.idl

    r206723 r207522  
    3838    readonly attribute unsigned short status;
    3939
    40     [MayThrowLegacyException] void update();
    41     [MayThrowLegacyException] void swapCache();
     40    [MayThrowException] void update();
     41    [MayThrowException] void swapCache();
    4242    void abort();
    4343
  • trunk/Source/WebCore/page/Crypto.cpp

    r206883 r207522  
    5353}
    5454
    55 void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
     55ExceptionOr<void> Crypto::getRandomValues(ArrayBufferView& array)
    5656{
    57     if (!array || !JSC::isInt(array->getType())) {
    58         ec = TYPE_MISMATCH_ERR;
    59         return;
    60     }
    61     if (array->byteLength() > 65536) {
    62         ec = QUOTA_EXCEEDED_ERR;
    63         return;
    64     }
    65     cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
     57    if (!isInt(array.getType()))
     58        return Exception { TYPE_MISMATCH_ERR };
     59    if (array.byteLength() > 65536)
     60        return Exception { QUOTA_EXCEEDED_ERR };
     61    cryptographicallyRandomValues(array.baseAddress(), array.byteLength());
     62    return { };
    6663}
    6764
    6865#if ENABLE(SUBTLE_CRYPTO)
     66
    6967SubtleCrypto& Crypto::subtle()
    7068{
     
    7270}
    7371
    74 WebKitSubtleCrypto* Crypto::webkitSubtle(ExceptionCode& ec)
     72ExceptionOr<WebKitSubtleCrypto*> Crypto::webkitSubtle()
    7573{
    76     if (!isMainThread()) {
    77         ec = NOT_SUPPORTED_ERR;
    78         return 0;
    79     }
     74    if (!isMainThread())
     75        return Exception { NOT_SUPPORTED_ERR };
    8076
    8177    if (!m_webkitSubtle)
     
    8480    return m_webkitSubtle.get();
    8581}
     82
    8683#endif
    8784
  • trunk/Source/WebCore/page/Crypto.h

    r206883 r207522  
    2828 */
    2929
    30 #ifndef Crypto_h
    31 #define Crypto_h
     30#pragma once
    3231
    3332#include "ContextDestructionObserver.h"
    34 #include <wtf/Forward.h>
    35 #include <wtf/RefCounted.h>
    36 #include <wtf/RefPtr.h>
     33#include "ExceptionOr.h"
    3734
    3835namespace JSC {
     
    4239namespace WebCore {
    4340
    44 typedef int ExceptionCode;
    45 
    46 class Document;
     41class SubtleCrypto;
    4742class WebKitSubtleCrypto;
    48 class SubtleCrypto;
    4943
    5044class Crypto : public ContextDestructionObserver, public RefCounted<Crypto> {
     
    5347    virtual ~Crypto();
    5448
    55     void getRandomValues(JSC::ArrayBufferView*, ExceptionCode&);
     49    ExceptionOr<void> getRandomValues(JSC::ArrayBufferView&);
    5650
    5751#if ENABLE(SUBTLE_CRYPTO)
     
    5953
    6054    // Will be deprecated.
    61     WebKitSubtleCrypto* webkitSubtle(ExceptionCode&);
     55    ExceptionOr<WebKitSubtleCrypto*> webkitSubtle();
    6256#endif
    6357
     
    7468
    7569}
    76 
    77 #endif
  • trunk/Source/WebCore/page/Crypto.idl

    r206883 r207522  
    3333] interface Crypto {
    3434    [Conditional=SUBTLE_CRYPTO] readonly attribute SubtleCrypto subtle;
    35     [Custom, MayThrowLegacyException] ArrayBufferView getRandomValues(ArrayBufferView array);
     35    [Custom, MayThrowException] ArrayBufferView getRandomValues(ArrayBufferView array);
    3636
    3737    // Will be deprecated.
    38     [Conditional=SUBTLE_CRYPTO, GetterMayThrowLegacyException] readonly attribute WebKitSubtleCrypto webkitSubtle;
     38    [Conditional=SUBTLE_CRYPTO, GetterMayThrowException] readonly attribute WebKitSubtleCrypto webkitSubtle;
    3939};
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r207505 r207522  
    407407    : ContextDestructionObserver(document)
    408408    , FrameDestructionObserver(document->frame())
    409     , m_shouldPrintWhenFinishedLoading(false)
    410     , m_suspendedForDocumentSuspension(false)
    411     , m_lastPageStatus(PageStatusNone)
    412409    , m_weakPtrFactory(this)
    413 #if PLATFORM(IOS)
    414     , m_scrollEventListenerCount(0)
    415 #endif
    416 #if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
    417     , m_touchEventListenerCount(0)
    418 #endif
    419 #if ENABLE(GAMEPAD)
    420     , m_gamepadEventListenerCount(0)
    421 #endif
    422410{
    423411    ASSERT(frame());
     
    489477Page* DOMWindow::page()
    490478{
    491     return frame() ? frame()->page() : 0;
     479    return frame() ? frame()->page() : nullptr;
    492480}
    493481
     
    538526
    539527#if ENABLE(GAMEPAD)
     528
    540529void DOMWindow::incrementGamepadEventListenerCount()
    541530{
     
    551540        GamepadManager::singleton().unregisterDOMWindow(this);
    552541}
     542
    553543#endif
    554544
     
    636626
    637627#if ENABLE(CUSTOM_ELEMENTS)
     628
    638629CustomElementRegistry& DOMWindow::ensureCustomElementRegistry()
    639630{
     
    642633    return *m_customElementRegistry;
    643634}
     635
    644636#endif
    645637
    646638#if ENABLE(ORIENTATION_EVENTS)
     639
    647640int DOMWindow::orientation() const
    648641{
     
    652645    return m_frame->orientation();
    653646}
     647
    654648#endif
    655649
     
    657651{
    658652    if (!isCurrentlyDisplayedInFrame())
    659         return 0;
     653        return nullptr;
    660654    if (!m_screen)
    661655        m_screen = Screen::create(m_frame);
     
    676670    // FIXME: Why is crypto not available when the window is not currently displayed in a frame?
    677671    if (!isCurrentlyDisplayedInFrame())
    678         return 0;
     672        return nullptr;
    679673    if (!m_crypto)
    680674        m_crypto = Crypto::create(*document());
     
    685679{
    686680    if (!isCurrentlyDisplayedInFrame())
    687         return 0;
     681        return nullptr;
    688682    if (!m_locationbar)
    689683        m_locationbar = BarProp::create(m_frame, BarProp::Locationbar);
     
    694688{
    695689    if (!isCurrentlyDisplayedInFrame())
    696         return 0;
     690        return nullptr;
    697691    if (!m_menubar)
    698692        m_menubar = BarProp::create(m_frame, BarProp::Menubar);
     
    703697{
    704698    if (!isCurrentlyDisplayedInFrame())
    705         return 0;
     699        return nullptr;
    706700    if (!m_personalbar)
    707701        m_personalbar = BarProp::create(m_frame, BarProp::Personalbar);
     
    712706{
    713707    if (!isCurrentlyDisplayedInFrame())
    714         return 0;
     708        return nullptr;
    715709    if (!m_scrollbars)
    716710        m_scrollbars = BarProp::create(m_frame, BarProp::Scrollbars);
     
    721715{
    722716    if (!isCurrentlyDisplayedInFrame())
    723         return 0;
     717        return nullptr;
    724718    if (!m_statusbar)
    725719        m_statusbar = BarProp::create(m_frame, BarProp::Statusbar);
     
    730724{
    731725    if (!isCurrentlyDisplayedInFrame())
    732         return 0;
     726        return nullptr;
    733727    if (!m_toolbar)
    734728        m_toolbar = BarProp::create(m_frame, BarProp::Toolbar);
     
    746740{
    747741    if (!isCurrentlyDisplayedInFrame())
    748         return 0;
     742        return nullptr;
    749743    if (!m_applicationCache)
    750744        m_applicationCache = DOMApplicationCache::create(m_frame);
     
    762756
    763757#if ENABLE(WEB_TIMING)
     758
    764759Performance* DOMWindow::performance() const
    765760{
     
    770765    return m_performance.get();
    771766}
     767
    772768#endif
    773769
     
    791787
    792788#if ENABLE(USER_MESSAGE_HANDLERS)
     789
    793790bool DOMWindow::shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld& world)
    794791{
     
    822819    return m_webkitNamespace.get();
    823820}
    824 #endif
    825 
    826 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const
    827 {
    828     if (!isCurrentlyDisplayedInFrame())
    829         return 0;
    830 
    831     Document* document = this->document();
     821
     822#endif
     823
     824ExceptionOr<Storage*> DOMWindow::sessionStorage() const
     825{
     826    if (!isCurrentlyDisplayedInFrame())
     827        return nullptr;
     828
     829    auto* document = this->document();
    832830    if (!document)
    833         return 0;
    834 
    835     if (!document->securityOrigin()->canAccessSessionStorage(document->topOrigin())) {
    836         ec = SECURITY_ERR;
    837         return 0;
    838     }
     831        return nullptr;
     832
     833    if (!document->securityOrigin()->canAccessSessionStorage(document->topOrigin()))
     834        return Exception { SECURITY_ERR };
    839835
    840836    if (m_sessionStorage) {
    841         if (!m_sessionStorage->area().canAccessStorage(m_frame)) {
    842             ec = SECURITY_ERR;
    843             return 0;
    844         }
     837        if (!m_sessionStorage->area().canAccessStorage(m_frame))
     838        return Exception { SECURITY_ERR };
    845839        return m_sessionStorage.get();
    846840    }
    847841
    848     Page* page = document->page();
     842    auto* page = document->page();
    849843    if (!page)
    850         return 0;
     844        return nullptr;
    851845
    852846    auto storageArea = page->sessionStorage()->storageArea(document->securityOrigin());
    853     if (!storageArea->canAccessStorage(m_frame)) {
    854         ec = SECURITY_ERR;
    855         return 0;
    856     }
     847    if (!storageArea->canAccessStorage(m_frame))
     848        return Exception { SECURITY_ERR };
    857849
    858850    m_sessionStorage = Storage::create(m_frame, WTFMove(storageArea));
     
    860852}
    861853
    862 Storage* DOMWindow::localStorage(ExceptionCode& ec) const
    863 {
    864     if (!isCurrentlyDisplayedInFrame())
    865         return nullptr;
    866 
    867     Document* document = this->document();
     854ExceptionOr<Storage*> DOMWindow::localStorage() const
     855{
     856    if (!isCurrentlyDisplayedInFrame())
     857        return nullptr;
     858
     859    auto* document = this->document();
    868860    if (!document)
    869861        return nullptr;
    870862
    871     if (!document->securityOrigin()->canAccessLocalStorage(nullptr)) {
    872         ec = SECURITY_ERR;
    873         return nullptr;
    874     }
    875 
    876     Page* page = document->page();
     863    if (!document->securityOrigin()->canAccessLocalStorage(nullptr))
     864        return Exception { SECURITY_ERR };
     865
     866    auto* page = document->page();
    877867    // FIXME: We should consider supporting access/modification to local storage
    878868    // after calling window.close(). See <https://bugs.webkit.org/show_bug.cgi?id=135330>.
    879869    if (!page || !page->isClosing()) {
    880870        if (m_localStorage) {
    881             if (!m_localStorage->area().canAccessStorage(m_frame)) {
    882                 ec = SECURITY_ERR;
    883                 return nullptr;
    884             }
     871            if (!m_localStorage->area().canAccessStorage(m_frame))
     872                return Exception { SECURITY_ERR };
    885873            return m_localStorage.get();
    886874        }
     
    898886    auto storageArea = page->storageNamespaceProvider().localStorageArea(*document);
    899887
    900     if (!storageArea->canAccessStorage(m_frame)) {
    901         ec = SECURITY_ERR;
    902         return nullptr;
    903     }
     888    if (!storageArea->canAccessStorage(m_frame))
     889        return Exception { SECURITY_ERR };
    904890
    905891    m_localStorage = Storage::create(m_frame, WTFMove(storageArea));
     
    907893}
    908894
    909 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&& ports, const String& targetOrigin, DOMWindow& source, ExceptionCode& ec)
    910 {
    911     if (!isCurrentlyDisplayedInFrame())
    912         return;
     895ExceptionOr<void> DOMWindow::postMessage(Ref<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&& ports, const String& targetOrigin, DOMWindow& source)
     896{
     897    if (!isCurrentlyDisplayedInFrame())
     898        return { };
    913899
    914900    Document* sourceDocument = source.document();
     
    919905    if (targetOrigin == "/") {
    920906        if (!sourceDocument)
    921             return;
     907            return { };
    922908        target = sourceDocument->securityOrigin();
    923909    } else if (targetOrigin != "*") {
     
    925911        // It doesn't make sense target a postMessage at a unique origin
    926912        // because there's no way to represent a unique origin in a string.
    927         if (target->isUnique()) {
    928             ec = SYNTAX_ERR;
    929             return;
    930         }
    931     }
    932 
     913        if (target->isUnique())
     914            return Exception { SYNTAX_ERR };
     915    }
     916
     917    ExceptionCode ec = 0;
    933918    auto channels = MessagePort::disentanglePorts(WTFMove(ports), ec);
    934919    if (ec)
    935         return;
     920        return Exception { ec };
    936921
    937922    // Capture the source of the message.  We need to do this synchronously
    938923    // in order to capture the source of the message correctly.
    939924    if (!sourceDocument)
    940         return;
    941     String sourceOrigin = sourceDocument->securityOrigin()->toString();
     925        return { };
     926    auto sourceOrigin = sourceDocument->securityOrigin()->toString();
    942927
    943928    // Capture stack trace only when inspector front-end is loaded as it may be time consuming.
     
    947932
    948933    // Schedule the message.
    949     PostMessageTimer* timer = new PostMessageTimer(*this, message, sourceOrigin, source, WTFMove(channels), WTFMove(target), WTFMove(stackTrace));
     934    auto* timer = new PostMessageTimer(*this, PassRefPtr<SerializedScriptValue> { WTFMove(message) }, sourceOrigin, source, WTFMove(channels), WTFMove(target), WTFMove(stackTrace));
    950935    timer->startOneShot(0);
     936
     937    return { };
    951938}
    952939
     
    987974{
    988975    if (!m_frame)
    989         return 0;
     976        return nullptr;
    990977
    991978    return m_frame->ownerElement();
     
    13621349{
    13631350    if (!m_frame)
    1364         return 0;
     1351        return nullptr;
    13651352
    13661353    return m_frame->document()->domWindow();
     
    13701357{
    13711358    if (!m_frame)
    1372         return 0;
     1359        return nullptr;
    13731360
    13741361    Frame* opener = m_frame->loader().opener();
    13751362    if (!opener)
    1376         return 0;
     1363        return nullptr;
    13771364
    13781365    return opener->document()->domWindow();
     
    13821369{
    13831370    if (!m_frame)
    1384         return 0;
     1371        return nullptr;
    13851372
    13861373    Frame* parent = m_frame->tree().parent();
     
    13941381{
    13951382    if (!m_frame)
    1396         return 0;
     1383        return nullptr;
    13971384
    13981385    Page* page = m_frame->page();
    13991386    if (!page)
    1400         return 0;
     1387        return nullptr;
    14011388
    14021389    return m_frame->tree().top().document()->domWindow();
     
    14181405}
    14191406
    1420 RefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element& element, const String& pseudoElt) const
     1407Ref<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element& element, const String& pseudoElt) const
    14211408{
    14221409    return CSSComputedStyleDeclaration::create(element, false, pseudoElt);
     
    14241411
    14251412// FIXME: Drop this overload once <rdar://problem/28016778> has been fixed.
    1426 RefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Document&, const String&, ExceptionCode& ec)
     1413ExceptionOr<RefPtr<CSSStyleDeclaration>> DOMWindow::getComputedStyle(Document&, const String&)
    14271414{
    14281415#if PLATFORM(MAC)
     
    14321419    }
    14331420#endif
    1434     ec = TypeError;
    1435     return nullptr;
     1421    return Exception { TypeError };
    14361422}
    14371423
     
    16321618}
    16331619
    1634 int DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout, ExceptionCode& ec)
    1635 {
    1636     ScriptExecutionContext* context = scriptExecutionContext();
    1637     if (!context) {
    1638         ec = INVALID_ACCESS_ERR;
    1639         return -1;
    1640     }
     1620ExceptionOr<int> DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
     1621{
     1622    auto* context = scriptExecutionContext();
     1623    if (!context)
     1624        return ExceptionCode { INVALID_ACCESS_ERR };
    16411625    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), true);
    16421626}
     
    16661650}
    16671651
    1668 int DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout, ExceptionCode& ec)
    1669 {
    1670     ScriptExecutionContext* context = scriptExecutionContext();
    1671     if (!context) {
    1672         ec = INVALID_ACCESS_ERR;
    1673         return -1;
    1674     }
     1652ExceptionOr<int> DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
     1653{
     1654    auto* context = scriptExecutionContext();
     1655    if (!context)
     1656        return ExceptionCode { INVALID_ACCESS_ERR };
    16751657    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), false);
    16761658}
     
    16851667
    16861668#if ENABLE(REQUEST_ANIMATION_FRAME)
     1669
    16871670int DOMWindow::requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback)
    16881671{
     
    17061689        d->cancelAnimationFrame(id);
    17071690}
    1708 #endif
    1709 
    1710 static void didAddStorageEventListener(DOMWindow* window)
     1691
     1692#endif
     1693
     1694static void didAddStorageEventListener(DOMWindow& window)
    17111695{
    17121696    // Creating these WebCore::Storage objects informs the system that we'd like to receive
     
    17141698    // than subscribe to these notifications explicitly, we subscribe to them implicitly to
    17151699    // simplify the work done by the system.
    1716     window->localStorage(IGNORE_EXCEPTION);
    1717     window->sessionStorage(IGNORE_EXCEPTION);
     1700    window.localStorage();
     1701    window.sessionStorage();
    17181702}
    17191703
     
    17461730            document->didAddTouchEventHandler(*document);
    17471731        else if (eventType == eventNames().storageEvent)
    1748             didAddStorageEventListener(this);
     1732            didAddStorageEventListener(*this);
    17491733    }
    17501734
     
    18071791
    18081792#if PLATFORM(IOS)
     1793
    18091794void DOMWindow::incrementScrollEventListenersCount()
    18101795{
     
    18261811    }
    18271812}
     1813
    18281814#endif
    18291815
     
    19391925    if (event.eventInterface() == PageTransitionEventInterfaceType) {
    19401926        if (event.type() == eventNames().pageshowEvent) {
    1941             if (m_lastPageStatus == PageStatusShown)
     1927            if (m_lastPageStatus == PageStatus::Shown)
    19421928                return true; // Event was previously dispatched; do not fire a duplicate event.
    1943             m_lastPageStatus = PageStatusShown;
     1929            m_lastPageStatus = PageStatus::Shown;
    19441930        } else if (event.type() == eventNames().pagehideEvent) {
    1945             if (m_lastPageStatus == PageStatusHidden)
     1931            if (m_lastPageStatus == PageStatus::Hidden)
    19461932                return true; // Event was previously dispatched; do not fire a duplicate event.
    1947             m_lastPageStatus = PageStatusHidden;
     1933            m_lastPageStatus = PageStatus::Hidden;
    19481934        }
    19491935    }
  • trunk/Source/WebCore/page/DOMWindow.h

    r207505 r207522  
    3030#include "ContextDestructionObserver.h"
    3131#include "EventTarget.h"
     32#include "ExceptionOr.h"
    3233#include "FrameDestructionObserver.h"
    3334#include "ScrollToOptions.h"
     
    4647namespace WebCore {
    4748
    48     class BarProp;
    49     class CSSRuleList;
    50     class CSSStyleDeclaration;
    51     class Crypto;
    52     class CustomElementRegistry;
    53     class DOMApplicationCache;
    54     class DOMSelection;
    55     class DOMURL;
    56     class DOMWindowProperty;
    57     class DOMWrapperWorld;
    58     class Database;
    59     class DatabaseCallback;
    60     class Document;
    61     class Element;
    62     class EventListener;
    63     class FloatRect;
    64     class Frame;
    65     class History;
    66     class IDBFactory;
    67     class Location;
    68     class MediaQueryList;
    69     class MessageEvent;
    70     class Navigator;
    71     class Node;
    72     class Page;
    73     class PageConsoleClient;
    74     class Performance;
    75     class PostMessageTimer;
    76     class ScheduledAction;
    77     class Screen;
    78     class SecurityOrigin;
    79     class SerializedScriptValue;
    80     class Storage;
    81     class StyleMedia;
    82     class WebKitNamespace;
    83     class WebKitPoint;
    84 
     49class BarProp;
     50class CSSRuleList;
     51class CSSStyleDeclaration;
     52class Crypto;
     53class CustomElementRegistry;
     54class DOMApplicationCache;
     55class DOMSelection;
     56class DOMURL;
     57class DOMWindowProperty;
     58class DOMWrapperWorld;
     59class Database;
     60class DatabaseCallback;
     61class Document;
     62class Element;
     63class EventListener;
     64class FloatRect;
     65class Frame;
     66class History;
     67class IDBFactory;
     68class Location;
     69class MediaQueryList;
     70class MessageEvent;
     71class Navigator;
     72class Node;
     73class Page;
     74class PageConsoleClient;
     75class Performance;
     76class PostMessageTimer;
     77class RequestAnimationFrameCallback;
     78class ScheduledAction;
     79class Screen;
     80class SecurityOrigin;
     81class SerializedScriptValue;
     82class Storage;
     83class StyleMedia;
     84class WebKitNamespace;
     85class WebKitPoint;
     86
     87struct WindowFeatures;
     88
     89enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
     90
     91// FIXME: DOMWindow shouldn't subclass FrameDestructionObserver and instead should get to Frame via its Document.
     92class DOMWindow final
     93    : public RefCounted<DOMWindow>
     94    , public EventTargetWithInlineData
     95    , public ContextDestructionObserver
     96    , public FrameDestructionObserver
     97    , public Base64Utilities
     98    , public Supplementable<DOMWindow> {
     99public:
     100    static Ref<DOMWindow> create(Document* document) { return adoptRef(*new DOMWindow(document)); }
     101    WEBCORE_EXPORT virtual ~DOMWindow();
     102
     103    // In some rare cases, we'll reuse a DOMWindow for a new Document. For example,
     104    // when a script calls window.open("..."), the browser gives JavaScript a window
     105    // synchronously but kicks off the load in the window asynchronously. Web sites
     106    // expect that modifications that they make to the window object synchronously
     107    // won't be blown away when the network load commits. To make that happen, we
     108    // "securely transition" the existing DOMWindow to the Document that results from
     109    // the network load. See also SecurityContext::isSecureTransitionTo.
     110    void didSecureTransitionTo(Document*);
     111
     112    EventTargetInterface eventTargetInterface() const override { return DOMWindowEventTargetInterfaceType; }
     113    ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); }
     114
     115    DOMWindow* toDOMWindow() override;
     116
     117    void registerProperty(DOMWindowProperty*);
     118    void unregisterProperty(DOMWindowProperty*);
     119
     120    void resetUnlessSuspendedForDocumentSuspension();
     121    void suspendForDocumentSuspension();
     122    void resumeFromDocumentSuspension();
     123
     124    RefPtr<MediaQueryList> matchMedia(const String&);
     125
     126    WEBCORE_EXPORT unsigned pendingUnloadEventListeners() const;
     127
     128    WEBCORE_EXPORT static bool dispatchAllPendingBeforeUnloadEvents();
     129    WEBCORE_EXPORT static void dispatchAllPendingUnloadEvents();
     130
     131    static FloatRect adjustWindowRect(Page*, const FloatRect& pendingChanges);
     132
     133    bool allowPopUp(); // Call on first window, not target window.
     134    static bool allowPopUp(Frame* firstFrame);
     135    static bool canShowModalDialog(const Frame*);
     136    WEBCORE_EXPORT void setCanShowModalDialogOverride(bool);
     137
     138    Screen* screen() const;
     139    History* history() const;
     140    Crypto* crypto() const;
     141    BarProp* locationbar() const;
     142    BarProp* menubar() const;
     143    BarProp* personalbar() const;
     144    BarProp* scrollbars() const;
     145    BarProp* statusbar() const;
     146    BarProp* toolbar() const;
     147    Navigator* navigator() const;
     148    Navigator* clientInformation() const { return navigator(); }
     149
     150    Location* location() const;
     151    void setLocation(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& location, SetLocationLocking = LockHistoryBasedOnGestureState);
     152
     153    DOMSelection* getSelection();
     154
     155    Element* frameElement() const;
     156
     157    WEBCORE_EXPORT void focus(bool allowFocus = false);
     158    void focus(DOMWindow& callerWindow);
     159    void blur();
     160    WEBCORE_EXPORT void close();
     161    void close(Document&);
     162    void print();
     163    void stop();
     164
     165    WEBCORE_EXPORT RefPtr<DOMWindow> open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow);
     166
     167    void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, std::function<void(DOMWindow&)> prepareDialogFunction);
     168
     169    void alert(const String& message = emptyString());
     170    bool confirm(const String& message);
     171    String prompt(const String& message, const String& defaultValue);
     172
     173    bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
     174
     175    bool offscreenBuffering() const;
     176
     177    int outerHeight() const;
     178    int outerWidth() const;
     179    int innerHeight() const;
     180    int innerWidth() const;
     181    int screenX() const;
     182    int screenY() const;
     183    int screenLeft() const { return screenX(); }
     184    int screenTop() const { return screenY(); }
     185    int scrollX() const;
     186    int scrollY() const;
     187
     188    bool closed() const;
     189
     190    unsigned length() const;
     191
     192    String name() const;
     193    void setName(const String&);
     194
     195    String status() const;
     196    void setStatus(const String&);
     197    String defaultStatus() const;
     198    void setDefaultStatus(const String&);
     199
     200    // Self-referential attributes
     201
     202    DOMWindow* self() const;
     203    DOMWindow* window() const { return self(); }
     204    DOMWindow* frames() const { return self(); }
     205
     206    DOMWindow* opener() const;
     207    DOMWindow* parent() const;
     208    DOMWindow* top() const;
     209
     210    // DOM Level 2 AbstractView Interface
     211
     212    WEBCORE_EXPORT Document* document() const;
     213
     214    // CSSOM View Module
     215
     216    RefPtr<StyleMedia> styleMedia() const;
     217
     218    // DOM Level 2 Style Interface
     219
     220    WEBCORE_EXPORT Ref<CSSStyleDeclaration> getComputedStyle(Element&, const String& pseudoElt) const;
     221    ExceptionOr<RefPtr<CSSStyleDeclaration>> getComputedStyle(Document&, const String& pseudoElt);
     222
     223    // WebKit extensions
     224
     225    WEBCORE_EXPORT RefPtr<CSSRuleList> getMatchedCSSRules(Element*, const String& pseudoElt, bool authorOnly = true) const;
     226    double devicePixelRatio() const;
     227
     228    RefPtr<WebKitPoint> webkitConvertPointFromPageToNode(Node*, const WebKitPoint*) const;
     229    RefPtr<WebKitPoint> webkitConvertPointFromNodeToPage(Node*, const WebKitPoint*) const;
     230
     231    PageConsoleClient* console() const;
     232
     233    void printErrorMessage(const String&);
     234    String crossDomainAccessErrorMessage(const DOMWindow& activeWindow);
     235
     236    ExceptionOr<void> postMessage(Ref<SerializedScriptValue>&& message, Vector<RefPtr<MessagePort>>&&, const String& targetOrigin, DOMWindow& source);
     237    void postMessageTimerFired(PostMessageTimer&);
     238    void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>);
     239
     240    void languagesChanged();
     241
     242    void scrollBy(const ScrollToOptions&) const;
     243    void scrollBy(double x, double y) const;
     244    void scrollTo(const ScrollToOptions&) const;
     245    void scrollTo(double x, double y) const;
     246
     247    void moveBy(float x, float y) const;
     248    void moveTo(float x, float y) const;
     249
     250    void resizeBy(float x, float y) const;
     251    void resizeTo(float width, float height) const;
     252
     253    // Timers
     254    ExceptionOr<int> setTimeout(std::unique_ptr<ScheduledAction>, int timeout);
     255    void clearTimeout(int timeoutId);
     256    ExceptionOr<int> setInterval(std::unique_ptr<ScheduledAction>, int timeout);
     257    void clearInterval(int timeoutId);
     258
     259    // WebKit animation extensions
    85260#if ENABLE(REQUEST_ANIMATION_FRAME)
    86     class RequestAnimationFrameCallback;
    87 #endif
    88 
    89     struct WindowFeatures;
    90 
    91     typedef int ExceptionCode;
    92 
    93     enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
    94 
    95     // FIXME: DOMWindow shouldn't subclass FrameDestructionObserver and instead should get to Frame via its Document.
    96     class DOMWindow final
    97         : public RefCounted<DOMWindow>
    98         , public EventTargetWithInlineData
    99         , public ContextDestructionObserver
    100         , public FrameDestructionObserver
    101         , public Base64Utilities
    102         , public Supplementable<DOMWindow> {
    103     public:
    104         static Ref<DOMWindow> create(Document* document) { return adoptRef(*new DOMWindow(document)); }
    105         WEBCORE_EXPORT virtual ~DOMWindow();
    106 
    107         // In some rare cases, we'll re-used a DOMWindow for a new Document. For example,
    108         // when a script calls window.open("..."), the browser gives JavaScript a window
    109         // synchronously but kicks off the load in the window asynchronously. Web sites
    110         // expect that modifications that they make to the window object synchronously
    111         // won't be blown away when the network load commits. To make that happen, we
    112         // "securely transition" the existing DOMWindow to the Document that results from
    113         // the network load. See also SecurityContext::isSecureTransitionTo.
    114         void didSecureTransitionTo(Document*);
    115 
    116         EventTargetInterface eventTargetInterface() const override { return DOMWindowEventTargetInterfaceType; }
    117         ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); }
    118 
    119         DOMWindow* toDOMWindow() override;
    120 
    121         void registerProperty(DOMWindowProperty*);
    122         void unregisterProperty(DOMWindowProperty*);
    123 
    124         void resetUnlessSuspendedForDocumentSuspension();
    125         void suspendForDocumentSuspension();
    126         void resumeFromDocumentSuspension();
    127 
    128         RefPtr<MediaQueryList> matchMedia(const String&);
    129 
    130         WEBCORE_EXPORT unsigned pendingUnloadEventListeners() const;
    131 
    132         WEBCORE_EXPORT static bool dispatchAllPendingBeforeUnloadEvents();
    133         WEBCORE_EXPORT static void dispatchAllPendingUnloadEvents();
    134 
    135         static FloatRect adjustWindowRect(Page*, const FloatRect& pendingChanges);
    136 
    137         bool allowPopUp(); // Call on first window, not target window.
    138         static bool allowPopUp(Frame* firstFrame);
    139         static bool canShowModalDialog(const Frame*);
    140         WEBCORE_EXPORT void setCanShowModalDialogOverride(bool);
    141 
    142         Screen* screen() const;
    143         History* history() const;
    144         Crypto* crypto() const;
    145         BarProp* locationbar() const;
    146         BarProp* menubar() const;
    147         BarProp* personalbar() const;
    148         BarProp* scrollbars() const;
    149         BarProp* statusbar() const;
    150         BarProp* toolbar() const;
    151         Navigator* navigator() const;
    152         Navigator* clientInformation() const { return navigator(); }
    153 
    154         Location* location() const;
    155         void setLocation(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& location,
    156             SetLocationLocking = LockHistoryBasedOnGestureState);
    157 
    158         DOMSelection* getSelection();
    159 
    160         Element* frameElement() const;
    161 
    162         WEBCORE_EXPORT void focus(bool allowFocus = false);
    163         void focus(DOMWindow& callerWindow);
    164         void blur();
    165         WEBCORE_EXPORT void close();
    166         void close(Document&);
    167         void print();
    168         void stop();
    169 
    170         WEBCORE_EXPORT RefPtr<DOMWindow> open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString,
    171             DOMWindow& activeWindow, DOMWindow& firstWindow);
    172 
    173         void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, std::function<void (DOMWindow&)> prepareDialogFunction);
    174 
    175         void alert(const String& message = emptyString());
    176         bool confirm(const String& message);
    177         String prompt(const String& message, const String& defaultValue);
    178 
    179         bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
    180 
    181         bool offscreenBuffering() const;
    182 
    183         int outerHeight() const;
    184         int outerWidth() const;
    185         int innerHeight() const;
    186         int innerWidth() const;
    187         int screenX() const;
    188         int screenY() const;
    189         int screenLeft() const { return screenX(); }
    190         int screenTop() const { return screenY(); }
    191         int scrollX() const;
    192         int scrollY() const;
    193 
    194         bool closed() const;
    195 
    196         unsigned length() const;
    197 
    198         String name() const;
    199         void setName(const String&);
    200 
    201         String status() const;
    202         void setStatus(const String&);
    203         String defaultStatus() const;
    204         void setDefaultStatus(const String&);
    205 
    206         // Self-referential attributes
    207 
    208         DOMWindow* self() const;
    209         DOMWindow* window() const { return self(); }
    210         DOMWindow* frames() const { return self(); }
    211 
    212         DOMWindow* opener() const;
    213         DOMWindow* parent() const;
    214         DOMWindow* top() const;
    215 
    216         // DOM Level 2 AbstractView Interface
    217 
    218         WEBCORE_EXPORT Document* document() const;
    219 
    220         // CSSOM View Module
    221 
    222         RefPtr<StyleMedia> styleMedia() const;
    223 
    224         // DOM Level 2 Style Interface
    225 
    226         WEBCORE_EXPORT RefPtr<CSSStyleDeclaration> getComputedStyle(Element&, const String& pseudoElt) const;
    227         RefPtr<CSSStyleDeclaration> getComputedStyle(Document&, const String& pseudoElt, ExceptionCode&);
    228 
    229         // WebKit extensions
    230 
    231         WEBCORE_EXPORT RefPtr<CSSRuleList> getMatchedCSSRules(Element*, const String& pseudoElt, bool authorOnly = true) const;
    232         double devicePixelRatio() const;
    233 
    234         RefPtr<WebKitPoint> webkitConvertPointFromPageToNode(Node*, const WebKitPoint*) const;
    235         RefPtr<WebKitPoint> webkitConvertPointFromNodeToPage(Node*, const WebKitPoint*) const;
    236 
    237         PageConsoleClient* console() const;
    238 
    239         void printErrorMessage(const String&);
    240         String crossDomainAccessErrorMessage(const DOMWindow& activeWindow);
    241 
    242         void postMessage(PassRefPtr<SerializedScriptValue> message, Vector<RefPtr<MessagePort>>&&, const String& targetOrigin, DOMWindow& source, ExceptionCode&);
    243         void postMessageTimerFired(PostMessageTimer&);
    244         void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>);
    245 
    246         void languagesChanged();
    247 
    248         void scrollBy(const ScrollToOptions&) const;
    249         void scrollBy(double x, double y) const;
    250         void scrollTo(const ScrollToOptions&) const;
    251         void scrollTo(double x, double y) const;
    252 
    253         void moveBy(float x, float y) const;
    254         void moveTo(float x, float y) const;
    255 
    256         void resizeBy(float x, float y) const;
    257         void resizeTo(float width, float height) const;
    258 
    259         // Timers
    260         int setTimeout(std::unique_ptr<ScheduledAction>, int timeout, ExceptionCode&);
    261         void clearTimeout(int timeoutId);
    262         int setInterval(std::unique_ptr<ScheduledAction>, int timeout, ExceptionCode&);
    263         void clearInterval(int timeoutId);
    264 
    265         // WebKit animation extensions
    266 #if ENABLE(REQUEST_ANIMATION_FRAME)
    267         int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
    268         int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
    269         void cancelAnimationFrame(int id);
    270 #endif
    271 
    272         // Events
    273         // EventTarget API
    274         bool addEventListener(const AtomicString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
    275         bool removeEventListener(const AtomicString& eventType, EventListener&, const ListenerOptions&) override;
    276         void removeAllEventListeners() override;
    277 
    278         using EventTarget::dispatchEvent;
    279         bool dispatchEvent(Event&, EventTarget*);
    280 
    281         void dispatchLoadEvent();
    282 
    283         void captureEvents();
    284         void releaseEvents();
    285 
    286         void finishedLoading();
    287 
    288         using RefCounted<DOMWindow>::ref;
    289         using RefCounted<DOMWindow>::deref;
    290 
    291         // HTML 5 key/value storage
    292         Storage* sessionStorage(ExceptionCode&) const;
    293         Storage* localStorage(ExceptionCode&) const;
    294         Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
    295         Storage* optionalLocalStorage() const { return m_localStorage.get(); }
    296 
    297         DOMApplicationCache* applicationCache() const;
    298         DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); }
     261    int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
     262    int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
     263    void cancelAnimationFrame(int id);
     264#endif
     265
     266    // Events
     267    // EventTarget API
     268    bool addEventListener(const AtomicString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
     269    bool removeEventListener(const AtomicString& eventType, EventListener&, const ListenerOptions&) override;
     270    void removeAllEventListeners() override;
     271
     272    using EventTarget::dispatchEvent;
     273    bool dispatchEvent(Event&, EventTarget*);
     274
     275    void dispatchLoadEvent();
     276
     277    void captureEvents();
     278    void releaseEvents();
     279
     280    void finishedLoading();
     281
     282    using RefCounted<DOMWindow>::ref;
     283    using RefCounted<DOMWindow>::deref;
     284
     285    // HTML 5 key/value storage
     286    ExceptionOr<Storage*> sessionStorage() const;
     287    ExceptionOr<Storage*> localStorage() const;
     288    Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
     289    Storage* optionalLocalStorage() const { return m_localStorage.get(); }
     290
     291    DOMApplicationCache* applicationCache() const;
     292    DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); }
    299293
    300294#if ENABLE(CUSTOM_ELEMENTS)
    301         CustomElementRegistry* customElementRegistry() { return m_customElementRegistry.get(); }
    302         CustomElementRegistry& ensureCustomElementRegistry();
     295    CustomElementRegistry* customElementRegistry() { return m_customElementRegistry.get(); }
     296    CustomElementRegistry& ensureCustomElementRegistry();
    303297#endif
    304298
    305299#if ENABLE(ORIENTATION_EVENTS)
    306         // This is the interface orientation in degrees. Some examples are:
    307         //  0 is straight up; -90 is when the device is rotated 90 clockwise;
    308         //  90 is when rotated counter clockwise.
    309         int orientation() const;
     300    // This is the interface orientation in degrees. Some examples are:
     301    //  0 is straight up; -90 is when the device is rotated 90 clockwise;
     302    //  90 is when rotated counter clockwise.
     303    int orientation() const;
    310304#endif
    311305
    312306#if ENABLE(WEB_TIMING)
    313         Performance* performance() const;
    314 #endif
    315         double nowTimestamp() const;
     307    Performance* performance() const;
     308#endif
     309    double nowTimestamp() const;
    316310
    317311#if PLATFORM(IOS)
    318         void incrementScrollEventListenersCount();
    319         void decrementScrollEventListenersCount();
    320         unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; }
    321 #endif
    322 
    323         void resetAllGeolocationPermission();
     312    void incrementScrollEventListenersCount();
     313    void decrementScrollEventListenersCount();
     314    unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; }
     315#endif
     316
     317    void resetAllGeolocationPermission();
    324318
    325319#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
    326         bool hasTouchEventListeners() const { return m_touchEventListenerCount > 0; }
     320    bool hasTouchEventListeners() const { return m_touchEventListenerCount > 0; }
    327321#endif
    328322
    329323#if ENABLE(USER_MESSAGE_HANDLERS)
    330         bool shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld&);
    331         WebKitNamespace* webkitNamespace() const;
    332 #endif
    333 
    334         // FIXME: When this DOMWindow is no longer the active DOMWindow (i.e.,
    335         // when its document is no longer the document that is displayed in its
    336         // frame), we would like to zero out m_frame to avoid being confused
    337         // by the document that is currently active in m_frame.
    338         bool isCurrentlyDisplayedInFrame() const;
    339 
    340         void willDetachDocumentFromFrame();
    341         void willDestroyCachedFrame();
    342 
    343         void enableSuddenTermination();
    344         void disableSuddenTermination();
    345 
    346         WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
    347 
    348     private:
    349         explicit DOMWindow(Document*);
    350 
    351         Page* page();
    352         bool allowedToChangeWindowGeometry() const;
    353 
    354         void frameDestroyed() override;
    355         void willDetachPage() override;
    356 
    357         void refEventTarget() override { ref(); }
    358         void derefEventTarget() override { deref(); }
    359 
    360         static RefPtr<Frame> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, std::function<void (DOMWindow&)> prepareDialogFunction = nullptr);
    361         bool isInsecureScriptAccess(DOMWindow& activeWindow, const String& urlString);
    362 
    363         void resetDOMWindowProperties();
    364         void disconnectDOMWindowProperties();
    365         void reconnectDOMWindowProperties();
    366         void willDestroyDocumentInFrame();
    367 
    368         bool isSameSecurityOriginAsMainFrame() const;
     324    bool shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld&);
     325    WebKitNamespace* webkitNamespace() const;
     326#endif
     327
     328    // FIXME: When this DOMWindow is no longer the active DOMWindow (i.e.,
     329    // when its document is no longer the document that is displayed in its
     330    // frame), we would like to zero out m_frame to avoid being confused
     331    // by the document that is currently active in m_frame.
     332    bool isCurrentlyDisplayedInFrame() const;
     333
     334    void willDetachDocumentFromFrame();
     335    void willDestroyCachedFrame();
     336
     337    void enableSuddenTermination();
     338    void disableSuddenTermination();
     339
     340    WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
     341
     342private:
     343    explicit DOMWindow(Document*);
     344
     345    Page* page();
     346    bool allowedToChangeWindowGeometry() const;
     347
     348    void frameDestroyed() override;
     349    void willDetachPage() override;
     350
     351    void refEventTarget() override { ref(); }
     352    void derefEventTarget() override { deref(); }
     353
     354    static RefPtr<Frame> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, std::function<void(DOMWindow&)> prepareDialogFunction = nullptr);
     355    bool isInsecureScriptAccess(DOMWindow& activeWindow, const String& urlString);
     356
     357    void resetDOMWindowProperties();
     358    void disconnectDOMWindowProperties();
     359    void reconnectDOMWindowProperties();
     360    void willDestroyDocumentInFrame();
     361
     362    bool isSameSecurityOriginAsMainFrame() const;
    369363
    370364#if ENABLE(GAMEPAD)
    371         void incrementGamepadEventListenerCount();
    372         void decrementGamepadEventListenerCount();
    373 #endif
    374 
    375         bool m_shouldPrintWhenFinishedLoading;
    376         bool m_suspendedForDocumentSuspension;
    377         Optional<bool> m_canShowModalDialogOverride;
    378 
    379         HashSet<DOMWindowProperty*> m_properties;
    380 
    381         mutable RefPtr<Crypto> m_crypto;
    382         mutable RefPtr<History> m_history;
    383         mutable RefPtr<BarProp> m_locationbar;
    384         mutable RefPtr<StyleMedia> m_media;
    385         mutable RefPtr<BarProp> m_menubar;
    386         mutable RefPtr<Navigator> m_navigator;
    387         mutable RefPtr<BarProp> m_personalbar;
    388         mutable RefPtr<Screen> m_screen;
    389         mutable RefPtr<BarProp> m_scrollbars;
    390         mutable RefPtr<DOMSelection> m_selection;
    391         mutable RefPtr<BarProp> m_statusbar;
    392         mutable RefPtr<BarProp> m_toolbar;
    393         mutable RefPtr<Location> m_location;
    394 
    395         String m_status;
    396         String m_defaultStatus;
    397 
    398         enum PageStatus { PageStatusNone, PageStatusShown, PageStatusHidden };
    399         PageStatus m_lastPageStatus;
    400 
    401         WeakPtrFactory<DOMWindow> m_weakPtrFactory;
     365    void incrementGamepadEventListenerCount();
     366    void decrementGamepadEventListenerCount();
     367#endif
     368
     369    bool m_shouldPrintWhenFinishedLoading { false };
     370    bool m_suspendedForDocumentSuspension { false };
     371    Optional<bool> m_canShowModalDialogOverride;
     372
     373    HashSet<DOMWindowProperty*> m_properties;
     374
     375    mutable RefPtr<Crypto> m_crypto;
     376    mutable RefPtr<History> m_history;
     377    mutable RefPtr<BarProp> m_locationbar;
     378    mutable RefPtr<StyleMedia> m_media;
     379    mutable RefPtr<BarProp> m_menubar;
     380    mutable RefPtr<Navigator> m_navigator;
     381    mutable RefPtr<BarProp> m_personalbar;
     382    mutable RefPtr<Screen> m_screen;
     383    mutable RefPtr<BarProp> m_scrollbars;
     384    mutable RefPtr<DOMSelection> m_selection;
     385    mutable RefPtr<BarProp> m_statusbar;
     386    mutable RefPtr<BarProp> m_toolbar;
     387    mutable RefPtr<Location> m_location;
     388
     389    String m_status;
     390    String m_defaultStatus;
     391
     392    enum class PageStatus { None, Shown, Hidden };
     393    PageStatus m_lastPageStatus { PageStatus::None };
     394
     395    WeakPtrFactory<DOMWindow> m_weakPtrFactory;
    402396
    403397#if PLATFORM(IOS)
    404         unsigned m_scrollEventListenerCount;
     398    unsigned m_scrollEventListenerCount { 0 };
    405399#endif
    406400
    407401#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
    408         unsigned m_touchEventListenerCount;
     402    unsigned m_touchEventListenerCount { 0 };
    409403#endif
    410404
    411405#if ENABLE(GAMEPAD)
    412         unsigned m_gamepadEventListenerCount;
    413 #endif
    414         mutable RefPtr<Storage> m_sessionStorage;
    415         mutable RefPtr<Storage> m_localStorage;
    416         mutable RefPtr<DOMApplicationCache> m_applicationCache;
     406    unsigned m_gamepadEventListenerCount { 0 };
     407#endif
     408
     409    mutable RefPtr<Storage> m_sessionStorage;
     410    mutable RefPtr<Storage> m_localStorage;
     411    mutable RefPtr<DOMApplicationCache> m_applicationCache;
    417412
    418413#if ENABLE(CUSTOM_ELEMENTS)
    419         RefPtr<CustomElementRegistry> m_customElementRegistry;
     414    RefPtr<CustomElementRegistry> m_customElementRegistry;
    420415#endif
    421416
    422417#if ENABLE(WEB_TIMING)
    423         mutable RefPtr<Performance> m_performance;
     418    mutable RefPtr<Performance> m_performance;
    424419#endif
    425420
    426421#if ENABLE(USER_MESSAGE_HANDLERS)
    427         mutable RefPtr<WebKitNamespace> m_webkitNamespace;
    428 #endif
    429     };
    430 
    431     inline String DOMWindow::status() const
    432     {
    433         return m_status;
    434     }
    435 
    436     inline String DOMWindow::defaultStatus() const
    437     {
    438         return m_defaultStatus;
    439     }
     422    mutable RefPtr<WebKitNamespace> m_webkitNamespace;
     423#endif
     424};
     425
     426inline String DOMWindow::status() const
     427{
     428    return m_status;
     429}
     430
     431inline String DOMWindow::defaultStatus() const
     432{
     433    return m_defaultStatus;
     434}
    440435
    441436} // namespace WebCore
  • trunk/Source/WebCore/page/DOMWindow.idl

    r207384 r207522  
    134134
    135135    // FIXME: Drop the following overload of getComputedStyle once <rdar://problem/28020681> has been fixed.
    136     [NewObject, MayThrowLegacyException] CSSStyleDeclaration getComputedStyle(Document document, optional DOMString? pseudoElement = null);
     136    [NewObject, MayThrowException] CSSStyleDeclaration? getComputedStyle(Document document, optional DOMString? pseudoElement = null);
    137137
    138138    CSSRuleList getMatchedCSSRules(optional Element? element = null, optional DOMString? pseudoElement = null);
     
    145145    readonly attribute DOMApplicationCache applicationCache;
    146146
    147     [GetterMayThrowLegacyException] readonly attribute Storage sessionStorage;
    148     [GetterMayThrowLegacyException] readonly attribute Storage localStorage;
     147    [GetterMayThrowException] readonly attribute Storage sessionStorage;
     148    [GetterMayThrowException] readonly attribute Storage localStorage;
    149149
    150150    // This is the interface orientation in degrees. Some examples:
     
    152152    [Conditional=ORIENTATION_EVENTS] readonly attribute long orientation;
    153153
    154     [DoNotCheckSecurity, Custom, MayThrowLegacyException, ForwardDeclareInHeader] void postMessage(SerializedScriptValue message, USVString targetOrigin, optional Array messagePorts);
     154    [DoNotCheckSecurity, Custom, MayThrowException, ForwardDeclareInHeader] void postMessage(SerializedScriptValue message, USVString targetOrigin, optional Array messagePorts);
    155155
    156156    [Conditional=WEB_TIMING, Replaceable] readonly attribute Performance performance;
  • trunk/Source/WebCore/page/EventSource.cpp

    r207086 r207522  
    5959}
    6060
    61 RefPtr<EventSource> EventSource::create(ScriptExecutionContext& context, const String& url, const Init& eventSourceInit, ExceptionCode& ec)
    62 {
    63     if (url.isEmpty()) {
    64         ec = SYNTAX_ERR;
    65         return nullptr;
    66     }
     61ExceptionOr<Ref<EventSource>> EventSource::create(ScriptExecutionContext& context, const String& url, const Init& eventSourceInit)
     62{
     63    if (url.isEmpty())
     64        return Exception { SYNTAX_ERR };
    6765
    6866    URL fullURL = context.completeURL(url);
    69     if (!fullURL.isValid()) {
    70         ec = SYNTAX_ERR;
    71         return nullptr;
    72     }
    73 
    74     // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
     67    if (!fullURL.isValid())
     68        return Exception { SYNTAX_ERR };
     69
     70    // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is resolved.
    7571    if (!context.shouldBypassMainWorldContentSecurityPolicy() && !context.contentSecurityPolicy()->allowConnectToSource(fullURL)) {
    7672        // FIXME: Should this be throwing an exception?
    77         ec = SECURITY_ERR;
    78         return nullptr;
     73        return Exception { SECURITY_ERR };
    7974    }
    8075
  • trunk/Source/WebCore/page/EventSource.h

    r202542 r207522  
    3434#include "ActiveDOMObject.h"
    3535#include "EventTarget.h"
     36#include "ExceptionOr.h"
    3637#include "URL.h"
    3738#include "ThreadableLoaderClient.h"
     
    5152        bool withCredentials;
    5253    };
    53     static RefPtr<EventSource> create(ScriptExecutionContext&, const String& url, const Init&, ExceptionCode&);
     54    static ExceptionOr<Ref<EventSource>> create(ScriptExecutionContext&, const String& url, const Init&);
    5455    virtual ~EventSource();
    5556
     
    5758    bool withCredentials() const;
    5859
    59     typedef short State;
     60    using State = short;
    6061    static const State CONNECTING = 0;
    6162    static const State OPEN = 1;
  • trunk/Source/WebCore/page/EventSource.idl

    r206723 r207522  
    3535    Constructor(USVString url, optional EventSourceInit eventSourceInitDict),
    3636    ConstructorCallWith=ScriptExecutionContext,
    37     ConstructorMayThrowLegacyException,
     37    ConstructorMayThrowException,
    3838] interface EventSource : EventTarget {
    3939    readonly attribute USVString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
  • trunk/Source/WebCore/page/Location.cpp

    r204679 r207522  
    159159}
    160160
    161 void Location::setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& protocol, ExceptionCode& ec)
    162 {
    163     if (!m_frame)
    164         return;
    165     URL url = m_frame->document()->url();
    166     if (!url.setProtocol(protocol)) {
    167         ec = SYNTAX_ERR;
    168         return;
    169     }
    170     setLocation(activeWindow, firstWindow, url.string());
     161ExceptionOr<void> Location::setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& protocol)
     162{
     163    if (!m_frame)
     164        return { };
     165    URL url = m_frame->document()->url();
     166    if (!url.setProtocol(protocol))
     167        return Exception { SYNTAX_ERR };
     168    setLocation(activeWindow, firstWindow, url.string());
     169    return { };
    171170}
    172171
  • trunk/Source/WebCore/page/Location.h

    r204679 r207522  
    2727 */
    2828
    29 #ifndef Location_h
    30 #define Location_h
     29#pragma once
    3130
    3231#include "DOMStringList.h"
    3332#include "DOMWindowProperty.h"
     33#include "ExceptionOr.h"
    3434#include "ScriptWrappable.h"
    35 #include <wtf/RefCounted.h>
    36 #include <wtf/text/WTFString.h>
    3735
    3836namespace WebCore {
     
    5553    void reload(DOMWindow& activeWindow);
    5654
    57     void setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String&, ExceptionCode&);
     55    ExceptionOr<void> setProtocol(DOMWindow& activeWindow, DOMWindow& firstWindow, const String&);
    5856    String protocol() const;
    5957    void setHost(DOMWindow& activeWindow, DOMWindow& firstWindow, const String&);
     
    8482
    8583} // namespace WebCore
    86 
    87 #endif // Location_h
  • trunk/Source/WebCore/page/Location.idl

    r207355 r207522  
    4949
    5050    // URI decomposition attributes
    51     [SetterCallWith=ActiveWindow&FirstWindow, SetterMayThrowLegacyException] attribute USVString protocol;
     51    [SetterCallWith=ActiveWindow&FirstWindow, SetterMayThrowException] attribute USVString protocol;
    5252    [SetterCallWith=ActiveWindow&FirstWindow] attribute USVString host;
    5353    [SetterCallWith=ActiveWindow&FirstWindow] attribute USVString hostname;
  • trunk/Source/WebCore/page/Performance.cpp

    r204976 r207522  
    3232
    3333#include "config.h"
     34#include "Performance.h"
    3435
    3536#if ENABLE(WEB_TIMING)
    36 #include "Performance.h"
    3737
    3838#include "Document.h"
     
    5050namespace WebCore {
    5151
    52 static const size_t defaultResourceTimingBufferSize = 150;
    53 
    5452Performance::Performance(Frame& frame)
    5553    : DOMWindowProperty(&frame)
    56     , m_resourceTimingBufferSize(defaultResourceTimingBufferSize)
    5754    , m_referenceTime(frame.document()->loader() ? frame.document()->loader()->timing().referenceMonotonicTime() : monotonicallyIncreasingTime())
    58 #if ENABLE(USER_TIMING)
    59     , m_userTiming(nullptr)
    60 #endif // ENABLE(USER_TIMING)
    6155{
    6256    ASSERT(m_referenceTime);
     
    7468}
    7569
    76 PerformanceNavigation* Performance::navigation() const
     70PerformanceNavigation& Performance::navigation()
    7771{
    7872    if (!m_navigation)
    7973        m_navigation = PerformanceNavigation::create(m_frame);
    80 
    81     return m_navigation.get();
    82 }
    83 
    84 PerformanceTiming* Performance::timing() const
     74    return *m_navigation;
     75}
     76
     77PerformanceTiming& Performance::timing()
    8578{
    8679    if (!m_timing)
    8780        m_timing = PerformanceTiming::create(m_frame);
    88 
    89     return m_timing.get();
     81    return *m_timing;
    9082}
    9183
     
    165157}
    166158
    167 void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const URL& originalURL, const ResourceResponse& response, LoadTiming loadTiming)
     159void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const URL& originalURL, const ResourceResponse& response, const LoadTiming& loadTiming)
    168160{
    169161    if (isResourceTimingBufferFull())
     
    184176
    185177#if ENABLE(USER_TIMING)
    186 void Performance::webkitMark(const String& markName, ExceptionCode& ec)
    187 {
    188     ec = 0;
    189     if (!m_userTiming)
    190         m_userTiming = UserTiming::create(this);
    191     m_userTiming->mark(markName, ec);
     178
     179ExceptionOr<void> Performance::webkitMark(const String& markName)
     180{
     181    if (!m_userTiming)
     182        m_userTiming = std::make_unique<UserTiming>(*this);
     183    return m_userTiming->mark(markName);
    192184}
    193185
     
    195187{
    196188    if (!m_userTiming)
    197         m_userTiming = UserTiming::create(this);
     189        m_userTiming = std::make_unique<UserTiming>(*this);
    198190    m_userTiming->clearMarks(markName);
    199191}
    200192
    201 void Performance::webkitMeasure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode& ec)
    202 {
    203     ec = 0;
    204     if (!m_userTiming)
    205         m_userTiming = UserTiming::create(this);
    206     m_userTiming->measure(measureName, startMark, endMark, ec);
     193ExceptionOr<void> Performance::webkitMeasure(const String& measureName, const String& startMark, const String& endMark)
     194{
     195    if (!m_userTiming)
     196        m_userTiming = std::make_unique<UserTiming>(*this);
     197    return m_userTiming->measure(measureName, startMark, endMark);
    207198}
    208199
     
    210201{
    211202    if (!m_userTiming)
    212         m_userTiming = UserTiming::create(this);
     203        m_userTiming = std::make_unique<UserTiming>(*this);
    213204    m_userTiming->clearMeasures(measureName);
    214205}
     
    225216{
    226217    const double resolutionSeconds = 0.000005;
    227     return floor(seconds / resolutionSeconds) * resolutionSeconds;
     218    return std::floor(seconds / resolutionSeconds) * resolutionSeconds;
    228219}
    229220
  • trunk/Source/WebCore/page/Performance.h

    r204976 r207522  
    3737#include "DOMWindowProperty.h"
    3838#include "EventTarget.h"
    39 #include "PerformanceNavigation.h"
    40 #include "PerformanceTiming.h"
    41 #include "ScriptWrappable.h"
    42 #include <wtf/RefCounted.h>
    43 #include <wtf/RefPtr.h>
    44 #include <wtf/text/WTFString.h>
     39#include "ExceptionOr.h"
    4540
    4641namespace WebCore {
     
    4944class LoadTiming;
    5045class PerformanceEntry;
    51 class ResourceRequest;
     46class PerformanceNavigation;
     47class PerformanceTiming;
    5248class ResourceResponse;
     49class URL;
    5350class UserTiming;
    54 class URL;
    5551
    5652class Performance final : public RefCounted<Performance>, public DOMWindowProperty, public EventTargetWithInlineData {
     
    5955    ~Performance();
    6056
    61     EventTargetInterface eventTargetInterface() const override { return PerformanceEventTargetInterfaceType; }
    62     ScriptExecutionContext* scriptExecutionContext() const override;
    63 
    64     PerformanceNavigation* navigation() const;
    65     PerformanceTiming* timing() const;
     57    PerformanceNavigation& navigation();
     58    PerformanceTiming& timing();
    6659    double now() const;
    6760
     
    7366    void setResourceTimingBufferSize(unsigned);
    7467
    75     void addResourceTiming(const String& initiatorName, Document*, const URL& originalURL, const ResourceResponse&, LoadTiming);
     68    void addResourceTiming(const String& initiatorName, Document*, const URL& originalURL, const ResourceResponse&, const LoadTiming&);
    7669
    77     using RefCounted<Performance>::ref;
    78     using RefCounted<Performance>::deref;
     70    using RefCounted::ref;
     71    using RefCounted::deref;
    7972
    8073#if ENABLE(USER_TIMING)
    81     void webkitMark(const String& markName, ExceptionCode&);
     74    ExceptionOr<void> webkitMark(const String& markName);
    8275    void webkitClearMarks(const String& markName);
    8376
    84     void webkitMeasure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode&);
     77    ExceptionOr<void> webkitMeasure(const String& measureName, const String& startMark, const String& endMark);
    8578    void webkitClearMeasures(const String& measureName);
    86 #endif // ENABLE(USER_TIMING)
     79#endif
    8780
    8881    static double reduceTimeResolution(double seconds);
     
    9184    explicit Performance(Frame&);
    9285
    93     void refEventTarget() override { ref(); }
    94     void derefEventTarget() override { deref(); }
     86    EventTargetInterface eventTargetInterface() const final { return PerformanceEventTargetInterfaceType; }
     87    ScriptExecutionContext* scriptExecutionContext() const final;
     88
     89    void refEventTarget() final { ref(); }
     90    void derefEventTarget() final { deref(); }
     91
    9592    bool isResourceTimingBufferFull();
    9693
     
    9895    mutable RefPtr<PerformanceTiming> m_timing;
    9996
     97    // https://w3c.github.io/resource-timing/#extensions-performance-interface recommends size of 150.
    10098    Vector<RefPtr<PerformanceEntry>> m_resourceTimingBuffer;
    101     unsigned m_resourceTimingBufferSize;
     99    unsigned m_resourceTimingBufferSize { 150 };
    102100
    103101    double m_referenceTime;
    104102
    105103#if ENABLE(USER_TIMING)
    106     RefPtr<UserTiming> m_userTiming;
    107 #endif // ENABLE(USER_TIMING)
     104    std::unique_ptr<UserTiming> m_userTiming;
     105#endif
    108106};
    109107
  • trunk/Source/WebCore/page/Performance.idl

    r206723 r207522  
    4242    [EnabledAtRuntime=ResourceTiming] PerformanceEntryList getEntriesByName(DOMString name, optional DOMString entryType);
    4343
    44 
    4544    [EnabledAtRuntime=ResourceTiming] void clearResourceTimings();
    4645    [EnabledAtRuntime=ResourceTiming] void setResourceTimingBufferSize(unsigned long maxSize);
     
    5049    // See http://www.w3.org/TR/2012/CR-user-timing-20120726/
    5150#if defined(ENABLE_USER_TIMING) && ENABLE_USER_TIMING
    52     [MayThrowLegacyException] void webkitMark(DOMString markName);
    53     void webkitClearMarks(optional  DOMString markName);
     51    [MayThrowException] void webkitMark(DOMString markName);
     52    void webkitClearMarks(optional DOMString markName);
    5453
    55     [MayThrowLegacyException] void webkitMeasure(DOMString measureName, optional DOMString startMark, optional DOMString endMark);
     54    [MayThrowException] void webkitMeasure(DOMString measureName, optional DOMString startMark, optional DOMString endMark);
    5655    void webkitClearMeasures(optional DOMString measureName);
    5756#endif
  • trunk/Source/WebCore/page/PerformanceUserTiming.cpp

    r194578 r207522  
    2929#if ENABLE(USER_TIMING)
    3030
     31#include "ExceptionCode.h"
    3132#include "Performance.h"
     33#include "PerformanceEntry.h"
    3234#include "PerformanceMark.h"
    3335#include "PerformanceMeasure.h"
     36#include <array>
    3437#include <wtf/NeverDestroyed.h>
    3538#include <wtf/dtoa/utils.h>
    36 #include <wtf/text/WTFString.h>
    3739
    3840namespace WebCore {
    3941
    4042namespace {
     43
     44typedef unsigned long long (PerformanceTiming::*NavigationTimingFunction)() const;
    4145
    4246static NavigationTimingFunction restrictedMarkFunction(const String& markName)
     
    4448    using MapPair = std::pair<ASCIILiteral, NavigationTimingFunction>;
    4549    static const std::array<MapPair, 21> pairs = { {
    46         MapPair{ ASCIILiteral("navigationStart"), &PerformanceTiming::navigationStart },
    47         MapPair{ ASCIILiteral("unloadEventStart"), &PerformanceTiming::unloadEventStart },
    48         MapPair{ ASCIILiteral("unloadEventEnd"), &PerformanceTiming::unloadEventEnd },
    49         MapPair{ ASCIILiteral("redirectStart"), &PerformanceTiming::redirectStart },
    50         MapPair{ ASCIILiteral("redirectEnd"), &PerformanceTiming::redirectEnd },
    51         MapPair{ ASCIILiteral("fetchStart"), &PerformanceTiming::fetchStart },
    52         MapPair{ ASCIILiteral("domainLookupStart"), &PerformanceTiming::domainLookupStart },
    53         MapPair{ ASCIILiteral("domainLookupEnd"), &PerformanceTiming::domainLookupEnd },
    54         MapPair{ ASCIILiteral("connectStart"), &PerformanceTiming::connectStart },
    55         MapPair{ ASCIILiteral("connectEnd"), &PerformanceTiming::connectEnd },
    56         MapPair{ ASCIILiteral("secureConnectionStart"), &PerformanceTiming::secureConnectionStart },
    57         MapPair{ ASCIILiteral("requestStart"), &PerformanceTiming::requestStart },
    58         MapPair{ ASCIILiteral("responseStart"), &PerformanceTiming::responseStart },
    59         MapPair{ ASCIILiteral("responseEnd"), &PerformanceTiming::responseEnd },
    60         MapPair{ ASCIILiteral("domLoading"), &PerformanceTiming::domLoading },
    61         MapPair{ ASCIILiteral("domInteractive"), &PerformanceTiming::domInteractive },
    62         MapPair{ ASCIILiteral("domContentLoadedEventStart"), &PerformanceTiming::domContentLoadedEventStart },
    63         MapPair{ ASCIILiteral("domContentLoadedEventEnd"), &PerformanceTiming::domContentLoadedEventEnd },
    64         MapPair{ ASCIILiteral("domComplete"), &PerformanceTiming::domComplete },
    65         MapPair{ ASCIILiteral("loadEventStart"), &PerformanceTiming::loadEventStart },
    66         MapPair{ ASCIILiteral("loadEventEnd"), &PerformanceTiming::loadEventEnd },
     50        { ASCIILiteral("navigationStart"), &PerformanceTiming::navigationStart },
     51        { ASCIILiteral("unloadEventStart"), &PerformanceTiming::unloadEventStart },
     52        { ASCIILiteral("unloadEventEnd"), &PerformanceTiming::unloadEventEnd },
     53        { ASCIILiteral("redirectStart"), &PerformanceTiming::redirectStart },
     54        { ASCIILiteral("redirectEnd"), &PerformanceTiming::redirectEnd },
     55        { ASCIILiteral("fetchStart"), &PerformanceTiming::fetchStart },
     56        { ASCIILiteral("domainLookupStart"), &PerformanceTiming::domainLookupStart },
     57        { ASCIILiteral("domainLookupEnd"), &PerformanceTiming::domainLookupEnd },
     58        { ASCIILiteral("connectStart"), &PerformanceTiming::connectStart },
     59        { ASCIILiteral("connectEnd"), &PerformanceTiming::connectEnd },
     60        { ASCIILiteral("secureConnectionStart"), &PerformanceTiming::secureConnectionStart },
     61        { ASCIILiteral("requestStart"), &PerformanceTiming::requestStart },
     62        { ASCIILiteral("responseStart"), &PerformanceTiming::responseStart },
     63        { ASCIILiteral("responseEnd"), &PerformanceTiming::responseEnd },
     64        { ASCIILiteral("domLoading"), &PerformanceTiming::domLoading },
     65        { ASCIILiteral("domInteractive"), &PerformanceTiming::domInteractive },
     66        { ASCIILiteral("domContentLoadedEventStart"), &PerformanceTiming::domContentLoadedEventStart },
     67        { ASCIILiteral("domContentLoadedEventEnd"), &PerformanceTiming::domContentLoadedEventEnd },
     68        { ASCIILiteral("domComplete"), &PerformanceTiming::domComplete },
     69        { ASCIILiteral("loadEventStart"), &PerformanceTiming::loadEventStart },
     70        { ASCIILiteral("loadEventEnd"), &PerformanceTiming::loadEventEnd },
    6771    } };
    6872
     
    7882} // namespace anonymous
    7983
    80 UserTiming::UserTiming(Performance* performance)
     84UserTiming::UserTiming(Performance& performance)
    8185    : m_performance(performance)
    8286{
     
    103107}
    104108
    105 void UserTiming::mark(const String& markName, ExceptionCode& ec)
    106 {
    107     ec = 0;
    108     if (restrictedMarkFunction(markName)) {
    109         ec = SYNTAX_ERR;
    110         return;
    111     }
    112 
    113     double startTime = m_performance->now();
    114     insertPerformanceEntry(m_marksMap, PerformanceMark::create(markName, startTime));
     109ExceptionOr<void> UserTiming::mark(const String& markName)
     110{
     111    if (restrictedMarkFunction(markName))
     112        return Exception { SYNTAX_ERR };
     113
     114    insertPerformanceEntry(m_marksMap, PerformanceMark::create(markName, m_performance.now()));
     115    return { };
    115116}
    116117
     
    120121}
    121122
    122 double UserTiming::findExistingMarkStartTime(const String& markName, ExceptionCode& ec)
    123 {
    124     ec = 0;
    125 
     123ExceptionOr<double> UserTiming::findExistingMarkStartTime(const String& markName)
     124{
    126125    if (m_marksMap.contains(markName))
    127126        return m_marksMap.get(markName).last()->startTime();
    128127
    129128    if (auto function = restrictedMarkFunction(markName)) {
    130         double value = static_cast<double>((m_performance->timing()->*(function))());
    131         if (!value) {
    132             ec = INVALID_ACCESS_ERR;
    133             return 0.0;
    134         }
    135         return value - m_performance->timing()->navigationStart();
    136     }
    137 
    138     ec = SYNTAX_ERR;
    139     return 0.0;
    140 }
    141 
    142 void UserTiming::measure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode& ec)
     129        double value = static_cast<double>((m_performance.timing().*(function))());
     130        if (!value)
     131            return Exception { INVALID_ACCESS_ERR };
     132        return value - m_performance.timing().navigationStart();
     133    }
     134
     135    return Exception { SYNTAX_ERR };
     136}
     137
     138ExceptionOr<void> UserTiming::measure(const String& measureName, const String& startMark, const String& endMark)
    143139{
    144140    double startTime = 0.0;
     
    146142
    147143    if (startMark.isNull())
    148         endTime = m_performance->now();
     144        endTime = m_performance.now();
    149145    else if (endMark.isNull()) {
    150         endTime = m_performance->now();
    151         startTime = findExistingMarkStartTime(startMark, ec);
    152         if (ec)
    153             return;
     146        endTime = m_performance.now();
     147        auto startMarkResult = findExistingMarkStartTime(startMark);
     148        if (startMarkResult.hasException())
     149            return startMarkResult.releaseException();
     150        endTime = startMarkResult.releaseReturnValue();
    154151    } else {
    155         endTime = findExistingMarkStartTime(endMark, ec);
    156         if (ec)
    157             return;
    158         startTime = findExistingMarkStartTime(startMark, ec);
    159         if (ec)
    160             return;
     152        auto endMarkResult = findExistingMarkStartTime(endMark);
     153        if (endMarkResult.hasException())
     154            return endMarkResult.releaseException();
     155        auto startMarkResult = findExistingMarkStartTime(startMark);
     156        if (startMarkResult.hasException())
     157            return startMarkResult.releaseException();
     158        startTime = startMarkResult.releaseReturnValue();
     159        endTime = endMarkResult.releaseReturnValue();
    161160    }
    162161
    163162    insertPerformanceEntry(m_measuresMap, PerformanceMeasure::create(measureName, startTime, endTime));
     163    return { };
    164164}
    165165
     
    169169}
    170170
    171 static Vector<RefPtr<PerformanceEntry> > convertToEntrySequence(const PerformanceEntryMap& performanceEntryMap)
    172 {
    173     Vector<RefPtr<PerformanceEntry> > entries;
    174 
     171static Vector<RefPtr<PerformanceEntry>> convertToEntrySequence(const PerformanceEntryMap& performanceEntryMap)
     172{
     173    Vector<RefPtr<PerformanceEntry>> entries;
    175174    for (auto& entry : performanceEntryMap.values())
    176175        entries.appendVector(entry);
    177 
    178176    return entries;
    179177}
    180178
    181 static Vector<RefPtr<PerformanceEntry> > getEntrySequenceByName(const PerformanceEntryMap& performanceEntryMap, const String& name)
    182 {
    183     Vector<RefPtr<PerformanceEntry> > entries;
    184 
    185     PerformanceEntryMap::const_iterator it = performanceEntryMap.find(name);
    186     if (it != performanceEntryMap.end())
    187         entries.appendVector(it->value);
    188 
    189     return entries;
    190 }
    191 
    192 Vector<RefPtr<PerformanceEntry> > UserTiming::getMarks() const
     179static Vector<RefPtr<PerformanceEntry>> getEntrySequenceByName(const PerformanceEntryMap& performanceEntryMap, const String& name)
     180{
     181    return performanceEntryMap.get(name);
     182}
     183
     184Vector<RefPtr<PerformanceEntry>> UserTiming::getMarks() const
    193185{
    194186    return convertToEntrySequence(m_marksMap);
    195187}
    196188
    197 Vector<RefPtr<PerformanceEntry> > UserTiming::getMarks(const String& name) const
     189Vector<RefPtr<PerformanceEntry>> UserTiming::getMarks(const String& name) const
    198190{
    199191    return getEntrySequenceByName(m_marksMap, name);
    200192}
    201193
    202 Vector<RefPtr<PerformanceEntry> > UserTiming::getMeasures() const
     194Vector<RefPtr<PerformanceEntry>> UserTiming::getMeasures() const
    203195{
    204196    return convertToEntrySequence(m_measuresMap);
    205197}
    206198
    207 Vector<RefPtr<PerformanceEntry> > UserTiming::getMeasures(const String& name) const
     199Vector<RefPtr<PerformanceEntry>> UserTiming::getMeasures(const String& name) const
    208200{
    209201    return getEntrySequenceByName(m_measuresMap, name);
  • trunk/Source/WebCore/page/PerformanceUserTiming.h

    r204466 r207522  
    2424 */
    2525
    26 #ifndef PerformanceUserTiming_h
    27 #define PerformanceUserTiming_h
     26#pragma once
    2827
    2928#if ENABLE(USER_TIMING)
    3029
    31 #include "ExceptionCode.h"
    32 #include "Performance.h"
    33 #include "PerformanceTiming.h"
     30#include "ExceptionOr.h"
    3431#include <wtf/HashMap.h>
    35 #include <wtf/RefCounted.h>
    3632#include <wtf/text/StringHash.h>
    37 #include <wtf/text/WTFString.h>
    3833
    3934namespace WebCore {
     
    4237class PerformanceEntry;
    4338
    44 typedef unsigned long long (PerformanceTiming::*NavigationTimingFunction)() const;
    45 typedef HashMap<String, Vector<RefPtr<PerformanceEntry> > > PerformanceEntryMap;
     39using PerformanceEntryMap = HashMap<String, Vector<RefPtr<PerformanceEntry>>>;
    4640
    47 class UserTiming : public RefCounted<UserTiming> {
     41class UserTiming {
    4842public:
    49     static Ref<UserTiming> create(Performance* performance) { return adoptRef(*new UserTiming(performance)); }
     43    explicit UserTiming(Performance&);
    5044
    51     void mark(const String& markName, ExceptionCode&);
     45    ExceptionOr<void> mark(const String& markName);
    5246    void clearMarks(const String& markName);
    5347
    54     void measure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode&);
     48    ExceptionOr<void> measure(const String& measureName, const String& startMark, const String& endMark);
    5549    void clearMeasures(const String& measureName);
    5650
    57     Vector<RefPtr<PerformanceEntry> > getMarks() const;
    58     Vector<RefPtr<PerformanceEntry> > getMeasures() const;
     51    Vector<RefPtr<PerformanceEntry>> getMarks() const;
     52    Vector<RefPtr<PerformanceEntry>> getMeasures() const;
    5953
    60     Vector<RefPtr<PerformanceEntry> > getMarks(const String& name) const;
    61     Vector<RefPtr<PerformanceEntry> > getMeasures(const String& name) const;
     54    Vector<RefPtr<PerformanceEntry>> getMarks(const String& name) const;
     55    Vector<RefPtr<PerformanceEntry>> getMeasures(const String& name) const;
    6256
    6357private:
    64     explicit UserTiming(Performance*);
     58    ExceptionOr<double> findExistingMarkStartTime(const String& markName);
    6559
    66     double findExistingMarkStartTime(const String& markName, ExceptionCode&);
    67     Performance* m_performance;
     60    Performance& m_performance;
    6861    PerformanceEntryMap m_marksMap;
    6962    PerformanceEntryMap m_measuresMap;
     
    7366
    7467#endif // ENABLE(USER_TIMING)
    75 
    76 #endif // !defined(PerformanceUserTiming_h)
  • trunk/Source/WebCore/page/UserMessageHandler.cpp

    r199020 r207522  
    4545}
    4646
    47 void UserMessageHandler::postMessage(PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec)
     47ExceptionOr<void> UserMessageHandler::postMessage(RefPtr<SerializedScriptValue>&& value)
    4848{
    4949    // Check to see if the descriptor has been removed. This can happen if the host application has
    5050    // removed the named message handler at the WebKit2 API level.
    51     if (!m_descriptor) {
    52         ec = INVALID_ACCESS_ERR;
    53         return;
    54     }
     51    if (!m_descriptor)
     52        return Exception { INVALID_ACCESS_ERR };
    5553
    5654    m_descriptor->didPostMessage(*this, value.get());
     55    return { };
    5756}
    5857
  • trunk/Source/WebCore/page/UserMessageHandler.h

    r199020 r207522  
    2424 */
    2525
    26 #ifndef UserMessageHandler_h
    27 #define UserMessageHandler_h
     26#pragma once
    2827
    2928#if ENABLE(USER_MESSAGE_HANDLERS)
    3029
     30#include "ExceptionOr.h"
    3131#include "FrameDestructionObserver.h"
    3232#include "UserMessageHandlerDescriptor.h"
    3333
    3434namespace WebCore {
    35 
    36 typedef int ExceptionCode;
    3735
    3836class UserMessageHandler : public RefCounted<UserMessageHandler>, public FrameDestructionObserver {
     
    4442    virtual ~UserMessageHandler();
    4543
    46     void postMessage(PassRefPtr<SerializedScriptValue>, ExceptionCode&);
     44    ExceptionOr<void> postMessage(RefPtr<SerializedScriptValue>&&);
    4745
    4846    UserMessageHandlerDescriptor* descriptor() { return m_descriptor.get(); }
     
    5856
    5957#endif // ENABLE(USER_MESSAGE_HANDLERS)
    60 #endif // UserMessageHandler_h
  • trunk/Source/WebCore/page/UserMessageHandler.idl

    r206723 r207522  
    2727    Conditional=USER_MESSAGE_HANDLERS
    2828] interface UserMessageHandler {
    29     [MayThrowLegacyException] void postMessage(SerializedScriptValue message);
     29    [MayThrowException] void postMessage(SerializedScriptValue message);
    3030};
  • trunk/Source/WebCore/storage/Storage.cpp

    r194496 r207522  
    5858}
    5959
    60 unsigned Storage::length(ExceptionCode& ec) const
     60ExceptionOr<unsigned> Storage::length() const
    6161{
    62     ec = 0;
    63     if (!m_storageArea->canAccessStorage(m_frame)) {
    64         ec = SECURITY_ERR;
    65         return 0;
    66     }
     62    if (!m_storageArea->canAccessStorage(m_frame))
     63        return Exception { SECURITY_ERR };
    6764
    6865    if (isDisabledByPrivateBrowsing())
     
    7269}
    7370
    74 String Storage::key(unsigned index, ExceptionCode& ec) const
     71ExceptionOr<String> Storage::key(unsigned index) const
    7572{
    76     if (!m_storageArea->canAccessStorage(m_frame)) {
    77         ec = SECURITY_ERR;
    78         return String();
    79     }
     73    if (!m_storageArea->canAccessStorage(m_frame))
     74        return Exception { SECURITY_ERR };
    8075
    8176    if (isDisabledByPrivateBrowsing())
     
    8580}
    8681
    87 String Storage::getItem(const String& key, ExceptionCode& ec) const
     82ExceptionOr<String> Storage::getItem(const String& key) const
    8883{
    89     if (!m_storageArea->canAccessStorage(m_frame)) {
    90         ec = SECURITY_ERR;
    91         return String();
    92     }
     84    if (!m_storageArea->canAccessStorage(m_frame))
     85        return Exception { SECURITY_ERR };
    9386
    9487    if (isDisabledByPrivateBrowsing())
     
    9891}
    9992
    100 void Storage::setItem(const String& key, const String& value, ExceptionCode& ec)
     93ExceptionOr<void> Storage::setItem(const String& key, const String& value)
    10194{
    102     if (!m_storageArea->canAccessStorage(m_frame)) {
    103         ec = SECURITY_ERR;
    104         return;
    105     }
     95    if (!m_storageArea->canAccessStorage(m_frame))
     96        return Exception { SECURITY_ERR };
    10697
    107     if (isDisabledByPrivateBrowsing()) {
    108         ec = QUOTA_EXCEEDED_ERR;
    109         return;
    110     }
     98    if (isDisabledByPrivateBrowsing())
     99        return Exception { QUOTA_EXCEEDED_ERR };
    111100
    112101    bool quotaException = false;
    113102    m_storageArea->setItem(m_frame, key, value, quotaException);
    114 
    115103    if (quotaException)
    116         ec = QUOTA_EXCEEDED_ERR;
     104        return Exception { QUOTA_EXCEEDED_ERR };
     105    return { };
    117106}
    118107
    119 void Storage::removeItem(const String& key, ExceptionCode& ec)
     108ExceptionOr<void> Storage::removeItem(const String& key)
    120109{
    121     if (!m_storageArea->canAccessStorage(m_frame)) {
    122         ec = SECURITY_ERR;
    123         return;
    124     }
     110    if (!m_storageArea->canAccessStorage(m_frame))
     111        return Exception { SECURITY_ERR };
    125112
    126113    if (isDisabledByPrivateBrowsing())
    127         return;
     114        return { };
    128115
    129116    m_storageArea->removeItem(m_frame, key);
     117    return { };
    130118}
    131119
    132 void Storage::clear(ExceptionCode& ec)
     120ExceptionOr<void> Storage::clear()
    133121{
    134     if (!m_storageArea->canAccessStorage(m_frame)) {
    135         ec = SECURITY_ERR;
    136         return;
    137     }
     122    if (!m_storageArea->canAccessStorage(m_frame))
     123        return Exception { SECURITY_ERR };
    138124
    139125    if (isDisabledByPrivateBrowsing())
    140         return;
     126        return { };
    141127
    142128    m_storageArea->clear(m_frame);
     129    return { };
    143130}
    144131
    145 bool Storage::contains(const String& key, ExceptionCode& ec) const
     132ExceptionOr<bool> Storage::contains(const String& key) const
    146133{
    147     if (!m_storageArea->canAccessStorage(m_frame)) {
    148         ec = SECURITY_ERR;
    149         return false;
    150     }
     134    if (!m_storageArea->canAccessStorage(m_frame))
     135        return Exception { SECURITY_ERR };
    151136
    152137    if (isDisabledByPrivateBrowsing())
  • trunk/Source/WebCore/storage/Storage.h

    r189675 r207522  
    2424 */
    2525
    26 #ifndef Storage_h
    27 #define Storage_h
     26#pragma once
    2827
    2928#include "DOMWindowProperty.h"
     29#include "ExceptionOr.h"
    3030#include "ScriptWrappable.h"
    31 #include <wtf/Forward.h>
    32 #include <wtf/RefCounted.h>
    33 #include <wtf/RefPtr.h>
    3431
    3532namespace WebCore {
     
    3835class StorageArea;
    3936
    40 typedef int ExceptionCode;
    41 
    4237class Storage : public ScriptWrappable, public RefCounted<Storage>, public DOMWindowProperty {
    4338public:
     
    4540    ~Storage();
    4641
    47     unsigned length(ExceptionCode&) const;
    48     String key(unsigned index, ExceptionCode&) const;
    49     String getItem(const String& key, ExceptionCode&) const;
    50     void setItem(const String& key, const String& value, ExceptionCode&);
    51     void removeItem(const String& key, ExceptionCode&);
    52     void clear(ExceptionCode&);
    53     bool contains(const String& key, ExceptionCode&) const;
     42    ExceptionOr<unsigned> length() const;
     43    ExceptionOr<String> key(unsigned index) const;
     44    ExceptionOr<String> getItem(const String& key) const;
     45    ExceptionOr<void> setItem(const String& key, const String& value);
     46    ExceptionOr<void> removeItem(const String& key);
     47    ExceptionOr<void> clear();
     48    ExceptionOr<bool> contains(const String& key) const;
    5449
    5550    StorageArea& area() const { return *m_storageArea; }
     
    6459
    6560} // namespace WebCore
    66 
    67 #endif // Storage_h
  • trunk/Source/WebCore/storage/Storage.idl

    r206723 r207522  
    3131    SkipVTableValidation,
    3232] interface Storage {
    33     [GetterMayThrowLegacyException] readonly attribute unsigned long length;
    34     [MayThrowLegacyException] DOMString? key(unsigned long index);
    35     [MayThrowLegacyException] getter DOMString? getItem(DOMString key);
    36     [MayThrowLegacyException] void setItem(DOMString key, DOMString data);
    37     [MayThrowLegacyException] void removeItem(DOMString key);
    38     [MayThrowLegacyException] void clear();
     33    [GetterMayThrowException] readonly attribute unsigned long length;
     34    [MayThrowException] DOMString? key(unsigned long index);
     35    [MayThrowException] getter DOMString? getItem(DOMString key);
     36    [MayThrowException] void setItem(DOMString key, DOMString data);
     37    [MayThrowException] void removeItem(DOMString key);
     38    [MayThrowException] void clear();
    3939};
    4040
  • trunk/Source/WebCore/storage/StorageEventDispatcher.cpp

    r184990 r207522  
    8080
    8181    for (auto& frame : frames) {
    82         ExceptionCode ec = 0;
    83         Storage* storage = frame->document()->domWindow()->sessionStorage(ec);
    84         if (!ec)
    85             frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
     82        auto result = frame->document()->domWindow()->sessionStorage();
     83        if (!result.hasException())
     84            frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, result.releaseReturnValue()));
    8685    }
    8786}
     
    9392
    9493    for (auto& frame : frames) {
    95         ExceptionCode ec = 0;
    96         Storage* storage = frame->document()->domWindow()->localStorage(ec);
    97         if (!ec)
    98             frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
     94        auto result = frame->document()->domWindow()->localStorage();
     95        if (!result.hasException())
     96            frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, result.releaseReturnValue()));
    9997    }
    10098}
  • trunk/Source/WebKit/win/ChangeLog

    r207495 r207522  
     12016-10-18  Darin Adler  <darin@apple.com>
     2
     3        Move many miscellaneous classes from ExceptionCode to Exception
     4        https://bugs.webkit.org/show_bug.cgi?id=163645
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * DOMCoreClasses.cpp:
     9        (DOMDocument::getComputedStyle): Use ptr instead of get since the return
     10        value is now Ref instead of RefPtr.
     11
    1122016-10-18  Anders Carlsson  <andersca@apple.com>
    213
  • trunk/Source/WebKit/win/DOMCoreClasses.cpp

    r203651 r207522  
    804804        return E_FAIL;
    805805   
    806     *result = DOMCSSStyleDeclaration::createInstance(dv->getComputedStyle(*element, pseudoEltString.impl()).get());
     806    *result = DOMCSSStyleDeclaration::createInstance(dv->getComputedStyle(*element, pseudoEltString.impl()).ptr());
    807807    return *result ? S_OK : E_FAIL;
    808808}
Note: See TracChangeset for help on using the changeset viewer.