2009-07-14 Ryosuke Niwa <rniwa@google.com>
Reviewed by Eric Seidel.
Outdenting a line inside a blockquote tag does nothing
https://bugs.webkit.org/show_bug.cgi?id=25316
The bug was caused by the code checking whether the blockquote is created by WebKit or not.
We simply remove this code to be consistent with Firefox and Internet Explorer.
Also, enclosingBlockFlow == enclosingNode in outdentParagraph isn't a sufficient condition to insert
the placeholder before the enclosingNode because there could be contents before the current paragraph.
Instead, we should split the enclosingNode (which is a blockquote) at the starting position of outdentation.
It turned out that this solves the bug 25315 also: https://bugs.webkit.org/show_bug.cgi?id=25315
Test: editing/execCommand/outdent-regular-blockquote.html
* editing/IndentOutdentCommand.cpp:
(WebCore::isIndentBlockquote): no longer checks whether a blockquote is created by WebKit or not.
(WebCore::IndentOutdentCommand::outdentParagraph): takes care of the case enclosingBlockFlow == enclosingNode
LayoutTests:
2009-07-14 Ryosuke Niwa <rniwa@google.com>
Reviewed by Eric Seidel.
Outdenting a line inside a blockquote tag does nothing
https://bugs.webkit.org/show_bug.cgi?id=25315
https://bugs.webkit.org/show_bug.cgi?id=25316
The expected result for /editing/execCommand/outdent-selection-expected.html
was rebaselined since the original expected result was wrong (Bug 25315).
Namely, "ipsum" moved to the same paragraph as "more Lorem!"
("ipsum" was in the blockblock immediately below "more Lorem!")
and "Dolor" was moved above the list items "Foo", "Bar", and "Baz".
* editing/execCommand/outdent-regular-blockquote-expected.txt: Added.
* editing/execCommand/outdent-regular-blockquote.html: Added.
* platform/mac/editing/execCommand/outdent-selection-expected.checksum:
* platform/mac/editing/execCommand/outdent-selection-expected.png:
* platform/mac/editing/execCommand/outdent-selection-expected.txt:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45886
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-07-14 Ryosuke Niwa <rniwa@google.com>
+
+ Reviewed by Eric Seidel.
+
+ Outdenting a line inside a blockquote tag does nothing
+ https://bugs.webkit.org/show_bug.cgi?id=25315
+ https://bugs.webkit.org/show_bug.cgi?id=25316
+
+ The expected result for /editing/execCommand/outdent-selection-expected.html
+ was rebaselined since the original expected result was wrong (Bug 25315).
+ Namely, "ipsum" moved to the same paragraph as "more Lorem!"
+ ("ipsum" was in the blockblock immediately below "more Lorem!")
+ and "Dolor" was moved above the list items "Foo", "Bar", and "Baz".
+
+ * editing/execCommand/outdent-regular-blockquote-expected.txt: Added.
+ * editing/execCommand/outdent-regular-blockquote.html: Added.
+ * platform/mac/editing/execCommand/outdent-selection-expected.checksum:
+ * platform/mac/editing/execCommand/outdent-selection-expected.png:
+ * platform/mac/editing/execCommand/outdent-selection-expected.txt:
+
2009-07-14 Darin Adler <darin@apple.com>
Reviewed by Dan Bernstein.
--- /dev/null
+This tests outdenting "two", the second paragraph in a regular blockquote (not created by WebKit). After outdenting two, there should be exactly two blockquotes.
+
+one
+two
+three
+Before: <blockquote id="test">one<br>two<br>three</blockquote>
+After: <blockquote id="test">one<br></blockquote>two<br><blockquote id="test">three</blockquote>
--- /dev/null
+<html>
+<body>
+<p>This tests outdenting "two", the second paragraph in a regular blockquote (not created by WebKit). After outdenting two, there should be exactly two blockquotes.</p>
+<div id="e" contenteditable="true">
+<blockquote id="test">one<br>two<br>three</blockquote>
+</div>
+
+<ul>
+<li>Before:<span id="c1"></span></li>
+<li>After:<span id="c2"></span></li>
+</ul>
+
+<script type="text/javascript">
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+var e = document.getElementById('e');
+
+document.getElementById('c1').appendChild(document.createTextNode(e.innerHTML));
+
+var s = window.getSelection();
+var r = document.createRange();
+r.setStart(document.getElementById('test'),2);
+r.setEnd(document.getElementById('test'),2);
+s.removeAllRanges();
+s.addRange(r);
+document.execCommand("Outdent", false, "");
+
+document.getElementById('c2').appendChild(document.createTextNode(e.innerHTML));
+
+</script>
-97ac98e6c95c9e62add62da32590799d
\ No newline at end of file
+1e2e3e7a894979e6744681a02b4da7af
\ No newline at end of file
text run at (0,18) width 279: "that's not in a list is pulled out of position."
RenderBlock (anonymous) at (0,36) size 784x18
RenderBR {BR} at (0,0) size 0x18
- RenderBlock {DIV} at (0,54) size 784x194
- RenderBlock (anonymous) at (0,0) size 784x54
+ RenderBlock {DIV} at (0,54) size 784x212
+ RenderBlock (anonymous) at (0,0) size 784x36
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
+ RenderText {#text} at (0,18) size 83x18
+ text run at (0,18) width 83: "more Lorem!"
+ RenderBlock {BLOCKQUOTE} at (40,36) size 744x0
+ RenderBlock (anonymous) at (0,36) size 784x18
+ RenderText {#text} at (0,0) size 38x18
+ text run at (0,0) width 38: "ipsum"
+ RenderBR {BR} at (38,14) size 0x0
RenderBlock {BLOCKQUOTE} at (40,54) size 744x54
RenderBlock (anonymous) at (0,0) size 744x54
RenderText {#text} at (0,0) size 25x18
text run at (0,36) width 25: "Baz"
RenderBR {BR} at (25,50) size 0x0
RenderBlock {UL} at (0,70) size 744x0
- RenderBlock (anonymous) at (0,70) size 744x0
- RenderBlock (anonymous) at (0,124) 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,158) size 784x0
- RenderBlock (anonymous) at (0,158) size 784x36
+ RenderBlock (anonymous) at (0,124) size 784x36
+ RenderText {#text} at (0,0) size 37x18
+ text run at (0,0) width 37: "Dolor"
+ RenderBR {BR} at (37,14) size 0x0
+ RenderText {#text} at (0,18) size 82x18
+ text run at (0,18) width 82: "Dinner time?"
+ RenderBR {BR} at (82,32) size 0x0
+ RenderBlock {UL} at (0,176) size 784x0
+ RenderBlock (anonymous) at (0,176) size 784x36
RenderText {#text} at (0,0) size 34x18
text run at (0,0) width 34: "Sum!"
RenderBR {BR} at (34,14) size 0x0
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 1 {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 1 {BODY} of child 0 {HTML} of document
+selection end: position 5 of child 0 {#text} of child 17 {SPAN} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+2009-07-14 Ryosuke Niwa <rniwa@google.com>
+
+ Reviewed by Eric Seidel.
+
+ Outdenting a line inside a blockquote tag does nothing
+ https://bugs.webkit.org/show_bug.cgi?id=25316
+
+ The bug was caused by the code checking whether the blockquote is created by WebKit or not.
+ We simply remove this code to be consistent with Firefox and Internet Explorer.
+ Also, enclosingBlockFlow == enclosingNode in outdentParagraph isn't a sufficient condition to insert
+ the placeholder before the enclosingNode because there could be contents before the current paragraph.
+ Instead, we should split the enclosingNode (which is a blockquote) at the starting position of outdentation.
+ It turned out that this solves the bug 25315 also: https://bugs.webkit.org/show_bug.cgi?id=25315
+
+ Test: editing/execCommand/outdent-regular-blockquote.html
+
+ * editing/IndentOutdentCommand.cpp:
+ (WebCore::isIndentBlockquote): no longer checks whether a blockquote is created by WebKit or not.
+ (WebCore::IndentOutdentCommand::outdentParagraph): takes care of the case enclosingBlockFlow == enclosingNode
+
2009-07-14 Adam Barth <abarth@webkit.org>
Reviewed by Dimitri Glazkov.
return element.release();
}
-static bool isIndentBlockquote(const Node* node)
-{
- if (!node || !node->hasTagName(blockquoteTag) || !node->isElementNode())
- return false;
-
- const Element* elem = static_cast<const Element*>(node);
- return elem->getAttribute(classAttr) == indentBlockquoteString();
-}
-
static bool isListOrIndentBlockquote(const Node* node)
{
- return node && (node->hasTagName(ulTag) || node->hasTagName(olTag) || isIndentBlockquote(node));
+ return node && (node->hasTagName(ulTag) || node->hasTagName(olTag) || node->hasTagName(blockquoteTag));
}
IndentOutdentCommand::IndentOutdentCommand(Document* document, EIndentType typeOfAction, int marginInPixels)
int currentBlockquoteLevel = 0;
int lastBlockquoteLevel = 0;
Node* node = currentParagraph.deepEquivalent().node();
- while ((node = enclosingNodeOfType(Position(node->parentNode(), 0), &isIndentBlockquote)))
+ while ((node = enclosingNodeWithTag(Position(node->parentNode(), 0), blockquoteTag)))
currentBlockquoteLevel++;
node = lastBlockquote.get();
- while ((node = enclosingNodeOfType(Position(node->parentNode(), 0), &isIndentBlockquote)))
+ while ((node = enclosingNodeWithTag(Position(node->parentNode(), 0), blockquoteTag)))
lastBlockquoteLevel++;
while (currentBlockquoteLevel > lastBlockquoteLevel) {
RefPtr<Element> newBlockquote = createIndentBlockquoteElement(document());
lastBlockquoteLevel++;
}
while (currentBlockquoteLevel < lastBlockquoteLevel) {
- lastBlockquote = static_cast<Element*>(enclosingNodeOfType(Position(lastBlockquote->parentNode(), 0), isIndentBlockquote));
+ lastBlockquote = static_cast<Element*>(enclosingNodeWithTag(Position(lastBlockquote->parentNode(), 0), blockquoteTag));
lastBlockquoteLevel--;
}
RefPtr<Element> placeholder = createBreakElement(document());
return;
}
- // The selection is inside a blockquote
+ // The selection is inside a blockquote i.e. enclosingNode is a blockquote
VisiblePosition positionInEnclosingBlock = VisiblePosition(Position(enclosingNode, 0));
VisiblePosition startOfEnclosingBlock = startOfBlock(positionInEnclosingBlock);
VisiblePosition lastPositionInEnclosingBlock = VisiblePosition(Position(enclosingNode, enclosingNode->childNodeCount()));
// just removed one, then this assumption isn't true. By splitting the next containing blockquote after this node, we keep this assumption true
if (splitPoint) {
if (Node* splitPointParent = splitPoint->parentNode()) {
- if (isIndentBlockquote(splitPointParent)
- && !isIndentBlockquote(splitPoint)
+ if (splitPointParent->hasTagName(blockquoteTag)
+ && !splitPoint->hasTagName(blockquoteTag)
&& isContentEditable(splitPointParent->parentNode())) // We can't outdent if there is no place to go!
splitElement(static_cast<Element*>(splitPointParent), splitPoint);
}
return;
}
- Node* enclosingBlockFlow = enclosingBlockFlowElement(visibleStartOfParagraph);
+ Node* enclosingBlockFlow = enclosingBlock(visibleStartOfParagraph.deepEquivalent().node());
RefPtr<Node> splitBlockquoteNode = enclosingNode;
if (enclosingBlockFlow != enclosingNode)
- splitBlockquoteNode = splitTreeToNode(enclosingBlockFlowElement(visibleStartOfParagraph), enclosingNode, true);
+ splitBlockquoteNode = splitTreeToNode(enclosingBlockFlow, enclosingNode, true);
+ else {
+ // We split the blockquote at where we start outdenting.
+ splitElement(static_cast<Element*>(enclosingNode), visibleStartOfParagraph.deepEquivalent().node());
+ }
RefPtr<Node> placeholder = createBreakElement(document());
insertNodeBefore(placeholder, splitBlockquoteNode);
moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visibleEndOfParagraph), VisiblePosition(Position(placeholder.get(), 0)), true);