Title: [160072] trunk/Source/WebCore
Revision
160072
Author
rn...@webkit.org
Date
2013-12-03 23:44:43 -0800 (Tue, 03 Dec 2013)

Log Message

bgColor, setBgColor, alinkColor, setAlinkColor, and etc... on HTMLBodyElement are useless
https://bugs.webkit.org/show_bug.cgi?id=125208

Reviewed by Antti Koivisto.

Merge https://chromium.googlesource.com/chromium/blink/+/49b1eeabbbf573d5271288c66d2b566cf33a09cf

These member functions of HTMLBodyElement were only used by corresponding functions in HTMLDocument
since they had the Reflect option specified in HTMLBodyElement.idl.

Removed the functions and directly called getAttribute and setAttribute in relevant functions in
HTMLDocument. The optimization to avoid assignment is no longer needed here since we've added that
optimization to setAttributeInternal a while ago.

* html/HTMLBodyElement.cpp:
* html/HTMLBodyElement.h:
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::bgColor):
(WebCore::HTMLDocument::setBgColor):
(WebCore::HTMLDocument::fgColor):
(WebCore::HTMLDocument::setFgColor):
(WebCore::HTMLDocument::alinkColor):
(WebCore::HTMLDocument::setAlinkColor):
(WebCore::HTMLDocument::linkColor):
(WebCore::HTMLDocument::setLinkColor):
(WebCore::HTMLDocument::vlinkColor):
(WebCore::HTMLDocument::setVlinkColor):
* html/HTMLDocument.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (160071 => 160072)


--- trunk/Source/WebCore/ChangeLog	2013-12-04 06:50:54 UTC (rev 160071)
+++ trunk/Source/WebCore/ChangeLog	2013-12-04 07:44:43 UTC (rev 160072)
@@ -1,3 +1,34 @@
+2013-12-03  Ryosuke Niwa  <rn...@webkit.org>
+
+        bgColor, setBgColor, alinkColor, setAlinkColor, and etc... on HTMLBodyElement are useless
+        https://bugs.webkit.org/show_bug.cgi?id=125208
+
+        Reviewed by Antti Koivisto.
+
+        Merge https://chromium.googlesource.com/chromium/blink/+/49b1eeabbbf573d5271288c66d2b566cf33a09cf
+
+        These member functions of HTMLBodyElement were only used by corresponding functions in HTMLDocument
+        since they had the Reflect option specified in HTMLBodyElement.idl.
+
+        Removed the functions and directly called getAttribute and setAttribute in relevant functions in
+        HTMLDocument. The optimization to avoid assignment is no longer needed here since we've added that
+        optimization to setAttributeInternal a while ago.
+
+        * html/HTMLBodyElement.cpp:
+        * html/HTMLBodyElement.h:
+        * html/HTMLDocument.cpp:
+        (WebCore::HTMLDocument::bgColor):
+        (WebCore::HTMLDocument::setBgColor):
+        (WebCore::HTMLDocument::fgColor):
+        (WebCore::HTMLDocument::setFgColor):
+        (WebCore::HTMLDocument::alinkColor):
+        (WebCore::HTMLDocument::setAlinkColor):
+        (WebCore::HTMLDocument::linkColor):
+        (WebCore::HTMLDocument::setLinkColor):
+        (WebCore::HTMLDocument::vlinkColor):
+        (WebCore::HTMLDocument::setVlinkColor):
+        * html/HTMLDocument.h:
+
 2013-12-03  Andreas Kling  <akl...@apple.com>
 
         Add a CSSProperty::isDirectionAwareProperty() helper.

Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (160071 => 160072)


--- trunk/Source/WebCore/html/HTMLBodyElement.cpp	2013-12-04 06:50:54 UTC (rev 160071)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp	2013-12-04 07:44:43 UTC (rev 160072)
@@ -188,56 +188,6 @@
     return rendererIsEditable() || HTMLElement::supportsFocus();
 }
 
-String HTMLBodyElement::aLink() const
-{
-    return getAttribute(alinkAttr);
-}
-
-void HTMLBodyElement::setALink(const String& value)
-{
-    setAttribute(alinkAttr, value);
-}
-
-String HTMLBodyElement::bgColor() const
-{
-    return getAttribute(bgcolorAttr);
-}
-
-void HTMLBodyElement::setBgColor(const String& value)
-{
-    setAttribute(bgcolorAttr, value);
-}
-
-String HTMLBodyElement::link() const
-{
-    return getAttribute(linkAttr);
-}
-
-void HTMLBodyElement::setLink(const String& value)
-{
-    setAttribute(linkAttr, value);
-}
-
-String HTMLBodyElement::text() const
-{
-    return getAttribute(textAttr);
-}
-
-void HTMLBodyElement::setText(const String& value)
-{
-    setAttribute(textAttr, value);
-}
-
-String HTMLBodyElement::vLink() const
-{
-    return getAttribute(vlinkAttr);
-}
-
-void HTMLBodyElement::setVLink(const String& value)
-{
-    setAttribute(vlinkAttr, value);
-}
-
 static int adjustForZoom(int value, Frame& frame)
 {
     float zoomFactor = frame.pageZoomFactor() * frame.frameScaleFactor();

Modified: trunk/Source/WebCore/html/HTMLBodyElement.h (160071 => 160072)


--- trunk/Source/WebCore/html/HTMLBodyElement.h	2013-12-04 06:50:54 UTC (rev 160071)
+++ trunk/Source/WebCore/html/HTMLBodyElement.h	2013-12-04 07:44:43 UTC (rev 160072)
@@ -36,17 +36,6 @@
     static PassRefPtr<HTMLBodyElement> create(const QualifiedName&, Document&);
     virtual ~HTMLBodyElement();
 
-    String aLink() const;
-    void setALink(const String&);
-    String bgColor() const;
-    void setBgColor(const String&);
-    String link() const;
-    void setLink(const String&);
-    String text() const;
-    void setText(const String&);
-    String vLink() const;
-    void setVLink(const String&);
-
     // Declared virtual in Element
     DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(blur);
     DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(error);

Modified: trunk/Source/WebCore/html/HTMLDocument.cpp (160071 => 160072)


--- trunk/Source/WebCore/html/HTMLDocument.cpp	2013-12-04 06:50:54 UTC (rev 160071)
+++ trunk/Source/WebCore/html/HTMLDocument.cpp	2013-12-04 07:44:43 UTC (rev 160072)
@@ -158,114 +158,84 @@
     return false;
 }
 
-String HTMLDocument::bgColor()
+const AtomicString& HTMLDocument::bgColor() const
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (!bodyElement)
-        return String();
-    return bodyElement->bgColor();
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return emptyAtom;
+    return bodyElement->getAttribute(bgcolorAttr);
 }
 
 void HTMLDocument::setBgColor(const String& value)
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (bodyElement)
-        bodyElement->setBgColor(value);
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return;
+    bodyElement->setAttribute(bgcolorAttr, value);
 }
 
-String HTMLDocument::fgColor()
+const AtomicString& HTMLDocument::fgColor() const
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (!bodyElement)
-        return String();
-    return bodyElement->text();
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return emptyAtom;
+    return bodyElement->getAttribute(textAttr);
 }
 
 void HTMLDocument::setFgColor(const String& value)
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (bodyElement)
-        bodyElement->setText(value);
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return;
+    bodyElement->setAttribute(textAttr, value);
 }
 
-String HTMLDocument::alinkColor()
+const AtomicString& HTMLDocument::alinkColor() const
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (!bodyElement)
-        return String();
-    return bodyElement->aLink();
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return emptyAtom;
+    return bodyElement->getAttribute(alinkAttr);
 }
 
 void HTMLDocument::setAlinkColor(const String& value)
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (bodyElement) {
-        // This check is a bit silly, but some benchmarks like to set the
-        // document's link colors over and over to the same value and we
-        // don't want to incur a style update each time.
-        if (bodyElement->aLink() != value)
-            bodyElement->setALink(value);
-    }
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return;
+    bodyElement->setAttribute(alinkAttr, value);
 }
 
-String HTMLDocument::linkColor()
+const AtomicString& HTMLDocument::linkColor() const
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (!bodyElement)
-        return String();
-    return bodyElement->link();
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return emptyAtom;
+    return bodyElement->getAttribute(linkAttr);
 }
 
 void HTMLDocument::setLinkColor(const String& value)
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (bodyElement) {
-        // This check is a bit silly, but some benchmarks like to set the
-        // document's link colors over and over to the same value and we
-        // don't want to incur a style update each time.
-        if (bodyElement->link() != value)
-            bodyElement->setLink(value);
-    }
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return;
+    return bodyElement->setAttribute(linkAttr, value);
 }
 
-String HTMLDocument::vlinkColor()
+const AtomicString& HTMLDocument::vlinkColor() const
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (!bodyElement)
-        return String();
-    return bodyElement->vLink();
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return emptyAtom;
+    return bodyElement->getAttribute(vlinkAttr);
 }
 
 void HTMLDocument::setVlinkColor(const String& value)
 {
-    HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
-
-    if (bodyElement) {
-        // This check is a bit silly, but some benchmarks like to set the
-        // document's link colors over and over to the same value and we
-        // don't want to incur a style update each time.
-        if (bodyElement->vLink() != value)
-            bodyElement->setVLink(value);
-    }
+    HTMLElement* bodyElement = body();
+    if (!bodyElement || !isHTMLBodyElement(bodyElement))
+        return;
+    return bodyElement->setAttribute(vlinkAttr, value);
 }
 
 void HTMLDocument::captureEvents()

Modified: trunk/Source/WebCore/html/HTMLDocument.h (160071 => 160072)


--- trunk/Source/WebCore/html/HTMLDocument.h	2013-12-04 06:50:54 UTC (rev 160071)
+++ trunk/Source/WebCore/html/HTMLDocument.h	2013-12-04 07:44:43 UTC (rev 160072)
@@ -49,15 +49,15 @@
     Element* activeElement();
     bool hasFocus();
 
-    String bgColor();
+    const AtomicString& bgColor() const;
     void setBgColor(const String&);
-    String fgColor();
+    const AtomicString& fgColor() const;
     void setFgColor(const String&);
-    String alinkColor();
+    const AtomicString& alinkColor() const;
     void setAlinkColor(const String&);
-    String linkColor();
+    const AtomicString& linkColor() const;
     void setLinkColor(const String&);
-    String vlinkColor();
+    const AtomicString& vlinkColor() const;
     void setVlinkColor(const String&);
 
     void clear();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to