Reviewed by darin
<rdar://problem/
5134759>
GMail Editor: Hang after pasting underlined text multiple times
Demonstrates the bug:
* editing/pasteboard/
5134759-expected.checksum: Added.
* editing/pasteboard/
5134759-expected.png: Added.
* editing/pasteboard/
5134759-expected.txt: Added.
* editing/pasteboard/
5134759.html: Added.
A unnecessary extra space was added to an element's
inline style declaration, because of the way cssText behaves:
* editing/pasteboard/paste-table-002-expected.txt:
WebCore:
Reviewed by darin
<rdar://problem/
5134759>
GMail Editor: Hang after pasting underlined text multiple times
The moveParagraphs call that ReplaceSelectionCommand
performs must receive only inline content from createMarkup,
or else it will result in another call to moveParagraphs
when it performs the move, resulting in infinite recursion.
* editing/markup.cpp:
(WebCore::startMarkup): We were only converting a block to
an inline if it had an inline style declaration or styles
coming from matched rules. Cleaned up this code a bit by
handling an element's style separately from its other
attributes.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20912
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-04-16 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by darin
+
+ <rdar://problem/5134759>
+ GMail Editor: Hang after pasting underlined text multiple times
+
+ Demonstrates the bug:
+ * editing/pasteboard/5134759-expected.checksum: Added.
+ * editing/pasteboard/5134759-expected.png: Added.
+ * editing/pasteboard/5134759-expected.txt: Added.
+ * editing/pasteboard/5134759.html: Added.
+
+ A unnecessary extra space was added to an element's
+ inline style declaration, because of the way cssText behaves:
+ * editing/pasteboard/paste-table-002-expected.txt:
+
2007-04-13 David Kilzer <ddkilzer@webkit.org>
Patch and review by hyatt. Testing and landing by ddkilzer.
--- /dev/null
+2bbca86f137f72d6dbeabd3ddd670f74
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 648x18
+ text run at (0,0) width 504: "This tests for a hang when pasting underlined content at the end of a paragraph. "
+ text run at (504,0) width 144: "You should see 'Hello "
+ RenderInline {U} at (0,0) size 45x18
+ RenderText {#text} at (648,0) size 45x18
+ text run at (648,0) width 45: "World!"
+ RenderText {#text} at (693,0) size 50x18
+ text run at (693,0) width 50: "' below."
+ RenderBlock {DIV} at (0,34) size 784x18
+ RenderBlock {DIV} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 39x18
+ text run at (0,0) width 39: "Hello "
+ RenderInline {SPAN} at (0,0) size 45x18
+ RenderInline {DIV} at (0,0) size 45x18
+ RenderText {#text} at (39,0) size 45x18
+ text run at (39,0) width 45: "World!"
+ RenderBlock (anonymous) at (0,18) size 784x0
+caret: position 6 of child 0 {#text} of child 0 {DIV} of child 1 {SPAN} of child 0 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
--- /dev/null
+<p>This tests for a hang when pasting underlined content at the end of a paragraph. You should see 'Hello <u>World!</u>' below.</p>
+
+<div id="div" contenteditable="true"><div>Hello </div></div>
+
+<script>
+var sel = window.getSelection();
+var div = document.getElementById("div");
+sel.setPosition(div, div.childNodes.length);
+document.execCommand("InsertHTML", false, "<span style='text-decoration: underline;'><div>World!</div></span>");
+</script>
abcdef
foo bar
ghijk
-<div id="test" class="editing"> <div>abcdef<div style="text-align: center"><table><tbody><tr><td>foo</td><td>bar</td></tr></tbody></table>ghijk</div> </div> </div>
+<div id="test" class="editing"> <div>abcdef<div style="text-align: center; "><table><tbody><tr><td>foo</td><td>bar</td></tr></tbody></table>ghijk</div> </div> </div>
+2007-04-16 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by darin
+
+ <rdar://problem/5134759>
+ GMail Editor: Hang after pasting underlined text multiple times
+
+ The moveParagraphs call that ReplaceSelectionCommand
+ performs must receive only inline content from createMarkup,
+ or else it will result in another call to moveParagraphs
+ when it performs the move, resulting in infinite recursion.
+
+ * editing/markup.cpp:
+ (WebCore::startMarkup): We were only converting a block to
+ an inline if it had an inline style declaration or styles
+ coming from matched rules. Cleaned up this code a bit by
+ handling an element's style separately from its other
+ attributes.
+
2007-04-16 Darin Adler <darin@apple.com>
- get layout tests going again
const Element* el = static_cast<const Element*>(node);
convertBlocksToInlines &= isBlock(const_cast<Node*>(node));
markup += el->nodeNamePreservingCase().deprecatedString();
- String additionalStyle;
- if (annotate && el->isHTMLElement()) {
- RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRulesForElement(const_cast<Element*>(el));
- if (convertBlocksToInlines)
- style->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE, true);
- if (style->length() > 0)
- additionalStyle = style->cssText();
- }
NamedAttrMap *attrs = el->attributes();
unsigned length = attrs->length();
for (unsigned int i = 0; i < length; i++) {
Attribute *attr = attrs->attributeItem(i);
+ // We'll handle the style attribute separately, below.
+ if (attr->name() == styleAttr && el->isHTMLElement() && (annotate || convertBlocksToInlines))
+ continue;
String value = attr->value();
- if (attr->name() == styleAttr && convertBlocksToInlines && el->isHTMLElement()) {
- Element* element = const_cast<Element*>(el);
- RefPtr<CSSMutableStyleDeclaration> inlineStyle = static_cast<HTMLElement*>(element)->getInlineStyleDecl()->copy();
- inlineStyle->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE, true);
- value = inlineStyle->cssText();
- }
- if (annotate && attr->name() == styleAttr && additionalStyle.length()) {
- value += "; " + additionalStyle;
- additionalStyle = "";
- }
// FIXME: Handle case where value has illegal characters in it, like "
if (documentIsHTML)
markup += " " + attr->name().localName().deprecatedString();
markup += "=\"" + escapeTextForMarkup(value.deprecatedString(), true) + "\"";
}
- if (annotate && additionalStyle.length())
- // FIXME: Handle case where additionalStyle has illegal characters in it, like "
- markup += " " + styleAttr.localName().deprecatedString() + "=\"" + additionalStyle.deprecatedString() + "\"";
+ if (el->isHTMLElement() && (annotate || convertBlocksToInlines)) {
+ Element* element = const_cast<Element*>(el);
+ RefPtr<CSSMutableStyleDeclaration> style = static_cast<HTMLElement*>(element)->getInlineStyleDecl()->copy();
+ if (annotate) {
+ RefPtr<CSSMutableStyleDeclaration> styleFromMatchedRules = styleFromMatchedRulesForElement(const_cast<Element*>(el));
+ style->merge(styleFromMatchedRules.get());
+ }
+ if (convertBlocksToInlines)
+ style->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE, true);
+ if (style->length() > 0)
+ markup += " " + styleAttr.localName().deprecatedString() + "=\"" + style->cssText().deprecatedString() + "\"";
+ }
if (shouldSelfClose(el)) {
if (el->isHTMLElement())