Exemplo n.º 1
0
// ActiveScriptWrappable
bool RTCDataChannel::hasPendingActivity() const
{
    if (m_stopped)
        return false;

    // A RTCDataChannel object must not be garbage collected if its
    // * readyState is connecting and at least one event listener is registered
    //   for open events, message events, error events, or close events.
    // * readyState is open and at least one event listener is registered for
    //   message events, error events, or close events.
    // * readyState is closing and at least one event listener is registered for
    //   error events, or close events.
    // * underlying data transport is established and data is queued to be
    //   transmitted.
    bool hasValidListeners = false;
    switch (m_readyState) {
    case ReadyStateConnecting:
        hasValidListeners |= hasEventListeners(EventTypeNames::open);
        // fallthrough intended
    case ReadyStateOpen:
        hasValidListeners |= hasEventListeners(EventTypeNames::message);
        // fallthrough intended
    case ReadyStateClosing:
        hasValidListeners |= hasEventListeners(EventTypeNames::error) || hasEventListeners(EventTypeNames::close);
        break;
    default:
        break;
    }

    if (hasValidListeners)
        return true;

    return m_readyState != ReadyStateClosed && bufferedAmount() > 0;
}
Exemplo n.º 2
0
void XMLHttpRequest::callReadyStateChangeListener()
{
    if (!scriptExecutionContext())
        return;

#if ENABLE(INSPECTOR)
    InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
    bool callTimelineAgentOnReadyStateChange = timelineAgent && hasEventListeners(eventNames().readystatechangeEvent);
    if (callTimelineAgentOnReadyStateChange)
        timelineAgent->willChangeXHRReadyState(m_url.string(), m_state);
#endif

    m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);

#if ENABLE(INSPECTOR)
    if (callTimelineAgentOnReadyStateChange && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
        timelineAgent->didChangeXHRReadyState();
#endif

    if (m_state == DONE && !m_error) {
#if ENABLE(INSPECTOR)
        timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
        bool callTimelineAgentOnLoad = timelineAgent && hasEventListeners(eventNames().loadEvent);
        if (callTimelineAgentOnLoad)
            timelineAgent->willLoadXHR(m_url.string());
#endif

        m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));

#if ENABLE(INSPECTOR)
        if (callTimelineAgentOnLoad && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
            timelineAgent->didLoadXHR();
#endif
    }
}
Exemplo n.º 3
0
bool IDBDatabase::hasPendingActivity() const
{
    ASSERT(&originThread() == &Thread::current() || mayBeGCThread());

    if (m_closedInServer || isContextStopped())
        return false;

    if (!m_activeTransactions.isEmpty() || !m_committingTransactions.isEmpty() || !m_abortingTransactions.isEmpty())
        return true;

    return hasEventListeners(m_eventNames.abortEvent) || hasEventListeners(m_eventNames.errorEvent) || hasEventListeners(m_eventNames.versionchangeEvent);
}
Exemplo n.º 4
0
bool IDBDatabase::hasPendingActivity() const
{
    ASSERT(currentThread() == originThreadID());

    if (m_closedInServer)
        return false;

    if (!m_activeTransactions.isEmpty() || !m_committingTransactions.isEmpty() || !m_abortingTransactions.isEmpty())
        return true;

    return hasEventListeners(eventNames().abortEvent) || hasEventListeners(eventNames().errorEvent) || hasEventListeners(eventNames().versionchangeEvent);
}
Exemplo n.º 5
0
bool HTMLElement::supportsSpatialNavigationFocus() const
{
    // This function checks whether the element satisfies the extended criteria
    // for the element to be focusable, introduced by spatial navigation feature,
    // i.e. checks if click or keyboard event handler is specified.
    // This is the way to make it possible to navigate to (focus) elements
    // which web designer meant for being active (made them respond to click events).

    if (!document().settings() || !document().settings()->spatialNavigationEnabled())
        return false;
    return hasEventListeners(EventTypeNames::click)
        || hasEventListeners(EventTypeNames::keydown)
        || hasEventListeners(EventTypeNames::keypress)
        || hasEventListeners(EventTypeNames::keyup);
}
Exemplo n.º 6
0
ImageCapture::~ImageCapture()
{
    DCHECK(!hasEventListeners());
    // There should be no more outstanding |m_serviceRequests| at this point
    // since each of them holds a persistent handle to this object.
    DCHECK(m_serviceRequests.isEmpty());
}
Exemplo n.º 7
0
bool AnimationPlayer::update(TimingUpdateReason reason)
{
    if (!m_timeline)
        return false;

    updateCurrentTimingState(reason);
    m_outdated = false;

    if (m_content) {
        double inheritedTime = isNull(m_timeline->currentTimeInternal()) ? nullValue() : currentTimeInternal();
        m_content->updateInheritedTime(inheritedTime, reason);
    }

    if (finished() && !m_finished) {
        if (reason == TimingUpdateForAnimationFrame && hasStartTime()) {
            const AtomicString& eventType = EventTypeNames::finish;
            if (executionContext() && hasEventListeners(eventType)) {
                m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, currentTime(), timeline()->currentTime());
                m_pendingFinishedEvent->setTarget(this);
                m_pendingFinishedEvent->setCurrentTarget(this);
                m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFinishedEvent);
            }
            m_finished = true;
        }
    }
    ASSERT(!m_outdated);
    return !m_finished || !finished();
}
Exemplo n.º 8
0
bool AnimationPlayer::update(TimingUpdateReason reason)
{
    if (!m_timeline)
        return false;

    PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending);

    m_outdated = false;
    bool idle = playStateInternal() == Idle;

    if (m_content) {
        double inheritedTime = idle || isNull(m_timeline->currentTimeInternal()) ? nullValue() : currentTimeInternal();
        // Special case for end-exclusivity when playing backwards.
        if (inheritedTime == 0 && m_playbackRate < 0)
            inheritedTime = -1;
        m_content->updateInheritedTime(inheritedTime, reason);
    }

    if ((idle || finished()) && !m_finished) {
        if (reason == TimingUpdateForAnimationFrame && (idle || hasStartTime())) {
            const AtomicString& eventType = EventTypeNames::finish;
            if (executionContext() && hasEventListeners(eventType)) {
                double eventCurrentTime = currentTimeInternal() * 1000;
                m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, eventCurrentTime, timeline()->currentTime());
                m_pendingFinishedEvent->setTarget(this);
                m_pendingFinishedEvent->setCurrentTarget(this);
                m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFinishedEvent);
            }
            m_finished = true;
        }
    }
    ASSERT(!m_outdated);
    return !m_finished;
}
bool AudioScheduledSourceNode::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
{
    bool success = AudioNode::removeEventListener(eventType, listener, useCapture);
    if (success && eventType == eventNames().endedEvent)
        m_hasEndedListener = hasEventListeners(eventNames().endedEvent);
    return success;
}
Exemplo n.º 10
0
bool ScriptProcessorNode::removeEventListener(const AtomicString& eventType, EventListener& listener, bool useCapture)
{
    bool success = AudioNode::removeEventListener(eventType, listener, useCapture);
    if (success && eventType == eventNames().audioprocessEvent)
        m_hasAudioProcessListener = hasEventListeners(eventNames().audioprocessEvent);
    return success;
}
Exemplo n.º 11
0
void HTMLAnchorElement::parseAttribute(Attribute* attr)
{
    if (attr->name() == hrefAttr) {
        bool wasLink = isLink();
        setIsLink(!attr->isNull());
        if (wasLink != isLink())
            setNeedsStyleRecalc();
        if (isLink()) {
            String parsedURL = stripLeadingAndTrailingHTMLSpaces(attr->value());
            if (document()->isDNSPrefetchEnabled()) {
                if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") || parsedURL.startsWith("//"))
                    prefetchDNS(document()->completeURL(parsedURL).host());
            }
            if (document()->page() && !document()->page()->javaScriptURLsAreAllowed() && protocolIsJavaScript(parsedURL)) {
                clearIsLink();
                // FIXME: This is horribly factored.
                if (Attribute* hrefAttribute = getAttributeItem(hrefAttr))
                    hrefAttribute->setValue(nullAtom);
            }
#ifdef ARTEMIS
            else if(protocolIsJavaScript(parsedURL) && !hasEventListeners(eventNames().clickEvent)) {
                // Don't set the onclick event handler if it already has one.
                setAttributeEventListener(eventNames().clickEvent, createAttributeEventListener(this, attr));
            }
#endif

        }
        invalidateCachedVisitedLinkHash();
    } else if (attr->name() == nameAttr || attr->name() == titleAttr) {
        // Do nothing.
    } else if (attr->name() == relAttr)
        setRel(attr->value());
    else
        HTMLElement::parseAttribute(attr);
}
bool AudioScheduledSourceNode::addEventListener(const AtomicString& eventType, RefPtr<EventListener>&& listener, bool useCapture)
{
    bool success = AudioNode::addEventListener(eventType, WTFMove(listener), useCapture);
    if (success && eventType == eventNames().endedEvent)
        m_hasEndedListener = hasEventListeners(eventNames().endedEvent);
    return success;
}
Exemplo n.º 13
0
bool NetworkInformation::hasPendingActivity() const
{
    ASSERT(m_contextStopped || m_observing == hasEventListeners());

    // Prevent collection of this object when there are active listeners.
    return m_observing;
}
Exemplo n.º 14
0
bool ScriptProcessorNode::addEventListener(const AtomicString& eventType, Ref<EventListener>&& listener, bool useCapture)
{
    bool success = AudioNode::addEventListener(eventType, WTFMove(listener), useCapture);
    if (success && eventType == eventNames().audioprocessEvent)
        m_hasAudioProcessListener = hasEventListeners(eventNames().audioprocessEvent);
    return success;
}
Exemplo n.º 15
0
bool NetworkInformation::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
{
    if (!EventTargetWithInlineData::removeEventListener(eventType, listener, useCapture))
        return false;
    if (!hasEventListeners())
        stopObserving();
    return true;
}
Exemplo n.º 16
0
void MediaDevices::removedEventListener(
    const AtomicString& eventType,
    const RegisteredEventListener& registeredListener) {
  EventTargetWithInlineData::removedEventListener(eventType,
                                                  registeredListener);
  if (!hasEventListeners())
    stopObserving();
}
Exemplo n.º 17
0
bool PresentationRequest::hasPendingActivity() const
{
    if (!getExecutionContext() || getExecutionContext()->activeDOMObjectsAreStopped())
        return false;

    // Prevents garbage collecting of this object when not hold by another
    // object but still has listeners registered.
    return hasEventListeners();
}
Exemplo n.º 18
0
bool ScriptProcessorNode::hasPendingActivity() const {
  // To prevent the node from leaking after the context is closed.
  if (context()->isContextClosed())
    return false;

  // If |onaudioprocess| event handler is defined, the node should not be
  // GCed even if it is out of scope.
  if (hasEventListeners(EventTypeNames::audioprocess))
    return true;

  return false;
}
Exemplo n.º 19
0
bool Animation::update(TimingUpdateReason reason)
{
    if (!m_timeline)
        return false;

    PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending);

    clearOutdated();
    bool idle = playStateInternal() == Idle;

    if (m_content) {
        double inheritedTime = idle || isNull(m_timeline->currentTimeInternal())
            ? nullValue()
            : currentTimeInternal();

        if (!isNull(inheritedTime)) {
            double timeForClipping = m_held && (!limited(inheritedTime) || isNull(m_startTime))
                // Use hold time when there is no start time.
                ? inheritedTime
                // Use calculated current time when the animation is limited.
                : calculateCurrentTime();
            if (clipped(timeForClipping))
                inheritedTime = nullValue();
        }
        // Special case for end-exclusivity when playing backwards.
        if (inheritedTime == 0 && m_playbackRate < 0)
            inheritedTime = -1;
        m_content->updateInheritedTime(inheritedTime, reason);
    }

    if ((idle || limited()) && !m_finished) {
        if (reason == TimingUpdateForAnimationFrame && (idle || hasStartTime())) {
            if (idle) {
                // TODO(dstockwell): Fire the cancel event.
            } else {
                const AtomicString& eventType = EventTypeNames::finish;
                if (executionContext() && hasEventListeners(eventType)) {
                    double eventCurrentTime = currentTimeInternal() * 1000;
                    m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, eventCurrentTime, timeline()->currentTime());
                    m_pendingFinishedEvent->setTarget(this);
                    m_pendingFinishedEvent->setCurrentTarget(this);
                    m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFinishedEvent);
                }
            }
            m_finished = true;
        }
    }
    ASSERT(!m_outdated);
    return !m_finished || std::isfinite(timeToEffectChange());
}
Exemplo n.º 20
0
bool MediaStreamTrack::hasPendingActivity() const {
    // If 'ended' listeners exist and the object hasn't yet reached
    // that state, keep the object alive.
    //
    // An otherwise unreachable MediaStreamTrack object in an non-ended
    // state will otherwise indirectly be transitioned to the 'ended' state
    // while finalizing m_component. Which dispatches an 'ended' event,
    // referring to this object as the target. If this object is then GCed
    // at the same time, v8 objects will retain (wrapper) references to
    // this dead MediaStreamTrack object. Bad.
    //
    // Hence insisting on keeping this object alive until the 'ended'
    // state has been reached & handled.
    return !ended() && hasEventListeners(EventTypeNames::ended);
}
Exemplo n.º 21
0
bool BatteryManager::hasPendingActivity() const
{
    // Prevent V8 from garbage collecting the wrapper object if there are
    // event listeners attached to it.
    return m_state == Resolved && hasEventListeners();
}
Exemplo n.º 22
0
bool LegacyDatabase::hasPendingActivity() const
{
    // The script wrapper must not be collected before the object is closed or
    // we can't fire a "versionchange" event to let script manually close the connection.
    return !m_closePending && hasEventListeners() && !m_contextStopped;
}
Exemplo n.º 23
0
bool MediaDevices::hasPendingActivity() const {
  DCHECK(m_stopped || m_observing == hasEventListeners());
  return m_observing;
}
Exemplo n.º 24
0
void MediaDevices::removeAllEventListeners() {
  EventTargetWithInlineData::removeAllEventListeners();
  DCHECK(!hasEventListeners());
  stopObserving();
}
Exemplo n.º 25
0
bool ImageCapture::hasPendingActivity() const
{
    return hasEventListeners();
}
Exemplo n.º 26
0
bool AnimationPlayer::hasPendingActivity() const
{
    return m_pendingFinishedEvent || (!m_finished && hasEventListeners(EventTypeNames::finish));
}
Exemplo n.º 27
0
void ImageCapture::contextDestroyed()
{
    removeAllEventListeners();
    m_serviceRequests.clear();
    DCHECK(!hasEventListeners());
}
Exemplo n.º 28
0
void NetworkInformation::removeAllEventListeners()
{
    EventTargetWithInlineData::removeAllEventListeners();
    ASSERT(!hasEventListeners());
    stopObserving();
}
Exemplo n.º 29
0
bool Sensor::hasPendingActivity() const {
  if (m_state == Sensor::SensorState::Idle ||
      m_state == Sensor::SensorState::Errored)
    return false;
  return hasEventListeners();
}
Exemplo n.º 30
0
bool Sensor::hasPendingActivity() const {
  if (m_state == Sensor::SensorState::IDLE ||
      m_state == Sensor::SensorState::ERRORED)
    return false;
  return hasEventListeners();
}