summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaocheng Hu <xiaochengh@chromium.org>2019-11-22 03:02:42 +0000
committerMichael Brüning <michael.bruning@qt.io>2020-03-24 12:10:56 +0000
commit1a2d6d8df67cf3f47adfa9979eb4a73637e58f58 (patch)
tree750c0a6f8307f2f56b3ba09cd3e5355af97ec4aa
parent604ef94f4f9e82a555109d87532bff6fb6739f41 (diff)
downloadqtwebengine-chromium-1a2d6d8df67cf3f47adfa9979eb4a73637e58f58.tar.gz
[Backport] Dependency for CVE-2020-6391
Manual backport of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/1927207: Pack CreateMarkup() optional parameters into CreateMarkupOptions CreateMarkup() has too many option parameters. This patch packs them into a CreateMarkupOptions object, to improve code readability and make callers easier to call CreateMarkup() without the need to understand all different parameters. This is also a preparation for crrev.com/c/1922919 where we need to add another parameter to CreateMarkup(). Change-Id: Ia97490279ec027b88c61fbc6de482b1310cabcf6 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--chromium/third_party/blink/renderer/core/editing/BUILD.gn2
-rw-r--r--chromium/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc7
-rw-r--r--chromium/third_party/blink/renderer/core/editing/frame_selection.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.cc36
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.h62
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/html_interchange.h5
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.h2
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.h4
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/serialization.cc50
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/serialization.h15
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.cc13
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.h12
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.cc12
-rw-r--r--chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.h13
-rw-r--r--chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc14
17 files changed, 168 insertions, 91 deletions
diff --git a/chromium/third_party/blink/renderer/core/editing/BUILD.gn b/chromium/third_party/blink/renderer/core/editing/BUILD.gn
index ea78e473a3d..14b789276c2 100644
--- a/chromium/third_party/blink/renderer/core/editing/BUILD.gn
+++ b/chromium/third_party/blink/renderer/core/editing/BUILD.gn
@@ -255,6 +255,8 @@ blink_core_sources("editing") {
"selection_template.cc",
"selection_template.h",
"selection_type.h",
+ "serializers/create_markup_options.cc",
+ "serializers/create_markup_options.h",
"serializers/html_interchange.cc",
"serializers/html_interchange.h",
"serializers/markup_accumulator.cc",
diff --git a/chromium/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc b/chromium/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc
index 34feb5af574..3139bf6409c 100644
--- a/chromium/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc
+++ b/chromium/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc
@@ -1477,9 +1477,10 @@ void CompositeEditCommand::MoveParagraphs(
GetDocument(),
CreateMarkup(start.ParentAnchoredEquivalent(),
end.ParentAnchoredEquivalent(),
- kDoNotAnnotateForInterchange,
- ConvertBlocksToInlines::kConvert,
- kDoNotResolveURLs, constraining_ancestor),
+ CreateMarkupOptions::Builder()
+ .SetShouldConvertBlocksToInlines(true)
+ .SetConstrainingAncestor(constraining_ancestor)
+ .Build()),
"", kDisallowScriptingAndPluginContent)
: nullptr;
diff --git a/chromium/third_party/blink/renderer/core/editing/frame_selection.cc b/chromium/third_party/blink/renderer/core/editing/frame_selection.cc
index e2971565e29..899539715c5 100644
--- a/chromium/third_party/blink/renderer/core/editing/frame_selection.cc
+++ b/chromium/third_party/blink/renderer/core/editing/frame_selection.cc
@@ -935,9 +935,11 @@ String FrameSelection::SelectedHTMLForClipboard() const {
ComputeVisibleSelectionInFlatTree();
const EphemeralRangeInFlatTree& range =
visible_selection.ToNormalizedEphemeralRange();
- return CreateMarkup(
- range.StartPosition(), range.EndPosition(), kAnnotateForInterchange,
- ConvertBlocksToInlines::kNotConvert, kResolveNonLocalURLs);
+ return CreateMarkup(range.StartPosition(), range.EndPosition(),
+ CreateMarkupOptions::Builder()
+ .SetShouldAnnotateForInterchange(true)
+ .SetShouldResolveURLs(kResolveNonLocalURLs)
+ .Build());
}
String FrameSelection::SelectedText(
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.cc b/chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.cc
new file mode 100644
index 00000000000..d726657e2aa
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.cc
@@ -0,0 +1,36 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/editing/serializers/create_markup_options.h"
+
+namespace blink {
+
+CreateMarkupOptions::Builder&
+CreateMarkupOptions::Builder::SetConstrainingAncestor(const Node* node) {
+ data_.constraining_ancestor_ = node;
+ return *this;
+}
+
+CreateMarkupOptions::Builder&
+CreateMarkupOptions::Builder::SetShouldResolveURLs(
+ AbsoluteURLs should_resolve_urls) {
+ data_.should_resolve_urls_ = should_resolve_urls;
+ return *this;
+}
+
+CreateMarkupOptions::Builder&
+CreateMarkupOptions::Builder::SetShouldAnnotateForInterchange(
+ bool annotate_for_interchange) {
+ data_.should_annotate_for_interchange_ = annotate_for_interchange;
+ return *this;
+}
+
+CreateMarkupOptions::Builder&
+CreateMarkupOptions::Builder::SetShouldConvertBlocksToInlines(
+ bool convert_blocks_to_inlines) {
+ data_.should_convert_blocks_to_inlines_ = convert_blocks_to_inlines;
+ return *this;
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.h b/chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.h
new file mode 100644
index 00000000000..fe0faa255ec
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/create_markup_options.h
@@ -0,0 +1,62 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SERIALIZERS_CREATE_MARKUP_OPTIONS_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SERIALIZERS_CREATE_MARKUP_OPTIONS_H_
+
+#include "third_party/blink/renderer/core/core_export.h"
+#include "third_party/blink/renderer/platform/heap/handle.h"
+
+namespace blink {
+
+class Node;
+
+enum AbsoluteURLs { kDoNotResolveURLs, kResolveAllURLs, kResolveNonLocalURLs };
+
+class CORE_EXPORT CreateMarkupOptions final {
+ STACK_ALLOCATED();
+
+ public:
+ class CORE_EXPORT Builder;
+
+ CreateMarkupOptions() = default;
+
+ const Node* ConstrainingAncestor() const { return constraining_ancestor_; }
+ AbsoluteURLs ShouldResolveURLs() const { return should_resolve_urls_; }
+ bool ShouldAnnotateForInterchange() const {
+ return should_annotate_for_interchange_;
+ }
+ bool ShouldConvertBlocksToInlines() const {
+ return should_convert_blocks_to_inlines_;
+ }
+
+ private:
+ Member<const Node> constraining_ancestor_;
+ AbsoluteURLs should_resolve_urls_ = kDoNotResolveURLs;
+ bool should_annotate_for_interchange_ = false;
+ bool should_convert_blocks_to_inlines_ = false;
+};
+
+class CORE_EXPORT CreateMarkupOptions::Builder final {
+ STACK_ALLOCATED();
+
+ public:
+ Builder() = default;
+ explicit Builder(const CreateMarkupOptions& options) : data_(options) {}
+
+ CreateMarkupOptions Build() const { return data_; }
+
+ Builder& SetConstrainingAncestor(const Node* node);
+ Builder& SetShouldResolveURLs(AbsoluteURLs absolute_urls);
+ Builder& SetShouldAnnotateForInterchange(bool annotate_for_interchange);
+ Builder& SetShouldConvertBlocksToInlines(bool convert_blocks_for_inlines);
+
+ private:
+ CreateMarkupOptions data_;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SERIALIZERS_CREATE_MARKUP_OPTIONS_H_
+
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/html_interchange.h b/chromium/third_party/blink/renderer/core/editing/serializers/html_interchange.h
index f2065d0fa70..bdc114e8736 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/html_interchange.h
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/html_interchange.h
@@ -34,11 +34,6 @@ class Text;
#define AppleInterchangeNewline "Apple-interchange-newline"
-enum EAnnotateForInterchange {
- kDoNotAnnotateForInterchange,
- kAnnotateForInterchange
-};
-
String ConvertHTMLTextToInterchangeFormat(const String&, const Text&);
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.cc b/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.cc
index f9b7c87e6a1..6c14e9bc39b 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.cc
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.cc
@@ -46,7 +46,7 @@
namespace blink {
-MarkupAccumulator::MarkupAccumulator(EAbsoluteURLs resolve_urls_method,
+MarkupAccumulator::MarkupAccumulator(AbsoluteURLs resolve_urls_method,
SerializationType serialization_type)
: formatter_(resolve_urls_method, serialization_type) {}
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.h b/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.h
index 54ed11c0ed6..3dcab52691c 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.h
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/markup_accumulator.h
@@ -44,7 +44,7 @@ class MarkupAccumulator {
STACK_ALLOCATED();
public:
- MarkupAccumulator(EAbsoluteURLs,
+ MarkupAccumulator(AbsoluteURLs,
SerializationType = SerializationType::kAsOwnerDocument);
virtual ~MarkupAccumulator();
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 536ffd21a6b..b7429e09d60 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
@@ -122,7 +122,7 @@ void MarkupFormatter::AppendCharactersReplacingEntities(
}
}
-MarkupFormatter::MarkupFormatter(EAbsoluteURLs resolve_urls_method,
+MarkupFormatter::MarkupFormatter(AbsoluteURLs resolve_urls_method,
SerializationType serialization_type)
: resolve_urls_method_(resolve_urls_method),
serialization_type_(serialization_type) {}
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.h b/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.h
index 31693ee08ea..e21c5582b8f 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.h
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/markup_formatter.h
@@ -90,7 +90,7 @@ class MarkupFormatter final {
const String& data);
static void AppendXMLDeclaration(StringBuilder&, const Document&);
- MarkupFormatter(EAbsoluteURLs,
+ MarkupFormatter(AbsoluteURLs,
SerializationType = SerializationType::kAsOwnerDocument);
~MarkupFormatter();
@@ -118,7 +118,7 @@ class MarkupFormatter final {
const Element&,
const Attribute&);
- const EAbsoluteURLs resolve_urls_method_;
+ const AbsoluteURLs resolve_urls_method_;
SerializationType serialization_type_;
DISALLOW_COPY_AND_ASSIGN(MarkupFormatter);
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/serialization.cc b/chromium/third_party/blink/renderer/core/editing/serializers/serialization.cc
index 4aacc70ee44..f73131d5465 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/serialization.cc
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/serialization.cc
@@ -170,8 +170,7 @@ template <typename Strategy>
static HTMLElement* HighestAncestorToWrapMarkup(
const PositionTemplate<Strategy>& start_position,
const PositionTemplate<Strategy>& end_position,
- EAnnotateForInterchange should_annotate,
- Node* constraining_ancestor) {
+ const CreateMarkupOptions& options) {
Node* first_node = start_position.NodeAsRangeFirstNode();
// For compatibility reason, we use container node of start and end
// positions rather than first node and last node in selection.
@@ -180,7 +179,7 @@ static HTMLElement* HighestAncestorToWrapMarkup(
*end_position.ComputeContainerNode());
DCHECK(common_ancestor);
HTMLElement* special_common_ancestor = nullptr;
- if (should_annotate == kAnnotateForInterchange) {
+ if (options.ShouldAnnotateForInterchange()) {
// Include ancestors that aren't completely inside the range but are
// required to retain the structure and appearance of the copied markup.
special_common_ancestor =
@@ -217,6 +216,16 @@ static HTMLElement* HighestAncestorToWrapMarkup(
Node* check_ancestor =
special_common_ancestor ? special_common_ancestor : common_ancestor;
if (check_ancestor->GetLayoutObject()) {
+ // We want to constrain the ancestor to the enclosing block.
+ // Ex: <b><p></p></b> is an ill-formed html and we don't want to return <b>
+ // as the ancestor because paragraph element is the enclosing block of the
+ // start and end positions provided to this API.
+ // TODO(editing-dev): Make |HighestEnclosingNodeOfType| take const pointer
+ // to remove the |const_cast| below.
+ Node* constraining_ancestor =
+ options.ConstrainingAncestor()
+ ? const_cast<Node*>(options.ConstrainingAncestor())
+ : EnclosingBlock(check_ancestor);
HTMLElement* new_special_common_ancestor =
ToHTMLElement(HighestEnclosingNodeOfType(
Position::FirstPositionInNode(*check_ancestor),
@@ -255,10 +264,7 @@ class CreateMarkupAlgorithm {
static String CreateMarkup(
const PositionTemplate<Strategy>& start_position,
const PositionTemplate<Strategy>& end_position,
- EAnnotateForInterchange should_annotate = kDoNotAnnotateForInterchange,
- ConvertBlocksToInlines = ConvertBlocksToInlines::kNotConvert,
- EAbsoluteURLs should_resolve_urls = kDoNotResolveURLs,
- Node* constraining_ancestor = nullptr);
+ const CreateMarkupOptions& options = CreateMarkupOptions());
};
// FIXME: Shouldn't we omit style info when annotate ==
@@ -269,10 +275,7 @@ template <typename Strategy>
String CreateMarkupAlgorithm<Strategy>::CreateMarkup(
const PositionTemplate<Strategy>& start_position,
const PositionTemplate<Strategy>& end_position,
- EAnnotateForInterchange should_annotate,
- ConvertBlocksToInlines convert_blocks_to_inlines,
- EAbsoluteURLs should_resolve_urls,
- Node* constraining_ancestor) {
+ const CreateMarkupOptions& options) {
if (start_position.IsNull() || end_position.IsNull())
return g_empty_string;
@@ -294,33 +297,24 @@ String CreateMarkupAlgorithm<Strategy>::CreateMarkup(
document->Lifecycle());
HTMLElement* special_common_ancestor = HighestAncestorToWrapMarkup<Strategy>(
- start_position, end_position, should_annotate, constraining_ancestor);
- StyledMarkupSerializer<Strategy> serializer(
- should_resolve_urls, should_annotate, start_position, end_position,
- special_common_ancestor, convert_blocks_to_inlines);
+ start_position, end_position, options);
+ StyledMarkupSerializer<Strategy> serializer(start_position, end_position,
+ special_common_ancestor, options);
return serializer.CreateMarkup();
}
String CreateMarkup(const Position& start_position,
const Position& end_position,
- EAnnotateForInterchange should_annotate,
- ConvertBlocksToInlines convert_blocks_to_inlines,
- EAbsoluteURLs should_resolve_urls,
- Node* constraining_ancestor) {
+ const CreateMarkupOptions& options) {
return CreateMarkupAlgorithm<EditingStrategy>::CreateMarkup(
- start_position, end_position, should_annotate, convert_blocks_to_inlines,
- should_resolve_urls, constraining_ancestor);
+ start_position, end_position, options);
}
String CreateMarkup(const PositionInFlatTree& start_position,
const PositionInFlatTree& end_position,
- EAnnotateForInterchange should_annotate,
- ConvertBlocksToInlines convert_blocks_to_inlines,
- EAbsoluteURLs should_resolve_urls,
- Node* constraining_ancestor) {
+ const CreateMarkupOptions& options) {
return CreateMarkupAlgorithm<EditingInFlatTreeStrategy>::CreateMarkup(
- start_position, end_position, should_annotate, convert_blocks_to_inlines,
- should_resolve_urls, constraining_ancestor);
+ start_position, end_position, options);
}
DocumentFragment* CreateFragmentFromMarkup(
@@ -447,7 +441,7 @@ DocumentFragment* CreateFragmentFromMarkupWithContext(
String CreateMarkup(const Node* node,
EChildrenOnly children_only,
- EAbsoluteURLs should_resolve_urls) {
+ AbsoluteURLs should_resolve_urls) {
if (!node)
return "";
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/serialization.h b/chromium/third_party/blink/renderer/core/editing/serializers/serialization.h
index 0dc9a4f9255..ac5f6eea011 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/serialization.h
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/serialization.h
@@ -30,6 +30,7 @@
#include "third_party/blink/renderer/core/css_property_names.h"
#include "third_party/blink/renderer/core/dom/parser_content_policy.h"
#include "third_party/blink/renderer/core/editing/forward.h"
+#include "third_party/blink/renderer/core/editing/serializers/create_markup_options.h"
#include "third_party/blink/renderer/core/editing/serializers/html_interchange.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
@@ -45,8 +46,6 @@ class Node;
class CSSPropertyValueSet;
enum EChildrenOnly { kIncludeNode, kChildrenOnly };
-enum EAbsoluteURLs { kDoNotResolveURLs, kResolveAllURLs, kResolveNonLocalURLs };
-enum class ConvertBlocksToInlines { kNotConvert, kConvert };
DocumentFragment* CreateFragmentFromText(const EphemeralRange& context,
const String& text);
@@ -86,22 +85,16 @@ void ReplaceChildrenWithText(ContainerNode*, const String&, ExceptionState&);
CORE_EXPORT String CreateMarkup(const Node*,
EChildrenOnly = kIncludeNode,
- EAbsoluteURLs = kDoNotResolveURLs);
+ AbsoluteURLs = kDoNotResolveURLs);
CORE_EXPORT String
CreateMarkup(const Position& start,
const Position& end,
- EAnnotateForInterchange = kDoNotAnnotateForInterchange,
- ConvertBlocksToInlines = ConvertBlocksToInlines::kNotConvert,
- EAbsoluteURLs = kDoNotResolveURLs,
- Node* constraining_ancestor = nullptr);
+ const CreateMarkupOptions& options = CreateMarkupOptions());
CORE_EXPORT String
CreateMarkup(const PositionInFlatTree& start,
const PositionInFlatTree& end,
- EAnnotateForInterchange = kDoNotAnnotateForInterchange,
- ConvertBlocksToInlines = ConvertBlocksToInlines::kNotConvert,
- EAbsoluteURLs = kDoNotResolveURLs,
- Node* constraining_ancestor = nullptr);
+ const CreateMarkupOptions& options = CreateMarkupOptions());
void MergeWithNextTextNode(Text*, ExceptionState&);
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.cc b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.cc
index 5cd195d3c4c..89159597149 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.cc
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.cc
@@ -52,18 +52,17 @@ size_t TotalLength(const Vector<String>& strings) {
using namespace HTMLNames;
StyledMarkupAccumulator::StyledMarkupAccumulator(
- EAbsoluteURLs should_resolve_urls,
const TextOffset& start,
const TextOffset& end,
Document* document,
- EAnnotateForInterchange should_annotate,
- ConvertBlocksToInlines convert_blocks_to_inlines)
- : formatter_(should_resolve_urls),
+ const CreateMarkupOptions& options)
+ : formatter_(options.ShouldResolveURLs(),
+ document->IsHTMLDocument() ? SerializationType::kAsOwnerDocument
+ : SerializationType::kForcedXML),
start_(start),
end_(end),
document_(document),
- should_annotate_(should_annotate),
- convert_blocks_to_inlines_(convert_blocks_to_inlines) {}
+ options_(options) {}
void StyledMarkupAccumulator::AppendEndTag(const Element& element) {
AppendEndMarkup(result_, element);
@@ -225,7 +224,7 @@ String StyledMarkupAccumulator::StringValueForRange(const Text& node) {
}
bool StyledMarkupAccumulator::ShouldAnnotate() const {
- return should_annotate_ == kAnnotateForInterchange;
+ return options_.ShouldAnnotateForInterchange();
}
void StyledMarkupAccumulator::PushMarkup(const String& str) {
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.h b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.h
index e211def8741..ba3616de40a 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.h
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.h
@@ -32,6 +32,7 @@
#include "base/macros.h"
#include "third_party/blink/renderer/core/editing/editing_style.h"
+#include "third_party/blink/renderer/core/editing/serializers/create_markup_options.h"
#include "third_party/blink/renderer/core/editing/serializers/markup_formatter.h"
#include "third_party/blink/renderer/core/editing/serializers/text_offset.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
@@ -46,12 +47,10 @@ class StyledMarkupAccumulator final {
STACK_ALLOCATED();
public:
- StyledMarkupAccumulator(EAbsoluteURLs,
- const TextOffset& start,
+ StyledMarkupAccumulator(const TextOffset& start,
const TextOffset& end,
Document*,
- EAnnotateForInterchange,
- ConvertBlocksToInlines);
+ const CreateMarkupOptions& options);
void AppendEndTag(const Element&);
void AppendInterchangeNewline();
@@ -74,7 +73,7 @@ class StyledMarkupAccumulator final {
bool ShouldAnnotate() const;
bool ShouldConvertBlocksToInlines() const {
- return convert_blocks_to_inlines_ == ConvertBlocksToInlines::kConvert;
+ return options_.ShouldConvertBlocksToInlines();
}
private:
@@ -87,10 +86,9 @@ class StyledMarkupAccumulator final {
const TextOffset start_;
const TextOffset end_;
const Member<Document> document_;
- const EAnnotateForInterchange should_annotate_;
+ const CreateMarkupOptions options_;
StringBuilder result_;
Vector<String> reversed_preceding_markup_;
- const ConvertBlocksToInlines convert_blocks_to_inlines_;
DISALLOW_COPY_AND_ASSIGN(StyledMarkupAccumulator);
};
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.cc b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.cc
index 09e14cae1ba..60292707f1c 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.cc
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.cc
@@ -120,18 +120,14 @@ bool StyledMarkupTraverser<Strategy>::ShouldConvertBlocksToInlines() const {
template <typename Strategy>
StyledMarkupSerializer<Strategy>::StyledMarkupSerializer(
- EAbsoluteURLs should_resolve_urls,
- EAnnotateForInterchange should_annotate,
const PositionTemplate<Strategy>& start,
const PositionTemplate<Strategy>& end,
Node* highest_node_to_be_serialized,
- ConvertBlocksToInlines convert_blocks_to_inlines)
+ const CreateMarkupOptions& options)
: start_(start),
end_(end),
- should_resolve_urls_(should_resolve_urls),
- should_annotate_(should_annotate),
highest_node_to_be_serialized_(highest_node_to_be_serialized),
- convert_blocks_to_inlines_(convert_blocks_to_inlines),
+ options_(options),
last_closed_(highest_node_to_be_serialized) {}
template <typename Strategy>
@@ -179,9 +175,9 @@ static EditingStyle* StyleFromMatchedRulesAndInlineDecl(
template <typename Strategy>
String StyledMarkupSerializer<Strategy>::CreateMarkup() {
StyledMarkupAccumulator markup_accumulator(
- should_resolve_urls_, ToTextOffset(start_.ParentAnchoredEquivalent()),
+ ToTextOffset(start_.ParentAnchoredEquivalent()),
ToTextOffset(end_.ParentAnchoredEquivalent()), start_.GetDocument(),
- should_annotate_, convert_blocks_to_inlines_);
+ options_);
Node* past_end = end_.NodeAsRangePastLastNode();
diff --git a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.h b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.h
index 7c5472768cf..3021ab7160b 100644
--- a/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.h
+++ b/chromium/third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.h
@@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/editing/editing_strategy.h"
#include "third_party/blink/renderer/core/editing/editing_style.h"
+#include "third_party/blink/renderer/core/editing/serializers/create_markup_options.h"
#include "third_party/blink/renderer/core/editing/position.h"
#include "third_party/blink/renderer/core/editing/serializers/styled_markup_accumulator.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
@@ -44,26 +45,22 @@ class StyledMarkupSerializer final {
STACK_ALLOCATED();
public:
- StyledMarkupSerializer(EAbsoluteURLs,
- EAnnotateForInterchange,
- const PositionTemplate<Strategy>& start,
+ StyledMarkupSerializer(const PositionTemplate<Strategy>& start,
const PositionTemplate<Strategy>& end,
Node* highest_node_to_be_serialized,
- ConvertBlocksToInlines);
+ const CreateMarkupOptions& options);
String CreateMarkup();
private:
bool ShouldAnnotate() const {
- return should_annotate_ == kAnnotateForInterchange;
+ return options_.ShouldAnnotateForInterchange();
}
const PositionTemplate<Strategy> start_;
const PositionTemplate<Strategy> end_;
- const EAbsoluteURLs should_resolve_urls_;
- const EAnnotateForInterchange should_annotate_;
const Member<Node> highest_node_to_be_serialized_;
- const ConvertBlocksToInlines convert_blocks_to_inlines_;
+ const CreateMarkupOptions options_;
Member<Node> last_closed_;
Member<EditingStyle> wrapping_style_;
};
diff --git a/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
index b63892fb628..0226d3c31c1 100644
--- a/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
+++ b/chromium/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
@@ -2469,14 +2469,16 @@ static String CreateMarkupInRect(LocalFrame* frame,
if (!start_position.GetDocument() || !end_position.GetDocument())
return String();
+ const CreateMarkupOptions create_markup_options =
+ CreateMarkupOptions::Builder()
+ .SetShouldAnnotateForInterchange(true)
+ .SetShouldResolveURLs(kResolveNonLocalURLs)
+ .Build();
+
if (start_position.CompareTo(end_position) <= 0) {
- return CreateMarkup(start_position, end_position, kAnnotateForInterchange,
- ConvertBlocksToInlines::kNotConvert,
- kResolveNonLocalURLs);
+ return CreateMarkup(start_position, end_position, create_markup_options);
}
- return CreateMarkup(end_position, start_position, kAnnotateForInterchange,
- ConvertBlocksToInlines::kNotConvert,
- kResolveNonLocalURLs);
+ return CreateMarkup(end_position, start_position, create_markup_options);
}
void WebLocalFrameImpl::AdvanceFocusInForm(WebFocusType focus_type) {