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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 static const Text* earliestLogicallyAdjacentTextNode(const Text* t) | 92 static const Text* earliestLogicallyAdjacentTextNode(const Text* t) |
93 { | 93 { |
94 const Node* n = t; | 94 const Node* n = t; |
95 while ((n = n->previousSibling())) { | 95 while ((n = n->previousSibling())) { |
96 Node::NodeType type = n->nodeType(); | 96 Node::NodeType type = n->nodeType(); |
97 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { | 97 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { |
98 t = static_cast<const Text*>(n); | 98 t = static_cast<const Text*>(n); |
99 continue; | 99 continue; |
100 } | 100 } |
101 | 101 |
102 // We would need to visit EntityReference child text nodes if they exist
ed | |
103 ASSERT(type != Node::ENTITY_REFERENCE_NODE || !n->hasChildNodes()); | |
104 break; | 102 break; |
105 } | 103 } |
106 return t; | 104 return t; |
107 } | 105 } |
108 | 106 |
109 static const Text* latestLogicallyAdjacentTextNode(const Text* t) | 107 static const Text* latestLogicallyAdjacentTextNode(const Text* t) |
110 { | 108 { |
111 const Node* n = t; | 109 const Node* n = t; |
112 while ((n = n->nextSibling())) { | 110 while ((n = n->nextSibling())) { |
113 Node::NodeType type = n->nodeType(); | 111 Node::NodeType type = n->nodeType(); |
114 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { | 112 if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) { |
115 t = static_cast<const Text*>(n); | 113 t = static_cast<const Text*>(n); |
116 continue; | 114 continue; |
117 } | 115 } |
118 | 116 |
119 // We would need to visit EntityReference child text nodes if they exist
ed | |
120 ASSERT(type != Node::ENTITY_REFERENCE_NODE || !n->hasChildNodes()); | |
121 break; | 117 break; |
122 } | 118 } |
123 return t; | 119 return t; |
124 } | 120 } |
125 | 121 |
126 String Text::wholeText() const | 122 String Text::wholeText() const |
127 { | 123 { |
128 const Text* startText = earliestLogicallyAdjacentTextNode(this); | 124 const Text* startText = earliestLogicallyAdjacentTextNode(this); |
129 const Text* endText = latestLogicallyAdjacentTextNode(this); | 125 const Text* endText = latestLogicallyAdjacentTextNode(this); |
130 | 126 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 result.appendLiteral("; "); | 347 result.appendLiteral("; "); |
352 result.appendLiteral("value="); | 348 result.appendLiteral("value="); |
353 result.append(s); | 349 result.append(s); |
354 } | 350 } |
355 | 351 |
356 strncpy(buffer, result.toString().utf8().data(), length - 1); | 352 strncpy(buffer, result.toString().utf8().data(), length - 1); |
357 } | 353 } |
358 #endif | 354 #endif |
359 | 355 |
360 } // namespace WebCore | 356 } // namespace WebCore |
OLD | NEW |