chromium/third_party/blink/renderer/core/css/parser/css_variable_parser.cc

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

#include "third_party/blink/renderer/core/css/parser/css_variable_parser.h"

#include "base/containers/contains.h"
#include "third_party/blink/renderer/core/css/css_attr_type.h"
#include "third_party/blink/renderer/core/css/css_unparsed_declaration_value.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token_range.h"
#include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
#include "third_party/blink/renderer/core/css/resolver/style_cascade.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"

namespace blink {

bool CSSVariableParser::IsValidVariableName(const CSSParserToken& token) {}

bool CSSVariableParser::IsValidVariableName(StringView string) {}

const CSSValue* CSSVariableParser::ParseDeclarationIncludingCSSWide(
    CSSParserTokenStream& stream,
    bool is_animation_tainted,
    const CSSParserContext& context) {}

CSSUnparsedDeclarationValue* CSSVariableParser::ParseDeclarationValue(
    StringView text,
    bool is_animation_tainted,
    const CSSParserContext& context) {}

static bool ConsumeUnparsedValue(CSSParserTokenStream& stream,
                                 bool restricted_value,
                                 bool comma_ends_declaration,
                                 bool& has_references,
                                 bool& has_font_units,
                                 bool& has_root_font_units,
                                 bool& has_line_height_units,
                                 const ExecutionContext* context);

static bool ConsumeVariableReference(CSSParserTokenStream& stream,
                                     bool& has_references,
                                     bool& has_font_units,
                                     bool& has_root_font_units,
                                     bool& has_line_height_units,
                                     const ExecutionContext* context) {}

static bool ConsumeEnvVariableReference(CSSParserTokenStream& stream,
                                        bool& has_references,
                                        bool& has_font_units,
                                        bool& has_root_font_units,
                                        bool& has_line_height_units,
                                        const ExecutionContext* context) {}

// attr() = attr( <attr-name> <attr-type>? , <declaration-value>?)
static bool ConsumeAttributeReference(CSSParserTokenStream& stream,
                                      bool& has_references,
                                      bool& has_font_units,
                                      bool& has_root_font_units,
                                      bool& has_line_height_units,
                                      const ExecutionContext* context) {}

// Utility function for ConsumeUnparsedDeclaration().
// Checks if a token sequence is a valid <declaration-value> [1],
// with the additional restriction that any var()/env() functions (if present)
// must follow their respective grammars as well.
//
// Parses until it detects some error (such as a stray top-level right-paren;
// if so, returns false) or something that should end a declaration,
// such as a top-level exclamation semicolon (returns true). AtEnd() must
// be checked by the caller even if this returns success, although on
// top-level, it may need to strip !important first.
//
// Called recursively for parsing fallback values.
//
// If this function returns true, then it outputs some additional details about
// the token sequence that can be used to determine if it's valid in a given
// situation, e.g. if "var()" is present (has_references=true), then the
// sequence is valid for any property [2].
//
//
// Braces (i.e. {}) are considered to be "positioned" when they appear
// top-level with non-whitespace tokens to the left or the right.
//
// For example:
//
//   foo {}    =>  Positioned
//   {} foo    =>  Positioned
//   { foo }   =>  Not positioned (the {} covers the whole value).
//   foo [{}]  =>  Not positioned (the {} appears within another block).
//
// Token sequences with "positioned" braces are not valid in standard
// properties (restricted_value=true), even if var()/env() is present
// in the value [3].
//
// [1] https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value
// [2] https://drafts.csswg.org/css-variables/#using-variables
// [3] https://github.com/w3c/csswg-drafts/issues/9317
static bool ConsumeUnparsedValue(CSSParserTokenStream& stream,
                                 bool restricted_value,
                                 bool comma_ends_declaration,
                                 bool& has_references,
                                 bool& has_font_units,
                                 bool& has_root_font_units,
                                 bool& has_line_height_units,
                                 const ExecutionContext* context) {}

CSSVariableData* CSSVariableParser::ConsumeUnparsedDeclaration(
    CSSParserTokenStream& stream,
    bool allow_important_annotation,
    bool is_animation_tainted,
    bool must_contain_variable_reference,
    bool restricted_value,
    bool comma_ends_declaration,
    bool& important,
    const ExecutionContext* context) {}

CSSUnparsedDeclarationValue* CSSVariableParser::ParseUniversalSyntaxValue(
    StringView text,
    const CSSParserContext& context,
    bool is_animation_tainted) {}

StringView CSSVariableParser::StripTrailingWhitespaceAndComments(
    StringView text) {}

}  // namespace blink