Exemplo n.º 1
0
PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent, SimulatedClickCreationScope creationScope)
{
    PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers;
    if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
        modifiers = keyStateEvent->modifiers();
    }

    PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::Positionless;
    int screenX = 0;
    int screenY = 0;
    if (underlyingEvent && underlyingEvent->isMouseEvent()) {
        syntheticType = PlatformMouseEvent::RealOrIndistinguishable;
        MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get());
        screenX = mouseEvent->screenLocation().x();
        screenY = mouseEvent->screenLocation().y();
    }

    double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime();
    RefPtrWillBeRawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view,
        0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr,
        timestamp, syntheticType);

    createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromUserAgent);
    createdEvent->setUnderlyingEvent(underlyingEvent);
    if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) {
        MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent());
        createdEvent->initCoordinates(mouseEvent->clientLocation());
    }

    return createdEvent.release();
}
DispatchEventResult EventDispatcher::dispatchEvent(Node& node, PassRefPtrWillBeRawPtr<EventDispatchMediator> mediator)
{
    TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dispatchEvent");
    ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
    EventDispatcher dispatcher(node, &mediator->event());
    return mediator->dispatchEvent(dispatcher);
}
bool TextTrackCueList::add(PassRefPtrWillBeRawPtr<TextTrackCue> cue)
{
    ASSERT(cue->startTime() >= 0);
    ASSERT(cue->endTime() >= 0);

    return add(cue, 0, m_list.size());
}
Exemplo n.º 4
0
static void workerGlobalScopeDidConnect(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const String& subprotocol, const String& extensions)
{
    ASSERT_UNUSED(context, context->isWorkerGlobalScope());
    workerClientWrapper->setSubprotocol(subprotocol);
    workerClientWrapper->setExtensions(extensions);
    workerClientWrapper->didConnect();
}
static PassRefPtrWillBeRawPtr<Range> expandToParagraphBoundary(PassRefPtrWillBeRawPtr<Range> range)
{
    RefPtrWillBeRawPtr<Range> paragraphRange = range->cloneRange();
    setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(range->startPosition())));
    setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(range->endPosition())));
    return paragraphRange;
}
Exemplo n.º 6
0
static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(PassRefPtrWillBeRawPtr<InjectedScriptHost> host, InjectedScriptManager* injectedScriptManager, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    ASSERT(host);

    v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &V8InjectedScriptHost::wrapperTypeInfo, host->toScriptWrappableBase(), isolate);
    if (UNLIKELY(wrapper.IsEmpty()))
        return wrapper;

    // Create a weak reference to the v8 wrapper of InspectorBackend to deref
    // InspectorBackend when the wrapper is garbage collected.
    InjectedScriptManager::CallbackData* callbackData = injectedScriptManager->createCallbackData(injectedScriptManager);
#if ENABLE(OILPAN)
    callbackData->hostPtr = WrapperPersistent<InjectedScriptHost>::create(host.get());
#else
    callbackData->host = host.get();
#endif
    callbackData->handle.set(isolate, wrapper);
    callbackData->handle.setWeak(callbackData, &InjectedScriptManager::setWeakCallback);

#if ENABLE(OILPAN)
    V8DOMWrapper::setNativeInfoWithPersistentHandle(wrapper, &V8InjectedScriptHost::wrapperTypeInfo, host->toScriptWrappableBase(), callbackData->hostPtr);
#else
    V8DOMWrapper::setNativeInfo(wrapper, &V8InjectedScriptHost::wrapperTypeInfo, host->toScriptWrappableBase());
#endif
    ASSERT(V8DOMWrapper::isDOMWrapper(wrapper));
    return wrapper;
}
static bool cueIsBefore(const TextTrackCue* cue, PassRefPtrWillBeRawPtr<TextTrackCue> otherCue)
{
    if (cue->startTime() < otherCue->startTime())
        return true;

    return cue->startTime() == otherCue->startTime() && cue->endTime() > otherCue->endTime();
}
Exemplo n.º 8
0
 CSSCalcBinaryOperation(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> rightSide, CalcOperator op, CalculationCategory category)
     : CSSCalcExpressionNode(category, isIntegerResult(leftSide.get(), rightSide.get(), op))
     , m_leftSide(leftSide)
     , m_rightSide(rightSide)
     , m_operator(op)
 {
 }
Exemplo n.º 9
0
void FontFace::initCSSFontFace(Document* document, PassRefPtrWillBeRawPtr<CSSValue> src)
{
    m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get());
    if (m_error)
        return;

    // Each item in the src property's list is a single CSSFontFaceSource. Put them all into a CSSFontFace.
    ASSERT(src);
    ASSERT(src->isValueList());
    CSSValueList* srcList = toCSSValueList(src.get());
    int srcLength = srcList->length();

    for (int i = 0; i < srcLength; i++) {
        // An item in the list either specifies a string (local font name) or a URL (remote font to download).
        CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i));
        OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr;

        if (!item->isLocal()) {
            const Settings* settings = document ? document->settings() : nullptr;
            bool allowDownloading = settings && settings->downloadableBinaryFontsEnabled();
            if (allowDownloading && item->isSupportedFormat() && document) {
                FontResource* fetched = item->fetch(document);
                if (fetched) {
                    FontLoader* fontLoader = document->styleEngine().fontSelector()->fontLoader();
                    source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fetched, fontLoader));
                }
            }
        } else {
            source = adoptPtrWillBeNoop(new LocalFontFaceSource(item->resource()));
        }

        if (source)
            m_cssFontFace->addSource(source.release());
    }
}
static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> buildSerializablePositionOffset(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> offset, CSSValueID defaultSide)
{
    CSSValueID side = defaultSide;
    RefPtrWillBeRawPtr<CSSPrimitiveValue> amount = nullptr;

    if (!offset) {
        side = CSSValueCenter;
    } else if (offset->isValueID()) {
        side = offset->getValueID();
    } else if (Pair* pair = offset->getPairValue()) {
        side = pair->first()->getValueID();
        amount = pair->second();
    } else {
        amount = offset;
    }

    if (side == CSSValueCenter) {
        side = defaultSide;
        amount = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAGE);
    } else if ((side == CSSValueRight || side == CSSValueBottom)
        && amount->isPercentage()) {
        side = defaultSide;
        amount = cssValuePool().createValue(100 - amount->getFloatValue(), CSSPrimitiveValue::CSS_PERCENTAGE);
    } else if (amount->isLength() && !amount->getFloatValue()) {
        if (side == CSSValueRight || side == CSSValueBottom)
            amount = cssValuePool().createValue(100, CSSPrimitiveValue::CSS_PERCENTAGE);
        else
            amount = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENTAGE);
        side = defaultSide;
    }

    return cssValuePool().createValue(Pair::create(cssValuePool().createValue(side), amount.release(), Pair::KeepIdenticalValues));
}
Exemplo n.º 11
0
void HTMLElementStack::pushHTMLBodyElement(PassRefPtrWillBeRawPtr<HTMLStackItem> item)
{
    ASSERT(item->hasTagName(HTMLNames::bodyTag));
    ASSERT(!m_bodyElement);
    m_bodyElement = item->element();
    pushCommon(item);
}
void SpellCheckRequester::enqueueRequest(PassRefPtrWillBeRawPtr<SpellCheckRequest> request)
{
    ASSERT(request);
    bool continuation = false;
    if (!m_requestQueue.isEmpty()) {
        RefPtrWillBeRawPtr<SpellCheckRequest> lastRequest = m_requestQueue.last();
        // It's a continuation if the number of the last request got incremented in the new one and
        // both apply to the same editable.
        continuation = request->rootEditableElement() == lastRequest->rootEditableElement()
            && request->requestNumber() == lastRequest->requestNumber() + 1;
    }

    // Spellcheck requests for chunks of text in the same element should not overwrite each other.
    if (!continuation) {
        for (auto& requestQueue : m_requestQueue) {
            if (request->rootEditableElement() != requestQueue->rootEditableElement())
                continue;

            requestQueue = request;
            return;
        }
    }

    m_requestQueue.append(request);
}
Exemplo n.º 13
0
void HTMLElementStack::insertAbove(PassRefPtrWillBeRawPtr<HTMLStackItem> item, ElementRecord* recordBelow)
{
    ASSERT(item);
    ASSERT(recordBelow);
    ASSERT(m_top);
    ASSERT(!item->hasTagName(htmlTag));
    ASSERT(!item->hasTagName(headTag));
    ASSERT(!item->hasTagName(bodyTag));
    ASSERT(m_rootNode);
    if (recordBelow == m_top) {
        push(item);
        return;
    }

    for (ElementRecord* recordAbove = m_top.get(); recordAbove; recordAbove = recordAbove->next()) {
        if (recordAbove->next() != recordBelow)
            continue;

        m_stackDepth++;
        recordAbove->setNext(adoptPtrWillBeNoop(new ElementRecord(item, recordAbove->releaseNext())));
        recordAbove->next()->element()->beginParsingChildren();
        return;
    }
    ASSERT_NOT_REACHED();
}
Exemplo n.º 14
0
v8::Handle<v8::Object> CustomElementWrapper<ElementType, WrapperType>::wrap(PassRefPtrWillBeRawPtr<ElementType> element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementType* element, v8::Handle<v8::Object> creationContext, v8::Isolate*))
{
    ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty());

    // FIXME: creationContext.IsEmpty() should never happen. Remove
    // this when callers (like InspectorController::inspect) are fixed
    // to never pass an empty creation context.
    v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCurrentContext() : creationContext->CreationContext();

    if (!element->isUpgradedCustomElement() || DOMWrapperWorld::world(context).isIsolatedWorld())
        return createUpgradeCandidateWrapper(element.get(), creationContext, isolate, createSpecificWrapper);

    V8PerContextData* perContextData = V8PerContextData::from(context);
    if (!perContextData)
        return v8::Handle<v8::Object>();

    CustomElementBinding* binding = perContextData->customElementBinding(element->customElementDefinition());
    v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, binding->wrapperType(), element.get(), isolate);
    if (wrapper.IsEmpty())
        return v8::Handle<v8::Object>();

    wrapper->SetPrototype(binding->prototype());

    V8DOMWrapper::associateObjectWithWrapper<WrapperType>(element, binding->wrapperType(), wrapper, isolate, WrapperConfiguration::Dependent);
    return wrapper;
}
Exemplo n.º 15
0
void FontFace::initCSSFontFace(Document* document, PassRefPtrWillBeRawPtr<CSSValue> src)
{
    m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get());
    if (m_error)
        return;

    // Each item in the src property's list is a single CSSFontFaceSource. Put them all into a CSSFontFace.
    ASSERT(src);
    ASSERT(src->isValueList());
    CSSValueList* srcList = toCSSValueList(src.get());
    int srcLength = srcList->length();

    bool foundSVGFont = false;

    for (int i = 0; i < srcLength; i++) {
        // An item in the list either specifies a string (local font name) or a URL (remote font to download).
        CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i));
        OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr;

#if ENABLE(SVG_FONTS)
        foundSVGFont = item->isSVGFontFaceSrc() || item->svgFontFaceElement();
#endif
        if (!item->isLocal()) {
            Settings* settings = document ? document->frame() ? document->frame()->settings() : 0 : 0;
            bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
            if (allowDownloading && item->isSupportedFormat() && document) {
                FontResource* fetched = item->fetch(document);
                if (fetched) {
                    FontLoader* fontLoader = document->styleEngine()->fontSelector()->fontLoader();

#if ENABLE(SVG_FONTS)
                    if (foundSVGFont) {
                        source = adoptPtrWillBeNoop(new SVGRemoteFontFaceSource(item->resource(), fetched, fontLoader));
                    } else
#endif
                    {
                        source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fetched, fontLoader));
                    }
                }
            }
        } else {
#if ENABLE(SVG_FONTS)
            if (item->svgFontFaceElement()) {
                RefPtrWillBeRawPtr<SVGFontFaceElement> fontfaceElement = item->svgFontFaceElement();
                // SVGFontFaceSource assumes that it is the case where <font-face> element resides in the same document.
                // We put a RELEASE_ASSERT here as it will cause UAF if the assumption is false.
                RELEASE_ASSERT(fontfaceElement->inDocument());
                RELEASE_ASSERT(fontfaceElement->document() == document);
                source = adoptPtrWillBeNoop(new SVGFontFaceSource(fontfaceElement.get()));
            } else
#endif
            {
                source = adoptPtrWillBeNoop(new LocalFontFaceSource(item->resource()));
            }
        }

        if (source)
            m_cssFontFace->addSource(source.release());
    }
}
v8::Handle<v8::Object> V8TestInterfaceDocument::createWrapper(PassRefPtrWillBeRawPtr<TestInterfaceDocument> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    ASSERT(impl);
    ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceDocument>(impl.get(), isolate));
    if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
        const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
        // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
        // the same object de-ref functions, though, so use that as the basis of the check.
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
    }

    if (LocalFrame* frame = impl->frame()) {
        if (frame->script().initializeMainWorld()) {
            // initializeMainWorld may have created a wrapper for the object, retry from the start.
            v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<V8TestInterfaceDocument>(impl.get(), isolate);
            if (!wrapper.IsEmpty())
                return wrapper;
        }
    }
    v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
    if (UNLIKELY(wrapper.IsEmpty()))
        return wrapper;

    installPerContextEnabledProperties(wrapper, impl.get(), isolate);
    V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceDocument>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
    return wrapper;
}
TextCheckingParagraph::TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> checkingRange, PassRefPtrWillBeRawPtr<Range> paragraphRange)
    : m_checkingRange(checkingRange.get())
    , m_paragraphRange(paragraphRange.get())
    , m_checkingStart(-1)
    , m_checkingEnd(-1)
    , m_checkingLength(-1)
{
}
Exemplo n.º 18
0
void HTMLElementStack::push(PassRefPtrWillBeRawPtr<HTMLStackItem> item)
{
    ASSERT(!item->hasTagName(htmlTag));
    ASSERT(!item->hasTagName(headTag));
    ASSERT(!item->hasTagName(bodyTag));
    ASSERT(m_rootNode);
    pushCommon(item);
}
Exemplo n.º 19
0
void ProcessingInstruction::setCSSStyleSheet(PassRefPtrWillBeRawPtr<CSSStyleSheet> sheet)
{
    ASSERT(!resource());
    ASSERT(!m_loading);
    m_sheet = sheet;
    sheet->setTitle(m_title);
    sheet->setDisabled(m_alternate);
}
Exemplo n.º 20
0
void SpellCheckerClientImpl::requestCheckingOfString(PassRefPtrWillBeRawPtr<TextCheckingRequest> request)
{
    if (m_webView->spellCheckClient()) {
        const String& text = request->data().text();
        const Vector<uint32_t>& markers = request->data().markers();
        const Vector<unsigned>& markerOffsets = request->data().offsets();
        m_webView->spellCheckClient()->requestCheckingOfText(text, markers, markerOffsets, new WebTextCheckingCompletionImpl(request));
    }
}
void IDBDatabase::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event)
{
    ASSERT(!m_contextStopped);
    ASSERT(executionContext());
    EventQueue* eventQueue = executionContext()->eventQueue();
    event->setTarget(this);
    eventQueue->enqueueEvent(event.get());
    m_enqueuedEvents.append(event);
}
Exemplo n.º 22
0
void WorkerConsole::reportMessageToConsole(PassRefPtrWillBeRawPtr<ConsoleMessage> consoleMessage)
{
    if (RefPtrWillBeRawPtr<ScriptCallStack> callStack = consoleMessage->callStack()) {
        const ScriptCallFrame& lastCaller = callStack->at(0);
        consoleMessage->setURL(lastCaller.sourceURL());
        consoleMessage->setLineNumber(lastCaller.lineNumber());
    }
    m_scope->addConsoleMessage(consoleMessage);
}
Exemplo n.º 23
0
bool EventTarget::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event)
{
    event->setTarget(this);
    event->setCurrentTarget(this);
    event->setEventPhase(Event::AT_TARGET);
    bool defaultWasNotPrevented = fireEventListeners(event.get());
    event->setEventPhase(0);
    return defaultWasNotPrevented;
}
bool ServiceWorkerGlobalScope::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event)
{
    m_eventNestingLevel++;
    bool result = WorkerGlobalScope::dispatchEventInternal(event.get());
    if (event->interfaceName() == EventNames::ErrorEvent && m_eventNestingLevel == 2)
        m_hadErrorInTopLevelEventHandler = true;
    m_eventNestingLevel--;
    return result;
}
Exemplo n.º 25
0
void CueTimeline::addCueInternal(PassRefPtrWillBeRawPtr<TextTrackCue> cue)
{
    // Negative duration cues need be treated in the interval tree as
    // zero-length cues.
    double endTime = std::max(cue->startTime(), cue->endTime());

    CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get());
    if (!m_cueTree.contains(interval))
        m_cueTree.add(interval);
}
Exemplo n.º 26
0
    static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> create(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> rightSide, CalcOperator op)
    {
        ASSERT(leftSide->category() != CalcOther && rightSide->category() != CalcOther);

        CalculationCategory newCategory = determineCategory(*leftSide, *rightSide, op);
        if (newCategory == CalcOther)
            return nullptr;

        return adoptRefWillBeNoop(new CSSCalcBinaryOperation(leftSide, rightSide, op, newCategory));
    }
Exemplo n.º 27
0
void FontFace::loadWithCallback(PassRefPtrWillBeRawPtr<LoadFontCallback> callback, ExecutionContext* context)
{
    loadInternal(context);
    if (m_status == Loaded)
        callback->notifyLoaded(this);
    else if (m_status == Error)
        callback->notifyError(this);
    else
        m_callbacks.append(callback);
}
Exemplo n.º 28
0
 PassRefPtrWillBeRawPtr<AnimationEffect> makeAnimationEffect(CSSPropertyID id, PassRefPtrWillBeRawPtr<AnimatableValue> value)
 {
     AnimatableValueKeyframeVector keyframes(2);
     keyframes[0] = AnimatableValueKeyframe::create();
     keyframes[0]->setOffset(0.0);
     keyframes[0]->setPropertyValue(id, value.get());
     keyframes[1] = AnimatableValueKeyframe::create();
     keyframes[1]->setOffset(1.0);
     keyframes[1]->setPropertyValue(id, value.get());
     return AnimatableValueKeyframeEffectModel::create(keyframes);
 }
Exemplo n.º 29
0
void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtrWillBeRawPtr<CustomElementRegistrationContext> context, PassRefPtrWillBeRawPtr<Element> element, const CustomElementDescriptor& descriptor)
{
    if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) {
        context->resolve(element.get(), descriptor);
        return;
    }

    HTMLImportLoader* loader = element->document().importLoader();
    OwnPtrWillBeRawPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskResolutionStep::create(context, element, descriptor);
    CustomElementMicrotaskDispatcher::instance().enqueue(loader, step.release());
}
Exemplo n.º 30
0
void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtrWillBeRawPtr<CustomElementRegistrationContext> context, PassRefPtrWillBeRawPtr<Element> element, const CustomElementDescriptor& descriptor)
{
    if (CustomElementProcessingStack::inCallbackDeliveryScope()) {
        context->resolve(element.get(), descriptor);
        return;
    }

    Document& document = element->document();
    OwnPtrWillBeRawPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskResolutionStep::create(context, element, descriptor);
    enqueueMicrotaskStep(document, step.release());
}