Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/DocumentType.cpp ('k') | Source/core/dom/ElementData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 const Attribute* existingAttribute = attributeItem(index); 967 const Attribute* existingAttribute = attributeItem(index);
968 QualifiedName existingAttributeName = existingAttribute->name(); 968 QualifiedName existingAttributeName = existingAttribute->name();
969 969
970 if (!inSynchronizationOfLazyAttribute) 970 if (!inSynchronizationOfLazyAttribute)
971 willModifyAttribute(existingAttributeName, existingAttribute->value(), n ewValue); 971 willModifyAttribute(existingAttributeName, existingAttribute->value(), n ewValue);
972 972
973 if (newValue != existingAttribute->value()) { 973 if (newValue != existingAttribute->value()) {
974 // If there is an Attr node hooked to this attribute, the Attr::setValue () call below 974 // If there is an Attr node hooked to this attribute, the Attr::setValue () call below
975 // will write into the ElementData. 975 // will write into the ElementData.
976 // FIXME: Refactor this so it makes some sense. 976 // FIXME: Refactor this so it makes some sense.
977 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? 0 : attrI fExists(existingAttributeName)) 977 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? nullptr : attrIfExists(existingAttributeName))
978 attrNode->setValue(newValue); 978 attrNode->setValue(newValue);
979 else 979 else
980 ensureUniqueElementData()->attributeItem(index)->setValue(newValue); 980 ensureUniqueElementData()->attributeItem(index)->setValue(newValue);
981 } 981 }
982 982
983 if (!inSynchronizationOfLazyAttribute) 983 if (!inSynchronizationOfLazyAttribute)
984 didModifyAttribute(existingAttributeName, newValue); 984 didModifyAttribute(existingAttributeName, newValue);
985 } 985 }
986 986
987 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode) 987 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode)
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& exceptionState) 1736 PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& exceptionState)
1737 { 1737 {
1738 if (alwaysCreateUserAgentShadowRoot()) 1738 if (alwaysCreateUserAgentShadowRoot())
1739 ensureUserAgentShadowRoot(); 1739 ensureUserAgentShadowRoot();
1740 1740
1741 // Some elements make assumptions about what kind of renderers they allow 1741 // Some elements make assumptions about what kind of renderers they allow
1742 // as children so we can't allow author shadows on them for now. An override 1742 // as children so we can't allow author shadows on them for now. An override
1743 // flag is provided for testing how author shadows interact on these element s. 1743 // flag is provided for testing how author shadows interact on these element s.
1744 if (!areAuthorShadowsAllowed() && !RuntimeEnabledFeatures::authorShadowDOMFo rAnyElementEnabled()) { 1744 if (!areAuthorShadowsAllowed() && !RuntimeEnabledFeatures::authorShadowDOMFo rAnyElementEnabled()) {
1745 exceptionState.throwDOMException(HierarchyRequestError, "Author-created shadow roots are disabled for this element."); 1745 exceptionState.throwDOMException(HierarchyRequestError, "Author-created shadow roots are disabled for this element.");
1746 return 0; 1746 return nullptr;
1747 } 1747 }
1748 1748
1749 return PassRefPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this, ShadowRoot ::AuthorShadowRoot)); 1749 return PassRefPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this, ShadowRoot ::AuthorShadowRoot));
1750 } 1750 }
1751 1751
1752 ShadowRoot* Element::shadowRoot() const 1752 ShadowRoot* Element::shadowRoot() const
1753 { 1753 {
1754 ElementShadow* elementShadow = shadow(); 1754 ElementShadow* elementShadow = shadow();
1755 if (!elementShadow) 1755 if (!elementShadow)
1756 return 0; 1756 return 0;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 const Vector<RefPtr<Attr> >& Element::attrNodeList() 1939 const Vector<RefPtr<Attr> >& Element::attrNodeList()
1940 { 1940 {
1941 ASSERT(hasSyntheticAttrChildNodes()); 1941 ASSERT(hasSyntheticAttrChildNodes());
1942 return *attrNodeListForElement(this); 1942 return *attrNodeListForElement(this);
1943 } 1943 }
1944 1944
1945 PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& excep tionState) 1945 PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& excep tionState)
1946 { 1946 {
1947 if (!attrNode) { 1947 if (!attrNode) {
1948 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Attr")); 1948 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Attr"));
1949 return 0; 1949 return nullptr;
1950 } 1950 }
1951 1951
1952 RefPtr<Attr> oldAttrNode = attrIfExists(attrNode->qualifiedName()); 1952 RefPtr<Attr> oldAttrNode = attrIfExists(attrNode->qualifiedName());
1953 if (oldAttrNode.get() == attrNode) 1953 if (oldAttrNode.get() == attrNode)
1954 return attrNode; // This Attr is already attached to the element. 1954 return attrNode; // This Attr is already attached to the element.
1955 1955
1956 // InUseAttributeError: Raised if node is an Attr that is already an attribu te of another Element object. 1956 // InUseAttributeError: Raised if node is an Attr that is already an attribu te of another Element object.
1957 // The DOM user must explicitly clone Attr nodes to re-use them in other ele ments. 1957 // The DOM user must explicitly clone Attr nodes to re-use them in other ele ments.
1958 if (attrNode->ownerElement()) { 1958 if (attrNode->ownerElement()) {
1959 exceptionState.throwDOMException(InUseAttributeError, "The node provided is an attribute node that is already an attribute of another Element; attribute nodes must be explicitly cloned."); 1959 exceptionState.throwDOMException(InUseAttributeError, "The node provided is an attribute node that is already an attribute of another Element; attribute nodes must be explicitly cloned.");
1960 return 0; 1960 return nullptr;
1961 } 1961 }
1962 1962
1963 synchronizeAllAttributes(); 1963 synchronizeAllAttributes();
1964 UniqueElementData* elementData = ensureUniqueElementData(); 1964 UniqueElementData* elementData = ensureUniqueElementData();
1965 1965
1966 size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase()); 1966 size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase());
1967 if (index != kNotFound) { 1967 if (index != kNotFound) {
1968 if (oldAttrNode) 1968 if (oldAttrNode)
1969 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a ttributeItem(index)->value()); 1969 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a ttributeItem(index)->value());
1970 else 1970 else
1971 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el ementData->attributeItem(index)->value()); 1971 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el ementData->attributeItem(index)->value());
1972 } 1972 }
1973 1973
1974 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No tInSynchronizationOfLazyAttribute); 1974 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No tInSynchronizationOfLazyAttribute);
1975 1975
1976 attrNode->attachToElement(this); 1976 attrNode->attachToElement(this);
1977 treeScope().adoptIfNeeded(*attrNode); 1977 treeScope().adoptIfNeeded(*attrNode);
1978 ensureAttrNodeListForElement(this).append(attrNode); 1978 ensureAttrNodeListForElement(this).append(attrNode);
1979 1979
1980 return oldAttrNode.release(); 1980 return oldAttrNode.release();
1981 } 1981 }
1982 1982
1983 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& except ionState) 1983 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& except ionState)
1984 { 1984 {
1985 if (!attr) { 1985 if (!attr) {
1986 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Attr")); 1986 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Attr"));
1987 return 0; 1987 return nullptr;
1988 } 1988 }
1989 if (attr->ownerElement() != this) { 1989 if (attr->ownerElement() != this) {
1990 exceptionState.throwDOMException(NotFoundError, "The node provided is ow ned by another element."); 1990 exceptionState.throwDOMException(NotFoundError, "The node provided is ow ned by another element.");
1991 return 0; 1991 return nullptr;
1992 } 1992 }
1993 1993
1994 ASSERT(document() == attr->document()); 1994 ASSERT(document() == attr->document());
1995 1995
1996 synchronizeAttribute(attr->qualifiedName()); 1996 synchronizeAttribute(attr->qualifiedName());
1997 1997
1998 size_t index = elementData()->getAttrIndex(attr); 1998 size_t index = elementData()->getAttrIndex(attr);
1999 if (index == kNotFound) { 1999 if (index == kNotFound) {
2000 exceptionState.throwDOMException(NotFoundError, "The attribute was not f ound on this element."); 2000 exceptionState.throwDOMException(NotFoundError, "The attribute was not f ound on this element.");
2001 return 0; 2001 return nullptr;
2002 } 2002 }
2003 2003
2004 RefPtr<Attr> guard(attr); 2004 RefPtr<Attr> guard(attr);
2005 detachAttrNodeAtIndex(attr, index); 2005 detachAttrNodeAtIndex(attr, index);
2006 return guard.release(); 2006 return guard.release();
2007 } 2007 }
2008 2008
2009 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) 2009 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState)
2010 { 2010 {
2011 AtomicString prefix, localName; 2011 AtomicString prefix, localName;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 } 2081 }
2082 2082
2083 void Element::removeAttributeNS(const AtomicString& namespaceURI, const AtomicSt ring& localName) 2083 void Element::removeAttributeNS(const AtomicString& namespaceURI, const AtomicSt ring& localName)
2084 { 2084 {
2085 removeAttribute(QualifiedName(nullAtom, localName, namespaceURI)); 2085 removeAttribute(QualifiedName(nullAtom, localName, namespaceURI));
2086 } 2086 }
2087 2087
2088 PassRefPtr<Attr> Element::getAttributeNode(const AtomicString& localName) 2088 PassRefPtr<Attr> Element::getAttributeNode(const AtomicString& localName)
2089 { 2089 {
2090 if (!elementData()) 2090 if (!elementData())
2091 return 0; 2091 return nullptr;
2092 synchronizeAttribute(localName); 2092 synchronizeAttribute(localName);
2093 const Attribute* attribute = elementData()->getAttributeItem(localName, shou ldIgnoreAttributeCase()); 2093 const Attribute* attribute = elementData()->getAttributeItem(localName, shou ldIgnoreAttributeCase());
2094 if (!attribute) 2094 if (!attribute)
2095 return 0; 2095 return nullptr;
2096 return ensureAttr(attribute->name()); 2096 return ensureAttr(attribute->name());
2097 } 2097 }
2098 2098
2099 PassRefPtr<Attr> Element::getAttributeNodeNS(const AtomicString& namespaceURI, c onst AtomicString& localName) 2099 PassRefPtr<Attr> Element::getAttributeNodeNS(const AtomicString& namespaceURI, c onst AtomicString& localName)
2100 { 2100 {
2101 if (!elementData()) 2101 if (!elementData())
2102 return 0; 2102 return nullptr;
2103 QualifiedName qName(nullAtom, localName, namespaceURI); 2103 QualifiedName qName(nullAtom, localName, namespaceURI);
2104 synchronizeAttribute(qName); 2104 synchronizeAttribute(qName);
2105 const Attribute* attribute = elementData()->getAttributeItem(qName); 2105 const Attribute* attribute = elementData()->getAttributeItem(qName);
2106 if (!attribute) 2106 if (!attribute)
2107 return 0; 2107 return nullptr;
2108 return ensureAttr(attribute->name()); 2108 return ensureAttr(attribute->name());
2109 } 2109 }
2110 2110
2111 bool Element::hasAttribute(const AtomicString& localName) const 2111 bool Element::hasAttribute(const AtomicString& localName) const
2112 { 2112 {
2113 if (!elementData()) 2113 if (!elementData())
2114 return false; 2114 return false;
2115 synchronizeAttribute(localName); 2115 synchronizeAttribute(localName);
2116 return elementData()->getAttributeItem(shouldIgnoreAttributeCase() ? localNa me.lower() : localName, false); 2116 return elementData()->getAttributeItem(shouldIgnoreAttributeCase() ? localNa me.lower() : localName, false);
2117 } 2117 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 } 2188 }
2189 2189
2190 void Element::blur() 2190 void Element::blur()
2191 { 2191 {
2192 cancelFocusAppearanceUpdate(); 2192 cancelFocusAppearanceUpdate();
2193 if (treeScope().adjustedFocusedElement() == this) { 2193 if (treeScope().adjustedFocusedElement() == this) {
2194 Document& doc = document(); 2194 Document& doc = document();
2195 if (doc.page()) 2195 if (doc.page())
2196 doc.page()->focusController().setFocusedElement(0, doc.frame()); 2196 doc.page()->focusController().setFocusedElement(0, doc.frame());
2197 else 2197 else
2198 doc.setFocusedElement(0); 2198 doc.setFocusedElement(nullptr);
2199 } 2199 }
2200 } 2200 }
2201 2201
2202 bool Element::isFocusable() const 2202 bool Element::isFocusable() const
2203 { 2203 {
2204 return inDocument() && supportsFocus() && !isInert() && rendererIsFocusable( ); 2204 return inDocument() && supportsFocus() && !isInert() && rendererIsFocusable( );
2205 } 2205 }
2206 2206
2207 bool Element::isKeyboardFocusable() const 2207 bool Element::isKeyboardFocusable() const
2208 { 2208 {
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 // PseudoElement styles hang off their parent element's style so if we n eeded 2711 // PseudoElement styles hang off their parent element's style so if we n eeded
2712 // a style recalc we should Force one on the pseudo. 2712 // a style recalc we should Force one on the pseudo.
2713 // FIXME: We should figure out the right text sibling to pass. 2713 // FIXME: We should figure out the right text sibling to pass.
2714 element->recalcStyle(change == UpdatePseudoElements ? Force : change); 2714 element->recalcStyle(change == UpdatePseudoElements ? Force : change);
2715 2715
2716 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed 2716 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed
2717 // is false, otherwise we could continously create and destroy PseudoEle ments 2717 // is false, otherwise we could continously create and destroy PseudoEle ments
2718 // when RenderObject::isChildAllowed on our parent returns false for the 2718 // when RenderObject::isChildAllowed on our parent returns false for the
2719 // PseudoElement's renderer for each style recalc. 2719 // PseudoElement's renderer for each style recalc.
2720 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) 2720 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId)))
2721 elementRareData()->setPseudoElement(pseudoId, 0); 2721 elementRareData()->setPseudoElement(pseudoId, nullptr);
2722 } else if (change >= UpdatePseudoElements) { 2722 } else if (change >= UpdatePseudoElements) {
2723 createPseudoElementIfNeeded(pseudoId); 2723 createPseudoElementIfNeeded(pseudoId);
2724 } 2724 }
2725 } 2725 }
2726 2726
2727 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) 2727 void Element::createPseudoElementIfNeeded(PseudoId pseudoId)
2728 { 2728 {
2729 if (isPseudoElement()) 2729 if (isPseudoElement())
2730 return; 2730 return;
2731 2731
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
3135 { 3135 {
3136 if (size.isZero() && !hasRareData()) 3136 if (size.isZero() && !hasRareData())
3137 return; 3137 return;
3138 ensureElementRareData().setSavedLayerScrollOffset(size); 3138 ensureElementRareData().setSavedLayerScrollOffset(size);
3139 } 3139 }
3140 3140
3141 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name) 3141 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name)
3142 { 3142 {
3143 if (AttrNodeList* attrNodeList = attrNodeListForElement(this)) 3143 if (AttrNodeList* attrNodeList = attrNodeListForElement(this))
3144 return findAttrNodeInList(*attrNodeList, name); 3144 return findAttrNodeInList(*attrNodeList, name);
3145 return 0; 3145 return nullptr;
3146 } 3146 }
3147 3147
3148 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name) 3148 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name)
3149 { 3149 {
3150 AttrNodeList& attrNodeList = ensureAttrNodeListForElement(this); 3150 AttrNodeList& attrNodeList = ensureAttrNodeListForElement(this);
3151 RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name); 3151 RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name);
3152 if (!attrNode) { 3152 if (!attrNode) {
3153 attrNode = Attr::create(*this, name); 3153 attrNode = Attr::create(*this, name);
3154 treeScope().adoptIfNeeded(*attrNode); 3154 treeScope().adoptIfNeeded(*attrNode);
3155 attrNodeList.append(attrNode); 3155 attrNodeList.append(attrNode);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 3195
3196 void Element::didRecalcStyle(StyleRecalcChange) 3196 void Element::didRecalcStyle(StyleRecalcChange)
3197 { 3197 {
3198 ASSERT(hasCustomStyleCallbacks()); 3198 ASSERT(hasCustomStyleCallbacks());
3199 } 3199 }
3200 3200
3201 3201
3202 PassRefPtr<RenderStyle> Element::customStyleForRenderer() 3202 PassRefPtr<RenderStyle> Element::customStyleForRenderer()
3203 { 3203 {
3204 ASSERT(hasCustomStyleCallbacks()); 3204 ASSERT(hasCustomStyleCallbacks());
3205 return 0; 3205 return nullptr;
3206 } 3206 }
3207 3207
3208 void Element::cloneAttributesFromElement(const Element& other) 3208 void Element::cloneAttributesFromElement(const Element& other)
3209 { 3209 {
3210 if (hasSyntheticAttrChildNodes()) 3210 if (hasSyntheticAttrChildNodes())
3211 detachAllAttrNodesFromElement(); 3211 detachAllAttrNodesFromElement();
3212 3212
3213 other.synchronizeAllAttributes(); 3213 other.synchronizeAllAttributes();
3214 if (!other.m_elementData) { 3214 if (!other.m_elementData) {
3215 m_elementData.clear(); 3215 m_elementData.clear();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
3504 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3504 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3505 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3505 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3506 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3506 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3507 return false; 3507 return false;
3508 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3508 if (FullscreenElementStack::isActiveFullScreenElement(this))
3509 return false; 3509 return false;
3510 return true; 3510 return true;
3511 } 3511 }
3512 3512
3513 } // namespace WebCore 3513 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/DocumentType.cpp ('k') | Source/core/dom/ElementData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698