Title: [106757] trunk/Source/WebCore
Revision
106757
Author
kl...@webkit.org
Date
2012-02-05 01:26:05 -0800 (Sun, 05 Feb 2012)

Log Message

Remove mapped vs non-mapped attribute distinction.
<http://webkit.org/b/77827>

Reviewed by Antti Koivisto.

Removed the isMappedAttribute flag from Attribute as it no longer serves
a practical purpose. Previously, StyledElement would generate mapped
attributes and plain Element would generate non-mapped ones.

The distinction is now made much more clearly by dividing the work between
Element's and StyledElement's attributeChanged() methods. The only thing
that StyledElement wants to do in addition to what Element does is
calling parseMappedAttribute() (which we'll rename in a later patch.)

* dom/Attribute.cpp:
(WebCore::Attribute::clone):
* dom/Attribute.h:
(WebCore::Attribute::create):
(WebCore::Attribute::Attribute):
(Attribute):
* dom/Document.cpp:
(WebCore::Document::createAttributeNS):
* dom/Element.cpp:
(WebCore::Element::attributeChanged):
* dom/Element.h:
(Element):
* dom/Node.cpp:
(WebCore::Node::dumpStatistics):
* dom/StyledElement.cpp:
(WebCore::StyledElement::attributeChanged):
(WebCore::StyledElement::parseMappedAttribute):
* dom/StyledElement.h:
(StyledElement):
* html/parser/HTMLConstructionSite.cpp:
(WebCore):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::attributesForIsindexInput):
* html/parser/TextDocumentParser.cpp:
(WebCore::TextDocumentParser::insertFakePreElement):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::getPresentationAttribute):
* xml/parser/MarkupTokenBase.h:
(WebCore::::initializeAttributes):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106756 => 106757)


--- trunk/Source/WebCore/ChangeLog	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/ChangeLog	2012-02-05 09:26:05 UTC (rev 106757)
@@ -1,5 +1,51 @@
 2012-02-05  Andreas Kling  <awesomekl...@apple.com>
 
+        Remove mapped vs non-mapped attribute distinction.
+        <http://webkit.org/b/77827>
+
+        Reviewed by Antti Koivisto.
+
+        Removed the isMappedAttribute flag from Attribute as it no longer serves
+        a practical purpose. Previously, StyledElement would generate mapped
+        attributes and plain Element would generate non-mapped ones.
+
+        The distinction is now made much more clearly by dividing the work between
+        Element's and StyledElement's attributeChanged() methods. The only thing
+        that StyledElement wants to do in addition to what Element does is
+        calling parseMappedAttribute() (which we'll rename in a later patch.)
+
+        * dom/Attribute.cpp:
+        (WebCore::Attribute::clone):
+        * dom/Attribute.h:
+        (WebCore::Attribute::create):
+        (WebCore::Attribute::Attribute):
+        (Attribute):
+        * dom/Document.cpp:
+        (WebCore::Document::createAttributeNS):
+        * dom/Element.cpp:
+        (WebCore::Element::attributeChanged):
+        * dom/Element.h:
+        (Element):
+        * dom/Node.cpp:
+        (WebCore::Node::dumpStatistics):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::attributeChanged):
+        (WebCore::StyledElement::parseMappedAttribute):
+        * dom/StyledElement.h:
+        (StyledElement):
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore):
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::attributesForIsindexInput):
+        * html/parser/TextDocumentParser.cpp:
+        (WebCore::TextDocumentParser::insertFakePreElement):
+        * svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::getPresentationAttribute):
+        * xml/parser/MarkupTokenBase.h:
+        (WebCore::::initializeAttributes):
+
+2012-02-05  Andreas Kling  <awesomekl...@apple.com>
+
         Kill CSSMappedAttributeDeclaration.
         <http://webkit.org/b/77820>
 

Modified: trunk/Source/WebCore/dom/Attribute.cpp (106756 => 106757)


--- trunk/Source/WebCore/dom/Attribute.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/Attribute.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -40,7 +40,7 @@
 
 PassRefPtr<Attribute> Attribute::clone() const
 {
-    return adoptRef(new Attribute(m_name, m_value, m_isMappedAttribute));
+    return adoptRef(new Attribute(m_name, m_value));
 }
 
 Attr* Attribute::attr() const

Modified: trunk/Source/WebCore/dom/Attribute.h (106756 => 106757)


--- trunk/Source/WebCore/dom/Attribute.h	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/Attribute.h	2012-02-05 09:26:05 UTC (rev 106757)
@@ -41,16 +41,12 @@
 public:
     static PassRefPtr<Attribute> create(const QualifiedName& name, const AtomicString& value)
     {
-        return adoptRef(new Attribute(name, value, false));
+        return adoptRef(new Attribute(name, value));
     }
-    static PassRefPtr<Attribute> createMapped(const QualifiedName& name, const AtomicString& value)
+    static PassRefPtr<Attribute> create(const AtomicString& name, const AtomicString& value)
     {
-        return adoptRef(new Attribute(name, value, true));
+        return adoptRef(new Attribute(name, value));
     }
-    static PassRefPtr<Attribute> createMapped(const AtomicString& name, const AtomicString& value)
-    {
-        return adoptRef(new Attribute(name, value, true));
-    }
 
     const AtomicString& value() const { return m_value; }
     const AtomicString& prefix() const { return m_name.prefix(); }
@@ -75,20 +71,16 @@
     // elements may have placed the Attribute in a hash by name.
     void parserSetName(const QualifiedName& name) { m_name = name; }
 
-    bool isMappedAttribute() { return m_isMappedAttribute; }
-
 private:
-    Attribute(const QualifiedName& name, const AtomicString& value, bool isMappedAttribute)
-        : m_isMappedAttribute(isMappedAttribute)
-        , m_hasAttr(false)
+    Attribute(const QualifiedName& name, const AtomicString& value)
+        : m_hasAttr(false)
         , m_name(name)
         , m_value(value)
     {
     }
 
-    Attribute(const AtomicString& name, const AtomicString& value, bool isMappedAttribute)
-        : m_isMappedAttribute(isMappedAttribute)
-        , m_hasAttr(false)
+    Attribute(const AtomicString& name, const AtomicString& value)
+        : m_hasAttr(false)
         , m_name(nullAtom, name, nullAtom)
         , m_value(value)
     {
@@ -97,8 +89,7 @@
     void bindAttr(Attr*);
     void unbindAttr(Attr*);
 
-    // These booleans will go into the spare 32-bits of padding from RefCounted in 64-bit.
-    bool m_isMappedAttribute;
+    // This boolean will go into the spare 32-bits of padding from RefCounted in 64-bit.
     bool m_hasAttr;
     
     QualifiedName m_name;

Modified: trunk/Source/WebCore/dom/Document.cpp (106756 => 106757)


--- trunk/Source/WebCore/dom/Document.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -4335,9 +4335,7 @@
         return 0;
     }
 
-    // FIXME: Assume this is a mapped attribute, since createAttribute isn't namespace-aware.  There's no harm to XML
-    // documents if we're wrong.
-    return Attr::create(0, this, Attribute::createMapped(qName, StringImpl::empty()));
+    return Attr::create(0, this, Attribute::create(qName, StringImpl::empty()));
 }
 
 #if ENABLE(SVG)

Modified: trunk/Source/WebCore/dom/Element.cpp (106756 => 106757)


--- trunk/Source/WebCore/dom/Element.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -659,6 +659,9 @@
 {
     if (isIdAttributeName(attr->name()))
         idAttributeChanged(attr);
+    else if (attr->name() == HTMLNames::nameAttr)
+        setHasName(!attr->isNull());
+
     recalcStyleIfNeededAfterAttributeChanged(attr);
     updateAfterAttributeChanged(attr);
 }

Modified: trunk/Source/WebCore/dom/Element.h (106756 => 106757)


--- trunk/Source/WebCore/dom/Element.h	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/Element.h	2012-02-05 09:26:05 UTC (rev 106757)
@@ -383,6 +383,8 @@
     
     PassRefPtr<RenderStyle> styleForRenderer();
 
+    PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
+
 protected:
     Element(const QualifiedName& tagName, Document* document, ConstructionType type)
         : ContainerNode(document, type)
@@ -422,8 +424,7 @@
     virtual bool childTypeAllowed(NodeType) const;
 
     void setAttributeInternal(size_t index, const QualifiedName&, const AtomicString& value);
-    virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
-    
+
 #ifndef NDEBUG
     virtual void formatForDebugger(char* buffer, unsigned length) const;
 #endif

Modified: trunk/Source/WebCore/dom/Node.cpp (106756 => 106757)


--- trunk/Source/WebCore/dom/Node.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -159,8 +159,6 @@
     HashMap<String, size_t> perTagCount;
 
     size_t attributes = 0;
-    size_t mappedAttributes = 0;
-    size_t mappedAttributesWithStyleDecl = 0;
     size_t attributesWithAttr = 0;
     size_t attrMaps = 0;
 
@@ -188,11 +186,6 @@
                         Attribute* attr = attrMap->attributeItem(i);
                         if (attr->attr())
                             ++attributesWithAttr;
-                        if (attr->isMappedAttribute()) {
-                            ++mappedAttributes;
-                            if (attr->style())
-                                ++mappedAttributesWithStyleDecl;
-                        }
                     }
                 }
                 break;
@@ -277,8 +270,6 @@
 
     printf("Attribute Maps:\n");
     printf("  Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes, sizeof(Attribute));
-    printf("  Number of Attributes that are mapped: %zu\n", mappedAttributes);
-    printf("  Number of Attributes with a StyleDeclaration: %zu\n", mappedAttributesWithStyleDecl);
     printf("  Number of Attributes with an Attr: %zu\n", attributesWithAttr);
     printf("  Number of NamedNodeMaps: %zu [%zu]\n", attrMaps, sizeof(NamedNodeMap));
 #endif

Modified: trunk/Source/WebCore/dom/StyledElement.cpp (106756 => 106757)


--- trunk/Source/WebCore/dom/StyledElement.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/StyledElement.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -60,26 +60,12 @@
     destroyInlineStyleDecl();
 }
 
-PassRefPtr<Attribute> StyledElement::createAttribute(const QualifiedName& name, const AtomicString& value)
-{
-    return Attribute::createMapped(name, value);
-}
-
 void StyledElement::attributeChanged(Attribute* attr)
 {
-    if (attr->name() == HTMLNames::nameAttr)
-        setHasName(!attr->isNull());
-
-    if (!attr->isMappedAttribute()) {
-        Element::attributeChanged(attr);
-        return;
-    }
-
     if (!(attr->name() == styleAttr && isSynchronizingStyleAttribute()))
         parseMappedAttribute(attr);
 
-    recalcStyleIfNeededAfterAttributeChanged(attr);
-    updateAfterAttributeChanged(attr);
+    Element::attributeChanged(attr);
 }
 
 void StyledElement::classAttributeChanged(const AtomicString& newClassString)
@@ -106,9 +92,7 @@
 
 void StyledElement::parseMappedAttribute(Attribute* attr)
 {
-    if (isIdAttributeName(attr->name()))
-        idAttributeChanged(attr);
-    else if (attr->name() == classAttr)
+    if (attr->name() == classAttr)
         classAttributeChanged(attr->value());
     else if (attr->name() == styleAttr) {
         if (attr->isNull())

Modified: trunk/Source/WebCore/dom/StyledElement.h (106756 => 106757)


--- trunk/Source/WebCore/dom/StyledElement.h	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/dom/StyledElement.h	2012-02-05 09:26:05 UTC (rev 106757)
@@ -59,8 +59,6 @@
 
     const SpaceSplitString& classNames() const;
 
-    virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
-
 protected:
     StyledElement(const QualifiedName& name, Document* document, ConstructionType type)
         : Element(name, document, type)

Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (106756 => 106757)


--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -432,7 +432,7 @@
     OwnPtr<NamedNodeMap> newAttributes = NamedNodeMap::create();
     for (size_t i = 0; i < attributes->length(); ++i) {
         Attribute* attribute = attributes->attributeItem(i);
-        RefPtr<Attribute> clone = Attribute::createMapped(attribute->name(), attribute->value());
+        RefPtr<Attribute> clone = Attribute::create(attribute->name(), attribute->value());
         newAttributes->addAttribute(clone);
     }
     return newAttributes.release();

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (106756 => 106757)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -571,7 +571,7 @@
         attributes->removeAttribute(promptAttr);
     }
 
-    RefPtr<Attribute> mappedAttribute = Attribute::createMapped(nameAttr, isindexTag.localName());
+    RefPtr<Attribute> mappedAttribute = Attribute::create(nameAttr, isindexTag.localName());
     attributes->insertAttribute(mappedAttribute.release(), false);
     return attributes.release();
 }

Modified: trunk/Source/WebCore/html/parser/TextDocumentParser.cpp (106756 => 106757)


--- trunk/Source/WebCore/html/parser/TextDocumentParser.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/html/parser/TextDocumentParser.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -60,7 +60,7 @@
     // sending fake bytes through the front-end of the parser to avoid
     // distrubing the line/column number calculations.
 
-    RefPtr<Attribute> styleAttribute = Attribute::createMapped("style", "word-wrap: break-word; white-space: pre-wrap;");
+    RefPtr<Attribute> styleAttribute = Attribute::create("style", "word-wrap: break-word; white-space: pre-wrap;");
     OwnPtr<NamedNodeMap> attributes = NamedNodeMap::create();
     attributes->insertAttribute(styleAttribute.release(), false);
     AtomicHTMLToken fakePre(HTMLTokenTypes::StartTag, preTag.localName(), attributes.release());

Modified: trunk/Source/WebCore/svg/SVGStyledElement.cpp (106756 => 106757)


--- trunk/Source/WebCore/svg/SVGStyledElement.cpp	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/svg/SVGStyledElement.cpp	2012-02-05 09:26:05 UTC (rev 106757)
@@ -411,7 +411,7 @@
 
     QualifiedName attributeName(nullAtom, name, nullAtom);
     Attribute* attr = attributeMap()->getAttributeItem(attributeName);
-    if (!attr || !attr->isMappedAttribute())
+    if (!attr)
         return 0;
 
     RefPtr<StylePropertySet> style = StylePropertySet::create();

Modified: trunk/Source/WebCore/xml/parser/MarkupTokenBase.h (106756 => 106757)


--- trunk/Source/WebCore/xml/parser/MarkupTokenBase.h	2012-02-05 08:29:38 UTC (rev 106756)
+++ trunk/Source/WebCore/xml/parser/MarkupTokenBase.h	2012-02-05 09:26:05 UTC (rev 106757)
@@ -541,7 +541,7 @@
         ASSERT(attribute.m_valueRange.m_end);
 
         String value(attribute.m_value.data(), attribute.m_value.size());
-        m_attributes->insertAttribute(Attribute::createMapped(nameForAttribute(attribute), value), false);
+        m_attributes->insertAttribute(Attribute::create(nameForAttribute(attribute), value), false);
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to