Index: Source/WebCore/editing/ApplyStyleCommand.cpp |
=================================================================== |
--- Source/WebCore/editing/ApplyStyleCommand.cpp (revision 95747) |
+++ Source/WebCore/editing/ApplyStyleCommand.cpp (working copy) |
@@ -61,7 +61,7 @@ |
return styleSpanClassString; |
} |
-bool isLegacyAppleStyleSpan(const Node *node) |
+bool isStyleSpan(const Node *node) |
{ |
if (!node || !node->isHTMLElement()) |
return false; |
@@ -96,8 +96,13 @@ |
return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(element), AllowNonEmptyStyleAttribute); |
} |
-static inline bool isSpanWithoutAttributesOrUnstyledStyleSpan(const Node* node) |
+static inline bool isUnstyledStyleSpan(const Node* node) |
{ |
+ return isStyleSpan(node) && hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(node), StyleAttributeShouldBeEmpty); |
+} |
+ |
+static inline bool isSpanWithoutAttributesOrUnstyleStyleSpan(const Node* node) |
+{ |
if (!node || !node->isHTMLElement() || !node->hasTagName(spanTag)) |
return false; |
return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(node), StyleAttributeShouldBeEmpty); |
@@ -118,12 +123,14 @@ |
static PassRefPtr<Element> createFontElement(Document* document) |
{ |
RefPtr<Element> fontNode = createHTMLElement(document, fontTag); |
+ fontNode->setAttribute(classAttr, styleSpanClassString()); |
return fontNode.release(); |
} |
PassRefPtr<HTMLElement> createStyleSpanElement(Document* document) |
{ |
RefPtr<HTMLElement> styleElement = createHTMLElement(document, spanTag); |
+ styleElement->setAttribute(classAttr, styleSpanClassString()); |
return styleElement.release(); |
} |
@@ -399,7 +406,8 @@ |
} |
if (inlineStyleDecl->isEmpty()) { |
removeNodeAttribute(element.get(), styleAttr); |
- if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) |
+ // FIXME: should this be isSpanWithoutAttributesOrUnstyleStyleSpan? Need a test. |
+ if (isUnstyledStyleSpan(element.get())) |
unstyledSpans.append(element.release()); |
} |
} |
@@ -411,7 +419,7 @@ |
static Node* dummySpanAncestorForNode(const Node* node) |
{ |
- while (node && (!node->isElementNode() || !isStyleSpanOrSpanWithOnlyStyleAttribute(toElement(node)))) |
+ while (node && !isStyleSpan(node)) |
node = node->parentNode(); |
return node ? node->parentNode() : 0; |
@@ -429,7 +437,7 @@ |
Node* next; |
for (Node* node = dummySpanAncestor->firstChild(); node; node = next) { |
next = node->nextSibling(); |
- if (isSpanWithoutAttributesOrUnstyledStyleSpan(node)) |
+ if (isUnstyledStyleSpan(node)) |
removeNodePreservingChildren(node); |
node = next; |
} |
@@ -516,7 +524,8 @@ |
inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); |
inlineStyle->removeProperty(CSSPropertyDirection); |
setNodeAttribute(element, styleAttr, inlineStyle->cssText()); |
- if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) |
+ // FIXME: should this be isSpanWithoutAttributesOrUnstyleStyleSpan? Need a test. |
+ if (isUnstyledStyleSpan(element)) |
removeNodePreservingChildren(element); |
} |
} |
@@ -873,7 +882,7 @@ |
for (size_t i = 0; i < attributes.size(); i++) |
removeNodeAttribute(element, attributes[i]); |
- if (isEmptyFontTag(element) || isSpanWithoutAttributesOrUnstyledStyleSpan(element)) |
+ if (isEmptyFontTag(element) || isSpanWithoutAttributesOrUnstyleStyleSpan(element)) |
removeNodePreservingChildren(element); |
return true; |
@@ -901,7 +910,7 @@ |
if (inlineStyle->isEmpty()) |
removeNodeAttribute(element, styleAttr); |
- if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) |
+ if (isSpanWithoutAttributesOrUnstyleStyleSpan(element)) |
removeNodePreservingChildren(element); |
return true; |