Changeset 261437 in webkit
- Timestamp:
- May 9, 2020 9:04:01 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r261430 r261437 1 2020-05-08 Darin Adler <darin@apple.com> 2 3 Streamline MarkupAccumulator to improve efficiency a bit 4 https://bugs.webkit.org/show_bug.cgi?id=211656 5 6 Reviewed by Anders Carlsson. 7 8 * b3/air/AirFixPartialRegisterStalls.h: Fix spelling of "explicitly". 9 1 10 2020-05-08 Alexey Shvayka <shvaikalesh@gmail.com> 2 11 -
trunk/Source/JavaScriptCore/b3/air/AirFixPartialRegisterStalls.h
r206525 r261437 36 36 // Some instructions update only part of a register, they can only be scheduled after 37 37 // the previous definition is computed. This problem can be avoided by the compiler 38 // by explicit ely resetting the entire register before executing the instruction with38 // by explicitly resetting the entire register before executing the instruction with 39 39 // partial update. 40 40 // -
trunk/Source/WTF/ChangeLog
r261436 r261437 1 2020-05-08 Darin Adler <darin@apple.com> 2 3 Streamline MarkupAccumulator to improve efficiency a bit 4 https://bugs.webkit.org/show_bug.cgi?id=211656 5 6 Reviewed by Anders Carlsson. 7 8 * wtf/text/StringBuilder.cpp: 9 (WTF::StringBuilder::isAllASCII const): Added. 10 * wtf/text/StringBuilder.h: Added isAllASCII. 11 1 12 2020-05-09 David Quesada <david_quesada@apple.com> 2 13 -
trunk/Source/WTF/wtf/text/StringBuilder.cpp
r254087 r261437 457 457 } 458 458 459 bool StringBuilder::isAllASCII() const 460 { 461 auto length = this->length(); 462 if (!length) 463 return true; 464 if (m_is8Bit) 465 return charactersAreAllASCII(characters8(), length); 466 return charactersAreAllASCII(characters16(), length); 467 } 468 459 469 } // namespace WTF -
trunk/Source/WTF/wtf/text/StringBuilder.h
r254087 r261437 326 326 327 327 bool is8Bit() const { return m_is8Bit; } 328 WTF_EXPORT_PRIVATE bool isAllASCII() const; 328 329 329 330 void clear() -
trunk/Source/WebCore/ChangeLog
r261434 r261437 1 2020-05-08 Darin Adler <darin@apple.com> 2 3 Streamline MarkupAccumulator to improve efficiency a bit 4 https://bugs.webkit.org/show_bug.cgi?id=211656 5 6 Reviewed by Anders Carlsson. 7 8 * editing/MarkupAccumulator.cpp: 9 (WebCore::MarkupAccumulator::appendCharactersReplacingEntities): Corrected early 10 exit so it returns any time the length is 0. For some reason the code before 11 wouldn't do the early return when offset is non-zero, which is unnecessary. 12 (WebCore::MarkupAccumulator::appendString): Deleted. 13 (WebCore::MarkupAccumulator::appendStringView): Deleted. 14 (WebCore::MarkupAccumulator::appendEndTag): Use variadic append to cut down 15 on memory allocations. 16 (WebCore::MarkupAccumulator::totalLength): Deleted. 17 (WebCore::MarkupAccumulator::concatenateMarkup): Deleted. 18 (WebCore::MarkupAccumulator::takeMarkup): Added. 19 (WebCore::MarkupAccumulator::appendQuotedURLAttributeValue): Use variadic 20 append to cut down on memory allocations. Also use char instead of UChar so 21 the string building code doesn't have to do an 8/16 bit check. 22 (WebCore::shouldAddNamespaceElement): Prepend a literal, don't bother to 23 make a String just to append to another String. Also made this a 24 non-member function. 25 (WebCore::shouldAddNamespaceAttribute): Made this a non-member function. 26 (WebCore::MarkupAccumulator::appendNamespace): Fix hash table usage 27 to use add instead of get followed by set to avoid double hashing. 28 Use variadic append to cut down on memory allocation. 29 (WebCore::MarkupAccumulator::appendText): Tweaked style to make this a 30 one-line function. 31 (WebCore::appendComment): Deleted. 32 (WebCore::appendXMLDeclaration): Made this a non-member function. 33 Use variadic append to cut down on memory allocation. 34 (WebCore::appendDocumentType): Made this a non-member function. 35 Use variadic append to cut down on memory allocation. 36 (WebCore::MarkupAccumulator::appendCDATASection): Deleted. 37 (WebCore::MarkupAccumulator::appendNonElementNode): Moved the bodies of 38 appendComment, appendProcessingInstruction, and appendCDATASection in 39 here since they can all be one-line variadic append calls. 40 41 * editing/MarkupAccumulator.h: 42 (WebCore::MarkupAccumulator::length const): Changed the return type 43 of length to be unsigned since that's what StringBuilder returns. 44 Made isAllASCII call StringBuilder::isAllASCII. Replaced appendString 45 and appendStringView with variadic append. Removed many functions 46 that no longer need to be member functions. Made appendAttributeValue 47 a static member function. Made appendNamespace private. Made 48 m_serializationSyntax const. 49 50 * editing/markup.cpp: 51 (WebCore::StyledMarkupAccumulator::wrapWithStyleNode): Use append 52 instead of appenString. 53 (WebCore::StyledMarkupAccumulator::isAllASCII const): Added. Before 54 the code would only check the StringBuilder, but we also need to 55 check m_reversedPrecedingMarkup. 56 (WebCore::StyledMarkupAccumulator::takeResults): Use CheckedUint32 57 since StringBuilder's reserveCapacity function takes unsigned, not 58 size_t. The old code, using totalLength, would just pass a size_t 59 and let it get chopped off, which didn't do any harm, but it seems 60 strange to compute a 64-bit value just to chop off the lower 32 61 bits. An alternative is to compute the 32-bit value and just let 62 it overflow. Use a modern for loop by defining a ReverseView 63 template rather than writing a confusing backwards loop. Use the 64 new takeMarkup instead of concatenateMarkup. 65 (WebCore::StyledMarkupAccumulator::appendText): Tweak coding 66 style a little bit. 67 (WebCore::StyledMarkupAccumulator::appendStartTag): Ditto. 68 (WebCore::StyledMarkupAccumulator::appendNodeToPreserveMSOList): 69 Use variadic append to cut down on memory allocations. 70 (WebCore::propertyMissingOrEqualToNone): Tweak coding style a bit. 71 (WebCore::serializePreservingVisualAppearanceInternal): Use 72 append instead of appendString. 73 (WebCore::shouldPreserveMSOLists): Take a StringView instead of a 74 String to eliminate unnecessary memory allocation in call to substring. 75 (WebCore::sanitizedMarkupForFragmentInDocument): Use makeString 76 instead of StringBuilder to cut down on memory allocation. 77 78 * html/HTMLFormElement.cpp: 79 (WebCore::HTMLFormElement::resetDefaultButton): Fix spelling error 80 in the word "explicitly". 81 * mathml/MathMLOperatorDictionary.cpp: 82 (WebCore::MathMLOperatorDictionary::search): Ditto. 83 84 * page/PageSerializer.cpp: 85 (WebCore::PageSerializer::SerializerMarkupAccumulator::SerializerMarkupAccumulator): 86 Use variadic append instead of appendString to cut down on 87 memory allocations. 88 89 * rendering/svg/SVGInlineTextBox.cpp: 90 (WebCore::SVGInlineTextBox::paint): Fix spelling error in the word 91 "explicitly". 92 1 93 2020-05-09 Jack Lee <shihchieh_lee@apple.com> 2 94 -
trunk/Source/WebCore/editing/MarkupAccumulator.cpp
r253988 r261437 161 161 void MarkupAccumulator::appendCharactersReplacingEntities(StringBuilder& result, const String& source, unsigned offset, unsigned length, EntityMask entityMask) 162 162 { 163 if (!(offset + length))164 return;165 166 163 ASSERT(offset + length <= source.length()); 164 165 if (!length) 166 return; 167 167 168 168 if (source.is8Bit()) … … 236 236 } 237 237 238 void MarkupAccumulator::appendString(const String& string)239 {240 m_markup.append(string);241 }242 243 void MarkupAccumulator::appendStringView(StringView view)244 {245 m_markup.append(view);246 }247 248 238 void MarkupAccumulator::startAppendingNode(const Node& node, Namespaces* namespaces) 249 239 { … … 261 251 if (shouldSelfClose(element, m_serializationSyntax) || (!element.hasChildNodes() && elementCannotHaveEndTag(element))) 262 252 return; 263 result.append('<'); 264 result.append('/'); 265 result.append(element.nodeNamePreservingCase()); 266 result.append('>'); 267 } 268 269 size_t MarkupAccumulator::totalLength(const Vector<String>& strings) 270 { 271 size_t length = 0; 272 for (auto& string : strings) 273 length += string.length(); 274 return length; 275 } 276 277 void MarkupAccumulator::concatenateMarkup(StringBuilder& result) 278 { 279 result.append(m_markup); 253 result.append("</", element.nodeNamePreservingCase(), '>'); 254 } 255 256 StringBuilder MarkupAccumulator::takeMarkup() 257 { 258 return std::exchange(m_markup, { }); 280 259 } 281 260 … … 294 273 ASSERT(element.isURLAttribute(attribute)); 295 274 String resolvedURLString = resolveURLIfNeeded(element, attribute.value()); 296 UChar quoteChar = '"';275 char quoteChar = '"'; 297 276 if (WTF::protocolIsJavaScript(resolvedURLString)) { 298 277 // minimal escaping for javascript urls … … 303 282 quoteChar = '\''; 304 283 } 305 result.append(quoteChar); 306 result.append(resolvedURLString); 307 result.append(quoteChar); 284 result.append(quoteChar, resolvedURLString, quoteChar); 308 285 return; 309 286 } … … 315 292 } 316 293 317 bool MarkupAccumulator::shouldAddNamespaceElement(const Element& element)294 static bool shouldAddNamespaceElement(const Element& element) 318 295 { 319 296 // Don't add namespace attribute if it is already defined for this elem. 320 const AtomString& prefix = element.prefix();297 auto& prefix = element.prefix(); 321 298 if (prefix.isEmpty()) 322 299 return !element.hasAttribute(xmlnsAtom()); 323 324 static NeverDestroyed<String> xmlnsWithColon(MAKE_STATIC_STRING_IMPL("xmlns:")); 325 return !element.hasAttribute(xmlnsWithColon.get() + prefix); 326 } 327 328 bool MarkupAccumulator::shouldAddNamespaceAttribute(const Attribute& attribute, Namespaces& namespaces) 300 return !element.hasAttribute("xmlns:" + prefix); 301 } 302 303 static bool shouldAddNamespaceAttribute(const Attribute& attribute, Namespaces& namespaces) 329 304 { 330 305 namespaces.checkConsistency(); … … 357 332 } 358 333 359 // Use emptyAtom()s's impl() for both null and empty strings since the HashMap can't handle 0 as a key 360 AtomStringImpl* pre = prefix.isEmpty() ? emptyAtom().impl() : prefix.impl(); 361 AtomStringImpl* foundNS = namespaces.get(pre); 362 if (foundNS != namespaceURI.impl()) { 363 namespaces.set(pre, namespaceURI.impl()); 364 // Add namespace to prefix pair so we can do constraint checking later. 365 if (inXMLFragmentSerialization() && !prefix.isEmpty()) 366 namespaces.set(namespaceURI.impl(), pre); 367 // Make sure xml prefix and namespace are always known to uphold the constraints listed at http://www.w3.org/TR/xml-names11/#xmlReserved. 368 if (namespaceURI.impl() == XMLNames::xmlNamespaceURI->impl()) 334 // Use emptyAtom()s's impl() for null strings since this HashMap can't handle nullptr as a key 335 auto addResult = namespaces.add(prefix.isNull() ? emptyAtom().impl() : prefix.impl(), namespaceURI.impl()); 336 if (!addResult.isNewEntry) { 337 if (addResult.iterator->value == namespaceURI.impl()) 369 338 return; 370 result.append(' ', xmlnsAtom()); 371 if (!prefix.isEmpty()) 372 result.append(':', prefix); 373 374 result.append('='); 375 result.append('"'); 376 appendAttributeValue(result, namespaceURI, false); 377 result.append('"'); 378 } 339 addResult.iterator->value = namespaceURI.impl(); 340 } 341 342 // Add namespace to prefix pair so we can do constraint checking later. 343 if (inXMLFragmentSerialization() && !prefix.isEmpty()) 344 namespaces.set(namespaceURI.impl(), prefix.impl()); 345 346 // Make sure xml prefix and namespace are always known to uphold the constraints listed at http://www.w3.org/TR/xml-names11/#xmlReserved. 347 if (namespaceURI == XMLNames::xmlNamespaceURI) 348 return; 349 350 result.append(' ', xmlnsAtom(), prefix.isEmpty() ? "" : ":", prefix, "=\""); 351 appendAttributeValue(result, namespaceURI, false); 352 result.append('"'); 379 353 } 380 354 … … 395 369 void MarkupAccumulator::appendText(StringBuilder& result, const Text& text) 396 370 { 397 const String& textData = text.data(); 398 appendCharactersReplacingEntities(result, textData, 0, textData.length(), entityMaskForText(text)); 399 } 400 401 static void appendComment(StringBuilder& result, const String& comment) 402 { 403 // FIXME: Comment content is not escaped, but XMLSerializer (and possibly other callers) should raise an exception if it includes "-->". 404 result.appendLiteral("<!--"); 405 result.append(comment); 406 result.appendLiteral("-->"); 407 } 408 409 void MarkupAccumulator::appendXMLDeclaration(StringBuilder& result, const Document& document) 371 appendCharactersReplacingEntities(result, text.data(), 0, text.length(), entityMaskForText(text)); 372 } 373 374 static void appendXMLDeclaration(StringBuilder& result, const Document& document) 410 375 { 411 376 if (!document.hasXMLDeclaration()) 412 377 return; 413 378 414 result.appendLiteral("<?xml version=\""); 415 result.append(document.xmlVersion()); 416 const String& encoding = document.xmlEncoding(); 417 if (!encoding.isEmpty()) { 418 result.appendLiteral("\" encoding=\""); 419 result.append(encoding); 420 } 421 if (document.xmlStandaloneStatus() != Document::StandaloneStatus::Unspecified) { 422 result.appendLiteral("\" standalone=\""); 423 if (document.xmlStandalone()) 424 result.appendLiteral("yes"); 425 else 426 result.appendLiteral("no"); 427 } 428 429 result.appendLiteral("\"?>"); 430 } 431 432 void MarkupAccumulator::appendDocumentType(StringBuilder& result, const DocumentType& documentType) 379 auto encoding = document.xmlEncoding(); 380 bool isStandaloneSpecified = document.xmlStandaloneStatus() != Document::StandaloneStatus::Unspecified; 381 382 result.append("<?xml version=\"", 383 document.xmlVersion(), 384 encoding.isEmpty() ? "" : "\" encoding=\"", 385 encoding, 386 isStandaloneSpecified ? (document.xmlStandalone() ? "\" standalone=\"yes" : "\" standalone=\"no") : "", 387 "\"?>"); 388 } 389 390 static void appendDocumentType(StringBuilder& result, const DocumentType& documentType) 433 391 { 434 392 if (documentType.name().isEmpty()) 435 393 return; 436 394 437 result.appendLiteral("<!DOCTYPE "); 438 result.append(documentType.name()); 439 if (!documentType.publicId().isEmpty()) { 440 result.appendLiteral(" PUBLIC \""); 441 result.append(documentType.publicId()); 442 result.append('"'); 443 if (!documentType.systemId().isEmpty()) { 444 result.append(' '); 445 result.append('"'); 446 result.append(documentType.systemId()); 447 result.append('"'); 448 } 449 } else if (!documentType.systemId().isEmpty()) { 450 result.appendLiteral(" SYSTEM \""); 451 result.append(documentType.systemId()); 452 result.append('"'); 453 } 454 result.append('>'); 455 } 456 457 void MarkupAccumulator::appendProcessingInstruction(StringBuilder& result, const String& target, const String& data) 458 { 459 // FIXME: PI data is not escaped, but XMLSerializer (and possibly other callers) this should raise an exception if it includes "?>". 460 result.append('<'); 461 result.append('?'); 462 result.append(target); 463 result.append(' '); 464 result.append(data); 465 result.append('?'); 466 result.append('>'); 395 result.append( 396 "<!DOCTYPE ", 397 documentType.name(), 398 documentType.publicId().isEmpty() ? "" : " PUBLIC \"", 399 documentType.publicId(), 400 documentType.publicId().isEmpty() ? "" : "\"", 401 documentType.systemId().isEmpty() ? "" : (documentType.publicId().isEmpty() ? " SYSTEM \"" : " \""), 402 documentType.systemId(), 403 documentType.systemId().isEmpty() ? ">" : "\">" 404 ); 467 405 } 468 406 … … 598 536 } 599 537 600 void MarkupAccumulator::appendCDATASection(StringBuilder& result, const String& section)601 {602 // FIXME: CDATA content is not escaped, but XMLSerializer (and possibly other callers) should raise an exception if it includes "]]>".603 result.appendLiteral("<![CDATA[");604 result.append(section);605 result.appendLiteral("]]>");606 }607 608 538 void MarkupAccumulator::appendNonElementNode(StringBuilder& result, const Node& node, Namespaces* namespaces) 609 539 { … … 616 546 break; 617 547 case Node::COMMENT_NODE: 618 appendComment(result, downcast<Comment>(node).data()); 548 // FIXME: Comment content is not escaped, but that may be OK because XMLSerializer (and possibly other callers) should raise an exception if it includes "-->". 549 result.append("<!--", downcast<Comment>(node).data(), "-->"); 619 550 break; 620 551 case Node::DOCUMENT_NODE: … … 627 558 break; 628 559 case Node::PROCESSING_INSTRUCTION_NODE: 629 appendProcessingInstruction(result, downcast<ProcessingInstruction>(node).target(), downcast<ProcessingInstruction>(node).data()); 560 // FIXME: PI data is not escaped, but XMLSerializer (and possibly other callers) this should raise an exception if it includes "?>". 561 result.append("<?", downcast<ProcessingInstruction>(node).target(), ' ', downcast<ProcessingInstruction>(node).data(), "?>"); 630 562 break; 631 563 case Node::ELEMENT_NODE: … … 633 565 break; 634 566 case Node::CDATA_SECTION_NODE: 635 appendCDATASection(result, downcast<CDATASection>(node).data()); 567 // FIXME: CDATA content is not escaped, but XMLSerializer (and possibly other callers) should raise an exception if it includes "]]>". 568 result.append("<![CDATA[", downcast<CDATASection>(node).data(), "]]>"); 636 569 break; 637 570 case Node::ATTRIBUTE_NODE: -
trunk/Source/WebCore/editing/MarkupAccumulator.h
r261395 r261437 68 68 69 69 protected: 70 static size_t totalLength(const Vector<String>&); 71 size_t length() const { return m_markup.length(); } 72 bool isAllASCII() const { return m_markup.toStringPreserveCapacity().isAllASCII(); } 70 unsigned length() const { return m_markup.length(); } 71 bool isAllASCII() const { return m_markup.isAllASCII(); } 73 72 74 void concatenateMarkup(StringBuilder&);73 StringBuilder takeMarkup(); 75 74 76 void appendString(const String&); 77 void appendStringView(StringView); 75 template<typename ...StringTypes> void append(StringTypes&&... strings) { m_markup.append(std::forward<StringTypes>(strings)...); } 78 76 79 77 void startAppendingNode(const Node&, Namespaces* = nullptr); 80 void endAppendingNode(const Node& node) 81 { 82 if (is<Element>(node)) 83 appendEndTag(m_markup, downcast<Element>(node)); 84 } 78 void endAppendingNode(const Node&); 85 79 86 80 virtual void appendStartTag(StringBuilder&, const Element&, Namespaces*); … … 93 87 94 88 void appendNonElementNode(StringBuilder&, const Node&, Namespaces*); 95 void appendEndMarkup(StringBuilder&, const Element&);96 89 97 void appendAttributeValue(StringBuilder&, const String&, bool isSerializingHTML); 98 void appendNamespace(StringBuilder&, const AtomString& prefix, const AtomString& namespaceURI, Namespaces&, bool allowEmptyDefaultNS = false); 99 void appendXMLDeclaration(StringBuilder&, const Document&); 100 void appendDocumentType(StringBuilder&, const DocumentType&); 101 void appendProcessingInstruction(StringBuilder&, const String& target, const String& data); 90 static void appendAttributeValue(StringBuilder&, const String&, bool isSerializingHTML); 102 91 void appendAttribute(StringBuilder&, const Element&, const Attribute&, Namespaces*); 103 void appendCDATASection(StringBuilder&, const String&);104 92 105 bool shouldAddNamespaceElement(const Element&);106 bool shouldAddNamespaceAttribute(const Attribute&, Namespaces&);107 93 EntityMask entityMaskForText(const Text&) const; 108 94 … … 110 96 111 97 private: 98 void appendNamespace(StringBuilder&, const AtomString& prefix, const AtomString& namespaceURI, Namespaces&, bool allowEmptyDefaultNS = false); 112 99 String resolveURLIfNeeded(const Element&, const String&) const; 113 100 void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Attribute&); … … 119 106 StringBuilder m_markup; 120 107 const ResolveURLs m_resolveURLs; 121 SerializationSyntax m_serializationSyntax;108 const SerializationSyntax m_serializationSyntax; 122 109 unsigned m_prefixLevel { 0 }; 123 110 }; 124 111 112 inline void MarkupAccumulator::endAppendingNode(const Node& node) 113 { 114 if (is<Element>(node)) 115 appendEndTag(m_markup, downcast<Element>(node)); 116 } 117 125 118 } // namespace WebCore -
trunk/Source/WebCore/editing/markup.cpp
r261395 r261437 87 87 using namespace HTMLNames; 88 88 89 static bool propertyMissingOrEqualToNone( StyleProperties*, CSSPropertyID);89 static bool propertyMissingOrEqualToNone(const StyleProperties*, CSSPropertyID); 90 90 91 91 class AttributeChange { … … 232 232 bool needClearingDiv() const { return m_needClearingDiv; } 233 233 234 using MarkupAccumulator::append String;234 using MarkupAccumulator::append; 235 235 236 236 ContainerNode* parentNode(Node& node) … … 243 243 void prependMetaCharsetUTF8TagIfNonASCIICharactersArePresent() 244 244 { 245 if (isAllASCII()) 246 return; 247 248 m_reversedPrecedingMarkup.append("<meta charset=\"UTF-8\">"_s); 245 if (!isAllASCII()) 246 m_reversedPrecedingMarkup.append("<meta charset=\"UTF-8\">"_s); 249 247 } 250 248 251 249 private: 250 bool isAllASCII() const; 252 251 void appendStyleNodeOpenTag(StringBuilder&, StyleProperties*, Document&, bool isBlock = false); 253 252 const String& styleNodeCloseTag(bool isBlock = false); … … 365 364 appendStyleNodeOpenTag(openTag, style, document, isBlock); 366 365 m_reversedPrecedingMarkup.append(openTag.toString()); 367 append String(styleNodeCloseTag(isBlock));366 append(styleNodeCloseTag(isBlock)); 368 367 } 369 368 … … 387 386 } 388 387 388 bool StyledMarkupAccumulator::isAllASCII() const 389 { 390 for (auto& preceding : m_reversedPrecedingMarkup) { 391 if (!preceding.isAllASCII()) 392 return false; 393 } 394 return MarkupAccumulator::isAllASCII(); 395 } 396 397 // Stopgap until C++20 adds std::ranges::reverse_view. 398 template<typename Collection> struct ReverseView { 399 Collection& collection; 400 decltype(collection.rbegin()) begin() const { return collection.rbegin(); } 401 decltype(collection.rend()) end() const { return collection.rend(); } 402 decltype(collection.size()) size() const { return collection.size(); } 403 ReverseView(Collection& collection) 404 : collection(collection) 405 { 406 } 407 }; 408 389 409 String StyledMarkupAccumulator::takeResults() 390 410 { 411 CheckedUint32 length = this->length(); 412 for (auto& string : m_reversedPrecedingMarkup) 413 length += string.length(); 391 414 StringBuilder result; 392 result.reserveCapacity(totalLength(m_reversedPrecedingMarkup) + length()); 393 394 for (size_t i = m_reversedPrecedingMarkup.size(); i > 0; --i) 395 result.append(m_reversedPrecedingMarkup[i - 1]); 396 397 concatenateMarkup(result); 398 399 // We remove '\0' characters because they are not visibly rendered to the user. 415 result.reserveCapacity(length.unsafeGet()); 416 for (auto& string : ReverseView { m_reversedPrecedingMarkup }) 417 result.append(string); 418 result.append(takeMarkup()); 419 // Remove '\0' characters because they are not visibly rendered to the user. 400 420 return result.toString().replaceWithLiteral('\0', ""); 401 421 } … … 406 426 const bool wrappingSpan = shouldApplyWrappingStyle(text) && !parentIsTextarea; 407 427 if (wrappingSpan) { 408 RefPtr<EditingStyle>wrappingStyle = m_wrappingStyle->copy();428 auto wrappingStyle = m_wrappingStyle->copy(); 409 429 // FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance 410 430 // Make sure spans are inline style in paste side e.g. span { display: block }. … … 565 585 out.appendLiteral(" style=\""); 566 586 appendAttributeValue(out, newInlineStyle->style()->asText(), documentIsHTML); 567 out.append(' \"');587 out.append('"'); 568 588 } 569 589 } … … 722 742 return false; 723 743 724 append String("<head><style class=\"" WebKitMSOListQuirksStyle "\">\n<!--\n");725 appendStringView(StringView(textChild.data()).substring(start, msoListDefinitionsEnd - start + 3));726 appendString("\n-->\n</style></head>");744 append("<head><style class=\"" WebKitMSOListQuirksStyle "\">\n<!--\n", 745 StringView(textChild.data()).substring(start, msoListDefinitionsEnd - start + 3), 746 "\n-->\n</style></head>"); 727 747 728 748 return true; … … 755 775 } 756 776 757 static bool propertyMissingOrEqualToNone( StyleProperties* style, CSSPropertyID propertyID)777 static bool propertyMissingOrEqualToNone(const StyleProperties* style, CSSPropertyID propertyID) 758 778 { 759 779 if (!style) 760 780 return false; 761 RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); 762 if (!value) 763 return true; 764 if (!is<CSSPrimitiveValue>(*value)) 765 return false; 766 return downcast<CSSPrimitiveValue>(*value).valueID() == CSSValueNone; 781 auto value = style->getPropertyCSSValue(propertyID); 782 return !value || (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).valueID() == CSSValueNone); 767 783 } 768 784 … … 870 886 return interchangeNewlineString; 871 887 872 accumulator.append String(interchangeNewlineString);888 accumulator.append(interchangeNewlineString.get()); 873 889 startAdjustedForInterchangeNewline = visibleStart.next().deepEquivalent(); 874 890 … … 916 932 if (accumulator.needRelativeStyleWrapper() && needsPositionStyleConversion) { 917 933 if (accumulator.needClearingDiv()) 918 accumulator.append String("<div style=\"clear: both;\"></div>");934 accumulator.append("<div style=\"clear: both;\"></div>"); 919 935 RefPtr<EditingStyle> positionRelativeStyle = styleFromMatchedRulesAndInlineDecl(*body); 920 936 positionRelativeStyle->style()->setProperty(CSSPropertyPosition, CSSValueRelative); … … 924 940 // FIXME: The interchange newline should be placed in the block that it's in, not after all of the content, unconditionally. 925 941 if (annotate == AnnotateForInterchange::Yes && needInterchangeNewlineAfter(visibleEnd.previous())) 926 accumulator.append String(interchangeNewlineString);942 accumulator.append(interchangeNewlineString.get()); 927 943 928 944 #if PLATFORM(COCOA) … … 931 947 accumulator.prependMetaCharsetUTF8TagIfNonASCIICharactersArePresent(); 932 948 #endif 949 933 950 return accumulator.takeResults(); 934 951 } … … 946 963 } 947 964 948 949 static bool shouldPreserveMSOLists(const String& markup) 965 static bool shouldPreserveMSOLists(StringView markup) 950 966 { 951 967 if (!markup.startsWith("<html xmlns:")) … … 954 970 if (tagClose == notFound) 955 971 return false; 956 auto htmlTag = markup.substring(0, tagClose);957 return htmlTag.contains("xmlns:o=\"urn:schemas-microsoft-com:office:office\"")958 && htmlTag.contains("xmlns:w=\"urn:schemas-microsoft-com:office:word\"");972 auto tag = markup.substring(0, tagClose); 973 return tag.contains("xmlns:o=\"urn:schemas-microsoft-com:office:office\"") 974 && tag.contains("xmlns:w=\"urn:schemas-microsoft-com:office:word\""); 959 975 } 960 976 … … 972 988 ResolveURLs::YesExcludingLocalFileURLsForPrivacy, SerializeComposedTree::No, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, StandardFontFamilySerializationMode::Strip, msoListMode); 973 989 974 StringBuilder builder; 975 if (msoListMode == MSOListMode::Preserve) { 976 builder.appendLiteral("<html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n" 977 "xmlns:w=\"urn:schemas-microsoft-com:office:word\"\n" 978 "xmlns:m=\"http://schemas.microsoft.com/office/2004/12/omml\"\n" 979 "xmlns=\"http://www.w3.org/TR/REC-html40\">"); 980 } 981 982 builder.append(result); 983 984 if (msoListMode == MSOListMode::Preserve) 985 builder.appendLiteral("</html>"); 986 987 return builder.toString(); 990 if (msoListMode != MSOListMode::Preserve) 991 return result; 992 993 return makeString( 994 "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n" 995 "xmlns:w=\"urn:schemas-microsoft-com:office:word\"\n" 996 "xmlns:m=\"http://schemas.microsoft.com/office/2004/12/omml\"\n" 997 "xmlns=\"http://www.w3.org/TR/REC-html40\">", 998 result, 999 "</html>"); 988 1000 } 989 1001 -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r261013 r261437 715 715 // Computing the default button is not cheap, we don't want to do it unless needed. 716 716 // If there was no default button set, the only style to invalidate is the element 717 // being added to the form. This is done explicit ely in registerFormElement().717 // being added to the form. This is done explicitly in registerFormElement(). 718 718 return; 719 719 } -
trunk/Source/WebCore/mathml/MathMLOperatorDictionary.cpp
r250216 r261437 1139 1139 return WTF::nullopt; 1140 1140 1141 // If we did not find the desired operator form and if it was not set explicit ely, we use the first one in the following order: Infix, Prefix, Postfix.1141 // If we did not find the desired operator form and if it was not set explicitly, we use the first one in the following order: Infix, Prefix, Postfix. 1142 1142 // This is to handle bad MathML markup without explicit <mrow> delimiters like "<mo>(</mo><mi>a</mi><mo>)</mo><mo>(</mo><mi>b</mi><mo>)</mo>" where innerfences should not be considered infix. 1143 1143 if (auto* entry = tryBinarySearch<const Entry, UChar32>(dictionary, dictionarySize, character, ExtractChar)) { -
trunk/Source/WebCore/page/PageSerializer.cpp
r260709 r261437 114 114 , m_document(document) 115 115 { 116 // MarkupAccumulator does not serialize the <?xml ... line, so we add it explicit ely to ensure the right encoding is specified.116 // MarkupAccumulator does not serialize the <?xml ... line, so we add it explicitly to ensure the right encoding is specified. 117 117 if (m_document.isXMLDocument() || m_document.xmlStandalone()) 118 append String("<?xml version=\"" + m_document.xmlVersion() + "\" encoding=\"" + m_document.charset() +"\"?>");118 append("<?xml version=\"", m_document.xmlVersion(), "\" encoding=\"", m_document.charset(), "\"?>"); 119 119 } 120 120 -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r258508 r261437 241 241 return; 242 242 243 // Note: We're explicit ely not supporting composition & custom underlines and custom highlighters - unlike InlineTextBox.243 // Note: We're explicitly not supporting composition & custom underlines and custom highlighters - unlike InlineTextBox. 244 244 // If we ever need that for SVG, it's very easy to refactor and reuse the code. 245 245 -
trunk/Tools/ChangeLog
r261429 r261437 1 2020-05-08 Darin Adler <darin@apple.com> 2 3 Streamline MarkupAccumulator to improve efficiency a bit 4 https://bugs.webkit.org/show_bug.cgi?id=211656 5 6 Reviewed by Anders Carlsson. 7 8 * TestWebKitAPI/Tests/WTF/StringImpl.cpp: 9 (TestWebKitAPI::TEST): Fix spellling error in the word "explicitly". 10 1 11 2020-05-08 David Kilzer <ddkilzer@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
r255125 r261437 42 42 ASSERT_TRUE(stringWithTemplate->is8Bit()); 43 43 44 // Constructor taking the size explicit ely.44 // Constructor taking the size explicitly. 45 45 const char* programmaticStringData = "Explicit Size Literal"; 46 46 auto programmaticString = StringImpl::createFromLiteral(programmaticStringData, strlen(programmaticStringData));
Note: See TracChangeset
for help on using the changeset viewer.