chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl

/*
 * (C) 1999-2003 Lars Knoll ([email protected])
 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
 * Copyright (C) 2013 Intel Corporation. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

{% from 'templates/macros.tmpl' import source_files_for_generated_file %}
{{source_files_for_generated_file(template_file, input_files)}}

#ifndef {{header_guard}}
#define {{header_guard}}

#include "base/containers/span.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {

class StylePropertyShorthand {
 public:
  using Properties = base::span<const CSSProperty* const>;

  constexpr StylePropertyShorthand() : shorthand_id_(CSSPropertyID::kInvalid) {}

  constexpr StylePropertyShorthand(CSSPropertyID id, Properties properties)
      : properties_(properties), shorthand_id_(id) {
    DCHECK_LE(properties.size(), std::numeric_limits<unsigned>::max());
  }

  const Properties& properties() const { return properties_; }
  unsigned length() const { return static_cast<unsigned>(properties_.size()); }
  CSSPropertyID id() const { return shorthand_id_; }

 private:
  Properties properties_;
  CSSPropertyID shorthand_id_;
};

{% for property in properties %}
const StylePropertyShorthand& {{property.name.to_lower_camel_case()}}Shorthand();
{% endfor %}

const StylePropertyShorthand& transitionShorthandForParsing();

// Returns an empty list if the property is not a shorthand.
CORE_EXPORT const StylePropertyShorthand& shorthandForProperty(CSSPropertyID);

// Return the list of shorthands for a given longhand.
// The client must pass in an empty result vector.
void getMatchingShorthandsForLonghand(
    CSSPropertyID, Vector<StylePropertyShorthand, 4>* result);

unsigned indexOfShorthandForLonghand(CSSPropertyID,
                                     const Vector<StylePropertyShorthand, 4>&);

}  // namespace blink

#endif  // {{header_guard}}