+2014-03-17 Ryosuke Niwa <rniwa@webkit.org>
+
+ 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 <rniwa@webkit.org>
Rewrite WebHTMLConverter::_elementIsBlockLevel in C++
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&);
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));
- (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;