void AnimationControllerPrivate::addNodeChangeToDispatch(PassRefPtr<Node> node) { ASSERT(!node || (node->document() && !node->document()->inPageCache())); if (!node) return; m_nodeChangesToDispatch.append(node); startUpdateStyleIfNeededDispatcher(); }
XPathNamespace::XPathNamespace(PassRefPtr<Element> ownerElement, const AtomicString& prefix, const AtomicString& uri) : Node(ownerElement->document(), CreateOther) , m_ownerElement(ownerElement) , m_prefix(prefix) , m_uri(uri) { }
v8::Handle<v8::Object> V8TestNode::wrapSlow(PassRefPtr<TestNode> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = V8Proxy::retrieve(impl->document()->frame()); // Enter the node's context and create the wrapper in that context. v8::Handle<v8::Context> context; if (proxy && !proxy->matchesCurrentContext()) { // For performance, we enter the context only if the currently running context // is different from the context that we are about to enter. context = proxy->context(); if (!context.IsEmpty()) context->Enter(); } wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); // Exit the node's context if it was entered. if (!context.IsEmpty()) context->Exit(); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); wrapperHandle.SetWrapperClassId(v8DOMSubtreeClassId); V8DOMWrapper::setJSWrapperForDOMNode(impl, wrapperHandle, isolate); return wrapper; }
void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild) { ASSERT(newChild); ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events). ASSERT(!newChild->isDocumentFragment()); ASSERT(!hasTagName(HTMLNames::templateTag)); if (document() != newChild->document()) document()->adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); Node* last = m_lastChild; { NoEventDispatchAssertion assertNoEventDispatch; // FIXME: This method should take a PassRefPtr. appendChildToContainer(newChild.get(), this); treeScope()->adoptIfNeeded(newChild.get()); } newChild->updateAncestorConnectedSubframeCountForInsertion(); ChildListMutationScope(this).childAdded(newChild.get()); childrenChanged(true, last, 0, 1); ChildNodeInsertionNotifier(this).notify(newChild.get()); }
SetNodeAttributeCommand::SetNodeAttributeCommand(PassRefPtr<Element> element, const QualifiedName& attribute, const String &value) : SimpleEditCommand(element->document()), m_element(element), m_attribute(attribute), m_value(value) { ASSERT(m_element); ASSERT(!m_value.isNull()); }
void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node* nextChild) { ASSERT(newChild); ASSERT(nextChild); ASSERT(nextChild->parentNode() == this); ASSERT(!newChild->isDocumentFragment()); #if ENABLE(TEMPLATE_ELEMENT) ASSERT(!hasTagName(HTMLNames::templateTag)); #endif if (nextChild->previousSibling() == newChild || nextChild == newChild) // nothing to do return; if (&document() != &newChild->document()) document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); insertBeforeCommon(nextChild, newChild.get()); newChild->updateAncestorConnectedSubframeCountForInsertion(); ChildListMutationScope(this).childAdded(newChild.get()); childrenChanged(true, newChild->previousSibling(), nextChild, 1); ChildNodeInsertionNotifier(this).notify(newChild.get()); }
void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild) { ASSERT(newChild); ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events). ASSERT(!newChild->isDocumentFragment()); #if ENABLE(TEMPLATE_ELEMENT) ASSERT(!hasTagName(HTMLNames::templateTag)); #endif if (&document() != &newChild->document()) document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); { NoEventDispatchAssertion assertNoEventDispatch; // FIXME: This method should take a PassRefPtr. appendChildToContainer(newChild.get(), *this); treeScope().adoptIfNeeded(newChild.get()); } newChild->updateAncestorConnectedSubframeCountForInsertion(); ChildListMutationScope(*this).childAdded(*newChild); notifyChildInserted(*newChild, ChildChangeSourceParser); ChildNodeInsertionNotifier(*this).notify(*newChild); newChild->setNeedsStyleRecalc(ReconstructRenderTree); }
PassRefPtr<StaticNodeList> createSelectorNodeList(PassRefPtr<Node> rootNode, CSSSelector* querySelector) { Vector<RefPtr<Node> > nodes; Document* document = rootNode->document(); AtomicString selectorValue = querySelector->m_value; if (!querySelector->next() && querySelector->m_match == CSSSelector::Id && !document->containsMultipleElementsWithId(selectorValue)) { Element* element = document->getElementById(selectorValue); if (element && (rootNode->isDocumentNode() || element->isDescendantOf(rootNode.get()))) nodes.append(element); } else { CSSStyleSelector::SelectorChecker selectorChecker(document, !document->inCompatMode()); for (Node* n = rootNode->firstChild(); n; n = n->traverseNextNode(rootNode.get())) { if (n->isElementNode()) { Element* element = static_cast<Element*>(n); for (CSSSelector* selector = querySelector; selector; selector = selector->next()) { if (selectorChecker.checkSelector(selector, element)) { nodes.append(n); break; } } } } } return StaticNodeList::adopt(nodes); }
RemoveNodeCommand::RemoveNodeCommand(PassRefPtr<Node> node) : SimpleEditCommand(node->document()) , m_node(node) { ASSERT(m_node); ASSERT(m_node->parentNode()); }
void applyCommand(PassRefPtr<EditCommand> command) { DeleteButtonController *deleteButtonController = command->document()->frame()->editor()->deleteButtonController(); deleteButtonController->disable(); command->apply(); deleteButtonController->enable(); }
RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable) : CompositeEditCommand(node->document()) , m_node(node) , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable) { ASSERT(m_node); }
RemoveNodeCommand::RemoveNodeCommand(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable) : SimpleEditCommand(node->document()) , m_node(node) , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable) { ASSERT(m_node); ASSERT(m_node->parentNode()); }
SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand(PassRefPtr<Text> text, int offset) : CompositeEditCommand(text->document()) , m_text(text) , m_offset(offset) { ASSERT(m_text); ASSERT(m_text->length() > 0); }
SplitElementCommand::SplitElementCommand(PassRefPtr<Element> element, PassRefPtr<Node> atChild) : SimpleEditCommand(element->document()) , m_element2(element) , m_atChild(atChild) { ASSERT(m_element2); ASSERT(m_atChild); ASSERT(m_atChild->parentNode() == m_element2); }
JoinTextNodesCommand::JoinTextNodesCommand(PassRefPtr<Text> text1, PassRefPtr<Text> text2) : SimpleEditCommand(text1->document()), m_text1(text1), m_text2(text2) { ASSERT(m_text1); ASSERT(m_text2); ASSERT(m_text1->nextSibling() == m_text2); ASSERT(m_text1->length() > 0); ASSERT(m_text2->length() > 0); }
MergeIdenticalElementsCommand::MergeIdenticalElementsCommand(PassRefPtr<Element> first, PassRefPtr<Element> second) : SimpleEditCommand(first->document()) , m_element1(first) , m_element2(second) { ASSERT(m_element1); ASSERT(m_element2); ASSERT(m_element1->nextSibling() == m_element2); }
AppendNodeCommand::AppendNodeCommand(PassRefPtr<ContainerNode> parent, Ref<Node>&& node, EditAction editingAction) : SimpleEditCommand(parent->document(), editingAction) , m_parent(parent) , m_node(WTFMove(node)) { ASSERT(m_parent); ASSERT(!m_node->parentNode()); ASSERT(m_parent->hasEditableStyle() || !m_parent->renderer()); }
DeleteFromTextNodeCommand::DeleteFromTextNodeCommand(PassRefPtr<Text> node, unsigned offset, unsigned count) : SimpleEditCommand(node->document()) , m_node(node) , m_offset(offset) , m_count(count) { ASSERT(m_node); ASSERT(m_offset <= m_node->length()); ASSERT(m_offset + m_count <= m_node->length()); }
InsertIntoTextNodeCommand::InsertIntoTextNodeCommand(PassRefPtr<Text> node, unsigned offset, const String& text) : SimpleEditCommand(node->document()) , m_node(node) , m_offset(offset) , m_text(text) { ASSERT(m_node); ASSERT(m_offset <= m_node->length()); ASSERT(!m_text.isEmpty()); }
void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtr<CustomElementRegistrationContext> context, PassRefPtr<Element> element, const CustomElementDescriptor& descriptor) { if (CustomElementProcessingStack::inCallbackDeliveryScope()) { context->resolve(element.get(), descriptor); return; } Document& document = element->document(); OwnPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskResolutionStep::create(context, element, descriptor); enqueueMicrotaskStep(document, step.release()); }
AppendNodeCommand::AppendNodeCommand(PassRefPtr<Element> parent, PassRefPtr<Node> node) : SimpleEditCommand(parent->document()) , m_parent(parent) , m_node(node) { ASSERT(m_parent); ASSERT(m_node); ASSERT(!m_node->parent()); ASSERT(m_parent->isContentEditable() || !m_parent->attached()); }
AppendNodeCommand::AppendNodeCommand(PassRefPtr<ContainerNode> parent, PassRefPtr<Node> node) : SimpleEditCommand(parent->document()) , m_parent(parent) , m_node(node) { ASSERT(m_parent); ASSERT(m_node); ASSERT(!m_node->parentNode()); ASSERT(m_parent->rendererIsEditable() || !m_parent->attached()); }
void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtr<CustomElementRegistrationContext> context, PassRefPtr<Element> element, const CustomElementDescriptor& descriptor) { if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) { context->resolve(element.get(), descriptor); return; } HTMLImportLoader* loader = element->document().importLoader(); OwnPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskResolutionStep::create(context, element, descriptor); CustomElementMicrotaskDispatcher::instance().enqueue(loader ? loader->firstImport() : 0, step.release()); }
void EventQueue::enqueueOrDispatchScrollEvent(PassRefPtr<Node> target, ScrollEventTargetType targetType) { if (!target->document()->hasListenerType(Document::SCROLL_LISTENER)) return; // Per the W3C CSSOM View Module, scroll events fired at the document should bubble, others should not. bool canBubble = targetType == ScrollEventDocumentTarget; RefPtr<Event> scrollEvent = Event::create(eventNames().scrollEvent, canBubble, false /* non cancelleable */); if (shouldDispatchScrollEventSynchronously(target->document())) { target->dispatchEvent(scrollEvent.release()); return; } if (!m_nodesWithQueuedScrollEvents.add(target.get()).second) return; scrollEvent->setTarget(target); enqueueEvent(scrollEvent.release()); }
InsertNodeBeforeCommand::InsertNodeBeforeCommand(PassRefPtr<Node> insertChild, PassRefPtr<Node> refChild) : SimpleEditCommand(refChild->document()) , m_insertChild(insertChild) , m_refChild(refChild) { ASSERT(m_insertChild); ASSERT(!m_insertChild->parentNode()); ASSERT(m_refChild); ASSERT(m_refChild->parentNode()); ASSERT(m_refChild->parentNode()->isContentEditable() || !m_refChild->parentNode()->attached()); }
void BackForwardList::pushStateItem(PassRefPtr<HistoryItem> newItem) { ASSERT(newItem); ASSERT(newItem->document()); ASSERT(newItem->stateObject()); RefPtr<HistoryItem> current = currentItem(); ASSERT(current); Document* newItemDocument = newItem->document(); while (HistoryItem* item = forwardItem()) { if (item->document() != newItemDocument) break; removeItem(item); } insertItemAfterCurrent(newItem, false); if (!current->document()) { current->setDocument(newItemDocument); current->setStateObject(SerializedScriptValue::create()); } }
InsertNodeBeforeCommand::InsertNodeBeforeCommand(PassRefPtr<Node> insertChild, PassRefPtr<Node> refChild, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable) : SimpleEditCommand(refChild->document()) , m_insertChild(insertChild) , m_refChild(refChild) , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable) { ASSERT(m_insertChild); ASSERT(!m_insertChild->parentNode()); ASSERT(m_refChild); ASSERT(m_refChild->parentNode()); ASSERT(m_refChild->parentNode()->hasEditableStyle() || !m_refChild->parentNode()->attached()); }
SplitTextNodeCommand::SplitTextNodeCommand(PassRefPtr<Text> text, int offset) : SimpleEditCommand(text->document()) , m_text2(text) , m_offset(offset) { // NOTE: Various callers rely on the fact that the original node becomes // the second node (i.e. the new node is inserted before the existing one). // That is not a fundamental dependency (i.e. it could be re-coded), but // rather is based on how this code happens to work. ASSERT(m_text2); ASSERT(m_text2->length() > 0); ASSERT(m_offset > 0); ASSERT(m_offset < m_text2->length()); }
bool FocusController::setFocusedElement(Element* element, PassRefPtr<LocalFrame> newFocusedFrame, FocusType type) { RefPtr<LocalFrame> oldFocusedFrame = focusedFrame(); RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document() : 0; Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0; if (element && oldFocusedElement == element) return true; // FIXME: Might want to disable this check for caretBrowsing if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !relinquishesEditingFocus(oldFocusedElement)) return false; RefPtr<Document> newDocument = nullptr; if (element) newDocument = &element->document(); else if (newFocusedFrame) newDocument = newFocusedFrame->document(); if (newDocument && oldDocument == newDocument && newDocument->focusedElement() == element) return true; if (oldDocument && oldDocument != newDocument) oldDocument->setFocusedElement(nullptr); if (newFocusedFrame && !newFocusedFrame->page()) { setFocusedFrame(nullptr); return false; } setFocusedFrame(newFocusedFrame); // Setting the focused node can result in losing our last reft to node when JS event handlers fire. RefPtr<Element> protect ALLOW_UNUSED = element; if (newDocument) { bool successfullyFocused = newDocument->setFocusedElement(element, type); if (!successfullyFocused) return false; } return true; }
v8::Handle<v8::Object> CustomElementHelpers::createWrapper(PassRefPtr<Element> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper) { ASSERT(impl); // 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(); // The constructor and registered lifecycle callbacks should be visible only from main world. // FIXME: This shouldn't be needed once each custom element has its own FunctionTemplate // https://bugs.webkit.org/show_bug.cgi?id=108138 if (!CustomElementHelpers::isFeatureAllowed(context)) { v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &V8HTMLElement::info, impl.get(), isolate); if (!wrapper.IsEmpty()) V8DOMWrapper::associateObjectWithWrapper(impl, &V8HTMLElement::info, wrapper, isolate, WrapperConfiguration::Dependent); return wrapper; } CustomElementRegistry* registry = impl->document()->registry(); RefPtr<CustomElementDefinition> definition = registry->findFor(impl.get()); if (!definition) return createUpgradeCandidateWrapper(impl, creationContext, isolate, createTypeExtensionUpgradeCandidateWrapper); v8::Handle<v8::Object> prototype = V8PerContextData::from(context)->customElementPrototypes()->get(definition->type()).newLocal(isolate); WrapperTypeInfo* typeInfo = CustomElementHelpers::findWrapperType(prototype); if (!typeInfo) { // FIXME: When can this happen? return v8::Handle<v8::Object>(); } v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, typeInfo, impl.get(), isolate); if (wrapper.IsEmpty()) return v8::Handle<v8::Object>(); wrapper->SetPrototype(prototype); V8DOMWrapper::associateObjectWithWrapper(impl, typeInfo, wrapper, isolate, WrapperConfiguration::Dependent); return wrapper; }