void V8MutationObserver::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate)
{
    MutationObserver* observer = static_cast<MutationObserver*>(object);
    HashSet<Node*> observedNodes = observer->getObservedNodes();
    for (HashSet<Node*>::iterator it = observedNodes.begin(); it != observedNodes.end(); ++it) {
        v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqueRootForGC(*it, isolate)));
        isolate->SetReferenceFromGroup(id, wrapper);
    }
}
void V8MutationObserver::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* scriptWrappable, const v8::Persistent<v8::Object>& wrapper)
{
    MutationObserver* observer = scriptWrappable->toImpl<MutationObserver>();
    HeapHashSet<Member<Node>> observedNodes = observer->getObservedNodes();
    for (HeapHashSet<Member<Node>>::iterator it = observedNodes.begin(); it != observedNodes.end(); ++it) {
        v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqueRootForGC(isolate, *it)));
        isolate->SetReferenceFromGroup(id, wrapper);
    }
}
Exemple #3
0
bool JSMutationObserverOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
    MutationObserver* observer = jsCast<JSMutationObserver*>(handle.get().asCell())->impl();
    HashSet<Node*> observedNodes = observer->getObservedNodes();
    for (HashSet<Node*>::iterator it = observedNodes.begin(); it != observedNodes.end(); ++it) {
        if (visitor.containsOpaqueRoot(root(*it)))
            return true;
    }
    return false;
}
void MutationObserverInterestGroup::enqueueMutationRecord(PassRefPtr<MutationRecord> prpMutation)
{
    RefPtr<MutationRecord> mutation = prpMutation;
    RefPtr<MutationRecord> mutationWithNullOldValue = nullptr;
    for (HashMap<RawPtr<MutationObserver>, MutationRecordDeliveryOptions>::iterator iter = m_observers.begin(); iter != m_observers.end(); ++iter) {
        MutationObserver* observer = iter->key;
        if (hasOldValue(iter->value)) {
            observer->enqueueMutationRecord(mutation);
            continue;
        }
        if (!mutationWithNullOldValue) {
            if (mutation->oldValue().isNull())
                mutationWithNullOldValue = mutation;
            else
                mutationWithNullOldValue = MutationRecord::createWithNullOldValue(mutation).get();
        }
        observer->enqueueMutationRecord(mutationWithNullOldValue);
    }
}
void MutationObserverInterestGroup::enqueueMutationRecord(PassRefPtrWillBeRawPtr<MutationRecord> prpMutation)
{
    RefPtrWillBeRawPtr<MutationRecord> mutation = prpMutation;
    RefPtrWillBeRawPtr<MutationRecord> mutationWithNullOldValue = nullptr;
    for (auto& iter : m_observers) {
        MutationObserver* observer = iter.key;
        if (hasOldValue(iter.value)) {
            observer->enqueueMutationRecord(mutation);
            continue;
        }
        if (!mutationWithNullOldValue) {
            if (mutation->oldValue().isNull())
                mutationWithNullOldValue = mutation;
            else
                mutationWithNullOldValue = MutationRecord::createWithNullOldValue(mutation).get();
        }
        observer->enqueueMutationRecord(mutationWithNullOldValue);
    }
}