| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Remove empty text nodes. | 59 // Remove empty text nodes. |
| 60 if (!length()) { | 60 if (!length()) { |
| 61 // Care must be taken to get the next node before removing the current n
ode. | 61 // Care must be taken to get the next node before removing the current n
ode. |
| 62 RefPtrWillBeRawPtr<Node> nextNode(NodeTraversal::nextPostOrder(*this)); | 62 RefPtrWillBeRawPtr<Node> nextNode(NodeTraversal::nextPostOrder(*this)); |
| 63 remove(IGNORE_EXCEPTION); | 63 remove(IGNORE_EXCEPTION); |
| 64 return nextNode.release(); | 64 return nextNode.release(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Merge text nodes. | 67 // Merge text nodes. |
| 68 while (Node* nextSibling = this->nextSibling()) { | 68 while (Node* nextSibling = this->nextSibling()) { |
| 69 if (nextSibling->nodeType() != TEXT_NODE) | 69 if (nextSibling->getNodeType() != TEXT_NODE) |
| 70 break; | 70 break; |
| 71 | 71 |
| 72 RefPtrWillBeRawPtr<Text> nextText = toText(nextSibling); | 72 RefPtrWillBeRawPtr<Text> nextText = toText(nextSibling); |
| 73 | 73 |
| 74 // Remove empty text nodes. | 74 // Remove empty text nodes. |
| 75 if (!nextText->length()) { | 75 if (!nextText->length()) { |
| 76 nextText->remove(IGNORE_EXCEPTION); | 76 nextText->remove(IGNORE_EXCEPTION); |
| 77 continue; | 77 continue; |
| 78 } | 78 } |
| 79 | 79 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 if (parentNode()) | 129 if (parentNode()) |
| 130 document().didSplitTextNode(*this); | 130 document().didSplitTextNode(*this); |
| 131 | 131 |
| 132 return newText.release(); | 132 return newText.release(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 static const Text* earliestLogicallyAdjacentTextNode(const Text* t) | 135 static const Text* earliestLogicallyAdjacentTextNode(const Text* t) |
| 136 { | 136 { |
| 137 for (const Node* n = t->previousSibling(); n; n = n->previousSibling()) { | 137 for (const Node* n = t->previousSibling(); n; n = n->previousSibling()) { |
| 138 Node::NodeType type = n->nodeType(); | 138 Node::NodeType type = n->getNodeType(); |
| 139 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { | 139 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { |
| 140 t = toText(n); | 140 t = toText(n); |
| 141 continue; | 141 continue; |
| 142 } | 142 } |
| 143 | 143 |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 return t; | 146 return t; |
| 147 } | 147 } |
| 148 | 148 |
| 149 static const Text* latestLogicallyAdjacentTextNode(const Text* t) | 149 static const Text* latestLogicallyAdjacentTextNode(const Text* t) |
| 150 { | 150 { |
| 151 for (const Node* n = t->nextSibling(); n; n = n->nextSibling()) { | 151 for (const Node* n = t->nextSibling(); n; n = n->nextSibling()) { |
| 152 Node::NodeType type = n->nodeType(); | 152 Node::NodeType type = n->getNodeType(); |
| 153 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { | 153 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { |
| 154 t = toText(n); | 154 t = toText(n); |
| 155 continue; | 155 continue; |
| 156 } | 156 } |
| 157 | 157 |
| 158 break; | 158 break; |
| 159 } | 159 } |
| 160 return t; | 160 return t; |
| 161 } | 161 } |
| 162 | 162 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 setData(newText); | 221 setData(newText); |
| 222 return protectedThis.release(); | 222 return protectedThis.release(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 String Text::nodeName() const | 225 String Text::nodeName() const |
| 226 { | 226 { |
| 227 return "#text"; | 227 return "#text"; |
| 228 } | 228 } |
| 229 | 229 |
| 230 Node::NodeType Text::nodeType() const | 230 Node::NodeType Text::getNodeType() const |
| 231 { | 231 { |
| 232 return TEXT_NODE; | 232 return TEXT_NODE; |
| 233 } | 233 } |
| 234 | 234 |
| 235 PassRefPtrWillBeRawPtr<Node> Text::cloneNode(bool /*deep*/) | 235 PassRefPtrWillBeRawPtr<Node> Text::cloneNode(bool /*deep*/) |
| 236 { | 236 { |
| 237 return cloneWithData(data()); | 237 return cloneWithData(data()); |
| 238 } | 238 } |
| 239 | 239 |
| 240 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Text* t
ext) | 240 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Text* t
ext) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 362 } |
| 363 | 363 |
| 364 if (layoutObjectIsNeeded == !!layoutObject()) | 364 if (layoutObjectIsNeeded == !!layoutObject()) |
| 365 return; | 365 return; |
| 366 | 366 |
| 367 // The following is almost the same as Node::reattach() except that we creat
e a layoutObject only if needed. | 367 // The following is almost the same as Node::reattach() except that we creat
e a layoutObject only if needed. |
| 368 // Not calling reattach() to avoid repeated calls to Text::textLayoutObjectI
sNeeded(). | 368 // Not calling reattach() to avoid repeated calls to Text::textLayoutObjectI
sNeeded(). |
| 369 AttachContext reattachContext(context); | 369 AttachContext reattachContext(context); |
| 370 reattachContext.performingReattach = true; | 370 reattachContext.performingReattach = true; |
| 371 | 371 |
| 372 if (styleChangeType() < NeedsReattachStyleChange) | 372 if (getStyleChangeType() < NeedsReattachStyleChange) |
| 373 detach(reattachContext); | 373 detach(reattachContext); |
| 374 if (layoutObjectIsNeeded) | 374 if (layoutObjectIsNeeded) |
| 375 LayoutTreeBuilderForText(*this, layoutParent->layoutObject()).createLayo
utObject(); | 375 LayoutTreeBuilderForText(*this, layoutParent->layoutObject()).createLayo
utObject(); |
| 376 CharacterData::attach(reattachContext); | 376 CharacterData::attach(reattachContext); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) | 379 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) |
| 380 { | 380 { |
| 381 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { | 381 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { |
| 382 if (change != NoChange || needsStyleRecalc()) | 382 if (change != NoChange || needsStyleRecalc()) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 result.appendLiteral("; "); | 440 result.appendLiteral("; "); |
| 441 result.appendLiteral("value="); | 441 result.appendLiteral("value="); |
| 442 result.append(s); | 442 result.append(s); |
| 443 } | 443 } |
| 444 | 444 |
| 445 strncpy(buffer, result.toString().utf8().data(), length - 1); | 445 strncpy(buffer, result.toString().utf8().data(), length - 1); |
| 446 } | 446 } |
| 447 #endif | 447 #endif |
| 448 | 448 |
| 449 } // namespace blink | 449 } // namespace blink |
| OLD | NEW |