#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/timer/elapsed_timer.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/single_request_url_loader_factory.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/css_value.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/dom/cdata_section.h"
#include "third_party/blink/renderer/core/dom/child_list_mutation_scope.h"
#include "third_party/blink/renderer/core/dom/comment.h"
#include "third_party/blink/renderer/core/dom/document_fragment.h"
#include "third_party/blink/renderer/core/dom/document_init.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/dom/range.h"
#include "third_party/blink/renderer/core/editing/editing_strategy.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/serializers/markup_accumulator.h"
#include "third_party/blink/renderer/core/editing/serializers/styled_markup_serializer.h"
#include "third_party/blink/renderer/core/editing/visible_selection.h"
#include "third_party/blink/renderer/core/editing/visible_units.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_body_element.h"
#include "third_party/blink/renderer/core/html/html_br_element.h"
#include "third_party/blink/renderer/core/html/html_div_element.h"
#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/html_head_element.h"
#include "third_party/blink/renderer/core/html/html_html_element.h"
#include "third_party/blink/renderer/core/html/html_quote_element.h"
#include "third_party/blink/renderer/core/html/html_span_element.h"
#include "third_party/blink/renderer/core/html/html_style_element.h"
#include "third_party/blink/renderer/core/html/html_table_cell_element.h"
#include "third_party/blink/renderer/core/html/html_table_element.h"
#include "third_party/blink/renderer/core/html/html_template_element.h"
#include "third_party/blink/renderer/core/html/parser/html_document_parser_fastpath.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/svg/svg_style_element.h"
#include "third_party/blink/renderer/core/svg/svg_use_element.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/url_loader/url_loader_client.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
class AttributeChange { … };
}
WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(…)
namespace blink {
namespace {
class EmptyLocalFrameClientWithFailingLoaderFactory final
: public EmptyLocalFrameClient { … };
void LogFastPathParserTotalTime(base::TimeDelta parse_time) { … }
}
static void CompleteURLs(DocumentFragment& fragment, const String& base_url) { … }
static bool IsHTMLBlockElement(const Node* node) { … }
static HTMLElement* AncestorToRetainStructureAndAppearanceForBlock(
Element* common_ancestor_block) { … }
static inline HTMLElement* AncestorToRetainStructureAndAppearance(
Node* common_ancestor) { … }
static inline HTMLElement*
AncestorToRetainStructureAndAppearanceWithNoLayoutObject(
const Node& common_ancestor) { … }
bool PropertyMissingOrEqualToNone(CSSPropertyValueSet* style,
CSSPropertyID property_id) { … }
template <typename Strategy>
static HTMLElement* HighestAncestorToWrapMarkup(
const PositionTemplate<Strategy>& start_position,
const PositionTemplate<Strategy>& end_position,
const CreateMarkupOptions& options) { … }
template <typename Strategy>
class CreateMarkupAlgorithm { … };
template <typename Strategy>
String CreateMarkupAlgorithm<Strategy>::CreateMarkup(
const PositionTemplate<Strategy>& start_position,
const PositionTemplate<Strategy>& end_position,
const CreateMarkupOptions& options) { … }
String CreateMarkup(const Position& start_position,
const Position& end_position,
const CreateMarkupOptions& options) { … }
String CreateMarkup(const PositionInFlatTree& start_position,
const PositionInFlatTree& end_position,
const CreateMarkupOptions& options) { … }
DocumentFragment* CreateFragmentFromMarkup(
Document& document,
const String& markup,
const String& base_url,
ParserContentPolicy parser_content_policy) { … }
static const char kFragmentMarkerTag[] = …;
static bool FindNodesSurroundingContext(DocumentFragment* fragment,
Comment*& node_before_context,
Comment*& node_after_context) { … }
static void TrimFragment(DocumentFragment* fragment,
Comment* node_before_context,
Comment* node_after_context) { … }
DocumentFragment* CreateFragmentFromMarkupWithContext(
Document& document,
const String& markup,
unsigned fragment_start,
unsigned fragment_end,
const String& base_url,
ParserContentPolicy parser_content_policy) { … }
String CreateMarkup(const Node* node,
ChildrenOnly children_only,
AbsoluteURLs should_resolve_urls,
const ShadowRootInclusion& shadow_root_inclusion) { … }
static void FillContainerFromString(ContainerNode* paragraph,
const String& string) { … }
bool IsPlainTextMarkup(Node* node) { … }
static bool ShouldPreserveNewline(const EphemeralRange& range) { … }
DocumentFragment* CreateFragmentFromText(const EphemeralRange& context,
const String& text) { … }
DocumentFragment* CreateFragmentForInnerOuterHTML(
const String& markup,
Element* context_element,
ParserContentPolicy parser_content_policy,
Element::ParseDeclarativeShadowRoots parse_declarative_shadows,
Element::ForceHtml force_html,
ExceptionState& exception_state) { … }
DocumentFragment* CreateFragmentForTransformToFragment(
const String& source_string,
const String& source_mime_type,
Document& output_doc) { … }
static inline void RemoveElementPreservingChildren(DocumentFragment* fragment,
HTMLElement* element) { … }
DocumentFragment* CreateContextualFragment(
const String& markup,
Element* element,
ParserContentPolicy parser_content_policy,
ExceptionState& exception_state) { … }
void ReplaceChildrenWithFragment(ContainerNode* container,
DocumentFragment* fragment,
ExceptionState& exception_state) { … }
void ReplaceChildrenWithText(ContainerNode* container,
const String& text,
ExceptionState& exception_state) { … }
void MergeWithNextTextNode(Text* text_node, ExceptionState& exception_state) { … }
static Document* CreateStagingDocumentForMarkupSanitization(
AgentGroupScheduler& agent_group_scheduler) { … }
static bool ContainsStyleElements(const DocumentFragment& fragment) { … }
static bool StripSVGUseNonLocalHrefs(Node& node) { … }
namespace {
constexpr unsigned kMaxSanitizationIterations = …;
}
String CreateStrictlyProcessedMarkupWithContext(
Document& document,
const String& raw_markup,
unsigned fragment_start,
unsigned fragment_end,
const String& base_url,
ChildrenOnly children_only,
AbsoluteURLs should_resolve_urls,
const ShadowRootInclusion& shadow_root_inclusion) { … }
DocumentFragment* CreateStrictlyProcessedFragmentFromMarkupWithContext(
Document& document,
const String& raw_markup,
unsigned fragment_start,
unsigned fragment_end,
const String& base_url) { … }
template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>;
template class CORE_TEMPLATE_EXPORT
CreateMarkupAlgorithm<EditingInFlatTreeStrategy>;
}