Ejemplo n.º 1
0
static PassRefPtr<Range> makeSearchRange(const Position& pos)
{
    Node* n = pos.deprecatedNode();
    if (!n)
        return 0;
    Document& d = n->document();
    Node* de = d.documentElement();
    if (!de)
        return 0;
    Node* boundary = n->enclosingBlockFlowElement();
    if (!boundary)
        return 0;

    RefPtr<Range> searchRange(Range::create(d));
    TrackExceptionState es;

    Position start(pos.parentAnchoredEquivalent());
    searchRange->selectNodeContents(boundary, es);
    searchRange->setStart(start.containerNode(), start.offsetInContainerNode(), es);

    ASSERT(!es.hadException());
    if (es.hadException())
        return 0;

    return searchRange.release();
}
Ejemplo n.º 2
0
static PassRefPtrWillBeRawPtr<Range> makeSearchRange(const Position& pos)
{
    Node* node = pos.deprecatedNode();
    if (!node)
        return nullptr;
    Document& document = node->document();
    if (!document.documentElement())
        return nullptr;
    Element* boundary = enclosingBlockFlowElement(*node);
    if (!boundary)
        return nullptr;

    RefPtrWillBeRawPtr<Range> searchRange(Range::create(document));
    TrackExceptionState exceptionState;

    Position start(pos.parentAnchoredEquivalent());
    searchRange->selectNodeContents(boundary, exceptionState);
    searchRange->setStart(start.containerNode(), start.offsetInContainerNode(), exceptionState);

    ASSERT(!exceptionState.hadException());
    if (exceptionState.hadException())
        return nullptr;

    return searchRange.release();
}
Ejemplo n.º 3
0
bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
{
    if (!m_frame)
        return false;

    FrameSelection& selection = m_frame->selection();

    if (!n || m_frame->document() != n->document() || selection.isNone())
        return false;

    unsigned nodeIndex = n->nodeIndex();
    RefPtrWillBeRawPtr<Range> selectedRange = selection.selection().toNormalizedRange();

    ContainerNode* parentNode = n->parentNode();
    if (!parentNode)
        return false;

    TrackExceptionState exceptionState;
    bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->startContainer(), selectedRange->startOffset(), exceptionState) >= 0 && !exceptionState.hadException()
        && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange->endContainer(), selectedRange->endOffset(), exceptionState) <= 0 && !exceptionState.hadException();
    if (exceptionState.hadException())
        return false;
    if (nodeFullySelected)
        return true;

    bool nodeFullyUnselected = (Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->endContainer(), selectedRange->endOffset(), exceptionState) > 0 && !exceptionState.hadException())
        || (Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange->startContainer(), selectedRange->startOffset(), exceptionState) < 0 && !exceptionState.hadException());
    ASSERT(!exceptionState.hadException());
    if (nodeFullyUnselected)
        return false;

    return allowPartial || n->isTextNode();
}
Ejemplo n.º 4
0
v8::Local<v8::Value> WebDocument::registerEmbedderCustomElement(const WebString& name, v8::Local<v8::Value> options, WebExceptionCode& ec)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    Document* document = unwrap<Document>();
    TrackExceptionState exceptionState;
    ElementRegistrationOptions registrationOptions;
    V8ElementRegistrationOptions::toImpl(isolate, options, registrationOptions, exceptionState);
    if (exceptionState.hadException())
        return v8::Local<v8::Value>();
    ScriptValue constructor = document->registerElement(ScriptState::current(isolate), name, registrationOptions, exceptionState, CustomElement::EmbedderNames);
    ec = exceptionState.code();
    if (exceptionState.hadException())
        return v8::Local<v8::Value>();
    return constructor.v8Value();
}
Ejemplo n.º 5
0
ScriptPromise Permissions::query(ScriptState* scriptState, const Dictionary& rawPermission)
{
    WebPermissionClient* client = getClient(scriptState->executionContext());
    if (!client)
        return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't query permissions."));

    TrackExceptionState exceptionState;
    PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState);

    if (exceptionState.hadException())
        return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8String(scriptState->isolate(), exceptionState.message())));

    ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();

    WebPermissionType type = getPermissionType(scriptState, rawPermission, permission, exceptionState);
    if (handleNotSupportedPermission(scriptState, rawPermission, resolver, type, exceptionState))
        return promise;

    // If the current origin is a file scheme, it will unlikely return a
    // meaningful value because most APIs are broken on file scheme and no
    // permission prompt will be shown even if the returned permission will most
    // likely be "prompt".
    client->queryPermission(type, KURL(KURL(), scriptState->executionContext()->securityOrigin()->toString()), new PermissionCallback(resolver, type));
    return promise;
}
Ejemplo n.º 6
0
void InspectorOverlay::drawNodeHighlight()
{
    if (!m_highlightNode)
        return;

    String selectors = m_nodeHighlightConfig.selectorList;
    RefPtrWillBeRawPtr<StaticElementList> elements = nullptr;
    TrackExceptionState exceptionState;
    ContainerNode* queryBase = m_highlightNode->containingShadowRoot();
    if (!queryBase)
        queryBase = m_highlightNode->ownerDocument();
    if (selectors.length())
        elements = queryBase->querySelectorAll(AtomicString(selectors), exceptionState);
    if (elements && !exceptionState.hadException()) {
        for (unsigned i = 0; i < elements->length(); ++i) {
            Element* element = elements->item(i);
            InspectorHighlight highlight(element, m_nodeHighlightConfig, false);
            RefPtr<JSONObject> highlightJSON = highlight.asJSONObject();
            evaluateInOverlay("drawHighlight", highlightJSON.release());
        }
    }

    bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highlightNode->document().frame();
    InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, appendElementInfo);
    if (m_eventTargetNode)
        highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighlightConfig);

    RefPtr<JSONObject> highlightJSON = highlight.asJSONObject();
    evaluateInOverlay("drawHighlight", highlightJSON.release());
}
void MergeIdenticalElementsCommand::doUnapply()
{
    ASSERT(m_element1);
    ASSERT(m_element2);

    RefPtr<Node> atChild = m_atChild.release();

    ContainerNode* parent = m_element2->parentNode();
    if (!parent || !parent->rendererIsEditable())
        return;

    TrackExceptionState es;

    parent->insertBefore(m_element1.get(), m_element2.get(), es);
    if (es.hadException())
        return;

    Vector<RefPtr<Node> > children;
    for (Node* child = m_element2->firstChild(); child && child != atChild; child = child->nextSibling())
        children.append(child);

    size_t size = children.size();
    for (size_t i = 0; i < size; ++i)
        m_element1->appendChild(children[i].release(), es);
}
Ejemplo n.º 8
0
void TouchActionTest::runShadowDOMTest(std::string file) {
  TouchActionTrackingWebViewClient client;

  WebView* webView = setupTest(file, client);

  TrackExceptionState es;

  // Oilpan: see runTouchActionTest() comment why these are persistent
  // references.
  Persistent<Document> document =
      static_cast<Document*>(webView->mainFrame()->document());
  Persistent<StaticElementList> hostNodes =
      document->querySelectorAll("[shadow-host]", es);
  ASSERT_FALSE(es.hadException());
  ASSERT_GE(hostNodes->length(), 1u);

  for (unsigned index = 0; index < hostNodes->length(); index++) {
    ShadowRoot* shadowRoot = hostNodes->item(index)->openShadowRoot();
    runTestOnTree(shadowRoot, webView, client);
  }

  // Projections show up in the main document.
  runTestOnTree(document.get(), webView, client);

  // Explicitly reset to break dependency on locally scoped client.
  m_webViewHelper.reset();
}
Ejemplo n.º 9
0
ScriptPromise Permissions::request(ScriptState* scriptState, const Vector<Dictionary>& rawPermissions)
{
    WebPermissionClient* client = getClient(scriptState->executionContext());
    if (!client)
        return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't query permissions."));

    TrackExceptionState exceptionState;
    OwnPtr<WebVector<WebPermissionType>> permissions = adoptPtr(new WebVector<WebPermissionType>(rawPermissions.size()));

    for (size_t i = 0; i < rawPermissions.size(); ++i) {
        const Dictionary& rawPermission = rawPermissions[i];
        PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState);

        if (exceptionState.hadException())
            return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8String(scriptState->isolate(), exceptionState.message())));

        permissions->operator[](i) = getPermissionType(scriptState, rawPermission, permission, exceptionState);
    }

    ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();

    // We need to do this is a separate loop because we can't create the Resolver and Promise untile we are clear of all parsing/type errors.
    for (size_t i = 0; i < rawPermissions.size(); ++i) {
        if (handleNotSupportedPermission(scriptState, rawPermissions[i], resolver, (*permissions)[i], exceptionState))
            return promise;
    }

    client->requestPermissions(*permissions, KURL(KURL(), scriptState->executionContext()->securityOrigin()->toString()), new PermissionsCallback(resolver, permissions.release()));
    return promise;
}
Ejemplo n.º 10
0
WebDOMEvent WebDocument::createEvent(const WebString& eventType)
{
    TrackExceptionState exceptionState;
    WebDOMEvent event(unwrap<Document>()->createEvent(eventType, exceptionState));
    if (exceptionState.hadException())
        return WebDOMEvent();
    return event;
}
WebSerializedScriptValue WebSerializedScriptValue::serialize(v8::Local<v8::Value> value)
{
    TrackExceptionState exceptionState;
    WebSerializedScriptValue serializedValue = SerializedScriptValueFactory::instance().create(v8::Isolate::GetCurrent(), value, nullptr, nullptr, nullptr, exceptionState);
    if (exceptionState.hadException())
        return createInvalid();
    return serializedValue;
}
Ejemplo n.º 12
0
void SplitTextNodeCommand::insertText1AndTrimText2()
{
    TrackExceptionState exceptionState;
    m_text2->parentNode()->insertBefore(m_text1.get(), m_text2.get(), exceptionState);
    if (exceptionState.hadException())
        return;
    m_text2->deleteData(0, m_offset, exceptionState, CharacterData::DeprecatedRecalcStyleImmediatlelyForEditing);
}
Ejemplo n.º 13
0
bool WebElement::setAttribute(const WebString& attrName, const WebString& attrValue)
{
    // TODO: Custom element callbacks need to be called on WebKit API methods that
    // mutate the DOM in any way.
    CustomElementCallbackDispatcher::CallbackDeliveryScope deliverCustomElementCallbacks;
    TrackExceptionState exceptionState;
    unwrap<Element>()->setAttribute(attrName, attrValue, exceptionState);
    return !exceptionState.hadException();
}
Ejemplo n.º 14
0
bool setEnd(Range *r, const VisiblePosition &visiblePosition)
{
    if (!r)
        return false;
    Position p = visiblePosition.deepEquivalent().parentAnchoredEquivalent();
    TrackExceptionState exceptionState;
    r->setEnd(p.containerNode(), p.offsetInContainerNode(), exceptionState);
    return !exceptionState.hadException();
}
Ejemplo n.º 15
0
void SVGStaticStringList::setBaseValueAsString(const String& value, SVGParsingError& parseError)
{
    TrackExceptionState es;

    m_value->setValueAsString(value, es);

    if (es.hadException())
        parseError = ParsingAttributeFailedError;
}
Ejemplo n.º 16
0
void Headers::forEachInternal(PassOwnPtr<HeadersForEachCallback> callback, ScriptValue* thisArg)
{
    TrackExceptionState exceptionState;
    for (size_t i = 0; i < m_headerList->size(); ++i) {
        if (thisArg)
            callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_headerList->list()[i]->first, this);
        else
            callback->handleItem(m_headerList->list()[i]->second, m_headerList->list()[i]->first, this);
        if (exceptionState.hadException())
            break;
    }
}
Ejemplo n.º 17
0
v8::Handle<v8::Value> WebDocument::registerEmbedderCustomElement(const WebString& name, v8::Handle<v8::Value> options, WebExceptionCode& ec)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    Document* document = unwrap<Document>();
    Dictionary dictionary(options, isolate);
    TrackExceptionState exceptionState;
    ScriptValue constructor = document->registerElement(ScriptState::current(isolate), name, dictionary, exceptionState, CustomElement::EmbedderNames);
    ec = exceptionState.code();
    if (exceptionState.hadException())
        return v8::Handle<v8::Value>();
    return constructor.v8Value();
}
Ejemplo n.º 18
0
void HeaderMap::forEachInternal(PassOwnPtr<HeaderMapForEachCallback> callback, ScriptValue* thisArg)
{
    TrackExceptionState exceptionState;
    for (HashMap<String, String>::const_iterator it = m_headers.begin(); it != m_headers.end(); ++it) {
        if (thisArg)
            callback->handleItem(*thisArg, it->value, it->key, this);
        else
            callback->handleItem(it->value, it->key, this);
        if (exceptionState.hadException())
            break;
    }
}
Ejemplo n.º 19
0
SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value)
{
    ASSERT(value);

    SVGLengthType svgType;
    switch (value->primitiveType()) {
    case CSSPrimitiveValue::CSS_NUMBER:
        svgType = LengthTypeNumber;
        break;
    case CSSPrimitiveValue::CSS_PERCENTAGE:
        svgType = LengthTypePercentage;
        break;
    case CSSPrimitiveValue::CSS_EMS:
        svgType = LengthTypeEMS;
        break;
    case CSSPrimitiveValue::CSS_EXS:
        svgType = LengthTypeEXS;
        break;
    case CSSPrimitiveValue::CSS_PX:
        svgType = LengthTypePX;
        break;
    case CSSPrimitiveValue::CSS_CM:
        svgType = LengthTypeCM;
        break;
    case CSSPrimitiveValue::CSS_MM:
        svgType = LengthTypeMM;
        break;
    case CSSPrimitiveValue::CSS_IN:
        svgType = LengthTypeIN;
        break;
    case CSSPrimitiveValue::CSS_PT:
        svgType = LengthTypePT;
        break;
    case CSSPrimitiveValue::CSS_PC:
        svgType = LengthTypePC;
        break;
    case CSSPrimitiveValue::CSS_UNKNOWN:
    default:
        svgType = LengthTypeUnknown;
        break;
    };

    if (svgType == LengthTypeUnknown)
        return SVGLength();

    TrackExceptionState exceptionState;
    SVGLength length;
    length.newValueSpecifiedUnits(svgType, value->getFloatValue(), exceptionState);
    if (exceptionState.hadException())
        return SVGLength();

    return length;
}
Ejemplo n.º 20
0
WebElement WebDocument::createElement(const WebString& tagName)
{
    TrackExceptionState exceptionState;
#if ENABLE(OILPAN)
    // FIXME: Document::createElement should return a raw pointer.
    WebElement element(unwrap<Document>()->createElement(tagName, exceptionState).get());
#else
    WebElement element(unwrap<Document>()->createElement(tagName, exceptionState));
#endif
    if (exceptionState.hadException())
        return WebElement();
    return element;
}
Ejemplo n.º 21
0
bool DOMSelection::containsNode(const Node* n, bool allowPartial) const {
    DCHECK(n);

    if (!isAvailable())
        return false;

    FrameSelection& selection = frame()->selection();

    if (frame()->document() != n->document() || selection.isNone())
        return false;

    unsigned nodeIndex = n->nodeIndex();

    // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
    // needs to be audited.  See http://crbug.com/590369 for more details.
    // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout.
    frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();

    const EphemeralRange selectedRange =
        selection.selection().toNormalizedEphemeralRange();

    ContainerNode* parentNode = n->parentNode();
    if (!parentNode)
        return false;

    const Position startPosition =
        selectedRange.startPosition().toOffsetInAnchor();
    const Position endPosition = selectedRange.endPosition().toOffsetInAnchor();
    TrackExceptionState exceptionState;
    bool nodeFullySelected =
        Range::compareBoundaryPoints(
            parentNode, nodeIndex, startPosition.computeContainerNode(),
            startPosition.offsetInContainerNode(), exceptionState) >= 0 &&
        !exceptionState.hadException() &&
        Range::compareBoundaryPoints(
            parentNode, nodeIndex + 1, endPosition.computeContainerNode(),
            endPosition.offsetInContainerNode(), exceptionState) <= 0 &&
        !exceptionState.hadException();
    if (exceptionState.hadException())
        return false;
    if (nodeFullySelected)
        return true;

    bool nodeFullyUnselected =
        (Range::compareBoundaryPoints(
             parentNode, nodeIndex, endPosition.computeContainerNode(),
             endPosition.offsetInContainerNode(), exceptionState) > 0 &&
         !exceptionState.hadException()) ||
        (Range::compareBoundaryPoints(
             parentNode, nodeIndex + 1, startPosition.computeContainerNode(),
             startPosition.offsetInContainerNode(), exceptionState) < 0 &&
         !exceptionState.hadException());
    DCHECK(!exceptionState.hadException());
    if (nodeFullyUnselected)
        return false;

    return allowPartial || n->isTextNode();
}
Ejemplo n.º 22
0
SVGLength SVGLength::construct(SVGLengthMode mode, const String& valueAsString, SVGParsingError& parseError, SVGLengthNegativeValuesMode negativeValuesMode)
{
    TrackExceptionState exceptionState;
    SVGLength length(mode);

    length.setValueAsString(valueAsString, exceptionState);

    if (exceptionState.hadException())
        parseError = ParsingAttributeFailedError;
    else if (negativeValuesMode == ForbidNegativeLengths && length.valueInSpecifiedUnits() < 0)
        parseError = NegativeValueForbiddenError;

    return length;
}
TEST_F(PasswordCredentialTest, CreateFromFormNoId)
{
    HTMLFormElement* form = populateForm("multipart/form-data",
        "<!-- No username field. -->"
        "<input type='text' name='thePassword' value='sekrit' autocomplete='current-password'>"
        "<input type='text' name='theIcon' value='https://example.com/photo' autocomplete='photo'>"
        "<input type='text' name='theName' value='friendly name' autocomplete='name'>");
    TrackExceptionState exceptionState;
    PasswordCredential* credential = PasswordCredential::create(form, exceptionState);
    EXPECT_EQ(nullptr, credential);
    EXPECT_TRUE(exceptionState.hadException());
    EXPECT_EQ(V8TypeError, exceptionState.code());
    EXPECT_EQ("'id' must not be empty.", exceptionState.message());
}
void DeleteFromTextNodeCommand::doApply()
{
    ASSERT(m_node);

    if (!m_node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable))
        return;

    TrackExceptionState exceptionState;
    m_text = m_node->substringData(m_offset, m_count, exceptionState);
    if (exceptionState.hadException())
        return;

    m_node->deleteData(m_offset, m_count, exceptionState, CharacterData::DeprecatedRecalcStyleImmediatlelyForEditing);
}
Ejemplo n.º 25
0
ScriptPromise Permissions::query(ScriptState* scriptState, const ScriptValue& rawPermission)
{
    WebPermissionClient* client = permissionClient(scriptState->executionContext());
    if (!client)
        return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't query permissions."));

    TrackExceptionState exceptionState;
    PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState);


    if (exceptionState.hadException())
        return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8String(scriptState->isolate(), exceptionState.message())));

    RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();

    String name = permission.name();
    WebPermissionType type;
    if (name == "geolocation") {
        type = WebPermissionTypeGeolocation;
    } else if (name == "notifications") {
        type = WebPermissionTypeNotifications;
    } else if (name == "push") {
        PushPermissionDescriptor pushPermission = NativeValueTraits<PushPermissionDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState);
        // Only "userVisible" push is supported for now.
        if (!pushPermission.userVisible()) {
            resolver->resolve(PermissionStatus::create(scriptState->executionContext(), WebPermissionStatusDenied, WebPermissionTypePush));
            return promise;
        }
        type = WebPermissionTypePushNotifications;
    } else if (name == "midi") {
        MidiPermissionDescriptor midiPermission = NativeValueTraits<MidiPermissionDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState);
        // Only sysex usage requires a permission for now.
        if (!midiPermission.sysex()) {
            resolver->resolve(PermissionStatus::create(scriptState->executionContext(), WebPermissionStatusGranted, WebPermissionTypeMidi));
            return promise;
        }
        type = WebPermissionTypeMidiSysEx;
    } else {
        ASSERT_NOT_REACHED();
        type = WebPermissionTypeGeolocation;
    }

    // If the current origin is a file scheme, it will unlikely return a
    // meaningful value because most APIs are broken on file scheme and no
    // permission prompt will be shown even if the returned permission will most
    // likely be "prompt".
    client->queryPermission(type, KURL(KURL(), scriptState->executionContext()->securityOrigin()->toString()), new PermissionQueryCallback(resolver, type));
    return promise;
}
static bool isNewLineAtPosition(const Position& position)
{
    Node* textNode = position.containerNode();
    int offset = position.offsetInContainerNode();
    if (!textNode || !textNode->isTextNode() || offset < 0 || offset >= textNode->maxCharacterOffset())
        return false;

    TrackExceptionState exceptionState;
    String textAtPosition = toText(textNode)->substringData(offset, 1, exceptionState);
    if (exceptionState.hadException())
        return false;

    return textAtPosition[0] == '\n';
}
Ejemplo n.º 27
0
bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
{
    ASSERT(n);

    if (!m_frame)
        return false;

    FrameSelection& selection = m_frame->selection();

    if (m_frame->document() != n->document() || selection.isNone())
        return false;

    unsigned nodeIndex = n->nodeIndex();
    const EphemeralRange selectedRange = selection.selection().toNormalizedEphemeralRange();

    ContainerNode* parentNode = n->parentNode();
    if (!parentNode)
        return false;

    const Position startPosition = selectedRange.startPosition().toOffsetInAnchor();
    const Position endPosition = selectedRange.endPosition().toOffsetInAnchor();
    TrackExceptionState exceptionState;
    bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex, startPosition.computeContainerNode(), startPosition.offsetInContainerNode(), exceptionState) >= 0 && !exceptionState.hadException()
        && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, endPosition.computeContainerNode(), endPosition.offsetInContainerNode(), exceptionState) <= 0 && !exceptionState.hadException();
    if (exceptionState.hadException())
        return false;
    if (nodeFullySelected)
        return true;

    bool nodeFullyUnselected = (Range::compareBoundaryPoints(parentNode, nodeIndex, endPosition.computeContainerNode(), endPosition.offsetInContainerNode(), exceptionState) > 0 && !exceptionState.hadException())
        || (Range::compareBoundaryPoints(parentNode, nodeIndex + 1, startPosition.computeContainerNode(), startPosition.offsetInContainerNode(), exceptionState) < 0 && !exceptionState.hadException());
    ASSERT(!exceptionState.hadException());
    if (nodeFullyUnselected)
        return false;

    return allowPartial || n->isTextNode();
}
Ejemplo n.º 28
0
ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const String& urlstring, const Dictionary& requestInit)
{
    if (!m_fetchManager)
        return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "ServiceWorkerGlobalScope is shutting down."));
    // "Let |r| be the associated request of the result of invoking the initial
    // value of Request as constructor with |input| and |init| as arguments. If
    // this throws an exception, reject |p| with it."
    TrackExceptionState exceptionState;
    Request* r = Request::create(this, urlstring, requestInit, exceptionState);
    if (exceptionState.hadException()) {
        // FIXME: We should throw the caught error.
        return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), exceptionState.message()));
    }
    return m_fetchManager->fetch(scriptState, r->request());
}
Ejemplo n.º 29
0
void DeleteFromTextNodeCommand::doApply(EditingState*) {
  DCHECK(m_node);

  document().updateStyleAndLayoutTree();
  if (!hasEditableStyle(*m_node))
    return;

  TrackExceptionState exceptionState;
  m_text = m_node->substringData(m_offset, m_count, exceptionState);
  if (exceptionState.hadException())
    return;

  m_node->deleteData(m_offset, m_count, exceptionState);
  m_node->document().updateStyleAndLayout();
}
Ejemplo n.º 30
0
void SVGAnimatedViewBoxRect::setBaseValueAsString(const String& value, SVGParsingError& parseError)
{
    TrackExceptionState es;

    baseValue()->setValueAsString(value, es);

    if (es.hadException()) {
        parseError = ParsingAttributeFailedError;
        return;
    }

    if (baseValue()->width() < 0 || baseValue()->height() < 0) {
        parseError = NegativeValueForbiddenError;
        baseValue()->setInvalid();
    }
}