Title: [165788] trunk/Source/WebCore
Revision
165788
Author
[email protected]
Date
2014-03-17 18:44:17 -0700 (Mon, 17 Mar 2014)

Log Message

Rewrite WebHTMLConverter::_elementHasOwnBackgroundColor in C++
https://bugs.webkit.org/show_bug.cgi?id=130291

Reviewed by Andreas Kling.

Extracted HTMLConverterCaches::elementHasOwnBackgroundColor.

* platform/mac/HTMLConverter.mm:
(HTMLConverterCaches::elementHasOwnBackgroundColor):
(-[WebHTMLConverter _elementHasOwnBackgroundColor:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (165787 => 165788)


--- trunk/Source/WebCore/ChangeLog	2014-03-18 01:38:01 UTC (rev 165787)
+++ trunk/Source/WebCore/ChangeLog	2014-03-18 01:44:17 UTC (rev 165788)
@@ -1,5 +1,18 @@
 2014-03-17  Ryosuke Niwa  <[email protected]>
 
+        Rewrite WebHTMLConverter::_elementHasOwnBackgroundColor in C++
+        https://bugs.webkit.org/show_bug.cgi?id=130291
+
+        Reviewed by Andreas Kling.
+
+        Extracted HTMLConverterCaches::elementHasOwnBackgroundColor.
+
+        * platform/mac/HTMLConverter.mm:
+        (HTMLConverterCaches::elementHasOwnBackgroundColor):
+        (-[WebHTMLConverter _elementHasOwnBackgroundColor:]):
+
+2014-03-17  Ryosuke Niwa  <[email protected]>
+
         Rewrite WebHTMLConverter::_elementIsBlockLevel in C++
         https://bugs.webkit.org/show_bug.cgi?id=130287
 

Modified: trunk/Source/WebCore/platform/mac/HTMLConverter.mm (165787 => 165788)


--- trunk/Source/WebCore/platform/mac/HTMLConverter.mm	2014-03-18 01:38:01 UTC (rev 165787)
+++ trunk/Source/WebCore/platform/mac/HTMLConverter.mm	2014-03-18 01:44:17 UTC (rev 165788)
@@ -404,6 +404,7 @@
     String propertyValueForNode(Node&, const String& propertyName);
     bool floatPropertyValueForNode(Node&, const String& propertyName, float&);
     bool isBlockElement(Element&);
+    bool elementHasOwnBackgroundColor(Element&);
 
     PassRefPtr<CSSValue> computedStylePropertyForElement(Element&, const String&);
     PassRefPtr<CSSValue> inlineStylePropertyForElement(Element&, const String&);
@@ -942,6 +943,15 @@
     return false;
 }
 
+bool HTMLConverterCaches::elementHasOwnBackgroundColor(Element& element)
+{
+    if (!isBlockElement(element))
+        return false;
+    // In the text system, text blocks (table elements) and documents (body elements)
+    // have their own background colors, which should not be inherited.
+    return element.hasTagName(htmlTag) || element.hasTagName(bodyTag) || propertyValueForNode(element, "display").startsWith("table");
+}
+
 - (BOOL)_elementIsBlockLevel:(DOMElement *)element
 {
     return element && _caches->isBlockElement(*core(element));
@@ -949,17 +959,9 @@
 
 - (BOOL)_elementHasOwnBackgroundColor:(DOMElement *)element
 {
-    // In the text system, text blocks (table elements) and documents (body elements)
-    // have their own background colors, which should not be inherited.
-    if ([self _elementIsBlockLevel:element]) {
-        Element* coreElement = core(element);
-        NSString *displayVal = [self _stringForNode:element property:@"display"];
-        if (coreElement->hasTagName(htmlTag) || coreElement->hasTagName(bodyTag) || [displayVal hasPrefix:@"table"])
-            return YES;
-    }
-    return NO;
+    return element && _caches->elementHasOwnBackgroundColor(*core(element));
 }
-    
+
 - (DOMElement *)_blockLevelElementForNode:(DOMNode *)node
 {
     DOMElement *element = (DOMElement *)node;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to