[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 14:33:32 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 93d722a2c768ca6b17137f86af2d1bee04ed7134
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Oct 13 06:34:18 2010 +0000
2010-10-12 Sheriff Bot <webkit.review.bot at gmail.com>
Unreviewed, rolling out r69639.
http://trac.webkit.org/changeset/69639
https://bugs.webkit.org/show_bug.cgi?id=47575
"regressed nav-element.html" (Requested by rniwa on #webkit).
* editing/execCommand/format-block-expected.txt:
* editing/execCommand/format-block-from-range-selection-expected.txt:
* editing/execCommand/format-block-multiple-paragraphs-expected.txt: Removed.
* editing/execCommand/format-block-multiple-paragraphs.html: Removed.
* editing/execCommand/format-block-table-expected.txt: Removed.
* editing/execCommand/format-block-table.html: Removed.
* editing/execCommand/format-block-with-braces-expected.txt:
2010-10-12 Sheriff Bot <webkit.review.bot at gmail.com>
Unreviewed, rolling out r69639.
http://trac.webkit.org/changeset/69639
https://bugs.webkit.org/show_bug.cgi?id=47575
"regressed nav-element.html" (Requested by rniwa on #webkit).
* editing/ApplyBlockElementCommand.cpp:
(WebCore::ApplyBlockElementCommand::formatSelection):
* editing/EditorCommand.cpp:
(WebCore::executeFormatBlock):
* editing/FormatBlockCommand.cpp:
(WebCore::FormatBlockCommand::formatRange):
* editing/FormatBlockCommand.h:
(WebCore::FormatBlockCommand::editingAction):
* editing/VisiblePosition.cpp:
(WebCore::enclosingBlockFlowElement):
* editing/VisiblePosition.h:
* editing/htmlediting.cpp:
(WebCore::validBlockTag):
* editing/htmlediting.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 876fd25..4ffde60 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2010-10-12 Sheriff Bot <webkit.review.bot at gmail.com>
+
+ Unreviewed, rolling out r69639.
+ http://trac.webkit.org/changeset/69639
+ https://bugs.webkit.org/show_bug.cgi?id=47575
+
+ "regressed nav-element.html" (Requested by rniwa on #webkit).
+
+ * editing/execCommand/format-block-expected.txt:
+ * editing/execCommand/format-block-from-range-selection-expected.txt:
+ * editing/execCommand/format-block-multiple-paragraphs-expected.txt: Removed.
+ * editing/execCommand/format-block-multiple-paragraphs.html: Removed.
+ * editing/execCommand/format-block-table-expected.txt: Removed.
+ * editing/execCommand/format-block-table.html: Removed.
+ * editing/execCommand/format-block-with-braces-expected.txt:
+
2010-10-12 Ryosuke Niwa <rniwa at webkit.org>
Reviewed by Tony Chang.
diff --git a/LayoutTests/editing/execCommand/format-block-expected.txt b/LayoutTests/editing/execCommand/format-block-expected.txt
index 03f0262..9b21c11 100644
--- a/LayoutTests/editing/execCommand/format-block-expected.txt
+++ b/LayoutTests/editing/execCommand/format-block-expected.txt
@@ -52,6 +52,7 @@ After FormatBlock:
"
| <pre>
| "Make Pre"
+| <br>
| "
"
| <br>
@@ -61,9 +62,8 @@ After FormatBlock:
| "Foo"
| <br>
| <h1>
-| <span>
-| id="item2"
-| "Make h1"
+| "Make h1"
+| <br>
| "baz"
| "
"
diff --git a/LayoutTests/editing/execCommand/format-block-from-range-selection-expected.txt b/LayoutTests/editing/execCommand/format-block-from-range-selection-expected.txt
index aa68510..f8d91ac 100644
--- a/LayoutTests/editing/execCommand/format-block-from-range-selection-expected.txt
+++ b/LayoutTests/editing/execCommand/format-block-from-range-selection-expected.txt
@@ -32,23 +32,22 @@ after FormatBlock:
"
| <dl>
| "Fo<#selection-anchor>o"
-| <br>
-| "bar"
-| <br>
-| <span>
-| "baz"
-| <br>
-| "raz"
-| <br>
-| "
-dar"
-| <br>
-| "
-"
-| "yar<#selection-focus>"
| "
"
+| <div>
+| <dl>
+| "bar"
+| <span>
+| <dl>
+| "baz"
+| <dl>
+| "raz"
+| <dl>
+| "dar"
+| " "
| "
"
+| <dl>
+| "ya<#selection-focus>r"
| "
"
diff --git a/LayoutTests/editing/execCommand/format-block-multiple-paragraphs-expected.txt b/LayoutTests/editing/execCommand/format-block-multiple-paragraphs-expected.txt
deleted file mode 100644
index a524cc8..0000000
--- a/LayoutTests/editing/execCommand/format-block-multiple-paragraphs-expected.txt
+++ /dev/null
@@ -1,233 +0,0 @@
-This tests ensures formatBlock do not make multiple elements when formatting multiple paragraphs.
-
-Formatting:
-| "
-"
-| <div>
-| "<#selection-anchor>hello"
-| <div>
-| "world"
-| <div>
-| "WebKit<#selection-focus>"
-| "
-"
-
-by p yields:
-| "
-"
-| <p>
-| "<#selection-anchor>hello"
-| <br>
-| "world"
-| <br>
-| "WebKit<#selection-focus>"
-| "
-"
-
-Formatting:
-| "
-"
-| <p>
-| "<#selection-anchor>hello"
-| <p>
-| "world<#selection-focus>"
-| "
-"
-
-by blockquote yields:
-| "
-"
-| <blockquote>
-| "<#selection-anchor>hello"
-| <br>
-| "world<#selection-focus>"
-| "
-"
-
-Formatting:
-| "
-"
-| <div>
-| "<#selection-anchor>hello"
-| <pre>
-| "world<#selection-focus>"
-| "
-"
-
-by p yields:
-| "
-"
-| <div>
-| <p>
-| "<#selection-anchor>hello"
-| <br>
-| "world<#selection-focus>"
-| "
-"
-
-Formatting:
-| "
-"
-| <h1>
-| "<#selection-anchor>hello"
-| <div>
-| <h2>
-| "world"
-| <h3>
-| "WebKit<#selection-focus>"
-| "
-"
-
-by pre yields:
-| "
-"
-| <pre>
-| "<#selection-anchor>hello"
-| <br>
-| "world"
-| <br>
-| "WebKit<#selection-focus>"
-| "
-"
-
-Formatting:
-| "
-"
-| <div>
-| "hello"
-| <p>
-| "<#selection-anchor>world"
-| "webki<#selection-focus>t"
-| "
-"
-
-by h1 yields:
-| "
-"
-| <div>
-| "hello"
-| <h1>
-| "<#selection-anchor>world"
-| <br>
-| "webkit<#selection-focus>"
-| "
-"
-
-Formatting:
-| "
-"
-| <pre>
-| "<#selection-anchor>hello
-world<#selection-focus>
-webkit
-"
-| "
-"
-
-by blockquote yields:
-| "
-"
-| <pre>
-| <blockquote>
-| "<#selection-anchor>hello"
-| <br>
-| "world<#selection-focus>"
-| <br>
-| "webkit"
-| "
-"
-
-Formatting:
-| "
-"
-| <pre>
-| "hello
-<#selection-anchor>world
-webki<#selection-focus>t
-"
-| "
-"
-
-by blockquote yields:
-| "
-"
-| <pre>
-| "hello
-"
-| <blockquote>
-| "<#selection-anchor>world"
-| <br>
-| "webki<#selection-focus>t"
-| "
-"
-
-Formatting:
-| "
-<#selection-anchor>hello"
-| <p>
-| "world<#selection-focus>"
-| <p>
-| "webkit"
-| "
-
-"
-
-by pre yields:
-| <pre>
-| "<#selection-anchor>
-hello"
-| <br>
-| "worl<#selection-focus>d"
-| <p>
-| "webkit"
-| "
-
-"
-
-Formatting:
-| "
-"
-| <div>
-| "hello"
-| <div>
-| "<#selection-anchor>world"
-| <div>
-| "webki<#selection-focus>t"
-| "
-"
-
-by pre yields:
-| "
-"
-| <div>
-| "hello"
-| <pre>
-| "<#selection-anchor>world"
-| <br>
-| "webki<#selection-focus>t"
-| "
-"
-
-Formatting:
-| "
-"
-| <ul>
-| <li>
-| "<#selection-anchor>hello"
-| <li>
-| "world<#selection-focus>"
-| "
-"
-
-by blockquote yields:
-| "
-"
-| <blockquote>
-| <ul>
-| <li>
-| "<#selection-anchor>hello"
-| <ul>
-| <li>
-| "world<#selection-focus>"
-| "
-"
diff --git a/LayoutTests/editing/execCommand/format-block-multiple-paragraphs.html b/LayoutTests/editing/execCommand/format-block-multiple-paragraphs.html
deleted file mode 100644
index dc41425..0000000
--- a/LayoutTests/editing/execCommand/format-block-multiple-paragraphs.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<script src="../../resources/dump-as-markup.js"></script>
-<div id="test0" contenteditable>
-<div>hello</div><div>world</div><div>WebKit</div>
-</div>
-<div id="test1" contenteditable>
-<p>hello</p><p>world</p>
-</div>
-<div id="test2" contenteditable>
-<div>hello<pre>world</pre></div>
-</div>
-<div id="test3" contenteditable>
-<h1>hello</h1><div><h2>world</h2><h3>WebKit</h3></div>
-</div>
-<div id="test4" contenteditable>
-<div>hello<p>world</p>webkit</div>
-</div>
-<div id="test5" contenteditable>
-<pre>hello
-world
-webkit
-</pre>
-</div>
-<div id="test6" contenteditable>
-<pre>hello
-world
-webkit
-</pre>
-</div>
-<div id="test7" contenteditable>
-hello<p>world</p><p>webkit</p>
-</pre>
-</div>
-<div id="test8" contenteditable>
-<div>hello</div><div>world</div><div>webkit</div>
-</div>
-<div id="test9" contenteditable>
-<ul><li>hello</li><li>world</li></ul>
-</div>
-<script>
-
-Markup.description('This tests ensures formatBlock do not make multiple elements when formatting multiple paragraphs.')
-
-function testIndentation(containerId, selector, value) {
- var container = document.getElementById(containerId);
- selector(container);
- Markup.dump(container, 'Formatting');
- document.execCommand('FormatBlock', false, value);
- Markup.dump(container, 'by ' + value + ' yields');
-}
-
-function selectAll(container) {
- window.getSelection().selectAllChildren(container);
-}
-
-function selectorForLines(first, last) {
- return function (container) {
- window.getSelection().setPosition(container, 0);
- for (var i = 0; i < first - 1; i++)
- window.getSelection().modify('move', 'forward', 'line');
- for (var i = 0; i < Math.abs(last - first, 0) + 1; i++)
- window.getSelection().modify('extend', 'forward', 'line');
- window.getSelection().modify('extend', 'backward', 'character');
- }
-}
-
-testIndentation('test0', selectAll, 'p');
-testIndentation('test1', selectAll, 'blockquote');
-testIndentation('test2', selectAll, 'p');
-testIndentation('test3', selectAll, 'pre');
-testIndentation('test4', selectorForLines(2, 3), 'h1');
-testIndentation('test5', selectorForLines(1, 2), 'blockquote');
-testIndentation('test6', selectorForLines(2, 3), 'blockquote');
-testIndentation('test7', selectorForLines(1, 2), 'pre');
-testIndentation('test8', selectorForLines(2, 3), 'pre');
-testIndentation('test9', selectAll, 'blockquote');
-
-</script>
-</body>
-</html>
diff --git a/LayoutTests/editing/execCommand/format-block-table-expected.txt b/LayoutTests/editing/execCommand/format-block-table-expected.txt
deleted file mode 100644
index 7f6ddde..0000000
--- a/LayoutTests/editing/execCommand/format-block-table-expected.txt
+++ /dev/null
@@ -1,124 +0,0 @@
-
-Formatting:
-| "
-"
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| "hello"
-| <td>
-| "world"
-| "
-"
-
-by p yields:
-| "
-"
-| <p>
-| <#selection-anchor>
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| "hello"
-| <td>
-| "world"
-| <#selection-focus>
-| "
-"
-
-Formatting:
-| "
-"
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| "<#selection-anchor>hello<#selection-focus>"
-| <td>
-| "world"
-| "
-"
-
-by blockquote yields:
-| "
-"
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| <blockquote>
-| "<#selection-anchor>hello<#selection-focus>"
-| <td>
-| "world"
-| "
-"
-
-Formatting:
-| "
-"
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| <p>
-| "<#selection-anchor>hello"
-| <div>
-| "world<#selection-focus>"
-| <td>
-| "WebKit"
-| "
-"
-
-by h3 yields:
-| "
-"
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| <h3>
-| "<#selection-anchor>hello"
-| <br>
-| "world<#selection-focus>"
-| <td>
-| "WebKit"
-| "
-"
-
-Formatting:
-| "
-"
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| <ul>
-| <li>
-| "<#selection-anchor>hello"
-| <li>
-| "world<#selection-focus>"
-| <td>
-| "WebKit"
-| "
-"
-
-by address yields:
-| "
-"
-| <table>
-| <tbody>
-| <tr>
-| <td>
-| <address>
-| <ul>
-| <li>
-| "<#selection-anchor>hello"
-| <ul>
-| <li>
-| "world<#selection-focus>"
-| <td>
-| "WebKit"
-| "
-"
diff --git a/LayoutTests/editing/execCommand/format-block-table.html b/LayoutTests/editing/execCommand/format-block-table.html
deleted file mode 100644
index 28ba100..0000000
--- a/LayoutTests/editing/execCommand/format-block-table.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<script src="../../resources/dump-as-markup.js"></script>
-<div id="test0" contenteditable>
-<table><tr><td>hello</td><td>world</td></tr></table>
-</div>
-<div id="test1" contenteditable>
-<table><tr><td>hello</td><td>world</td></tr></table>
-</div>
-<div id="test2" contenteditable>
-<table><tr><td><p>hello</p><div>world</div></td><td>WebKit</td></tr></table>
-</div>
-<div id="test3" contenteditable>
-<table><tr><td><ul><li>hello</li><li>world</li></ul></td><td>WebKit</td></tr></table>
-</div>
-<script>
-
-function testIndentation(containerId, selector, value) {
- var container = document.getElementById(containerId);
- selector(container);
- Markup.dump(container, 'Formatting');
- document.execCommand('FormatBlock', false, value);
- Markup.dump(container, 'by ' + value + ' yields');
-}
-
-function selectAll(container) {
- window.getSelection().selectAllChildren(container);
-}
-
-function selectFirstCell(container) {
- window.getSelection().selectAllChildren(container.getElementsByTagName('td')[0]);
-}
-
-testIndentation('test0', selectAll, 'p');
-testIndentation('test1', selectFirstCell, 'blockquote');
-testIndentation('test2', selectFirstCell, 'h3');
-testIndentation('test3', selectFirstCell, 'address');
-
-</script>
-</body>
-</html>
diff --git a/LayoutTests/editing/execCommand/format-block-with-braces-expected.txt b/LayoutTests/editing/execCommand/format-block-with-braces-expected.txt
index 2b5b4dc..89b4435 100644
--- a/LayoutTests/editing/execCommand/format-block-with-braces-expected.txt
+++ b/LayoutTests/editing/execCommand/format-block-with-braces-expected.txt
@@ -16,6 +16,5 @@ Format Me
After FormatBlock with <h1>:
| <h1>
-| "
-<#selection-caret>Format Me
-"
+| "<#selection-caret>Format Me"
+| <br>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index aa59290..ff92e3d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-10-12 Sheriff Bot <webkit.review.bot at gmail.com>
+
+ Unreviewed, rolling out r69639.
+ http://trac.webkit.org/changeset/69639
+ https://bugs.webkit.org/show_bug.cgi?id=47575
+
+ "regressed nav-element.html" (Requested by rniwa on #webkit).
+
+ * editing/ApplyBlockElementCommand.cpp:
+ (WebCore::ApplyBlockElementCommand::formatSelection):
+ * editing/EditorCommand.cpp:
+ (WebCore::executeFormatBlock):
+ * editing/FormatBlockCommand.cpp:
+ (WebCore::FormatBlockCommand::formatRange):
+ * editing/FormatBlockCommand.h:
+ (WebCore::FormatBlockCommand::editingAction):
+ * editing/VisiblePosition.cpp:
+ (WebCore::enclosingBlockFlowElement):
+ * editing/VisiblePosition.h:
+ * editing/htmlediting.cpp:
+ (WebCore::validBlockTag):
+ * editing/htmlediting.h:
+
2010-10-12 Ryosuke Niwa <rniwa at webkit.org>
Reviewed by Tony Chang.
diff --git a/WebCore/editing/ApplyBlockElementCommand.cpp b/WebCore/editing/ApplyBlockElementCommand.cpp
index ecd3d9b..d810555 100644
--- a/WebCore/editing/ApplyBlockElementCommand.cpp
+++ b/WebCore/editing/ApplyBlockElementCommand.cpp
@@ -112,8 +112,10 @@ void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel
VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection);
bool atEnd = false;
- Position end;
while (endOfCurrentParagraph != endAfterSelection && !atEnd) {
+ Position start;
+ Position end;
+
if (endOfCurrentParagraph == endOfLastParagraph)
atEnd = true;
diff --git a/WebCore/editing/EditorCommand.cpp b/WebCore/editing/EditorCommand.cpp
index a8a23fb..a7a5af5 100644
--- a/WebCore/editing/EditorCommand.cpp
+++ b/WebCore/editing/EditorCommand.cpp
@@ -432,6 +432,8 @@ static bool executeFormatBlock(Frame* frame, Event*, EditorCommandSource, const
String tagName = value.lower();
if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
tagName = tagName.substring(1, tagName.length() - 2);
+ if (!validBlockTag(tagName))
+ return false;
ExceptionCode ec;
String localName, prefix;
@@ -439,9 +441,6 @@ static bool executeFormatBlock(Frame* frame, Event*, EditorCommandSource, const
return false;
QualifiedName qualifiedTagName(prefix, localName, xhtmlNamespaceURI);
- if (!FormatBlockCommand::isElementToApplyInFormatBlockCommand(qualifiedTagName))
- return false;
-
applyCommand(FormatBlockCommand::create(frame->document(), qualifiedTagName));
return true;
}
diff --git a/WebCore/editing/FormatBlockCommand.cpp b/WebCore/editing/FormatBlockCommand.cpp
index bc48f18..c4e81e2 100644
--- a/WebCore/editing/FormatBlockCommand.cpp
+++ b/WebCore/editing/FormatBlockCommand.cpp
@@ -36,91 +36,46 @@ namespace WebCore {
using namespace HTMLNames;
-static Node* enclosingBlockToSplitTreeTo(Node* startNode);
-
FormatBlockCommand::FormatBlockCommand(Document* document, const QualifiedName& tagName)
: ApplyBlockElementCommand(document, tagName)
{
}
-void FormatBlockCommand::formatRange(const Position& start, const Position& end, RefPtr<Element>& blockNode)
+void FormatBlockCommand::formatRange(const Position&, const Position& end, RefPtr<Element>&)
{
- Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.node());
- RefPtr<Node> outerBlock = (start.node() == nodeToSplitTo) ? start.node() : splitTreeToNode(start.node(), nodeToSplitTo);
- RefPtr<Node> nodeAfterInsertionPosition = outerBlock;
-
- Element* refNode = enclosingBlockFlowElement(end);
- Element* root = editableRootForPosition(start);
- if (isElementToApplyInFormatBlockCommand(refNode->tagQName()) && start == startOfBlock(start) && end == endOfBlock(end)
- && refNode != root && !root->isDescendantOf(refNode)) {
- // Already in a block element that only contains the current paragraph
- if (refNode->hasTagName(tagName()))
- return;
- nodeAfterInsertionPosition = refNode;
- }
-
- if (!blockNode) {
- // Create a new blockquote and insert it as a child of the root editable element. We accomplish
- // this by splitting all parents of the current paragraph up to that point.
- blockNode = createBlockElement();
- insertNodeBefore(blockNode, nodeAfterInsertionPosition);
- }
+ setEndingSelection(VisiblePosition(end));
- Position lastParagraphInBlockNode = lastPositionInNode(blockNode.get());
- bool wasEndOfParagraph = isEndOfParagraph(lastParagraphInBlockNode);
+ Node* refNode = enclosingBlockFlowElement(endingSelection().visibleStart());
+ if (refNode->hasTagName(tagName()))
+ // We're already in a block with the format we want, so we don't have to do anything
+ return;
- moveParagraphWithClones(start, end, blockNode.get(), outerBlock.get());
+ VisiblePosition paragraphStart = startOfParagraph(end);
+ VisiblePosition paragraphEnd = endOfParagraph(end);
+ VisiblePosition blockStart = startOfBlock(endingSelection().visibleStart());
+ VisiblePosition blockEnd = endOfBlock(endingSelection().visibleStart());
+ RefPtr<Element> blockNode = createBlockElement();
+ RefPtr<Element> placeholder = createBreakElement(document());
- if (wasEndOfParagraph && !isEndOfParagraph(lastParagraphInBlockNode) && !isStartOfParagraph(lastParagraphInBlockNode))
- insertBlockPlaceholder(lastParagraphInBlockNode);
-}
-
-// FIXME: We should consider mering this function with isElementForFormatBlockCommand in Editor.cpp
-// Checks if a tag name is valid for execCommand('FormatBlock').
-bool FormatBlockCommand::isElementToApplyInFormatBlockCommand(const QualifiedName& tagName)
-{
- DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, blockTags, ());
- if (blockTags.isEmpty()) {
- blockTags.add(addressTag);
- blockTags.add(articleTag);
- blockTags.add(asideTag);
- blockTags.add(blockquoteTag);
- blockTags.add(ddTag);
- blockTags.add(divTag);
- blockTags.add(dlTag);
- blockTags.add(dtTag);
- blockTags.add(footerTag);
- blockTags.add(h1Tag);
- blockTags.add(h2Tag);
- blockTags.add(h3Tag);
- blockTags.add(h4Tag);
- blockTags.add(h5Tag);
- blockTags.add(h6Tag);
- blockTags.add(headerTag);
- blockTags.add(hgroupTag);
- blockTags.add(navTag);
- blockTags.add(pTag);
- blockTags.add(preTag);
- blockTags.add(sectionTag);
+ Node* root = endingSelection().start().node()->rootEditableElement();
+ if (validBlockTag(refNode->nodeName().lower()) &&
+ paragraphStart == blockStart && paragraphEnd == blockEnd &&
+ refNode != root && !root->isDescendantOf(refNode))
+ // Already in a valid block tag that only contains the current paragraph, so we can swap with the new tag
+ insertNodeBefore(blockNode, refNode);
+ else {
+ // Avoid inserting inside inline elements that surround paragraphStart with upstream().
+ // This is only to avoid creating bloated markup.
+ insertNodeAt(blockNode, paragraphStart.deepEquivalent().upstream());
}
- return blockTags.contains(tagName);
-}
+ appendNode(placeholder, blockNode);
-Node* enclosingBlockToSplitTreeTo(Node* startNode)
-{
- Node* lastBlock = startNode;
- for (Node* n = startNode; n; n = n->parentNode()) {
- if (!n->isContentEditable())
- return lastBlock;
- if (isTableCell(n) || n->hasTagName(bodyTag) || !n->parentNode() || !n->parentNode()->isContentEditable()
- || (n->isElementNode() && FormatBlockCommand::isElementToApplyInFormatBlockCommand(static_cast<Element*>(n)->tagQName())))
- return n;
- if (isBlock(n))
- lastBlock = n;
- if (isListElement(n))
- return n->parentNode()->isContentEditable() ? n->parentNode() : n;
+ VisiblePosition destination(Position(placeholder.get(), 0));
+ if (paragraphStart == paragraphEnd && !lineBreakExistsAtVisiblePosition(paragraphStart)) {
+ setEndingSelection(destination);
+ return;
}
- return lastBlock;
+ moveParagraph(paragraphStart, paragraphEnd, destination, true, false);
}
}
diff --git a/WebCore/editing/FormatBlockCommand.h b/WebCore/editing/FormatBlockCommand.h
index 68a1f47..5e9cb96 100644
--- a/WebCore/editing/FormatBlockCommand.h
+++ b/WebCore/editing/FormatBlockCommand.h
@@ -38,13 +38,11 @@ public:
return adoptRef(new FormatBlockCommand(document, tagName));
}
- static bool isElementToApplyInFormatBlockCommand(const QualifiedName& tagName);
-
private:
FormatBlockCommand(Document*, const QualifiedName& tagName);
- void formatRange(const Position&, const Position&, RefPtr<Element>&);
- EditAction editingAction() const { return EditActionFormatBlock; }
+ virtual void formatRange(const Position&, const Position&, RefPtr<Element>&);
+ virtual EditAction editingAction() const { return EditActionFormatBlock; }
};
} // namespace WebCore
diff --git a/WebCore/editing/VisiblePosition.cpp b/WebCore/editing/VisiblePosition.cpp
index 760c68c..1e68538 100644
--- a/WebCore/editing/VisiblePosition.cpp
+++ b/WebCore/editing/VisiblePosition.cpp
@@ -634,7 +634,7 @@ bool setEnd(Range *r, const VisiblePosition &visiblePosition)
return code == 0;
}
-Element* enclosingBlockFlowElement(const VisiblePosition &visiblePosition)
+Node *enclosingBlockFlowElement(const VisiblePosition &visiblePosition)
{
if (visiblePosition.isNull())
return NULL;
diff --git a/WebCore/editing/VisiblePosition.h b/WebCore/editing/VisiblePosition.h
index e649b68..fe795a1 100644
--- a/WebCore/editing/VisiblePosition.h
+++ b/WebCore/editing/VisiblePosition.h
@@ -136,7 +136,7 @@ bool setEnd(Range*, const VisiblePosition&);
VisiblePosition startVisiblePosition(const Range*, EAffinity);
VisiblePosition endVisiblePosition(const Range*, EAffinity);
-Element* enclosingBlockFlowElement(const VisiblePosition&);
+Node *enclosingBlockFlowElement(const VisiblePosition&);
bool isFirstVisiblePositionInNode(const VisiblePosition&, const Node*);
bool isLastVisiblePositionInNode(const VisiblePosition&, const Node*);
diff --git a/WebCore/editing/htmlediting.cpp b/WebCore/editing/htmlediting.cpp
index 7927900..9ec71e7 100644
--- a/WebCore/editing/htmlediting.cpp
+++ b/WebCore/editing/htmlediting.cpp
@@ -465,6 +465,39 @@ bool isSpecialElement(const Node *n)
return false;
}
+// Checks if a string is a valid tag for the FormatBlockCommand function of execCommand. Expects lower case strings.
+bool validBlockTag(const AtomicString& blockTag)
+{
+ if (blockTag.isEmpty())
+ return false;
+
+ DEFINE_STATIC_LOCAL(HashSet<AtomicString>, blockTags, ());
+ if (blockTags.isEmpty()) {
+ blockTags.add(addressTag.localName());
+ blockTags.add(articleTag.localName());
+ blockTags.add(asideTag.localName());
+ blockTags.add(blockquoteTag.localName());
+ blockTags.add(ddTag.localName());
+ blockTags.add(divTag.localName());
+ blockTags.add(dlTag.localName());
+ blockTags.add(dtTag.localName());
+ blockTags.add(footerTag.localName());
+ blockTags.add(h1Tag.localName());
+ blockTags.add(h2Tag.localName());
+ blockTags.add(h3Tag.localName());
+ blockTags.add(h4Tag.localName());
+ blockTags.add(h5Tag.localName());
+ blockTags.add(h6Tag.localName());
+ blockTags.add(headerTag.localName());
+ blockTags.add(hgroupTag.localName());
+ blockTags.add(navTag.localName());
+ blockTags.add(pTag.localName());
+ blockTags.add(preTag.localName());
+ blockTags.add(sectionTag.localName());
+ }
+ return blockTags.contains(blockTag);
+}
+
static Node* firstInSpecialElement(const Position& pos)
{
// FIXME: This begins at pos.node(), which doesn't necessarily contain pos (suppose pos was [img, 0]). See <rdar://problem/5027702>.
diff --git a/WebCore/editing/htmlediting.h b/WebCore/editing/htmlediting.h
index 1892357..aaf6ef2 100644
--- a/WebCore/editing/htmlediting.h
+++ b/WebCore/editing/htmlediting.h
@@ -228,6 +228,8 @@ VisibleSelection selectionForParagraphIteration(const VisibleSelection&);
String stringWithRebalancedWhitespace(const String&, bool, bool);
const String& nonBreakingSpaceString();
+bool validBlockTag(const AtomicString&);
+
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list