Commit 44c00582 authored by lweintraub's avatar lweintraub

LayoutTests:

        Reviewed by justin

        <rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
        <rdar://problem/4590763> FormatBlock for paragraph style doesn't work

        * editing/execCommand/format-block-with-braces-expected.checksum: Added.
        * editing/execCommand/format-block-with-braces-expected.png: Added.
        * editing/execCommand/format-block-with-braces-expected.txt: Added.
        * editing/execCommand/format-block-with-braces.html: Added.
        * editing/execCommand/indent-list-item-expected.checksum: Added.
        * editing/execCommand/indent-list-item-expected.png: Added.
        * editing/execCommand/indent-list-item-expected.txt: Added.
        * editing/execCommand/indent-list-item.html: Added.
        * editing/execCommand/indent-selection-expected.checksum: Added.
        * editing/execCommand/indent-selection-expected.png: Added.
        * editing/execCommand/indent-selection-expected.txt: Added.
        * editing/execCommand/indent-selection.html: Added.
        * editing/execCommand/outdent-selection-expected.checksum: Added.
        * editing/execCommand/outdent-selection-expected.png: Added.
        * editing/execCommand/outdent-selection-expected.txt: Added.
        * editing/execCommand/outdent-selection.html: Added.

WebCore:

        Reviewed by justin

        <rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
        <rdar://problem/4590763> FormatBlock for paragraph style doesn't work

        * dom/Node.cpp:
        (WebCore::Node::rootEditableElement): Return inline nodes
        * editing/FormatBlockCommand.cpp:
        (WebCore::FormatBlockCommand::doApply): Keep from inserting before editable content
        * editing/JSEditor.cpp: Support html braces (<>) around tag names



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9b1c7761
2006-06-28 Levi Weintraub <lweintraub@apple.com>
Reviewed by justin
<rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
<rdar://problem/4590763> FormatBlock for paragraph style doesn't work
* editing/execCommand/format-block-with-braces-expected.checksum: Added.
* editing/execCommand/format-block-with-braces-expected.png: Added.
* editing/execCommand/format-block-with-braces-expected.txt: Added.
* editing/execCommand/format-block-with-braces.html: Added.
* editing/execCommand/indent-list-item-expected.checksum: Added.
* editing/execCommand/indent-list-item-expected.png: Added.
* editing/execCommand/indent-list-item-expected.txt: Added.
* editing/execCommand/indent-list-item.html: Added.
* editing/execCommand/indent-selection-expected.checksum: Added.
* editing/execCommand/indent-selection-expected.png: Added.
* editing/execCommand/indent-selection-expected.txt: Added.
* editing/execCommand/indent-selection.html: Added.
* editing/execCommand/outdent-selection-expected.checksum: Added.
* editing/execCommand/outdent-selection-expected.png: Added.
* editing/execCommand/outdent-selection-expected.txt: Added.
* editing/execCommand/outdent-selection.html: Added.
2006-06-28 Levi Weintraub <lweintraub@apple.com>
Reviewed by justin
Missed the layout tests themselves in the first checkin! Whoops!
2006-06-28 Levi Weintraub <lweintraub@apple.com>
Reviewed by justin
234a16a1f6c067f0d87b41565e6dbcba
\ No newline at end of file
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of H1 > DIV > BODY > HTML > #document to 0 of H1 > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
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 784x571
RenderBlock {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 557x18
text run at (0,0) width 557: "This test uses FormatBlock with html brackets in the tag string passed to execCommand."
RenderBlock (anonymous) at (0,18) size 784x18
RenderBR {BR} at (0,0) size 0x18
RenderInline {DIV} at (0,0) size 0x0
RenderBlock (anonymous) at (0,57) size 784x37
RenderBlock {H1} at (0,0) size 784x37
RenderInline {DIV} at (0,0) size 156x37
RenderText {#text} at (0,0) size 156x37
text run at (0,0) width 156: "Format Me"
RenderBlock (anonymous) at (0,115) size 784x0
RenderInline {DIV} at (0,0) size 0x0
caret: position 0 of child 0 {#text} of child 0 {DIV} of child 0 {H1} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<div id="description">This test uses FormatBlock with html brackets in the tag string passed to execCommand.</div>
<br>
<div style="display:inline" contenteditable="true" id="item1">
Format Me
</div>
<script>
var s = window.getSelection();
var r = document.createRange();
var p1 = document.getElementById("item1");
s.setPosition(p1, 0);
document.execCommand("FormatBlock", false, "<h1>");
</script>
\ No newline at end of file
9e610294e20545bacfc2bedfb37899fa
\ No newline at end of file
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of LI > UL > UL > DIV > BODY > HTML > #document to 0 of LI > UL > UL > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
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 {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 374x18
text run at (0,0) width 374: "This test uses the execCommand to Outdent the text below."
RenderBlock (anonymous) at (0,18) size 784x18
RenderBR {BR} at (0,0) size 0x18
RenderBlock {DIV} at (0,52) size 784x54
RenderBlock {UL} at (0,0) size 784x54
RenderListItem {LI} at (40,0) size 744x18
RenderListMarker at (-17,0) size 7x18
RenderText {#text} at (0,0) size 25x18
text run at (0,0) width 25: "Foo"
RenderBlock {UL} at (40,18) size 744x18
RenderListItem {LI} at (40,0) size 704x18
RenderListMarker at (-17,0) size 7x18
RenderText {#text} at (0,0) size 23x18
text run at (0,0) width 23: "Bar"
RenderListItem {LI} at (40,36) size 744x18
RenderListMarker at (-17,0) size 7x18
RenderText {#text} at (0,0) size 25x18
text run at (0,0) width 25: "Baz"
caret: position 0 of child 0 {#text} of child 0 {LI} of child 3 {UL} of child 1 {UL} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<div id="description">
This test uses the execCommand to Outdent the text below.
</div>
<br>
<div contenteditable="true">
<ul>
<li>Foo</li>
<li id="item1">Bar</li>
<li>Baz</li>
</ul>
</div>
<script>
var s = window.getSelection();
var p1 = document.getElementById("item1");
s.setPosition(p1, 0);
document.execCommand("Indent", false, "");
</script>
\ No newline at end of file
d1074841553c7b04760fab12d8da6e9e
\ No newline at end of file
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 10 of DIV > BODY > HTML > #document
EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > BLOCKQUOTE > DIV > BODY > HTML > #document to 5 of #text > SPAN > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
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 {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 362x18
text run at (0,0) width 362: "This test uses the execCommand to indent the text below."
RenderBlock (anonymous) at (0,18) size 784x18
RenderBR {BR} at (0,0) size 0x18
RenderBlock {DIV} at (0,52) size 784x244
RenderBlock {BLOCKQUOTE} at (40,0) size 704x70
RenderBlock (anonymous) at (0,0) size 704x36
RenderInline {SPAN} at (0,0) size 42x18
RenderText {#text} at (0,0) size 42x18
text run at (0,0) width 42: "Lorem"
RenderBR {BR} at (42,14) size 0x0
RenderText {#text} at (0,18) size 83x18
text run at (0,18) width 83: "more Lorem!"
RenderBlock {BLOCKQUOTE} at (40,52) size 624x18
RenderText {#text} at (0,0) size 38x18
text run at (0,0) width 38: "ipsum"
RenderBlock (anonymous) at (0,86) size 784x0
RenderBlock {BLOCKQUOTE} at (40,86) size 704x54
RenderBlock {UL} at (0,0) size 704x54
RenderBlock {UL} at (40,0) size 664x54
RenderListItem {LI} at (40,0) size 624x18
RenderListMarker at (-17,0) size 7x18
RenderText {#text} at (0,0) size 25x18
text run at (0,0) width 25: "Foo"
RenderListItem {LI} at (40,18) size 624x18
RenderListMarker at (-17,0) size 7x18
RenderText {#text} at (0,0) size 23x18
text run at (0,0) width 23: "Bar"
RenderListItem {LI} at (40,36) size 624x18
RenderListMarker at (-17,0) size 7x18
RenderText {#text} at (0,0) size 25x18
text run at (0,0) width 25: "Baz"
RenderBlock {BLOCKQUOTE} at (40,156) size 704x88
RenderBlock {BLOCKQUOTE} at (40,0) size 624x18
RenderText {#text} at (0,0) size 37x18
text run at (0,0) width 37: "Dolor"
RenderBlock (anonymous) at (0,34) size 704x54
RenderBR {BR} at (0,0) size 0x18
RenderText {#text} at (0,18) size 34x18
text run at (0,18) width 34: "Sum!"
RenderBR {BR} at (34,32) size 0x0
RenderInline {SPAN} at (0,0) size 38x18
RenderText {#text} at (0,36) size 38x18
text run at (0,36) width 38: "Thing"
RenderBlock (anonymous) at (0,260) size 784x0
selection start: position 0 of child 0 {#text} of child 4 {SPAN} of child 3 {BLOCKQUOTE} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
selection end: position 5 of child 0 {#text} of child 4 {SPAN} of child 3 {BLOCKQUOTE} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<div id="description">
This test uses the execCommand to indent the text below.
</div>
<br>
<div contenteditable="true">
<span id="item1">Lorem</span><br>
more Lorem!
<blockquote>
ipsum<br>
<ul>
<li>Foo</li>
<li>Bar</li>
<li>Baz</li>
</ul>
Dolor
</blockquote>
Sum!<br>
<span id="item2">Thing</span>
</div>
<script>
var s = window.getSelection();
var p1 = document.getElementById("item1");
var p2 = document.getElementById("item2");
s.setPosition(p1, 0);
s.setBaseAndExtent(p1, 0, p2, 2);
document.execCommand("Indent", false, "");
</script>
\ No newline at end of file
73cbe29f64487852600dbe71dd92532a
\ No newline at end of file
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 12 of DIV > BODY > HTML > #document
EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 5 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 5 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
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 784x584
RenderBlock {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 374x18
text run at (0,0) width 374: "This test uses the execCommand to Outdent the text below."
RenderBlock (anonymous) at (0,18) size 784x18
RenderBR {BR} at (0,0) size 0x18
RenderBlock {DIV} at (0,36) size 784x210
RenderBlock (anonymous) at (0,0) size 784x54
RenderInline {SPAN} at (0,0) size 42x18
RenderText {#text} at (0,0) size 42x18
text run at (0,0) width 42: "Lorem"
RenderBR {BR} at (42,14) size 0x0
RenderText {#text} at (0,18) size 87x18
text run at (0,18) width 87: "more Lorem! "
RenderText {#text} at (87,18) size 38x18
text run at (87,18) width 38: "ipsum"
RenderBR {BR} at (125,32) size 0x0
RenderText {#text} at (0,36) size 37x18
text run at (0,36) width 37: "Dolor"
RenderBR {BR} at (37,50) size 0x0
RenderBlock {BLOCKQUOTE} at (40,70) size 704x54
RenderBlock (anonymous) at (0,0) size 704x54
RenderText {#text} at (0,0) size 25x18
text run at (0,0) width 25: "Foo"
RenderBR {BR} at (25,14) size 0x0
RenderText {#text} at (0,18) size 23x18
text run at (0,18) width 23: "Bar"
RenderBR {BR} at (23,32) size 0x0
RenderText {#text} at (0,36) size 25x18
text run at (0,36) width 25: "Baz"
RenderBR {BR} at (25,50) size 0x0
RenderBlock {UL} at (0,70) size 704x0
RenderBlock (anonymous) at (0,70) size 704x0
RenderBlock (anonymous) at (0,140) size 784x18
RenderText {#text} at (0,0) size 82x18
text run at (0,0) width 82: "Dinner time?"
RenderBR {BR} at (82,14) size 0x0
RenderBlock {UL} at (0,174) size 784x0
RenderBlock (anonymous) at (0,174) size 784x36
RenderText {#text} at (0,0) size 34x18
text run at (0,0) width 34: "Sum!"
RenderBR {BR} at (34,14) size 0x0
RenderInline {SPAN} at (0,0) size 38x18
RenderText {#text} at (0,18) size 38x18
text run at (0,18) width 38: "Thing"
RenderText {#text} at (0,0) size 0x0
selection start: position 0 of child 0 {#text} of child 1 {SPAN} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
selection end: position 5 of child 0 {#text} of child 16 {SPAN} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<div id="description">
This test uses the execCommand to Outdent the text below.
</div>
<br>
<div contenteditable="true">
<span id="item1">Lorem</span><br>
more Lorem!
<blockquote>
ipsum<br>
<ul>
<li>Foo</li>
<li>Bar</li>
<li>Baz</li>
</ul>
Dolor
</blockquote>
<ul>
<li>Dinner time?</li>
</ul>
Sum!<br>
<span id="item2">Thing</span>
</div>
<script>
var s = window.getSelection();
var p1 = document.getElementById("item1");
var p2 = document.getElementById("item2");
s.setPosition(p1, 0);
s.setBaseAndExtent(p1, 0, p2, 2);
document.execCommand("Outdent", false, "");
</script>
\ No newline at end of file
2006-06-28 Levi Weintraub <lweintraub@apple.com>
Reviewed by justin
<rdar://problem/4592005> FormatBlock inserts in the wrong place, disregarding editable content
<rdar://problem/4590763> FormatBlock for paragraph style doesn't work
* dom/Node.cpp:
(WebCore::Node::rootEditableElement): Return inline nodes
* editing/FormatBlockCommand.cpp:
(WebCore::FormatBlockCommand::doApply): Keep from inserting before editable content
* editing/JSEditor.cpp: Support html braces (<>) around tag names
2006-06-28 Justin Garcia <justin.garcia@apple.com>
Reviewed by levi
......
......@@ -1054,7 +1054,7 @@ Element* Node::rootEditableElement() const
{
Element* result = 0;
for (Node* n = const_cast<Node*>(this); n && n->isContentEditable(); n = n->parentNode()) {
if (n->isBlockFlow() && n->isElementNode())
if (n->isElementNode())
result = static_cast<Element*>(n);
if (n->hasTagName(bodyTag))
break;
......
......@@ -85,8 +85,8 @@ void FormatBlockCommand::doApply()
return;
QualifiedName qTypeOfBlock = QualifiedName(AtomicString(prefix), AtomicString(localName), xhtmlNamespaceURI);
Node* enclosingBlock = enclosingBlockFlowElement(endingSelection().visibleStart());
if (enclosingBlock->hasTagName(qTypeOfBlock))
Node* refNode = enclosingBlockFlowElement(endingSelection().visibleStart());
if (refNode->hasTagName(qTypeOfBlock))
// We're already in a block with the format we want, so we don't have to do anything
return;
......@@ -97,11 +97,16 @@ void FormatBlockCommand::doApply()
RefPtr<Node> blockNode = createElement(document(), m_tagName);
RefPtr<Node> placeholder = createBreakElement(document());
if (validBlockTag(enclosingBlock->nodeName().lower()) && paragraphStart == blockStart && paragraphEnd == blockEnd)
Node* root = endingSelection().start().node()->rootEditableElement();
if (refNode == root || root->isAncestor(refNode))
refNode = paragraphStart.deepEquivalent().node();
Position upstreamStart = paragraphStart.deepEquivalent().upstream();
if ((validBlockTag(refNode->nodeName().lower()) && paragraphStart == blockStart && paragraphEnd == blockEnd) ||
!upstreamStart.node()->isAncestor(root))
// Already in a valid block tag that only contains the current paragraph, so we can swap with the new tag
insertNodeBefore(blockNode.get(), enclosingBlock);
insertNodeBefore(blockNode.get(), refNode);
else {
Position upstreamStart = paragraphStart.deepEquivalent().upstream();
insertNodeAt(blockNode.get(), upstreamStart.node(), upstreamStart.offset());
}
appendNode(placeholder.get(), blockNode.get());
......
......@@ -264,6 +264,8 @@ bool execForeColor(Frame *frame, bool userInterface, const String &value)
bool execFormatBlock(Frame *frame, bool userInterface, const String &value)
{
String tagName = value.lower();
if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
tagName = tagName.substring(1, tagName.length() - 2);
if (!validBlockTag(tagName))
return 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