PassRefPtr<NodeList> ContainerNode::getElementsByTagName(const AtomicString& localName) { if (localName.isNull()) return 0; if (document().isHTMLDocument()) return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, localName); return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, localName); }
PassRefPtr<NodeList> LabelableElement::labels() { if (!supportLabels()) return 0; return ensureRareData().ensureNodeLists().addCacheWithAtomicName<LabelsNodeList>(*this, starAtom); }
void EventTargetNode::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) { Document* document = this->document(); if (!document->attached()) return; document->addListenerTypeIfNeeded(eventType); RegisteredEventListenerVector& listeners = ensureRareData()->ensureListeners(); // Remove existing identical listener set with identical arguments. // The DOM2 spec says that "duplicate instances are discarded" in this case. removeEventListener(eventType, listener.get(), useCapture); // adding the first one if (listeners.isEmpty() && !inDocument()) document->registerDisconnectedNodeWithEventListeners(this); listeners.append(RegisteredEventListener::create(eventType, listener, useCapture)); updateSVGElementInstancesAfterEventListenerChange(this); #if ENABLE(TOUCH_EVENTS) // Android if (eventType == eventNames().touchstartEvent || eventType == eventNames().touchendEvent || eventType == eventNames().touchmoveEvent || eventType == eventNames().touchcancelEvent) document->addTouchEventListener(this); #endif }
PassRefPtr<NodeList> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName) { if (localName.isNull()) return 0; if (namespaceURI == starAtom) return getElementsByTagName(localName); return ensureRareData().ensureNodeLists().addCacheWithQualifiedName(*this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName); }
ShadowRoot::ShadowRoot(Document* document) : TreeScope(document) { ASSERT(document); // Assume document as parent scope. setParentTreeScope(document); // Shadow tree scopes have the scope pointer point to themselves. // This way, direct children will receive the correct scope pointer. ensureRareData()->setTreeScope(this); }
Path* LayoutSVGShape::nonScalingStrokePath(const Path* path, const AffineTransform& strokeTransform) const { LayoutSVGShapeRareData& rareData = ensureRareData(); if (!rareData.m_cachedNonScalingStrokePath.isEmpty() && strokeTransform == rareData.m_cachedNonScalingStrokeTransform) return &rareData.m_cachedNonScalingStrokePath; rareData.m_cachedNonScalingStrokePath = *path; rareData.m_cachedNonScalingStrokePath.transform(strokeTransform); rareData.m_cachedNonScalingStrokeTransform = strokeTransform; return &rareData.m_cachedNonScalingStrokePath; }
ShadowRoot::ShadowRoot(Document* document) : DocumentFragment(document, CreateShadowRoot) , TreeScope(this) , m_prev(0) , m_next(0) , m_applyAuthorStyles(false) , m_insertionPointAssignedTo(0) { ASSERT(document); // Assume document as parent scope. setParentTreeScope(document); // Shadow tree scopes have the scope pointer point to themselves. // This way, direct children will receive the correct scope pointer. ensureRareData()->setTreeScope(this); }
ShadowRoot::ShadowRoot(Document* document) : DocumentFragment(document, CreateShadowRoot) , TreeScope(this) , m_prev(0) , m_next(0) , m_applyAuthorStyles(false) , m_resetStyleInheritance(false) , m_registeredWithParentShadowRoot(false) , m_insertionPointAssignedTo(0) , m_numberOfShadowElementChildren(0) , m_numberOfContentElementChildren(0) , m_numberOfElementShadowChildren(0) , m_numberOfStyles(0) { ASSERT(document); // Assume document as parent scope. setParentTreeScope(document); // Shadow tree scopes have the scope pointer point to themselves. // This way, direct children will receive the correct scope pointer. ensureRareData()->setTreeScope(this); }
void Element::focus(bool restorePreviousSelection) { Document* doc = document(); if (doc->focusedNode() == this) return; doc->updateLayoutIgnorePendingStylesheets(); if (!supportsFocus()) return; if (Page* page = doc->page()) page->focusController()->setFocusedNode(this, doc->frame()); if (!isFocusable()) { ensureRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(true); return; } cancelFocusAppearanceUpdate(); updateFocusAppearance(restorePreviousSelection); }
inline ElementRareData& Element::ensureElementRareData() { return static_cast<ElementRareData&>(ensureRareData()); }
PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name) { ASSERT(hasTagName(HTMLNames::formTag) || hasTagName(HTMLNames::fieldsetTag)); return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, name); }
PassRefPtr<NodeList> ContainerNode::getElementsByClassName(const AtomicString& classNames) { return ensureRareData().ensureNodeLists().addCacheWithAtomicName<ClassNodeList>(*this, classNames); }
PassRefPtr<NodeList> ContainerNode::getElementsByName(const String& elementName) { return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, elementName); }
Ref<HTMLFormControlsCollection> HTMLFieldSetElement::elements() { return ensureRareData().ensureNodeLists().addCachedCollection<HTMLFormControlsCollection>(*this, FormControls); }