Commit 2b981fc4 authored by justing's avatar justing

LayoutTests:

        Reviewed by kevin
        
        <http://bugs.webkit.org/show_bug.cgi?id=12245>
        FCKeditor: Remove Format sometimes doesn't work
        <rdar://problem/4786404>
        Underline style is not removed from selection after performing Remove Format

        Added:
        * editing/execCommand/4786404-1-expected.checksum: Added.
        * editing/execCommand/4786404-1-expected.png: Added.
        * editing/execCommand/4786404-1-expected.txt: Added.
        * editing/execCommand/4786404-1.html: Added.
        * editing/execCommand/4786404-2-expected.checksum: Added.
        * editing/execCommand/4786404-2-expected.png: Added.
        * editing/execCommand/4786404-2-expected.txt: Added.
        * editing/execCommand/4786404-2.html: Added.
        Demonstrate fixes:
        * editing/execCommand/4920488-expected.checksum:
        * editing/execCommand/4920488-expected.png:
        * editing/execCommand/4920488-expected.txt:
        * editing/execCommand/4920742-1-expected.checksum:
        * editing/execCommand/4920742-1-expected.png:
        * editing/execCommand/4920742-1-expected.txt:
        * editing/execCommand/remove-formatting-2-expected.checksum:
        * editing/execCommand/remove-formatting-2-expected.png:
        * editing/execCommand/remove-formatting-2-expected.txt:
        Ditto, also added a FIXME:
        * editing/execCommand/remove-formatting-expected.checksum:
        * editing/execCommand/remove-formatting-expected.png:
        * editing/execCommand/remove-formatting-expected.txt:
        * editing/execCommand/remove-formatting.html:

WebCore:

        Reviewed by kevin
        
        <http://bugs.webkit.org/show_bug.cgi?id=12245>
        FCKeditor: Remove Format sometimes doesn't work
        <rdar://problem/4786404>
        Underline style is not removed from selection after performing Remove Format

        * editing/Editor.cpp:
        (WebCore::Editor::removeFormattingAndStyle): Re-wrote this.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19991 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 989a64f7
2007-03-06 Justin Garcia <justin.garcia@apple.com>
Reviewed by kevin
<http://bugs.webkit.org/show_bug.cgi?id=12245>
FCKeditor: Remove Format sometimes doesn't work
<rdar://problem/4786404>
Underline style is not removed from selection after performing Remove Format
Added:
* editing/execCommand/4786404-1-expected.checksum: Added.
* editing/execCommand/4786404-1-expected.png: Added.
* editing/execCommand/4786404-1-expected.txt: Added.
* editing/execCommand/4786404-1.html: Added.
* editing/execCommand/4786404-2-expected.checksum: Added.
* editing/execCommand/4786404-2-expected.png: Added.
* editing/execCommand/4786404-2-expected.txt: Added.
* editing/execCommand/4786404-2.html: Added.
Demonstrate fixes:
* editing/execCommand/4920488-expected.checksum:
* editing/execCommand/4920488-expected.png:
* editing/execCommand/4920488-expected.txt:
* editing/execCommand/4920742-1-expected.checksum:
* editing/execCommand/4920742-1-expected.png:
* editing/execCommand/4920742-1-expected.txt:
* editing/execCommand/remove-formatting-2-expected.checksum:
* editing/execCommand/remove-formatting-2-expected.png:
* editing/execCommand/remove-formatting-2-expected.txt:
Ditto, also added a FIXME:
* editing/execCommand/remove-formatting-expected.checksum:
* editing/execCommand/remove-formatting-expected.png:
* editing/execCommand/remove-formatting-expected.txt:
* editing/execCommand/remove-formatting.html:
2007-03-06 Kevin Decker <kdecker@apple.com>
Reviewed by Adele.
1775394c7d651a729d009b4604871c29
\ No newline at end of file
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 [color=#999999]
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 784x36
text run at (0,0) width 784: "This tests for a bug where performing the Remove Format operation on content would apply the document's style to"
text run at (0,18) width 267: "it, not the editable regions default style. "
text run at (267,18) width 377: "The text below should not be bold, and should be black."
RenderBlock {DIV} at (0,52) size 784x18 [color=#000000]
RenderText {#text} at (0,0) size 71x18
text run at (0,0) width 71: "foo bar baz"
selection start: position 0 of child 0 {#text} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
selection end: position 11 of child 0 {#text} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<html style="font-weight: bold;">
<body style="color: #999;">
<p>This tests for a bug where performing the Remove Format operation on content would apply the document's style to it, not the editable regions default style. The text below should not be bold, and should be black.</p>
<div id="div" contenteditable="true" style="font-weight: normal; color: black;">foo <i>bar</i> baz</div>
<script>
var div = document.getElementById("div");
div.focus();
document.execCommand("RemoveFormat");
</script>
</body>
d7881285eb08dbcb83e40ecddc3d20d8
\ No newline at end of file
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 784x36
RenderText {#text} at (0,0) size 772x36
text run at (0,0) width 772: "This tests for a bug where performing the Remove Format operation on a selection that started in underlined content would"
text run at (0,18) width 212: "underline everything operated on."
RenderBlock {DIV} at (0,52) size 784x18
RenderText {#text} at (0,0) size 71x18
text run at (0,0) width 71: "foo bar baz"
selection start: position 0 of child 0 {#text} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
selection end: position 11 of child 0 {#text} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<html>
<body>
<p>This tests for a bug where performing the Remove Format operation on a selection that started in underlined content would underline everything operated on.</p>
<div id="div" contenteditable="true"><u>foo</u> bar baz</div>
<script>
var div = document.getElementById("div");
div.focus();
document.execCommand("RemoveFormat");
</script>
</body>
ce64c3b7059dab375961686ca2aa0956
\ No newline at end of file
f1af284cf9d2fd4ef5765735acd654b0
\ No newline at end of file
......@@ -12,4 +12,5 @@ layer at (0,0) size 800x600
RenderBlock {DIV} at (0,52) size 784x18
RenderText {#text} at (0,0) size 53x18
text run at (0,0) width 53: "dogfood"
caret: position 7 of child 0 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
selection start: position 0 of child 0 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
selection end: position 7 of child 0 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
d84e33037e7df15531f6b5323e760175
\ No newline at end of file
7be99d72a3228d92356e5ed05a43097c
\ No newline at end of file
......@@ -13,12 +13,11 @@ layer at (0,0) size 800x600
text run at (126,18) width 185: "It should be on the last line."
RenderBlock {DIV} at (0,52) size 784x54
RenderBlock (anonymous) at (0,0) size 784x0
RenderBlock {DIV} at (0,0) size 784x54
RenderBlock {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 21x18
text run at (0,0) width 21: "foo"
RenderBlock {DIV} at (0,18) size 784x18
RenderBR {BR} at (0,0) size 0x18
RenderBlock (anonymous) at (0,36) size 784x18
RenderBR {BR} at (0,0) size 0x18
caret: position 0 of child 0 {BR} of child 1 {DIV} of child 0 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
RenderBlock {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 21x18
text run at (0,0) width 21: "foo"
RenderBlock {DIV} at (0,18) size 784x18
RenderBR {BR} at (0,0) size 0x18
RenderBlock {DIV} at (0,36) size 784x18
RenderBR {BR} at (0,0) size 0x18
caret: position 0 of child 0 {BR} of child 2 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
d7ae305d9b161eed95c6b7a643adce6c
\ No newline at end of file
8b7372effa7d6b934935cfa3e3f056b6
\ No newline at end of file
......@@ -2,7 +2,10 @@ EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -15,8 +18,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 722: "This tests that RemoveFormat not only removes style from the selected part of the DOM, but that it also applies the"
text run at (0,18) width 625: "document default style to the selection if that's necessary in order to leave the selected text unstyled."
RenderBlock {DIV} at (0,52) size 784x18
RenderText {#text} at (0,0) size 28x18
text run at (0,0) width 28: "This"
RenderText {#text} at (28,0) size 277x18
text run at (28,0) width 277: " text should look the same as the text above."
caret: position 4 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
RenderText {#text} at (0,0) size 305x18
text run at (0,0) width 305: "This text should look the same as the text above."
selection start: position 0 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
selection end: position 4 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
0b20b5f332955ebe0fda257b29b3c264
\ No newline at end of file
312d1fb518c4df3350a75a0a4eb3fb6b
\ No newline at end of file
......@@ -3,37 +3,47 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > B > DIV > BODY > HTML > #document to 3 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 11 of #text > DIV > DIV > BODY > HTML > #document to 11 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 11 of #text > DIV > DIV > BODY > HTML > #document to 11 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
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 784x576
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (0,0) size 321x18
text run at (0,0) width 321: "This is a test for execCommand(\"RemoveFormat\")"
RenderBlock {DIV} at (0,34) size 784x54
RenderBlock {DIV} at (0,0) size 784x18
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 329x18
text run at (0,0) width 329: "This is a test for execCommand(\"RemoveFormat\"). "
RenderInline {B} at (0,0) size 747x36
RenderText {#text} at (329,0) size 747x36
text run at (329,0) width 418: "It demonstrates a bug: everything in the editable region below"
text run at (0,18) width 576: "should be selected, as everything was selected before Remove Format was performed."
RenderBlock {DIV} at (0,52) size 784x54
RenderBlock (anonymous) at (0,0) size 784x18
RenderText {#text} at (0,0) size 63x18
text run at (0,0) width 63: "foobarbaz"
RenderBlock {DIV} at (0,18) size 784x18
RenderText {#text} at (0,0) size 21x18
text run at (0,0) width 21: "foo"
RenderInline {SPAN} at (0,0) size 11x18
RenderText {#text} at (21,0) size 11x18
text run at (21,0) width 11: "\x{9}"
RenderText {#text} at (32,0) size 20x18
text run at (32,0) width 20: "bar"
RenderInline {SPAN} at (0,0) size 12x18
RenderText {#text} at (52,0) size 12x18
text run at (52,0) width 12: "\x{9}"
RenderText {#text} at (64,0) size 22x18
text run at (64,0) width 22: "baz"
RenderText {#text} at (0,0) size 71x18
text run at (0,0) width 71: "foo\x{9}bar\x{9}baz"
RenderBlock {DIV} at (0,36) size 784x18
RenderText {#text} at (0,0) size 63x18
text run at (0,0) width 63: "foobarbaz"
RenderBlock (anonymous) at (0,54) size 784x0
RenderBlock {UL} at (0,104) size 784x0
caret: position 9 of child 0 {#text} of child 2 {DIV} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
RenderBlock {UL} at (0,122) size 784x0
selection start: position 0 of child 0 {#text} of child 3 {DIV} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
selection end: position 9 of child 0 {#text} of child 3 {DIV} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
......@@ -2,7 +2,7 @@
if (window.layoutTestController)
layoutTestController.dumpEditingCallbacks();
</script>
<p>This is a test for execCommand("RemoveFormat")</p>
<p>This is a test for execCommand("RemoveFormat"). <b>It demonstrates a bug: everything in the editable region below should be selected, as everything was selected before Remove Format was performed.</b></p>
<div id="test" contenteditable="true">
<b>foo</b><a href="http://www.google.com/">bar</a><i>baz</i><br>
<table border="1"><tr><td>foo</td><td>bar</td><td>baz</td></tr></table>
......
2007-03-06 Justin Garcia <justin.garcia@apple.com>
Reviewed by kevin
<http://bugs.webkit.org/show_bug.cgi?id=12245>
FCKeditor: Remove Format sometimes doesn't work
<rdar://problem/4786404>
Underline style is not removed from selection after performing Remove Format
* editing/Editor.cpp:
(WebCore::Editor::removeFormattingAndStyle): Re-wrote this.
2007-03-07 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Oliver.
......
......@@ -508,26 +508,22 @@ void Editor::removeFormattingAndStyle()
Document* document = m_frame->document();
// Make a plain text string from the selection to remove formatting like tables and lists.
RefPtr<DocumentFragment> text = createFragmentFromText(m_frame->selectionController()->toRange().get(), m_frame->selectionController()->toString());
String string = m_frame->selectionController()->toString();
// Put the fragment made from that string into a style span with the document's
// default style to make sure that it is unstyled regardless of where it is inserted.
Position pos(document->documentElement(), 0);
RefPtr<CSSComputedStyleDeclaration> computedStyle = pos.computedStyle();
// Get the default style for this editable root, it's the style that we'll give the
// content that we're operating on.
Node* root = m_frame->selectionController()->rootEditableElement();
RefPtr<CSSComputedStyleDeclaration> computedStyle = new CSSComputedStyleDeclaration(root);
RefPtr<CSSMutableStyleDeclaration> defaultStyle = computedStyle->copyInheritableProperties();
RefPtr<Element> span = createStyleSpanElement(document);
span->setAttribute(styleAttr, defaultStyle->cssText());
ExceptionCode ec;
while (text->firstChild())
span->appendChild(text->firstChild(), ec);
RefPtr<DocumentFragment> fragment = new DocumentFragment(document);
fragment->appendChild(span, ec);
// Delete the selected content.
// FIXME: We should be able to leave this to insertText, but its delete operation
// doesn't preserve the style we're about to set.
deleteSelectionWithSmartDelete(false);
applyCommand(new ReplaceSelectionCommand(document, fragment, false, false, false, true, EditActionUnspecified));
// Insert the content with the default style.
m_frame->setTypingStyle(defaultStyle.get());
TypingCommand::insertText(document, string, true);
}
void Editor::setLastEditCommand(PassRefPtr<EditCommand> lastEditCommand)
......
......@@ -100,6 +100,7 @@ void InsertTextCommand::input(const String &text, bool selectInsertedText)
return;
// Delete the current selection.
// FIXME: This delete operation blows away the typing style.
if (endingSelection().isRange())
deleteSelection(false, true, true, false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment