chromium/third_party/blink/renderer/core/dom/document.cc

/*
 * Copyright (C) 1999 Lars Knoll ([email protected])
 *           (C) 1999 Antti Koivisto ([email protected])
 *           (C) 2001 Dirk Mueller ([email protected])
 *           (C) 2006 Alexey Proskuryakov ([email protected])
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
 * rights reserved.
 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
 * (http://www.torchmobile.com/)
 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/core/dom/document.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/auto_reset.h"
#include "base/containers/adapters.h"
#include "base/containers/contains.h"
#include "base/debug/dump_without_crashing.h"
#include "base/i18n/time_formatting.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "cc/animation/animation_host.h"
#include "cc/animation/animation_timeline.h"
#include "cc/input/overscroll_behavior.h"
#include "cc/input/scroll_snap_data.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/mojom/base/text_direction.mojom-blink.h"
#include "services/metrics/public/cpp/delegating_ukm_recorder.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/network/public/cpp/web_sandbox_flags.h"
#include "services/network/public/mojom/trust_tokens.mojom-blink.h"
#include "services/network/public/mojom/web_sandbox_flags.mojom-blink.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/permissions_policy/document_policy_features.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_sample_collector.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
#include "third_party/blink/public/mojom/manifest/display_mode.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/page_state/page_state.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-blink-forward.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/public/web/web_link_preview_triggerer.h"
#include "third_party/blink/public/web/web_print_page_description.h"
#include "third_party/blink/renderer/bindings/core/v8/frozen_array.h"
#include "third_party/blink/renderer/bindings/core/v8/isolated_world_csp.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_aria_notification_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_caret_position_from_point_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_element_creation_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_element_registration_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_observable_array_css_style_sheet.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_elementcreationoptions_string.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_htmlscriptelement_svgscriptelement.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy.h"
#include "third_party/blink/renderer/core/accessibility/ax_context.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/animation/document_animations.h"
#include "third_party/blink/renderer/core/animation/document_timeline.h"
#include "third_party/blink/renderer/core/animation/pending_animations.h"
#include "third_party/blink/renderer/core/animation/worklet_animation_controller.h"
#include "third_party/blink/renderer/core/annotation/annotation_agent_container_impl.h"
#include "third_party/blink/renderer/core/aom/computed_accessible_node.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/css_style_declaration.h"
#include "third_party/blink/renderer/core/css/css_style_sheet.h"
#include "third_party/blink/renderer/core/css/cssom/caret_position.h"
#include "third_party/blink/renderer/core/css/cssom/computed_style_property_map.h"
#include "third_party/blink/renderer/core/css/element_rule_collector.h"
#include "third_party/blink/renderer/core/css/font_face_set_document.h"
#include "third_party/blink/renderer/core/css/invalidation/style_invalidator.h"
#include "third_party/blink/renderer/core/css/layout_upgrade.h"
#include "third_party/blink/renderer/core/css/media_query_list.h"
#include "third_party/blink/renderer/core/css/media_query_matcher.h"
#include "third_party/blink/renderer/core/css/media_values.h"
#include "third_party/blink/renderer/core/css/parser/css_parser.h"
#include "third_party/blink/renderer/core/css/post_style_update_scope.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
#include "third_party/blink/renderer/core/css/resolver/font_builder.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_stats.h"
#include "third_party/blink/renderer/core/css/selector_query.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
#include "third_party/blink/renderer/core/css/style_sheet_list.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_context.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_document_state.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h"
#include "third_party/blink/renderer/core/dom/attr.h"
#include "third_party/blink/renderer/core/dom/beforeunload_event_listener.h"
#include "third_party/blink/renderer/core/dom/cdata_section.h"
#include "third_party/blink/renderer/core/dom/comment.h"
#include "third_party/blink/renderer/core/dom/document_data.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/document_lifecycle.h"
#include "third_party/blink/renderer/core/dom/document_parser_timing.h"
#include "third_party/blink/renderer/core/dom/document_part_root.h"
#include "third_party/blink/renderer/core/dom/document_type.h"
#include "third_party/blink/renderer/core/dom/dom_implementation.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/element_data_cache.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/events/event_dispatch_forbidden_scope.h"
#include "third_party/blink/renderer/core/dom/events/event_listener.h"
#include "third_party/blink/renderer/core/dom/events/native_event_listener.h"
#include "third_party/blink/renderer/core/dom/events/scoped_event_queue.h"
#include "third_party/blink/renderer/core/dom/flat_tree_traversal.h"
#include "third_party/blink/renderer/core/dom/focus_params.h"
#include "third_party/blink/renderer/core/dom/focused_element_change_observer.h"
#include "third_party/blink/renderer/core/dom/layout_tree_builder_traversal.h"
#include "third_party/blink/renderer/core/dom/live_node_list.h"
#include "third_party/blink/renderer/core/dom/mutation_observer.h"
#include "third_party/blink/renderer/core/dom/node_child_removal_tracker.h"
#include "third_party/blink/renderer/core/dom/node_cloning_data.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/node_iterator.h"
#include "third_party/blink/renderer/core/dom/node_lists_node_data.h"
#include "third_party/blink/renderer/core/dom/node_rare_data.h"
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/dom/node_with_index.h"
#include "third_party/blink/renderer/core/dom/part_root.h"
#include "third_party/blink/renderer/core/dom/processing_instruction.h"
#include "third_party/blink/renderer/core/dom/scripted_animation_controller.h"
#include "third_party/blink/renderer/core/dom/shadow_including_tree_order_traversal.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/slot_assignment.h"
#include "third_party/blink/renderer/core/dom/slot_assignment_engine.h"
#include "third_party/blink/renderer/core/dom/slot_assignment_recalc_forbidden_scope.h"
#include "third_party/blink/renderer/core/dom/static_node_list.h"
#include "third_party/blink/renderer/core/dom/text_diff_range.h"
#include "third_party/blink/renderer/core/dom/transform_source.h"
#include "third_party/blink/renderer/core/dom/tree_walker.h"
#include "third_party/blink/renderer/core/dom/visited_link_state.h"
#include "third_party/blink/renderer/core/dom/whitespace_attacher.h"
#include "third_party/blink/renderer/core/dom/xml_document.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/ime/edit_context.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include "third_party/blink/renderer/core/editing/position_with_affinity.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/events/before_unload_event.h"
#include "third_party/blink/renderer/core/events/event_factory.h"
#include "third_party/blink/renderer/core/events/event_util.h"
#include "third_party/blink/renderer/core/events/hash_change_event.h"
#include "third_party/blink/renderer/core/events/overscroll_event.h"
#include "third_party/blink/renderer/core/events/page_transition_event.h"
#include "third_party/blink/renderer/core/events/visual_viewport_resize_event.h"
#include "third_party/blink/renderer/core/events/visual_viewport_scroll_event.h"
#include "third_party/blink/renderer/core/events/visual_viewport_scrollend_event.h"
#include "third_party/blink/renderer/core/execution_context/window_agent.h"
#include "third_party/blink/renderer/core/fragment_directive/fragment_directive.h"
#include "third_party/blink/renderer/core/fragment_directive/text_fragment_handler.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/dom_visual_viewport.h"
#include "third_party/blink/renderer/core/frame/event_handler_registry.h"
#include "third_party/blink/renderer/core/frame/font_matching_metrics.h"
#include "third_party/blink/renderer/core/frame/frame_console.h"
#include "third_party/blink/renderer/core/frame/history.h"
#include "third_party/blink/renderer/core/frame/intervention.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/page_dismissal_scope.h"
#include "third_party/blink/renderer/core/frame/performance_monitor.h"
#include "third_party/blink/renderer/core/frame/picture_in_picture_controller.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/viewport_data.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/html/anchor_element_metrics_sender.h"
#include "third_party/blink/renderer/core/html/anchor_element_observer_for_service_worker.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_font_cache.h"
#include "third_party/blink/renderer/core/html/collection_type.h"
#include "third_party/blink/renderer/core/html/custom/custom_element.h"
#include "third_party/blink/renderer/core/html/custom/custom_element_definition.h"
#include "third_party/blink/renderer/core/html/custom/custom_element_descriptor.h"
#include "third_party/blink/renderer/core/html/custom/custom_element_registry.h"
#include "third_party/blink/renderer/core/html/document_all_name_collection.h"
#include "third_party/blink/renderer/core/html/document_name_collection.h"
#include "third_party/blink/renderer/core/html/forms/email_input_type.h"
#include "third_party/blink/renderer/core/html/forms/form_controller.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/html_all_collection.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_base_element.h"
#include "third_party/blink/renderer/core/html/html_body_element.h"
#include "third_party/blink/renderer/core/html/html_collection.h"
#include "third_party/blink/renderer/core/html/html_dialog_element.h"
#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html/html_frame_set_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_image_element.h"
#include "third_party/blink/renderer/core/html/html_link_element.h"
#include "third_party/blink/renderer/core/html/html_meta_element.h"
#include "third_party/blink/renderer/core/html/html_object_element.h"
#include "third_party/blink/renderer/core/html/html_plugin_element.h"
#include "third_party/blink/renderer/core/html/html_script_element.h"
#include "third_party/blink/renderer/core/html/html_style_element.h"
#include "third_party/blink/renderer/core/html/html_title_element.h"
#include "third_party/blink/renderer/core/html/html_unknown_element.h"
#include "third_party/blink/renderer/core/html/lazy_load_image_observer.h"
#include "third_party/blink/renderer/core/html/nesting_level_incrementer.h"
#include "third_party/blink/renderer/core/html/parser/html_document_parser.h"
#include "third_party/blink/renderer/core/html/parser/html_document_parser_fastpath.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/html/parser/text_resource_decoder.h"
#include "third_party/blink/renderer/core/html/parser/text_resource_decoder_builder.h"
#include "third_party/blink/renderer/core/html/plugin_document.h"
#include "third_party/blink/renderer/core/html/window_name_collection.h"
#include "third_party/blink/renderer/core/html_element_factory.h"
#include "third_party/blink/renderer/core/html_element_type_helpers.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/input/touch_list.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/intersection_observer/element_intersection_observer_data.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer_controller.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer_entry.h"
#include "third_party/blink/renderer/core/layout/adjust_for_absolute_zoom.h"
#include "third_party/blink/renderer/core/layout/hit_test_canvas_result.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/pagination_utils.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.h"
#include "third_party/blink/renderer/core/lcp_critical_path_predictor/lcp_critical_path_predictor.h"
#include "third_party/blink/renderer/core/loader/anchor_element_interaction_tracker.h"
#include "third_party/blink/renderer/core/loader/cookie_jar.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_fetch_context.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/loader/http_refresh_scheduler.h"
#include "third_party/blink/renderer/core/loader/idleness_detector.h"
#include "third_party/blink/renderer/core/loader/interactive_detector.h"
#include "third_party/blink/renderer/core/loader/lazy_image_helper.h"
#include "third_party/blink/renderer/core/loader/no_state_prefetch_client.h"
#include "third_party/blink/renderer/core/loader/pending_link_preload.h"
#include "third_party/blink/renderer/core/loader/progress_tracker.h"
#include "third_party/blink/renderer/core/loader/render_blocking_resource_manager.h"
#include "third_party/blink/renderer/core/loader/resource/link_dictionary_resource.h"
#include "third_party/blink/renderer/core/mathml/mathml_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_row_element.h"
#include "third_party/blink/renderer/core/mathml_element_factory.h"
#include "third_party/blink/renderer/core/mathml_names.h"
#include "third_party/blink/renderer/core/mobile_metrics/mobile_friendliness_checker.h"
#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/event_with_hit_test_results.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/page/frame_tree.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/page_animator.h"
#include "third_party/blink/renderer/core/page/plugin_script_forbidden_scope.h"
#include "third_party/blink/renderer/core/page/pointer_lock_controller.h"
#include "third_party/blink/renderer/core/page/scrolling/fragment_anchor.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_controller.h"
#include "third_party/blink/renderer/core/page/scrolling/snap_coordinator.h"
#include "third_party/blink/renderer/core/page/scrolling/top_document_root_scroller_controller.h"
#include "third_party/blink/renderer/core/page/spatial_navigation_controller.h"
#include "third_party/blink/renderer/core/page/validation_message_client.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/paint/timing/first_meaningful_paint_detector.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing.h"
#include "third_party/blink/renderer/core/permissions_policy/dom_feature_policy.h"
#include "third_party/blink/renderer/core/permissions_policy/permissions_policy_parser.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/resize_observer/resize_observer.h"
#include "third_party/blink/renderer/core/resize_observer/resize_observer_controller.h"
#include "third_party/blink/renderer/core/resize_observer/resize_observer_entry.h"
#include "third_party/blink/renderer/core/resize_observer/resize_observer_size.h"
#include "third_party/blink/renderer/core/script/detect_javascript_frameworks.h"
#include "third_party/blink/renderer/core/script/script_runner.h"
#include "third_party/blink/renderer/core/scroll/scrollbar_theme.h"
#include "third_party/blink/renderer/core/scroll/snap_event.h"
#include "third_party/blink/renderer/core/speculation_rules/document_speculation_rules.h"
#include "third_party/blink/renderer/core/svg/svg_document_extensions.h"
#include "third_party/blink/renderer/core/svg/svg_script_element.h"
#include "third_party/blink/renderer/core/svg/svg_svg_element.h"
#include "third_party/blink/renderer/core/svg/svg_title_element.h"
#include "third_party/blink/renderer/core/svg/svg_unknown_element.h"
#include "third_party/blink/renderer/core/svg/svg_use_element.h"
#include "third_party/blink/renderer/core/svg_element_factory.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/core/timing/render_blocking_metrics_reporter.h"
#include "third_party/blink/renderer/core/timing/soft_navigation_heuristics.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_html.h"
#include "third_party/blink/renderer/core/view_transition/page_reveal_event.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_supplement.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_utils.h"
#include "third_party/blink/renderer/core/xml/parser/xml_document_parser.h"
#include "third_party/blink/renderer/core/xml_names.h"
#include "third_party/blink/renderer/core/xmlns_names.h"
#include "third_party/blink/renderer/platform/bindings/dom_data_store.h"
#include "third_party/blink/renderer/platform/bindings/dom_wrapper_world.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/bindings/v8_dom_wrapper.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/fonts/font_performance.h"
#include "third_party/blink/renderer/platform/geometry/length_functions.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/instance_counters.h"
#include "third_party/blink/renderer/platform/instrumentation/resource_coordinator/document_resource_coordinator.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/language.h"
#include "third_party/blink/renderer/platform/loader/fetch/null_resource_fetcher_properties.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/network/content_security_policy_parsers.h"
#include "third_party/blink/renderer/platform/network/http_parsers.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_or_worker_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/text/platform_locale.h"
#include "third_party/blink/renderer/platform/web_test_support.h"
#include "third_party/blink/renderer/platform/weborigin/origin_access_entry.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/widget/frame_widget.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/string_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h"

#ifndef NDEBUG
WeakDocumentSet;
static WeakDocumentSet& LiveDocumentSet();
#endif

namespace blink {

namespace {

constexpr char kTextHtml[] =;

class IntrinsicSizeResizeObserverDelegate : public ResizeObserver::Delegate {};

// Returns true if any of <object> ancestors don't start loading or are loading
// plugins/frames/images. If there are no <object> ancestors, this function
// returns false.
bool IsInIndeterminateObjectAncestor(const Element* element) {}

// Helper function to notify both `first` and `second` that the priority scroll
// anchor status changed. This is used when, for example, a focused element
// changes from `first` to `second`.
void NotifyPriorityScrollAnchorStatusChanged(Node* first, Node* second) {}

// Before fetching the default URL, make sure it won't be blocked by CSP. The
// webpage didn't requested "/favicon.ico", it is automatic. Developers
// shouldn't suffer from any errors provoked by Chrome.
// See https://crbug.com/820846
bool DefaultFaviconAllowedByCSP(const Document* document, const IconURL& icon) {}

// The sampling rate for UKM.
constexpr double kUkmSamplingRate =;

}  // namespace

static const unsigned kCMaxWriteRecursionDepth =;

// This amount of time must have elapsed before we will even consider scheduling
// a layout without a delay.
// FIXME: For faster machines this value can really be lowered to 200.  250 is
// adequate, but a little high for dual G5s. :)
static const base::TimeDelta kCLayoutScheduleThreshold =;

// DOM Level 2 says (letters added):
//
// a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl.
// b) Name characters other than Name-start characters must have one of the
//    categories Mc, Me, Mn, Lm, or Nd.
// c) Characters in the compatibility area (i.e. with character code greater
//    than #xF900 and less than #xFFFE) are not allowed in XML names.
// d) Characters which have a font or compatibility decomposition (i.e. those
//    with a "compatibility formatting tag" in field 5 of the database -- marked
//    by field 5 beginning with a "<") are not allowed.
// e) The following characters are treated as name-start characters rather than
//    name characters, because the property file classifies them as Alphabetic:
//    [#x02BB-#x02C1], #x0559, #x06E5, #x06E6.
// f) Characters #x20DD-#x20E0 are excluded (in accordance with Unicode, section
//    5.14).
// g) Character #x00B7 is classified as an extender, because the property list
//    so identifies it.
// h) Character #x0387 is added as a name character, because #x00B7 is its
//    canonical equivalent.
// i) Characters ':' and '_' are allowed as name-start characters.
// j) Characters '-' and '.' are allowed as name characters.
//
// It also contains complete tables. If we decide it's better, we could include
// those instead of the following code.

static inline bool IsValidNameStart(UChar32 c) {}

static inline bool IsValidNamePart(UChar32 c) {}

// Tests whether |name| is something the HTML parser would accept as a
// tag name.
template <typename CharType>
static inline bool IsValidElementNamePerHTMLParser(const CharType* characters,
                                                   unsigned length) {}

static bool IsValidElementNamePerHTMLParser(const String& name) {}

// Tests whether |name| is a valid name per DOM spec. Also checks
// whether the HTML parser would accept this element name and counts
// cases of mismatches.
static bool IsValidElementName(Document* document, const String& name) {}

static bool AcceptsEditingFocus(const Element& element) {}

uint64_t Document::global_tree_version_ =;

static bool g_force_synchronous_parsing_for_testing =;

void IntrinsicSizeResizeObserverDelegate::OnResize(
    const HeapVector<Member<ResizeObserverEntry>>& entries) {}

ResizeObserver::DeliveryTime IntrinsicSizeResizeObserverDelegate::Delivery()
    const {}

bool IntrinsicSizeResizeObserverDelegate::SkipNonAtomicInlineObservations()
    const {}

void Document::UnassociatedListedElementsList::MarkDirty() {}

void Document::UnassociatedListedElementsList::Trace(Visitor* visitor) const {}

const ListedElement::List& Document::UnassociatedListedElementsList::Get(
    const Document& owner) {}

const ListedElement::List& Document::UnassociatedListedElements() const {}

void Document::MarkUnassociatedListedElementsDirty() {}

void Document::TopLevelFormsList::MarkDirty() {}

void Document::TopLevelFormsList::Trace(Visitor* visitor) const {}

const HeapVector<Member<HTMLFormElement>>& Document::TopLevelFormsList::Get(
    Document& owner) {}

const HeapVector<Member<HTMLFormElement>>& Document::GetTopLevelForms() {}

void Document::MarkTopLevelFormsDirty() {}

ExplicitlySetAttrElementsMap* Document::GetExplicitlySetAttrElementsMap(
    const Element* element) {}

void Document::MoveElementExplicitlySetAttrElementsMapToNewDocument(
    const Element* element,
    Document& new_document) {}

CachedAttrAssociatedElementsMap* Document::GetCachedAttrAssociatedElementsMap(
    Element* element) {}

void Document::MoveElementCachedAttrAssociatedElementsMapToNewDocument(
    Element* element,
    Document& new_document) {}

UnloadEventTimingInfo::UnloadEventTimingInfo(
    scoped_refptr<SecurityOrigin> new_document_origin)
    :{}

Document* Document::Create(Document& document) {}

Document* Document::CreateForTest(ExecutionContext& execution_context) {}

Document::Document(const DocumentInit& initializer,
                   DocumentClassFlags document_classes)
    :{}

Document::~Document() {}

Range* Document::CreateRangeAdjustedToTreeScope(const TreeScope& tree_scope,
                                                const Position& position) {}

CaretPosition* Document::CreateCaretPosition(const Position& position) {}

const Position Document::PositionAdjustedToTreeScope(
    const TreeScope& tree_scope,
    const Position& position) {}

SelectorQueryCache& Document::GetSelectorQueryCache() {}

MediaQueryMatcher& Document::GetMediaQueryMatcher() {}

void Document::MediaQueryAffectingValueChanged(MediaValueChange change) {}

void Document::SetCompatibilityMode(CompatibilityMode mode) {}

String Document::compatMode() const {}

void Document::SetDoctype(DocumentType* doc_type) {}

DOMImplementation& Document::implementation() {}

Location* Document::location() const {}

bool Document::DocumentPolicyFeatureObserved(
    mojom::blink::DocumentPolicyFeature feature) {}

void Document::ChildrenChanged(const ChildrenChange& change) {}

bool Document::IsInMainFrame() const {}

bool Document::IsInOutermostMainFrame() const {}

AtomicString Document::ConvertLocalName(const AtomicString& name) {}

// Just creates an element with specified qualified name without any
// custom element processing.
// This is a common code for step 5.2 and 7.2 of "create an element"
// <https://dom.spec.whatwg.org/#concept-create-element>
// Functions other than this one should not use HTMLElementFactory and
// SVGElementFactory because they don't support prefixes correctly.
Element* Document::CreateRawElement(const QualifiedName& qname,
                                    CreateElementFlags flags) {}

// https://dom.spec.whatwg.org/#dom-document-createelement
// TODO(crbug.com/1304439): Move it to `tree_scope.cc` if the feature
// `ScopedCustomElementRegistry` can stabilize.
Element* TreeScope::CreateElementForBinding(const AtomicString& name,
                                            ExceptionState& exception_state) {}

AtomicString GetTypeExtension(
    Document* document,
    const V8UnionElementCreationOptionsOrString* string_or_options) {}

// https://dom.spec.whatwg.org/#dom-document-createelement
// TODO(crbug.com/1304439): Move it to `tree_scope.cc` if the feature
// `ScopedCustomElementRegistry` can stabilize.
Element* TreeScope::CreateElementForBinding(
    const AtomicString& local_name,
    const V8UnionElementCreationOptionsOrString* string_or_options,
    ExceptionState& exception_state) {}

static inline QualifiedName CreateQualifiedName(
    const AtomicString& namespace_uri,
    const AtomicString& qualified_name,
    ExceptionState& exception_state) {}

// TODO(crbug.com/1304439): Move it to `tree_scope.cc` if the feature
// `ScopedCustomElementRegistry` can stabilize.
Element* TreeScope::createElementNS(const AtomicString& namespace_uri,
                                    const AtomicString& qualified_name,
                                    ExceptionState& exception_state) {}

// https://dom.spec.whatwg.org/#internal-createelementns-steps
// TODO(crbug.com/1304439): Move it to `tree_scope.cc` if the feature
// `ScopedCustomElementRegistry` can stabilize.
Element* TreeScope::createElementNS(
    const AtomicString& namespace_uri,
    const AtomicString& qualified_name,
    const V8UnionElementCreationOptionsOrString* string_or_options,
    ExceptionState& exception_state) {}

// Entry point of "create an element".
// https://dom.spec.whatwg.org/#concept-create-element
// TODO(crbug.com/1304439): Move it to `tree_scope.cc` if the feature
// `ScopedCustomElementRegistry` can stabilize.
Element* TreeScope::CreateElement(const QualifiedName& q_name,
                                  const CreateElementFlags flags,
                                  const AtomicString& is) {}

DocumentFragment* Document::createDocumentFragment() {}

Text* Document::createTextNode(const String& data) {}

Comment* Document::createComment(const String& data) {}

CDATASection* Document::createCDATASection(const String& data,
                                           ExceptionState& exception_state) {}

ProcessingInstruction* Document::createProcessingInstruction(
    const String& target,
    const String& data,
    ExceptionState& exception_state) {}

Text* Document::CreateEditingTextNode(const String& text) {}

Node* Document::importNode(Node* imported_node,
                           bool deep,
                           ExceptionState& exception_state) {}

Node* Document::adoptNode(Node* source, ExceptionState& exception_state) {}

bool Document::HasValidNamespaceForElements(const QualifiedName& q_name) {}

bool Document::HasValidNamespaceForAttributes(const QualifiedName& q_name) {}

String Document::readyState() const {}

void Document::SetReadyState(DocumentReadyState ready_state) {}

bool Document::IsLoadCompleted() const {}

AtomicString Document::EncodingName() const {}

void Document::SetContentLanguage(const AtomicString& language) {}

void Document::setXMLVersion(const String& version,
                             ExceptionState& exception_state) {}

void Document::setXMLStandalone(bool standalone,
                                ExceptionState& exception_state) {}

void Document::SetContent(const String& content) {}

AllowState;
void Document::SetContentFromDOMParser(const String& content) {}

String Document::SuggestedMIMEType() const {}

void Document::SetMimeType(const AtomicString& mime_type) {}

AtomicString Document::contentType() const {}

Range* Document::caretRangeFromPoint(int x, int y) {}

CaretPosition* Document::caretPositionFromPoint(
    float x,
    float y,
    const CaretPositionFromPointOptions* options) {}

Element* Document::scrollingElement() {}

Element* Document::ScrollingElementNoLayout() {}

bool Document::KeyboardFocusableScrollersEnabled() {}

bool Document::StandardizedBrowserZoomEnabled() const {}

/*
 * Performs three operations:
 *  1. Convert control characters to spaces
 *  2. Trim leading and trailing spaces
 *  3. Collapse internal whitespace.
 */
template <typename CharacterType>
static inline String CanonicalizedTitle(Document* document,
                                        const String& title) {}

void Document::UpdateTitle(const String& title) {}

void Document::DispatchDidReceiveTitle() {}

void Document::setTitle(const String& title) {}

void Document::SetTitleElement(Element* title_element) {}

void Document::RemoveTitle(Element* title_element) {}

const AtomicString& Document::dir() {}

void Document::setDir(const AtomicString& value) {}

bool Document::IsPageVisible() const {}

bool Document::IsPrefetchOnly() const {}

AtomicString Document::visibilityState() const {}

bool Document::prerendering() const {}
uint32_t Document::softNavigations() const {}

bool Document::hidden() const {}

bool Document::wasDiscarded() const {}

void Document::SetWasDiscarded(bool was_discarded) {}

void Document::DidChangeVisibilityState() {}

String Document::nodeName() const {}

FormController& Document::GetFormController() {}

DocumentState* Document::GetDocumentState() const {}

void Document::SetStateForNewControls(const Vector<String>& state_vector) {}

LocalFrameView* Document::View() const {}

LocalFrame* Document::GetFrame() const {}

Page* Document::GetPage() const {}

Settings* Document::GetSettings() const {}

Range* Document::createRange() {}

NodeIterator* Document::createNodeIterator(Node* root,
                                           unsigned what_to_show,
                                           V8NodeFilter* filter) {}

TreeWalker* Document::createTreeWalker(Node* root,
                                       unsigned what_to_show,
                                       V8NodeFilter* filter) {}

Document::StyleAndLayoutTreeUpdate Document::CalculateStyleAndLayoutTreeUpdate()
    const {}

Document::StyleAndLayoutTreeUpdate
Document::CalculateStyleAndLayoutTreeUpdateForThisDocument() const {}

Document::StyleAndLayoutTreeUpdate
Document::CalculateStyleAndLayoutTreeUpdateForParentFrame() const {}

bool Document::ShouldScheduleLayoutTreeUpdate() const {}

void Document::ScheduleLayoutTreeUpdate() {}

bool Document::HasPendingForcedStyleRecalc() const {}

void Document::UpdateStyleInvalidationIfNeeded() {}

#if DCHECK_IS_ON()
static void AssertNodeClean(const Node& node) {}

static void AssertLayoutTreeUpdatedForPseudoElements(const Element& element) {}

static void AssertLayoutTreeUpdated(Node& root,
                                    bool allow_dirty_container_subtrees) {}

#endif

#if EXPENSIVE_DCHECKS_ARE_ON()
void Document::AssertLayoutTreeUpdatedAfterLayout() {}
#endif

void Document::UpdateStyleAndLayoutTree() {}

void Document::UpdateStyleAndLayoutTree(LayoutUpgrade& upgrade) {}

void Document::UpdateStyleAndLayoutTreeForThisDocument() {}

void Document::InvalidateStyleAndLayoutForFontUpdates() {}

void Document::UpdateStyle() {}

bool Document::NeedsLayoutTreeUpdateForNode(const Node& node) const {}

bool Document::NeedsLayoutTreeUpdateForNodeIncludingDisplayLocked(
    const Node& node) const {}

void Document::UpdateStyleAndLayoutTreeForElement(const Element* element,
                                                  DocumentUpdateReason) {}

void Document::UpdateStyleAndLayoutTreeForSubtree(const Element* element,
                                                  DocumentUpdateReason) {}

void Document::UpdateStyleAndLayoutForRange(const Range* range,
                                            DocumentUpdateReason reason) {}

void Document::UpdateStyleAndLayoutForNode(const Node* node,
                                           DocumentUpdateReason reason) {}

DocumentPartRoot& Document::getPartRoot() {}

DocumentPartRoot& Document::EnsureDocumentPartRoot() {}

void Document::ApplyScrollRestorationLogic() {}

void Document::MarkHasFindInPageRequest() {}

void Document::MarkHasFindInPageContentVisibilityActiveMatch() {}

void Document::MarkHasFindInPageBeforematchExpandedHiddenMatchable() {}

void Document::UpdateStyleAndLayout(DocumentUpdateReason reason) {}

void Document::LayoutUpdated() {}

void Document::AttachCompositorTimeline(cc::AnimationTimeline* timeline) const {}

void Document::ClearFocusedElementIfNeeded() {}

void Document::ClearFocusedElementTimerFired(TimerBase*) {}

void Document::EnsurePaintLocationDataValidForNode(
    const Node* node,
    DocumentUpdateReason reason) {}

WebPrintPageDescription Document::GetPageDescription(uint32_t page_index) {}

void Document::SetIsXrOverlay(bool val, Element* overlay_element) {}

void Document::ScheduleUseShadowTreeUpdate(SVGUseElement& element) {}

void Document::UnscheduleUseShadowTreeUpdate(SVGUseElement& element) {}

void Document::UpdateUseShadowTreesIfNeeded() {}

void Document::ScheduleSVGResourceInvalidation(LocalSVGResource& resource) {}

void Document::InvalidatePendingSVGResources() {}

StyleResolver& Document::GetStyleResolver() const {}

void Document::Initialize() {}

void Document::Shutdown() {}

void Document::RemovedEventListener(
    const AtomicString& event_type,
    const RegisteredEventListener& registered_listener) {}

void Document::RemoveAllEventListeners() {}

Document& Document::AXObjectCacheOwner() const {}

static ui::AXMode ComputeAXModeFromAXContexts(Vector<AXContext*> ax_contexts) {}

namespace {

// Simple count of AXObjectCache objects that are reachable from Documents. The
// count assumes that multiple Documents in a single process can have such
// caches and that the caches will only ever be created from the main rendering
// thread.
size_t g_ax_object_cache_count =;

}  // namespace

void Document::AddAXContext(AXContext* context) {}

void Document::AXContextModeChanged() {}

void Document::RemoveAXContext(AXContext* context) {}

void Document::ClearAXObjectCache() {}

AXObjectCache* Document::ExistingAXObjectCache() const {}

void Document::RefreshAccessibilityTree() const {}

CanvasFontCache* Document::GetCanvasFontCache() {}

DocumentParser* Document::CreateParser() {}

bool Document::IsFrameSet() const {}

ScriptableDocumentParser* Document::GetScriptableDocumentParser() const {}

void Document::DisplayNoneChangedForFrame() {}

bool Document::WillPrintSoon() {}

bool Document::InitiateStyleOrLayoutDependentLoadForPrint() {}

void Document::SetPrinting(PrintingState state) {}

// https://html.spec.whatwg.org/C/dynamic-markup-insertion.html#document-open-steps
void Document::open(LocalDOMWindow* entered_window,
                    ExceptionState& exception_state) {}

// https://html.spec.whatwg.org/C/dynamic-markup-insertion.html#document-open-steps
void Document::open() {}

void Document::DetachParser() {}

void Document::CancelParsing() {}

DocumentParser* Document::OpenForNavigation(
    ParserSynchronizationPolicy parser_sync_policy,
    const AtomicString& mime_type,
    const AtomicString& encoding) {}

DocumentParser* Document::ImplicitOpen(
    ParserSynchronizationPolicy parser_sync_policy) {}

void Document::DispatchHandleLoadStart() {}

void Document::DispatchHandleLoadComplete() {}

HTMLElement* Document::body() const {}

HTMLBodyElement* Document::FirstBodyElement() const {}

void Document::setBody(HTMLElement* prp_new_body,
                       ExceptionState& exception_state) {}

void Document::WillInsertBody() {}

HTMLHeadElement* Document::head() const {}

Element* Document::ViewportDefiningElement() const {}

Document* Document::open(v8::Isolate* isolate,
                         const AtomicString& type,
                         const AtomicString& replace,
                         ExceptionState& exception_state) {}

DOMWindow* Document::open(v8::Isolate* isolate,
                          const String& url_string,
                          const AtomicString& name,
                          const AtomicString& features,
                          ExceptionState& exception_state) {}

// https://html.spec.whatwg.org/C/dynamic-markup-insertion.html#dom-document-close
void Document::close(ExceptionState& exception_state) {}

// https://html.spec.whatwg.org/C/dynamic-markup-insertion.html#dom-document-close
void Document::close() {}

void Document::ImplicitClose() {}

static bool AllDescendantsAreComplete(Document* document) {}

bool Document::ShouldComplete() {}

void Document::Abort() {}

void Document::CheckCompleted() {}

void Document::FetchDictionaryFromLinkHeader() {}

bool Document::CheckCompletedInternal() {}

namespace {

enum class BeforeUnloadUse {};

void RecordBeforeUnloadUse(BeforeUnloadUse metric) {}

}  // namespace

bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client,
                                         bool is_reload,
                                         bool& did_allow_navigation) {}

void Document::DispatchUnloadEvents(UnloadEventTimingInfo* unload_timing_info) {}

void Document::DispatchFreezeEvent() {}

Document::PageDismissalType Document::PageDismissalEventBeingDispatched()
    const {}

void Document::SetParsingState(ParsingState parsing_state) {}

bool Document::ShouldScheduleLayout() const {}

void Document::write(const String& text,
                     LocalDOMWindow* entered_window,
                     ExceptionState& exception_state) {}

void Document::writeln(const String& text,
                       LocalDOMWindow* entered_window,
                       ExceptionState& exception_state) {}

void Document::write(v8::Isolate* isolate,
                     const Vector<String>& text,
                     ExceptionState& exception_state) {}

void Document::writeln(v8::Isolate* isolate,
                       const Vector<String>& text,
                       ExceptionState& exception_state) {}

void Document::write(v8::Isolate* isolate,
                     TrustedHTML* text,
                     ExceptionState& exception_state) {}

void Document::writeln(v8::Isolate* isolate,
                       TrustedHTML* text,
                       ExceptionState& exception_state) {}

KURL Document::urlForBinding() const {}

void Document::SetURL(const KURL& url) {}

KURL Document::ValidBaseElementURL() const {}

void Document::UpdateBaseURL() {}

// [spec] https://html.spec.whatwg.org/C/#fallback-base-url
KURL Document::FallbackBaseURL() const {}

const KURL& Document::BaseURL() const {}

void Document::SetBaseURLOverride(const KURL& url) {}

void Document::ProcessBaseElement() {}

void Document::DidAddPendingParserBlockingStylesheet() {}

void Document::DidRemoveAllPendingStylesheets() {}

void Document::DidLoadAllPendingParserBlockingStylesheets() {}

void Document::DidLoadAllScriptBlockingResources() {}

void Document::ExecuteScriptsWaitingForResources() {}

CSSStyleSheet& Document::ElementSheet() {}

bool Document::InvalidationDisallowed() const {}

void Document::MaybeHandleHttpRefresh(const String& content,
                                      HttpRefreshType http_refresh_type) {}

bool Document::IsHttpRefreshScheduledWithin(base::TimeDelta interval) {}

bool Document::HasDocumentPictureInPictureWindow() const {}

network::mojom::ReferrerPolicy Document::GetReferrerPolicy() const {}

MouseEventWithHitTestResults Document::PerformMouseEventHitTest(
    const HitTestRequest& request,
    const PhysicalOffset& document_point,
    const WebMouseEvent& event) {}

// DOM Section 1.1.1
bool Document::ChildTypeAllowed(NodeType type) const {}

// This is an implementation of step 6 of
// https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
// and https://dom.spec.whatwg.org/#concept-node-replace .
//
// 6. If parent is a document, and any of the statements below, switched on
// node, are true, throw a HierarchyRequestError.
//  -> DocumentFragment node
//     If node has more than one element child or has a Text node child.
//     Otherwise, if node has one element child and either parent has an element
//     child, child is a doctype, or child is not null and a doctype is
//     following child.
//  -> element
//     parent has an element child, child is a doctype, or child is not null and
//     a doctype is following child.
//  -> doctype
//     parent has a doctype child, child is non-null and an element is preceding
//     child, or child is null and parent has an element child.
//
// 6. If parent is a document, and any of the statements below, switched on
// node, are true, throw a HierarchyRequestError.
//  -> DocumentFragment node
//     If node has more than one element child or has a Text node child.
//     Otherwise, if node has one element child and either parent has an element
//     child that is not child or a doctype is following child.
//  -> element
//     parent has an element child that is not child or a doctype is following
//     child.
//  -> doctype
//     parent has a doctype child that is not child, or an element is preceding
//     child.
bool Document::CanAcceptChild(const Node& new_child,
                              const Node* next,
                              const Node* old_child,
                              ExceptionState& exception_state) const {}

Node* Document::Clone(Document& factory,
                      NodeCloningData& data,
                      ContainerNode* append_to,
                      ExceptionState& append_exception_state) const {}

ResizeObserver& Document::EnsureResizeObserver() {}

void Document::ObserveForIntrinsicSize(Element* element) {}

void Document::UnobserveForIntrinsicSize(Element* element) {}

class LazyLoadedAutoSizedImgResizeObserverDelegate final
    : public ResizeObserver::Delegate {};

ResizeObserver& Document::GetLazyLoadedAutoSizedImgObserver() {}

void Document::ObserveForLazyLoadedAutoSizedImg(HTMLImageElement* img) {}

void Document::UnobserveForLazyLoadedAutoSizedImg(HTMLImageElement* img) {}

Document* Document::CloneDocumentWithoutChildren() const {}

void Document::CloneDataFromDocument(const Document& other) {}

void Document::EvaluateMediaQueryListIfNeeded() {}

void Document::EvaluateMediaQueryList() {}

void Document::LayoutViewportWasResized() {}

void Document::MarkViewportUnitsDirty() {}

void Document::DynamicViewportUnitsChanged() {}

void EmitDidChangeHoverElement(Document& document, Element* new_hover_element) {}

void Document::SetHoverElement(Element* new_hover_element) {}

void Document::SetActiveElement(Element* new_active_element) {}

void Document::RemoveFocusedElementOfSubtree(Node& node,
                                             bool among_children_only) {}

static Element* SkipDisplayNoneAncestors(Element* element) {}

static Element* SkipDisplayNoneAncestorsOrReturnNullIfFlatTreeIsDirty(
    Element& element) {}

void Document::HoveredElementDetached(Element& element) {}

void Document::ActiveChainNodeDetached(Element& element) {}

const Vector<DraggableRegionValue>& Document::DraggableRegions() const {}

void Document::SetDraggableRegions(
    const Vector<DraggableRegionValue>& regions) {}

void Document::SetLastFocusType(mojom::blink::FocusType last_focus_type) {}

bool Document::SetFocusedElement(Element* new_focused_element,
                                 const FocusParams& params) {}

void Document::ClearFocusedElement(bool omit_blur_events) {}

void Document::SendFocusNotification(Element* new_focused_element,
                                     mojom::blink::FocusType focus_type) {}

void Document::NotifyFocusedElementChanged(Element* old_focused_element,
                                           Element* new_focused_element,
                                           mojom::blink::FocusType focus_type) {}

// This forwards to the TreeScope implementation.
void Document::OnAdoptedStyleSheetSet(
    ScriptState* script_state,
    V8ObservableArrayCSSStyleSheet& observable_array,
    uint32_t index,
    Member<CSSStyleSheet>& sheet,
    ExceptionState& exception_state) {}

// This forwards to the TreeScope implementation.
void Document::OnAdoptedStyleSheetDelete(
    ScriptState* script_state,
    V8ObservableArrayCSSStyleSheet& observable_array,
    uint32_t index,
    ExceptionState& exception_state) {}

void Document::SetSequentialFocusNavigationStartingPoint(Node* node) {}

Element* Document::SequentialFocusNavigationStartingPoint(
    mojom::blink::FocusType type) const {}

void Document::SetSelectorFragmentAnchorCSSTarget(Element* new_target) {}

void Document::SetCSSTarget(Element* new_target) {}

void Document::RegisterNodeList(const LiveNodeListBase* list) {}

void Document::UnregisterNodeList(const LiveNodeListBase* list) {}

void Document::RegisterNodeListWithIdNameCache(const LiveNodeListBase* list) {}

void Document::UnregisterNodeListWithIdNameCache(const LiveNodeListBase* list) {}

void Document::AttachNodeIterator(NodeIterator* ni) {}

void Document::DetachNodeIterator(NodeIterator* ni) {}

void Document::MoveNodeIteratorsToNewDocument(Node& node,
                                              Document& new_document) {}

void Document::DidMoveTreeToNewDocument(const Node& root) {}

void Document::NodeChildrenWillBeRemoved(ContainerNode& container) {}

void Document::NodeWillBeRemoved(Node& n) {}

void Document::NotifyUpdateCharacterData(CharacterData* character_data,
                                         const TextDiffRange& diff) {}

void Document::NotifyChangeChildren(
    const ContainerNode& container,
    const ContainerNode::ChildrenChange& change) {}

void Document::NotifyAttributeChanged(const Element& element,
                                      const QualifiedName& name,
                                      const AtomicString& old_value,
                                      const AtomicString& new_value) {}

void Document::DidInsertText(const CharacterData& text,
                             unsigned offset,
                             unsigned length) {}

void Document::DidRemoveText(const CharacterData& text,
                             unsigned offset,
                             unsigned length) {}

void Document::DidMergeTextNodes(const Text& merged_node,
                                 const Text& node_to_be_removed,
                                 unsigned old_length) {}

void Document::DidSplitTextNode(const Text& old_node) {}

void Document::SetWindowAttributeEventListener(const AtomicString& event_type,
                                               EventListener* listener) {}

EventListener* Document::GetWindowAttributeEventListener(
    const AtomicString& event_type) {}

void Document::EnqueueDisplayLockActivationTask(base::OnceClosure task) {}

void Document::EnqueueAnimationFrameTask(base::OnceClosure task) {}

void Document::EnqueueAnimationFrameEvent(Event* event) {}

void Document::EnqueueUniqueAnimationFrameEvent(Event* event) {}

void Document::EnqueueScrollEventForNode(Node* target) {}

void Document::EnqueueScrollEndEventForNode(Node* target) {}

void Document::EnqueueOverscrollEventForNode(Node* target,
                                             double delta_x,
                                             double delta_y) {}

void Document::EnqueueScrollSnapChangeEvent(Node* target,
                                            Member<Node>& block_target,
                                            Member<Node>& inline_target) {}

void Document::EnqueueScrollSnapChangingEvent(Node* target,
                                              Member<Node>& block_target,
                                              Member<Node>& inline_target) {}

void Document::EnqueueMoveEvent() {}

void Document::EnqueueResizeEvent() {}

void Document::EnqueueMediaQueryChangeListeners(
    HeapVector<Member<MediaQueryListListener>>& listeners) {}

void Document::EnqueueVisualViewportScrollEvent() {}

void Document::EnqueueVisualViewportScrollEndEvent() {}

void Document::EnqueueVisualViewportResizeEvent() {}

void Document::DispatchEventsForPrinting() {}

Document::EventFactorySet& Document::EventFactories() {}

void Document::RegisterEventFactory(
    std::unique_ptr<EventFactoryBase> event_factory) {}

Event* Document::createEvent(ScriptState* script_state,
                             const String& event_type,
                             ExceptionState& exception_state) {}

void Document::AddMutationEventListenerTypeIfEnabled(
    ListenerType listener_type) {}

bool Document::HasListenerType(ListenerType listener_type) const {}

void Document::AddListenerTypeIfNeeded(const AtomicString& event_type,
                                       EventTarget& event_target) {}

void Document::DidAddEventListeners(uint32_t count) {}

void Document::DidRemoveEventListeners(uint32_t count) {}

HTMLFrameOwnerElement* Document::LocalOwner() const {}

void Document::WillChangeFrameOwnerProperties(
    int margin_width,
    int margin_height,
    mojom::blink::ScrollbarMode scrollbar_mode,
    bool is_display_none,
    mojom::blink::ColorScheme color_scheme,
    mojom::blink::PreferredColorScheme preferred_color_scheme) {}

String Document::cookie(ExceptionState& exception_state) const {}

void Document::setCookie(const String& value, ExceptionState& exception_state) {}

bool Document::CookiesEnabled() const {}

void Document::SetCookieManager(
    mojo::PendingRemote<network::mojom::blink::RestrictedCookieManager>
        cookie_manager) {}

const base::Uuid& Document::base_auction_nonce() {}

const AtomicString& Document::referrer() const {}

String Document::domain() const {}

void Document::setDomain(const String& raw_domain,
                         ExceptionState& exception_state) {}

std::optional<base::Time> Document::lastModifiedTime() const {}

// https://html.spec.whatwg.org/C#dom-document-lastmodified
String Document::lastModified() const {}

scoped_refptr<const SecurityOrigin> Document::TopFrameOrigin() const {}

net::SiteForCookies Document::SiteForCookies() const {}

mojom::blink::PermissionService* Document::GetPermissionService(
    ExecutionContext* execution_context) {}

void Document::PermissionServiceConnectionError() {}

FragmentDirective& Document::fragmentDirective() const {}

ScriptPromise<IDLBoolean> Document::hasPrivateToken(
    ScriptState* script_state,
    const String& issuer,
    ExceptionState& exception_state) {}

ScriptPromise<IDLBoolean> Document::hasRedemptionRecord(
    ScriptState* script_state,
    const String& issuer,
    ExceptionState& exception_state) {}

void Document::TrustTokenQueryAnswererConnectionError() {}

void Document::ariaNotify(const String& announcement,
                          const AriaNotificationOptions* options) {}

static bool IsValidNameNonASCII(const LChar* characters, unsigned length) {}

static bool IsValidNameNonASCII(const UChar* characters, unsigned length) {}

template <typename CharType>
static inline bool IsValidNameASCII(const CharType* characters,
                                    unsigned length) {}

bool Document::IsValidName(const StringView& name) {}

enum QualifiedNameStatus {};

struct ParseQualifiedNameResult {};

template <typename CharType>
static ParseQualifiedNameResult ParseQualifiedNameInternal(
    const AtomicString& qualified_name,
    const CharType* characters,
    unsigned length,
    AtomicString& prefix,
    AtomicString& local_name) {}

bool Document::ParseQualifiedName(const AtomicString& qualified_name,
                                  AtomicString& prefix,
                                  AtomicString& local_name,
                                  ExceptionState& exception_state) {}

void Document::SetEncodingData(const DocumentEncodingData& new_data) {}

KURL Document::CompleteURL(
    const String& url,
    const CompleteURLPreloadStatus preload_status) const {}

KURL Document::CompleteURLWithOverride(
    const String& url,
    const KURL& base_url_override,
    CompleteURLPreloadStatus preload_status) const {}

// static
bool Document::ShouldInheritSecurityOriginFromOwner(const KURL& url) {}

KURL Document::OpenSearchDescriptionURL() {}

V8HTMLOrSVGScriptElement* Document::currentScriptForBinding() const {}

void Document::PushCurrentScript(ScriptElementBase* new_current_script) {}

void Document::PopCurrentScript(ScriptElementBase* script) {}

void Document::SetTransformSource(std::unique_ptr<TransformSource> source) {}

String Document::designMode() const {}

void Document::setDesignMode(const String& value) {}

Document* Document::ParentDocument() const {}

Document& Document::TopDocument() const {}

ExecutionContext* Document::GetExecutionContext() const {}

Agent& Document::GetAgent() const {}

Attr* Document::createAttribute(const AtomicString& name,
                                ExceptionState& exception_state) {}

Attr* Document::createAttributeNS(const AtomicString& namespace_uri,
                                  const AtomicString& qualified_name,
                                  ExceptionState& exception_state) {}

const SVGDocumentExtensions* Document::SvgExtensions() const {}

SVGDocumentExtensions& Document::AccessSVGExtensions() {}

bool Document::HasSVGRootNode() const {}

HTMLCollection* Document::images() {}

HTMLCollection* Document::applets() {}

HTMLCollection* Document::embeds() {}

HTMLCollection* Document::scripts() {}

HTMLCollection* Document::links() {}

HTMLCollection* Document::forms() {}

HTMLCollection* Document::anchors() {}

HTMLAllCollection* Document::all() {}

HTMLCollection* Document::WindowNamedItems(const AtomicString& name) {}

DocumentNameCollection* Document::DocumentNamedItems(const AtomicString& name) {}

HTMLCollection* Document::DocumentAllNamedItems(const AtomicString& name) {}

void Document::IncrementImmediateChildFrameCreationCount() {}

int Document::GetImmediateChildFrameCreationCount() const {}

DOMWindow* Document::defaultView() const {}

AllowState Document::GetDeclarativeShadowRootAllowState() const {}

void Document::setAllowDeclarativeShadowRoots(bool val) {}

void Document::MaybeExecuteDelayedAsyncScripts(
    MilestoneForDelayedAsyncScript milestone) {}

void Document::MarkFirstPaint() {}

void Document::OnPaintFinished() {}

void Document::OnLargestContentfulPaintUpdated() {}

void Document::OnPrepareToStopParsing() {}

void Document::FinishedParsing() {}

void Document::ElementDataCacheClearTimerFired(TimerBase*) {}

void Document::BeginLifecycleUpdatesIfRenderingReady() {}

Vector<IconURL> Document::IconURLs(int icon_types_mask) {}

void Document::UpdateThemeColorCache() {}

std::optional<Color> Document::ThemeColor() {}

void Document::UpdateAppTitle() {}

void Document::ColorSchemeMetaChanged() {}

void Document::SupportsReducedMotionMetaChanged() {}

bool Document::ShouldForceReduceMotion() const {}

static HTMLLinkElement* GetLinkElement(const Document* doc,
                                       bool (*match_fn)(HTMLLinkElement&)) {}

HTMLLinkElement* Document::LinkManifest() const {}

HTMLLinkElement* Document::LinkCanonical() const {}

ukm::UkmRecorder* Document::UkmRecorder() {}

ukm::SourceId Document::UkmSourceID() const {}

FontMatchingMetrics* Document::GetFontMatchingMetrics() {}

void Document::MaybeRecordShapeTextElapsedTime(base::TimeDelta elapsed_time) {}

void Document::MaybeRecordSvgImageProcessingTime(
    int data_change_count,
    base::TimeDelta data_change_elapsed_time) const {}

bool Document::AllowInlineEventHandler(Node* node,
                                       EventListener* listener,
                                       const String& context_url,
                                       const WTF::OrdinalNumber& context_line) {}

void Document::UpdateSelectionAfterLayout() {}

void Document::AttachRange(Range* range) {}

void Document::DetachRange(Range* range) {}

void Document::InitDNSPrefetch() {}

void Document::ParseDNSPrefetchControlHeader(
    const String& dns_prefetch_control) {}

IntersectionObserverController* Document::GetIntersectionObserverController() {}

IntersectionObserverController&
Document::EnsureIntersectionObserverController() {}

ElementIntersectionObserverData*
Document::DocumentExplicitRootIntersectionObserverData() const {}

ElementIntersectionObserverData&
Document::EnsureDocumentExplicitRootIntersectionObserverData() {}

const ScriptRegexp& Document::EnsureEmailRegexp() const {}

void Document::SetMediaFeatureEvaluated(int feature) {}

bool Document::WasMediaFeatureEvaluated(int feature) {}

void Document::AddConsoleMessage(ConsoleMessage* message,
                                 bool discard_duplicates) const {}

void Document::AddToTopLayer(Element* element, const Element* before) {}

void Document::ScheduleForTopLayerRemoval(Element* element,
                                          TopLayerReason reason) {}

void Document::RemoveFinishedTopLayerElements() {}

void Document::RemoveFromTopLayerImmediately(Element* element) {}

std::optional<Document::TopLayerReason> Document::IsScheduledForTopLayerRemoval(
    Element* element) const {}

HTMLDialogElement* Document::ActiveModalDialog() const {}

HTMLElement* Document::TopmostPopoverOrHint() const {}
void Document::SetPopoverPointerdownTarget(const HTMLElement* popover) {}

void Document::exitPointerLock() {}

Element* Document::PointerLockElement() const {}

void Document::DecrementLoadEventDelayCount() {}

void Document::DecrementLoadEventDelayCountAndCheckLoadEvent() {}

void Document::CheckLoadEventSoon() {}

bool Document::IsDelayingLoadEvent() {}

void Document::LoadEventDelayTimerFired(TimerBase*) {}

void Document::LoadPluginsSoon() {}

void Document::PluginLoadingTimerFired(TimerBase*) {}

ScriptedAnimationController& Document::GetScriptedAnimationController() {}

int Document::RequestAnimationFrame(FrameCallback* callback) {}

void Document::CancelAnimationFrame(int id) {}

DocumentLoader* Document::Loader() const {}

Node* EventTargetNodeForDocument(Document* doc) {}

void Document::AdjustQuadsForScrollAndAbsoluteZoom(
    Vector<gfx::QuadF>& quads,
    const LayoutObject& layout_object) const {}

void Document::AdjustRectForScrollAndAbsoluteZoom(
    gfx::RectF& rect,
    const LayoutObject& layout_object) const {}

void Document::SetForceSynchronousParsingForTesting(bool enabled) {}

bool Document::ForceSynchronousParsingForTesting() {}

void Document::UpdateHoverActiveState(bool is_active,
                                      bool update_active_chain,
                                      Element* inner_element) {}

void Document::UpdateActiveState(bool is_active,
                                 bool update_active_chain,
                                 Element* new_active_element) {}

void Document::UpdateHoverState(Element* inner_element_in_document) {}

bool Document::HaveScriptBlockingStylesheetsLoaded() const {}

bool Document::HaveRenderBlockingStylesheetsLoaded() const {}

bool Document::HaveRenderBlockingResourcesLoaded() const {}

Locale& Document::GetCachedLocale(const AtomicString& locale) {}

AnimationClock& Document::GetAnimationClock() {}

const AnimationClock& Document::GetAnimationClock() const {}

Document& Document::EnsureTemplateDocument() {}

void Document::DidChangeFormRelatedElementDynamically(
    HTMLElement* element,
    WebFormRelatedChangeType form_related_change) {}

float Document::DevicePixelRatio() const {}

TextAutosizer* Document::GetTextAutosizer() {}

bool Document::SetPseudoStateForTesting(Element& element,
                                        const String& pseudo,
                                        bool matches) {}

void Document::EnqueueAutofocusCandidate(Element& element) {}

bool Document::HasAutofocusCandidates() const {}

// https://html.spec.whatwg.org/C/#flush-autofocus-candidates
void Document::FlushAutofocusCandidates() {}

void Document::FinalizeAutofocus() {}

// https://html.spec.whatwg.org/C/#autofocus-delegate, although most uses are
// of Element::GetAutofocusDelegate().
Element* Document::GetAutofocusDelegate() const {}

Element* Document::ActiveElement() const {}

bool Document::hasFocus() const {}

const AtomicString& Document::BodyAttributeValue(
    const QualifiedName& name) const {}

void Document::SetBodyAttribute(const QualifiedName& name,
                                const AtomicString& value) {}

const AtomicString& Document::bgColor() const {}

void Document::setBgColor(const AtomicString& value) {}

const AtomicString& Document::fgColor() const {}

void Document::setFgColor(const AtomicString& value) {}

const AtomicString& Document::alinkColor() const {}

void Document::setAlinkColor(const AtomicString& value) {}

const AtomicString& Document::linkColor() const {}

void Document::setLinkColor(const AtomicString& value) {}

const AtomicString& Document::vlinkColor() const {}

void Document::setVlinkColor(const AtomicString& value) {}

FontFaceSet* Document::fonts() {}

template <unsigned type>
bool ShouldInvalidateNodeListCachesForAttr(
    const LiveNodeListRegistry& node_lists,
    const QualifiedName& attr_name) {}

template <>
bool ShouldInvalidateNodeListCachesForAttr<kNumNodeListInvalidationTypes>(
    const LiveNodeListRegistry&,
    const QualifiedName&) {}

bool Document::ShouldInvalidateNodeListCaches(
    const QualifiedName* attr_name) const {}

void Document::InvalidateNodeListCaches(const QualifiedName* attr_name) {}

void Document::PlatformColorsChanged() {}

PropertyRegistry& Document::EnsurePropertyRegistry() {}

DocumentResourceCoordinator* Document::GetResourceCoordinator() {}

scoped_refptr<base::SingleThreadTaskRunner> Document::GetTaskRunner(
    TaskType type) {}

DOMFeaturePolicy* Document::featurePolicy() {}

StylePropertyMapReadOnly* Document::ComputedStyleMap(Element* element) {}

void Document::AddComputedStyleMapItem(
    Element* element,
    StylePropertyMapReadOnly* computed_style) {}

StylePropertyMapReadOnly* Document::RemoveComputedStyleMapItem(
    Element* element) {}

void Document::DelayAsyncScriptExecution() {}

void Document::ResumeAsyncScriptExecution() {}

void Document::Trace(Visitor* visitor) const {}

SlotAssignmentEngine& Document::GetSlotAssignmentEngine() {}

bool Document::IsSlotAssignmentDirty() const {}

bool Document::IsFocusAllowed() const {}

LazyLoadImageObserver& Document::EnsureLazyLoadImageObserver() {}

void Document::IncrementNumberOfCanvases() {}

void Document::ExecuteJavaScriptUrls() {}

void Document::ProcessJavaScriptUrl(const KURL& url,
                                    const DOMWrapperWorld* world) {}

DisplayLockDocumentState& Document::GetDisplayLockDocumentState() const {}

void Document::CancelPendingJavaScriptUrls() {}

bool Document::IsInWebAppScope() const {}

bool Document::ChildrenCanHaveStyle() const {}

ComputedAccessibleNode* Document::GetOrCreateComputedAccessibleNode(AXID axid) {}

void Document::SetShowBeforeUnloadDialog(bool show_dialog) {}

mojom::blink::PreferredColorScheme Document::GetPreferredColorScheme() const {}

void Document::ColorSchemeChanged() {}

void Document::VisionDeficiencyChanged() {}

void Document::UpdateForcedColors() {}

bool Document::InForcedColorsMode() const {}

bool Document::InDarkMode() {}

const ui::ColorProvider* Document::GetColorProviderForPainting(
    mojom::blink::ColorScheme color_scheme) const {}

void Document::CountUse(mojom::WebFeature feature) const {}

void Document::CountUse(mojom::WebFeature feature) {}

void Document::CountDeprecation(mojom::WebFeature feature) {}

void Document::CountWebDXFeature(mojom::blink::WebDXFeature feature) const {}

void Document::CountWebDXFeature(mojom::blink::WebDXFeature feature) {}

void Document::CountProperty(CSSPropertyID property) const {}

void Document::CountAnimatedProperty(CSSPropertyID property) const {}

bool Document::IsUseCounted(mojom::WebFeature feature) const {}

bool Document::IsWebDXFeatureCounted(mojom::blink::WebDXFeature feature) const {}

bool Document::IsPropertyCounted(CSSPropertyID property) const {}

bool Document::IsAnimatedPropertyCounted(CSSPropertyID property) const {}

void Document::ClearUseCounterForTesting(mojom::WebFeature feature) {}

void Document::RenderBlockingResourceUnblocked() {}

void Document::SetFindInPageActiveMatchNode(Node* node) {}

const Node* Document::GetFindInPageActiveMatchNode() const {}

void Document::ActivateForPrerendering(
    const mojom::blink::PrerenderPageActivationParams& params) {}

void Document::AddWillDispatchPrerenderingchangeCallback(
    base::OnceClosure closure) {}

void Document::AddPostPrerenderingActivationStep(base::OnceClosure callback) {}

void Document::RunPostPrerenderingActivationSteps() {}

bool Document::InStyleRecalc() const {}

void Document::DelayLoadEventUntilLayoutTreeUpdate() {}

void Document::UnblockLoadEventAfterLayoutTreeUpdate() {}

void Document::AddPendingLinkHeaderPreload(const PendingLinkPreload& preload) {}

void Document::RemovePendingLinkHeaderPreloadIfNeeded(
    const PendingLinkPreload& preload) {}

void Document::AddFocusedElementChangeObserver(
    FocusedElementChangeObserver* observer) {}

void Document::RemoveFocusedElementChangeObserver(
    FocusedElementChangeObserver* observer) {}

void Document::WriteIntoTrace(perfetto::TracedValue ctx) const {}

bool Document::DeferredCompositorCommitIsAllowed() const {}

Document::PaintPreviewScope::PaintPreviewScope(Document& document,
                                               PaintPreviewState state)
    :{}

Document::PaintPreviewScope::~PaintPreviewScope() {}

Document::PendingJavascriptUrl::PendingJavascriptUrl(
    const KURL& input_url,
    const DOMWrapperWorld* world)
    :{}

Document::PendingJavascriptUrl::~PendingJavascriptUrl() = default;

void Document::PendingJavascriptUrl::Trace(Visitor* visitor) const {}

void Document::ResetAgent(Agent& agent) {}

bool Document::SupportsLegacyDOMMutations() {}

void Document::EnqueuePageRevealEvent() {}

Resource* Document::GetPendingLinkPreloadForTesting(const KURL& url) {}

void Document::SetLcpElementFoundInHtml(bool found) {}

bool Document::IsLcpElementFoundInHtml() {}

void Document::ScheduleShadowTreeCreation(HTMLInputElement& element) {}

void Document::UnscheduleShadowTreeCreation(HTMLInputElement& element) {}

#if BUILDFLAG(IS_ANDROID)
void Document::HandlePaymentLink(const KURL& href) {
  // Only the first payment link is expected to be handled in a page.
  if (payment_link_handled_) {
    return;
  }
  // TODO(crbug.com/344997566): Validate the href before triggering the IPC
  // call.
  if (!payment_link_handler_.is_bound()) {
    GetFrame()->GetBrowserInterfaceBroker().GetInterface(
        payment_link_handler_.BindNewPipeAndPassReceiver(
            GetExecutionContext()->GetTaskRunner(TaskType::kDOMManipulation)));
  }
  payment_link_handled_ = true;
  payment_link_handler_->HandlePaymentLink(href);
}
#endif  // BUILDFLAG(IS_ANDROID)

void Document::ProcessScheduledShadowTreeCreationsNow() {}

void Document::ScheduleSelectionchangeEvent() {}

// static
Document* Document::parseHTMLUnsafe(ExecutionContext* context,
                                    const String& html) {}

void Document::SetOverrideSiteForCookiesForCSPMedia(bool value) {}

void Document::OnWarnUnusedPreloads(Vector<KURL> unused_preloads) {}

VisitedLinkState& Document::GetVisitedLinkState() {}

template class CORE_TEMPLATE_EXPORT Supplement<Document>;

}  // namespace blink
#ifndef NDEBUG
static WeakDocumentSet& LiveDocumentSet() {}

void ShowLiveDocumentInstances() {}
#endif