| Index: sky/engine/core/dom/Text.cpp
|
| diff --git a/sky/engine/core/dom/Text.cpp b/sky/engine/core/dom/Text.cpp
|
| index b010c4969c9c8564eef200a5777c31970316919f..9d91a66d9e4c05c630131d6f08e965807495ef82 100644
|
| --- a/sky/engine/core/dom/Text.cpp
|
| +++ b/sky/engine/core/dom/Text.cpp
|
| @@ -48,55 +48,6 @@ PassRefPtr<Text> Text::createEditingText(Document& document, const String& data)
|
| return adoptRef(new Text(document, data, CreateEditingText));
|
| }
|
|
|
| -PassRefPtr<Node> Text::mergeNextSiblingNodesIfPossible()
|
| -{
|
| - RefPtr<Node> protect(this);
|
| -
|
| - // Remove empty text nodes.
|
| - if (!length()) {
|
| - // Care must be taken to get the next node before removing the current node.
|
| - RefPtr<Node> nextNode(NodeTraversal::nextPostOrder(*this));
|
| - remove(IGNORE_EXCEPTION);
|
| - return nextNode.release();
|
| - }
|
| -
|
| - // Merge text nodes.
|
| - while (Node* nextSibling = this->nextSibling()) {
|
| - if (nextSibling->nodeType() != TEXT_NODE)
|
| - break;
|
| -
|
| - RefPtr<Text> nextText = toText(nextSibling);
|
| -
|
| - // Remove empty text nodes.
|
| - if (!nextText->length()) {
|
| - nextText->remove(IGNORE_EXCEPTION);
|
| - continue;
|
| - }
|
| -
|
| - // Both non-empty text nodes. Merge them.
|
| - unsigned offset = length();
|
| - String nextTextData = nextText->data();
|
| - String oldTextData = data();
|
| - setDataWithoutUpdate(data() + nextTextData);
|
| - updateTextRenderer(oldTextData.length(), 0);
|
| -
|
| - // Empty nextText for layout update.
|
| - nextText->setDataWithoutUpdate(emptyString());
|
| - nextText->updateTextRenderer(0, nextTextData.length());
|
| -
|
| - document().didMergeTextNodes(*nextText, offset);
|
| -
|
| - // Restore nextText for mutation event.
|
| - nextText->setDataWithoutUpdate(nextTextData);
|
| - nextText->updateTextRenderer(0, 0);
|
| -
|
| - didModifyData(oldTextData);
|
| - nextText->remove(IGNORE_EXCEPTION);
|
| - }
|
| -
|
| - return NodeTraversal::nextPostOrder(*this);
|
| -}
|
| -
|
| PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionState& exceptionState)
|
| {
|
| // IndexSizeError: Raised if the specified offset is negative or greater than
|
| @@ -127,96 +78,6 @@ PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionState& exceptionState
|
| return newText.release();
|
| }
|
|
|
| -static const Text* earliestLogicallyAdjacentTextNode(const Text* t)
|
| -{
|
| - for (const Node* n = t->previousSibling(); n; n = n->previousSibling()) {
|
| - Node::NodeType type = n->nodeType();
|
| - if (type == Node::TEXT_NODE) {
|
| - t = toText(n);
|
| - continue;
|
| - }
|
| -
|
| - break;
|
| - }
|
| - return t;
|
| -}
|
| -
|
| -static const Text* latestLogicallyAdjacentTextNode(const Text* t)
|
| -{
|
| - for (const Node* n = t->nextSibling(); n; n = n->nextSibling()) {
|
| - Node::NodeType type = n->nodeType();
|
| - if (type == Node::TEXT_NODE) {
|
| - t = toText(n);
|
| - continue;
|
| - }
|
| -
|
| - break;
|
| - }
|
| - return t;
|
| -}
|
| -
|
| -String Text::wholeText() const
|
| -{
|
| - const Text* startText = earliestLogicallyAdjacentTextNode(this);
|
| - const Text* endText = latestLogicallyAdjacentTextNode(this);
|
| -
|
| - Node* onePastEndText = endText->nextSibling();
|
| - unsigned resultLength = 0;
|
| - for (const Node* n = startText; n != onePastEndText; n = n->nextSibling()) {
|
| - if (!n->isTextNode())
|
| - continue;
|
| - const String& data = toText(n)->data();
|
| - if (std::numeric_limits<unsigned>::max() - data.length() < resultLength)
|
| - CRASH();
|
| - resultLength += data.length();
|
| - }
|
| - StringBuilder result;
|
| - result.reserveCapacity(resultLength);
|
| - for (const Node* n = startText; n != onePastEndText; n = n->nextSibling()) {
|
| - if (!n->isTextNode())
|
| - continue;
|
| - result.append(toText(n)->data());
|
| - }
|
| - ASSERT(result.length() == resultLength);
|
| -
|
| - return result.toString();
|
| -}
|
| -
|
| -PassRefPtr<Text> Text::replaceWholeText(const String& newText)
|
| -{
|
| - // Remove all adjacent text nodes, and replace the contents of this one.
|
| -
|
| - // Protect startText and endText against mutation event handlers removing the last ref
|
| - RefPtr<Text> startText = const_cast<Text*>(earliestLogicallyAdjacentTextNode(this));
|
| - RefPtr<Text> endText = const_cast<Text*>(latestLogicallyAdjacentTextNode(this));
|
| -
|
| - RefPtr<Text> protectedThis(this); // Mutation event handlers could cause our last ref to go away
|
| - RefPtr<ContainerNode> parent = parentNode(); // Protect against mutation handlers moving this node during traversal
|
| - for (RefPtr<Node> n = startText; n && n != this && n->isTextNode() && n->parentNode() == parent;) {
|
| - RefPtr<Node> nodeToRemove(n.release());
|
| - n = nodeToRemove->nextSibling();
|
| - parent->removeChild(nodeToRemove.get(), IGNORE_EXCEPTION);
|
| - }
|
| -
|
| - if (this != endText) {
|
| - Node* onePastEndText = endText->nextSibling();
|
| - for (RefPtr<Node> n = nextSibling(); n && n != onePastEndText && n->isTextNode() && n->parentNode() == parent;) {
|
| - RefPtr<Node> nodeToRemove(n.release());
|
| - n = nodeToRemove->nextSibling();
|
| - parent->removeChild(nodeToRemove.get(), IGNORE_EXCEPTION);
|
| - }
|
| - }
|
| -
|
| - if (newText.isEmpty()) {
|
| - if (parent && parentNode() == parent)
|
| - parent->removeChild(this, IGNORE_EXCEPTION);
|
| - return nullptr;
|
| - }
|
| -
|
| - setData(newText);
|
| - return protectedThis.release();
|
| -}
|
| -
|
| String Text::nodeName() const
|
| {
|
| return "#text";
|
|
|