Changeset 150782 in webkit
- Timestamp:
- May 27, 2013 4:40:38 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150778 r150782 1 2013-05-27 Darin Adler <darin@apple.com> 2 3 Move isBlockFlowElement and related functions out of the Node class into editing code 4 https://bugs.webkit.org/show_bug.cgi?id=116846 5 6 Reviewed by Antti Koivisto. 7 8 * dom/Node.cpp: Removed isBlockFlowElement, enclosingBlockFlowElement, and 9 inSameContainingBlockFlowElement. These are all editing functions that don't 10 belong in the Node class, and mostly-deprecated ones to boot. 11 * dom/Node.h: Ditto. 12 13 * dom/Position.cpp: 14 (WebCore::inSameEnclosingBlockFlowElement): Added. This editing-specific function 15 is used only here, so put it here. 16 (WebCore::Position::rendersInDifferentPosition): Updated to call new function above. 17 (WebCore::Position::leadingWhitespacePosition): Ditto. 18 19 * editing/InsertLineBreakCommand.cpp: 20 (WebCore::InsertLineBreakCommand::insertNodeAfterPosition): Use 21 deprecatedEnclosingBlockFlowElement at its new location. 22 (WebCore::InsertLineBreakCommand::insertNodeBeforePosition): Ditto. 23 24 * editing/InsertListCommand.cpp: 25 (WebCore::InsertListCommand::doApplyForSingleParagraph): use 26 isBlockFlowElement at its new location. 27 * editing/ReplaceSelectionCommand.cpp: 28 (WebCore::enclosingInline): Ditto. 29 30 * editing/VisiblePosition.cpp: 31 (WebCore::VisiblePosition::canonicalPosition): Use deprecatedEnclosingBlockFlowElement 32 at its new location. 33 (WebCore::enclosingBlockFlowElement): Ditto. Also added FIXME. 34 * editing/VisibleSelection.cpp: 35 (WebCore::makeSearchRange): Ditto. 36 37 * editing/htmlediting.cpp: 38 (WebCore::isBlockFlowElement): Added. Same as the Node::isBlockFlowElement 39 function, but here because this is an editing function, not suitable as a Node member. 40 (WebCore::deprecatedEnclosingBlockFlowElement): Ditto. Added "deprecated" to the name 41 since the Node member function had a comment saying it was deprecated. Also changed so 42 it tolerates a 0 for an argument, which made it easier for one caller. 43 44 * editing/htmlediting.h: Added the two new functions. 45 1 46 2013-05-27 Seokju Kwon <seokju.kwon@gmail.com> 2 47 -
trunk/Source/WebCore/dom/Node.cpp
r150722 r150782 1266 1266 } 1267 1267 1268 bool Node::isBlockFlowElement() const1269 {1270 return isElementNode() && renderer() && renderer()->isBlockFlow();1271 }1272 1273 Element *Node::enclosingBlockFlowElement() const1274 {1275 Node *n = const_cast<Node *>(this);1276 if (isBlockFlowElement())1277 return toElement(n);1278 1279 while (1) {1280 n = n->parentNode();1281 if (!n)1282 break;1283 if (n->isBlockFlowElement() || n->hasTagName(bodyTag))1284 return toElement(n);1285 }1286 return 0;1287 }1288 1289 1268 bool Node::isRootEditableElement() const 1290 1269 { … … 1313 1292 } 1314 1293 return result; 1315 }1316 1317 bool Node::inSameContainingBlockFlowElement(Node *n)1318 {1319 return n ? enclosingBlockFlowElement() == n->enclosingBlockFlowElement() : false;1320 1294 } 1321 1295 -
trunk/Source/WebCore/dom/Node.h
r150722 r150782 305 305 Node* enclosingLinkEventParentOrSelf(); 306 306 307 bool isBlockFlowElement() const;308 309 307 // These low-level calls give the caller responsibility for maintaining the integrity of the tree. 310 308 void setPreviousSibling(Node* previous) { m_previous = previous; } … … 329 327 Node* previousLeafNode() const; 330 328 331 // enclosingBlockFlowElement() is deprecated. Use enclosingBlock instead.332 Element* enclosingBlockFlowElement() const;333 334 329 bool isRootEditableElement() const; 335 330 Element* rootEditableElement() const; 336 331 Element* rootEditableElement(EditableType) const; 337 338 bool inSameContainingBlockFlowElement(Node*);339 332 340 333 // Called by the parser when this element's close tag is reached, -
trunk/Source/WebCore/dom/Position.cpp
r145818 r150782 994 994 } 995 995 996 static bool inSameEnclosingBlockFlowElement(Node* a, Node* b) 997 { 998 return a && b && deprecatedEnclosingBlockFlowElement(a) == deprecatedEnclosingBlockFlowElement(b); 999 } 1000 996 1001 bool Position::rendersInDifferentPosition(const Position &pos) const 997 1002 { … … 1030 1035 return true; 1031 1036 1032 if ( deprecatedNode()->enclosingBlockFlowElement() != pos.deprecatedNode()->enclosingBlockFlowElement())1037 if (!inSameEnclosingBlockFlowElement(deprecatedNode(), pos.deprecatedNode())) 1033 1038 return true; 1034 1039 … … 1091 1096 1092 1097 Position prev = previousCharacterPosition(affinity); 1093 if (prev != *this && prev.deprecatedNode()->inSameContainingBlockFlowElement(deprecatedNode()) && prev.deprecatedNode()->isTextNode()) {1098 if (prev != *this && inSameEnclosingBlockFlowElement(deprecatedNode(), prev.deprecatedNode()) && prev.deprecatedNode()->isTextNode()) { 1094 1099 String string = toText(prev.deprecatedNode())->data(); 1095 1100 UChar c = string[prev.deprecatedEditingOffset()]; -
trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp
r148545 r150782 59 59 // position is a block, do an append. We don't want to insert 60 60 // the BR *after* the block. 61 Element* cb = pos.deprecatedNode()->enclosingBlockFlowElement();61 Element* cb = deprecatedEnclosingBlockFlowElement(pos.deprecatedNode()); 62 62 if (cb == pos.deprecatedNode()) 63 63 appendNode(node, cb); … … 71 71 // position is a block, do an append. We don't want to insert 72 72 // the BR *before* the block. 73 Element* cb = pos.deprecatedNode()->enclosingBlockFlowElement();73 Element* cb = deprecatedEnclosingBlockFlowElement(pos.deprecatedNode()); 74 74 if (cb == pos.deprecatedNode()) 75 75 appendNode(node, cb); -
trunk/Source/WebCore/editing/InsertListCommand.cpp
r147388 r150782 220 220 221 221 Node* firstChildInList = enclosingListChild(VisiblePosition(firstPositionInNode(listNode.get())).deepEquivalent().deprecatedNode(), listNode.get()); 222 Node* outerBlock = firstChildInList->isBlockFlowElement() ? firstChildInList : listNode.get();222 Node* outerBlock = isBlockFlowElement(firstChildInList) ? firstChildInList : listNode.get(); 223 223 224 224 moveParagraphWithClones(firstPositionInNode(listNode.get()), lastPositionInNode(listNode.get()), newList.get(), outerBlock); -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r148251 r150782 843 843 { 844 844 while (ContainerNode* parent = node->parentNode()) { 845 if ( parent->isBlockFlowElement() || parent->hasTagName(bodyTag))845 if (isBlockFlowElement(parent) || parent->hasTagName(bodyTag)) 846 846 return node; 847 847 // Stop if any previous sibling is a block. 848 848 for (Node* sibling = node->previousSibling(); sibling; sibling = sibling->previousSibling()) { 849 if ( sibling->isBlockFlowElement())849 if (isBlockFlowElement(sibling)) 850 850 return node; 851 851 } -
trunk/Source/WebCore/editing/VisiblePosition.cpp
r144911 r150782 559 559 560 560 // The new position should be in the same block flow element. Favor that. 561 Node* originalBlock = node ? node->enclosingBlockFlowElement() : 0;561 Element* originalBlock = deprecatedEnclosingBlockFlowElement(node); 562 562 bool nextIsOutsideOriginalBlock = !nextNode->isDescendantOf(originalBlock) && nextNode != originalBlock; 563 563 bool prevIsOutsideOriginalBlock = !prevNode->isDescendantOf(originalBlock) && prevNode != originalBlock; … … 712 712 } 713 713 714 Element* enclosingBlockFlowElement(const VisiblePosition &visiblePosition) 714 // FIXME: Maybe this should be deprecated too, like the underlying function? 715 Element* enclosingBlockFlowElement(const VisiblePosition& visiblePosition) 715 716 { 716 717 if (visiblePosition.isNull()) 717 718 return NULL; 718 719 719 return visiblePosition.deepEquivalent().deprecatedNode()->enclosingBlockFlowElement();720 return deprecatedEnclosingBlockFlowElement(visiblePosition.deepEquivalent().deprecatedNode()); 720 721 } 721 722 -
trunk/Source/WebCore/editing/VisibleSelection.cpp
r144911 r150782 208 208 if (!de) 209 209 return 0; 210 Node* boundary = n->enclosingBlockFlowElement();210 Element* boundary = deprecatedEnclosingBlockFlowElement(n); 211 211 if (!boundary) 212 212 return 0; -
trunk/Source/WebCore/editing/htmlediting.cpp
r150712 r150782 1209 1209 } 1210 1210 1211 // FIXME: Should this be deprecated like deprecatedEnclosingBlockFlowElement is? 1212 bool isBlockFlowElement(const Node* node) 1213 { 1214 if (!node->isElementNode()) 1215 return false; 1216 RenderObject* renderer = node->renderer(); 1217 return renderer && renderer->isBlockFlow(); 1218 } 1219 1220 Element* deprecatedEnclosingBlockFlowElement(Node* node) 1221 { 1222 if (!node) 1223 return 0; 1224 if (isBlockFlowElement(node)) 1225 return toElement(node); 1226 while ((node = node->parentNode())) { 1227 if (isBlockFlowElement(node) || node->hasTagName(bodyTag)) 1228 return toElement(node); 1229 } 1230 return 0; 1231 } 1232 1211 1233 } // namespace WebCore -
trunk/Source/WebCore/editing/htmlediting.h
r150712 r150782 62 62 Node* lowestEditableAncestor(Node*); 63 63 64 Element* deprecatedEnclosingBlockFlowElement(Node*); // Use enclosingBlock instead. 64 65 Element* enclosingBlock(Node*, EditingBoundaryCrossingRule = CannotCrossEditingBoundary); 65 66 Node* enclosingTableCell(const Position&); … … 98 99 bool isAtomicNode(const Node*); 99 100 bool isBlock(const Node*); 101 bool isBlockFlowElement(const Node*); 100 102 bool isInline(const Node*); 101 103 bool isSpecialElement(const Node*); … … 114 116 bool areIdenticalElements(const Node*, const Node*); 115 117 bool isNonTableCellHTMLBlockElement(const Node*); 118 116 119 TextDirection directionOfEnclosingBlock(const Position&); 117 120
Note: See TracChangeset
for help on using the changeset viewer.