Changeset 150879 in webkit
- Timestamp:
- May 29, 2013 1:57:42 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150878 r150879 1 2013-05-29 Andreas Kling <akling@apple.com> 2 3 Move leaf Node traversal helpers to htmlediting.cpp 4 <http://webkit.org/b/116940> 5 6 Reviewed by Antti Koivisto. 7 8 Move Node::previousLeafNode() and Node::nextLeafNode() to htmlediting.cpp along with their helpers. 9 Fixes an 8-year old FIXME. \o/ 10 11 * dom/Node.h: 12 * dom/Node.cpp: 13 * dom/Position.cpp: 14 (WebCore::nextRenderedEditable): 15 (WebCore::previousRenderedEditable): 16 * editing/VisibleUnits.cpp: 17 (WebCore::previousLeafWithSameEditability): 18 (WebCore::nextLeafWithSameEditability): 19 * editing/htmlediting.h: 20 * editing/htmlediting.cpp: 21 (WebCore::previousNodeConsideringAtomicNodes): 22 (WebCore::nextNodeConsideringAtomicNodes): 23 (WebCore::previousLeafNode): 24 (WebCore::nextLeafNode): 25 1 26 2013-05-29 Peter Gal <galpeter@inf.u-szeged.hu> 2 27 -
trunk/Source/WebCore/dom/Node.cpp
r150805 r150879 1091 1091 } 1092 1092 1093 // FIXME: This code is used by editing. Seems like it could move over there and not pollute Node.1094 Node *Node::previousNodeConsideringAtomicNodes() const1095 {1096 if (previousSibling()) {1097 Node *n = previousSibling();1098 while (!isAtomicNode(n) && n->lastChild())1099 n = n->lastChild();1100 return n;1101 }1102 else if (parentNode()) {1103 return parentNode();1104 }1105 else {1106 return 0;1107 }1108 }1109 1110 Node *Node::nextNodeConsideringAtomicNodes() const1111 {1112 if (!isAtomicNode(this) && firstChild())1113 return firstChild();1114 if (nextSibling())1115 return nextSibling();1116 const Node *n = this;1117 while (n && !n->nextSibling())1118 n = n->parentNode();1119 if (n)1120 return n->nextSibling();1121 return 0;1122 }1123 1124 Node *Node::previousLeafNode() const1125 {1126 Node *node = previousNodeConsideringAtomicNodes();1127 while (node) {1128 if (isAtomicNode(node))1129 return node;1130 node = node->previousNodeConsideringAtomicNodes();1131 }1132 return 0;1133 }1134 1135 Node *Node::nextLeafNode() const1136 {1137 Node *node = nextNodeConsideringAtomicNodes();1138 while (node) {1139 if (isAtomicNode(node))1140 return node;1141 node = node->nextNodeConsideringAtomicNodes();1142 }1143 return 0;1144 }1145 1146 1093 ContainerNode* Node::parentNodeForRenderingAndStyle() 1147 1094 { -
trunk/Source/WebCore/dom/Node.h
r150805 r150879 310 310 virtual bool canContainRangeEndPoint() const { return false; } 311 311 312 // FIXME: These two functions belong in editing -- "atomic node" is an editing concept.313 Node* previousNodeConsideringAtomicNodes() const;314 Node* nextNodeConsideringAtomicNodes() const;315 316 // Returns the next leaf node or 0 if there are no more.317 // Delivers leaf nodes as if the whole DOM tree were a linear chain of its leaf nodes.318 // Uses an editing-specific concept of what a leaf node is, and should probably be moved319 // out of the Node class into an editing-specific source file.320 Node* nextLeafNode() const;321 322 // Returns the previous leaf node or 0 if there are no more.323 // Delivers leaf nodes as if the whole DOM tree were a linear chain of its leaf nodes.324 // Uses an editing-specific concept of what a leaf node is, and should probably be moved325 // out of the Node class into an editing-specific source file.326 Node* previousLeafNode() const;327 328 312 bool isRootEditableElement() const; 329 313 Element* rootEditableElement() const; -
trunk/Source/WebCore/dom/Position.cpp
r150782 r150879 52 52 static Node* nextRenderedEditable(Node* node) 53 53 { 54 while ((node = n ode->nextLeafNode())) {54 while ((node = nextLeafNode(node))) { 55 55 if (!node->rendererIsEditable()) 56 56 continue; … … 66 66 static Node* previousRenderedEditable(Node* node) 67 67 { 68 while ((node = node->previousLeafNode())) {68 while ((node = previousLeafNode(node))) { 69 69 if (!node->rendererIsEditable()) 70 70 continue; -
trunk/Source/WebCore/editing/VisibleUnits.cpp
r149583 r150879 52 52 { 53 53 bool editable = node->rendererIsEditable(editableType); 54 node = node->previousLeafNode();54 node = previousLeafNode(node); 55 55 while (node) { 56 56 if (editable == node->rendererIsEditable(editableType)) 57 57 return node; 58 node = node->previousLeafNode();58 node = previousLeafNode(node); 59 59 } 60 60 return 0; … … 67 67 68 68 bool editable = node->rendererIsEditable(editableType); 69 node = n ode->nextLeafNode();69 node = nextLeafNode(node); 70 70 while (node) { 71 71 if (editable == node->rendererIsEditable(editableType)) 72 72 return node; 73 node = n ode->nextLeafNode();73 node = nextLeafNode(node); 74 74 } 75 75 return 0; -
trunk/Source/WebCore/editing/htmlediting.cpp
r150782 r150879 803 803 } 804 804 805 static Node* previousNodeConsideringAtomicNodes(const Node* node) 806 { 807 if (node->previousSibling()) { 808 Node* n = node->previousSibling(); 809 while (!isAtomicNode(n) && n->lastChild()) 810 n = n->lastChild(); 811 return n; 812 } 813 if (node->parentNode()) 814 return node->parentNode(); 815 return 0; 816 } 817 818 static Node* nextNodeConsideringAtomicNodes(const Node* node) 819 { 820 if (!isAtomicNode(node) && node->firstChild()) 821 return node->firstChild(); 822 if (node->nextSibling()) 823 return node->nextSibling(); 824 const Node* n = node; 825 while (n && !n->nextSibling()) 826 n = n->parentNode(); 827 if (n) 828 return n->nextSibling(); 829 return 0; 830 } 831 832 Node* previousLeafNode(const Node* node) 833 { 834 Node* n = previousNodeConsideringAtomicNodes(node); 835 while (n) { 836 if (isAtomicNode(n)) 837 return n; 838 n = previousNodeConsideringAtomicNodes(n); 839 } 840 return 0; 841 } 842 843 Node* nextLeafNode(const Node* node) 844 { 845 Node* n = nextNodeConsideringAtomicNodes(node); 846 while (node) { 847 if (isAtomicNode(n)) 848 return n; 849 n = nextNodeConsideringAtomicNodes(n); 850 } 851 return 0; 852 } 853 805 854 // FIXME: do not require renderer, so that this can be used within fragments, or rename to isRenderedTable() 806 855 bool isTableElement(Node* n) -
trunk/Source/WebCore/editing/htmlediting.h
r150782 r150879 74 74 Node* isFirstPositionAfterTable(const VisiblePosition&); 75 75 76 // These two deliver leaf nodes as if the whole DOM tree were a linear chain of its leaf nodes. 77 Node* nextLeafNode(const Node*); 78 Node* previousLeafNode(const Node*); 79 76 80 // offset functions on Node 77 81
Note: See TracChangeset
for help on using the changeset viewer.