Modified: trunk/Source/WebCore/ChangeLog (233544 => 233545)
--- trunk/Source/WebCore/ChangeLog 2018-07-05 22:20:08 UTC (rev 233544)
+++ trunk/Source/WebCore/ChangeLog 2018-07-05 22:20:39 UTC (rev 233545)
@@ -1,3 +1,26 @@
+2018-07-05 Chris Dumez <[email protected]>
+
+ Update Element API to use qualifiedName instead of name/localName where applicable
+ https://bugs.webkit.org/show_bug.cgi?id=187347
+
+ Reviewed by Darin Adler.
+
+ Update Element API to use qualifiedName instead of name/localName where applicable. Naming
+ is now consistent with the IDL and the specification:
+ - https://dom.spec.whatwg.org/#element
+
+ Our implementation properly deals with qualified names already, even though the parameters
+ were named localName.
+
+ * dom/Element.cpp:
+ (WebCore::Element::getAttribute const):
+ (WebCore::Element::toggleAttribute):
+ (WebCore::Element::setAttribute):
+ (WebCore::Element::removeAttribute):
+ (WebCore::Element::getAttributeNode):
+ (WebCore::Element::hasAttribute const):
+ * dom/Element.h:
+
2018-07-04 Ryosuke Niwa <[email protected]>
Youtube video pages crash after a couple of minutes
Modified: trunk/Source/WebCore/dom/Element.cpp (233544 => 233545)
--- trunk/Source/WebCore/dom/Element.cpp 2018-07-05 22:20:08 UTC (rev 233544)
+++ trunk/Source/WebCore/dom/Element.cpp 2018-07-05 22:20:39 UTC (rev 233545)
@@ -1257,12 +1257,12 @@
return IntRect();
}
-const AtomicString& Element::getAttribute(const AtomicString& localName) const
+const AtomicString& Element::getAttribute(const AtomicString& qualifiedName) const
{
if (!elementData())
return nullAtom();
- synchronizeAttribute(localName);
- if (const Attribute* attribute = elementData()->findAttributeByName(localName, shouldIgnoreAttributeCase(*this)))
+ synchronizeAttribute(qualifiedName);
+ if (const Attribute* attribute = elementData()->findAttributeByName(qualifiedName, shouldIgnoreAttributeCase(*this)))
return attribute->value();
return nullAtom();
}
@@ -1273,18 +1273,18 @@
}
// https://dom.spec.whatwg.org/#dom-element-toggleattribute
-ExceptionOr<bool> Element::toggleAttribute(const AtomicString& localName, std::optional<bool> force)
+ExceptionOr<bool> Element::toggleAttribute(const AtomicString& qualifiedName, std::optional<bool> force)
{
- if (!Document::isValidName(localName))
+ if (!Document::isValidName(qualifiedName))
return Exception { InvalidCharacterError };
- synchronizeAttribute(localName);
+ synchronizeAttribute(qualifiedName);
- auto caseAdjustedLocalName = shouldIgnoreAttributeCase(*this) ? localName.convertToASCIILowercase() : localName;
- unsigned index = elementData() ? elementData()->findAttributeIndexByName(caseAdjustedLocalName, false) : ElementData::attributeNotFound;
+ auto caseAdjustedQualifiedName = shouldIgnoreAttributeCase(*this) ? qualifiedName.convertToASCIILowercase() : qualifiedName;
+ unsigned index = elementData() ? elementData()->findAttributeIndexByName(caseAdjustedQualifiedName, false) : ElementData::attributeNotFound;
if (index == ElementData::attributeNotFound) {
if (!force || *force) {
- setAttributeInternal(index, QualifiedName { nullAtom(), caseAdjustedLocalName, nullAtom() }, emptyString(), NotInSynchronizationOfLazyAttribute);
+ setAttributeInternal(index, QualifiedName { nullAtom(), caseAdjustedQualifiedName, nullAtom() }, emptyString(), NotInSynchronizationOfLazyAttribute);
return true;
}
return false;
@@ -1297,15 +1297,15 @@
return true;
}
-ExceptionOr<void> Element::setAttribute(const AtomicString& localName, const AtomicString& value)
+ExceptionOr<void> Element::setAttribute(const AtomicString& qualifiedName, const AtomicString& value)
{
- if (!Document::isValidName(localName))
+ if (!Document::isValidName(qualifiedName))
return Exception { InvalidCharacterError };
- synchronizeAttribute(localName);
- auto caseAdjustedLocalName = shouldIgnoreAttributeCase(*this) ? localName.convertToASCIILowercase() : localName;
- unsigned index = elementData() ? elementData()->findAttributeIndexByName(caseAdjustedLocalName, false) : ElementData::attributeNotFound;
- auto name = index != ElementData::attributeNotFound ? attributeAt(index).name() : QualifiedName { nullAtom(), caseAdjustedLocalName, nullAtom() };
+ synchronizeAttribute(qualifiedName);
+ auto caseAdjustedQualifiedName = shouldIgnoreAttributeCase(*this) ? qualifiedName.convertToASCIILowercase() : qualifiedName;
+ unsigned index = elementData() ? elementData()->findAttributeIndexByName(caseAdjustedQualifiedName, false) : ElementData::attributeNotFound;
+ auto name = index != ElementData::attributeNotFound ? attributeAt(index).name() : QualifiedName { nullAtom(), caseAdjustedQualifiedName, nullAtom() };
setAttributeInternal(index, name, value, NotInSynchronizationOfLazyAttribute);
return { };
@@ -2413,15 +2413,15 @@
didAddAttribute(name, value);
}
-bool Element::removeAttribute(const AtomicString& name)
+bool Element::removeAttribute(const AtomicString& qualifiedName)
{
if (!elementData())
return false;
- AtomicString localName = shouldIgnoreAttributeCase(*this) ? name.convertToASCIILowercase() : name;
- unsigned index = elementData()->findAttributeIndexByName(localName, false);
+ AtomicString caseAdjustedQualifiedName = shouldIgnoreAttributeCase(*this) ? qualifiedName.convertToASCIILowercase() : qualifiedName;
+ unsigned index = elementData()->findAttributeIndexByName(caseAdjustedQualifiedName, false);
if (index == ElementData::attributeNotFound) {
- if (UNLIKELY(localName == styleAttr) && elementData()->styleAttributeIsDirty() && is<StyledElement>(*this))
+ if (UNLIKELY(caseAdjustedQualifiedName == styleAttr) && elementData()->styleAttributeIsDirty() && is<StyledElement>(*this))
downcast<StyledElement>(*this).removeAllInlineStyleProperties();
return false;
}
@@ -2435,12 +2435,12 @@
return removeAttribute(QualifiedName(nullAtom(), localName, namespaceURI));
}
-RefPtr<Attr> Element::getAttributeNode(const AtomicString& localName)
+RefPtr<Attr> Element::getAttributeNode(const AtomicString& qualifiedName)
{
if (!elementData())
return nullptr;
- synchronizeAttribute(localName);
- const Attribute* attribute = elementData()->findAttributeByName(localName, shouldIgnoreAttributeCase(*this));
+ synchronizeAttribute(qualifiedName);
+ const Attribute* attribute = elementData()->findAttributeByName(qualifiedName, shouldIgnoreAttributeCase(*this));
if (!attribute)
return nullptr;
return ensureAttr(attribute->name());
@@ -2458,12 +2458,12 @@
return ensureAttr(attribute->name());
}
-bool Element::hasAttribute(const AtomicString& localName) const
+bool Element::hasAttribute(const AtomicString& qualifiedName) const
{
if (!elementData())
return false;
- synchronizeAttribute(localName);
- return elementData()->findAttributeByName(localName, shouldIgnoreAttributeCase(*this));
+ synchronizeAttribute(qualifiedName);
+ return elementData()->findAttributeByName(qualifiedName, shouldIgnoreAttributeCase(*this));
}
bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const
Modified: trunk/Source/WebCore/dom/Element.h (233544 => 233545)
--- trunk/Source/WebCore/dom/Element.h 2018-07-05 22:20:08 UTC (rev 233544)
+++ trunk/Source/WebCore/dom/Element.h 2018-07-05 22:20:39 UTC (rev 233545)
@@ -104,17 +104,17 @@
// in style attribute or one of the SVG animation attributes.
bool hasAttributesWithoutUpdate() const;
- WEBCORE_EXPORT bool hasAttribute(const AtomicString& name) const;
+ WEBCORE_EXPORT bool hasAttribute(const AtomicString& qualifiedName) const;
WEBCORE_EXPORT bool hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
- WEBCORE_EXPORT const AtomicString& getAttribute(const AtomicString& name) const;
+ WEBCORE_EXPORT const AtomicString& getAttribute(const AtomicString& qualifiedName) const;
WEBCORE_EXPORT const AtomicString& getAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
- WEBCORE_EXPORT ExceptionOr<void> setAttribute(const AtomicString& name, const AtomicString& value);
+ WEBCORE_EXPORT ExceptionOr<void> setAttribute(const AtomicString& qualifiedName, const AtomicString& value);
static ExceptionOr<QualifiedName> parseAttributeName(const AtomicString& namespaceURI, const AtomicString& qualifiedName);
WEBCORE_EXPORT ExceptionOr<void> setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value);
- ExceptionOr<bool> toggleAttribute(const AtomicString& name, std::optional<bool> force);
+ ExceptionOr<bool> toggleAttribute(const AtomicString& qualifiedName, std::optional<bool> force);
const AtomicString& getIdAttribute() const;
void setIdAttribute(const AtomicString&);
@@ -185,12 +185,12 @@
// Returns the absolute bounding box translated into screen coordinates.
WEBCORE_EXPORT IntRect screenRect() const;
- WEBCORE_EXPORT bool removeAttribute(const AtomicString& name);
+ WEBCORE_EXPORT bool removeAttribute(const AtomicString& qualifiedName);
WEBCORE_EXPORT bool removeAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName);
Ref<Attr> detachAttribute(unsigned index);
- WEBCORE_EXPORT RefPtr<Attr> getAttributeNode(const AtomicString& name);
+ WEBCORE_EXPORT RefPtr<Attr> getAttributeNode(const AtomicString& qualifiedName);
WEBCORE_EXPORT RefPtr<Attr> getAttributeNodeNS(const AtomicString& namespaceURI, const AtomicString& localName);
WEBCORE_EXPORT ExceptionOr<RefPtr<Attr>> setAttributeNode(Attr&);
WEBCORE_EXPORT ExceptionOr<RefPtr<Attr>> setAttributeNodeNS(Attr&);