Changeset 26474 in webkit
- Timestamp:
- Oct 12, 2007 7:41:35 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r26469 r26474 1 2007-10-02 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Oliver. 4 5 - test updates for "file:///Volumes/Data/mjs/Work/src/Safari/OpenSource/LayoutTests/fast/dom/serialize-attribute.xhtml" 6 http://bugs.webkit.org/show_bug.cgi?id=15339 7 8 We no longer entity-escape the '>' character in content or attribute values since this is unnecessary. 9 10 * fast/dom/dom-parse-serialize-expected.txt: 11 * fast/dom/serialize-attribute.xhtml: 12 * fast/xsl/xslt-processor-expected.txt: 13 1 14 2007-10-02 Nicholas Shanks <webkit@nickshanks.com> 2 15 -
trunk/LayoutTests/fast/dom/serialize-attribute.xhtml
r18484 r26474 12 12 serialized = (new XMLSerializer()).serializeToString(document.getElementById("testDiv\"'&<>")); 13 13 if (serialized == "<div xmlns=\"http://www.w3.org/1999/xhtml\" id=\"testDiv"'&<>\"/>" || 14 serialized == "<div xmlns=\"http://www.w3.org/1999/xhtml\" id=\"testDiv"'&<>\"></div>") 14 serialized == "<div xmlns=\"http://www.w3.org/1999/xhtml\" id=\"testDiv"'&<>\"></div>" || 15 serialized == "<div xmlns=\"http://www.w3.org/1999/xhtml\" id=\"testDiv"'&<>\"/>" || 16 serialized == "<div xmlns=\"http://www.w3.org/1999/xhtml\" id=\"testDiv"'&<>\"></div>") 15 17 document.getElementById("result").textContent = "SUCCESS"; 16 18 else -
trunk/LayoutTests/fast/xsl/xslt-processor-expected.txt
r21687 r26474 1 1 0.1 original xml: 2 <?xml-stylesheet type="text/xsl" href="xslt-text.xsl"?><TEST>SOURCE XML: <<<&тест& >>></TEST>2 <?xml-stylesheet type="text/xsl" href="xslt-text.xsl"?><TEST>SOURCE XML: <<<&тест&>>></TEST> 3 3 0.2 xsl1: 4 4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 5 5 6 6 <xsl:output method="text" encoding="KOI8-R"/> 7 <xsl:template match="TEST">CHARACTERS IN XSLT: <<<&тест& >>>7 <xsl:template match="TEST">CHARACTERS IN XSLT: <<<&тест&>>> 8 8 <xsl:apply-templates/><xsl:text> 9 9 </xsl:text></xsl:template> … … 38 38 1.1 Import two different stylesheets: 39 39 <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body> 40 CHARACTERS IN XSLT: ééééééééééé <br><br>SOURCE XML: <<<&тест& >>>40 CHARACTERS IN XSLT: ééééééééééé <br><br>SOURCE XML: <<<&тест&>>> 41 41 </body></html> 42 42 1.2 Import same stylesheet twice: … … 44 44 <head><title></title></head> 45 45 <body> 46 <pre>CHARACTERS IN XSLT: <<<&тест& >>>47 SOURCE XML: <<<&тест& >>>46 <pre>CHARACTERS IN XSLT: <<<&тест&>>> 47 SOURCE XML: <<<&тест&>>> 48 48 </pre> 49 49 </body> -
trunk/WebCore/ChangeLog
r26471 r26474 1 2007-10-02 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Oliver. 4 5 - Use Vector<UChar> instead of DeprecatedString for innerHTML, for 35% speedup on CK DOM test 6 http://bugs.webkit.org/show_bug.cgi?id=15339 7 8 Rewrote both versions of createMarkup to build based on 9 Vector<UChar> instead of String. Also other miscellaneous 10 speedups (mainly content strings are now encoded in a way that 11 doesn't take a function call per character, and switch is avoided). 12 13 This also causes a functional change - we no longer escape '>' since this was unnecessary and it's faster 14 to avoid testing for it. See updated test results. 15 16 * editing/markup.cpp: 17 (WebCore::appendString): 18 (WebCore::appendAttributeValue): 19 (WebCore::escapeContentText): 20 (WebCore::appendEscapedContent): 21 (WebCore::appendDeprecatedString): 22 (WebCore::appendQuotedURLAttributeValue): 23 (WebCore::stringValueForRange): 24 (WebCore::ucharRange): 25 (WebCore::appendUCharRange): 26 (WebCore::appendNamespace): 27 (WebCore::appendStartMarkup): 28 (WebCore::getStartMarkup): 29 (WebCore::appendEndMarkup): 30 (WebCore::getEndMarkup): 31 (WebCore::appendMarkup): 32 (WebCore::joinMarkups): 33 (WebCore::createMarkup): 34 * editing/markup.h: 35 * page/mac/WebCoreFrameBridge.mm: 36 (-[WebCoreFrameBridge markupStringFromNode:nodes:]): 37 (-[WebCoreFrameBridge markupStringFromRange:nodes:]): 38 1 39 2007-10-02 Maciej Stachowiak <mjs@apple.com> 2 40 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r26459 r26474 13203 13203 isa = PBXProject; 13204 13204 buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; 13205 compatibilityVersion = "Xcode 2.4"; 13205 13206 hasScannedForEncodings = 1; 13206 13207 knownRegions = ( -
trunk/WebCore/editing/markup.cpp
r26470 r26474 87 87 }; 88 88 89 static DeprecatedString escapeTextForMarkup(const String& in, bool isAttributeValue) 90 { 91 DeprecatedString s = ""; 92 93 unsigned len = in.length(); 89 static inline void appendString(Vector<UChar>& result, const String& str) 90 { 91 result.append(str.characters(), str.length()); 92 } 93 94 static void appendAttributeValue(Vector<UChar>& result, const String& attr) 95 { 96 const UChar* uchars = attr.characters(); 97 unsigned len = attr.length(); 98 unsigned lastCopiedFrom = 0; 99 100 static const String ampEntity("&"); 101 static const String ltEntity("<"); 102 static const String quotEntity("""); 103 94 104 for (unsigned i = 0; i < len; ++i) { 95 switch (in[i]) { 105 UChar c = uchars[i]; 106 switch (c) { 96 107 case '&': 97 s += "&"; 108 result.append(uchars + lastCopiedFrom, i - lastCopiedFrom); 109 appendString(result, ampEntity); 110 lastCopiedFrom = i + 1; 98 111 break; 99 112 case '<': 100 s += "<"; 101 break; 102 case '>': 103 s += ">"; 113 result.append(uchars + lastCopiedFrom, i - lastCopiedFrom); 114 appendString(result, ltEntity); 115 lastCopiedFrom = i + 1; 104 116 break; 105 117 case '"': 106 if (isAttributeValue) { 107 s += """; 108 break; 109 } 110 // fall through 111 default: 112 s += DeprecatedChar(in[i]); 113 } 114 } 118 result.append(uchars + lastCopiedFrom, i - lastCopiedFrom); 119 appendString(result, quotEntity); 120 lastCopiedFrom = i + 1; 121 } 122 } 123 124 result.append(uchars + lastCopiedFrom, len - lastCopiedFrom); 125 } 126 127 static DeprecatedString escapeContentText(const String& in) 128 { 129 DeprecatedString s = ""; 130 131 unsigned len = in.length(); 132 unsigned lastCopiedFrom = 0; 133 134 const UChar* uchars = in.characters(); 135 const DeprecatedChar* dchars = reinterpret_cast<const DeprecatedChar*>(uchars); 136 137 for (unsigned i = 0; i < len; ++i) { 138 UChar c = uchars[i]; 139 if (c == '&' | c == '<') { 140 s.append(dchars + lastCopiedFrom, i - lastCopiedFrom); 141 if (c == '&') 142 s += "&"; 143 else 144 s += "<"; 145 lastCopiedFrom = i + 1; 146 } 147 } 148 149 s.append(dchars + lastCopiedFrom, len - lastCopiedFrom); 115 150 116 151 return s; 117 152 } 118 119 static String urlAttributeToQuotedString(String urlString) 120 { 121 UChar quoteChar = '"'; 153 154 155 static void appendEscapedContent(Vector<UChar>& result, pair<const UChar*, size_t> range) 156 { 157 const UChar* uchars = range.first; 158 unsigned len = range.second; 159 unsigned lastCopiedFrom = 0; 160 161 static const String ampEntity("&"); 162 static const String ltEntity("<"); 163 164 for (unsigned i = 0; i < len; ++i) { 165 UChar c = uchars[i]; 166 if (c == '&' | c == '<') { 167 result.append(uchars + lastCopiedFrom, i - lastCopiedFrom); 168 if (c == '&') 169 appendString(result, ampEntity); 170 else 171 appendString(result, ltEntity); 172 lastCopiedFrom = i + 1; 173 } 174 } 175 176 result.append(uchars + lastCopiedFrom, len - lastCopiedFrom); 177 } 178 179 static inline void appendDeprecatedString(Vector<UChar>& result, const DeprecatedString& str) 180 { 181 result.append(reinterpret_cast<const UChar*>(str.unicode()), str.length()); 182 } 183 184 static void appendQuotedURLAttributeValue(Vector<UChar>& result, String urlString) 185 { 186 UChar quoteChar = '\"'; 122 187 if (urlString.stripWhiteSpace().startsWith("javascript:", false)) { 123 188 // minimal escaping for javascript urls 124 if (urlString.contains(' "')) {189 if (urlString.contains('\"')) { 125 190 if (urlString.contains('\'')) 126 urlString.replace(' "', """);191 urlString.replace('\"', """); 127 192 else 128 193 quoteChar = '\''; 129 194 } 130 } else 131 // FIXME this does not fully match other browsers. Firefox escapes spaces and other special characters. 132 urlString = escapeTextForMarkup(urlString.deprecatedString(), true); 133 134 String res; 135 res.append(quoteChar); 136 res.append(urlString); 137 res.append(quoteChar); 138 return res; 139 } 140 195 result.append(quoteChar); 196 appendString(result, urlString); 197 result.append(quoteChar); 198 return; 199 } 200 201 // FIXME this does not fully match other browsers. Firefox escapes spaces and other special characters. 202 result.append(quoteChar); 203 appendAttributeValue(result, urlString); 204 result.append(quoteChar); 205 } 206 141 207 static String stringValueForRange(const Node *node, const Range *range) 142 208 { 209 if (!range) 210 return node->nodeValue(); 211 143 212 String str = node->nodeValue().copy(); 213 ExceptionCode ec; 214 if (node == range->endContainer(ec)) 215 str.truncate(range->endOffset(ec)); 216 if (node == range->startContainer(ec)) 217 str.remove(0, range->startOffset(ec)); 218 return str; 219 } 220 221 static inline pair<const UChar*, size_t> ucharRange(const Node *node, const Range *range) 222 { 223 String str = node->nodeValue(); 224 const UChar* characters = str.characters(); 225 size_t length = str.length(); 226 144 227 if (range) { 145 228 ExceptionCode ec; 146 229 if (node == range->endContainer(ec)) 147 str.truncate(range->endOffset(ec)); 148 if (node == range->startContainer(ec)) 149 str.remove(0, range->startOffset(ec)); 150 } 151 return str; 152 } 153 230 length = range->endOffset(ec); 231 if (node == range->startContainer(ec)) { 232 size_t start = range->startOffset(ec); 233 characters += start; 234 length -= start; 235 } 236 } 237 238 return make_pair(characters, length); 239 } 240 241 static inline void appendUCharRange(Vector<UChar>& result, const pair<const UChar*, size_t> range) 242 { 243 result.append(range.first, range.second); 244 } 245 154 246 static String renderedText(const Node* node, const Range* range) 155 247 { … … 228 320 } 229 321 230 static String addNamespace(const AtomicString& prefix, const AtomicString& ns, HashMap<AtomicStringImpl*, AtomicStringImpl*>& namespaces)322 static void appendNamespace(Vector<UChar>& result, const AtomicString& prefix, const AtomicString& ns, HashMap<AtomicStringImpl*, AtomicStringImpl*>& namespaces) 231 323 { 232 324 if (ns.isEmpty()) 233 return "";234 325 return; 326 235 327 // Use emptyAtoms's impl() for both null and empty strings since the HashMap can't handle 0 as a key 236 328 AtomicStringImpl* pre = prefix.isEmpty() ? emptyAtom.impl() : prefix.impl(); … … 238 330 if (foundNS != ns.impl()) { 239 331 namespaces.set(pre, ns.impl()); 240 return " xmlns" + (!prefix.isEmpty() ? ":" + prefix : "") + "=\"" + escapeTextForMarkup(ns, true) + "\""; 241 } 242 243 return ""; 244 } 245 246 static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnotateForInterchange annotate, bool convertBlocksToInlines = false, HashMap<AtomicStringImpl*, AtomicStringImpl*>* namespaces = 0) 332 static const String xmlns("xmlns"); 333 result.append(' '); 334 appendString(result, xmlns); 335 if (!prefix.isEmpty()) { 336 result.append(':'); 337 appendString(result, prefix); 338 } 339 340 result.append('='); 341 result.append('"'); 342 appendAttributeValue(result, ns); 343 result.append('"'); 344 } 345 } 346 347 static void appendStartMarkup(Vector<UChar>& result, const Node *node, const Range *range, EAnnotateForInterchange annotate, bool convertBlocksToInlines = false, HashMap<AtomicStringImpl*, AtomicStringImpl*>* namespaces = 0) 247 348 { 248 349 bool documentIsHTML = node->document()->isHTMLDocument(); … … 251 352 if (Node* parent = node->parentNode()) { 252 353 if (parent->hasTagName(listingTag) 253 || parent->hasTagName(scriptTag) 254 || parent->hasTagName(styleTag) 255 || parent->hasTagName(textareaTag) 256 || parent->hasTagName(xmpTag)) 257 return stringValueForRange(node, range).deprecatedString(); 258 } 259 bool useRenderedText = annotate && !enclosingNodeWithTag(const_cast<Node*>(node), selectTag); 260 DeprecatedString markup = escapeTextForMarkup(useRenderedText ? renderedText(node, range) : stringValueForRange(node, range), false); 261 return annotate ? convertHTMLTextToInterchangeFormat(markup, static_cast<const Text*>(node)) : markup; 354 || parent->hasTagName(scriptTag) 355 || parent->hasTagName(styleTag) 356 || parent->hasTagName(textareaTag) 357 || parent->hasTagName(xmpTag)) { 358 appendUCharRange(result, ucharRange(node, range)); 359 break; 360 } 361 } 362 if (!annotate) { 363 appendEscapedContent(result, ucharRange(node, range)); 364 break; 365 } 366 367 bool useRenderedText = !enclosingNodeWithTag(const_cast<Node*>(node), selectTag); 368 DeprecatedString markup = escapeContentText(useRenderedText ? renderedText(node, range) : stringValueForRange(node, range)); 369 if (annotate) 370 markup = convertHTMLTextToInterchangeFormat(markup, static_cast<const Text*>(node)); 371 appendDeprecatedString(result, markup); 372 break; 262 373 } 263 374 case Node::COMMENT_NODE: 264 return static_cast<const Comment*>(node)->toString().deprecatedString(); 375 appendString(result, static_cast<const Comment*>(node)->toString()); 376 break; 265 377 case Node::DOCUMENT_NODE: { 378 // FIXME: I think the comment below (and therefore this code) is wrong now 266 379 // Documents do not normally contain a docType as a child node, force it to print here instead. 267 380 const DocumentType* docType = static_cast<const Document*>(node)->doctype(); 268 381 if (docType) 269 return docType->toString().deprecatedString();270 return "";382 appendString(result, docType->toString()); 383 break; 271 384 } 272 385 case Node::DOCUMENT_FRAGMENT_NODE: 273 return "";386 break; 274 387 case Node::DOCUMENT_TYPE_NODE: 275 return static_cast<const DocumentType*>(node)->toString().deprecatedString(); 388 appendString(result, static_cast<const DocumentType*>(node)->toString()); 389 break; 276 390 case Node::PROCESSING_INSTRUCTION_NODE: 277 return static_cast<const ProcessingInstruction*>(node)->toString().deprecatedString(); 391 appendString(result, static_cast<const ProcessingInstruction*>(node)->toString()); 392 break; 278 393 case Node::ELEMENT_NODE: { 279 DeprecatedString markup = DeprecatedChar('<');394 result.append('<'); 280 395 const Element* el = static_cast<const Element*>(node); 281 convertBlocksToInlines &=isBlock(const_cast<Node*>(node));282 markup += el->nodeNamePreservingCase().deprecatedString();396 bool convert = convertBlocksToInlines & isBlock(const_cast<Node*>(node)); 397 appendString(result, el->nodeNamePreservingCase()); 283 398 NamedAttrMap *attrs = el->attributes(); 284 399 unsigned length = attrs->length(); 285 400 if (!documentIsHTML && namespaces && shouldAddNamespaceElem(el)) 286 markup += addNamespace(el->prefix(), el->namespaceURI(), *namespaces).deprecatedString();401 appendNamespace(result, el->prefix(), el->namespaceURI(), *namespaces); 287 402 288 403 for (unsigned int i = 0; i < length; i++) { 289 404 Attribute *attr = attrs->attributeItem(i); 290 405 // We'll handle the style attribute separately, below. 291 if (attr->name() == styleAttr && el->isHTMLElement() && (annotate || convert BlocksToInlines))406 if (attr->name() == styleAttr && el->isHTMLElement() && (annotate || convert)) 292 407 continue; 408 result.append(' '); 409 293 410 if (documentIsHTML) 294 markup += " " + attr->name().localName().deprecatedString();411 appendString(result, attr->name().localName()); 295 412 else 296 markup += " " + attr->name().toString().deprecatedString(); 413 appendString(result, attr->name().toString()); 414 415 result.append('='); 416 297 417 if (el->isURLAttribute(attr)) 298 markup += "=" + urlAttributeToQuotedString(attr->value()).deprecatedString(); 299 else 300 markup += "=\"" + escapeTextForMarkup(attr->value(), true) + "\""; 418 appendQuotedURLAttributeValue(result, attr->value()); 419 else { 420 result.append('\"'); 421 appendAttributeValue(result, attr->value()); 422 result.append('\"'); 423 } 424 301 425 if (!documentIsHTML && namespaces && shouldAddNamespaceAttr(attr, *namespaces)) 302 markup += addNamespace(attr->prefix(), attr->namespaceURI(), *namespaces).deprecatedString();426 appendNamespace(result, attr->prefix(), attr->namespaceURI(), *namespaces); 303 427 } 304 428 305 if (el->isHTMLElement() && (annotate || convert BlocksToInlines)) {429 if (el->isHTMLElement() && (annotate || convert)) { 306 430 Element* element = const_cast<Element*>(el); 307 431 RefPtr<CSSMutableStyleDeclaration> style = static_cast<HTMLElement*>(element)->getInlineStyleDecl()->copy(); … … 310 434 style->merge(styleFromMatchedRules.get()); 311 435 } 312 if (convert BlocksToInlines)436 if (convert) 313 437 style->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE, true); 314 if (style->length() > 0) 315 markup += " style=\"" + escapeTextForMarkup(style->cssText(), true) + "\""; 438 if (style->length() > 0) { 439 static const String stylePrefix(" style=\""); 440 appendString(result, stylePrefix); 441 appendAttributeValue(result, style->cssText()); 442 result.append('\"'); 443 } 316 444 } 317 445 318 446 if (shouldSelfClose(el)) { 319 447 if (el->isHTMLElement()) 320 markup += " "; // XHTML 1.0 <-> HTML compatibility. 321 markup += "/>"; 322 } else 323 markup += ">"; 324 325 return markup; 448 result.append(' '); // XHTML 1.0 <-> HTML compatibility. 449 result.append('/'); 450 } 451 result.append('>'); 452 break; 326 453 } 327 454 case Node::CDATA_SECTION_NODE: 328 return static_cast<const CDATASection*>(node)->toString().deprecatedString(); 455 appendString(result, static_cast<const CDATASection*>(node)->toString()); 456 break; 329 457 case Node::ATTRIBUTE_NODE: 330 458 case Node::ENTITY_NODE: … … 332 460 case Node::NOTATION_NODE: 333 461 case Node::XPATH_NAMESPACE_NODE: 462 ASSERT_NOT_REACHED(); 334 463 break; 335 464 } 336 return ""; 465 } 466 467 static String getStartMarkup(const Node *node, const Range *range, EAnnotateForInterchange annotate, bool convertBlocksToInlines = false, HashMap<AtomicStringImpl*, AtomicStringImpl*>* namespaces = 0) 468 { 469 Vector<UChar> result; 470 appendStartMarkup(result, node, range, annotate, convertBlocksToInlines, namespaces); 471 return String::adopt(result); 337 472 } 338 473 … … 362 497 } 363 498 364 static DeprecatedString endMarkup(const Node *node) 365 { 366 if (node->isElementNode() && !shouldSelfClose(node) && (node->hasChildNodes() || !doesHTMLForbidEndTag(node))) 367 return "</" + static_cast<const Element*>(node)->nodeNamePreservingCase().deprecatedString() + ">"; 368 return ""; 369 } 370 371 static DeprecatedString markup(Node* startNode, bool onlyIncludeChildren, Vector<Node*>* nodes, const HashMap<AtomicStringImpl*, AtomicStringImpl*>* namespaces = 0) 499 static void appendEndMarkup(Vector<UChar>& result, const Node* node) 500 { 501 if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes() && doesHTMLForbidEndTag(node))) 502 return; 503 504 result.append('<'); 505 result.append('/'); 506 appendString(result, static_cast<const Element*>(node)->nodeNamePreservingCase()); 507 result.append('>'); 508 } 509 510 static String getEndMarkup(const Node *node) 511 { 512 Vector<UChar> result; 513 appendEndMarkup(result, node); 514 return String::adopt(result); 515 } 516 517 static void appendMarkup(Vector<UChar>& result, Node* startNode, bool onlyIncludeChildren, Vector<Node*>* nodes, const HashMap<AtomicStringImpl*, AtomicStringImpl*>* namespaces = 0) 372 518 { 373 519 HashMap<AtomicStringImpl*, AtomicStringImpl*> namespaceHash; … … 375 521 namespaceHash = *namespaces; 376 522 377 DeprecatedString me = "";378 523 if (!onlyIncludeChildren) { 379 524 if (nodes) 380 525 nodes->append(startNode); 381 me += startMarkup(startNode, 0, DoNotAnnotateForInterchange, false, &namespaceHash); 526 527 appendStartMarkup(result,startNode, 0, DoNotAnnotateForInterchange, false, &namespaceHash); 382 528 } 383 529 // print children 384 530 if (!(startNode->document()->isHTMLDocument() && doesHTMLForbidEndTag(startNode))) 385 531 for (Node* current = startNode->firstChild(); current; current = current->nextSibling()) 386 me += markup(current, false, nodes, &namespaceHash);532 appendMarkup(result, current, false, nodes, &namespaceHash); 387 533 388 534 // Print my ending tag 389 535 if (!onlyIncludeChildren) 390 me += endMarkup(startNode); 391 392 return me; 536 appendEndMarkup(result, startNode); 393 537 } 394 538 … … 461 605 } 462 606 607 String joinMarkups(const Vector<String> preMarkups, const Vector<String>& postMarkups) 608 { 609 size_t length = 0; 610 611 size_t preCount = preMarkups.size(); 612 for (size_t i = 0; i < preCount; ++i) 613 length += preMarkups[i].length(); 614 615 size_t postCount = postMarkups.size(); 616 for (size_t i = 0; i < postCount; ++i) 617 length += postMarkups[i].length(); 618 619 Vector<UChar> result; 620 result.reserveCapacity(length); 621 622 for (size_t i = preCount; i > 0; --i) 623 appendString(result, preMarkups[i - 1]); 624 625 for (size_t i = 0; i < postCount; ++i) 626 appendString(result, postMarkups[i]); 627 628 return String::adopt(result); 629 } 630 463 631 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForInterchange? 464 632 // FIXME: At least, annotation and style info should probably not be included in range.markupString() 465 DeprecatedString createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterchange annotate, bool convertBlocksToInlines)466 { 467 static const DeprecatedString interchangeNewlineString = DeprecatedString("<br class=\"") + AppleInterchangeNewline + "\">";633 String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterchange annotate, bool convertBlocksToInlines) 634 { 635 static const String interchangeNewlineString = String("<br class=\"") + AppleInterchangeNewline + "\">"; 468 636 469 637 if (!range || range->isDetached()) … … 494 662 document->updateLayoutIgnorePendingStylesheets(); 495 663 496 DeprecatedStringList markups; 664 Vector<String> markups; 665 Vector<String> preMarkups; 497 666 Node* pastEnd = updatedRange->pastEndNode(); 498 667 Node* lastClosed = 0; … … 534 703 // Add the node to the markup. 535 704 if (addMarkupForNode) { 536 markups.append( startMarkup(n, updatedRange.get(), annotate));705 markups.append(getStartMarkup(n, updatedRange.get(), annotate)); 537 706 if (nodes) 538 707 nodes->append(n); … … 542 711 // Node has no children, or we are skipping it's descendants, add its close tag now. 543 712 if (addMarkupForNode) { 544 markups.append( endMarkup(n));713 markups.append(getEndMarkup(n)); 545 714 lastClosed = n; 546 715 } … … 555 724 break; 556 725 // Not at the end of the range, close ancestors up to sibling of next node. 557 markups.append( endMarkup(ancestor));726 markups.append(getEndMarkup(ancestor)); 558 727 lastClosed = ancestor; 559 728 ancestorsToClose.removeLast(); … … 571 740 // or b) ancestors that we never encountered during a pre-order traversal starting at startNode: 572 741 ASSERT(startNode->isDescendantOf(parent)); 573 markups.prepend(startMarkup(parent, updatedRange.get(), annotate));574 markups.append( endMarkup(parent));742 preMarkups.append(getStartMarkup(parent, updatedRange.get(), annotate)); 743 markups.append(getEndMarkup(parent)); 575 744 if (nodes) 576 745 nodes->append(parent); … … 634 803 635 804 if (style->length()) { 636 markups.prepend("<div style=\"" + escapeTextForMarkup(style->cssText(), true) + "\">"); 637 markups.append("</div>"); 805 Vector<UChar> openTag; 806 static const String divStyle("<div style=\""); 807 appendString(openTag, divStyle); 808 appendAttributeValue(openTag, style->cssText()); 809 openTag.append('\"'); 810 openTag.append('>'); 811 preMarkups.append(String::adopt(openTag)); 812 813 static const String divCloseTag("</div>"); 814 markups.append(divCloseTag); 638 815 } 639 816 } else { 640 markups.prepend(startMarkup(ancestor, updatedRange.get(), annotate, convertBlocksToInlines));641 markups.append( endMarkup(ancestor));817 preMarkups.append(getStartMarkup(ancestor, updatedRange.get(), annotate, convertBlocksToInlines)); 818 markups.append(getEndMarkup(ancestor)); 642 819 } 643 820 if (nodes) … … 668 845 669 846 if (style->length() > 0) { 670 DeprecatedString openTag = DeprecatedString("<span class=\"") + AppleStyleSpanClass + "\" style=\"" + escapeTextForMarkup(style->cssText(), true) + "\">"; 671 markups.prepend(openTag); 672 markups.append("</span>"); 847 Vector<UChar> openTag; 848 const String spanClassStyle = String("<span class=\"" AppleStyleSpanClass "\" style=\""); 849 appendString(openTag, spanClassStyle); 850 appendAttributeValue(openTag, style->cssText()); 851 openTag.append('\"'); 852 openTag.append('>'); 853 preMarkups.append(String::adopt(openTag)); 854 855 static const String spanCloseTag("</span>"); 856 markups.append(spanCloseTag); 673 857 } 674 858 } … … 685 869 for (Node *ancestor = lastClosed->parentNode(); ancestor; ancestor = ancestor->parentNode()) { 686 870 if (isMailBlockquote(ancestor)) { 687 markups.prepend(startMarkup(ancestor, updatedRange.get(), annotate));688 markups.append( endMarkup(ancestor));871 preMarkups.append(getStartMarkup(ancestor, updatedRange.get(), annotate)); 872 markups.append(getEndMarkup(ancestor)); 689 873 } 690 874 } … … 694 878 deleteButton->enable(); 695 879 696 return markups.join("");880 return joinMarkups(preMarkups, markups); 697 881 } 698 882 … … 711 895 } 712 896 713 DeprecatedString createMarkup(const Node* node, EChildrenOnly includeChildren, 714 Vector<Node*>* nodes, EAnnotateForInterchange annotate) 715 { 716 ASSERT(annotate == DoNotAnnotateForInterchange); // annotation not yet implemented for this code path 897 String createMarkup(const Node* node, EChildrenOnly includeChildren, Vector<Node*>* nodes) 898 { 899 Vector<UChar> result; 717 900 718 901 if (!node) … … 730 913 } 731 914 732 DeprecatedString result(markup(const_cast<Node*>(node), includeChildren, nodes));915 appendMarkup(result, const_cast<Node*>(node), includeChildren, nodes); 733 916 734 917 if (deleteButton) 735 918 deleteButton->enable(); 736 919 737 return result;920 return String::adopt(result); 738 921 } 739 922 -
trunk/WebCore/editing/markup.h
r20542 r26474 45 45 PassRefPtr<DocumentFragment> createFragmentFromNodes(Document*, const Vector<Node*>&); 46 46 47 DeprecatedString createMarkup(const Range*,47 String createMarkup(const Range*, 48 48 Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false); 49 DeprecatedString createMarkup(const Node*, EChildrenOnly = IncludeNode, 50 Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange); 49 String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0); 51 50 52 51 } -
trunk/WebCore/page/mac/WebCoreFrameBridge.mm
r25547 r26474 344 344 // FIXME: This is never "for interchange". Is that right? See the next method. 345 345 Vector<Node*> nodeList; 346 NSString *markupString = createMarkup([node _node], IncludeNode, nodes ? &nodeList : 0) .getNSString();346 NSString *markupString = createMarkup([node _node], IncludeNode, nodes ? &nodeList : 0); 347 347 if (nodes) 348 348 *nodes = [self nodesFromList:&nodeList]; … … 355 355 // FIXME: This is always "for interchange". Is that right? See the previous method. 356 356 Vector<Node*> nodeList; 357 NSString *markupString = createMarkup([range _range], nodes ? &nodeList : 0, AnnotateForInterchange) .getNSString();357 NSString *markupString = createMarkup([range _range], nodes ? &nodeList : 0, AnnotateForInterchange); 358 358 if (nodes) 359 359 *nodes = [self nodesFromList:&nodeList];
Note: See TracChangeset
for help on using the changeset viewer.