chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc

/*
 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
 * Copyright (C) 2010 Google 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 INC. ``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 INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "third_party/blink/renderer/core/html/parser/html_preload_scanner.h"

#include <memory>
#include <optional>

#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/script/script_type.mojom-blink.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_property_name.h"
#include "third_party/blink/renderer/core/css/media_list.h"
#include "third_party/blink/renderer/core/css/media_query_evaluator.h"
#include "third_party/blink/renderer/core/css/media_values_cached.h"
#include "third_party/blink/renderer/core/css/parser/css_parser.h"
#include "third_party/blink/renderer/core/css/parser/sizes_attribute_parser.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/security_context.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/viewport_data.h"
#include "third_party/blink/renderer/core/html/blocking_attribute.h"
#include "third_party/blink/renderer/core/html/client_hints_util.h"
#include "third_party/blink/renderer/core/html/cross_origin_attribute.h"
#include "third_party/blink/renderer/core/html/html_dimension.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/html/html_meta_element.h"
#include "third_party/blink/renderer/core/html/link_rel_attribute.h"
#include "third_party/blink/renderer/core/html/loading_attribute.h"
#include "third_party/blink/renderer/core/html/parser/background_html_scanner.h"
#include "third_party/blink/renderer/core/html/parser/html_document_parser.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/html/parser/html_srcset_parser.h"
#include "third_party/blink/renderer/core/html/parser/html_tokenizer.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input_type_names.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/fetch_priority_attribute.h"
#include "third_party/blink/renderer/core/loader/preload_helper.h"
#include "third_party/blink/renderer/core/loader/subresource_integrity_helper.h"
#include "third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/script_loader.h"
#include "third_party/blink/renderer/core/script_type_names.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/loader/fetch/client_hints_preferences.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_initiator_type_names.h"
#include "third_party/blink/renderer/platform/loader/fetch/integrity_metadata.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource.h"
#include "third_party/blink/renderer/platform/loader/subresource_integrity.h"
#include "third_party/blink/renderer/platform/network/mime/content_type.h"
#include "third_party/blink/renderer/platform/network/mime/mime_type_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"

namespace blink {

namespace {

bool Match(const AtomicString& name, const QualifiedName& q_name) {}

String InitiatorFor(const StringImpl* tag_impl, bool link_is_modulepreload) {}

bool MediaAttributeMatches(const MediaValuesCached& media_values,
                           const String& attribute_value) {}

void ScanScriptWebBundle(
    const String& inline_text,
    const KURL& base_url,
    scoped_refptr<const PreloadRequest::ExclusionInfo>& exclusion_info) {}

void ScanScriptWebBundle(
    const HTMLToken::DataVector& data,
    const KURL& base_url,
    scoped_refptr<const PreloadRequest::ExclusionInfo>& exclusion_info) {}

}  // namespace

bool Match(const StringImpl* impl, const QualifiedName& q_name) {}

const StringImpl* TagImplFor(const HTMLToken::DataVector& data) {}

class TokenPreloadScanner::StartTagScanner {};

TokenPreloadScanner::TokenPreloadScanner(
    const KURL& document_url,
    std::unique_ptr<CachedDocumentParameters> document_parameters,
    std::unique_ptr<MediaValuesCached::MediaValuesCachedData>
        media_values_cached_data,
    const ScannerType scanner_type,
    Vector<ElementLocator> locators)
    :{}

TokenPreloadScanner::~TokenPreloadScanner() = default;

static void HandleMetaViewport(
    const String& attribute_value,
    const CachedDocumentParameters* document_parameters,
    MediaValuesCached* media_values,
    std::optional<ViewportDescription>* viewport) {}

static void HandleMetaReferrer(const String& attribute_value,
                               CachedDocumentParameters* document_parameters,
                               CSSPreloadScanner* css_scanner) {}

void TokenPreloadScanner::HandleMetaNameAttribute(
    const HTMLToken& token,
    MetaCHValues& meta_ch_values,
    std::optional<ViewportDescription>* viewport) {}

void TokenPreloadScanner::Scan(const HTMLToken& token,
                               const SegmentedString& source,
                               PreloadRequestStream& requests,
                               MetaCHValues& meta_ch_values,
                               std::optional<ViewportDescription>* viewport,
                               bool* is_csp_meta_tag) {}

void TokenPreloadScanner::UpdatePredictedBaseURL(const HTMLToken& token) {}

// static
std::unique_ptr<HTMLPreloadScanner> HTMLPreloadScanner::Create(
    Document& document,
    HTMLParserOptions options,
    TokenPreloadScanner::ScannerType scanner_type) {}

// static
bool HTMLPreloadScanner::IsSkipPreloadScanEnabled(const Document* document) {}

// static
HTMLPreloadScanner::BackgroundPtr HTMLPreloadScanner::CreateBackground(
    HTMLDocumentParser* parser,
    HTMLParserOptions options,
    scoped_refptr<base::SequencedTaskRunner> task_runner,
    TakePreloadFn take_preload) {}

HTMLPreloadScanner::HTMLPreloadScanner(
    std::unique_ptr<HTMLTokenizer> tokenizer,
    const KURL& document_url,
    std::unique_ptr<CachedDocumentParameters> document_parameters,
    std::unique_ptr<MediaValuesCached::MediaValuesCachedData>
        media_values_cached_data,
    const TokenPreloadScanner::ScannerType scanner_type,
    std::unique_ptr<BackgroundHTMLScanner::ScriptTokenScanner>
        script_token_scanner,
    TakePreloadFn take_preload,
    Vector<ElementLocator> locators,
    bool skip_preload_scanning)
    :{}

HTMLPreloadScanner::~HTMLPreloadScanner() {}

void HTMLPreloadScanner::AppendToEnd(const SegmentedString& source) {}

std::unique_ptr<PendingPreloadData> HTMLPreloadScanner::Scan(
    const KURL& starting_base_element_url) {}

void HTMLPreloadScanner::ScanInBackground(
    const String& source,
    const KURL& document_base_element_url) {}

CachedDocumentParameters::CachedDocumentParameters(Document* document) {}

// static
std::optional<features::LcppPreloadLazyLoadImageType>
    CachedDocumentParameters::preload_lazy_load_image_type_for_testing =;
// static
void CachedDocumentParameters::SetLcppPreloadLazyLoadImageTypeForTesting(
    std::optional<features::LcppPreloadLazyLoadImageType> type) {}

}  // namespace blink