Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode& insertionPoint) { if (m_formSetByParser) { m_form = m_formSetByParser; m_formSetByParser = nullptr; m_form->registerImgElement(this); } if (!m_form) { m_form = HTMLFormElement::findClosestFormAncestor(*this); if (m_form) m_form->registerImgElement(this); } // Insert needs to complete first, before we start updating the loader. Loader dispatches events which could result // in callbacks back to this node. Node::InsertionNotificationRequest insertNotificationRequest = HTMLElement::insertedInto(insertionPoint); if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull()) document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); if (is<HTMLPictureElement>(parentNode())) { setPictureElement(&downcast<HTMLPictureElement>(*parentNode())); selectImageSource(); } // If we have been inserted from a renderer-less document, // our loader may have not fetched the image, so do it now. if (insertionPoint.inDocument() && !m_imageLoader.image()) m_imageLoader.updateFromElement(); return insertNotificationRequest; }
void notifyNodeRemovedFromDocument(ContainerNode& insertionPoint, Node& node) { ASSERT(insertionPoint.inDocument()); node.removedFrom(insertionPoint); if (!is<ContainerNode>(node)) return; ChildNodesLazySnapshot snapshot(node); while (RefPtr<Node> child = snapshot.nextNode()) { // If we have been added to the document during this loop, then we // don't want to tell the rest of our children that they've been // removed from the document because they haven't. if (!node.inDocument() && child->parentNode() == &node) notifyNodeRemovedFromDocument(insertionPoint, *child.get()); } if (!is<Element>(node)) return; if (node.document().cssTarget() == &node) node.document().setCSSTarget(nullptr); if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) { if (!node.inDocument() && root->host() == &node) notifyNodeRemovedFromDocument(insertionPoint, *root.get()); } }
Node::InsertionNotificationRequest SVGStyleElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); if (rootParent.inDocument()) m_styleSheetOwner.insertedIntoDocument(document(), *this); return InsertionDone; }
bool DOMSelection::containsNode(Node& node, bool allowPartial) const { if (!m_frame) return false; FrameSelection& selection = m_frame->selection(); if (m_frame->document() != &node.document() || selection.isNone()) return false; Ref<Node> protectedNode(node); RefPtr<Range> selectedRange = selection.selection().toNormalizedRange(); ContainerNode* parentNode = node.parentNode(); if (!parentNode || !parentNode->inDocument()) return false; unsigned nodeIndex = node.computeNodeIndex(); ExceptionCode ec = 0; bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex, &selectedRange->startContainer(), selectedRange->startOffset(), ec) >= 0 && !ec && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, &selectedRange->endContainer(), selectedRange->endOffset(), ec) <= 0 && !ec; ASSERT(!ec); if (nodeFullySelected) return true; bool nodeFullyUnselected = (Range::compareBoundaryPoints(parentNode, nodeIndex, &selectedRange->endContainer(), selectedRange->endOffset(), ec) > 0 && !ec) || (Range::compareBoundaryPoints(parentNode, nodeIndex + 1, &selectedRange->startContainer(), selectedRange->startOffset(), ec) < 0 && !ec); ASSERT(!ec); if (nodeFullyUnselected) return false; return allowPartial || node.isTextNode(); }
Node::InsertionNotificationRequest HTMLFrameElementBase::insertedInto(ContainerNode& insertionPoint) { HTMLFrameOwnerElement::insertedInto(insertionPoint); if (insertionPoint.inDocument()) return InsertionShouldCallDidNotifySubtreeInsertions; return InsertionDone; }
Node::InsertionNotificationRequest SVGSMILElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); if (!rootParent.inDocument()) return InsertionDone; // Verify we are not in <use> instance tree. ASSERT(!isInShadowTree()); setAttributeName(constructQualifiedName(this, fastGetAttribute(SVGNames::attributeNameAttr))); SVGSVGElement* owner = ownerSVGElement(); if (!owner) return InsertionDone; m_timeContainer = owner->timeContainer(); ASSERT(m_timeContainer); m_timeContainer->setDocumentOrderIndexesDirty(); // "If no attribute is present, the default begin value (an offset-value of 0) must be evaluated." if (!fastHasAttribute(SVGNames::beginAttr)) m_beginTimes.append(SMILTimeWithOrigin()); if (m_isWaitingForFirstInterval) resolveFirstInterval(); if (m_timeContainer) m_timeContainer->notifyIntervalsChanged(); buildPendingResource(); return InsertionDone; }
Node::InsertionNotificationRequest SVGMPathElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); if (rootParent.inDocument()) buildPendingResource(); return InsertionDone; }
Node::InsertionNotificationRequest MathMLMathElement::insertedInto(ContainerNode& insertionPoint) { // There are sibling rules in the MathML default style. if (insertionPoint.inDocument()) document().styleSheetCollection().setUsesSiblingRulesOverride(true); return MathMLInlineContainerElement::insertedInto(insertionPoint); }
void SVGMPathElement::removedFrom(ContainerNode& rootParent) { SVGElement::removedFrom(rootParent); notifyParentOfPathChange(&rootParent); if (rootParent.inDocument()) clearResourceReferences(); }
Node::InsertionNotificationRequest SVGTRefElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); if (rootParent.inDocument()) return InsertionShouldCallFinishedInsertingSubtree; return InsertionDone; }
void HTMLStyleElement::removedFrom(ContainerNode& insertionPoint) { HTMLElement::removedFrom(insertionPoint); if (insertionPoint.inDocument()) m_styleSheetOwner.removedFromDocument(document(), *this); }
Node::InsertionNotificationRequest SVGMPathElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); if (rootParent.inDocument()) return InsertionShouldCallDidNotifySubtreeInsertions; return InsertionDone; }
Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); if (rootParent.inDocument()) SVGExternalResourcesRequired::insertedIntoDocument(this); return shouldCallFinishedInsertingSubtree(rootParent) ? InsertionShouldCallFinishedInsertingSubtree : InsertionDone; }
Node::InsertionNotificationRequest HTMLMapElement::insertedInto(ContainerNode& insertionPoint) { Node::InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPoint); if (insertionPoint.inDocument()) treeScope().addImageMap(*this); return request; }
Node::InsertionNotificationRequest HTMLFormElement::insertedInto(ContainerNode& insertionPoint) { HTMLElement::insertedInto(insertionPoint); if (insertionPoint.inDocument()) document().didAssociateFormControl(this); return InsertionDone; }
Node::InsertionNotificationRequest HTMLBaseElement::insertedInto(ContainerNode& insertionPoint) { HTMLElement::insertedInto(insertionPoint); if (insertionPoint.inDocument()) document().processBaseElement(); return InsertionDone; }
void HTMLFrameSetElement::removedFrom(ContainerNode& insertionPoint) { HTMLElement::removedFrom(insertionPoint); if (insertionPoint.inDocument()) { if (Frame* frame = document().frame()) frame->loader().client().dispatchDidBecomeFrameset(document().isFrameSet()); } }
Node::InsertionNotificationRequest HTMLStyleElement::insertedInto(ContainerNode& insertionPoint) { HTMLElement::insertedInto(insertionPoint); if (insertionPoint.inDocument()) m_styleSheetOwner.insertedIntoDocument(document(), *this); return InsertionDone; }
Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); ScriptElement::insertedInto(rootParent); if (rootParent.inDocument()) SVGExternalResourcesRequired::insertedIntoDocument(this); return InsertionDone; }
void notifyNodeInsertedIntoDocument(ContainerNode& insertionPoint, Node& node, NodeVector& postInsertionNotificationTargets) { ASSERT(insertionPoint.inDocument()); if (node.insertedInto(insertionPoint) == Node::InsertionShouldCallFinishedInsertingSubtree) postInsertionNotificationTargets.append(node); if (is<ContainerNode>(node)) notifyDescendantInsertedIntoDocument(insertionPoint, downcast<ContainerNode>(node), postInsertionNotificationTargets); }
Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode& insertionPoint) { bool wasInDocument = inDocument(); DocumentFragment::insertedInto(insertionPoint); if (insertionPoint.inDocument() && !wasInDocument) document().didInsertInDocumentShadowRoot(*this); return InsertionDone; }
void notifyNodeInsertedIntoTree(ContainerNode& insertionPoint, ContainerNode& node, NodeVector& postInsertionNotificationTargets) { NoEventDispatchAssertion assertNoEventDispatch; ASSERT(!insertionPoint.inDocument()); if (node.insertedInto(insertionPoint) == Node::InsertionShouldCallFinishedInsertingSubtree) postInsertionNotificationTargets.append(node); notifyDescendantInsertedIntoTree(insertionPoint, node, postInsertionNotificationTargets); }
Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(ContainerNode& insertionPoint) { CharacterData::insertedInto(insertionPoint); if (!insertionPoint.inDocument()) return InsertionDone; document().styleScope().addStyleSheetCandidateNode(*this, m_createdByParser); checkStyleSheet(); return InsertionDone; }
void FormAssociatedElement::removedFrom(ContainerNode& insertionPoint) { HTMLElement& element = asHTMLElement(); if (insertionPoint.inDocument() && element.fastHasAttribute(formAttr)) m_formAttributeTargetObserver = nullptr; // If the form and element are both in the same tree, preserve the connection to the form. // Otherwise, null out our form and remove ourselves from the form's list of elements. if (m_form && element.highestAncestor() != m_form->highestAncestor()) setForm(0); }
void FormAssociatedElement::insertedInto(ContainerNode& insertionPoint) { resetFormOwner(); if (!insertionPoint.inDocument()) return; HTMLElement& element = asHTMLElement(); if (element.fastHasAttribute(formAttr)) resetFormAttributeTargetObserver(); }
static void notifyDescendantInsertedIntoDocument(ContainerNode& insertionPoint, ContainerNode& node, NodeVector& postInsertionNotificationTargets) { ChildNodesLazySnapshot snapshot(node); while (RefPtr<Node> child = snapshot.nextNode()) { // If we have been removed from the document during this loop, then // we don't want to tell the rest of our children that they've been // inserted into the document because they haven't. if (node.inDocument() && child->parentNode() == &node) notifyNodeInsertedIntoDocument(insertionPoint, *child, postInsertionNotificationTargets); } if (!is<Element>(node)) return; if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) { if (node.inDocument() && root->host() == &node) notifyNodeInsertedIntoDocument(insertionPoint, *root, postInsertionNotificationTargets); } }
Node::InsertionNotificationRequest SVGImageElement::insertedInto(ContainerNode& rootParent) { SVGGraphicsElement::insertedInto(rootParent); if (!rootParent.inDocument()) return InsertionDone; // Update image loader, as soon as we're living in the tree. // We can only resolve base URIs properly, after that! m_imageLoader.updateFromElement(); return InsertionDone; }
Node::InsertionNotificationRequest HTMLFrameSetElement::insertedInto(ContainerNode& insertionPoint) { HTMLElement::insertedInto(insertionPoint); if (insertionPoint.inDocument()) { if (Frame* frame = document().frame()) frame->loader().client().dispatchDidBecomeFrameset(document().isFrameSet()); } return InsertionDone; }
void HTMLImageElement::removedFrom(ContainerNode& insertionPoint) { if (m_form) m_form->removeImgElement(this); if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull()) document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); m_form = nullptr; HTMLElement::removedFrom(insertionPoint); }
Node::InsertionNotificationRequest SVGFontFaceElement::insertedInto(ContainerNode& rootParent) { SVGElement::insertedInto(rootParent); if (!rootParent.inDocument()) { ASSERT(!m_fontElement); return InsertionDone; } document().accessSVGExtensions().registerSVGFontFaceElement(this); rebuildFontFace(); return InsertionDone; }