Changeset 106740 in webkit


Ignore:
Timestamp:
Feb 4, 2012 4:24:19 AM (12 years ago)
Author:
kling@webkit.org
Message:

Kill per-Attribute style declarations.
<http://webkit.org/b/77204>

Reviewed by Antti Koivisto.

Source/WebCore:

TL;DR summary: Remove the per-Attribute style declarations and replace them by a single
style declaration on StyledElement that acts as a secondary inline style.

The previous design was conceived in the Age of the Old Web(tm) where the majority of
element styling was accomplished via attributes. Nowadays, CSS is a much better tool for
this and we should optimize around that instead.

StyledElements now have an attributeStyle() which contains all the styling from attributes.
parseMappedAttribute() is responsible for adding/removing properties to the attributeStyle
as the corresponding attributes come in/out of the element.

Each Attribute instance shrinks by one pointer, each element that has attributes grows by
one pointer. The styles from individual attributes are no longer shared, so content that
uses a lot of repeating styling attributes will see a slight memory regression from this.
Future improvements to this could enable sharing the attributeStyle between elements that
have the same exact attributes to mitigate some of the damage.

There should be no web-facing behavior change from this, but it does break two things:

  • The Inspector feature for displaying per-attribute styles. To keep things manageable, this patch simply files all the attribute styles together under an anonymous attribute in the Inspector.
  • The Obj-C DOM binding for Attr::style() has to be kept for compatibility reasons, though it's already deprecated. It will now always return nil, since there's no way to retrieve a live style declaration that's specific to a certain Attr.
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::matchAllRules):
(WebCore::CSSStyleSelector::canShareStyleWithElement):

  • dom/Attr.h:

(WebCore):
(Attr):
(WebCore::Attr::style):

  • dom/Attribute.cpp:

(WebCore::Attribute::clone):

  • dom/Attribute.h:

(WebCore):
(WebCore::Attribute::create):
(WebCore::Attribute::createMapped):
(Attribute):
(WebCore::Attribute::Attribute):

  • dom/CSSMappedAttributeDeclaration.cpp:

(WebCore::CSSMappedAttributeDeclaration::~CSSMappedAttributeDeclaration):
(WebCore::CSSMappedAttributeDeclaration::setMappedProperty):

  • dom/CSSMappedAttributeDeclaration.h:

(CSSMappedAttributeDeclaration):
(WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):

  • dom/Element.h:

(Element):

  • dom/ElementAttributeData.h:

(ElementAttributeData):

  • dom/NamedNodeMap.cpp:

(WebCore::NamedNodeMap::ensureAttributeStyle):
(WebCore):

  • dom/NamedNodeMap.h:

(WebCore::NamedNodeMap::attributeStyle):
(NamedNodeMap):

  • dom/StyledElement.cpp:

(WebCore):
(WebCore::StyledElement::attributeChanged):
(WebCore::StyledElement::removeCSSProperties):
(WebCore::StyledElement::addCSSProperty):
(WebCore::StyledElement::addCSSImageProperty):
(WebCore::StyledElement::addCSSLength):
(WebCore::StyledElement::addCSSColor):

  • dom/StyledElement.h:

(StyledElement):
(WebCore::StyledElement::removeCSSProperty):
(WebCore::StyledElement::attributeStyle):
(WebCore::StyledElement::ensureAttributeStyle):

  • html/HTMLBRElement.cpp:

(WebCore::HTMLBRElement::parseMappedAttribute):

  • html/HTMLBRElement.h:

(HTMLBRElement):

  • html/HTMLBodyElement.cpp:

(WebCore::HTMLBodyElement::parseMappedAttribute):

  • html/HTMLBodyElement.h:

(HTMLBodyElement):

  • html/HTMLDivElement.cpp:

(WebCore::HTMLDivElement::parseMappedAttribute):

  • html/HTMLDivElement.h:

(HTMLDivElement):

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::applyBorderAttribute):
(WebCore::HTMLElement::mapLanguageAttributeToLocale):
(WebCore::HTMLElement::parseMappedAttribute):
(WebCore::HTMLElement::removeHTMLAlignment):
(WebCore):
(WebCore::HTMLElement::addHTMLAlignmentToStyledElement):
(WebCore::HTMLElement::setContentEditable):

  • html/HTMLElement.h:

(HTMLElement):

  • html/HTMLEmbedElement.cpp:

(WebCore::HTMLEmbedElement::parseMappedAttribute):

  • html/HTMLEmbedElement.h:

(HTMLEmbedElement):

  • html/HTMLFontElement.cpp:

(WebCore::HTMLFontElement::parseMappedAttribute):

  • html/HTMLFontElement.h:

(HTMLFontElement):

  • html/HTMLFrameSetElement.cpp:

(WebCore::HTMLFrameSetElement::parseMappedAttribute):

  • html/HTMLFrameSetElement.h:

(HTMLFrameSetElement):

  • html/HTMLHRElement.cpp:

(WebCore::HTMLHRElement::parseMappedAttribute):

  • html/HTMLHRElement.h:

(HTMLHRElement):

  • html/HTMLIFrameElement.cpp:

(WebCore::HTMLIFrameElement::parseMappedAttribute):

  • html/HTMLIFrameElement.h:

(HTMLIFrameElement):

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::parseMappedAttribute):

  • html/HTMLImageElement.h:

(HTMLImageElement):

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::parseMappedAttribute):

  • html/HTMLInputElement.h:

(HTMLInputElement):

  • html/HTMLLIElement.cpp:

(WebCore::HTMLLIElement::parseMappedAttribute):

  • html/HTMLLIElement.h:

(HTMLLIElement):

  • html/HTMLMarqueeElement.cpp:

(WebCore::HTMLMarqueeElement::parseMappedAttribute):

  • html/HTMLMarqueeElement.h:

(HTMLMarqueeElement):

  • html/HTMLOListElement.cpp:

(WebCore::HTMLOListElement::parseMappedAttribute):

  • html/HTMLOListElement.h:

(HTMLOListElement):

  • html/HTMLOutputElement.cpp:
  • html/HTMLOutputElement.h:

(HTMLOutputElement):

  • html/HTMLParagraphElement.cpp:

(WebCore::HTMLParagraphElement::parseMappedAttribute):

  • html/HTMLParagraphElement.h:

(HTMLParagraphElement):

  • html/HTMLPlugInElement.cpp:

(WebCore::HTMLPlugInElement::parseMappedAttribute):

  • html/HTMLPlugInElement.h:

(HTMLPlugInElement):

  • html/HTMLPreElement.cpp:

(WebCore::HTMLPreElement::parseMappedAttribute):

  • html/HTMLPreElement.h:

(HTMLPreElement):

  • html/HTMLTableCaptionElement.cpp:

(WebCore::HTMLTableCaptionElement::parseMappedAttribute):

  • html/HTMLTableCaptionElement.h:

(HTMLTableCaptionElement):

  • html/HTMLTableCellElement.cpp:

(WebCore::HTMLTableCellElement::parseMappedAttribute):

  • html/HTMLTableCellElement.h:

(HTMLTableCellElement):

  • html/HTMLTableColElement.cpp:

(WebCore::HTMLTableColElement::parseMappedAttribute):

  • html/HTMLTableColElement.h:

(HTMLTableColElement):

  • html/HTMLTableElement.cpp:

(WebCore::HTMLTableElement::parseMappedAttribute):

  • html/HTMLTableElement.h:

(HTMLTableElement):

  • html/HTMLTablePartElement.cpp:

(WebCore):
(WebCore::HTMLTablePartElement::parseMappedAttribute):

  • html/HTMLTablePartElement.h:
  • html/HTMLTextAreaElement.cpp:

(WebCore::HTMLTextAreaElement::parseMappedAttribute):

  • html/HTMLUListElement.cpp:

(WebCore::HTMLUListElement::parseMappedAttribute):

  • html/HTMLUListElement.h:

(HTMLUListElement):

  • html/HTMLVideoElement.cpp:

(WebCore::HTMLVideoElement::parseMappedAttribute):

  • inspector/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::buildArrayForAttributeStyles):

  • mathml/MathMLElement.cpp:

(WebCore::MathMLElement::parseMappedAttribute):

  • mathml/MathMLElement.h:
  • svg/SVGImageElement.cpp:

(WebCore::SVGImageElement::parseMappedAttribute):

  • svg/SVGStyledElement.cpp:

(WebCore::SVGStyledElement::parseMappedAttribute):
(WebCore::SVGStyledElement::getPresentationAttribute):

  • svg/SVGStyledElement.h:

(SVGStyledElement):

  • svg/SVGTextContentElement.cpp:

(WebCore::SVGTextContentElement::parseMappedAttribute):

LayoutTests:

Rebaselined 3 inspector tests since attribute styles are no longer shown per-attribute.

  • inspector/elements/elements-panel-styles-expected.txt:
  • inspector/styles/styles-computed-trace-expected.txt:
  • inspector/styles/styles-new-API-expected.txt:
Location:
trunk
Files:
74 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106736 r106740  
     12012-02-03  Andreas Kling  <awesomekling@apple.com>
     2
     3        Kill per-Attribute style declarations.
     4        <http://webkit.org/b/77204>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Rebaselined 3 inspector tests since attribute styles are no longer shown per-attribute.
     9
     10        * inspector/elements/elements-panel-styles-expected.txt:
     11        * inspector/styles/styles-computed-trace-expected.txt:
     12        * inspector/styles/styles-new-API-expected.txt:
     13
    1142012-02-04  Adam Barth  <abarth@webkit.org>
    215
  • trunk/LayoutTests/inspector/elements/elements-panel-styles-expected.txt

    r99713 r106740  
    3333    .foo - 10px elements-panel-styles.css:14
    3434text-align: -webkit-left;
    35     div[align=left] - -webkit-left
     35    div[] - -webkit-left
    3636
    3737[expanded]
     
    6868
    6969[expanded]
    70 div[align=left]  { ()
     70div[]  { ()
    7171text-align: -webkit-left;
    7272
  • trunk/LayoutTests/inspector/styles/styles-computed-trace-expected.txt

    r99713 r106740  
    5353======== Matched CSS Rules ========
    5454[expanded]
    55 button[hidden]  { ()
     55button[]  { ()
    5656display: none;
    5757
  • trunk/LayoutTests/inspector/styles/styles-new-API-expected.txt

    r103761 r106740  
    9292
    9393=== Attribute styles for table ===
    94 Attribute: width
     94Attribute:
    9595
    9696style
  • trunk/Source/WebCore/ChangeLog

    r106738 r106740  
     12012-02-03  Andreas Kling  <awesomekling@apple.com>
     2
     3        Kill per-Attribute style declarations.
     4        <http://webkit.org/b/77204>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        TL;DR summary: Remove the per-Attribute style declarations and replace them by a single
     9        style declaration on StyledElement that acts as a secondary inline style.
     10
     11        The previous design was conceived in the Age of the Old Web(tm) where the majority of
     12        element styling was accomplished via attributes. Nowadays, CSS is a much better tool for
     13        this and we should optimize around that instead.
     14
     15        StyledElements now have an attributeStyle() which contains all the styling from attributes.
     16        parseMappedAttribute() is responsible for adding/removing properties to the attributeStyle
     17        as the corresponding attributes come in/out of the element.
     18
     19        Each Attribute instance shrinks by one pointer, each element that has attributes grows by
     20        one pointer. The styles from individual attributes are no longer shared, so content that
     21        uses a lot of repeating styling attributes will see a slight memory regression from this.
     22        Future improvements to this could enable sharing the attributeStyle between elements that
     23        have the same exact attributes to mitigate some of the damage.
     24
     25        There should be no web-facing behavior change from this, but it does break two things:
     26
     27        - The Inspector feature for displaying per-attribute styles. To keep things manageable,
     28          this patch simply files all the attribute styles together under an anonymous attribute
     29          in the Inspector.
     30
     31        - The Obj-C DOM binding for Attr::style() has to be kept for compatibility reasons,
     32          though it's already deprecated. It will now always return nil, since there's no way to
     33          retrieve a live style declaration that's specific to a certain Attr.
     34
     35        * css/CSSStyleSelector.cpp:
     36        (WebCore::CSSStyleSelector::matchAllRules):
     37        (WebCore::CSSStyleSelector::canShareStyleWithElement):
     38        * dom/Attr.h:
     39        (WebCore):
     40        (Attr):
     41        (WebCore::Attr::style):
     42        * dom/Attribute.cpp:
     43        (WebCore::Attribute::clone):
     44        * dom/Attribute.h:
     45        (WebCore):
     46        (WebCore::Attribute::create):
     47        (WebCore::Attribute::createMapped):
     48        (Attribute):
     49        (WebCore::Attribute::Attribute):
     50        * dom/CSSMappedAttributeDeclaration.cpp:
     51        (WebCore::CSSMappedAttributeDeclaration::~CSSMappedAttributeDeclaration):
     52        (WebCore::CSSMappedAttributeDeclaration::setMappedProperty):
     53        * dom/CSSMappedAttributeDeclaration.h:
     54        (CSSMappedAttributeDeclaration):
     55        (WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):
     56        * dom/Element.h:
     57        (Element):
     58        * dom/ElementAttributeData.h:
     59        (ElementAttributeData):
     60        * dom/NamedNodeMap.cpp:
     61        (WebCore::NamedNodeMap::ensureAttributeStyle):
     62        (WebCore):
     63        * dom/NamedNodeMap.h:
     64        (WebCore::NamedNodeMap::attributeStyle):
     65        (NamedNodeMap):
     66        * dom/StyledElement.cpp:
     67        (WebCore):
     68        (WebCore::StyledElement::attributeChanged):
     69        (WebCore::StyledElement::removeCSSProperties):
     70        (WebCore::StyledElement::addCSSProperty):
     71        (WebCore::StyledElement::addCSSImageProperty):
     72        (WebCore::StyledElement::addCSSLength):
     73        (WebCore::StyledElement::addCSSColor):
     74        * dom/StyledElement.h:
     75        (StyledElement):
     76        (WebCore::StyledElement::removeCSSProperty):
     77        (WebCore::StyledElement::attributeStyle):
     78        (WebCore::StyledElement::ensureAttributeStyle):
     79        * html/HTMLBRElement.cpp:
     80        (WebCore::HTMLBRElement::parseMappedAttribute):
     81        * html/HTMLBRElement.h:
     82        (HTMLBRElement):
     83        * html/HTMLBodyElement.cpp:
     84        (WebCore::HTMLBodyElement::parseMappedAttribute):
     85        * html/HTMLBodyElement.h:
     86        (HTMLBodyElement):
     87        * html/HTMLDivElement.cpp:
     88        (WebCore::HTMLDivElement::parseMappedAttribute):
     89        * html/HTMLDivElement.h:
     90        (HTMLDivElement):
     91        * html/HTMLElement.cpp:
     92        (WebCore::HTMLElement::applyBorderAttribute):
     93        (WebCore::HTMLElement::mapLanguageAttributeToLocale):
     94        (WebCore::HTMLElement::parseMappedAttribute):
     95        (WebCore::HTMLElement::removeHTMLAlignment):
     96        (WebCore):
     97        (WebCore::HTMLElement::addHTMLAlignmentToStyledElement):
     98        (WebCore::HTMLElement::setContentEditable):
     99        * html/HTMLElement.h:
     100        (HTMLElement):
     101        * html/HTMLEmbedElement.cpp:
     102        (WebCore::HTMLEmbedElement::parseMappedAttribute):
     103        * html/HTMLEmbedElement.h:
     104        (HTMLEmbedElement):
     105        * html/HTMLFontElement.cpp:
     106        (WebCore::HTMLFontElement::parseMappedAttribute):
     107        * html/HTMLFontElement.h:
     108        (HTMLFontElement):
     109        * html/HTMLFrameSetElement.cpp:
     110        (WebCore::HTMLFrameSetElement::parseMappedAttribute):
     111        * html/HTMLFrameSetElement.h:
     112        (HTMLFrameSetElement):
     113        * html/HTMLHRElement.cpp:
     114        (WebCore::HTMLHRElement::parseMappedAttribute):
     115        * html/HTMLHRElement.h:
     116        (HTMLHRElement):
     117        * html/HTMLIFrameElement.cpp:
     118        (WebCore::HTMLIFrameElement::parseMappedAttribute):
     119        * html/HTMLIFrameElement.h:
     120        (HTMLIFrameElement):
     121        * html/HTMLImageElement.cpp:
     122        (WebCore::HTMLImageElement::parseMappedAttribute):
     123        * html/HTMLImageElement.h:
     124        (HTMLImageElement):
     125        * html/HTMLInputElement.cpp:
     126        (WebCore::HTMLInputElement::parseMappedAttribute):
     127        * html/HTMLInputElement.h:
     128        (HTMLInputElement):
     129        * html/HTMLLIElement.cpp:
     130        (WebCore::HTMLLIElement::parseMappedAttribute):
     131        * html/HTMLLIElement.h:
     132        (HTMLLIElement):
     133        * html/HTMLMarqueeElement.cpp:
     134        (WebCore::HTMLMarqueeElement::parseMappedAttribute):
     135        * html/HTMLMarqueeElement.h:
     136        (HTMLMarqueeElement):
     137        * html/HTMLOListElement.cpp:
     138        (WebCore::HTMLOListElement::parseMappedAttribute):
     139        * html/HTMLOListElement.h:
     140        (HTMLOListElement):
     141        * html/HTMLOutputElement.cpp:
     142        * html/HTMLOutputElement.h:
     143        (HTMLOutputElement):
     144        * html/HTMLParagraphElement.cpp:
     145        (WebCore::HTMLParagraphElement::parseMappedAttribute):
     146        * html/HTMLParagraphElement.h:
     147        (HTMLParagraphElement):
     148        * html/HTMLPlugInElement.cpp:
     149        (WebCore::HTMLPlugInElement::parseMappedAttribute):
     150        * html/HTMLPlugInElement.h:
     151        (HTMLPlugInElement):
     152        * html/HTMLPreElement.cpp:
     153        (WebCore::HTMLPreElement::parseMappedAttribute):
     154        * html/HTMLPreElement.h:
     155        (HTMLPreElement):
     156        * html/HTMLTableCaptionElement.cpp:
     157        (WebCore::HTMLTableCaptionElement::parseMappedAttribute):
     158        * html/HTMLTableCaptionElement.h:
     159        (HTMLTableCaptionElement):
     160        * html/HTMLTableCellElement.cpp:
     161        (WebCore::HTMLTableCellElement::parseMappedAttribute):
     162        * html/HTMLTableCellElement.h:
     163        (HTMLTableCellElement):
     164        * html/HTMLTableColElement.cpp:
     165        (WebCore::HTMLTableColElement::parseMappedAttribute):
     166        * html/HTMLTableColElement.h:
     167        (HTMLTableColElement):
     168        * html/HTMLTableElement.cpp:
     169        (WebCore::HTMLTableElement::parseMappedAttribute):
     170        * html/HTMLTableElement.h:
     171        (HTMLTableElement):
     172        * html/HTMLTablePartElement.cpp:
     173        (WebCore):
     174        (WebCore::HTMLTablePartElement::parseMappedAttribute):
     175        * html/HTMLTablePartElement.h:
     176        * html/HTMLTextAreaElement.cpp:
     177        (WebCore::HTMLTextAreaElement::parseMappedAttribute):
     178        * html/HTMLUListElement.cpp:
     179        (WebCore::HTMLUListElement::parseMappedAttribute):
     180        * html/HTMLUListElement.h:
     181        (HTMLUListElement):
     182        * html/HTMLVideoElement.cpp:
     183        (WebCore::HTMLVideoElement::parseMappedAttribute):
     184        * inspector/InspectorCSSAgent.cpp:
     185        (WebCore::InspectorCSSAgent::buildArrayForAttributeStyles):
     186        * mathml/MathMLElement.cpp:
     187        (WebCore::MathMLElement::parseMappedAttribute):
     188        * mathml/MathMLElement.h:
     189        * svg/SVGImageElement.cpp:
     190        (WebCore::SVGImageElement::parseMappedAttribute):
     191        * svg/SVGStyledElement.cpp:
     192        (WebCore::SVGStyledElement::parseMappedAttribute):
     193        (WebCore::SVGStyledElement::getPresentationAttribute):
     194        * svg/SVGStyledElement.h:
     195        (SVGStyledElement):
     196        * svg/SVGTextContentElement.cpp:
     197        (WebCore::SVGTextContentElement::parseMappedAttribute):
     198
    11992012-02-03  Ilya Tikhonovsky  <loislo@chromium.org>
    2200
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r106681 r106740  
    997997    // Now check author rules, beginning first with presentational attributes mapped from HTML.
    998998    if (m_styledElement) {
    999         if (const NamedNodeMap* map = m_styledElement->attributeMap()) {
    1000             // Walk the element's attribute map and add all mapped attribute declarations.
    1001             for (unsigned i = 0; i < map->length(); ++i) {
    1002                 Attribute* attribute = map->attributeItem(i);
    1003                 if (!attribute->decl())
    1004                     continue;
    1005                 ASSERT(attribute->isMappedAttribute());
    1006                 result.ranges.lastAuthorRule = m_matchedDecls.size();
     999        if (CSSMappedAttributeDeclaration* attributeStyle = m_styledElement->attributeStyle()) {
     1000            ASSERT(attributeStyle->declaration());
     1001            if (!attributeStyle->declaration()->isEmpty()) {
     1002                result.ranges.lastAuthorRule = m_matchedRules.size();
    10071003                if (result.ranges.firstAuthorRule == -1)
    10081004                    result.ranges.firstAuthorRule = result.ranges.lastAuthorRule;
    1009                 addMatchedDeclaration(attribute->decl());
     1005                addMatchedDeclaration(attributeStyle->declaration());
    10101006            }
    10111007        }
     
    11991195}
    12001196
    1201 static inline bool mappedAttributesEquivalent(NamedNodeMap* a, NamedNodeMap* b)
    1202 {
    1203     ASSERT(a->mappedAttributeCount() == b->mappedAttributeCount());
    1204 
    1205     for (size_t i = 0; i < a->length(); ++i) {
    1206         Attribute* attribute = a->attributeItem(i);
    1207         if (!attribute->decl())
    1208             continue;
    1209         ASSERT(attribute->isMappedAttribute());
    1210         Attribute* otherAttribute = b->getAttributeItem(attribute->name());
    1211         if (!otherAttribute || attribute->value() != otherAttribute->value() || attribute->decl() != otherAttribute->decl())
    1212             return false;
    1213     }
    1214     return true;
    1215 }
    1216 
    12171197bool CSSStyleSelector::canShareStyleWithElement(StyledElement* element) const
    12181198{
     
    12291209    if (element->inlineStyleDecl())
    12301210        return false;
    1231     size_t mappedAttributeCount = element->mappedAttributeCount();
    1232     if (mappedAttributeCount != m_styledElement->mappedAttributeCount())
     1211    if (!!element->attributeStyle() != !!m_styledElement->attributeStyle())
    12331212        return false;
    12341213    if (element->isLink() != m_element->isLink())
     
    12961275        return false;
    12971276
    1298     if (mappedAttributeCount && !mappedAttributesEquivalent(element->attributeMap(), m_styledElement->attributeMap()))
     1277    if (element->attributeStyle() && !element->attributeMap()->mapsEquivalent(m_styledElement->attributeMap()))
    12991278        return false;
    13001279
  • trunk/Source/WebCore/dom/Attr.h

    r106681 r106740  
    3131namespace WebCore {
    3232
     33class CSSStyleDeclaration;
     34
    3335// Attr can have Text and EntityReference children
    3436// therefore it has to be a fullblown Node. The plan
     
    5658    bool isId() const;
    5759
    58     // An extension to get presentational information for attributes.
    59     CSSStyleDeclaration* style() { return m_attribute->decl()->ensureCSSStyleDeclaration(); }
     60    // A deprecated extension to get presentational information for attributes.
     61    // We have to keep it around because it's exposed in the Obj-C DOM API.
     62    CSSStyleDeclaration* style() { return 0; }
    6063
    6164    void setSpecified(bool specified) { m_specified = specified; }
  • trunk/Source/WebCore/dom/Attribute.cpp

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

    r106681 r106740  
    2626#define Attribute_h
    2727
    28 #include "CSSMappedAttributeDeclaration.h"
    2928#include "QualifiedName.h"
    3029
     
    3231
    3332class Attr;
    34 class CSSStyleDeclaration;
    3533class Element;
    3634class NamedNodeMap;
     
    4442    static PassRefPtr<Attribute> create(const QualifiedName& name, const AtomicString& value)
    4543    {
    46         return adoptRef(new Attribute(name, value, false, 0));
     44        return adoptRef(new Attribute(name, value, false));
    4745    }
    4846    static PassRefPtr<Attribute> createMapped(const QualifiedName& name, const AtomicString& value)
    4947    {
    50         return adoptRef(new Attribute(name, value, true, 0));
     48        return adoptRef(new Attribute(name, value, true));
    5149    }
    5250    static PassRefPtr<Attribute> createMapped(const AtomicString& name, const AtomicString& value)
    5351    {
    54         return adoptRef(new Attribute(name, value, true, 0));
     52        return adoptRef(new Attribute(name, value, true));
    5553    }
    5654
     
    6967   
    7068    PassRefPtr<Attribute> clone() const;
    71    
    72     StylePropertySet* decl() const { return m_mappedAttributeDeclaration ? m_mappedAttributeDeclaration->declaration() : 0; }
    73 
    74     CSSMappedAttributeDeclaration* mappedAttributeDeclaration() const { return m_mappedAttributeDeclaration.get(); }
    75     void setMappedAttributeDeclaration(PassRefPtr<CSSMappedAttributeDeclaration> decl) { m_mappedAttributeDeclaration = decl; }
    7669
    7770    void setValue(const AtomicString& value) { m_value = value; }
     
    8679
    8780private:
    88     Attribute(const QualifiedName& name, const AtomicString& value, bool isMappedAttribute, CSSMappedAttributeDeclaration* styleDecl)
     81    Attribute(const QualifiedName& name, const AtomicString& value, bool isMappedAttribute)
    8982        : m_isMappedAttribute(isMappedAttribute)
    9083        , m_hasAttr(false)
    9184        , m_name(name)
    9285        , m_value(value)
    93         , m_mappedAttributeDeclaration(styleDecl)
    9486    {
    9587    }
    9688
    97     Attribute(const AtomicString& name, const AtomicString& value, bool isMappedAttribute, CSSMappedAttributeDeclaration* styleDecl)
     89    Attribute(const AtomicString& name, const AtomicString& value, bool isMappedAttribute)
    9890        : m_isMappedAttribute(isMappedAttribute)
    9991        , m_hasAttr(false)
    10092        , m_name(nullAtom, name, nullAtom)
    10193        , m_value(value)
    102         , m_mappedAttributeDeclaration(styleDecl)
    10394    {
    10495    }
     
    113104    QualifiedName m_name;
    114105    AtomicString m_value;
    115     RefPtr<CSSMappedAttributeDeclaration> m_mappedAttributeDeclaration;
    116106};
    117107
  • trunk/Source/WebCore/dom/CSSMappedAttributeDeclaration.cpp

    r106471 r106740  
    3939CSSMappedAttributeDeclaration::~CSSMappedAttributeDeclaration()
    4040{
    41     StyledElement::removeMappedAttributeDecl(m_entryType, m_attrName, m_attrValue);
    4241}
    4342
     
    6766    }
    6867
    69     if (!CSSParser::parseMappedAttributeValue(this, element, propertyId, value))
     68    if (!CSSParser::parseMappedAttributeValue(this, element, propertyId, value)) {
     69        removeMappedProperty(element, propertyId);
    7070        return;
     71    }
    7172
    7273    setNeedsStyleRecalc(element);
  • trunk/Source/WebCore/dom/CSSMappedAttributeDeclaration.h

    r106695 r106740  
    4343    ~CSSMappedAttributeDeclaration();
    4444
    45     void setMappedState(MappedAttributeEntry type, const QualifiedName& name, const AtomicString& val)
    46     {
    47         m_entryType = type;
    48         m_attrName = name;
    49         m_attrValue = val;
    50     }
    51 
    5245    void setMappedProperty(StyledElement*, int propertyId, int value);
    5346    void setMappedProperty(StyledElement*, int propertyId, const String& value);
     
    6457    CSSMappedAttributeDeclaration()
    6558        : m_declaration(StylePropertySet::create())
    66         , m_entryType(eNone)
    67         , m_attrName(anyQName())
    6859    {
    6960    }
     
    7263
    7364    RefPtr<StylePropertySet> m_declaration;
    74     MappedAttributeEntry m_entryType;
    75     QualifiedName m_attrName;
    76     AtomicString m_attrValue;
    7765};
    7866
  • trunk/Source/WebCore/dom/Element.h

    r106626 r106740  
    222222
    223223    // This method is called whenever an attribute is added, changed or removed.
     224    // FIXME: Remove the preserveDecls argument.
    224225    virtual void attributeChanged(Attribute*, bool preserveDecls = false);
    225226
  • trunk/Source/WebCore/dom/ElementAttributeData.h

    r106695 r106740  
    2727#define ElementAttributeData_h
    2828
     29#include "CSSMappedAttributeDeclaration.h"
    2930#include "SpaceSplitString.h"
    3031#include "StylePropertySet.h"
     
    5152
    5253    RefPtr<StylePropertySet> m_inlineStyleDecl;
     54    RefPtr<CSSMappedAttributeDeclaration> m_attributeStyle;
    5355    SpaceSplitString m_classNames;
    5456    AtomicString m_idForStyleResolution;
  • trunk/Source/WebCore/dom/NamedNodeMap.cpp

    r106681 r106740  
    340340}
    341341
     342CSSMappedAttributeDeclaration* NamedNodeMap::ensureAttributeStyle()
     343{
     344    if (!attributeData()->m_attributeStyle) {
     345        attributeData()->m_attributeStyle = CSSMappedAttributeDeclaration::create();
     346        attributeData()->m_attributeStyle->declaration()->setStrictParsing(false);
     347    }
     348    return attributeData()->m_attributeStyle.get();
     349}
     350
    342351} // namespace WebCore
  • trunk/Source/WebCore/dom/NamedNodeMap.h

    r106681 r106740  
    2727
    2828#include "Attribute.h"
     29#include "CSSMappedAttributeDeclaration.h"
     30#include "CSSPropertyNames.h"
    2931#include "ElementAttributeData.h"
    3032#include "SpaceSplitString.h"
     
    103105    StylePropertySet* ensureInlineStyleDecl();
    104106    void destroyInlineStyleDecl();
     107
     108    CSSMappedAttributeDeclaration* attributeStyle() const { return attributeData()->m_attributeStyle.get(); }
     109    CSSMappedAttributeDeclaration* ensureAttributeStyle();
    105110
    106111private:
     
    185190}
    186191
    187 inline size_t NamedNodeMap::mappedAttributeCount() const
    188 {
    189     size_t count = 0;
    190     for (size_t i = 0; i < m_attributes.size(); ++i) {
    191         if (m_attributes[i]->decl())
    192             ++count;
    193     }
    194     return count;
    195 }
    196 
    197192} // namespace WebCore
    198193
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r106695 r106740  
    4545using namespace HTMLNames;
    4646
    47 struct MappedAttributeKey {
    48     uint16_t type;
    49     StringImpl* name;
    50     StringImpl* value;
    51     MappedAttributeKey(MappedAttributeEntry t = eNone, StringImpl* n = 0, StringImpl* v = 0)
    52         : type(t), name(n), value(v) { }
    53 };
    54 
    55 static inline bool operator==(const MappedAttributeKey& a, const MappedAttributeKey& b)
    56     { return a.type == b.type && a.name == b.name && a.value == b.value; }
    57 
    58 struct MappedAttributeKeyTraits : WTF::GenericHashTraits<MappedAttributeKey> {
    59     static const bool emptyValueIsZero = true;
    60     static const bool needsDestruction = false;
    61     static void constructDeletedValue(MappedAttributeKey& slot) { slot.type = eLastEntry; }
    62     static bool isDeletedValue(const MappedAttributeKey& value) { return value.type == eLastEntry; }
    63 };
    64 
    65 struct MappedAttributeHash {
    66     static unsigned hash(const MappedAttributeKey&);
    67     static bool equal(const MappedAttributeKey& a, const MappedAttributeKey& b) { return a == b; }
    68     static const bool safeToCompareToEmptyOrDeleted = true;
    69 };
    70 
    71 typedef HashMap<MappedAttributeKey, CSSMappedAttributeDeclaration*, MappedAttributeHash, MappedAttributeKeyTraits> MappedAttributeDecls;
    72 
    73 static MappedAttributeDecls* mappedAttributeDecls = 0;
    74 
    75 CSSMappedAttributeDeclaration* StyledElement::getMappedAttributeDecl(MappedAttributeEntry entryType, Attribute* attr)
    76 {
    77     if (!mappedAttributeDecls)
    78         return 0;
    79     return mappedAttributeDecls->get(MappedAttributeKey(entryType, attr->name().localName().impl(), attr->value().impl()));
    80 }
    81 
    82 CSSMappedAttributeDeclaration* StyledElement::getMappedAttributeDecl(MappedAttributeEntry type, const QualifiedName& name, const AtomicString& value)
    83 {
    84     if (!mappedAttributeDecls)
    85         return 0;
    86     return mappedAttributeDecls->get(MappedAttributeKey(type, name.localName().impl(), value.impl()));
    87 }
    88 
    89 void StyledElement::setMappedAttributeDecl(MappedAttributeEntry entryType, Attribute* attr, CSSMappedAttributeDeclaration* decl)
    90 {
    91     if (!mappedAttributeDecls)
    92         mappedAttributeDecls = new MappedAttributeDecls;
    93     mappedAttributeDecls->set(MappedAttributeKey(entryType, attr->name().localName().impl(), attr->value().impl()), decl);
    94 }
    95 
    96 void StyledElement::setMappedAttributeDecl(MappedAttributeEntry entryType, const QualifiedName& name, const AtomicString& value, CSSMappedAttributeDeclaration* decl)
    97 {
    98     if (!mappedAttributeDecls)
    99         mappedAttributeDecls = new MappedAttributeDecls;
    100     mappedAttributeDecls->set(MappedAttributeKey(entryType, name.localName().impl(), value.impl()), decl);
    101 }
    102 
    103 void StyledElement::removeMappedAttributeDecl(MappedAttributeEntry entryType, const QualifiedName& attrName, const AtomicString& attrValue)
    104 {
    105     if (!mappedAttributeDecls)
    106         return;
    107     mappedAttributeDecls->remove(MappedAttributeKey(entryType, attrName.localName().impl(), attrValue.impl()));
    108 }
    109 
    11047void StyledElement::updateStyleAttribute() const
    11148{
     
    13774        return;
    13875    }
    139  
    140     if (attr->mappedAttributeDeclaration() && !preserveDecls) {
    141         attr->setMappedAttributeDeclaration(0);
    142         setNeedsStyleRecalc();
    143     }
    144 
    145     bool checkDecl = true;
    146     MappedAttributeEntry entry;
    147     bool needToParse = mapToEntry(attr->name(), entry);
    148     if (preserveDecls) {
    149         if (attr->mappedAttributeDeclaration()) {
    150             setNeedsStyleRecalc();
    151             checkDecl = false;
    152         }
    153     } else if (!attr->isNull() && entry != eNone) {
    154         CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(entry, attr);
    155         if (decl) {
    156             attr->setMappedAttributeDeclaration(decl);
    157             setNeedsStyleRecalc();
    158             checkDecl = false;
    159         } else
    160             needToParse = true;
    161     }
    162 
    163     // parseMappedAttribute() might create a CSSMappedAttributeDeclaration on the attribute. 
    164     // Normally we would be concerned about reseting the parent of those declarations in StyledElement::didMoveToNewDocument().
    165     // But currently we always clear its parent and node below when adding it to the decl table. 
    166     // If that changes for some reason moving between documents will be buggy.
    167     // webarchive/adopt-attribute-styled-node-webarchive.html should catch any resulting crashes.
    168     if (needToParse)
     76
     77    if (!(attr->name() == styleAttr && isSynchronizingStyleAttribute()))
    16978        parseMappedAttribute(attr);
    17079
    171     if (entry == eNone)
    172         recalcStyleIfNeededAfterAttributeChanged(attr);
    173 
    174     if (checkDecl && attr->mappedAttributeDeclaration()) {
    175         // Add the decl to the table in the appropriate spot.
    176         setMappedAttributeDecl(entry, attr, attr->mappedAttributeDeclaration());
    177         attr->mappedAttributeDeclaration()->setMappedState(entry, attr->name(), attr->value());
    178     }
    179 
     80    recalcStyleIfNeededAfterAttributeChanged(attr);
    18081    updateAfterAttributeChanged(attr);
    181 }
    182 
    183 bool StyledElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    184 {
    185     result = eNone;
    186     if (attrName == styleAttr)
    187         return !isSynchronizingStyleAttribute();
    188     return true;
    18982}
    19083
     
    227120}
    228121
    229 void StyledElement::removeCSSProperty(Attribute* attribute, int id)
    230 {
    231     if (!attribute->mappedAttributeDeclaration())
    232         createMappedDecl(attribute);
    233     attribute->mappedAttributeDeclaration()->removeMappedProperty(this, id);
    234 }
    235 
    236 void StyledElement::addCSSProperty(Attribute* attribute, int id, const String &value)
    237 {
    238     if (!attribute->mappedAttributeDeclaration())
    239         createMappedDecl(attribute);
    240     attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, value);
    241 }
    242 
    243 void StyledElement::addCSSProperty(Attribute* attribute, int id, int value)
    244 {
    245     if (!attribute->mappedAttributeDeclaration())
    246         createMappedDecl(attribute);
    247     attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, value);
    248 }
    249 
    250 void StyledElement::addCSSImageProperty(Attribute* attribute, int id, const String& url)
    251 {
    252     if (!attribute->mappedAttributeDeclaration())
    253         createMappedDecl(attribute);
    254     attribute->mappedAttributeDeclaration()->setMappedImageProperty(this, id, url);
    255 }
    256 
    257 void StyledElement::addCSSLength(Attribute* attribute, int id, const String &value)
     122void StyledElement::removeCSSProperties(int id1, int id2, int id3, int id4, int id5, int id6, int id7, int id8)
     123{
     124    CSSMappedAttributeDeclaration* style = attributeStyle();
     125    if (!style)
     126        return;
     127
     128    ASSERT(id1 != CSSPropertyInvalid);
     129    style->removeMappedProperty(this, id1);
     130
     131    if (id2 == CSSPropertyInvalid)
     132        return;
     133    style->removeMappedProperty(this, id2);
     134    if (id3 == CSSPropertyInvalid)
     135        return;
     136    style->removeMappedProperty(this, id3);
     137    if (id4 == CSSPropertyInvalid)
     138        return;
     139    style->removeMappedProperty(this, id4);
     140    if (id5 == CSSPropertyInvalid)
     141        return;
     142    style->removeMappedProperty(this, id5);
     143    if (id6 == CSSPropertyInvalid)
     144        return;
     145    style->removeMappedProperty(this, id6);
     146    if (id7 == CSSPropertyInvalid)
     147        return;
     148    style->removeMappedProperty(this, id7);
     149    if (id8 == CSSPropertyInvalid)
     150        return;
     151    style->removeMappedProperty(this, id8);
     152}
     153
     154void StyledElement::addCSSProperty(int id, const String &value)
     155{
     156    ensureAttributeStyle()->setMappedProperty(this, id, value);
     157}
     158
     159void StyledElement::addCSSProperty(int id, int value)
     160{
     161    ensureAttributeStyle()->setMappedProperty(this, id, value);
     162}
     163
     164void StyledElement::addCSSImageProperty(int id, const String& url)
     165{
     166    ensureAttributeStyle()->setMappedImageProperty(this, id, url);
     167}
     168
     169void StyledElement::addCSSLength(int id, const String &value)
    258170{
    259171    // FIXME: This function should not spin up the CSS parser, but should instead just figure out the correct
    260172    // length unit and make the appropriate parsed value.
    261     if (!attribute->mappedAttributeDeclaration())
    262         createMappedDecl(attribute);
    263173
    264174    // strip attribute garbage..
     
    283193
    284194        if (l != v->length()) {
    285             attribute->mappedAttributeDeclaration()->setMappedLengthProperty(this, id, v->substring(0, l));
     195            ensureAttributeStyle()->setMappedLengthProperty(this, id, v->substring(0, l));
    286196            return;
    287197        }
    288198    }
    289199
    290     attribute->mappedAttributeDeclaration()->setMappedLengthProperty(this, id, value);
     200    ensureAttributeStyle()->setMappedLengthProperty(this, id, value);
    291201}
    292202
     
    344254
    345255// Color parsing that matches HTML's "rules for parsing a legacy color value"
    346 void StyledElement::addCSSColor(Attribute* attribute, int id, const String& attributeValue)
     256void StyledElement::addCSSColor(int id, const String& attributeValue)
    347257{
    348258    // An empty string doesn't apply a color. (One containing only whitespace does, which is why this check occurs before stripping.)
    349     if (attributeValue.isEmpty())
    350         return;
     259    if (attributeValue.isEmpty()) {
     260        removeCSSProperty(id);
     261        return;
     262    }
    351263
    352264    String colorString = attributeValue.stripWhiteSpace();
    353265
    354266    // "transparent" doesn't apply a color either.
    355     if (equalIgnoringCase(colorString, "transparent"))
    356         return;
    357 
    358     if (!attribute->mappedAttributeDeclaration())
    359         createMappedDecl(attribute);
     267    if (equalIgnoringCase(colorString, "transparent")) {
     268        removeCSSProperty(id);
     269        return;
     270    }
    360271
    361272    // If the string is a named CSS color or a 3/6-digit hex color, use that.
    362273    Color parsedColor(colorString);
    363274    if (parsedColor.isValid()) {
    364         attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, colorString);
    365         return;
    366     }
    367 
    368     attribute->mappedAttributeDeclaration()->setMappedProperty(this, id, parseColorStringWithCrazyLegacyRules(colorString));
    369 }
    370 
    371 void StyledElement::createMappedDecl(Attribute* attr)
    372 {
    373     RefPtr<CSSMappedAttributeDeclaration> decl = CSSMappedAttributeDeclaration::create();
    374     attr->setMappedAttributeDeclaration(decl);
    375     ASSERT(!decl->declaration()->useStrictParsing());
    376 }
    377 
    378 unsigned MappedAttributeHash::hash(const MappedAttributeKey& key)
    379 {
    380     COMPILE_ASSERT(sizeof(key.name) == 4 || sizeof(key.name) == 8, key_name_size);
    381     COMPILE_ASSERT(sizeof(key.value) == 4 || sizeof(key.value) == 8, key_value_size);
    382 
    383     StringHasher hasher;
    384     const UChar* data;
    385 
    386     data = reinterpret_cast<const UChar*>(&key.name);
    387     hasher.addCharacters(data[0], data[1]);
    388     if (sizeof(key.name) == 8)
    389         hasher.addCharacters(data[2], data[3]);
    390 
    391     data = reinterpret_cast<const UChar*>(&key.value);
    392     hasher.addCharacters(data[0], data[1]);
    393     if (sizeof(key.value) == 8)
    394         hasher.addCharacters(data[2], data[3]);
    395 
    396     return hasher.hash();
     275        ensureAttributeStyle()->setMappedProperty(this, id, colorString);
     276        return;
     277    }
     278
     279    ensureAttributeStyle()->setMappedProperty(this, id, parseColorStringWithCrazyLegacyRules(colorString));
    397280}
    398281
  • trunk/Source/WebCore/dom/StyledElement.h

    r106695 r106740  
    4040
    4141    size_t mappedAttributeCount() const { return attributeMap() ? attributeMap()->mappedAttributeCount() : 0; }
    42     bool isMappedAttribute(const QualifiedName& name) const { MappedAttributeEntry res = eNone; mapToEntry(name, res); return res != eNone; }
    4342
    44     void addCSSLength(Attribute*, int id, const String& value);
    45     void addCSSProperty(Attribute*, int id, const String& value);
    46     void addCSSProperty(Attribute*, int id, int value);
    47     void addCSSImageProperty(Attribute*, int propertyID, const String& url);
    48     void addCSSColor(Attribute*, int id, const String& color);
    49     void removeCSSProperty(Attribute*, int id);
    50 
    51     static CSSMappedAttributeDeclaration* getMappedAttributeDecl(MappedAttributeEntry, const QualifiedName& name, const AtomicString& value);
    52     static void setMappedAttributeDecl(MappedAttributeEntry, const QualifiedName& name, const AtomicString& value, CSSMappedAttributeDeclaration*);
    53     static void removeMappedAttributeDecl(MappedAttributeEntry, const QualifiedName& name, const AtomicString& value);
    54 
    55     static CSSMappedAttributeDeclaration* getMappedAttributeDecl(MappedAttributeEntry, Attribute*);
    56     static void setMappedAttributeDecl(MappedAttributeEntry, Attribute*, CSSMappedAttributeDeclaration*);
     43    void addCSSLength(int id, const String& value);
     44    void addCSSProperty(int id, const String& value);
     45    void addCSSProperty(int id, int value);
     46    void addCSSImageProperty(int propertyID, const String& url);
     47    void addCSSColor(int id, const String& color);
     48    void removeCSSProperties(int id1, int id2 = CSSPropertyInvalid, int id3 = CSSPropertyInvalid, int id4 = CSSPropertyInvalid, int id5 = CSSPropertyInvalid, int id6 = CSSPropertyInvalid, int id7 = CSSPropertyInvalid, int id8 = CSSPropertyInvalid);
     49    void removeCSSProperty(int id) { removeCSSProperties(id); }
    5750
    5851    virtual PassRefPtr<StylePropertySet> additionalAttributeStyle() { return 0; }
     
    6356    virtual CSSStyleDeclaration* style() OVERRIDE { return ensureInlineStyleDecl()->ensureCSSStyleDeclaration(); }
    6457
     58    CSSMappedAttributeDeclaration* attributeStyle() const { return attributeMap() ? attributeMap()->attributeStyle() : 0; }
     59    CSSMappedAttributeDeclaration* ensureAttributeStyle() { return ensureAttributeMap()->ensureAttributeStyle(); }
     60
    6561    const SpaceSplitString& classNames() const;
    66 
    67     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    6862
    6963    virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
     
    8781
    8882private:
    89     void createMappedDecl(Attribute*);
    90 
    9183    virtual void updateStyleAttribute() const;
    9284
  • trunk/Source/WebCore/html/HTMLBRElement.cpp

    r88270 r106740  
    4949}
    5050
    51 bool HTMLBRElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    52 {
    53     if (attrName == clearAttr) {
    54         result = eUniversal;
    55         return false;
    56     }
    57    
    58     return HTMLElement::mapToEntry(attrName, result);
    59 }
    60 
    6151void HTMLBRElement::parseMappedAttribute(Attribute* attr)
    6252{
     
    6454        // If the string is empty, then don't add the clear property.
    6555        // <br clear> and <br clear=""> are just treated like <br> by Gecko, Mac IE, etc. -dwh
    66         const AtomicString& str = attr->value();
    67         if (!str.isEmpty()) {
    68             if (equalIgnoringCase(str, "all"))
    69                 addCSSProperty(attr, CSSPropertyClear, "both");
     56        if (attr->value().isNull())
     57            removeCSSProperty(CSSPropertyClear);
     58        else if (!attr->value().isEmpty()) {
     59            if (equalIgnoringCase(attr->value(), "all"))
     60                addCSSProperty(CSSPropertyClear, "both");
    7061            else
    71                 addCSSProperty(attr, CSSPropertyClear, str);
     62                addCSSProperty(CSSPropertyClear, attr->value());
    7263        }
    7364    } else
  • trunk/Source/WebCore/html/HTMLBRElement.h

    r86491 r106740  
    3939    HTMLBRElement(const QualifiedName&, Document*);
    4040
    41     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    4241    virtual void parseMappedAttribute(Attribute*);
    4342   
  • trunk/Source/WebCore/html/HTMLBodyElement.cpp

    r99742 r106740  
    6161}
    6262
    63 bool HTMLBodyElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    64 {
    65     if (attrName == backgroundAttr) {
    66         result = (MappedAttributeEntry)(eLastEntry + document()->docID());
    67         return false;
    68     }
    69    
    70     if (attrName == bgcolorAttr ||
    71         attrName == textAttr ||
    72         attrName == marginwidthAttr ||
    73         attrName == leftmarginAttr ||
    74         attrName == marginheightAttr ||
    75         attrName == topmarginAttr ||
    76         attrName == bgpropertiesAttr) {
    77         result = eUniversal;
    78         return false;
    79     }
    80 
    81     return HTMLElement::mapToEntry(attrName, result);
    82 }
    83 
    8463void HTMLBodyElement::parseMappedAttribute(Attribute* attr)
    8564{
     
    8766        String url = stripLeadingAndTrailingHTMLSpaces(attr->value());
    8867        if (!url.isEmpty())
    89             addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string());
     68            addCSSImageProperty(CSSPropertyBackgroundImage, document()->completeURL(url).string());
     69        else
     70            removeCSSProperty(CSSPropertyBackgroundImage);
    9071    } else if (attr->name() == marginwidthAttr || attr->name() == leftmarginAttr) {
    91         addCSSLength(attr, CSSPropertyMarginRight, attr->value());
    92         addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
     72        if (attr->value().isNull())
     73            removeCSSProperties(CSSPropertyMarginRight, CSSPropertyMarginLeft);
     74        else {
     75            addCSSLength(CSSPropertyMarginRight, attr->value());
     76            addCSSLength(CSSPropertyMarginLeft, attr->value());
     77        }
    9378    } else if (attr->name() == marginheightAttr || attr->name() == topmarginAttr) {
    94         addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
    95         addCSSLength(attr, CSSPropertyMarginTop, attr->value());
     79        if (attr->value().isNull())
     80            removeCSSProperties(CSSPropertyMarginBottom, CSSPropertyMarginTop);
     81        else {
     82            addCSSLength(CSSPropertyMarginBottom, attr->value());
     83            addCSSLength(CSSPropertyMarginTop, attr->value());
     84        }
    9685    } else if (attr->name() == bgcolorAttr) {
    97         addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
     86        if (attr->value().isNull())
     87            removeCSSProperty(CSSPropertyBackgroundColor);
     88        else
     89            addCSSColor(CSSPropertyBackgroundColor, attr->value());
    9890    } else if (attr->name() == textAttr) {
    99         addCSSColor(attr, CSSPropertyColor, attr->value());
     91        if (attr->value().isNull())
     92            removeCSSProperty(CSSPropertyColor);
     93        else
     94            addCSSColor(CSSPropertyColor, attr->value());
    10095    } else if (attr->name() == bgpropertiesAttr) {
    10196        if (equalIgnoringCase(attr->value(), "fixed"))
    102             addCSSProperty(attr, CSSPropertyBackgroundAttachment, CSSValueFixed);
     97            addCSSProperty(CSSPropertyBackgroundAttachment, CSSValueFixed);
     98        else
     99            removeCSSProperty(CSSPropertyBackgroundAttachment);
    103100    } else if (attr->name() == vlinkAttr ||
    104101               attr->name() == alinkAttr ||
  • trunk/Source/WebCore/html/HTMLBodyElement.h

    r97877 r106740  
    7171    HTMLBodyElement(const QualifiedName&, Document*);
    7272
    73     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    7473    virtual void parseMappedAttribute(Attribute*);
    7574
  • trunk/Source/WebCore/html/HTMLDivElement.cpp

    r103828 r106740  
    4949}
    5050
    51 bool HTMLDivElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    52 {
    53     if (attrName == alignAttr) {
    54         result = eBlock;
    55         return false;
    56     }
    57     return HTMLElement::mapToEntry(attrName, result);
    58 }
    59 
    6051void HTMLDivElement::parseMappedAttribute(Attribute* attr)
    6152{
    6253    if (attr->name() == alignAttr) {
     54        if (attr->value().isNull())
     55            removeCSSProperty(CSSPropertyTextAlign);
    6356        if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))
    64            addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitCenter);
     57           addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitCenter);
    6558        else if (equalIgnoringCase(attr->value(), "left"))
    66             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitLeft);
     59            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitLeft);
    6760        else if (equalIgnoringCase(attr->value(), "right"))
    68             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitRight);
     61            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitRight);
    6962        else
    70             addCSSProperty(attr, CSSPropertyTextAlign, attr->value());
     63            addCSSProperty(CSSPropertyTextAlign, attr->value());
    7164    } else
    7265        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLDivElement.h

    r89452 r106740  
    3737
    3838private:
    39     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    4039    virtual void parseMappedAttribute(Attribute*);
    4140};
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r106685 r106740  
    121121}
    122122
    123 bool HTMLElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    124 {
    125     if (attrName == alignAttr
    126         || attrName == contenteditableAttr
    127         || attrName == hiddenAttr) {
    128         result = eUniversal;
    129         return false;
    130     }
    131     if (attrName == dirAttr) {
    132         if (hasLocalName(bdoTag))
    133             result = eBDO;
    134         else if (hasLocalName(bdiTag))
    135             result = eBDI;
    136         else
    137             result = eUniversal;
    138         return true;
    139     }
    140 
    141     return StyledElement::mapToEntry(attrName, result);
    142 }
    143 
    144123static inline int unicodeBidiAttributeForDirAuto(HTMLElement* element)
    145124{
     
    164143void HTMLElement::applyBorderAttribute(Attribute* attr)
    165144{
    166     addCSSLength(attr, CSSPropertyBorderWidth, String::number(parseBorderWidthAttribute(attr)));
    167     addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
    168     addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
    169     addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
    170     addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
     145    addCSSLength(CSSPropertyBorderWidth, String::number(parseBorderWidthAttribute(attr)));
     146    addCSSProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
     147    addCSSProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
     148    addCSSProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
     149    addCSSProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
    171150}
    172151
     
    175154    ASSERT(attribute && (attribute->name() == langAttr || attribute->name().matches(XMLNames::langAttr)));
    176155    const AtomicString& value = attribute->value();
    177     if (!value.isEmpty()) {
     156    if (value.isNull())
     157        removeCSSProperty(CSSPropertyWebkitLocale);
     158    else if (!value.isEmpty()) {
    178159        // Have to quote so the locale id is treated as a string instead of as a CSS keyword.
    179         addCSSProperty(attribute, CSSPropertyWebkitLocale, quoteCSSString(value));
     160        addCSSProperty(CSSPropertyWebkitLocale, quoteCSSString(value));
    180161    } else {
    181162        // The empty string means the language is explicitly unknown.
    182         addCSSProperty(attribute, CSSPropertyWebkitLocale, CSSValueAuto);
     163        addCSSProperty(CSSPropertyWebkitLocale, CSSValueAuto);
    183164    }
    184165    setNeedsStyleRecalc();
     
    191172
    192173    if (attr->name() == alignAttr) {
    193         if (equalIgnoringCase(attr->value(), "middle"))
    194             addCSSProperty(attr, CSSPropertyTextAlign, "center");
     174        if (attr->isNull())
     175            removeCSSProperty(CSSPropertyTextAlign);
     176        else if (equalIgnoringCase(attr->value(), "middle"))
     177            addCSSProperty(CSSPropertyTextAlign, "center");
    195178        else
    196             addCSSProperty(attr, CSSPropertyTextAlign, attr->value());
     179            addCSSProperty(CSSPropertyTextAlign, attr->value());
    197180    } else if (attr->name() == contenteditableAttr) {
    198181        setContentEditable(attr);
    199182    } else if (attr->name() == hiddenAttr) {
    200         addCSSProperty(attr, CSSPropertyDisplay, CSSValueNone);
     183        if (attr->isNull())
     184            removeCSSProperty(CSSPropertyDisplay);
     185        else
     186            addCSSProperty(CSSPropertyDisplay, CSSValueNone);
    201187    } else if (attr->name() == tabindexAttr) {
    202188        int tabindex = 0;
     
    214200            mapLanguageAttributeToLocale(attr);
    215201    } else if (attr->name() == dirAttr) {
    216         bool dirIsAuto = equalIgnoringCase(attr->value(), "auto");
    217         if (!dirIsAuto)
    218             addCSSProperty(attr, CSSPropertyDirection, attr->value());
    219         dirAttributeChanged(attr);
    220         if (dirIsAuto)
    221             addCSSProperty(attr, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
    222         else if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag))
    223             addCSSProperty(attr, CSSPropertyUnicodeBidi, CSSValueEmbed);
     202        if (attr->isNull())
     203            removeCSSProperties(CSSPropertyDirection, CSSPropertyUnicodeBidi);
     204        else {
     205            bool dirIsAuto = equalIgnoringCase(attr->value(), "auto");
     206            if (!dirIsAuto)
     207                addCSSProperty(CSSPropertyDirection, attr->value());
     208            else
     209                removeCSSProperty(CSSPropertyDirection);
     210
     211            dirAttributeChanged(attr);
     212            if (dirIsAuto)
     213                addCSSProperty(CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
     214            else if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag))
     215                addCSSProperty(CSSPropertyUnicodeBidi, CSSValueEmbed);
     216            else
     217                removeCSSProperty(CSSPropertyUnicodeBidi);
     218        }
    224219    } else if (attr->name() == draggableAttr) {
    225220        const AtomicString& value = attr->value();
    226221        if (equalIgnoringCase(value, "true")) {
    227             addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueElement);
    228             addCSSProperty(attr, CSSPropertyWebkitUserSelect, CSSValueNone);
    229         } else if (equalIgnoringCase(value, "false"))
    230             addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueNone);
     222            addCSSProperty(CSSPropertyWebkitUserDrag, CSSValueElement);
     223            addCSSProperty(CSSPropertyWebkitUserSelect, CSSValueNone);
     224        } else if (equalIgnoringCase(value, "false")) {
     225            addCSSProperty(CSSPropertyWebkitUserDrag, CSSValueNone);
     226            removeCSSProperty(CSSPropertyWebkitUserSelect);
     227        } else
     228            removeCSSProperties(CSSPropertyWebkitUserDrag, CSSPropertyWebkitUserSelect);
    231229#if ENABLE(MICRODATA)
    232230    } else if (attr->name() == itempropAttr) {
     
    686684}
    687685
     686void HTMLElement::removeHTMLAlignment()
     687{
     688    removeCSSProperties(CSSPropertyFloat, CSSPropertyVerticalAlign);
     689}
     690
    688691void HTMLElement::addHTMLAlignmentToStyledElement(StyledElement* element, Attribute* attr)
    689692{
     
    716719
    717720    if (floatValue != CSSValueInvalid)
    718         element->addCSSProperty(attr, CSSPropertyFloat, floatValue);
     721        element->addCSSProperty(CSSPropertyFloat, floatValue);
     722    else
     723        element->removeCSSProperty(CSSPropertyFloat);
    719724
    720725    if (verticalAlignValue != CSSValueInvalid)
    721         element->addCSSProperty(attr, CSSPropertyVerticalAlign, verticalAlignValue);
     726        element->addCSSProperty(CSSPropertyVerticalAlign, verticalAlignValue);
     727    else
     728        element->removeCSSProperty(CSSPropertyVerticalAlign);
    722729}
    723730
     
    746753{
    747754    const AtomicString& enabled = attr->value();
    748     if (enabled.isEmpty() || equalIgnoringCase(enabled, "true")) {
    749         addCSSProperty(attr, CSSPropertyWebkitUserModify, CSSValueReadWrite);
    750         addCSSProperty(attr, CSSPropertyWordWrap, CSSValueBreakWord);
    751         addCSSProperty(attr, CSSPropertyWebkitNbspMode, CSSValueSpace);
    752         addCSSProperty(attr, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
     755    if (enabled.isNull())
     756        removeCSSProperties(CSSPropertyWebkitUserModify, CSSPropertyWordWrap, CSSPropertyWebkitNbspMode, CSSPropertyWebkitLineBreak);
     757    else if (enabled.isEmpty() || equalIgnoringCase(enabled, "true")) {
     758        addCSSProperty(CSSPropertyWebkitUserModify, CSSValueReadWrite);
     759        addCSSProperty(CSSPropertyWordWrap, CSSValueBreakWord);
     760        addCSSProperty(CSSPropertyWebkitNbspMode, CSSValueSpace);
     761        addCSSProperty(CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
    753762    } else if (equalIgnoringCase(enabled, "false")) {
    754         addCSSProperty(attr, CSSPropertyWebkitUserModify, CSSValueReadOnly);
    755         removeCSSProperty(attr, CSSPropertyWordWrap);
    756         removeCSSProperty(attr, CSSPropertyWebkitNbspMode);
    757         removeCSSProperty(attr, CSSPropertyWebkitLineBreak);
     763        addCSSProperty(CSSPropertyWebkitUserModify, CSSValueReadOnly);
     764        removeCSSProperties(CSSPropertyWordWrap, CSSPropertyWebkitNbspMode, CSSPropertyWebkitLineBreak);
    758765    } else if (equalIgnoringCase(enabled, "plaintext-only")) {
    759         addCSSProperty(attr, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
    760         addCSSProperty(attr, CSSPropertyWordWrap, CSSValueBreakWord);
    761         addCSSProperty(attr, CSSPropertyWebkitNbspMode, CSSValueSpace);
    762         addCSSProperty(attr, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
     766        addCSSProperty(CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
     767        addCSSProperty(CSSPropertyWordWrap, CSSValueBreakWord);
     768        addCSSProperty(CSSPropertyWebkitNbspMode, CSSValueSpace);
     769        addCSSProperty(CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
    763770    }
    764771}
  • trunk/Source/WebCore/html/HTMLElement.h

    r104383 r106740  
    9595
    9696    void addHTMLAlignment(Attribute*);
     97    void removeHTMLAlignment();
    9798
    98     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    9999    virtual void parseMappedAttribute(Attribute*);
    100100    void applyBorderAttribute(Attribute*);
  • trunk/Source/WebCore/html/HTMLEmbedElement.cpp

    r106515 r106740  
    7575}
    7676
    77 bool HTMLEmbedElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    78 {
    79     if (attrName == hiddenAttr) {
    80         result = eUniversal;
    81         return false;
    82     }
    83        
    84     return HTMLPlugInImageElement::mapToEntry(attrName, result);
    85 }
    86 
    8777void HTMLEmbedElement::parseMappedAttribute(Attribute* attr)
    8878{
     
    10999            // FIXME: Not dynamic, since we add this but don't remove it, but it may be OK for now
    110100            // that this rarely-used attribute won't work properly if you remove it.
    111             addCSSLength(attr, CSSPropertyWidth, "0");
    112             addCSSLength(attr, CSSPropertyHeight, "0");
    113         }
     101            addCSSLength(CSSPropertyWidth, "0");
     102            addCSSLength(CSSPropertyHeight, "0");
     103        } else
     104            removeCSSProperties(CSSPropertyWidth, CSSPropertyHeight);
    114105    } else
    115106        HTMLPlugInImageElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLEmbedElement.h

    r105030 r106740  
    3535    HTMLEmbedElement(const QualifiedName&, Document*, bool createdByParser);
    3636
    37     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    3837    virtual void parseMappedAttribute(Attribute*);
    3938
  • trunk/Source/WebCore/html/HTMLFontElement.cpp

    r94640 r106740  
    124124}
    125125
    126 bool HTMLFontElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    127 {
    128     if (attrName == sizeAttr ||
    129         attrName == colorAttr ||
    130         attrName == faceAttr) {
    131         result = eUniversal;
    132         return false;
    133     }
    134    
    135     return HTMLElement::mapToEntry(attrName, result);
    136 }
    137 
    138126bool HTMLFontElement::cssValueFromFontSizeNumber(const String& s, int& size)
    139127{
     
    176164        int size = 0;
    177165        if (cssValueFromFontSizeNumber(attr->value(), size))
    178             addCSSProperty(attr, CSSPropertyFontSize, size);
     166            addCSSProperty(CSSPropertyFontSize, size);
     167        else
     168            removeCSSProperty(CSSPropertyFontSize);
    179169    } else if (attr->name() == colorAttr) {
    180         addCSSColor(attr, CSSPropertyColor, attr->value());
     170        if (attr->value().isNull())
     171            removeCSSProperty(CSSPropertyColor);
     172        else
     173            addCSSColor(CSSPropertyColor, attr->value());
    181174    } else if (attr->name() == faceAttr) {
    182         addCSSProperty(attr, CSSPropertyFontFamily, attr->value());
     175        if (attr->value().isNull())
     176            removeCSSProperty(CSSPropertyFontFamily);
     177        else
     178            addCSSProperty(CSSPropertyFontFamily, attr->value());
    183179    } else
    184180        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLFontElement.h

    r66057 r106740  
    3838    HTMLFontElement(const QualifiedName&, Document*);
    3939
    40     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    4140    virtual void parseMappedAttribute(Attribute*);
    4241};
  • trunk/Source/WebCore/html/HTMLFrameSetElement.cpp

    r94406 r106740  
    6565}
    6666
    67 bool HTMLFrameSetElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    68 {
    69     if (attrName == bordercolorAttr) {
    70         result = eUniversal;
    71         return true;
    72     }
    73 
    74     return HTMLElement::mapToEntry(attrName, result);
    75 }
    76 
    7767void HTMLFrameSetElement::parseMappedAttribute(Attribute* attr)
    7868{
     
    110100            m_borderSet = false;
    111101    } else if (attr->name() == bordercolorAttr) {
    112         m_borderColorSet = attr->decl();
    113         if (!attr->decl() && !attr->isEmpty()) {
    114             addCSSColor(attr, CSSPropertyBorderColor, attr->value());
    115             m_borderColorSet = true;
    116         }
     102        m_borderColorSet = !attr->isEmpty();
     103        if (attr->value().isNull())
     104            removeCSSProperty(CSSPropertyBorderColor);
     105        else
     106            addCSSColor(CSSPropertyBorderColor, attr->value());
    117107    } else if (attr->name() == onloadAttr)
    118108        document()->setWindowAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(document()->frame(), attr));
  • trunk/Source/WebCore/html/HTMLFrameSetElement.h

    r94406 r106740  
    6868    HTMLFrameSetElement(const QualifiedName&, Document*);
    6969
    70     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    7170    virtual void parseMappedAttribute(Attribute*);
    7271
  • trunk/Source/WebCore/html/HTMLHRElement.cpp

    r61959 r106740  
    4949}
    5050
    51 bool HTMLHRElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    52 {
    53     if (attrName == alignAttr ||
    54         attrName == widthAttr ||
    55         attrName == colorAttr ||
    56         attrName == sizeAttr ||
    57         attrName == noshadeAttr) {
    58         result = eHR;
    59         return false;
    60     }
    61     return HTMLElement::mapToEntry(attrName, result);
    62 }
    63 
    6451void HTMLHRElement::parseMappedAttribute(Attribute* attr)
    6552{
    6653    if (attr->name() == alignAttr) {
    67         if (equalIgnoringCase(attr->value(), "left")) {
    68             addCSSProperty(attr, CSSPropertyMarginLeft, "0");
    69             addCSSProperty(attr, CSSPropertyMarginRight, CSSValueAuto);
     54        if (attr->value().isNull()) {
     55            removeCSSProperties(CSSPropertyMarginLeft, CSSPropertyMarginRight);
     56        } else if (equalIgnoringCase(attr->value(), "left")) {
     57            addCSSProperty(CSSPropertyMarginLeft, "0");
     58            addCSSProperty(CSSPropertyMarginRight, CSSValueAuto);
    7059        } else if (equalIgnoringCase(attr->value(), "right")) {
    71             addCSSProperty(attr, CSSPropertyMarginLeft, CSSValueAuto);
    72             addCSSProperty(attr, CSSPropertyMarginRight, "0");
     60            addCSSProperty(CSSPropertyMarginLeft, CSSValueAuto);
     61            addCSSProperty(CSSPropertyMarginRight, "0");
    7362        } else {
    74             addCSSProperty(attr, CSSPropertyMarginLeft, CSSValueAuto);
    75             addCSSProperty(attr, CSSPropertyMarginRight, CSSValueAuto);
     63            addCSSProperty(CSSPropertyMarginLeft, CSSValueAuto);
     64            addCSSProperty(CSSPropertyMarginRight, CSSValueAuto);
    7665        }
    7766    } else if (attr->name() == widthAttr) {
    78         bool ok;
    79         int v = attr->value().toInt(&ok);
    80         if (ok && !v)
    81             addCSSLength(attr, CSSPropertyWidth, "1");
    82         else
    83             addCSSLength(attr, CSSPropertyWidth, attr->value());
     67        if (attr->value().isNull())
     68            removeCSSProperty(CSSPropertyWidth);
     69        else {
     70            bool ok;
     71            int v = attr->value().toInt(&ok);
     72            if (ok && !v)
     73                addCSSLength(CSSPropertyWidth, "1");
     74            else
     75                addCSSLength(CSSPropertyWidth, attr->value());
     76        }
    8477    } else if (attr->name() == colorAttr) {
    85         addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
    86         addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
    87         addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
    88         addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
    89         addCSSColor(attr, CSSPropertyBorderColor, attr->value());
    90         addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
     78        if (attr->value().isNull())
     79            removeCSSProperties(CSSPropertyBorderTopStyle, CSSPropertyBorderRightStyle, CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle, CSSPropertyBorderColor, CSSPropertyBackgroundColor);
     80        else {
     81            addCSSProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
     82            addCSSProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
     83            addCSSProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
     84            addCSSProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
     85            addCSSColor(CSSPropertyBorderColor, attr->value());
     86            addCSSColor(CSSPropertyBackgroundColor, attr->value());
     87        }
    9188    } else if (attr->name() == noshadeAttr) {
    92         addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
    93         addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
    94         addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
    95         addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
    96         addCSSColor(attr, CSSPropertyBorderColor, String("grey"));
    97         addCSSColor(attr, CSSPropertyBackgroundColor, String("grey"));
     89        if (attr->value().isNull())
     90            removeCSSProperties(CSSPropertyBorderTopStyle, CSSPropertyBorderRightStyle, CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle, CSSPropertyBorderColor, CSSPropertyBackgroundColor);
     91        else {
     92            addCSSProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
     93            addCSSProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
     94            addCSSProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
     95            addCSSProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
     96            addCSSColor(CSSPropertyBorderColor, String("grey"));
     97            addCSSColor(CSSPropertyBackgroundColor, String("grey"));
     98        }
    9899    } else if (attr->name() == sizeAttr) {
    99         StringImpl* si = attr->value().impl();
    100         int size = si->toInt();
    101         if (size <= 1)
    102             addCSSProperty(attr, CSSPropertyBorderBottomWidth, String("0"));
    103         else
    104             addCSSLength(attr, CSSPropertyHeight, String::number(size-2));
     100        if (attr->value().isNull())
     101            removeCSSProperties(CSSPropertyBorderBottomWidth, CSSPropertyHeight);
     102        else {
     103            StringImpl* si = attr->value().impl();
     104            int size = si->toInt();
     105            if (size <= 1) {
     106                addCSSProperty(CSSPropertyBorderBottomWidth, String("0"));
     107                removeCSSProperty(CSSPropertyHeight);
     108            } else {
     109                addCSSLength(CSSPropertyHeight, String::number(size-2));
     110                removeCSSProperty(CSSPropertyBorderBottomWidth);
     111            }
     112        }
    105113    } else
    106114        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLHRElement.h

    r86491 r106740  
    3737private:
    3838    HTMLHRElement(const QualifiedName&, Document*);
    39    
    40     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
     39
    4140    virtual void parseMappedAttribute(Attribute*);
    4241};
  • trunk/Source/WebCore/html/HTMLIFrameElement.cpp

    r105668 r106740  
    4949}
    5050
    51 bool HTMLIFrameElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    52 {
    53     if (attrName == widthAttr || attrName == heightAttr) {
    54         result = eUniversal;
    55         return false;
    56     }
    57    
    58     if (attrName == alignAttr) {
    59         result = eReplaced; // Share with <img> since the alignment behavior is the same.
    60         return false;
    61     }
    62    
    63     if (attrName == frameborderAttr) {
    64         result = eReplaced;
    65         return false;
    66     }
    67 
    68     return HTMLFrameElementBase::mapToEntry(attrName, result);
    69 }
    70 
    7151void HTMLIFrameElement::parseMappedAttribute(Attribute* attr)
    7252{
    7353    if (attr->name() == widthAttr)
    74         addCSSLength(attr, CSSPropertyWidth, attr->value());
     54        addCSSLength(CSSPropertyWidth, attr->value());
    7555    else if (attr->name() == heightAttr)
    76         addCSSLength(attr, CSSPropertyHeight, attr->value());
     56        addCSSLength(CSSPropertyHeight, attr->value());
    7757    else if (attr->name() == alignAttr)
    7858        addHTMLAlignment(attr);
     
    8868        // Frame border doesn't really match the HTML4 spec definition for iframes.  It simply adds
    8969        // a presentational hint that the border should be off if set to zero.
    90         if (!attr->isNull() && !attr->value().toInt())
     70        if (!attr->isNull() && !attr->value().toInt()) {
    9171            // Add a rule that nulls out our border width.
    92             addCSSLength(attr, CSSPropertyBorderWidth, "0");
     72            addCSSLength(CSSPropertyBorderWidth, "0");
     73        } else
     74            removeCSSProperty(CSSPropertyBorderWidth);
    9375    } else if (attr->name() == sandboxAttr)
    9476        setSandboxFlags(attr->isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(attr->value()));
  • trunk/Source/WebCore/html/HTMLIFrameElement.h

    r99742 r106740  
    3636    HTMLIFrameElement(const QualifiedName&, Document*);
    3737
    38     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    3938    virtual void parseMappedAttribute(Attribute*);
    4039
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r105668 r106740  
    7979}
    8080
    81 bool HTMLImageElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    82 {
    83     if (attrName == widthAttr ||
    84         attrName == heightAttr ||
    85         attrName == vspaceAttr ||
    86         attrName == hspaceAttr ||
    87         attrName == valignAttr) {
    88         result = eUniversal;
    89         return false;
    90     }
    91 
    92     if (attrName == borderAttr || attrName == alignAttr) {
    93         result = eReplaced; // Shared with embed and iframe elements.
    94         return false;
    95     }
    96 
    97     return HTMLElement::mapToEntry(attrName, result);
    98 }
    99 
    10081void HTMLImageElement::parseMappedAttribute(Attribute* attr)
    10182{
     
    10788        m_imageLoader.updateFromElementIgnoringPreviousError();
    10889    else if (attrName == widthAttr)
    109         addCSSLength(attr, CSSPropertyWidth, attr->value());
     90        if (attr->value().isNull())
     91            removeCSSProperty(CSSPropertyWidth);
     92        else
     93            addCSSLength(CSSPropertyWidth, attr->value());
    11094    else if (attrName == heightAttr)
    111         addCSSLength(attr, CSSPropertyHeight, attr->value());
     95        if (attr->value().isNull())
     96            removeCSSProperty(CSSPropertyHeight);
     97        else
     98            addCSSLength(CSSPropertyHeight, attr->value());
    11299    else if (attrName == borderAttr) {
    113100        // border="noborder" -> border="0"
    114101        applyBorderAttribute(attr);
    115102    } else if (attrName == vspaceAttr) {
    116         addCSSLength(attr, CSSPropertyMarginTop, attr->value());
    117         addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
     103        if (attr->value().isNull())
     104            removeCSSProperties(CSSPropertyMarginTop, CSSPropertyMarginBottom);
     105        else {
     106            addCSSLength(CSSPropertyMarginTop, attr->value());
     107            addCSSLength(CSSPropertyMarginBottom, attr->value());
     108        }
    118109    } else if (attrName == hspaceAttr) {
    119         addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
    120         addCSSLength(attr, CSSPropertyMarginRight, attr->value());
     110        if (attr->value().isNull())
     111            removeCSSProperties(CSSPropertyMarginLeft, CSSPropertyMarginRight);
     112        else {
     113            addCSSLength(CSSPropertyMarginLeft, attr->value());
     114            addCSSLength(CSSPropertyMarginRight, attr->value());
     115        }
    121116    } else if (attrName == alignAttr)
    122117        addHTMLAlignment(attr);
    123118    else if (attrName == valignAttr)
    124         addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
     119        if (attr->value().isNull())
     120            removeCSSProperty(CSSPropertyVerticalAlign);
     121        else
     122            addCSSProperty(CSSPropertyVerticalAlign, attr->value());
    125123    else if (attrName == usemapAttr)
    126124        setIsLink(!attr->isNull());
  • trunk/Source/WebCore/html/HTMLImageElement.h

    r103679 r106740  
    8484
    8585private:
    86     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    8786    virtual void parseMappedAttribute(Attribute*);
    8887
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r105980 r106740  
    658658{
    659659    m_inputType->accessKeyAction(sendMouseEvents);
    660 }
    661 
    662 bool HTMLInputElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    663 {
    664     if (((attrName == heightAttr || attrName == widthAttr) && m_inputType->shouldRespectHeightAndWidthAttributes())
    665         || attrName == vspaceAttr
    666         || attrName == hspaceAttr) {
    667         result = eUniversal;
    668         return false;
    669     }
    670 
    671     if (attrName == alignAttr && m_inputType->shouldRespectAlignAttribute()) {
    672         // Share with <img> since the alignment behavior is the same.
    673         result = eReplaced;
    674         return false;
    675     }
    676 
    677     return HTMLElement::mapToEntry(attrName, result);
    678660}
    679661
     
    734716        // FIXME: ignore for the moment
    735717    } else if (attr->name() == vspaceAttr) {
    736         addCSSLength(attr, CSSPropertyMarginTop, attr->value());
    737         addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
     718        addCSSLength(CSSPropertyMarginTop, attr->value());
     719        addCSSLength(CSSPropertyMarginBottom, attr->value());
    738720    } else if (attr->name() == hspaceAttr) {
    739         addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
    740         addCSSLength(attr, CSSPropertyMarginRight, attr->value());
     721        addCSSLength(CSSPropertyMarginLeft, attr->value());
     722        addCSSLength(CSSPropertyMarginRight, attr->value());
    741723    } else if (attr->name() == alignAttr) {
    742724        if (m_inputType->shouldRespectAlignAttribute())
    743725            addHTMLAlignment(attr);
     726        else
     727            removeHTMLAlignment();
    744728    } else if (attr->name() == widthAttr) {
    745729        if (m_inputType->shouldRespectHeightAndWidthAttributes())
    746             addCSSLength(attr, CSSPropertyWidth, attr->value());
     730            addCSSLength(CSSPropertyWidth, attr->value());
     731        else
     732            removeCSSProperty(CSSPropertyWidth);
    747733    } else if (attr->name() == heightAttr) {
    748734        if (m_inputType->shouldRespectHeightAndWidthAttributes())
    749             addCSSLength(attr, CSSPropertyHeight, attr->value());
     735            addCSSLength(CSSPropertyHeight, attr->value());
     736        else
     737            removeCSSProperty(CSSPropertyHeight);
    750738    } else if (attr->name() == borderAttr && isImageButton()) {
    751739        applyBorderAttribute(attr);
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r105710 r106740  
    277277    virtual void accessKeyAction(bool sendMouseEvents);
    278278
    279     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    280279    virtual void parseMappedAttribute(Attribute*);
    281280    virtual void finishParsingChildren();
  • trunk/Source/WebCore/html/HTMLLIElement.cpp

    r102290 r106740  
    5050}
    5151
    52 bool HTMLLIElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    53 {
    54     if (attrName == typeAttr) {
    55         result = eListItem; // Share with <ol> since all the values are the same
    56         return false;
    57     }
    58    
    59     return HTMLElement::mapToEntry(attrName, result);
    60 }
    61 
    6252void HTMLLIElement::parseMappedAttribute(Attribute* attr)
    6353{
     
    6656            parseValue(attr->value());
    6757    } else if (attr->name() == typeAttr) {
    68         if (attr->value() == "a")
    69             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueLowerAlpha);
     58        if (attr->value().isNull())
     59            removeCSSProperty(CSSPropertyListStyleType);
     60        else if (attr->value() == "a")
     61            addCSSProperty(CSSPropertyListStyleType, CSSValueLowerAlpha);
    7062        else if (attr->value() == "A")
    71             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueUpperAlpha);
     63            addCSSProperty(CSSPropertyListStyleType, CSSValueUpperAlpha);
    7264        else if (attr->value() == "i")
    73             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueLowerRoman);
     65            addCSSProperty(CSSPropertyListStyleType, CSSValueLowerRoman);
    7466        else if (attr->value() == "I")
    75             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueUpperRoman);
     67            addCSSProperty(CSSPropertyListStyleType, CSSValueUpperRoman);
    7668        else if (attr->value() == "1")
    77             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueDecimal);
     69            addCSSProperty(CSSPropertyListStyleType, CSSValueDecimal);
    7870        else
    79             addCSSProperty(attr, CSSPropertyListStyleType, attr->value());
     71            addCSSProperty(CSSPropertyListStyleType, attr->value());
    8072    } else
    8173        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLLIElement.h

    r102290 r106740  
    3636    HTMLLIElement(const QualifiedName&, Document*);
    3737
    38     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    3938    virtual void parseMappedAttribute(Attribute*);
    4039
  • trunk/Source/WebCore/html/HTMLMarqueeElement.cpp

    r106667 r106740  
    5252}
    5353
    54 bool HTMLMarqueeElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    55 {
    56     if (attrName == widthAttr ||
    57         attrName == heightAttr ||
    58         attrName == bgcolorAttr ||
    59         attrName == vspaceAttr ||
    60         attrName == hspaceAttr ||
    61         attrName == scrollamountAttr ||
    62         attrName == scrolldelayAttr ||
    63         attrName == loopAttr ||
    64         attrName == behaviorAttr ||
    65         attrName == directionAttr) {
    66         result = eUniversal;
    67         return false;
    68     }
    69 
    70     return HTMLElement::mapToEntry(attrName, result);
    71 }
    72 
    7354void HTMLMarqueeElement::parseMappedAttribute(Attribute* attr)
    7455{
    7556    if (attr->name() == widthAttr) {
    7657        if (!attr->value().isEmpty())
    77             addCSSLength(attr, CSSPropertyWidth, attr->value());
     58            addCSSLength(CSSPropertyWidth, attr->value());
     59        else
     60            removeCSSProperty(CSSPropertyWidth);
    7861    } else if (attr->name() == heightAttr) {
    7962        if (!attr->value().isEmpty())
    80             addCSSLength(attr, CSSPropertyHeight, attr->value());
     63            addCSSLength(CSSPropertyHeight, attr->value());
     64        else
     65            removeCSSProperty(CSSPropertyHeight);
    8166    } else if (attr->name() == bgcolorAttr) {
    8267        if (!attr->value().isEmpty())
    83             addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
     68            addCSSColor(CSSPropertyBackgroundColor, attr->value());
     69        else
     70            removeCSSProperty(CSSPropertyBackgroundColor);
    8471    } else if (attr->name() == vspaceAttr) {
    8572        if (!attr->value().isEmpty()) {
    86             addCSSLength(attr, CSSPropertyMarginTop, attr->value());
    87             addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
    88         }
     73            addCSSLength(CSSPropertyMarginTop, attr->value());
     74            addCSSLength(CSSPropertyMarginBottom, attr->value());
     75        } else
     76            removeCSSProperties(CSSPropertyMarginTop, CSSPropertyMarginBottom);
    8977    } else if (attr->name() == hspaceAttr) {
    9078        if (!attr->value().isEmpty()) {
    91             addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
    92             addCSSLength(attr, CSSPropertyMarginRight, attr->value());
    93         }
     79            addCSSLength(CSSPropertyMarginLeft, attr->value());
     80            addCSSLength(CSSPropertyMarginRight, attr->value());
     81        } else
     82            removeCSSProperties(CSSPropertyMarginLeft, CSSPropertyMarginRight);
    9483    } else if (attr->name() == scrollamountAttr) {
    9584        if (!attr->value().isEmpty())
    96             addCSSLength(attr, CSSPropertyWebkitMarqueeIncrement, attr->value());
     85            addCSSLength(CSSPropertyWebkitMarqueeIncrement, attr->value());
     86        else
     87            removeCSSProperty(CSSPropertyWebkitMarqueeIncrement);
    9788    } else if (attr->name() == scrolldelayAttr) {
    9889        if (!attr->value().isEmpty())
    99             addCSSLength(attr, CSSPropertyWebkitMarqueeSpeed, attr->value());
     90            addCSSLength(CSSPropertyWebkitMarqueeSpeed, attr->value());
     91        else
     92            removeCSSProperty(CSSPropertyWebkitMarqueeSpeed);
    10093    } else if (attr->name() == loopAttr) {
    10194        if (!attr->value().isEmpty()) {
    10295            if (attr->value() == "-1" || equalIgnoringCase(attr->value(), "infinite"))
    103                 addCSSProperty(attr, CSSPropertyWebkitMarqueeRepetition, CSSValueInfinite);
     96                addCSSProperty(CSSPropertyWebkitMarqueeRepetition, CSSValueInfinite);
    10497            else
    105                 addCSSLength(attr, CSSPropertyWebkitMarqueeRepetition, attr->value());
    106         }
     98                addCSSLength(CSSPropertyWebkitMarqueeRepetition, attr->value());
     99        } else
     100            removeCSSProperty(CSSPropertyWebkitMarqueeRepetition);
    107101    } else if (attr->name() == behaviorAttr) {
    108102        if (!attr->value().isEmpty())
    109             addCSSProperty(attr, CSSPropertyWebkitMarqueeStyle, attr->value());
     103            addCSSProperty(CSSPropertyWebkitMarqueeStyle, attr->value());
     104        else
     105            removeCSSProperty(CSSPropertyWebkitMarqueeStyle);
    110106    } else if (attr->name() == directionAttr) {
    111107        if (!attr->value().isEmpty())
    112             addCSSProperty(attr, CSSPropertyWebkitMarqueeDirection, attr->value());
     108            addCSSProperty(CSSPropertyWebkitMarqueeDirection, attr->value());
     109        else
     110            removeCSSProperty(CSSPropertyWebkitMarqueeDirection);
    113111    } else if (attr->name() == truespeedAttr)
    114112        m_minimumDelay = !attr->isEmpty() ? 0 : defaultMinimumDelay;
  • trunk/Source/WebCore/html/HTMLMarqueeElement.h

    r73189 r106740  
    5454    HTMLMarqueeElement(const QualifiedName&, Document*);
    5555
    56     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    5756    virtual void parseMappedAttribute(Attribute*);
    5857
  • trunk/Source/WebCore/html/HTMLOListElement.cpp

    r103074 r106740  
    5555}
    5656
    57 bool HTMLOListElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    58 {
    59     if (attrName == typeAttr) {
    60         result = eListItem; // Share with <li>
    61         return false;
    62     }
    63    
    64     return HTMLElement::mapToEntry(attrName, result);
    65 }
    66 
    6757void HTMLOListElement::parseMappedAttribute(Attribute* attr)
    6858{
    6959    if (attr->name() == typeAttr) {
    7060        if (attr->value() == "a")
    71             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueLowerAlpha);
     61            addCSSProperty(CSSPropertyListStyleType, CSSValueLowerAlpha);
    7262        else if (attr->value() == "A")
    73             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueUpperAlpha);
     63            addCSSProperty(CSSPropertyListStyleType, CSSValueUpperAlpha);
    7464        else if (attr->value() == "i")
    75             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueLowerRoman);
     65            addCSSProperty(CSSPropertyListStyleType, CSSValueLowerRoman);
    7666        else if (attr->value() == "I")
    77             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueUpperRoman);
     67            addCSSProperty(CSSPropertyListStyleType, CSSValueUpperRoman);
    7868        else if (attr->value() == "1")
    79             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueDecimal);
     69            addCSSProperty(CSSPropertyListStyleType, CSSValueDecimal);
     70        else
     71            removeCSSProperty(CSSPropertyListStyleType);
    8072    } else if (attr->name() == startAttr) {
    8173        int oldStart = start();
  • trunk/Source/WebCore/html/HTMLOListElement.h

    r103074 r106740  
    5454    void recalculateItemCount();
    5555
    56     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    5756    virtual void parseMappedAttribute(Attribute*);
    5857
  • trunk/Source/WebCore/html/HTMLOutputElement.cpp

    r101268 r106740  
    6060{
    6161    return Node::supportsFocus() && !disabled();
    62 }
    63 
    64 bool HTMLOutputElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    65 {
    66     if (attrName == HTMLNames::dirAttr) {
    67         result = eBDI;
    68         return true;
    69     }
    70 
    71     return HTMLElement::mapToEntry(attrName, result);
    7262}
    7363
  • trunk/Source/WebCore/html/HTMLOutputElement.h

    r101268 r106740  
    5656    HTMLOutputElement(const QualifiedName&, Document*, HTMLFormElement*);
    5757
    58     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const OVERRIDE;
    5958    virtual void parseMappedAttribute(Attribute*);
    6059    virtual const AtomicString& formControlType() const;
  • trunk/Source/WebCore/html/HTMLParagraphElement.cpp

    r103827 r106740  
    4545}
    4646
    47 bool HTMLParagraphElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    48 {
    49     if (attrName == alignAttr) {
    50         result = eBlock; // We can share with DIV here.
    51         return false;
    52     }
    53     return HTMLElement::mapToEntry(attrName, result);
    54 }
    55 
    5647void HTMLParagraphElement::parseMappedAttribute(Attribute* attr)
    5748{
    5849    if (attr->name() == alignAttr) {
    59         if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))
    60             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitCenter);
     50        if (attr->value().isNull())
     51            removeCSSProperty(CSSPropertyTextAlign);
     52        else if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))
     53            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitCenter);
    6154        else if (equalIgnoringCase(attr->value(), "left"))
    62             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitLeft);
     55            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitLeft);
    6356        else if (equalIgnoringCase(attr->value(), "right"))
    64             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitRight);
     57            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitRight);
    6558        else
    66             addCSSProperty(attr, CSSPropertyTextAlign, attr->value());
     59            addCSSProperty(CSSPropertyTextAlign, attr->value());
    6760    } else
    6861        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLParagraphElement.h

    r66057 r106740  
    3535    HTMLParagraphElement(const QualifiedName&, Document*);
    3636
    37     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    3837    virtual void parseMappedAttribute(Attribute*);
    3938};
  • trunk/Source/WebCore/html/HTMLPlugInElement.cpp

    r105932 r106740  
    137137}
    138138
    139 bool HTMLPlugInElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    140 {
    141     if (attrName == widthAttr ||
    142         attrName == heightAttr ||
    143         attrName == vspaceAttr ||
    144         attrName == hspaceAttr) {
    145             result = eUniversal;
    146             return false;
    147     }
    148    
    149     if (attrName == alignAttr) {
    150         result = eReplaced; // Share with <img> since the alignment behavior is the same.
    151         return false;
    152     }
    153    
    154     return HTMLFrameOwnerElement::mapToEntry(attrName, result);
    155 }
    156 
    157139void HTMLPlugInElement::parseMappedAttribute(Attribute* attr)
    158140{
    159141    if (attr->name() == widthAttr)
    160         addCSSLength(attr, CSSPropertyWidth, attr->value());
     142        if (attr->isNull())
     143            removeCSSProperty(CSSPropertyWidth);
     144        else
     145            addCSSLength(CSSPropertyWidth, attr->value());
    161146    else if (attr->name() == heightAttr)
    162         addCSSLength(attr, CSSPropertyHeight, attr->value());
     147        if (attr->isNull())
     148            removeCSSProperty(CSSPropertyHeight);
     149        else
     150            addCSSLength(CSSPropertyHeight, attr->value());
    163151    else if (attr->name() == vspaceAttr) {
    164         addCSSLength(attr, CSSPropertyMarginTop, attr->value());
    165         addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
     152        if (attr->isNull())
     153            removeCSSProperties(CSSPropertyMarginTop, CSSPropertyMarginBottom);
     154        else {
     155            addCSSLength(CSSPropertyMarginTop, attr->value());
     156            addCSSLength(CSSPropertyMarginBottom, attr->value());
     157        }
    166158    } else if (attr->name() == hspaceAttr) {
    167         addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
    168         addCSSLength(attr, CSSPropertyMarginRight, attr->value());
     159        if (attr->isNull())
     160            removeCSSProperties(CSSPropertyMarginLeft, CSSPropertyMarginRight);
     161        else {
     162            addCSSLength(CSSPropertyMarginLeft, attr->value());
     163            addCSSLength(CSSPropertyMarginRight, attr->value());
     164        }
    169165    } else if (attr->name() == alignAttr)
    170166        addHTMLAlignment(attr);
  • trunk/Source/WebCore/html/HTMLPlugInElement.h

    r105932 r106740  
    5959    virtual void detach();
    6060    virtual void removedFromDocument();
    61     virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    6261    virtual void parseMappedAttribute(Attribute*);
    6362
  • trunk/Source/WebCore/html/HTMLPreElement.cpp

    r61959 r106740  
    4343}
    4444
    45 bool HTMLPreElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    46 {
    47     if (attrName == widthAttr || attrName == wrapAttr) {
    48         result = ePre;
    49         return false;
    50     }
    51     return HTMLElement::mapToEntry(attrName, result);
    52 }
    53 
    5445void HTMLPreElement::parseMappedAttribute(Attribute* attr)
    5546{
     
    6051        // property.
    6152    } else if (attr->name() == wrapAttr) {
    62         if (!attr->value().isNull())
    63             addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePreWrap);
     53        if (attr->value().isNull())
     54            removeCSSProperty(CSSPropertyWhiteSpace);
     55        else
     56            addCSSProperty(CSSPropertyWhiteSpace, CSSValuePreWrap);
    6457    } else
    6558        return HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLPreElement.h

    r66057 r106740  
    3535    HTMLPreElement(const QualifiedName&, Document*);
    3636
    37     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    3837    virtual void parseMappedAttribute(Attribute*);
    3938};
  • trunk/Source/WebCore/html/HTMLTableCaptionElement.cpp

    r61959 r106740  
    4545}
    4646
    47 bool HTMLTableCaptionElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    48 {
    49     if (attrName == alignAttr) {
    50         result = eCaption;
    51         return false;
    52     }
    53 
    54     return HTMLElement::mapToEntry(attrName, result);
    55 }
    56 
    5747void HTMLTableCaptionElement::parseMappedAttribute(Attribute* attr)
    5848{
    5949    if (attr->name() == alignAttr) {
    6050        if (!attr->value().isEmpty())
    61             addCSSProperty(attr, CSSPropertyCaptionSide, attr->value());
     51            addCSSProperty(CSSPropertyCaptionSide, attr->value());
     52        else
     53            removeCSSProperty(CSSPropertyCaptionSide);
    6254    } else
    6355        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLTableCaptionElement.h

    r66057 r106740  
    3737private:
    3838    HTMLTableCaptionElement(const QualifiedName&, Document*);
    39    
    40     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
     39
    4140    virtual void parseMappedAttribute(Attribute*);
    4241};
  • trunk/Source/WebCore/html/HTMLTableCellElement.cpp

    r106681 r106740  
    7676}
    7777
    78 bool HTMLTableCellElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    79 {
    80     if (attrName == nowrapAttr) {
    81         result = eUniversal;
    82         return false;
    83     }
    84    
    85     if (attrName == widthAttr ||
    86         attrName == heightAttr) {
    87         result = eCell; // Because of the quirky behavior of ignoring 0 values, cells are special.
    88         return false;
    89     }
    90 
    91     return HTMLTablePartElement::mapToEntry(attrName, result);
    92 }
    93 
    9478void HTMLTableCellElement::parseMappedAttribute(Attribute* attr)
    9579{
     
    10185            toRenderTableCell(renderer())->colSpanOrRowSpanChanged();
    10286    } else if (attr->name() == nowrapAttr) {
    103         if (!attr->isNull())
    104             addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValueWebkitNowrap);
     87        if (attr->isNull())
     88            removeCSSProperty(CSSPropertyWhiteSpace);
     89        else
     90            addCSSProperty(CSSPropertyWhiteSpace, CSSValueWebkitNowrap);
     91
    10592    } else if (attr->name() == widthAttr) {
    10693        if (!attr->value().isEmpty()) {
    10794            int widthInt = attr->value().toInt();
    10895            if (widthInt > 0) // width="0" is ignored for compatibility with WinIE.
    109                 addCSSLength(attr, CSSPropertyWidth, attr->value());
    110         }
     96                addCSSLength(CSSPropertyWidth, attr->value());
     97        } else
     98            removeCSSProperty(CSSPropertyWidth);
    11199    } else if (attr->name() == heightAttr) {
    112100        if (!attr->value().isEmpty()) {
    113101            int heightInt = attr->value().toInt();
    114102            if (heightInt > 0) // height="0" is ignored for compatibility with WinIE.
    115                 addCSSLength(attr, CSSPropertyHeight, attr->value());
    116         }
     103                addCSSLength(CSSPropertyHeight, attr->value());
     104        } else
     105            removeCSSProperty(CSSPropertyHeight);
    117106    } else
    118107        HTMLTablePartElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLTableCellElement.h

    r106681 r106740  
    5454    HTMLTableCellElement(const QualifiedName&, Document*);
    5555
    56     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    5756    virtual void parseMappedAttribute(Attribute*);
    5857
  • trunk/Source/WebCore/html/HTMLTableColElement.cpp

    r106681 r106740  
    4848}
    4949
    50 bool HTMLTableColElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    51 {
    52     if (attrName == widthAttr) {
    53         result = eUniversal;
    54         return false;
    55     }
    56 
    57     return HTMLTablePartElement::mapToEntry(attrName, result);
    58 }
    59 
    6050void HTMLTableColElement::parseMappedAttribute(Attribute* attr)
    6151{
     
    6656    } else if (attr->name() == widthAttr) {
    6757        if (!attr->value().isEmpty()) {
    68             addCSSLength(attr, CSSPropertyWidth, attr->value());
     58            addCSSLength(CSSPropertyWidth, attr->value());
    6959            if (renderer() && renderer()->isTableCol()) {
    7060                RenderTableCol* col = toRenderTableCol(renderer());
     
    7363                    col->setNeedsLayoutAndPrefWidthsRecalc();
    7464            }
    75         }
     65        } else
     66            removeCSSProperty(CSSPropertyWidth);
    7667    } else
    7768        HTMLTablePartElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLTableColElement.h

    r106681 r106740  
    4343    HTMLTableColElement(const QualifiedName& tagName, Document*);
    4444
    45     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    4645    virtual void parseMappedAttribute(Attribute*);
    4746    virtual PassRefPtr<StylePropertySet> additionalAttributeStyle() OVERRIDE;
  • trunk/Source/WebCore/html/HTMLTableElement.cpp

    r106681 r106740  
    242242}
    243243
    244 bool HTMLTableElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    245 {
    246     if (attrName == backgroundAttr) {
    247         result = (MappedAttributeEntry)(eLastEntry + document()->docID());
    248         return false;
    249     }
    250    
    251     if (attrName == widthAttr ||
    252         attrName == heightAttr ||
    253         attrName == bgcolorAttr ||
    254         attrName == cellspacingAttr ||
    255         attrName == vspaceAttr ||
    256         attrName == hspaceAttr ||
    257         attrName == valignAttr) {
    258         result = eUniversal;
    259         return false;
    260     }
    261    
    262     if (attrName == bordercolorAttr || attrName == frameAttr || attrName == rulesAttr) {
    263         result = eUniversal;
    264         return true;
    265     }
    266    
    267     if (attrName == borderAttr) {
    268         result = eTable;
    269         return true;
    270     }
    271    
    272     if (attrName == alignAttr) {
    273         result = eTable;
    274         return false;
    275     }
    276 
    277     return HTMLElement::mapToEntry(attrName, result);
    278 }
    279 
    280244static inline bool isTableCellAncestor(Node* n)
    281245{
     
    309273
    310274    if (attr->name() == widthAttr)
    311         addCSSLength(attr, CSSPropertyWidth, attr->value());
     275        if (attr->isNull())
     276            removeCSSProperty(CSSPropertyWidth);
     277        else
     278            addCSSLength(CSSPropertyWidth, attr->value());
    312279    else if (attr->name() == heightAttr)
    313         addCSSLength(attr, CSSPropertyHeight, attr->value());
     280        if (attr->isNull())
     281            removeCSSProperty(CSSPropertyHeight);
     282        else
     283            addCSSLength(CSSPropertyHeight, attr->value());
    314284    else if (attr->name() == borderAttr)  {
    315285        m_borderAttr = true;
    316         if (attr->decl()) {
    317             RefPtr<CSSValue> val = attr->decl()->getPropertyCSSValue(CSSPropertyBorderLeftWidth);
    318             if (val && val->isPrimitiveValue()) {
    319                 CSSPrimitiveValue* primVal = static_cast<CSSPrimitiveValue*>(val.get());
    320                 m_borderAttr = primVal->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER);
    321             }
    322         } else if (!attr->isNull()) {
     286
     287        if (attr->isNull())
     288            removeCSSProperty(CSSPropertyBorderWidth);
     289        else {
    323290            int border = 0;
    324291            if (attr->isEmpty())
     
    327294                border = attr->value().toInt();
    328295            m_borderAttr = border;
    329             addCSSLength(attr, CSSPropertyBorderWidth, String::number(border));
     296            addCSSLength(CSSPropertyBorderWidth, String::number(border));
    330297        }
    331298    } else if (attr->name() == bgcolorAttr)
    332         addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
     299        if (attr->isNull())
     300            removeCSSProperty(CSSPropertyBackgroundColor);
     301        else
     302            addCSSColor(CSSPropertyBackgroundColor, attr->value());
    333303    else if (attr->name() == bordercolorAttr) {
    334         m_borderColorAttr = attr->decl();
    335         if (!attr->decl() && !attr->isEmpty()) {
    336             addCSSColor(attr, CSSPropertyBorderColor, attr->value());
    337             m_borderColorAttr = true;
    338         }
     304        m_borderColorAttr = !attr->isEmpty();
     305        if (!attr->isEmpty())
     306            addCSSColor(CSSPropertyBorderColor, attr->value());
     307        else
     308            removeCSSProperty(CSSPropertyBorderColor);
    339309    } else if (attr->name() == backgroundAttr) {
    340310        String url = stripLeadingAndTrailingHTMLSpaces(attr->value());
    341311        if (!url.isEmpty())
    342             addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string());
     312            addCSSImageProperty(CSSPropertyBackgroundImage, document()->completeURL(url).string());
     313        else
     314            removeCSSProperty(CSSPropertyBackgroundImage);
    343315    } else if (attr->name() == frameAttr) {
    344316        // Cache the value of "frame" so that the table can examine it later.
     
    381353        // Now map in the border styles of solid and hidden respectively.
    382354        if (m_frameAttr) {
    383             addCSSProperty(attr, CSSPropertyBorderTopWidth, CSSValueThin);
    384             addCSSProperty(attr, CSSPropertyBorderBottomWidth, CSSValueThin);
    385             addCSSProperty(attr, CSSPropertyBorderLeftWidth, CSSValueThin);
    386             addCSSProperty(attr, CSSPropertyBorderRightWidth, CSSValueThin);
    387             addCSSProperty(attr, CSSPropertyBorderTopStyle, borders[cTop] ? CSSValueSolid : CSSValueHidden);
    388             addCSSProperty(attr, CSSPropertyBorderBottomStyle, borders[cBottom] ? CSSValueSolid : CSSValueHidden);
    389             addCSSProperty(attr, CSSPropertyBorderLeftStyle, borders[cLeft] ? CSSValueSolid : CSSValueHidden);
    390             addCSSProperty(attr, CSSPropertyBorderRightStyle, borders[cRight] ? CSSValueSolid : CSSValueHidden);
    391         }
     355            addCSSProperty(CSSPropertyBorderTopWidth, CSSValueThin);
     356            addCSSProperty(CSSPropertyBorderBottomWidth, CSSValueThin);
     357            addCSSProperty(CSSPropertyBorderLeftWidth, CSSValueThin);
     358            addCSSProperty(CSSPropertyBorderRightWidth, CSSValueThin);
     359            addCSSProperty(CSSPropertyBorderTopStyle, borders[cTop] ? CSSValueSolid : CSSValueHidden);
     360            addCSSProperty(CSSPropertyBorderBottomStyle, borders[cBottom] ? CSSValueSolid : CSSValueHidden);
     361            addCSSProperty(CSSPropertyBorderLeftStyle, borders[cLeft] ? CSSValueSolid : CSSValueHidden);
     362            addCSSProperty(CSSPropertyBorderRightStyle, borders[cRight] ? CSSValueSolid : CSSValueHidden);
     363        } else
     364            removeCSSProperties(CSSPropertyBorderTopWidth, CSSPropertyBorderBottomWidth, CSSPropertyBorderLeftWidth, CSSPropertyBorderRightWidth, CSSPropertyBorderTopStyle, CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle, CSSPropertyBorderRightStyle);
    392365    } else if (attr->name() == rulesAttr) {
    393366        m_rulesAttr = UnsetRules;
     
    405378        // The presence of a valid rules attribute causes border collapsing to be enabled.
    406379        if (m_rulesAttr != UnsetRules)
    407             addCSSProperty(attr, CSSPropertyBorderCollapse, CSSValueCollapse);
     380            addCSSProperty(CSSPropertyBorderCollapse, CSSValueCollapse);
     381        else
     382            removeCSSProperty(CSSPropertyBorderCollapse);
    408383    } else if (attr->name() == cellspacingAttr) {
    409384        if (!attr->value().isEmpty())
    410             addCSSLength(attr, CSSPropertyBorderSpacing, attr->value());
     385            addCSSLength(CSSPropertyBorderSpacing, attr->value());
     386        else
     387            removeCSSProperty(CSSPropertyBorderSpacing);
    411388    } else if (attr->name() == cellpaddingAttr) {
    412389        if (!attr->value().isEmpty())
     
    417394        // ###
    418395    } else if (attr->name() == vspaceAttr) {
    419         addCSSLength(attr, CSSPropertyMarginTop, attr->value());
    420         addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
     396        if (attr->isNull())
     397            removeCSSProperties(CSSPropertyMarginTop, CSSPropertyMarginBottom);
     398        else {
     399            addCSSLength(CSSPropertyMarginTop, attr->value());
     400            addCSSLength(CSSPropertyMarginBottom, attr->value());
     401        }
    421402    } else if (attr->name() == hspaceAttr) {
    422         addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
    423         addCSSLength(attr, CSSPropertyMarginRight, attr->value());
     403        if (attr->isNull())
     404            removeCSSProperties(CSSPropertyMarginLeft, CSSPropertyMarginRight);
     405        else {
     406            addCSSLength(CSSPropertyMarginLeft, attr->value());
     407            addCSSLength(CSSPropertyMarginRight, attr->value());
     408        }
    424409    } else if (attr->name() == alignAttr) {
    425410        if (!attr->value().isEmpty()) {
    426411            if (equalIgnoringCase(attr->value(), "center")) {
    427                 addCSSProperty(attr, CSSPropertyWebkitMarginStart, CSSValueAuto);
    428                 addCSSProperty(attr, CSSPropertyWebkitMarginEnd, CSSValueAuto);
     412                addCSSProperty(CSSPropertyWebkitMarginStart, CSSValueAuto);
     413                addCSSProperty(CSSPropertyWebkitMarginEnd, CSSValueAuto);
    429414            } else
    430                 addCSSProperty(attr, CSSPropertyFloat, attr->value());
    431         }
     415                addCSSProperty(CSSPropertyFloat, attr->value());
     416        } else
     417            removeCSSProperties(CSSPropertyWebkitMarginStart, CSSPropertyWebkitMarginEnd, CSSPropertyFloat);
    432418    } else if (attr->name() == valignAttr) {
    433419        if (!attr->value().isEmpty())
    434             addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
     420            addCSSProperty(CSSPropertyVerticalAlign, attr->value());
     421        else
     422            removeCSSProperty(CSSPropertyVerticalAlign);
    435423    } else
    436424        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLTableElement.h

    r106681 r106740  
    7373    HTMLTableElement(const QualifiedName&, Document*);
    7474
    75     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    7675    virtual void parseMappedAttribute(Attribute*);
    7776    virtual bool isURLAttribute(Attribute*) const;
  • trunk/Source/WebCore/html/HTMLTablePartElement.cpp

    r68854 r106740  
    3737using namespace HTMLNames;
    3838
    39 bool HTMLTablePartElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    40 {
    41     if (attrName == backgroundAttr) {
    42         result = (MappedAttributeEntry)(eLastEntry + document()->docID());
    43         return false;
    44     }
    45    
    46     if (attrName == bgcolorAttr ||
    47         attrName == bordercolorAttr ||
    48         attrName == valignAttr ||
    49         attrName == heightAttr) {
    50         result = eUniversal;
    51         return false;
    52     }
    53    
    54     if (attrName == alignAttr) {
    55         result = eCell; // All table parts will just share in the TD space.
    56         return false;
    57     }
    58 
    59     return HTMLElement::mapToEntry(attrName, result);
    60 }
    61 
    6239void HTMLTablePartElement::parseMappedAttribute(Attribute* attr)
    6340{
    6441    if (attr->name() == bgcolorAttr)
    65         addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
     42        if (attr->value().isNull())
     43            removeCSSProperty(CSSPropertyBackgroundColor);
     44        else
     45            addCSSColor(CSSPropertyBackgroundColor, attr->value());
    6646    else if (attr->name() == backgroundAttr) {
    6747        String url = stripLeadingAndTrailingHTMLSpaces(attr->value());
    6848        if (!url.isEmpty())
    69             addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string());
     49            addCSSImageProperty(CSSPropertyBackgroundImage, document()->completeURL(url).string());
     50        else
     51            removeCSSProperty(CSSPropertyBackgroundImage);
    7052    } else if (attr->name() == bordercolorAttr) {
    7153        if (!attr->value().isEmpty()) {
    72             addCSSColor(attr, CSSPropertyBorderColor, attr->value());
    73             addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
    74             addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
    75             addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
    76             addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
    77         }
     54            addCSSColor(CSSPropertyBorderColor, attr->value());
     55            addCSSProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
     56            addCSSProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
     57            addCSSProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
     58            addCSSProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
     59        } else
     60            removeCSSProperties(CSSPropertyBorderColor, CSSPropertyBorderTopStyle, CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle, CSSPropertyBorderRightStyle);
    7861    } else if (attr->name() == valignAttr) {
    7962        if (!attr->value().isEmpty())
    80             addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
     63            addCSSProperty(CSSPropertyVerticalAlign, attr->value());
     64        else
     65            removeCSSProperty(CSSPropertyVerticalAlign);
    8166    } else if (attr->name() == alignAttr) {
    8267        const AtomicString& v = attr->value();
    83         if (equalIgnoringCase(v, "middle") || equalIgnoringCase(v, "center"))
    84             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitCenter);
     68        if (v.isNull())
     69            removeCSSProperty(CSSPropertyTextAlign);
     70        else if (equalIgnoringCase(v, "middle") || equalIgnoringCase(v, "center"))
     71            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitCenter);
    8572        else if (equalIgnoringCase(v, "absmiddle"))
    86             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueCenter);
     73            addCSSProperty(CSSPropertyTextAlign, CSSValueCenter);
    8774        else if (equalIgnoringCase(v, "left"))
    88             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitLeft);
     75            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitLeft);
    8976        else if (equalIgnoringCase(v, "right"))
    90             addCSSProperty(attr, CSSPropertyTextAlign, CSSValueWebkitRight);
     77            addCSSProperty(CSSPropertyTextAlign, CSSValueWebkitRight);
    9178        else
    92             addCSSProperty(attr, CSSPropertyTextAlign, v);
     79            addCSSProperty(CSSPropertyTextAlign, v);
    9380    } else if (attr->name() == heightAttr) {
    9481        if (!attr->value().isEmpty())
    95             addCSSLength(attr, CSSPropertyHeight, attr->value());
     82            addCSSLength(CSSPropertyHeight, attr->value());
     83        else
     84            removeCSSProperty(CSSPropertyHeight);
    9685    } else
    9786        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLTablePartElement.h

    r60361 r106740  
    3838    }
    3939
    40     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    4140    virtual void parseMappedAttribute(Attribute*);
    4241};
  • trunk/Source/WebCore/html/HTMLTextAreaElement.cpp

    r103051 r106740  
    152152
    153153            if (shouldWrapText()) {
    154                 addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePreWrap);
    155                 addCSSProperty(attr, CSSPropertyWordWrap, CSSValueBreakWord);
     154                addCSSProperty(CSSPropertyWhiteSpace, CSSValuePreWrap);
     155                addCSSProperty(CSSPropertyWordWrap, CSSValueBreakWord);
    156156            } else {
    157                 addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePre);
    158                 addCSSProperty(attr, CSSPropertyWordWrap, CSSValueNormal);
     157                addCSSProperty(CSSPropertyWhiteSpace, CSSValuePre);
     158                addCSSProperty(CSSPropertyWordWrap, CSSValueNormal);
    159159            }
    160160
  • trunk/Source/WebCore/html/HTMLUListElement.cpp

    r61959 r106740  
    4848}
    4949
    50 bool HTMLUListElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    51 {
    52     if (attrName == typeAttr) {
    53         result = eUnorderedList;
    54         return false;
    55     }
    56    
    57     return HTMLElement::mapToEntry(attrName, result);
    58 }
    59 
    6050void HTMLUListElement::parseMappedAttribute(Attribute* attr)
    6151{
    6252    if (attr->name() == typeAttr)
    63         addCSSProperty(attr, CSSPropertyListStyleType, attr->value());
     53        if (attr->value().isNull())
     54            removeCSSProperty(CSSPropertyListStyleType);
     55        else
     56            addCSSProperty(CSSPropertyListStyleType, attr->value());
    6457    else
    6558        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLUListElement.h

    r66057 r106740  
    3636    HTMLUListElement(const QualifiedName&, Document*);
    3737
    38     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    3938    virtual void parseMappedAttribute(Attribute*);
    4039};
  • trunk/Source/WebCore/html/HTMLVideoElement.cpp

    r106667 r106740  
    115115#endif
    116116    } else if (attrName == widthAttr)
    117         addCSSLength(attr, CSSPropertyWidth, attr->value());
     117        if (attr->value().isNull())
     118            removeCSSProperty(CSSPropertyWidth);
     119        else
     120            addCSSLength(CSSPropertyWidth, attr->value());
    118121    else if (attrName == heightAttr)
    119         addCSSLength(attr, CSSPropertyHeight, attr->value());
     122        if (attr->value().isNull())
     123            removeCSSProperty(CSSPropertyHeight);
     124        else
     125            addCSSLength(CSSPropertyHeight, attr->value());
    120126    else
    121127        HTMLMediaElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r106695 r106740  
    717717PassRefPtr<InspectorArray> InspectorCSSAgent::buildArrayForAttributeStyles(Element* element)
    718718{
     719    // FIXME: Since we no longer have per-attribute style declarations, we should come up
     720    //        with a nicer way to present what we do have.
     721
     722    if (!element->isStyledElement())
     723        return InspectorArray::create();
     724
     725    CSSMappedAttributeDeclaration* attributeStyle = static_cast<StyledElement*>(element)->attributeStyle();
     726    if (!attributeStyle || !attributeStyle->declaration())
     727        return InspectorArray::create();
     728
     729    RefPtr<InspectorObject> attrStyleObject = InspectorObject::create();
     730    RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), attributeStyle->declaration()->ensureCSSStyleDeclaration(), 0);
     731    attrStyleObject->setString("name", "");
     732    attrStyleObject->setObject("style", inspectorStyle->buildObjectForStyle());
     733
    719734    RefPtr<InspectorArray> attrStyles = InspectorArray::create();
    720     NamedNodeMap* attributes = element->updatedAttributes();
    721     if (!attributes)
    722         return attrStyles.release();
    723 
    724     for (unsigned i = 0; attributes && i < attributes->length(); ++i) {
    725         Attribute* attribute = attributes->attributeItem(i);
    726         if (!attribute->decl())
    727             continue;
    728         RefPtr<InspectorObject> attrStyleObject = InspectorObject::create();
    729         String attributeName = attribute->localName();
    730         RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), attribute->decl()->ensureCSSStyleDeclaration(), 0);
    731         attrStyleObject->setString("name", attributeName.utf8().data());
    732         attrStyleObject->setObject("style", inspectorStyle->buildObjectForStyle());
    733         attrStyles->pushObject(attrStyleObject.release());
    734     }
    735 
     735    attrStyles->pushObject(attrStyleObject.release());
    736736    return attrStyles.release();
    737737}
  • trunk/Source/WebCore/mathml/MathMLElement.cpp

    r95901 r106740  
    4949}
    5050
    51 bool MathMLElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    52 {
    53     if (attrName == mathcolorAttr || attrName == mathbackgroundAttr
    54         || attrName == colorAttr || attrName == backgroundAttr
    55         || attrName == fontsizeAttr || attrName == fontstyleAttr
    56         || attrName == fontweightAttr || attrName == fontfamilyAttr) {
    57         result = eMathML;
    58         return false;
    59     }
    60     return StyledElement::mapToEntry(attrName, result);
    61 }
    62 
    6351void MathMLElement::parseMappedAttribute(Attribute* attr)
    6452{
    6553    if (attr->name() == mathbackgroundAttr)
    66         addCSSProperty(attr, CSSPropertyBackgroundColor, attr->value());
     54        addCSSProperty(CSSPropertyBackgroundColor, attr->value());
    6755    else if (attr->name() == mathsizeAttr) {
    6856        // The following three values of mathsize are handled in WebCore/css/mathml.css
    6957        if (attr->value() != "normal" && attr->value() != "small" && attr->value() != "big")
    70             addCSSProperty(attr, CSSPropertyFontSize, attr->value());
     58            addCSSProperty(CSSPropertyFontSize, attr->value());
    7159    } else if (attr->name() == mathcolorAttr)
    72         addCSSProperty(attr, CSSPropertyColor, attr->value());
     60        addCSSProperty(CSSPropertyColor, attr->value());
    7361    // FIXME: deprecated attributes that should loose in a conflict with a non deprecated attribute
    7462    else if (attr->name() == fontsizeAttr)
    75         addCSSProperty(attr, CSSPropertyFontSize, attr->value());
     63        addCSSProperty(CSSPropertyFontSize, attr->value());
    7664    else if (attr->name() == backgroundAttr)
    77         addCSSProperty(attr, CSSPropertyBackgroundColor, attr->value());
     65        addCSSProperty(CSSPropertyBackgroundColor, attr->value());
    7866    else if (attr->name() == colorAttr)
    79         addCSSProperty(attr, CSSPropertyColor, attr->value());
     67        addCSSProperty(CSSPropertyColor, attr->value());
    8068    else if (attr->name() == fontstyleAttr)
    81         addCSSProperty(attr, CSSPropertyFontStyle, attr->value());
     69        addCSSProperty(CSSPropertyFontStyle, attr->value());
    8270    else if (attr->name() == fontweightAttr)
    83         addCSSProperty(attr, CSSPropertyFontWeight, attr->value());
     71        addCSSProperty(CSSPropertyFontWeight, attr->value());
    8472    else if (attr->name() == fontfamilyAttr)
    85         addCSSProperty(attr, CSSPropertyFontFamily, attr->value());
     73        addCSSProperty(CSSPropertyFontFamily, attr->value());
    8674    else
    8775        StyledElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/mathml/MathMLElement.h

    r95901 r106740  
    4343private:   
    4444    virtual bool isMathMLElement() const { return true; }
    45     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    4645    virtual void parseMappedAttribute(Attribute*);
    4746};
  • trunk/Source/WebCore/svg/SVGImageElement.cpp

    r105613 r106740  
    106106    else if (attr->name() == SVGNames::widthAttr) {
    107107        setWidthBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError, ForbidNegativeLengths));
    108         addCSSProperty(attr, CSSPropertyWidth, attr->value());
     108        addCSSProperty(CSSPropertyWidth, attr->value());
    109109    } else if (attr->name() == SVGNames::heightAttr) {
    110110        setHeightBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError, ForbidNegativeLengths));
    111         addCSSProperty(attr, CSSPropertyHeight, attr->value());
     111        addCSSProperty(CSSPropertyHeight, attr->value());
    112112    } else if (SVGTests::parseMappedAttribute(attr)
    113113             || SVGLangSpace::parseMappedAttribute(attr)
  • trunk/Source/WebCore/svg/SVGStyledElement.cpp

    r106471 r106740  
    293293}
    294294
    295 bool SVGStyledElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    296 {
    297     if (SVGStyledElement::cssPropertyIdForSVGAttributeName(attrName) > 0) {
    298         result = eSVG;
    299         return false;
    300     }
    301     return SVGElement::mapToEntry(attrName, result);
    302 }
    303 
    304295void SVGStyledElement::parseMappedAttribute(Attribute* attr)
    305296{
    306     // NOTE: Any subclass which overrides parseMappedAttribute for a property handled by
    307     // cssPropertyIdForSVGAttributeName will also have to override mapToEntry to disable the default eSVG mapping
    308297    int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
    309298    if (propId > 0) {
    310         addCSSProperty(attr, propId, attr->value());
     299        addCSSProperty(propId, attr->value());
    311300        setNeedsStyleRecalc();
    312301        return;
     
    423412    QualifiedName attributeName(nullAtom, name, nullAtom);
    424413    Attribute* attr = attributeMap()->getAttributeItem(attributeName);
    425     if (!attr || !attr->isMappedAttribute() || !attr->mappedAttributeDeclaration())
     414    if (!attr || !attr->isMappedAttribute())
    426415        return 0;
    427416
    428     Attribute* cssSVGAttr = attr;
    429     // This function returns a pointer to a CSSValue which can be mutated from JavaScript.
    430     // If the associated MappedAttribute uses the same CSSMappedAttributeDeclaration
    431     // as StyledElement's mappedAttributeDecls cache, create a new CSSMappedAttributeDeclaration
    432     // before returning so that any modifications to the CSSValue will not affect other attributes.
    433     MappedAttributeEntry entry;
    434     mapToEntry(attributeName, entry);
    435     if (getMappedAttributeDecl(entry, cssSVGAttr) == cssSVGAttr->mappedAttributeDeclaration()) {
    436         cssSVGAttr->setMappedAttributeDeclaration(0);
    437         int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(cssSVGAttr->name());
    438         addCSSProperty(cssSVGAttr, propId, cssSVGAttr->value());
    439     }
    440     return cssSVGAttr->decl()->getPropertyCSSValue(cssPropertyID(name));
     417    RefPtr<StylePropertySet> style = StylePropertySet::create();
     418    style->setStrictParsing(false);
     419    int propertyID = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
     420    style->setProperty(propertyID, attr->value());
     421    return style->getPropertyCSSValue(propertyID);
    441422}
    442423
  • trunk/Source/WebCore/svg/SVGStyledElement.h

    r96803 r106740  
    6666    virtual bool rendererIsNeeded(const NodeRenderingContext&);
    6767
    68     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    6968    virtual void parseMappedAttribute(Attribute*);
    7069    virtual void svgAttributeChanged(const QualifiedName&);
  • trunk/Source/WebCore/svg/SVGTextContentElement.cpp

    r105143 r106740  
    248248
    249249            if (attr->value() == preserveString)
    250                 addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePre);
     250                addCSSProperty(CSSPropertyWhiteSpace, CSSValuePre);
    251251            else
    252                 addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValueNowrap);
     252                addCSSProperty(CSSPropertyWhiteSpace, CSSValueNowrap);
    253253        }
    254254    } else
Note: See TracChangeset for help on using the changeset viewer.