chromium/third_party/blink/renderer/core/testing/internals.cc

/*
 * Copyright (C) 2012 Google Inc. All rights reserved.
 * Copyright (C) 2013 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#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/testing/internals.h"

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

#include "base/functional/function_ref.h"
#include "base/numerics/safe_conversions.h"
#include "base/process/process_handle.h"
#include "base/task/single_thread_task_runner.h"
#include "cc/layers/picture_layer.h"
#include "cc/trees/layer_tree_host.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/abseil-cpp/absl/utility/utility.h"
#include "third_party/blink/public/common/widget/device_emulation_params.h"
#include "third_party/blink/public/mojom/devtools/inspector_issue.mojom-blink.h"
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom-blink.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/animation/document_timeline.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
#include "third_party/blink/renderer/core/css/properties/css_unresolved_property.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/dom/dom_string_list.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/flat_tree_traversal.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/pseudo_element.h"
#include "third_party/blink/renderer/core/dom/range.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/static_node_list.h"
#include "third_party/blink/renderer/core/dom/tree_scope.h"
#include "third_party/blink/renderer/core/editing/drag_caret.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/frame_selection.h"
#include "third_party/blink/renderer/core/editing/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include "third_party/blink/renderer/core/editing/markers/spell_check_marker.h"
#include "third_party/blink/renderer/core/editing/markers/suggestion_marker_properties.h"
#include "third_party/blink/renderer/core/editing/markers/text_match_marker.h"
#include "third_party/blink/renderer/core/editing/plain_text_range.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/editing/spellcheck/idle_spell_check_controller.h"
#include "third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.h"
#include "third_party/blink/renderer/core/editing/spellcheck/spell_checker.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/event_handler_registry.h"
#include "third_party/blink/renderer/core/frame/frame_console.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_view.h"
#include "third_party/blink/renderer/core/frame/performance_monitor.h"
#include "third_party/blink/renderer/core/frame/remote_dom_window.h"
#include "third_party/blink/renderer/core/frame/report.h"
#include "third_party/blink/renderer/core/frame/reporting_context.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/test_report_body.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/geometry/dom_point.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/geometry/dom_rect_list.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_context_creation_attributes_core.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_font_cache.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/html/custom/custom_element.h"
#include "third_party/blink/renderer/core/html/forms/form_controller.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/html_select_element.h"
#include "third_party/blink/renderer/core/html/forms/html_select_list_element.h"
#include "third_party/blink/renderer/core/html/forms/html_text_area_element.h"
#include "third_party/blink/renderer/core/html/forms/text_control_inner_elements.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/html/media/remote_playback_controller.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.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/keyboard_event_manager.h"
#include "third_party/blink/renderer/core/inspector/inspector_audits_issue.h"
#include "third_party/blink/renderer/core/inspector/inspector_issue.h"
#include "third_party/blink/renderer/core/inspector/inspector_issue_conversion.h"
#include "third_party/blink/renderer/core/inspector/main_thread_debugger.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_tree_as_text.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/lcp_critical_path_predictor/element_locator.h"
#include "third_party/blink/renderer/core/lcp_critical_path_predictor/lcp_critical_path_predictor.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/loader/history_item.h"
#include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/print_context.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_controller.h"
#include "third_party/blink/renderer/core/page/spatial_navigation_controller.h"
#include "third_party/blink/renderer/core/page/touch_adjustment.h"
#include "third_party/blink/renderer/core/page/validation_message_client.h"
#include "third_party/blink/renderer/core/page/viewport_description.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/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/import_map.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/scroll/mac_scrollbar_animator.h"
#include "third_party/blink/renderer/core/scroll/programmatic_scroll_animator.h"
#include "third_party/blink/renderer/core/scroll/scroll_animator_base.h"
#include "third_party/blink/renderer/core/scroll/scrollbar_theme.h"
#include "third_party/blink/renderer/core/streams/readable_stream.h"
#include "third_party/blink/renderer/core/streams/readable_stream_default_controller_with_script_scope.h"
#include "third_party/blink/renderer/core/streams/readable_stream_transferring_optimizer.h"
#include "third_party/blink/renderer/core/streams/underlying_sink_base.h"
#include "third_party/blink/renderer/core/streams/underlying_source_base.h"
#include "third_party/blink/renderer/core/streams/writable_stream.h"
#include "third_party/blink/renderer/core/streams/writable_stream_transferring_optimizer.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/core/svg/svg_image_element.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/core/testing/callback_function_test.h"
#include "third_party/blink/renderer/core/testing/dictionary_test.h"
#include "third_party/blink/renderer/core/testing/gc_observation.h"
#include "third_party/blink/renderer/core/testing/hit_test_layer_rect.h"
#include "third_party/blink/renderer/core/testing/hit_test_layer_rect_list.h"
#include "third_party/blink/renderer/core/testing/internal_runtime_flags.h"
#include "third_party/blink/renderer/core/testing/internal_settings.h"
#include "third_party/blink/renderer/core/testing/internals_ukm_recorder.h"
#include "third_party/blink/renderer/core/testing/mock_hyphenation.h"
#include "third_party/blink/renderer/core/testing/origin_trials_test.h"
#include "third_party/blink/renderer/core/testing/record_test.h"
#include "third_party/blink/renderer/core/testing/scoped_mock_overlay_scrollbars.h"
#include "third_party/blink/renderer/core/testing/sequence_test.h"
#include "third_party/blink/renderer/core/testing/static_selection.h"
#include "third_party/blink/renderer/core/testing/type_conversions.h"
#include "third_party/blink/renderer/core/testing/union_types_test.h"
#include "third_party/blink/renderer/core/timezone/timezone_controller.h"
#include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/workers/worker_thread.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_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/graphics/paint/raster_invalidation_tracking.h"
#include "third_party/blink/renderer/platform/heap/cross_thread_handle.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/instance_counters.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/language.h"
#include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h"
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
#include "third_party/blink/renderer/platform/text/layout_locale.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_std.h"
#include "third_party/blink/renderer/platform/wtf/dtoa.h"
#include "third_party/blink/renderer/platform/wtf/text/string_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h"
#include "third_party/blink/renderer/platform/wtf/threading.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-blink.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect.h"
#include "v8/include/v8.h"

namespace blink {

ImeTextSpanThickness;
ImeTextSpanUnderlineStyle;

namespace {

ScopedMockOverlayScrollbars* g_mock_overlay_scrollbars =;

void ResetMockOverlayScrollbars() {}

class UseCounterImplObserverImpl final : public UseCounterImpl::Observer {};

class TestReadableStreamSource : public UnderlyingSourceBase {};

UnderlyingSourceBase*
TestReadableStreamSource::Optimizer::PerformInProcessOptimization(
    ScriptState* script_state) {}

class TestWritableStreamSink final : public UnderlyingSinkBase {};

UnderlyingSinkBase*
TestWritableStreamSink::Optimizer::PerformInProcessOptimization(
    ScriptState* script_state) {}

void OnLCPPredicted(ScriptPromiseResolver<IDLString>* resolver,
                    const Element* lcp_element) {}

}  // namespace

static std::optional<DocumentMarker::MarkerType> MarkerTypeFrom(
    const String& marker_type) {}

static std::optional<DocumentMarker::MarkerTypes> MarkerTypesFrom(
    const String& marker_type) {}

static SpellCheckRequester* GetSpellCheckRequester(Document* document) {}

static ScrollableArea* ScrollableAreaForNode(Node* node) {}

void Internals::ResetToConsistentState(Page* page) {}

Internals::Internals(ExecutionContext* context)
    :{}

Internals::~Internals() {}

LocalFrame* Internals::GetFrame() const {}

InternalSettings* Internals::settings() const {}

InternalRuntimeFlags* Internals::runtimeFlags() const {}

unsigned Internals::workerThreadCount() const {}

GCObservation* Internals::observeGC(ScriptValue script_value,
                                    ExceptionState& exception_state) {}

unsigned Internals::updateStyleAndReturnAffectedElementCount(
    ExceptionState& exception_state) const {}

unsigned Internals::styleForElementCount(
    ExceptionState& exception_state) const {}

unsigned Internals::needsLayoutCount(ExceptionState& exception_state) const {}

unsigned Internals::layoutCountForTesting(
    ExceptionState& exception_state) const {}

bool Internals::nodeNeedsStyleRecalc(Node* node,
                                     ExceptionState& exception_state) const {}

unsigned Internals::hitTestCount(Document* doc,
                                 ExceptionState& exception_state) const {}

unsigned Internals::hitTestCacheHits(Document* doc,
                                     ExceptionState& exception_state) const {}

Element* Internals::elementFromPoint(Document* doc,
                                     double x,
                                     double y,
                                     bool ignore_clipping,
                                     bool allow_child_frame_content,
                                     ExceptionState& exception_state) const {}

void Internals::clearHitTestCache(Document* doc,
                                  ExceptionState& exception_state) const {}

Element* Internals::innerEditorElement(Element* container,
                                       ExceptionState& exception_state) const {}

bool Internals::isPreloaded(const String& url) {}

bool Internals::isPreloadedBy(const String& url, Document* document) {}

bool Internals::isLoading(const String& url) {}

bool Internals::isLoadingFromMemoryCache(const String& url) {}

ScriptPromise<IDLLong> Internals::getInitialResourcePriority(
    ScriptState* script_state,
    const String& url,
    Document* document,
    bool new_load_only) {}

ScriptPromise<IDLLong> Internals::getInitialResourcePriorityOfNewLoad(
    ScriptState* script_state,
    const String& url,
    Document* document) {}

bool Internals::doesWindowHaveUrlFragment(DOMWindow* window) {}

String Internals::getResourceHeader(const String& url,
                                    const String& header,
                                    Document* document) {}

Node* Internals::treeScopeRootNode(Node* node) {}

Node* Internals::parentTreeScope(Node* node) {}

uint16_t Internals::compareTreeScopePosition(
    const Node* node1,
    const Node* node2,
    ExceptionState& exception_state) const {}

void Internals::pauseAnimations(double pause_time,
                                ExceptionState& exception_state) {}

bool Internals::isCompositedAnimation(Animation* animation) {}

void Internals::disableCompositedAnimation(Animation* animation) {}

void Internals::advanceImageAnimation(Element* image,
                                      ExceptionState& exception_state) {}

uint32_t Internals::countElementShadow(const Node* root,
                                       ExceptionState& exception_state) const {}

namespace {

bool CheckForFlatTreeExceptions(Node* node, ExceptionState& exception_state) {}

}  // namespace

Node* Internals::nextSiblingInFlatTree(Node* node,
                                       ExceptionState& exception_state) {}

Node* Internals::firstChildInFlatTree(Node* node,
                                      ExceptionState& exception_state) {}

Node* Internals::lastChildInFlatTree(Node* node,
                                     ExceptionState& exception_state) {}

Node* Internals::nextInFlatTree(Node* node, ExceptionState& exception_state) {}

Node* Internals::previousInFlatTree(Node* node,
                                    ExceptionState& exception_state) {}

String Internals::elementLayoutTreeAsText(Element* element,
                                          ExceptionState& exception_state) {}

CSSStyleDeclaration* Internals::computedStyleIncludingVisitedInfo(
    Element* element) const {}

ShadowRoot* Internals::createUserAgentShadowRoot(Element* host) {}

void Internals::setBrowserControlsState(float top_height,
                                        float bottom_height,
                                        bool shrinks_layout) {}

void Internals::setBrowserControlsShownRatio(float top_ratio,
                                             float bottom_ratio) {}

Node* Internals::effectiveRootScroller(Document* document) {}

ShadowRoot* Internals::shadowRoot(Element* host) {}

String Internals::ShadowRootMode(const Node* root,
                                 ExceptionState& exception_state) const {}

const AtomicString& Internals::shadowPseudoId(Element* element) {}

bool Internals::isValidationMessageVisible(Element* element) {}

void Internals::selectColorInColorChooser(Element* element,
                                          const String& color_value) {}

void Internals::endColorChooser(Element* element) {}

bool Internals::hasAutofocusRequest(Document* document) {}

bool Internals::hasAutofocusRequest() {}

Vector<String> Internals::formControlStateOfHistoryItem(
    ExceptionState& exception_state) {}

void Internals::setFormControlStateOfHistoryItem(
    const Vector<String>& state,
    ExceptionState& exception_state) {}

DOMWindow* Internals::pagePopupWindow() const {}

DOMRectReadOnly* Internals::absoluteCaretBounds(
    ExceptionState& exception_state) {}

String Internals::textAffinity() {}

DOMRectReadOnly* Internals::boundingBox(Element* element) {}

void Internals::setMarker(Document* document,
                          const Range* range,
                          const String& marker_type,
                          ExceptionState& exception_state) {}

void Internals::removeMarker(Document* document,
                             const Range* range,
                             const String& marker_type,
                             ExceptionState& exception_state) {}

unsigned Internals::markerCountForNode(Text* text,
                                       const String& marker_type,
                                       ExceptionState& exception_state) {}

unsigned Internals::activeMarkerCountForNode(Text* text) {}

DocumentMarker* Internals::MarkerAt(Text* text,
                                    const String& marker_type,
                                    unsigned index,
                                    ExceptionState& exception_state) {}

Range* Internals::markerRangeForNode(Text* text,
                                     const String& marker_type,
                                     unsigned index,
                                     ExceptionState& exception_state) {}

String Internals::markerDescriptionForNode(Text* text,
                                           const String& marker_type,
                                           unsigned index,
                                           ExceptionState& exception_state) {}

unsigned Internals::markerBackgroundColorForNode(
    Text* text,
    const String& marker_type,
    unsigned index,
    ExceptionState& exception_state) {}

unsigned Internals::markerUnderlineColorForNode(
    Text* text,
    const String& marker_type,
    unsigned index,
    ExceptionState& exception_state) {}

static std::optional<TextMatchMarker::MatchStatus> MatchStatusFrom(
    const String& match_status) {}

void Internals::addTextMatchMarker(const Range* range,
                                   const String& match_status,
                                   ExceptionState& exception_state) {}

static bool ParseColor(const String& value,
                       Color& color,
                       ExceptionState& exception_state,
                       String error_message) {}

static std::optional<ImeTextSpanThickness> ThicknessFrom(
    const String& thickness) {}

static std::optional<ImeTextSpanUnderlineStyle> UnderlineStyleFrom(
    const String& underline_style) {}

namespace {

void AddStyleableMarkerHelper(const Range* range,
                              const String& underline_color_value,
                              const String& thickness_value,
                              const String& underline_style_value,
                              const String& text_color_value,
                              const String& background_color_value,
                              ExceptionState& exception_state,
                              base::FunctionRef<void(const EphemeralRange&,
                                                     Color,
                                                     ImeTextSpanThickness,
                                                     ImeTextSpanUnderlineStyle,
                                                     Color,
                                                     Color)> create_marker) {}

}  // namespace

void Internals::addCompositionMarker(const Range* range,
                                     const String& underline_color_value,
                                     const String& thickness_value,
                                     const String& underline_style_value,
                                     const String& text_color_value,
                                     const String& background_color_value,
                                     ExceptionState& exception_state) {}

void Internals::addActiveSuggestionMarker(const Range* range,
                                          const String& underline_color_value,
                                          const String& thickness_value,
                                          const String& background_color_value,
                                          ExceptionState& exception_state) {}

void Internals::addSuggestionMarker(
    const Range* range,
    const Vector<String>& suggestions,
    const String& suggestion_highlight_color_value,
    const String& underline_color_value,
    const String& thickness_value,
    const String& background_color_value,
    ExceptionState& exception_state) {}

void Internals::setTextMatchMarkersActive(Node* node,
                                          unsigned start_offset,
                                          unsigned end_offset,
                                          bool active) {}

void Internals::setMarkedTextMatchesAreHighlighted(Document* document,
                                                   bool highlight) {}

String Internals::viewportAsText(Document* document,
                                 float,
                                 int available_width,
                                 int available_height,
                                 ExceptionState& exception_state) {}

bool Internals::elementShouldAutoComplete(Element* element,
                                          ExceptionState& exception_state) {}

String Internals::suggestedValue(Element* element,
                                 ExceptionState& exception_state) {}

void Internals::setSuggestedValue(Element* element,
                                  const String& value,
                                  ExceptionState& exception_state) {}

void Internals::setAutofilledValue(Element* element,
                                   const String& value,
                                   ExceptionState& exception_state) {}

void Internals::setAutofilled(Element* element,
                              bool enabled,
                              ExceptionState& exception_state) {}

void Internals::setSelectionRangeForNumberType(
    Element* input_element,
    uint32_t start,
    uint32_t end,
    ExceptionState& exception_state) {}

Range* Internals::rangeFromLocationAndLength(Element* scope,
                                             int range_location,
                                             int range_length) {}

unsigned Internals::locationFromRange(Element* scope, const Range* range) {}

unsigned Internals::lengthFromRange(Element* scope, const Range* range) {}

String Internals::rangeAsText(const Range* range) {}

void Internals::HitTestRect(HitTestLocation& location,
                            HitTestResult& result,
                            int x,
                            int y,
                            int width,
                            int height,
                            Document* document) {}

// TODO(mustaq): The next 5 functions are very similar, can we combine them?

DOMPoint* Internals::touchPositionAdjustedToBestClickableNode(
    int x,
    int y,
    int width,
    int height,
    Document* document,
    ExceptionState& exception_state) {}

Node* Internals::touchNodeAdjustedToBestClickableNode(
    int x,
    int y,
    int width,
    int height,
    Document* document,
    ExceptionState& exception_state) {}

DOMPoint* Internals::touchPositionAdjustedToBestContextMenuNode(
    int x,
    int y,
    int width,
    int height,
    Document* document,
    ExceptionState& exception_state) {}

Node* Internals::touchNodeAdjustedToBestContextMenuNode(
    int x,
    int y,
    int width,
    int height,
    Document* document,
    ExceptionState& exception_state) {}

Node* Internals::touchNodeAdjustedToBestStylusWritableNode(
    int x,
    int y,
    int width,
    int height,
    Document* document,
    ExceptionState& exception_state) {}

int Internals::lastSpellCheckRequestSequence(Document* document,
                                             ExceptionState& exception_state) {}

int Internals::lastSpellCheckProcessedSequence(
    Document* document,
    ExceptionState& exception_state) {}

int Internals::spellCheckedTextLength(Document* document,
                                      ExceptionState& exception_state) {}

void Internals::cancelCurrentSpellCheckRequest(
    Document* document,
    ExceptionState& exception_state) {}

String Internals::idleTimeSpellCheckerState(Document* document,
                                            ExceptionState& exception_state) {}

void Internals::runIdleTimeSpellChecker(Document* document,
                                        ExceptionState& exception_state) {}

bool Internals::hasLastEditCommand(Document* document,
                                   ExceptionState& exception_state) {}

Vector<AtomicString> Internals::userPreferredLanguages() const {}

// Optimally, the bindings generator would pass a Vector<AtomicString> here but
// this is not supported yet.
void Internals::setUserPreferredLanguages(const Vector<String>& languages) {}

void Internals::setSystemTimeZone(const String& timezone) {}

unsigned Internals::mediaKeysCount() {}

unsigned Internals::mediaKeySessionCount() {}

static unsigned EventHandlerCount(
    Document& document,
    EventHandlerRegistry::EventHandlerClass handler_class) {}

unsigned Internals::wheelEventHandlerCount(Document* document) const {}

unsigned Internals::scrollEventHandlerCount(Document* document) const {}

unsigned Internals::touchStartOrMoveEventHandlerCount(
    Document* document) const {}

unsigned Internals::touchEndOrCancelEventHandlerCount(
    Document* document) const {}

unsigned Internals::pointerEventHandlerCount(Document* document) const {}

// Given a vector of rects, merge those that are adjacent, leaving empty rects
// in the place of no longer used slots. This is intended to simplify the list
// of rects returned by an SkRegion (which have been split apart for sorting
// purposes). No attempt is made to do this efficiently (eg. by relying on the
// sort criteria of SkRegion).
static void MergeRects(Vector<gfx::Rect>& rects) {}

HitTestLayerRectList* Internals::touchEventTargetLayerRects(
    Document* document,
    ExceptionState& exception_state) {}

bool Internals::executeCommand(Document* document,
                               const String& name,
                               const String& value,
                               ExceptionState& exception_state) {}

void Internals::triggerTestInspectorIssue(Document* document) {}

AtomicString Internals::htmlNamespace() {}

Vector<AtomicString> Internals::htmlTags() {}

AtomicString Internals::svgNamespace() {}

Vector<AtomicString> Internals::svgTags() {}

StaticNodeList* Internals::nodesFromRect(
    ScriptState* script_state,
    Document* document,
    int x,
    int y,
    int width,
    int height,
    bool ignore_clipping,
    bool allow_child_frame_content,
    ExceptionState& exception_state) const {}

bool Internals::hasSpellingMarker(Document* document,
                                  int from,
                                  int length,
                                  ExceptionState& exception_state) {}

void Internals::replaceMisspelled(Document* document,
                                  const String& replacement,
                                  ExceptionState& exception_state) {}

bool Internals::canHyphenate(const AtomicString& locale) {}

void Internals::setMockHyphenation(const AtomicString& locale) {}

unsigned Internals::numberOfLiveNodes() const {}

unsigned Internals::numberOfLiveDocuments() const {}

bool Internals::hasGrammarMarker(Document* document,
                                 int from,
                                 int length,
                                 ExceptionState& exception_state) {}

unsigned Internals::numberOfScrollableAreas(Document* document) {}

String Internals::layerTreeAsText(Document* document,
                                  ExceptionState& exception_state) const {}

String Internals::layerTreeAsText(Document* document,
                                  unsigned flags,
                                  ExceptionState& exception_state) const {}

String Internals::mainThreadScrollingReasons(
    Document* document,
    ExceptionState& exception_state) const {}

void Internals::evictAllResources() const {}

String Internals::counterValue(Element* element) {}

int Internals::pageNumber(Element* element,
                          float page_width,
                          float page_height,
                          ExceptionState& exception_state) {}

Vector<String> Internals::IconURLs(Document* document,
                                   int icon_types_mask) const {}

Vector<String> Internals::shortcutIconURLs(Document* document) const {}

Vector<String> Internals::allIconURLs(Document* document) const {}

int Internals::numberOfPages(float page_width,
                             float page_height,
                             ExceptionState& exception_state) {}

float Internals::pageScaleFactor(ExceptionState& exception_state) {}

void Internals::setPageScaleFactor(float scale_factor,
                                   ExceptionState& exception_state) {}

void Internals::setPageScaleFactorLimits(float min_scale_factor,
                                         float max_scale_factor,
                                         ExceptionState& exception_state) {}

float Internals::layoutZoomFactor(ExceptionState& exception_state) {}

void Internals::setIsCursorVisible(Document* document,
                                   bool is_visible,
                                   ExceptionState& exception_state) {}

void Internals::setMaxNumberOfFramesToTen(bool enabled) {}

String Internals::effectivePreload(HTMLMediaElement* media_element) {}

void Internals::mediaPlayerRemoteRouteAvailabilityChanged(
    HTMLMediaElement* media_element,
    bool available) {}

void Internals::mediaPlayerPlayingRemotelyChanged(
    HTMLMediaElement* media_element,
    bool remote) {}

void Internals::setPersistent(HTMLVideoElement* video_element,
                              bool persistent) {}

void Internals::forceStaleStateForMediaElement(HTMLMediaElement* media_element,
                                               int target_state) {}

bool Internals::isMediaElementSuspended(HTMLMediaElement* media_element) {}

void Internals::setMediaControlsTestMode(HTMLMediaElement* media_element,
                                         bool enable) {}

void Internals::registerURLSchemeAsBypassingContentSecurityPolicy(
    const String& scheme) {}

void Internals::registerURLSchemeAsBypassingContentSecurityPolicy(
    const String& scheme,
    const Vector<String>& policy_areas) {}

void Internals::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(
    const String& scheme) {}

TypeConversions* Internals::typeConversions() const {}

DictionaryTest* Internals::dictionaryTest() const {}

RecordTest* Internals::recordTest() const {}

SequenceTest* Internals::sequenceTest() const {}

UnionTypesTest* Internals::unionTypesTest() const {}

InternalsUkmRecorder* Internals::initializeUKMRecorder() {}

OriginTrialsTest* Internals::originTrialsTest() const {}

CallbackFunctionTest* Internals::callbackFunctionTest() const {}

Vector<String> Internals::getReferencedFilePaths() const {}

void Internals::disableReferencedFilePathsVerification() const {}

void Internals::startTrackingRepaints(Document* document,
                                      ExceptionState& exception_state) {}

void Internals::stopTrackingRepaints(Document* document,
                                     ExceptionState& exception_state) {}

void Internals::updateLayoutAndRunPostLayoutTasks(
    Node* node,
    ExceptionState& exception_state) {}

void Internals::forceFullRepaint(Document* document,
                                 ExceptionState& exception_state) {}

DOMRectList* Internals::draggableRegions(Document* document,
                                         ExceptionState& exception_state) {}

DOMRectList* Internals::nonDraggableRegions(Document* document,
                                            ExceptionState& exception_state) {}

void Internals::SetSupportsDraggableRegions(bool supports_draggable_regions) {}

DOMRectList* Internals::DraggableRegions(Document* document,
                                         bool draggable,
                                         ExceptionState& exception_state) {}

static const char* CursorTypeToString(
    ui::mojom::blink::CursorType cursor_type) {}

String Internals::getCurrentCursorInfo() {}

bool Internals::cursorUpdatePending() const {}

DOMArrayBuffer* Internals::serializeObject(
    v8::Isolate* isolate,
    const ScriptValue& value,
    ExceptionState& exception_state) const {}

ScriptValue Internals::deserializeBuffer(v8::Isolate* isolate,
                                         DOMArrayBuffer* buffer) const {}

void Internals::forceReload(bool bypass_cache) {}

StaticSelection* Internals::getDragCaret() {}

StaticSelection* Internals::getSelectionInFlatTree(
    DOMWindow* window,
    ExceptionState& exception_state) {}

Node* Internals::visibleSelectionAnchorNode() {}

unsigned Internals::visibleSelectionAnchorOffset() {}

Node* Internals::visibleSelectionFocusNode() {}

unsigned Internals::visibleSelectionFocusOffset() {}

DOMRect* Internals::selectionBounds(ExceptionState& exception_state) {}

String Internals::markerTextForListItem(Element* element) {}

String Internals::getImageSourceURL(Element* element) {}

void Internals::forceImageReload(Element* element,
                                 ExceptionState& exception_state) {}

String Internals::selectMenuListText(HTMLSelectElement* select) {}

bool Internals::isSelectPopupVisible(Node* node) {}

bool Internals::selectPopupItemStyleIsRtl(Node* node, int item_index) {}

int Internals::selectPopupItemStyleFontHeight(Node* node, int item_index) {}

void Internals::resetTypeAheadSession(HTMLSelectElement* select) {}

void Internals::resetSelectListTypeAheadSession(
    HTMLSelectListElement* selectlist) {}

void Internals::forceCompositingUpdate(Document* document,
                                       ExceptionState& exception_state) {}

void Internals::setForcedColorsAndDarkPreferredColorScheme(Document* document) {}

void Internals::setDarkPreferredColorScheme(Document* document) {}

void Internals::setDarkPreferredRootScrollbarColorScheme(Document* document) {}

void Internals::setShouldRevealPassword(Element* element,
                                        bool reveal,
                                        ExceptionState& exception_state) {}

namespace {

class AddOneFunction : public ScriptFunction::Callable {};

}  // namespace

ScriptPromise<IDLAny> Internals::createResolvedPromise(
    ScriptState* script_state,
    ScriptValue value) {}

ScriptPromise<IDLAny> Internals::createRejectedPromise(
    ScriptState* script_state,
    ScriptValue value) {}

ScriptPromise<IDLAny> Internals::addOneToPromise(ScriptState* script_state,
                                                 ScriptPromiseUntyped promise) {}

ScriptPromise<IDLAny> Internals::promiseCheck(ScriptState* script_state,
                                              int32_t arg1,
                                              bool arg2,
                                              const ScriptValue& arg3,
                                              const String& arg4,
                                              const Vector<String>& arg5,
                                              ExceptionState& exception_state) {}

ScriptPromise<IDLAny> Internals::promiseCheckWithoutExceptionState(
    ScriptState* script_state,
    const ScriptValue& arg1,
    const String& arg2,
    const Vector<String>& arg3) {}

ScriptPromise<IDLAny> Internals::promiseCheckRange(ScriptState* script_state,
                                                   int32_t arg1) {}

ScriptPromise<IDLAny> Internals::promiseCheckOverload(ScriptState* script_state,
                                                      Location*) {}

ScriptPromise<IDLAny> Internals::promiseCheckOverload(ScriptState* script_state,
                                                      Document*) {}

ScriptPromise<IDLAny> Internals::promiseCheckOverload(ScriptState* script_state,
                                                      Location*,
                                                      int32_t,
                                                      int32_t) {}

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

void Internals::setValueForUser(HTMLInputElement* element,
                                const String& value) {}

void Internals::setFocused(bool focused) {}

void Internals::setInitialFocus(bool reverse) {}

bool Internals::isActivated() {}

bool Internals::isInCanvasFontCache(Document* document,
                                    const String& font_string) {}

unsigned Internals::canvasFontCacheMaxFonts() {}

void Internals::forceLoseCanvasContext(HTMLCanvasElement* canvas,
                                       const String& context_type) {}

void Internals::forceLoseCanvasContext(OffscreenCanvas* offscreencanvas,
                                       const String& context_type) {}

void Internals::disableCanvasAcceleration(HTMLCanvasElement* canvas) {}

String Internals::selectedHTMLForClipboard() {}

String Internals::selectedTextForClipboard() {}

void Internals::setVisualViewportOffset(int css_x, int css_y) {}

bool Internals::isUseCounted(Document* document, uint32_t feature) {}

bool Internals::isWebDXFeatureUseCounted(Document* document, uint32_t feature) {}

bool Internals::isCSSPropertyUseCounted(Document* document,
                                        const String& property_name) {}

bool Internals::isAnimatedCSSPropertyUseCounted(Document* document,
                                                const String& property_name) {}

void Internals::clearUseCounter(Document* document, uint32_t feature) {}

Vector<String> Internals::getCSSPropertyLonghands() const {}

Vector<String> Internals::getCSSPropertyShorthands() const {}

Vector<String> Internals::getCSSPropertyAliases() const {}

ScriptPromise<IDLUndefined> Internals::observeUseCounter(
    ScriptState* script_state,
    Document* document,
    uint32_t feature) {}

String Internals::unscopableAttribute() {}

String Internals::unscopableMethod() {}

void Internals::setCapsLockState(bool enabled) {}

void Internals::setPseudoClassState(Element* element,
                                    const String& pseudo,
                                    bool matches,
                                    ExceptionState& exception_state) {}

bool Internals::setScrollbarVisibilityInScrollableArea(Node* node,
                                                       bool visible) {}

double Internals::monotonicTimeToZeroBasedDocumentTime(
    double platform_time,
    ExceptionState& exception_state) {}

int64_t Internals::zeroBasedDocumentTimeToMonotonicTime(double dom_event_time) {}

int64_t Internals::currentTimeTicks() {}

String Internals::getScrollAnimationState(Node* node) const {}

String Internals::getProgrammaticScrollAnimationState(Node* node) const {}

void Internals::crash() {}

String Internals::evaluateInInspectorOverlay(const String& script) {}

void Internals::setIsLowEndDevice(bool is_low_end_device) {}

bool Internals::isLowEndDevice() const {}

Vector<String> Internals::supportedTextEncodingLabels() const {}

void Internals::simulateRasterUnderInvalidations(bool enable) {}

void Internals::DisableIntersectionObserverThrottleDelay() const {}

bool Internals::isSiteIsolated(HTMLIFrameElement* iframe) const {}

bool Internals::isTrackingOcclusionForIFrame(HTMLIFrameElement* iframe) const {}

void Internals::addEmbedderCustomElementName(const AtomicString& name,
                                             ExceptionState& exception_state) {}

String Internals::getParsedImportMap(Document* document,
                                     ExceptionState& exception_state) {}

void Internals::setDeviceEmulationScale(float scale,
                                        ExceptionState& exception_state) {}

void Internals::ResolveResourcePriority(
    ScriptPromiseResolver<IDLLong>* resolver,
    int resource_load_priority) {}

String Internals::getAgentId(DOMWindow* window) {}

void Internals::useMockOverlayScrollbars() {}

bool Internals::overlayScrollbarsEnabled() const {}

void Internals::generateTestReport(const String& message) {}

void Internals::setIsAdFrame(Document* target_doc,
                             ExceptionState& exception_state) {}

ReadableStream* Internals::createReadableStream(
    ScriptState* script_state,
    int32_t queue_size,
    const String& optimizer,
    ExceptionState& exception_state) {}

ScriptValue Internals::createWritableStreamAndSink(
    ScriptState* script_state,
    int32_t queue_size,
    const String& optimizer,
    ExceptionState& exception_state) {}

void Internals::setAllowPerChunkTransferring(ReadableStream* stream) {}

void Internals::setBackForwardCacheRestorationBufferSize(unsigned int maxSize) {}

void Internals::setEventTimingBufferSize(unsigned int maxSize) {}

void Internals::stopResponsivenessMetricsUkmSampling() {}

Vector<String> Internals::getCreatorScripts(HTMLImageElement* img) {}

ScriptPromise<IDLString> Internals::LCPPrediction(ScriptState* script_state,
                                                  Document* document) {}

void ExemptUrlFromNetworkRevocationComplete(
    ScriptPromiseResolver<IDLUndefined>* resolver) {}

ScriptPromise<IDLUndefined> Internals::exemptUrlFromNetworkRevocation(
    ScriptState* script_state,
    const String& url) {}

}  // namespace blink