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

Unified Diff: Source/core/dom/Range.cpp

Issue 560333002: Avoid more temporary ranges in connection with various TextIterators. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix mac build. Created 6 years, 3 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 | « Source/core/dom/Range.h ('k') | Source/core/editing/PlainTextRange.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Range.cpp
diff --git a/Source/core/dom/Range.cpp b/Source/core/dom/Range.cpp
index 3e47af202657e94d52076859a519eb121f93ed88..cbae14b603c1734340bca934649856128d782046 100644
--- a/Source/core/dom/Range.cpp
+++ b/Source/core/dom/Range.cpp
@@ -1228,18 +1228,18 @@ void Range::selectNodeContents(Node* refNode, ExceptionState& exceptionState)
// or DocumentType node.
for (Node* n = refNode; n; n = n->parentNode()) {
switch (n->nodeType()) {
- case Node::ATTRIBUTE_NODE:
- case Node::CDATA_SECTION_NODE:
- case Node::COMMENT_NODE:
- case Node::DOCUMENT_FRAGMENT_NODE:
- case Node::DOCUMENT_NODE:
- case Node::ELEMENT_NODE:
- case Node::PROCESSING_INSTRUCTION_NODE:
- case Node::TEXT_NODE:
- break;
- case Node::DOCUMENT_TYPE_NODE:
- exceptionState.throwDOMException(InvalidNodeTypeError, "The node provided is of type '" + refNode->nodeName() + "'.");
- return;
+ case Node::ATTRIBUTE_NODE:
+ case Node::CDATA_SECTION_NODE:
+ case Node::COMMENT_NODE:
+ case Node::DOCUMENT_FRAGMENT_NODE:
+ case Node::DOCUMENT_NODE:
+ case Node::ELEMENT_NODE:
+ case Node::PROCESSING_INSTRUCTION_NODE:
+ case Node::TEXT_NODE:
+ break;
+ case Node::DOCUMENT_TYPE_NODE:
+ exceptionState.throwDOMException(InvalidNodeTypeError, "The node provided is of type '" + refNode->nodeName() + "'.");
+ return;
}
}
@@ -1250,6 +1250,37 @@ void Range::selectNodeContents(Node* refNode, ExceptionState& exceptionState)
m_end.setToEndOfNode(*refNode);
}
+bool Range::selectNodeContents(Node* refNode, Position& start, Position& end)
+{
+ if (!refNode) {
+ return false;
+ }
+
+ for (Node* n = refNode; n; n = n->parentNode()) {
+ switch (n->nodeType()) {
+ case Node::ATTRIBUTE_NODE:
+ case Node::CDATA_SECTION_NODE:
+ case Node::COMMENT_NODE:
+ case Node::DOCUMENT_FRAGMENT_NODE:
+ case Node::DOCUMENT_NODE:
+ case Node::ELEMENT_NODE:
+ case Node::PROCESSING_INSTRUCTION_NODE:
+ case Node::TEXT_NODE:
+ break;
+ case Node::DOCUMENT_TYPE_NODE:
+ return false;
+ }
+ }
+
+ RangeBoundaryPoint startBoundaryPoint(refNode);
+ startBoundaryPoint.setToStartOfNode(*refNode);
+ start = startBoundaryPoint.toPosition();
+ RangeBoundaryPoint endBoundaryPoint(refNode);
+ endBoundaryPoint.setToEndOfNode(*refNode);
+ end = endBoundaryPoint.toPosition();
+ return true;
+}
+
void Range::surroundContents(PassRefPtrWillBeRawPtr<Node> passNewParent, ExceptionState& exceptionState)
{
RefPtrWillBeRawPtr<Node> newParent = passNewParent;
« no previous file with comments | « Source/core/dom/Range.h ('k') | Source/core/editing/PlainTextRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698