text: // Copyright 2017 The Chromium Authors. All rights reserved.
  // 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/properties/shorthands/grid_template.h"
  
  #include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
  #include "third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h"
  #include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
  #include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
  #include "third_party/blink/renderer/core/layout/layout_object.h"
  #include "third_party/blink/renderer/core/style/computed_style.h"
  #include "third_party/blink/renderer/core/style_property_shorthand.h"
  
  namespace blink {
  namespace CSSShorthand {
  
  bool GridTemplate::ParseShorthand(
      bool important,
      CSSParserTokenRange& range,
      const CSSParserContext& context,
      const CSSParserLocalContext&,
      HeapVector<CSSPropertyValue, 256>& properties) const {
    CSSValue* template_rows = nullptr;
    CSSValue* template_columns = nullptr;
    CSSValue* template_areas = nullptr;
    if (!CSSParsingUtils::ConsumeGridTemplateShorthand(
            important, range, context, template_rows, template_columns,
            template_areas))
      return false;
  
    DCHECK(template_rows);
    DCHECK(template_columns);
    DCHECK(template_areas);
  
    CSSPropertyParserHelpers::AddProperty(
        CSSPropertyGridTemplateRows, CSSPropertyGridTemplate, *template_rows,
        important, CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit,
        properties);
    CSSPropertyParserHelpers::AddProperty(
        CSSPropertyGridTemplateColumns, CSSPropertyGridTemplate,
        *template_columns, important,
        CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties);
    CSSPropertyParserHelpers::AddProperty(
        CSSPropertyGridTemplateAreas, CSSPropertyGridTemplate, *template_areas,
        important, CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit,
        properties);
  
    return true;
  }
  
  bool GridTemplate::IsLayoutDependent(const ComputedStyle* style,
                                       LayoutObject* layout_object) const {
    return layout_object && layout_object->IsLayoutGrid();
  }
  
  const CSSValue* GridTemplate::CSSValueFromComputedStyleInternal(
      const ComputedStyle& style,
      const SVGComputedStyle&,
      const LayoutObject* layout_object,
      Node* styled_node,
      bool allow_visited_style) const {
    return ComputedStyleUtils::ValuesForGridShorthand(
        gridTemplateShorthand(), style, layout_object, styled_node,
        allow_visited_style);
  }
  
  }  // namespace CSSShorthand
  }  // namespace blink
  