chromium/third_party/blink/renderer/core/html/parser/html_document_parser_fastpath.h

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_PARSER_HTML_DOCUMENT_PARSER_FASTPATH_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_PARSER_HTML_DOCUMENT_PARSER_FASTPATH_H_

#include "base/containers/enum_set.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/parser_content_policy.h"

namespace WTF {
class String;
}  // namespace WTF

namespace blink {

class ContainerNode;
class Document;
class DocumentFragment;
class Element;

// Captures additional parsing behaviors that may require special cases.
enum class HTMLFragmentParsingBehavior {};

HTMLFragmentParsingBehaviorSet;

// If this fails because of an unsupported tag and
// `failed_because_unsupported_tag` is non-null, then it is set to true.
CORE_EXPORT bool TryParsingHTMLFragment(
    const WTF::String& source,
    Document& document,
    ContainerNode& root_node,
    Element& context_element,
    ParserContentPolicy policy,
    HTMLFragmentParsingBehaviorSet behavior,
    bool* failed_because_unsupported_tag = nullptr);

// Logs histograms to help track why parsing failed because of an unsupported
// tag when `fragment` was generated.
void LogTagsForUnsupportedTagTypeFailure(DocumentFragment& fragment);

// Captures the potential outcomes for fast path html parser.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// This is exposed for testing.
enum class HtmlFastPathResult {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_PARSER_HTML_DOCUMENT_PARSER_FASTPATH_H_