Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1105)

Unified Diff: third_party/WebKit/WebCore/editing/htmlediting.cpp

Issue 21184: WebKit merge 40722:40785 (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/WebCore/editing/TypingCommand.cpp ('k') | third_party/WebKit/WebCore/editing/markup.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/WebCore/editing/htmlediting.cpp
===================================================================
--- third_party/WebKit/WebCore/editing/htmlediting.cpp (revision 9391)
+++ third_party/WebKit/WebCore/editing/htmlediting.cpp (working copy)
@@ -309,27 +309,32 @@
return static_cast<Element*>(enclosingNodeOfType(Position(node, 0), isBlock));
}
+// Internally editing uses "invalid" positions for historical reasons. For
+// example, in <div><img /></div>, Editing might use (img, 1) for the position
+// after <img>, but we have to convert that to (div, 1) before handing the
+// position to a Range object. Ideally all internal positions should
+// be "range compliant" for simplicity.
Position rangeCompliantEquivalent(const Position& pos)
{
if (pos.isNull())
return Position();
- Node *node = pos.node();
-
+ Node* node = pos.node();
+
if (pos.offset() <= 0) {
if (node->parentNode() && (editingIgnoresContent(node) || isTableElement(node)))
return positionBeforeNode(node);
return Position(node, 0);
}
-
+
if (node->offsetInCharacters())
return Position(node, min(node->maxCharacterOffset(), pos.offset()));
-
+
int maxCompliantOffset = node->childNodeCount();
if (pos.offset() > maxCompliantOffset) {
if (node->parentNode())
return positionAfterNode(node);
-
+
// there is no other option at this point than to
// use the highest allowed position in the node
return Position(node, maxCompliantOffset);
« no previous file with comments | « third_party/WebKit/WebCore/editing/TypingCommand.cpp ('k') | third_party/WebKit/WebCore/editing/markup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698