Changeset 106757 in webkit


Ignore:
Timestamp:
Feb 5, 2012 1:26:05 AM (12 years ago)
Author:
kling@webkit.org
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):

Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106756 r106757  
     12012-02-05  Andreas Kling  <awesomekling@apple.com>
     2
     3        Remove mapped vs non-mapped attribute distinction.
     4        <http://webkit.org/b/77827>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Removed the isMappedAttribute flag from Attribute as it no longer serves
     9        a practical purpose. Previously, StyledElement would generate mapped
     10        attributes and plain Element would generate non-mapped ones.
     11
     12        The distinction is now made much more clearly by dividing the work between
     13        Element's and StyledElement's attributeChanged() methods. The only thing
     14        that StyledElement wants to do in addition to what Element does is
     15        calling parseMappedAttribute() (which we'll rename in a later patch.)
     16
     17        * dom/Attribute.cpp:
     18        (WebCore::Attribute::clone):
     19        * dom/Attribute.h:
     20        (WebCore::Attribute::create):
     21        (WebCore::Attribute::Attribute):
     22        (Attribute):
     23        * dom/Document.cpp:
     24        (WebCore::Document::createAttributeNS):
     25        * dom/Element.cpp:
     26        (WebCore::Element::attributeChanged):
     27        * dom/Element.h:
     28        (Element):
     29        * dom/Node.cpp:
     30        (WebCore::Node::dumpStatistics):
     31        * dom/StyledElement.cpp:
     32        (WebCore::StyledElement::attributeChanged):
     33        (WebCore::StyledElement::parseMappedAttribute):
     34        * dom/StyledElement.h:
     35        (StyledElement):
     36        * html/parser/HTMLConstructionSite.cpp:
     37        (WebCore):
     38        * html/parser/HTMLTreeBuilder.cpp:
     39        (WebCore::HTMLTreeBuilder::attributesForIsindexInput):
     40        * html/parser/TextDocumentParser.cpp:
     41        (WebCore::TextDocumentParser::insertFakePreElement):
     42        * svg/SVGStyledElement.cpp:
     43        (WebCore::SVGStyledElement::getPresentationAttribute):
     44        * xml/parser/MarkupTokenBase.h:
     45        (WebCore::::initializeAttributes):
     46
    1472012-02-05  Andreas Kling  <awesomekling@apple.com>
    248
  • trunk/Source/WebCore/dom/Attribute.cpp

    r106740 r106757  
    4141PassRefPtr<Attribute> Attribute::clone() const
    4242{
    43     return adoptRef(new Attribute(m_name, m_value, m_isMappedAttribute));
     43    return adoptRef(new Attribute(m_name, m_value));
    4444}
    4545
  • trunk/Source/WebCore/dom/Attribute.h

    r106740 r106757  
    4242    static PassRefPtr<Attribute> create(const QualifiedName& name, const AtomicString& value)
    4343    {
    44         return adoptRef(new Attribute(name, value, false));
     44        return adoptRef(new Attribute(name, value));
    4545    }
    46     static PassRefPtr<Attribute> createMapped(const QualifiedName& name, const AtomicString& value)
     46    static PassRefPtr<Attribute> create(const AtomicString& name, const AtomicString& value)
    4747    {
    48         return adoptRef(new Attribute(name, value, true));
    49     }
    50     static PassRefPtr<Attribute> createMapped(const AtomicString& name, const AtomicString& value)
    51     {
    52         return adoptRef(new Attribute(name, value, true));
     48        return adoptRef(new Attribute(name, value));
    5349    }
    5450
     
    7672    void parserSetName(const QualifiedName& name) { m_name = name; }
    7773
    78     bool isMappedAttribute() { return m_isMappedAttribute; }
    79 
    8074private:
    81     Attribute(const QualifiedName& name, const AtomicString& value, bool isMappedAttribute)
    82         : m_isMappedAttribute(isMappedAttribute)
    83         , m_hasAttr(false)
     75    Attribute(const QualifiedName& name, const AtomicString& value)
     76        : m_hasAttr(false)
    8477        , m_name(name)
    8578        , m_value(value)
     
    8780    }
    8881
    89     Attribute(const AtomicString& name, const AtomicString& value, bool isMappedAttribute)
    90         : m_isMappedAttribute(isMappedAttribute)
    91         , m_hasAttr(false)
     82    Attribute(const AtomicString& name, const AtomicString& value)
     83        : m_hasAttr(false)
    9284        , m_name(nullAtom, name, nullAtom)
    9385        , m_value(value)
     
    9890    void unbindAttr(Attr*);
    9991
    100     // These booleans will go into the spare 32-bits of padding from RefCounted in 64-bit.
    101     bool m_isMappedAttribute;
     92    // This boolean will go into the spare 32-bits of padding from RefCounted in 64-bit.
    10293    bool m_hasAttr;
    10394   
  • trunk/Source/WebCore/dom/Document.cpp

    r106681 r106757  
    43364336    }
    43374337
    4338     // FIXME: Assume this is a mapped attribute, since createAttribute isn't namespace-aware.  There's no harm to XML
    4339     // documents if we're wrong.
    4340     return Attr::create(0, this, Attribute::createMapped(qName, StringImpl::empty()));
     4338    return Attr::create(0, this, Attribute::create(qName, StringImpl::empty()));
    43414339}
    43424340
  • trunk/Source/WebCore/dom/Element.cpp

    r106746 r106757  
    660660    if (isIdAttributeName(attr->name()))
    661661        idAttributeChanged(attr);
     662    else if (attr->name() == HTMLNames::nameAttr)
     663        setHasName(!attr->isNull());
     664
    662665    recalcStyleIfNeededAfterAttributeChanged(attr);
    663666    updateAfterAttributeChanged(attr);
  • trunk/Source/WebCore/dom/Element.h

    r106746 r106757  
    384384    PassRefPtr<RenderStyle> styleForRenderer();
    385385
     386    PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
     387
    386388protected:
    387389    Element(const QualifiedName& tagName, Document* document, ConstructionType type)
     
    423425
    424426    void setAttributeInternal(size_t index, const QualifiedName&, const AtomicString& value);
    425     virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
    426    
     427
    427428#ifndef NDEBUG
    428429    virtual void formatForDebugger(char* buffer, unsigned length) const;
  • trunk/Source/WebCore/dom/Node.cpp

    r106515 r106757  
    160160
    161161    size_t attributes = 0;
    162     size_t mappedAttributes = 0;
    163     size_t mappedAttributesWithStyleDecl = 0;
    164162    size_t attributesWithAttr = 0;
    165163    size_t attrMaps = 0;
     
    189187                        if (attr->attr())
    190188                            ++attributesWithAttr;
    191                         if (attr->isMappedAttribute()) {
    192                             ++mappedAttributes;
    193                             if (attr->style())
    194                                 ++mappedAttributesWithStyleDecl;
    195                         }
    196189                    }
    197190                }
     
    278271    printf("Attribute Maps:\n");
    279272    printf("  Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes, sizeof(Attribute));
    280     printf("  Number of Attributes that are mapped: %zu\n", mappedAttributes);
    281     printf("  Number of Attributes with a StyleDeclaration: %zu\n", mappedAttributesWithStyleDecl);
    282273    printf("  Number of Attributes with an Attr: %zu\n", attributesWithAttr);
    283274    printf("  Number of NamedNodeMaps: %zu [%zu]\n", attrMaps, sizeof(NamedNodeMap));
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r106756 r106757  
    6161}
    6262
    63 PassRefPtr<Attribute> StyledElement::createAttribute(const QualifiedName& name, const AtomicString& value)
    64 {
    65     return Attribute::createMapped(name, value);
    66 }
    67 
    6863void StyledElement::attributeChanged(Attribute* attr)
    6964{
    70     if (attr->name() == HTMLNames::nameAttr)
    71         setHasName(!attr->isNull());
    72 
    73     if (!attr->isMappedAttribute()) {
    74         Element::attributeChanged(attr);
    75         return;
    76     }
    77 
    7865    if (!(attr->name() == styleAttr && isSynchronizingStyleAttribute()))
    7966        parseMappedAttribute(attr);
    8067
    81     recalcStyleIfNeededAfterAttributeChanged(attr);
    82     updateAfterAttributeChanged(attr);
     68    Element::attributeChanged(attr);
    8369}
    8470
     
    10793void StyledElement::parseMappedAttribute(Attribute* attr)
    10894{
    109     if (isIdAttributeName(attr->name()))
    110         idAttributeChanged(attr);
    111     else if (attr->name() == classAttr)
     95    if (attr->name() == classAttr)
    11296        classAttributeChanged(attr->value());
    11397    else if (attr->name() == styleAttr) {
  • trunk/Source/WebCore/dom/StyledElement.h

    r106756 r106757  
    6060    const SpaceSplitString& classNames() const;
    6161
    62     virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
    63 
    6462protected:
    6563    StyledElement(const QualifiedName& name, Document* document, ConstructionType type)
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r106515 r106757  
    433433    for (size_t i = 0; i < attributes->length(); ++i) {
    434434        Attribute* attribute = attributes->attributeItem(i);
    435         RefPtr<Attribute> clone = Attribute::createMapped(attribute->name(), attribute->value());
     435        RefPtr<Attribute> clone = Attribute::create(attribute->name(), attribute->value());
    436436        newAttributes->addAttribute(clone);
    437437    }
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r104130 r106757  
    572572    }
    573573
    574     RefPtr<Attribute> mappedAttribute = Attribute::createMapped(nameAttr, isindexTag.localName());
     574    RefPtr<Attribute> mappedAttribute = Attribute::create(nameAttr, isindexTag.localName());
    575575    attributes->insertAttribute(mappedAttribute.release(), false);
    576576    return attributes.release();
  • trunk/Source/WebCore/html/parser/TextDocumentParser.cpp

    r104130 r106757  
    6161    // distrubing the line/column number calculations.
    6262
    63     RefPtr<Attribute> styleAttribute = Attribute::createMapped("style", "word-wrap: break-word; white-space: pre-wrap;");
     63    RefPtr<Attribute> styleAttribute = Attribute::create("style", "word-wrap: break-word; white-space: pre-wrap;");
    6464    OwnPtr<NamedNodeMap> attributes = NamedNodeMap::create();
    6565    attributes->insertAttribute(styleAttribute.release(), false);
  • trunk/Source/WebCore/svg/SVGStyledElement.cpp

    r106740 r106757  
    412412    QualifiedName attributeName(nullAtom, name, nullAtom);
    413413    Attribute* attr = attributeMap()->getAttributeItem(attributeName);
    414     if (!attr || !attr->isMappedAttribute())
     414    if (!attr)
    415415        return 0;
    416416
  • trunk/Source/WebCore/xml/parser/MarkupTokenBase.h

    r104130 r106757  
    542542
    543543        String value(attribute.m_value.data(), attribute.m_value.size());
    544         m_attributes->insertAttribute(Attribute::createMapped(nameForAttribute(attribute), value), false);
     544        m_attributes->insertAttribute(Attribute::create(nameForAttribute(attribute), value), false);
    545545    }
    546546}
Note: See TracChangeset for help on using the changeset viewer.