diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.cc | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.cc b/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.cc index 5837555ddcd..83320613a45 100644 --- a/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.cc +++ b/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.cc @@ -51,7 +51,7 @@ using namespace html_names; struct EntityDescription { UChar entity; - const CString& reference; + const std::string& reference; EntityMask mask; }; @@ -71,8 +71,8 @@ static inline void AppendCharactersReplacingEntitiesInternal( entity_maps[entity_index].mask & entity_mask) { result.Append(text + position_after_last_entity, i - position_after_last_entity); - const CString& replacement = entity_maps[entity_index].reference; - result.Append(replacement.data(), replacement.length()); + const std::string& replacement = entity_maps[entity_index].reference; + result.Append(replacement.c_str(), replacement.length()); position_after_last_entity = i + 1; break; } @@ -88,14 +88,14 @@ void MarkupFormatter::AppendCharactersReplacingEntities( unsigned offset, unsigned length, EntityMask entity_mask) { - DEFINE_STATIC_LOCAL(const CString, amp_reference, ("&")); - DEFINE_STATIC_LOCAL(const CString, lt_reference, ("<")); - DEFINE_STATIC_LOCAL(const CString, gt_reference, (">")); - DEFINE_STATIC_LOCAL(const CString, quot_reference, (""")); - DEFINE_STATIC_LOCAL(const CString, nbsp_reference, (" ")); - DEFINE_STATIC_LOCAL(const CString, tab_reference, ("	")); - DEFINE_STATIC_LOCAL(const CString, line_feed_reference, (" ")); - DEFINE_STATIC_LOCAL(const CString, carriage_return_reference, (" ")); + DEFINE_STATIC_LOCAL(const std::string, amp_reference, ("&")); + DEFINE_STATIC_LOCAL(const std::string, lt_reference, ("<")); + DEFINE_STATIC_LOCAL(const std::string, gt_reference, (">")); + DEFINE_STATIC_LOCAL(const std::string, quot_reference, (""")); + DEFINE_STATIC_LOCAL(const std::string, nbsp_reference, (" ")); + DEFINE_STATIC_LOCAL(const std::string, tab_reference, ("	")); + DEFINE_STATIC_LOCAL(const std::string, line_feed_reference, (" ")); + DEFINE_STATIC_LOCAL(const std::string, carriage_return_reference, (" ")); static const EntityDescription kEntityMaps[] = { {'&', amp_reference, kEntityAmp}, @@ -379,7 +379,7 @@ void MarkupFormatter::AppendCDATASection(StringBuilder& result, } EntityMask MarkupFormatter::EntityMaskForText(const Text& text) const { - if (!SerializeAsHTMLDocument(text)) + if (!SerializeAsHTML()) return kEntityMaskInPCDATA; // TODO(hajimehoshi): We need to switch EditingStrategy. @@ -405,7 +405,7 @@ EntityMask MarkupFormatter::EntityMaskForText(const Text& text) const { // separate end tag. // 4. Other elements self-close. bool MarkupFormatter::ShouldSelfClose(const Element& element) const { - if (SerializeAsHTMLDocument(element)) + if (SerializeAsHTML()) return false; if (element.HasChildren()) return false; @@ -414,10 +414,8 @@ bool MarkupFormatter::ShouldSelfClose(const Element& element) const { return true; } -bool MarkupFormatter::SerializeAsHTMLDocument(const Node& node) const { - if (serialization_type_ == SerializationType::kForcedXML) - return false; - return node.GetDocument().IsHTMLDocument(); +bool MarkupFormatter::SerializeAsHTML() const { + return serialization_type_ == SerializationType::kHTML; } } // namespace blink |