Changeset 107509 in webkit
- Timestamp:
- Feb 12, 2012 3:27:56 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107508 r107509 1 2012-02-12 Joe Thomas <joethomas@motorola.com> 2 3 Add toText and isTextNode helpers in Text class. 4 https://bugs.webkit.org/show_bug.cgi?id=78140 5 6 Added a new helper function toText() in dom/Text.h which does the type casting operation to Text object. 7 Modified the code to make use of this helper function. 8 9 Reviewed by Adam Barth. 10 11 No new tests. 12 13 * accessibility/AccessibilityRenderObject.cpp: 14 (WebCore::accessibleNameForNode): 15 * bindings/v8/custom/V8NodeCustom.cpp: 16 (WebCore::toV8Slow): 17 * css/SelectorChecker.cpp: 18 (WebCore::SelectorChecker::checkOneSelector): 19 * dom/Attr.cpp: 20 (WebCore::Attr::childrenChanged): 21 * dom/Element.cpp: 22 (WebCore::Element::recalcStyle): 23 * dom/Node.cpp: 24 (WebCore::Node::normalize): 25 * dom/Position.cpp: 26 (WebCore::Position::containerText): 27 (WebCore::Position::leadingWhitespacePosition): 28 * dom/Range.cpp: 29 (WebCore::Range::insertNode): 30 (WebCore::Range::getBorderAndTextQuads): 31 * dom/ScriptElement.cpp: 32 (WebCore::ScriptElement::scriptContent): 33 * dom/ShadowRoot.cpp: 34 (WebCore::ShadowRoot::recalcShadowTreeStyle): 35 * dom/Text.h: Added new helper function toText. 36 (WebCore::toText): new helper function which does the type casting operation to Text object. 37 (WebCore): 38 * editing/ApplyBlockElementCommand.cpp: 39 (WebCore::isNewLineAtPosition): 40 (WebCore::ApplyBlockElementCommand::endOfNextParagrahSplittingTextNodesIfNeeded): 41 * editing/ApplyStyleCommand.cpp: 42 (WebCore::ApplyStyleCommand::splitTextAtEnd): 43 (WebCore::ApplyStyleCommand::splitTextElementAtEnd): 44 (WebCore::ApplyStyleCommand::joinChildTextNodes): 45 * editing/BreakBlockquoteCommand.cpp: 46 (WebCore::BreakBlockquoteCommand::doApply): 47 * editing/CompositeEditCommand.cpp: 48 (WebCore::CompositeEditCommand::insertNodeAt): 49 (WebCore::CompositeEditCommand::positionOutsideTabSpan): 50 (WebCore::CompositeEditCommand::canRebalance): 51 (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): 52 (WebCore::CompositeEditCommand::prepareWhitespaceAtPositionForSplit): 53 (WebCore::CompositeEditCommand::deleteInsignificantText): 54 (WebCore::CompositeEditCommand::removePlaceholderAt): 55 (WebCore::CompositeEditCommand::cleanupAfterDeletion): 56 (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph): 57 * editing/DeleteSelectionCommand.cpp: 58 (WebCore::DeleteSelectionCommand::handleGeneralDelete): 59 (WebCore::DeleteSelectionCommand::fixupWhitespace): 60 * editing/Editor.cpp: 61 (WebCore::Editor::setComposition): 62 * editing/InsertLineBreakCommand.cpp: 63 (WebCore::InsertLineBreakCommand::doApply): 64 * editing/InsertParagraphSeparatorCommand.cpp: 65 (WebCore::InsertParagraphSeparatorCommand::doApply): 66 * editing/InsertTextCommand.cpp: 67 (WebCore::InsertTextCommand::insertTab): 68 * editing/MarkupAccumulator.cpp: 69 (WebCore::MarkupAccumulator::appendStartMarkup): 70 * editing/ReplaceSelectionCommand.cpp: 71 (WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds): 72 (WebCore::ReplaceSelectionCommand::addSpacesForSmartReplace): 73 (WebCore::ReplaceSelectionCommand::insertAsListItems): 74 (WebCore::ReplaceSelectionCommand::performTrivialReplace): 75 * editing/htmlediting.cpp: 76 (WebCore::lineBreakExistsAtPosition): 77 * editing/visible_units.cpp: 78 (WebCore::startPositionForLine): 79 (WebCore::endPositionForLine): 80 (WebCore::startOfParagraph): 81 (WebCore::endOfParagraph): 82 * html/HTMLElement.cpp: 83 (WebCore::replaceChildrenWithFragment): 84 (WebCore::replaceChildrenWithText): 85 (WebCore::mergeWithNextTextNode): 86 * html/HTMLObjectElement.cpp: 87 (WebCore::HTMLObjectElement::hasFallbackContent): 88 (WebCore::HTMLObjectElement::updateDocNamedItem): 89 * html/HTMLOptionElement.cpp: 90 (WebCore::HTMLOptionElement::setText): 91 * html/HTMLScriptElement.cpp: 92 (WebCore::HTMLScriptElement::setText): 93 * html/HTMLTextAreaElement.cpp: 94 (WebCore::HTMLTextAreaElement::defaultValue): 95 * html/HTMLTextFormControlElement.cpp: 96 (WebCore::HTMLTextFormControlElement::innerTextValue): 97 (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks): 98 * html/HTMLTitleElement.cpp: 99 (WebCore::HTMLTitleElement::text): 100 (WebCore::HTMLTitleElement::setText): 101 * inspector/InspectorDOMAgent.cpp: 102 (WebCore::InspectorDOMAgent::setNodeValue): 103 * rendering/RenderText.cpp: 104 (WebCore::RenderText::originalText): 105 * rendering/RenderTextFragment.cpp: 106 (WebCore::RenderTextFragment::originalText): 107 (WebCore::RenderTextFragment::previousCharacter): 108 1 109 2012-02-12 Kentaro Hara <haraken@chromium.org> 2 110 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r107477 r107509 1213 1213 { 1214 1214 if (node->isTextNode()) 1215 return static_cast<Text*>(node)->data();1215 return toText(node)->data(); 1216 1216 1217 1217 if (node->hasTagName(inputTag)) -
trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp
r107367 r107509 148 148 return toV8(static_cast<Attr*>(impl), forceNewObject); 149 149 case Node::TEXT_NODE: 150 return toV8( static_cast<Text*>(impl), forceNewObject);150 return toV8(toText(impl), forceNewObject); 151 151 case Node::CDATA_SECTION_NODE: 152 152 return toV8(static_cast<CDATASection*>(impl), forceNewObject); -
trunk/Source/WebCore/css/SelectorChecker.cpp
r107212 r107509 772 772 } 773 773 if (n->isTextNode()) { 774 Text* textNode = static_cast<Text*>(n);774 Text* textNode = toText(n); 775 775 if (!textNode->data().isEmpty()) { 776 776 result = false; -
trunk/Source/WebCore/dom/Attr.cpp
r104674 r107509 182 182 for (Node *n = firstChild(); n; n = n->nextSibling()) { 183 183 if (n->isTextNode()) 184 valueBuilder.append( static_cast<Text*>(n)->data());184 valueBuilder.append(toText(n)->data()); 185 185 } 186 186 -
trunk/Source/WebCore/dom/Element.cpp
r107202 r107509 1122 1122 for (Node *n = firstChild(); n; n = n->nextSibling()) { 1123 1123 if (n->isTextNode()) { 1124 static_cast<Text*>(n)->recalcTextStyle(change);1124 toText(n)->recalcTextStyle(change); 1125 1125 continue; 1126 1126 } -
trunk/Source/WebCore/dom/Node.cpp
r107479 r107509 633 633 } 634 634 635 RefPtr<Text> text = static_cast<Text*>(node.get());635 RefPtr<Text> text = toText(node.get()); 636 636 637 637 // Remove empty text nodes. … … 648 648 if (nextSibling->nodeType() != TEXT_NODE) 649 649 break; 650 RefPtr<Text> nextText = static_cast<Text*>(nextSibling);650 RefPtr<Text> nextText = toText(nextSibling); 651 651 652 652 // Remove empty text nodes. -
trunk/Source/WebCore/dom/Position.cpp
r107407 r107509 154 154 switch (anchorType()) { 155 155 case PositionIsOffsetInAnchor: 156 return m_anchorNode && m_anchorNode->isTextNode() ? static_cast<Text*>(m_anchorNode.get()) : 0;156 return m_anchorNode && m_anchorNode->isTextNode() ? toText(m_anchorNode.get()) : 0; 157 157 case PositionIsBeforeAnchor: 158 158 case PositionIsAfterAnchor: … … 1019 1019 Position prev = previousCharacterPosition(affinity); 1020 1020 if (prev != *this && prev.deprecatedNode()->inSameContainingBlockFlowElement(deprecatedNode()) && prev.deprecatedNode()->isTextNode()) { 1021 String string = static_cast<Text *>(prev.deprecatedNode())->data();1021 String string = toText(prev.deprecatedNode())->data(); 1022 1022 UChar c = string[prev.deprecatedEditingOffset()]; 1023 1023 if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : isCollapsibleWhitespace(c)) -
trunk/Source/WebCore/dom/Range.cpp
r107461 r107509 1038 1038 bool collapsed = m_start == m_end; 1039 1039 if (startIsText) { 1040 RefPtr<Text> newText = static_cast<Text*>(m_start.container())->splitText(m_start.offset(), ec);1040 RefPtr<Text> newText = toText(m_start.container())->splitText(m_start.offset(), ec); 1041 1041 if (ec) 1042 1042 return; … … 2041 2041 } 2042 2042 } else if (node->isTextNode()) { 2043 if (RenderObject* renderer = static_cast<Text*>(node)->renderer()) {2043 if (RenderObject* renderer = toText(node)->renderer()) { 2044 2044 RenderText* renderText = toRenderText(renderer); 2045 2045 int startOffset = (node == startContainer) ? m_start.offset() : 0; -
trunk/Source/WebCore/dom/ScriptElement.cpp
r106043 r107509 356 356 continue; 357 357 358 Text* t = static_cast<Text*>(n);358 Text* t = toText(n); 359 359 if (foundMultipleTextNodes) 360 360 content.append(t->data()); -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r107202 r107509 156 156 static_cast<Element*>(n)->recalcStyle(change); 157 157 else if (n->isTextNode()) 158 static_cast<Text*>(n)->recalcTextStyle(change);158 toText(n)->recalcTextStyle(change); 159 159 } 160 160 } -
trunk/Source/WebCore/dom/Text.h
r94561 r107509 71 71 }; 72 72 73 inline Text* toText(Node* node) 74 { 75 ASSERT(!node || node->isTextNode()); 76 return static_cast<Text*>(node); 77 } 78 73 79 } // namespace WebCore 74 80 -
trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp
r102833 r107509 163 163 164 164 ExceptionCode ec = 0; 165 String textAtPosition = static_cast<Text*>(textNode)->substringData(offset, 1, ec);165 String textAtPosition = toText(textNode)->substringData(offset, 1, ec); 166 166 if (ec) 167 167 return false; … … 258 258 if (text == start.containerNode() && text->previousSibling() && text->previousSibling()->isTextNode()) { 259 259 ASSERT(start.offsetInContainerNode() < position.offsetInContainerNode()); 260 start = Position( static_cast<Text*>(text->previousSibling()), start.offsetInContainerNode());260 start = Position(toText(text->previousSibling()), start.offsetInContainerNode()); 261 261 } 262 262 if (text == end.containerNode() && text->previousSibling() && text->previousSibling()->isTextNode()) { 263 263 ASSERT(end.offsetInContainerNode() < position.offsetInContainerNode()); 264 end = Position( static_cast<Text*>(text->previousSibling()), end.offsetInContainerNode());264 end = Position(toText(text->previousSibling()), end.offsetInContainerNode()); 265 265 } 266 266 if (text == m_endOfLastParagraph.containerNode()) { … … 268 268 // We can only fix endOfLastParagraph if the previous node was still text and hasn't been modified by script. 269 269 if (text->previousSibling()->isTextNode() 270 && static_cast<unsigned>(m_endOfLastParagraph.offsetInContainerNode()) <= static_cast<Text*>(text->previousSibling())->length())271 m_endOfLastParagraph = Position( static_cast<Text*>(text->previousSibling()), m_endOfLastParagraph.offsetInContainerNode());270 && static_cast<unsigned>(m_endOfLastParagraph.offsetInContainerNode()) <= toText(text->previousSibling())->length()) 271 m_endOfLastParagraph = Position(toText(text->previousSibling()), m_endOfLastParagraph.offsetInContainerNode()); 272 272 } else 273 273 m_endOfLastParagraph = Position(text.get(), m_endOfLastParagraph.offsetInContainerNode() - 1); -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r107407 r107509 1124 1124 1125 1125 bool shouldUpdateStart = start.anchorType() == Position::PositionIsOffsetInAnchor && start.containerNode() == end.containerNode(); 1126 Text* text = static_cast<Text *>(end.deprecatedNode());1126 Text* text = toText(end.deprecatedNode()); 1127 1127 splitTextNode(text, end.offsetInContainerNode()); 1128 1128 … … 1131 1131 return; 1132 1132 1133 Position newStart = shouldUpdateStart ? Position( static_cast<Text*>(prevNode), start.offsetInContainerNode()) : start;1133 Position newStart = shouldUpdateStart ? Position(toText(prevNode), start.offsetInContainerNode()) : start; 1134 1134 updateStartEnd(newStart, lastPositionInNode(prevNode)); 1135 1135 } … … 1163 1163 return; 1164 1164 1165 Position newStart = shouldUpdateStart ? Position( static_cast<Text*>(firstTextNode), start.offsetInContainerNode()) : start;1165 Position newStart = shouldUpdateStart ? Position(toText(firstTextNode), start.offsetInContainerNode()) : start; 1166 1166 updateStartEnd(newStart, positionAfterNode(firstTextNode)); 1167 1167 } … … 1434 1434 Node* next = child->nextSibling(); 1435 1435 if (child->isTextNode() && next && next->isTextNode()) { 1436 Text* childText = static_cast<Text *>(child);1437 Text* nextText = static_cast<Text *>(next);1436 Text* childText = toText(child); 1437 Text* nextText = toText(next); 1438 1438 if (start.anchorType() == Position::PositionIsOffsetInAnchor && next == start.containerNode()) 1439 1439 newStart = Position(childText, childText->length() + start.offsetInContainerNode()); -
trunk/Source/WebCore/editing/BreakBlockquoteCommand.cpp
r93134 r107509 108 108 // Split at pos if in the middle of a text node. 109 109 if (startNode->isTextNode()) { 110 Text* textNode = static_cast<Text*>(startNode);110 Text* textNode = toText(startNode); 111 111 if ((unsigned)pos.deprecatedEditingOffset() >= textNode->length()) { 112 112 startNode = startNode->traverseNextNode(); -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r106515 r107509 357 357 insertNodeBefore(insertChild, refChild); 358 358 else if (refChild->isTextNode() && caretMaxOffset(refChild) > offset) { 359 splitTextNode( static_cast<Text *>(refChild), offset);359 splitTextNode(toText(refChild), offset); 360 360 361 361 // Mutation events (bug 22634) from the text node insertion may have removed the refChild … … 533 533 return positionInParentAfterNode(tabSpan); 534 534 535 splitTextNodeContainingElement( static_cast<Text *>(pos.containerNode()), pos.offsetInContainerNode());535 splitTextNodeContainingElement(toText(pos.containerNode()), pos.offsetInContainerNode()); 536 536 return positionInParentBeforeNode(tabSpan); 537 537 } … … 591 591 return false; 592 592 593 Text* textNode = static_cast<Text*>(node);593 Text* textNode = toText(node); 594 594 if (textNode->length() == 0) 595 595 return false; … … 611 611 // If the rebalance is for the single offset, and neither text[offset] nor text[offset - 1] are some form of whitespace, do nothing. 612 612 int offset = position.deprecatedEditingOffset(); 613 String text = static_cast<Text*>(node)->data();613 String text = toText(node)->data(); 614 614 if (!isWhitespace(text[offset])) { 615 615 offset--; … … 618 618 } 619 619 620 rebalanceWhitespaceOnTextSubstring( static_cast<Text*>(node), position.offsetInContainerNode(), position.offsetInContainerNode());620 rebalanceWhitespaceOnTextSubstring(toText(node), position.offsetInContainerNode(), position.offsetInContainerNode()); 621 621 } 622 622 … … 660 660 if (!node || !node->isTextNode()) 661 661 return; 662 Text* textNode = static_cast<Text*>(node);662 Text* textNode = toText(node); 663 663 664 664 if (textNode->length() == 0) … … 678 678 679 679 if (isCollapsibleWhitespace(previousVisiblePos.characterAfter()) && previous.deprecatedNode()->isTextNode() && !previous.deprecatedNode()->hasTagName(brTag)) 680 replaceTextInNodePreservingMarkers( static_cast<Text*>(previous.deprecatedNode()), previous.deprecatedEditingOffset(), 1, nonBreakingSpaceString());680 replaceTextInNodePreservingMarkers(toText(previous.deprecatedNode()), previous.deprecatedEditingOffset(), 1, nonBreakingSpaceString()); 681 681 if (isCollapsibleWhitespace(visiblePos.characterAfter()) && position.deprecatedNode()->isTextNode() && !position.deprecatedNode()->hasTagName(brTag)) 682 replaceTextInNodePreservingMarkers( static_cast<Text*>(position.deprecatedNode()), position.deprecatedEditingOffset(), 1, nonBreakingSpaceString());682 replaceTextInNodePreservingMarkers(toText(position.deprecatedNode()), position.deprecatedEditingOffset(), 1, nonBreakingSpaceString()); 683 683 } 684 684 … … 785 785 next = node->traverseNextNode(); 786 786 if (node->isTextNode()) { 787 Text* textNode = static_cast<Text*>(node);787 Text* textNode = toText(node); 788 788 int startOffset = node == start.deprecatedNode() ? start.deprecatedEditingOffset() : 0; 789 789 int endOffset = node == end.deprecatedNode() ? end.deprecatedEditingOffset() : static_cast<int>(textNode->length()); … … 858 858 } 859 859 860 deleteTextFromNode( static_cast<Text*>(p.anchorNode()), p.offsetInContainerNode(), 1);860 deleteTextFromNode(toText(p.anchorNode()), p.offsetInContainerNode(), 1); 861 861 } 862 862 … … 1034 1034 // There is a preserved '\n' at caretAfterDelete. 1035 1035 // We can safely assume this is a text node. 1036 Text* textNode = static_cast<Text*>(node);1036 Text* textNode = toText(node); 1037 1037 if (textNode->length() == 1) 1038 1038 removeNodeAndPruneAncestors(node); … … 1327 1327 else if (caretPos.deprecatedNode()->isTextNode()) { 1328 1328 ASSERT(caretPos.deprecatedEditingOffset() == 0); 1329 Text* textNode = static_cast<Text*>(caretPos.deprecatedNode());1329 Text* textNode = toText(caretPos.deprecatedNode()); 1330 1330 ContainerNode* parentNode = textNode->parentNode(); 1331 1331 // The preserved newline must be the first thing in the node, since otherwise the previous -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r106380 r107509 424 424 425 425 if (startOffset >= caretMaxOffset(startNode) && startNode->isTextNode()) { 426 Text *text = static_cast<Text *>(startNode);426 Text* text = toText(startNode); 427 427 if (text->length() > (unsigned)caretMaxOffset(startNode)) 428 428 deleteTextFromNode(text, caretMaxOffset(startNode), text->length() - caretMaxOffset(startNode)); … … 442 442 if (startNode->isTextNode()) { 443 443 // in a text node that needs to be trimmed 444 Text* text = static_cast<Text*>(startNode);444 Text* text = toText(startNode); 445 445 deleteTextFromNode(text, startOffset, m_downstreamEnd.deprecatedEditingOffset() - startOffset); 446 446 } else { … … 462 462 if (startNode->isTextNode()) { 463 463 // in a text node that needs to be trimmed 464 Text *text = static_cast<Text *>(node.get());464 Text* text = toText(node.get()); 465 465 deleteTextFromNode(text, startOffset, text->length() - startOffset); 466 466 node = node->traverseNextNode(); … … 469 469 } 470 470 } else if (startNode == m_upstreamEnd.deprecatedNode() && startNode->isTextNode()) { 471 Text* text = static_cast<Text*>(m_upstreamEnd.deprecatedNode());471 Text* text = toText(m_upstreamEnd.deprecatedNode()); 472 472 deleteTextFromNode(text, 0, m_upstreamEnd.deprecatedEditingOffset()); 473 473 } … … 502 502 if (m_downstreamEnd.deprecatedNode()->isTextNode()) { 503 503 // in a text node that needs to be trimmed 504 Text* text = static_cast<Text*>(m_downstreamEnd.deprecatedNode());504 Text* text = toText(m_downstreamEnd.deprecatedNode()); 505 505 if (m_downstreamEnd.deprecatedEditingOffset() > 0) { 506 506 deleteTextFromNode(text, 0, m_downstreamEnd.deprecatedEditingOffset()); … … 534 534 // FIXME: isRenderedCharacter should be removed, and we should use VisiblePosition::characterAfter and VisiblePosition::characterBefore 535 535 if (m_leadingWhitespace.isNotNull() && !m_leadingWhitespace.isRenderedCharacter() && m_leadingWhitespace.deprecatedNode()->isTextNode()) { 536 Text* textNode = static_cast<Text*>(m_leadingWhitespace.deprecatedNode());536 Text* textNode = toText(m_leadingWhitespace.deprecatedNode()); 537 537 ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseWhiteSpace()); 538 538 replaceTextInNodePreservingMarkers(textNode, m_leadingWhitespace.deprecatedEditingOffset(), 1, nonBreakingSpaceString()); 539 539 } 540 540 if (m_trailingWhitespace.isNotNull() && !m_trailingWhitespace.isRenderedCharacter() && m_trailingWhitespace.deprecatedNode()->isTextNode()) { 541 Text* textNode = static_cast<Text*>(m_trailingWhitespace.deprecatedNode());541 Text* textNode = toText(m_trailingWhitespace.deprecatedNode()); 542 542 ASSERT(!textNode->renderer() ||textNode->renderer()->style()->collapseWhiteSpace()); 543 543 replaceTextInNodePreservingMarkers(textNode, m_trailingWhitespace.deprecatedEditingOffset(), 1, nonBreakingSpaceString()); -
trunk/Source/WebCore/editing/Editor.cpp
r107407 r107509 1503 1503 1504 1504 if (baseNode && baseNode == extentNode && baseNode->isTextNode() && baseOffset + text.length() == extentOffset) { 1505 m_compositionNode = static_cast<Text*>(baseNode);1505 m_compositionNode = toText(baseNode); 1506 1506 m_compositionStart = baseOffset; 1507 1507 m_compositionEnd = extentOffset; -
trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp
r102833 r107509 138 138 } else if (pos.deprecatedNode()->isTextNode()) { 139 139 // Split a text node 140 Text* textNode = static_cast<Text*>(pos.deprecatedNode());140 Text* textNode = toText(pos.deprecatedNode()); 141 141 splitTextNode(textNode, pos.deprecatedEditingOffset()); 142 142 insertNodeBefore(nodeToInsert, textNode); -
trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
r106833 r107509 323 323 // after the preserved newline, causing the newline to be turned into a nbsp. 324 324 if (leadingWhitespace.isNotNull() && leadingWhitespace.deprecatedNode()->isTextNode()) { 325 Text* textNode = static_cast<Text*>(leadingWhitespace.deprecatedNode());325 Text* textNode = toText(leadingWhitespace.deprecatedNode()); 326 326 ASSERT(!textNode->renderer() || textNode->renderer()->style()->collapseWhiteSpace()); 327 327 replaceTextInNodePreservingMarkers(textNode, leadingWhitespace.deprecatedEditingOffset(), 1, nonBreakingSpaceString()); … … 330 330 // Split at pos if in the middle of a text node. 331 331 if (insertionPosition.deprecatedNode()->isTextNode()) { 332 Text* textNode = static_cast<Text*>(insertionPosition.deprecatedNode());332 Text* textNode = toText(insertionPosition.deprecatedNode()); 333 333 bool atEnd = (unsigned)insertionPosition.deprecatedEditingOffset() >= textNode->length(); 334 334 if (insertionPosition.deprecatedEditingOffset() > 0 && !atEnd) { … … 390 390 deleteInsignificantTextDownstream(insertionPosition); 391 391 if (insertionPosition.deprecatedNode()->isTextNode()) 392 insertTextIntoNode( static_cast<Text*>(insertionPosition.deprecatedNode()), 0, nonBreakingSpaceString());392 insertTextIntoNode(toText(insertionPosition.deprecatedNode()), 0, nonBreakingSpaceString()); 393 393 } 394 394 } -
trunk/Source/WebCore/editing/InsertTextCommand.cpp
r93290 r107509 210 210 // keep tabs coalesced in tab span 211 211 if (isTabSpanTextNode(node)) { 212 RefPtr<Text> textNode = static_cast<Text*>(node);212 RefPtr<Text> textNode = toText(node); 213 213 insertTextIntoNode(textNode, offset, "\t"); 214 214 return Position(textNode.release(), offset + 1); … … 222 222 insertNodeAt(spanNode.get(), insertPos); 223 223 } else { 224 RefPtr<Text> textNode = static_cast<Text*>(node);224 RefPtr<Text> textNode = toText(node); 225 225 if (offset >= textNode->length()) 226 226 insertNodeAfter(spanNode, textNode.release()); -
trunk/Source/WebCore/editing/MarkupAccumulator.cpp
r106833 r107509 420 420 switch (node->nodeType()) { 421 421 case Node::TEXT_NODE: 422 appendText(result, static_cast<Text*>(const_cast<Node*>(node)));422 appendText(result, toText(const_cast<Node*>(node))); 423 423 break; 424 424 case Node::COMMENT_NODE: -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r106695 r107509 598 598 599 599 Node* lastLeafInserted = insertedNodes.lastLeafInserted(); 600 if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRenderText( static_cast<Text*>(lastLeafInserted))600 if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRenderText(toText(lastLeafInserted)) 601 601 && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag) 602 602 && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) { … … 609 609 Node* firstNodeInserted = insertedNodes.firstNodeInserted(); 610 610 lastLeafInserted = insertedNodes.lastLeafInserted(); 611 if (firstNodeInserted && firstNodeInserted->isTextNode() && !nodeHasVisibleRenderText( static_cast<Text*>(firstNodeInserted))) {611 if (firstNodeInserted && firstNodeInserted->isTextNode() && !nodeHasVisibleRenderText(toText(firstNodeInserted))) { 612 612 insertedNodes.willRemoveNode(firstNodeInserted); 613 613 removeNode(firstNodeInserted); … … 1190 1190 bool collapseWhiteSpace = !endNode->renderer() || endNode->renderer()->style()->collapseWhiteSpace(); 1191 1191 if (endNode->isTextNode()) { 1192 Text* text = static_cast<Text*>(endNode);1192 Text* text = toText(endNode); 1193 1193 // FIXME: we shouldn't always be inserting the space at the end 1194 1194 insertTextIntoNode(text, text->length(), collapseWhiteSpace ? nonBreakingSpaceString() : " "); … … 1214 1214 bool collapseWhiteSpace = !startNode->renderer() || startNode->renderer()->style()->collapseWhiteSpace(); 1215 1215 if (startNode->isTextNode()) { 1216 insertTextIntoNode( static_cast<Text*>(startNode), startOffset, collapseWhiteSpace ? nonBreakingSpaceString() : " ");1216 insertTextIntoNode(toText(startNode), startOffset, collapseWhiteSpace ? nonBreakingSpaceString() : " "); 1217 1217 if (m_endOfInsertedContent.containerNode() == startNode && m_endOfInsertedContent.offsetInContainerNode()) 1218 1218 m_endOfInsertedContent.moveToOffset(m_endOfInsertedContent.offsetInContainerNode() + 1); … … 1280 1280 int textNodeOffset = insertPos.offsetInContainerNode(); 1281 1281 if (insertPos.deprecatedNode()->isTextNode() && textNodeOffset > 0) 1282 splitTextNode( static_cast<Text*>(insertPos.deprecatedNode()), textNodeOffset);1282 splitTextNode(toText(insertPos.deprecatedNode()), textNodeOffset); 1283 1283 splitTreeToNode(insertPos.deprecatedNode(), lastNode, true); 1284 1284 } … … 1334 1334 1335 1335 Node* nodeAfterInsertionPos = endingSelection().end().downstream().anchorNode(); 1336 Text* textNode = static_cast<Text*>(fragment.firstChild());1336 Text* textNode = toText(fragment.firstChild()); 1337 1337 // Our fragment creation code handles tabs, spaces, and newlines, so we don't have to worry about those here. 1338 1338 -
trunk/Source/WebCore/editing/htmlediting.cpp
r106515 r107509 1034 1034 return false; 1035 1035 1036 Text* textNode = static_cast<Text*>(position.anchorNode());1036 Text* textNode = toText(position.anchorNode()); 1037 1037 unsigned offset = position.offsetInContainerNode(); 1038 1038 return offset < textNode->length() && textNode->data()[offset] == '\n'; -
trunk/Source/WebCore/editing/visible_units.cpp
r106298 r107509 362 362 } 363 363 364 return startNode->isTextNode() ? Position( static_cast<Text*>(startNode), toInlineTextBox(startBox)->start())364 return startNode->isTextNode() ? Position(toText(startNode), toInlineTextBox(startBox)->start()) 365 365 : positionBeforeNode(startNode); 366 366 } … … 442 442 if (!endTextBox->isLineBreak()) 443 443 endOffset += endTextBox->len(); 444 pos = Position( static_cast<Text*>(endNode), endOffset);444 pos = Position(toText(endNode), endOffset); 445 445 } else 446 446 pos = positionAfterNode(endNode); … … 835 835 while (--i >= 0) { 836 836 if (chars[i] == '\n') 837 return VisiblePosition(Position( static_cast<Text*>(n), i + 1), DOWNSTREAM);837 return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM); 838 838 } 839 839 } … … 911 911 for (int i = o; i < length; ++i) { 912 912 if (chars[i] == '\n') 913 return VisiblePosition(Position( static_cast<Text*>(n), i), DOWNSTREAM);913 return VisiblePosition(Position(toText(n), i), DOWNSTREAM); 914 914 } 915 915 } -
trunk/Source/WebCore/html/HTMLElement.cpp
r107484 r107509 365 365 366 366 if (hasOneTextChild(element) && hasOneTextChild(fragment.get())) { 367 static_cast<Text*>(element->firstChild())->setData(static_cast<Text*>(fragment->firstChild())->data(), ec);367 toText(element->firstChild())->setData(toText(fragment->firstChild())->data(), ec); 368 368 return; 369 369 } … … 385 385 386 386 if (hasOneTextChild(element)) { 387 static_cast<Text*>(element->firstChild())->setData(text, ec);387 toText(element->firstChild())->setData(text, ec); 388 388 return; 389 389 } … … 434 434 return; 435 435 436 RefPtr<Text> textNode = static_cast<Text*>(node.get());437 RefPtr<Text> textNext = static_cast<Text*>(next);436 RefPtr<Text> textNode = toText(node.get()); 437 RefPtr<Text> textNext = toText(next); 438 438 textNode->appendData(textNext->data(), ec); 439 439 if (ec) -
trunk/Source/WebCore/html/HTMLObjectElement.cpp
r107484 r107509 216 216 // Ignore whitespace-only text, and <param> tags, any other content is fallback content. 217 217 if (child->isTextNode()) { 218 if (! static_cast<Text*>(child)->containsOnlyWhitespace())218 if (!toText(child)->containsOnlyWhitespace()) 219 219 return true; 220 220 } else if (!child->hasTagName(paramTag)) … … 423 423 isNamedItem = false; 424 424 } else if (child->isTextNode()) { 425 if (! static_cast<Text*>(child)->containsOnlyWhitespace())425 if (!toText(child)->containsOnlyWhitespace()) 426 426 isNamedItem = false; 427 427 } else -
trunk/Source/WebCore/html/HTMLOptionElement.cpp
r106769 r107509 148 148 Node* child = firstChild(); 149 149 if (child && child->isTextNode() && !child->nextSibling()) 150 static_cast<Text *>(child)->setData(text, ec);150 toText(child)->setData(text, ec); 151 151 else { 152 152 removeChildren(); -
trunk/Source/WebCore/html/HTMLScriptElement.cpp
r106769 r107509 92 92 93 93 if (numChildren == 1 && firstChild()->isTextNode()) { 94 static_cast<Text*>(firstChild())->setData(value, ec);94 toText(firstChild())->setData(value, ec); 95 95 return; 96 96 } -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r107484 r107509 368 368 for (Node* n = firstChild(); n; n = n->nextSibling()) { 369 369 if (n->isTextNode()) 370 value += static_cast<Text*>(n)->data();370 value += toText(n)->data(); 371 371 } 372 372 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r106769 r107509 494 494 result.append(newlineCharacter); 495 495 else if (node->isTextNode()) 496 result.append( static_cast<Text*>(node)->data());496 result.append(toText(node)->data()); 497 497 } 498 498 return finishText(result); … … 541 541 result.append(newlineCharacter); 542 542 else if (node->isTextNode()) { 543 String data = static_cast<Text*>(node)->data();543 String data = toText(node)->data(); 544 544 unsigned length = data.length(); 545 545 unsigned position = 0; -
trunk/Source/WebCore/html/HTMLTitleElement.cpp
r94659 r107509 71 71 for (Node *n = firstChild(); n; n = n->nextSibling()) { 72 72 if (n->isTextNode()) 73 val += static_cast<Text*>(n)->data();73 val += toText(n)->data(); 74 74 } 75 75 … … 93 93 94 94 if (numChildren == 1 && firstChild()->isTextNode()) 95 static_cast<Text*>(firstChild())->setData(value, ec);95 toText(firstChild())->setData(value, ec); 96 96 else { 97 97 // We make a copy here because entity of "value" argument can be Document::m_title, -
trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp
r107399 r107509 707 707 } 708 708 709 m_domEditor->replaceWholeText( static_cast<Text*>(node), value, errorString);709 m_domEditor->replaceWholeText(toText(node), value, errorString); 710 710 } 711 711 -
trunk/Source/WebCore/rendering/RenderText.cpp
r105394 r107509 301 301 { 302 302 Node* e = node(); 303 return (e && e->isTextNode()) ? static_cast<Text*>(e)->dataImpl() : 0;303 return (e && e->isTextNode()) ? toText(e)->dataImpl() : 0; 304 304 } 305 305 -
trunk/Source/WebCore/rendering/RenderTextFragment.cpp
r90675 r107509 53 53 { 54 54 Node* e = node(); 55 RefPtr<StringImpl> result = ((e && e->isTextNode()) ? static_cast<Text*>(e)->dataImpl() : contentString());55 RefPtr<StringImpl> result = ((e && e->isTextNode()) ? toText(e)->dataImpl() : contentString()); 56 56 if (!result) 57 57 return 0; … … 96 96 if (start()) { 97 97 Node* e = node(); 98 StringImpl* original = ((e && e->isTextNode()) ? static_cast<Text*>(e)->dataImpl() : contentString());98 StringImpl* original = ((e && e->isTextNode()) ? toText(e)->dataImpl() : contentString()); 99 99 if (original && start() <= original->length()) 100 100 return (*original)[start() - 1]; -
trunk/Tools/ChangeLog
r107504 r107509 1 2012-02-12 Joe Thomas <joethomas@motorola.com> 2 3 Add toText and isTextNode helpers in Text class. 4 https://bugs.webkit.org/show_bug.cgi?id=78140 5 6 Added a style checker to use toText rather than static_cast<Text*>. 7 8 Reviewed by Adam Barth. 9 10 * Scripts/webkitpy/style/checkers/cpp.py: 11 (check_language): Style checker for static_cast<Text*>. 12 1 13 2012-02-12 Philippe Normand <pnormand@igalia.com> 2 14 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r106838 r107509 2981 2981 check_identifier_name_in_declaration(filename, line_number, line, file_state, error) 2982 2982 2983 # Check that we're not using static_cast<Text*>. 2984 if search(r'\bstatic_cast<Text\*>', line): 2985 error(line_number, 'readability/check', 4, 2986 'Consider using toText helper function in WebCore/dom/Text.h ' 2987 'instead of static_cast<Text*>') 2983 2988 2984 2989 def check_identifier_name_in_declaration(filename, line_number, line, file_state, error):
Note: See TracChangeset
for help on using the changeset viewer.