Title: [97877] trunk/Source/WebCore
Revision
97877
Author
[email protected]
Date
2011-10-19 14:28:36 -0700 (Wed, 19 Oct 2011)

Log Message

HTMLBodyElement: Simplify link/alink/vlink attribute parsing.
https://bugs.webkit.org/show_bug.cgi?id=70429

Reviewed by Antonio Gomes.

Instead of carrying around a CSSMutableStyleDeclaration with the body element,
just use CSSParser::parseColor() to parse the three link color attributes.

* html/HTMLBodyElement.h:
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::~HTMLBodyElement):

    Remove HTMLBodyElement::m_linkDecl and all the voodoo that went along with it.

(WebCore::HTMLBodyElement::parseMappedAttribute):

    Use CSSParser directly to parse the color values for {link,alink,vlink}Attr.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97876 => 97877)


--- trunk/Source/WebCore/ChangeLog	2011-10-19 21:25:10 UTC (rev 97876)
+++ trunk/Source/WebCore/ChangeLog	2011-10-19 21:28:36 UTC (rev 97877)
@@ -1,3 +1,23 @@
+2011-10-19  Andreas Kling  <[email protected]>
+
+        HTMLBodyElement: Simplify link/alink/vlink attribute parsing.
+        https://bugs.webkit.org/show_bug.cgi?id=70429
+
+        Reviewed by Antonio Gomes.
+
+        Instead of carrying around a CSSMutableStyleDeclaration with the body element,
+        just use CSSParser::parseColor() to parse the three link color attributes.
+
+        * html/HTMLBodyElement.h:
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::~HTMLBodyElement):
+
+            Remove HTMLBodyElement::m_linkDecl and all the voodoo that went along with it.
+
+        (WebCore::HTMLBodyElement::parseMappedAttribute):
+
+            Use CSSParser directly to parse the color values for {link,alink,vlink}Attr.
+
 2011-10-18  Oliver Hunt  <[email protected]>
 
         Support CanvasPixelArray in the DFG

Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (97876 => 97877)


--- trunk/Source/WebCore/html/HTMLBodyElement.cpp	2011-10-19 21:25:10 UTC (rev 97876)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp	2011-10-19 21:28:36 UTC (rev 97877)
@@ -25,8 +25,7 @@
 #include "HTMLBodyElement.h"
 
 #include "Attribute.h"
-#include "CSSStyleSelector.h"
-#include "CSSStyleSheet.h"
+#include "CSSParser.h"
 #include "CSSValueKeywords.h"
 #include "EventNames.h"
 #include "Frame.h"
@@ -59,20 +58,8 @@
 
 HTMLBodyElement::~HTMLBodyElement()
 {
-    if (m_linkDecl) {
-        m_linkDecl->setNode(0);
-        m_linkDecl->setParent(0);
-    }
 }
 
-void HTMLBodyElement::createLinkDecl()
-{
-    m_linkDecl = CSSMutableStyleDeclaration::create();
-    m_linkDecl->setParent(document()->elementSheet());
-    m_linkDecl->setNode(this);
-    m_linkDecl->setStrictParsing(!document()->inQuirksMode());
-}
-
 bool HTMLBodyElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
 {
     if (attrName == backgroundAttr) {
@@ -124,18 +111,14 @@
             else
                 document()->resetActiveLinkColor();
         } else {
-            if (!m_linkDecl)
-                createLinkDecl();
-            m_linkDecl->setProperty(CSSPropertyColor, attr->value(), false, false);
-            RefPtr<CSSValue> val = m_linkDecl->getPropertyCSSValue(CSSPropertyColor);
-            if (val && val->isPrimitiveValue()) {
-                Color col = document()->styleSelector()->getColorFromPrimitiveValue(static_cast<CSSPrimitiveValue*>(val.get()));
+            RGBA32 color;
+            if (CSSParser::parseColor(color, attr->value(), !document()->inQuirksMode())) {
                 if (attr->name() == linkAttr)
-                    document()->setLinkColor(col);
+                    document()->setLinkColor(color);
                 else if (attr->name() == vlinkAttr)
-                    document()->setVisitedLinkColor(col);
+                    document()->setVisitedLinkColor(color);
                 else
-                    document()->setActiveLinkColor(col);
+                    document()->setActiveLinkColor(color);
             }
         }
         
@@ -345,16 +328,4 @@
     addSubresourceURL(urls, document()->completeURL(getAttribute(backgroundAttr)));
 }
 
-void HTMLBodyElement::didMoveToNewOwnerDocument()
-{
-    // When moving body elements between documents, we should have to reset the parent sheet for any
-    // link style declarations.  If we don't we might crash later.
-    // In practice I can't reproduce this theoretical problem.
-    // webarchive/adopt-attribute-styled-body-webarchive.html tries to make sure this crash won't surface.
-    if (m_linkDecl)
-        m_linkDecl->setParent(document()->elementSheet());
-    
-    HTMLElement::didMoveToNewOwnerDocument();
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLBodyElement.h (97876 => 97877)


--- trunk/Source/WebCore/html/HTMLBodyElement.h	2011-10-19 21:25:10 UTC (rev 97876)
+++ trunk/Source/WebCore/html/HTMLBodyElement.h	2011-10-19 21:28:36 UTC (rev 97877)
@@ -74,8 +74,6 @@
     virtual void parseMappedAttribute(Attribute*);
 
     virtual void insertedIntoDocument();
-
-    void createLinkDecl();
     
     virtual bool isURLAttribute(Attribute*) const;
     
@@ -91,10 +89,6 @@
     virtual int scrollWidth();
     
     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
-    
-    virtual void didMoveToNewOwnerDocument();
-
-    RefPtr<CSSMutableStyleDeclaration> m_linkDecl;
 };
 
 } //namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to