/* * (C) 1999-2003 Lars Knoll (knoll@kde.org) * Copyright (C) 2004, 2005, 2006, 2007, 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)}} #include "third_party/blink/renderer/core/style_property_shorthand.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" namespace blink { {% for property in properties %} const StylePropertyShorthand& {{property.name.to_lower_camel_case()}}Shorthand() { static const CSSProperty* {{property.name.to_lower_camel_case()}}Properties[] = { {% for longhand_id in property.longhand_property_ids %} &Get{{longhand_id}}(), {% endfor %} }; static StylePropertyShorthand {{property.name.to_lower_camel_case()}}Longhands( {{property.property_id}}, {{property.name.to_lower_camel_case()}}Properties, arraysize({{property.name.to_lower_camel_case()}}Properties)); return {{property.name.to_lower_camel_case()}}Longhands; } {% endfor %} // TODO(ericwilligers): Retire this when offset-position and offset-anchor ship const StylePropertyShorthand& offsetShorthandWithoutPositionAnchor() { static const CSSProperty* offsetProperties[] = { &GetCSSPropertyOffsetPath(), &GetCSSPropertyOffsetDistance(), &GetCSSPropertyOffsetRotate(), }; DEFINE_STATIC_LOCAL(StylePropertyShorthand, offsetLonghands, (CSSPropertyOffset, offsetProperties, arraysize(offsetProperties))); return offsetLonghands; } // Returns an empty list if the property is not a shorthand const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID) { // FIXME: We shouldn't switch between shorthand/not shorthand based on a runtime flag static StylePropertyShorthand emptyShorthand; if (propertyID == CSSPropertyOffset && !RuntimeEnabledFeatures::CSSOffsetPositionAnchorEnabled()) return offsetShorthandWithoutPositionAnchor(); switch (propertyID) { {% for property in properties %} case {{property.property_id}}: return {{property.name.to_lower_camel_case()}}Shorthand(); {% endfor %} default: { return emptyShorthand; } } } void getMatchingShorthandsForLonghand( CSSPropertyID propertyID, Vector* result) { DCHECK(!result->size()); switch (propertyID) { {% for longhand_id, shorthands in longhands_dictionary.items() %} case {{longhand_id}}: { {% for shorthand in shorthands %} if (CSSProperty::Get({{shorthand.property_id}}).IsEnabled()) result->UncheckedAppend({{shorthand.name.to_lower_camel_case()}}Shorthand()); {% endfor %} break; } {% endfor %} default: break; } } } // namespace blink