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

Side by Side Diff: Source/core/dom/Range.cpp

Issue 1363833002: Drop unnecessary ancestor traversal in Range::selectNode() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
5 * (C) 2001 Peter Kelly (pmk@post.com) 5 * (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 // FIXME: Generated bindings code never calls with null, and neither sho uld other callers! 1073 // FIXME: Generated bindings code never calls with null, and neither sho uld other callers!
1074 exceptionState.throwTypeError("The node provided is null."); 1074 exceptionState.throwTypeError("The node provided is null.");
1075 return; 1075 return;
1076 } 1076 }
1077 1077
1078 if (!refNode->parentNode()) { 1078 if (!refNode->parentNode()) {
1079 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h as no parent."); 1079 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h as no parent.");
1080 return; 1080 return;
1081 } 1081 }
1082 1082
1083 // InvalidNodeTypeError: Raised if an ancestor of refNode is an Entity, Nota tion or 1083 // INVALID_NODE_TYPE_ERR: Raised if refNode is a Document, DocumentFragment or Attr node.
sof 2015/09/23 10:01:39 InvalidNodeTypeError, not INVALID_NODE_TYPE_ERR, b
pals 2015/09/23 11:34:35 Done.
1084 // DocumentType node or if refNode is a Document, DocumentFragment, ShadowRo ot, Attr, Entity, or Notation
1085 // node.
1086 for (ContainerNode* anc = refNode->parentNode(); anc; anc = anc->parentNode( )) {
1087 switch (anc->nodeType()) {
1088 case Node::ATTRIBUTE_NODE:
1089 case Node::CDATA_SECTION_NODE:
1090 case Node::COMMENT_NODE:
1091 case Node::DOCUMENT_FRAGMENT_NODE:
1092 case Node::DOCUMENT_NODE:
1093 case Node::ELEMENT_NODE:
1094 case Node::PROCESSING_INSTRUCTION_NODE:
1095 case Node::TEXT_NODE:
1096 break;
1097 case Node::DOCUMENT_TYPE_NODE:
1098 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro vided has an ancestor of type '" + anc->nodeName() + "'.");
1099 return;
1100 }
1101 }
1102
1103 switch (refNode->nodeType()) { 1084 switch (refNode->nodeType()) {
1104 case Node::CDATA_SECTION_NODE: 1085 case Node::CDATA_SECTION_NODE:
1105 case Node::COMMENT_NODE: 1086 case Node::COMMENT_NODE:
1106 case Node::DOCUMENT_TYPE_NODE: 1087 case Node::DOCUMENT_TYPE_NODE:
1107 case Node::ELEMENT_NODE: 1088 case Node::ELEMENT_NODE:
1108 case Node::PROCESSING_INSTRUCTION_NODE: 1089 case Node::PROCESSING_INSTRUCTION_NODE:
1109 case Node::TEXT_NODE: 1090 case Node::TEXT_NODE:
1110 break; 1091 break;
1111 case Node::ATTRIBUTE_NODE: 1092 case Node::ATTRIBUTE_NODE:
1112 case Node::DOCUMENT_FRAGMENT_NODE: 1093 case Node::DOCUMENT_FRAGMENT_NODE:
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 { 1663 {
1683 if (range && range->boundaryPointsValid()) { 1664 if (range && range->boundaryPointsValid()) {
1684 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1665 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1685 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1666 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1686 } else { 1667 } else {
1687 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n"); 1668 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n");
1688 } 1669 }
1689 } 1670 }
1690 1671
1691 #endif 1672 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698