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

Unified Diff: third_party/WebKit/Source/core/editing/DOMSelection.cpp

Issue 1756763002: 2016-03-02T18:53:01 LayoutPosition Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-25T19:02:18 Created 4 years, 8 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/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/editing/Editor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/DOMSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
index 7155e70ea780ae1e990f77b41c6aea6e7900229c..3f79f98bd83fda03b008b4e513b810520e6dc976 100644
--- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
@@ -288,6 +288,14 @@ void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent
if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode))
return;
+ // We check |DocumentTypeNode| here instead of |isValidForPosition()|,
+ // since, |collapse()| throws error for |DocumentTypeNode|, but
+ // |setBaseAndExtent()| doesn't.
+ if (baseNode && baseNode->isDocumentTypeNode())
+ return;
+ if (extentNode && extentNode->isDocumentTypeNode())
+ return;
+
VisiblePosition visibleBase = createVisiblePosition(createPosition(baseNode, baseOffset));
VisiblePosition visibleExtent = createVisiblePosition(createPosition(extentNode, extentOffset));
@@ -363,6 +371,12 @@ void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState
if (!isValidForPosition(node))
return;
+ // We check |DocumentTypeNode| here instead of |isValidForPosition()|,
+ // since, |collapse()| throws error for |DocumentTypeNode|, but
+ // |setBaseAndExtent()| doesn't.
+ if (node && node->isDocumentTypeNode())
+ return;
+
m_frame->selection().setExtent(createVisiblePosition(createPosition(node, offset)));
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/editing/Editor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698