Beispiel #1
0
void MouseEvent::initMouseEvent(ScriptState* scriptState,
                                const AtomicString& type,
                                bool canBubble,
                                bool cancelable,
                                AbstractView* view,
                                int detail,
                                int screenX,
                                int screenY,
                                int clientX,
                                int clientY,
                                bool ctrlKey,
                                bool altKey,
                                bool shiftKey,
                                bool metaKey,
                                short button,
                                EventTarget* relatedTarget,
                                unsigned short buttons) {
  if (isBeingDispatched())
    return;

  if (scriptState && scriptState->world().isIsolatedWorld())
    UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey,
                                                       shiftKey, metaKey);

  initModifiers(ctrlKey, altKey, shiftKey, metaKey);
  initMouseEventInternal(type, canBubble, cancelable, view, detail, screenX,
                         screenY, clientX, clientY, modifiers(), button,
                         relatedTarget, nullptr, buttons);
}
void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext, const Vector<String>& subScopes, const USVStringOrUSVStringSequence& origins, ExceptionState& exceptionState)
{
    if (!isBeingDispatched()) {
        exceptionState.throwDOMException(InvalidStateError, "The event handler is already finished.");
        return;
    }

    Vector<String> originList;
    if (origins.isUSVString()) {
        originList.append(origins.getAsUSVString());
    } else if (origins.isUSVStringSequence()) {
        originList = origins.getAsUSVStringSequence();
    }
    if (originList.isEmpty()) {
        exceptionState.throwTypeError("At least one origin is required");
        return;
    }

    // The origins parameter is either just a "*" to indicate all origins, or an
    // explicit list of origins as absolute URLs. Internally an empty list of
    // origins is used to represent the "*" case though.
    Vector<RefPtr<SecurityOrigin>> parsedOrigins;
    if (originList.size() != 1 || originList[0] != "*") {
        parsedOrigins.resize(originList.size());
        for (size_t i = 0; i < originList.size(); ++i) {
            parsedOrigins[i] = SecurityOrigin::createFromString(originList[i]);
            // Invalid URLs will result in a unique origin. And in general
            // unique origins should not be accepted.
            if (parsedOrigins[i]->isUnique()) {
                exceptionState.throwTypeError("Invalid origin URL: " + originList[i]);
                return;
            }
        }
    }

    ServiceWorkerGlobalScopeClient* client = ServiceWorkerGlobalScopeClient::from(executionContext);

    String scopePath = static_cast<KURL>(client->scope()).path();
    RefPtr<SecurityOrigin> origin = executionContext->securityOrigin();

    Vector<KURL> subScopeURLs(subScopes.size());
    for (size_t i = 0; i < subScopes.size(); ++i) {
        subScopeURLs[i] = executionContext->completeURL(subScopes[i]);
        if (!subScopeURLs[i].isValid()) {
            exceptionState.throwTypeError("Invalid subscope URL: " + subScopes[i]);
            return;
        }
        subScopeURLs[i].removeFragmentIdentifier();
        if (!origin->canRequest(subScopeURLs[i])) {
            exceptionState.throwTypeError("Subscope URL is not within scope: " + subScopes[i]);
            return;
        }
        String subScopePath = subScopeURLs[i].path();
        if (!subScopePath.startsWith(scopePath)) {
            exceptionState.throwTypeError("Subscope URL is not within scope: " + subScopes[i]);
            return;
        }
    }
    client->registerForeignFetchScopes(subScopeURLs, parsedOrigins);
}
void PaymentRequestUpdateEvent::updateWith(ScriptState* scriptState,
                                           ScriptPromise promise,
                                           ExceptionState& exceptionState) {
  if (!m_updater)
    return;

  if (!isBeingDispatched()) {
    exceptionState.throwDOMException(
        InvalidStateError,
        "Cannot update details when the event is not being dispatched");
    return;
  }

  if (m_waitForUpdate) {
    exceptionState.throwDOMException(InvalidStateError,
                                     "Cannot update details twice");
    return;
  }

  stopImmediatePropagation();
  m_waitForUpdate = true;
  m_abortTimer.stop();

  promise.then(
      UpdatePaymentDetailsFunction::createFunction(scriptState, m_updater),
      UpdatePaymentDetailsErrorFunction::createFunction(scriptState,
                                                        m_updater));
}
Beispiel #4
0
void UIEvent::initUIEventInternal(const AtomicString& typeArg, bool canBubbleArg, bool cancelableArg, EventTarget* relatedTarget, AbstractView* viewArg, int detailArg, InputDeviceCapabilities* sourceCapabilitiesArg)
{
    if (isBeingDispatched())
        return;

    initEvent(typeArg, canBubbleArg, cancelableArg, relatedTarget);

    m_view = viewArg;
    m_detail = detailArg;
    m_sourceCapabilities = sourceCapabilitiesArg;
}
void CustomEvent::initCustomEvent(JSC::ExecState& state, const AtomicString& type, bool canBubble, bool cancelable, JSC::JSValue detail)
{
    if (isBeingDispatched())
        return;

    initEvent(type, canBubble, cancelable);

    m_detail = { state.vm(), detail };
    m_serializedDetail = nullptr;
    m_triedToSerialize = false;
}
Beispiel #6
0
void TextEvent::initTextEvent(const AtomicString& type,
                              bool canBubble,
                              bool cancelable,
                              AbstractView* view,
                              const String& data) {
  if (isBeingDispatched())
    return;

  initUIEvent(type, canBubble, cancelable, view, 0);

  m_data = data;
}
void DeviceOrientationEvent::initDeviceOrientationEvent(
    const AtomicString& type,
    bool bubbles,
    bool cancelable,
    const Nullable<double>& alpha,
    const Nullable<double>& beta,
    const Nullable<double>& gamma,
    bool absolute) {
  if (isBeingDispatched())
    return;

  initEvent(type, bubbles, cancelable);
  m_orientation = DeviceOrientationData::create(alpha, beta, gamma, absolute);
}
Beispiel #8
0
void DeviceMotionEvent::initDeviceMotionEvent(
    const AtomicString& type,
    bool bubbles,
    bool cancelable,
    DeviceMotionData* deviceMotionData) {
  if (isBeingDispatched())
    return;

  initEvent(type, bubbles, cancelable);
  m_deviceMotionData = deviceMotionData;

  m_acceleration.clear();
  m_accelerationIncludingGravity.clear();
  m_rotationRate.clear();
}
Beispiel #9
0
void MutationEvent::initMutationEvent(const AtomicString& type,
                                      bool canBubble,
                                      bool cancelable,
                                      Node* relatedNode,
                                      const String& prevValue,
                                      const String& newValue,
                                      const String& attrName,
                                      unsigned short attrChange) {
  if (isBeingDispatched())
    return;

  initEvent(type, canBubble, cancelable);

  m_relatedNode = relatedNode;
  m_prevValue = prevValue;
  m_newValue = newValue;
  m_attrName = attrName;
  m_attrChange = attrChange;
}
Beispiel #10
0
void KeyboardEvent::initKeyboardEvent(ScriptState* scriptState,
                                      const AtomicString& type,
                                      bool canBubble,
                                      bool cancelable,
                                      AbstractView* view,
                                      const String& keyIdentifier,
                                      unsigned location,
                                      bool ctrlKey,
                                      bool altKey,
                                      bool shiftKey,
                                      bool metaKey) {
  if (isBeingDispatched())
    return;

  if (scriptState->world().isIsolatedWorld())
    UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey,
                                                       shiftKey, metaKey);

  initUIEvent(type, canBubble, cancelable, view, 0);

  m_location = location;
  initModifiers(ctrlKey, altKey, shiftKey, metaKey);
  initLocationModifiers(location);
}