blob: 6e4d467d79aed84278d674073261f66b3a4c6d07 [file] [log] [blame]
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This file contains a definition of CSS grammar.
// A reentrant parser.
%pure_parser
// yyparse()'s first and only parameter.
%parse-param { ParserImpl* parser_impl }
%{
// Specify how the location of an action should be calculated in terms
// of its children.
#define YYLLOC_DEFAULT(Current, Rhs, N) \
if (N) { \
Current.first_line = Rhs[1].first_line; \
Current.first_column = Rhs[1].first_column; \
Current.line_start = Rhs[1].line_start; \
} else { \
Current.first_line = Rhs[0].first_line; \
Current.first_column = Rhs[0].first_column; \
Current.line_start = Rhs[0].line_start; \
}
// yylex()'s third parameter.
#define YYLEX_PARAM &(parser_impl->scanner())
%}
// Token values returned by a scanner.
%union TokenValue {
float real;
int integer;
TrivialIntPair integer_pair;
TrivialStringPiece string;
}
//
// Tokens returned by a scanner.
//
// Entry point tokens, injected by the parser in order to choose the path
// within a grammar, never appear in the source code.
%token kMediaListEntryPointToken
%token kMediaQueryEntryPointToken
%token kStyleSheetEntryPointToken
%token kRuleEntryPointToken
%token kStyleDeclarationListEntryPointToken
%token kFontFaceDeclarationListEntryPointToken
%token kPropertyValueEntryPointToken
%token kPropertyIntoDeclarationDataEntryPointToken
// Tokens without a value.
%token kEndOfFileToken 0 // null
%token kWhitespaceToken // tab, space, CR, LF
%token kSgmlCommentDelimiterToken // <!-- -->
%token kCommentToken // /* */
%token kImportantToken // !important
// Property name tokens.
// WARNING: Every time a new name token is introduced, it should be added
// to |identifier_token| rule below.
%token kAllToken // all
%token kAnimationDelayToken // animation-delay
%token kAnimationDirectionToken // animation-direction
%token kAnimationDurationToken // animation-duration
%token kAnimationFillModeToken // animation-fill-mode
%token kAnimationIterationCountToken // animation-iteration-count
%token kAnimationNameToken // animation-name
%token kAnimationTimingFunctionToken // animation-timing-function
%token kAnimationToken // animation
%token kBackgroundColorToken // background-color
%token kBackgroundImageToken // background-image
%token kBackgroundPositionToken // background-position
%token kBackgroundRepeatToken // background-repeat
%token kBackgroundSizeToken // background-size
%token kBackgroundToken // background
%token kBorderToken // border
%token kBorderBottomToken // border-bottom
%token kBorderBottomColorToken // border-bottom-color
%token kBorderBottomStyleToken // border-bottom-style
%token kBorderBottomWidthToken // border-bottom-width
%token kBorderColorToken // border-color
%token kBorderLeftToken // border-left
%token kBorderLeftColorToken // border-left-color
%token kBorderLeftStyleToken // border-left-style
%token kBorderLeftWidthToken // border-left-width
%token kBorderRadiusToken // border-radius
%token kBorderRightToken // border-right
%token kBorderRightColorToken // border-right-color
%token kBorderRightStyleToken // border-right-style
%token kBorderRightWidthToken // border-right-width
%token kBorderStyleToken // border-style
%token kBorderTopToken // border-top
%token kBorderTopColorToken // border-top-color
%token kBorderTopStyleToken // border-top-style
%token kBorderTopWidthToken // border-top-width
%token kBorderWidthToken // border-width
%token kBottomToken // bottom
%token kBoxShadowToken // box-shadow
%token kColorToken // color
%token kContentToken // content
%token kDisplayToken // display
%token kFilterToken // filter
%token kFontToken // font
%token kFontFamilyToken // font-family
%token kFontSizeToken // font-size
%token kFontStyleToken // font-style
%token kFontWeightToken // font-weight
%token kHeightToken // height
%token kLeftToken // left
%token kLineHeightToken // line-height
%token kMarginBottomToken // margin-bottom
%token kMarginLeftToken // margin-left
%token kMarginRightToken // margin-right
%token kMarginToken // margin
%token kMarginTopToken // margin-top
%token kMaxHeightToken // max-height
%token kMaxWidthToken // max-width
%token kMinHeightToken // min-height
%token kMinWidthToken // min-width
%token kOpacityToken // opacity
%token kOutlineToken // outline
%token kOutlineColorToken // outline-color
%token kOutlineStyleToken // outline-style
%token kOutlineWidthToken // outline-width
%token kOverflowToken // overflow
%token kOverflowWrapToken // overflow-wrap
%token kPaddingBottomToken // padding-bottom
%token kPaddingLeftToken // padding-left
%token kPaddingRightToken // padding-right
%token kPaddingToken // padding
%token kPaddingTopToken // padding-top
%token kPointerEventsToken // pointer-events
%token kPositionToken // position
%token kRightToken // right
%token kSrcToken // src
%token kTextAlignToken // text-align
%token kTextDecorationToken // text-decoration
%token kTextDecorationColorToken // text-decoration-color
%token kTextDecorationLineToken // text-decoration-line
%token kTextIndentToken // text-indent
%token kTextOverflowToken // text-overflow
%token kTextShadowToken // text-shadow
%token kTextTransformToken // text-transform
%token kTopToken // top
%token kTransformToken // transform
%token kTransformOriginToken // transform-origin
%token kTransitionDelayToken // transition-delay
%token kTransitionDurationToken // transition-duration
%token kTransitionPropertyToken // transition-property
%token kTransitionTimingFunctionToken // transition-timing-function
%token kTransitionToken // transition
%token kUnicodeRangePropertyToken // unicode-range
%token kVerticalAlignToken // vertical-align
%token kVisibilityToken // visibility
%token kWhiteSpacePropertyToken // white-space
%token kWidthToken // width
%token kZIndexToken // z-index
// Property value tokens.
// WARNING: Every time a new name token is introduced, it should be added
// to |identifier_token| rule below.
%token kAbsoluteToken // absolute
%token kAlternateToken // alternate
%token kAlternateReverseToken // alternate-reverse
%token kAquaToken // aqua
%token kAtToken // at
%token kAutoToken // auto
%token kBackwardsToken // backwards
%token kBaselineToken // baseline
%token kBlackToken // black
%token kBlockToken // block
%token kBlueToken // blue
%token kBoldToken // bold
%token kBothToken // both
%token kBreakWordToken // break-word
%token kCenterToken // center
%token kCircleToken // circle
%token kClipToken // clip
%token kClosestCornerToken // closest-corner
%token kClosestSideToken // closest-side
%token kContainToken // contain
%token kCoverToken // cover
%token kCursiveToken // cursive
%token kEaseInOutToken // ease-in-out
%token kEaseInToken // ease-in
%token kEaseOutToken // ease-out
%token kEaseToken // ease
%token kEllipseToken // ellipse
%token kEllipsisToken // ellipsis
%token kEndToken // end
%token kEquirectangularToken // equirectangular
%token kFantasyToken // fantasy
%token kFarthestCornerToken // farthest-corner
%token kFarthestSideToken // farthest-side
%token kFixedToken // fixed
%token kForwardsToken // forwards
%token kFromToken // from
%token kFuchsiaToken // fuchsia
%token kGrayToken // gray
%token kGreenToken // green
%token kHiddenToken // hidden
%token kInfiniteToken // infinite
%token kInheritToken // inherit
%token kInitialToken // initial
%token kInlineBlockToken // inline-block
%token kInlineToken // inline
%token kInsetToken // inset
%token kItalicToken // italic
%token kLimeToken // lime
%token kLinearToken // linear
%token kLineThroughToken // line-through
// %token kLeftToken // left - also property name token
%token kMaroonToken // maroon
%token kMiddleToken // middle
%token kMonoscopicToken // monoscopic
%token kMonospaceToken // monospace
%token kNavyToken // navy
%token kNoneToken // none
%token kNoRepeatToken // no-repeat
%token kNormalToken // normal
%token kNoWrapToken // nowrap
%token kObliqueToken // oblique
%token kOliveToken // olive
%token kPreToken // pre
%token kPreLineToken // pre-line
%token kPreWrapToken // pre-wrap
%token kPurpleToken // purple
%token kRedToken // red
%token kRepeatToken // repeat
%token kRepeatXToken // repeat-x
%token kRepeatYToken // repeat-y
%token kRelativeToken // relative
%token kReverseToken // reverse
// %token kRightToken // right - also property name token
%token kSansSerifToken // sans-serif
%token kSerifToken // serif
%token kSilverToken // silver
%token kSolidToken // solid
%token kStartToken // start
%token kStaticToken // static
%token kStepEndToken // step-end
%token kStepStartToken // step-start
%token kStereoscopicLeftRightToken // stereoscopic-left-right
%token kStereoscopicTopBottomToken // stereoscopic-top-bottom
%token kTealToken // teal
%token kToToken // to
// %token kTopToken // top - also property name token
%token kTransparentToken // transparent
%token kUppercaseToken // uppercase
%token kVisibleToken // visible
%token kWhiteToken // white
%token kYellowToken // yellow
// Pseudo-class name tokens.
// WARNING: Every time a new name token is introduced, it should be added
// to |identifier_token| rule below.
%token kActiveToken // active
%token kEmptyToken // empty
%token kFocusToken // focus
%token kHoverToken // hover
// Pseudo-element name tokens.
// WARNING: Every time a new name token is introduced, it should be added
// to |identifier_token| rule below.
%token kAfterToken // after
%token kBeforeToken // before
// Attribute matching tokens.
%token kIncludesToken // ~=
%token kDashMatchToken // |=
%token kBeginsWithToken // ^=
%token kEndsWithToken // $=
%token kContainsToken // *=
// "Media query" mode: Operator tokens.
%token kMediaAndToken // and
%token kMediaNotToken // not
%token kMediaOnlyToken // only
%token kMediaMinimumToken // min-
%token kMediaMaximumToken // max-
// "Media query" mode: Media type tokens.
// WARNING: Every time a new media type token is introduced, it should be added
// to |media_type_known| rule below.
%token kAllMediaTypeToken // all
%token kTVMediaTypeToken // tv
%token kScreenMediaTypeToken // screen
// "Media query" mode: Media feature type tokens. These tokens represent the
// value types of media features. The integer values of these tokens represent
// enum MediaFeatureName.
// WARNING: Every time a new media feature type token is introduced, it should
// be added to |media_type_unknown| rule below.
%token <integer> kLengthMediaFeatureTypeToken // ...px, ...em, etc.
%token <integer> kOrientationMediaFeatureTypeToken // portrait, landscape
%token <integer> kRatioMediaFeatureTypeToken // ... / ...
%token <integer> kNonNegativeIntegerMediaFeatureTypeToken // 0, 1, 2, 3, ...
%token <integer> kResolutionMediaFeatureTypeToken // ...dpi, ...dpcm
%token <integer> kScanMediaFeatureTypeToken // progressive,
// interlace
%token <integer> kZeroOrOneMediaFeatureTypeToken // 0, 1
// "Media query" mode: Media feature value tokens.
%token kInterlaceMediaFeatureKeywordValueToken // interlace
%token kLandscapeMediaFeatureKeywordValueToken // landscape
%token kPortraitMediaFeatureKeywordValueToken // portrait
%token kProgressiveMediaFeatureKeywordValueToken // progressive
// "Supports" mode tokens.
%token kSupportsAndToken // and (in "supports" mode)
%token kSupportsNotToken // not (in "supports" mode)
%token kSupportsOrToken // or (in "supports" mode)
// @-tokens.
%token kImportToken // @import
%token kKeyframesToken // @keyframes
%token kPageToken // @page
%token kMediaToken // @media
%token kFontFaceToken // @font-face
%token kCharsetToken // @charset
%token kNamespaceToken // @namespace
%token kSupportsToken // @supports
// Paged media tokens.
%token kTopLeftCornerToken // @top-left-corner
%token kTopLeftToken // @top-left
%token kTopCenterToken // @top-center
%token kTopRightToken // @top-right
%token kTopRightCornerToken // @top-right-corner
%token kBottomLeftCornerToken // @bottom-left-corner
%token kBottomLeftToken // @bottom-left
%token kBottomCenterToken // @bottom-center
%token kBottomRightToken // @bottom-right
%token kBottomRightCornerToken // @bottom-right-corner
%token kLeftTopToken // @left-top
%token kLeftMiddleToken // @left-middle
%token kLeftBottomToken // @left-bottom
%token kRightTopToken // @right-top
%token kRightMiddleToken // @right-middle
%token kRightBottomToken // @right-bottom
// Function tokens.
%token kCalcFunctionToken // calc(
%token kCubicBezierFunctionToken // cubic-bezier(
%token kCueFunctionToken // cue(
%token kFormatFunctionToken // format(
%token kLinearGradientFunctionToken // linear-gradient(
%token kLocalFunctionToken // local(
%token kMapToMeshFunctionToken // map-to-mesh(
%token kMatrixFunctionToken // matrix(
%token kMatrix3dFunctionToken // matrix3d(
%token kNotFunctionToken // not(
%token kNthChildFunctionToken // nth-child(
%token kNthLastChildFunctionToken // nth-last-child(
%token kNthLastOfTypeFunctionToken // nth-last-of-type(
%token kNthOfTypeFunctionToken // nth-of-type(
%token kRotateFunctionToken // rotate(
%token kScaleFunctionToken // scale(
%token kScaleXFunctionToken // scaleX(
%token kScaleYFunctionToken // scaleY(
%token kStepsFunctionToken // steps(
%token kTranslateFunctionToken // translate(
%token kTranslateXFunctionToken // translateX(
%token kTranslateYFunctionToken // translateY(
%token kTranslateZFunctionToken // translateZ(
%token kRadialGradientFunctionToken // radial-gradient(
%token kRGBFunctionToken // rgb(
%token kRGBAFunctionToken // rgba(
%token kCobaltMtmFunctionToken // -cobalt-mtm(
// Tokens with a string value.
%token <string> kStringToken // "...", '...'
%token <string> kIdentifierToken // ...
%token <string> kNthToken // an+b, where a, b - integers
%token <string> kHexToken // #...
%token <string> kIdSelectorToken // #...
%token <string> kUriToken // url(...
%token <string> kInvalidFunctionToken // ...(
%token <string> kInvalidNumberToken // ... (digits)
%token <string> kInvalidDimensionToken // XXyy, where XX - number,
// yy - identifier
%token <string> kInvalidAtBlockToken // @... { ... }, @... ... ;
%token <string> kOtherBrowserAtBlockToken // @-... { ... }
// Tokens with an integer value.
// WARNING: Use |integer| rule if you want to handle the sign.
%token <integer> kIntegerToken // 123, for example
// Tokens with a floating point value.
// WARNING: Remember to use |maybe_sign_token| rule with these tokens.
%token <real> kRealToken // 1.23, for example
%token <real> kPercentageToken // ...%
%token <real> kRootElementFontSizesAkaRemToken // ...rem
%token <real> kZeroGlyphWidthsAkaChToken // ...ch
%token <real> kFontSizesAkaEmToken // ...em
%token <real> kXHeightsAkaExToken // ...ex
%token <real> kPixelsToken // ...px
%token <real> kCentimetersToken // ...cm
%token <real> kMillimetersToken // ...mm
%token <real> kInchesToken // ...in
%token <real> kPointsToken // ...pt
%token <real> kPicasToken // ...pc
%token <real> kDegreesToken // ...deg
%token <real> kRadiansToken // ...rad
%token <real> kGradiansToken // ...grad
%token <real> kTurnsToken // ...turn
%token <real> kMillisecondsToken // ...ms
%token <real> kSecondsToken // ...s
%token <real> kHertzToken // ...hz
%token <real> kKilohertzToken // ...khz
%token <real> kViewportWidthPercentsAkaVwToken // ...vw
%token <real> kViewportHeightPercentsAkaVhToken // ...vh
%token <real> kViewportSmallerSizePercentsAkaVminToken // ...vmin
%token <real> kViewportLargerSizePercentsAkaVmaxToken // ...vmax
%token <real> kDotsPerPixelToken // ...dppx
%token <real> kDotsPerInchToken // ...dpi
%token <real> kDotsPerCentimeterToken // ...dpcm
%token <real> kFractionsToken // ...fr
// Tokens with an integer pair value
%token <integer_pair> kUnicodeRangeToken // u+..., U+...
//
// Rules and their types, sorted by type name.
//
// A top-level rule.
%start entry_point
%union { bool important; }
%type <important> maybe_important
%type <integer> integer non_negative_integer positive_integer zero_or_one
%union { cssom::RGBAColorValue* color; }
%type <color> color
%destructor { SafeRelease($$); } <color>
%union { cssom::ColorStop* color_stop; }
%type <color_stop> color_stop
%destructor { delete $$; } <color_stop>
%union { cssom::ColorStopList* color_stop_list; }
%type <color_stop_list> comma_separated_color_stop_list
%destructor { delete $$; } <color_stop_list>
%union { cssom::PercentageValue* percentage; }
%type <percentage> percentage positive_percentage
%destructor { SafeRelease($$); } <percentage>
%union { cssom::LengthValue* length; }
%type <length> length positive_length absolute_or_relative_length
%destructor { SafeRelease($$); } <length>
%union { cssom::RatioValue* ratio; }
%type <ratio> ratio
%destructor { SafeRelease($$); } <ratio>
%union { cssom::ResolutionValue* resolution; }
%type <resolution> resolution
%destructor { SafeRelease($$); } <resolution>
%union { cssom::StringValue* string_value; }
%type <string_value> font_family_name_identifier_list
font_family_string_name
font_family_specific_name
font_family_specific_name_no_single_identifier
%destructor { SafeRelease($$); } <string_value>
// base::TimeDelta's internal value. One can construct a base::TimeDelta from
// this value using the function base::TimeDelta::FromInternalValue(). We use
// it instead of base::TimeDelta because base::TimeDelta does not have a
// trivial constructor and thus cannot be used in a union.
%union { int64 time; }
%type <time> time time_with_units_required
%union { PropertyDeclaration* property_declaration; }
%type <property_declaration> maybe_declaration
%destructor { delete $$; } <property_declaration>
// To reduce the number of classes derived from cssom::PropertyValue, some
// semantic actions contain a value processing (such as opacity clamping
// or RGBA color resolution) that technically belongs to computed value
// resolution and as such should be done by layout engine. This is harmless
// as long as web app does not rely on literal preservation of property values
// exposed by cssom::CSSRuleStyleDeclaration (semantics is
// always preserved).
%union { cssom::PropertyValue* property_value; }
%type <property_value> animation_delay_property_value
animation_direction_list_element
animation_direction_property_value
animation_duration_property_value
animation_fill_mode_list_element
animation_fill_mode_property_value
animation_iteration_count_list_element
animation_iteration_count_property_value
animation_name_list_element
animation_name_property_value
animation_timing_function_property_value
auto
background_color_property_value
background_image_property_list_element
background_image_property_value
background_position_property_value
background_repeat_element
background_repeat_property_value
background_repeat_property_value_without_common_values
background_size_property_list_element
background_size_property_value
background_size_property_value_without_common_values
border_color_property_value
border_radius_property_value
border_style_property_value
border_width_element
border_width_element_with_common_values
border_width_property_value
box_shadow_property_value
color_property_value
common_values
common_values_without_errors
content_property_value
display_property_value
font_face_local_src
font_face_src_list_element
font_face_src_property_value
font_face_url_src
font_family_name
font_family_property_value
font_size_property_value
font_style_exclusive_property_value
font_style_property_value
font_weight_exclusive_property_value
font_weight_property_value
height_property_value
length_percent_property_value
line_height_property_value
line_style
line_style_with_common_values
linear_gradient_params
margin_side_property_value
margin_width
max_height_property_value
max_width_property_value
min_height_property_value
min_width_property_value
maybe_background_size_property_value
offset_property_value
opacity_property_value
orientation_media_feature_keyword_value
overflow_property_value
overflow_wrap_property_value
padding_side_property_value
pointer_events_property_value
position_list_element
position_property_value
positive_length_percent_property_value
radial_gradient_params
scan_media_feature_keyword_value
text_align_property_value
text_decoration_line_property_value
text_decoration_property_value
text_indent_property_value
text_overflow_property_value
text_shadow_property_value
text_transform_property_value
time_list_property_value
timing_function_list_property_value
transform_property_value
transform_origin_property_value
transition_delay_property_value
transition_duration_property_value
transition_property_property_value
transition_timing_function_property_value
unicode_range_property_value
url
validated_box_shadow_list
validated_text_shadow_list
vertical_align_property_value
visibility_property_value
white_space_property_value
width_property_value
z_index_property_value
filter_property_value
%destructor { SafeRelease($$); } <property_value>
%union { std::vector<float>* number_matrix; }
%type <number_matrix> number_matrix
%destructor { delete $$; } <number_matrix>
%union { glm::mat4* matrix4x4; }
%type <matrix4x4> cobalt_mtm_transform_function
%destructor { delete $$; } <matrix4x4>
%union { MarginOrPaddingShorthand* margin_or_padding_shorthand; }
%type <margin_or_padding_shorthand> margin_property_value padding_property_value
%destructor { delete $$; } <margin_or_padding_shorthand>
%union { SingleAnimationShorthand* single_animation; }
%type <single_animation> single_animation single_non_empty_animation
%destructor { delete $$; } <single_animation>
%union { AnimationShorthandBuilder* animation_builder; }
%type <animation_builder> comma_separated_animation_list
%destructor { delete $$; } <animation_builder>
%union { AnimationShorthand* animation; }
%type <animation> animation_property_value
%destructor { delete $$; } <animation>
%union { FontShorthand* font; }
%type <font> font_property_value
optional_font_value_list
non_empty_optional_font_value_list
%destructor { delete $$; } <font>
%union { TransitionShorthand* transition; }
%type <transition> transition_property_value
%destructor { delete $$; } <transition>
%type <real> alpha angle non_negative_number number
%union { cssom::CSSStyleSheet* style_sheet; }
%type <style_sheet> style_sheet
%destructor { SafeRelease($$); } <style_sheet>
%union { cssom::CSSRuleList* rule_list; }
%type <rule_list> rule_list rule_list_block
%destructor { SafeRelease($$); } <rule_list>
%union { cssom::AttributeSelector::ValueMatchType attribute_match; }
%type <attribute_match> attribute_match
%union { cssom::SimpleSelector* simple_selector; }
%type <simple_selector> attribute_selector_token
class_selector_token
id_selector_token
pseudo_class_token
pseudo_element_token
simple_selector_token
type_selector_token
universal_selector_token
%destructor { delete $$; } <simple_selector>
%union { cssom::CompoundSelector* compound_selector; }
%type <compound_selector> compound_selector_token
%destructor { delete $$; } <compound_selector>
%union { cssom::Combinator* combinator; }
%type <combinator> combinator
%destructor { delete $$; } <combinator>
%union { cssom::ComplexSelector* complex_selector; }
%type <complex_selector> complex_selector
%destructor { delete $$; } <complex_selector>
%union { cssom::Selectors* selectors; }
%type <selectors> selector_list
%destructor { delete $$; } <selectors>
%union { cssom::LinearGradientValue::SideOrCorner side_or_corner; }
%type <side_or_corner> side side_or_corner
%union { int sign; }
%type <sign> maybe_sign_token
%type <string> identifier_token
%union { cssom::PropertyKey property_key; }
%type <property_key> animatable_property_token
%union { cssom::CSSDeclaredStyleData* style_declaration_data; }
%type <style_declaration_data> style_declaration_list
%destructor { SafeRelease($$); } <style_declaration_data>
%union { cssom::CSSRuleStyleDeclaration* style_declaration; }
%type <style_declaration> style_declaration_block
%destructor { SafeRelease($$); } <style_declaration>
%union { cssom::CSSFontFaceRule* font_face_rule; }
%type <font_face_rule> at_font_face_rule
%destructor { SafeRelease($$); } <font_face_rule>
%union { cssom::CSSKeyframeRule* keyframe_rule; }
%type <keyframe_rule> keyframe_rule
%destructor { SafeRelease($$); } <keyframe_rule>
%union { cssom::CSSKeyframesRule* keyframes_rule; }
%type <keyframes_rule> at_keyframes_rule
%destructor { SafeRelease($$); } <keyframes_rule>
%union { cssom::CSSRuleList* keyframe_rule_list; }
%type <keyframe_rule_list> keyframe_rule_list
%destructor { SafeRelease($$); } <keyframe_rule_list>
%union { float keyframe_offset; }
%type <keyframe_offset> keyframe_offset
%union { std::vector<float>* keyframe_selector; }
%type <keyframe_selector> keyframe_selector;
%destructor { delete $$; } <keyframe_selector>
%union { cssom::CSSFontFaceDeclarationData* font_face_declaration_data; }
%type <font_face_declaration_data> font_face_declaration_list
%destructor { SafeRelease($$); } <font_face_declaration_data>
%union { cssom::CSSMediaRule* media_rule; }
%type <media_rule> at_media_rule
%destructor { SafeRelease($$); } <media_rule>
%union { cssom::MediaList* media_list; }
%type <media_list> media_list
%destructor { SafeRelease($$); } <media_list>
%union { cssom::MediaQuery* media_query; }
%type <media_query> media_query
%destructor { SafeRelease($$); } <media_query>
%union { bool evaluated_media_type; }
%type <evaluated_media_type> evaluated_media_type media_type_specified
%union { cssom::MediaFeatures* media_features; }
%type <media_features> media_feature_list
%destructor { delete $$; } <media_features>
%union { cssom::MediaFeature* media_feature; }
%type <media_feature> media_feature media_feature_block
media_feature_with_value media_feature_without_value
media_feature_allowing_operator_with_value
%destructor { SafeRelease($$); } <media_feature>
%union { cssom::MediaFeatureOperator media_feature_operator; }
%type <media_feature_operator> media_feature_operator
%union { cssom::CSSStyleRule* style_rule; }
%type <style_rule> qualified_rule style_rule
%destructor { SafeRelease($$); } <style_rule>
%union { cssom::CSSRule* css_rule; }
%type <css_rule> rule
%destructor { SafeRelease($$); } <css_rule>
%union { cssom::PropertyListValue::Builder* property_list; }
%type <property_list> background_size_property_list
border_color_property_list
border_style_property_list
border_width_property_list
comma_separated_animation_direction_list
comma_separated_animation_fill_mode_list
comma_separated_animation_iteration_count_list
comma_separated_animation_name_list
comma_separated_background_image_list
comma_separated_box_shadow_list
comma_separated_font_face_src_list
comma_separated_font_family_name_list
comma_separated_text_shadow_list
comma_separated_unicode_range_list
validated_two_position_list_elements
%destructor { delete $$; } <property_list>
%union { cssom::PropertyListValue* property_list_value; }
%type <property_list_value> at_position
circle_with_positive_length
ellipse_with_2_positive_length_percents
maybe_at_position
validated_position_property
%destructor { SafeRelease($$); } <property_list_value>
%union { cssom::TransformFunction* transform_function; }
%type <transform_function> scale_function_parameters
%destructor { delete $$; } <transform_function>
%union { cssom::TransformFunctionListValue::Builder* transform_functions; }
%type <transform_functions> transform_list
%destructor { delete $$; } <transform_functions>
%union { cssom::FilterFunction* filter_function; }
%type <filter_function> cobalt_mtm_filter_function
%type <filter_function> filter_function
%destructor { delete $$; } <filter_function>
%union { cssom::FilterFunctionListValue::Builder* cobalt_mtm_filter_functions; }
%type <cobalt_mtm_filter_functions> filter_function_list
%destructor { delete $$; } <cobalt_mtm_filter_functions>
%union {
cssom::MapToMeshFunction::MeshSpec* cobalt_map_to_mesh_spec; }
%type <cobalt_map_to_mesh_spec> cobalt_map_to_mesh_spec
%destructor { delete $$; } <cobalt_map_to_mesh_spec>
%union {
cssom::MapToMeshFunction::ResolutionMatchedMeshListBuilder* cobalt_mtm_resolution_matched_meshes; }
%type <cobalt_mtm_resolution_matched_meshes> cobalt_mtm_resolution_matched_mesh_list
%destructor { delete $$; } <cobalt_mtm_resolution_matched_meshes>
%union { cssom::MapToMeshFunction::ResolutionMatchedMesh* cobalt_mtm_resolution_matched_mesh; }
%type <cobalt_mtm_resolution_matched_mesh> cobalt_mtm_resolution_matched_mesh
%destructor { delete $$; } <cobalt_mtm_resolution_matched_mesh>
%union { cssom::KeywordValue* stereo_mode; }
%type <stereo_mode> maybe_cobalt_mtm_stereo_mode;
%type <stereo_mode> cobalt_mtm_stereo_mode;
%destructor { SafeRelease($$); } <stereo_mode>
%union { cssom::TimeListValue::Builder* time_list; }
%type <time_list> comma_separated_time_list
%destructor { delete $$; } <time_list>
%union { cssom::PropertyKeyListValue::Builder* property_name_list; }
%type <property_name_list> comma_separated_animatable_property_name_list
%destructor { delete $$; } <property_name_list>
%union {
cssom::SteppingTimingFunction::ValueChangeLocation
stepping_value_change_location;
}
%type <stepping_value_change_location> maybe_steps_start_or_end_parameter
%union { cssom::TimingFunction* timing_function; }
%type <timing_function> single_timing_function
%destructor { SafeRelease($$); } <timing_function>
%union {
cssom::TimingFunctionListValue::Builder*
timing_function_list;
}
%type <timing_function_list>
comma_separated_single_timing_function_list
%destructor { delete $$; } <timing_function_list>
%union { SingleTransitionShorthand* single_transition; }
%type <single_transition> single_transition single_non_empty_transition
%destructor { delete $$; } <single_transition>
%union { TransitionShorthandBuilder* transition_builder; }
%type <transition_builder> comma_separated_transition_list
%destructor { delete $$; } <transition_builder>
%union { BackgroundShorthandLayer* background_shorthand_layer; }
%type <background_shorthand_layer>
background_position_and_size_shorthand_property_value
background_repeat_shorthand_property_value
background_position_and_repeat_combination
final_background_layer_without_position_and_repeat
final_background_layer
background_property_value
%destructor { delete $$; } <background_shorthand_layer>
%union { PositionParseStructure* position_structure; }
%type <position_structure> position_list
%destructor { delete $$; } <position_structure>
%union { BorderOrOutlineShorthand* border_or_outline_shorthand; }
%type <border_or_outline_shorthand> border_or_outline_property_value
border_or_outline_property_list
%destructor { delete $$; } <border_or_outline_shorthand>
%union { ShadowPropertyInfo* shadow_info; }
%type <shadow_info> box_shadow_list text_shadow_list
%destructor { delete $$; } <shadow_info>
%union { cssom::RadialGradientValue::SizeKeyword size_keyword; }
%type <size_keyword> circle_with_size_keyword
maybe_ellipse_with_size_keyword size_keyword
%%
// WARNING: Every rule, except the ones which end with "..._token", should
// consume trailing whitespace.
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Common rules used across the grammar.
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
maybe_whitespace:
/* empty */
| maybe_whitespace kWhitespaceToken
;
errors:
error
| errors error
;
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// @-rules.
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// The @font-face rule consists of the @font-face at-keyword followed by a block
// of descriptor declarations.
// https://www.w3.org/TR/css3-fonts/#font-face-rule
at_font_face_rule:
kFontFaceToken maybe_whitespace '{' maybe_whitespace
font_face_declaration_list '}' maybe_whitespace {
scoped_refptr<cssom::CSSFontFaceRule>
font_face_rule(
new cssom::CSSFontFaceRule(MakeScopedRefPtrAndRelease($5)));
if (font_face_rule->IsValid()) {
$$ = AddRef(font_face_rule.get());
} else {
parser_impl->LogWarning(@1, "invalid font-face");
$$ = NULL;
}
}
;
// The @media rule is a conditional group rule whose condition is a media query.
// It consists of the at-keyword '@media' followed by a (possibly empty) media
// query list, followed by a group rule body. The condition of the rule is the
// result of the media query.
// https://www.w3.org/TR/css3-conditional/#at-media
at_media_rule:
// @media expr {}
kMediaToken maybe_whitespace media_list rule_list_block {
$$ = AddRef(new cssom::CSSMediaRule(MakeScopedRefPtrAndRelease($3),
MakeScopedRefPtrAndRelease($4)));
}
;
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Media Rule, Media Query, Media Type
// https://www.w3.org/TR/cssom/#media-queries
// https://www.w3.org/TR/css3-mediaqueries/
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Follow the syntax defined here:
// https://www.w3.org/TR/css3-mediaqueries/#syntax
// Orientation value, landscale or portrait
// https://www.w3.org/TR/css3-mediaqueries/#orientation
orientation_media_feature_keyword_value:
kLandscapeMediaFeatureKeywordValueToken maybe_whitespace {
$$ = AddRef(cssom::MediaFeatureKeywordValue::GetLandscape().get());
}
| kPortraitMediaFeatureKeywordValueToken maybe_whitespace {
$$ = AddRef(cssom::MediaFeatureKeywordValue::GetPortrait().get());
}
;
// Scan value, interlace or progressive
// https://www.w3.org/TR/css3-mediaqueries/#scan
scan_media_feature_keyword_value:
kInterlaceMediaFeatureKeywordValueToken maybe_whitespace {
$$ = AddRef(cssom::MediaFeatureKeywordValue::GetInterlace().get());
}
| kProgressiveMediaFeatureKeywordValueToken maybe_whitespace {
$$ = AddRef(cssom::MediaFeatureKeywordValue::GetProgressive().get());
}
;
// 'min-' or 'max-' prefix for media feature name.
media_feature_operator:
kMediaMinimumToken { $$ = cssom::kMinimum; }
| kMediaMaximumToken { $$ = cssom::kMaximum; }
;
// Media feature: 'feature' only.
// (feature) will evaluate to true if (feature:x) will evaluate to true for a
// value x other than zero or zero followed by a unit identifier.
// https://www.w3.org/TR/css3-mediaqueries/#media1
media_feature_without_value:
kLengthMediaFeatureTypeToken maybe_whitespace {
$$ = AddRef(new cssom::MediaFeature($1));
}
| kOrientationMediaFeatureTypeToken maybe_whitespace {
$$ = AddRef(new cssom::MediaFeature($1));
}
| kRatioMediaFeatureTypeToken maybe_whitespace {
$$ = AddRef(new cssom::MediaFeature($1));
}
| kNonNegativeIntegerMediaFeatureTypeToken maybe_whitespace {
$$ = AddRef(new cssom::MediaFeature($1));
}
| kResolutionMediaFeatureTypeToken maybe_whitespace {
$$ = AddRef(new cssom::MediaFeature($1));
}
| kScanMediaFeatureTypeToken maybe_whitespace {
$$ = AddRef(new cssom::MediaFeature($1));
}
| kZeroOrOneMediaFeatureTypeToken maybe_whitespace {
$$ = AddRef(new cssom::MediaFeature($1));
}
;
// Media feature: 'feature:value' for features that don't allow prefixes.
media_feature_with_value:
kOrientationMediaFeatureTypeToken maybe_whitespace colon
orientation_media_feature_keyword_value {
$$ = AddRef(new cssom::MediaFeature($1, $4));
}
| kScanMediaFeatureTypeToken maybe_whitespace colon
scan_media_feature_keyword_value {
$$ = AddRef(new cssom::MediaFeature($1, $4));
}
| kZeroOrOneMediaFeatureTypeToken maybe_whitespace colon zero_or_one {
$$ = AddRef(new cssom::MediaFeature($1, new cssom::IntegerValue($4)));
}
;
// Media feature: 'feature:value' for features that allow min/max prefixes.
media_feature_allowing_operator_with_value:
kLengthMediaFeatureTypeToken maybe_whitespace colon length {
$$ = AddRef(new cssom::MediaFeature($1, MakeScopedRefPtrAndRelease($4)));
}
| kNonNegativeIntegerMediaFeatureTypeToken maybe_whitespace colon
non_negative_integer {
$$ = AddRef(new cssom::MediaFeature($1, new cssom::IntegerValue($4)));
}
| kRatioMediaFeatureTypeToken maybe_whitespace colon ratio {
$$ = AddRef(new cssom::MediaFeature($1, MakeScopedRefPtrAndRelease($4)));
}
| kResolutionMediaFeatureTypeToken maybe_whitespace colon resolution {
$$ = AddRef(new cssom::MediaFeature($1, MakeScopedRefPtrAndRelease($4)));
}
;
// Media feature: 'feature' or 'feature:value' or 'min-feature:value' or
// 'max-feature:value'
// https://www.w3.org/TR/css3-mediaqueries/#media1
media_feature:
media_feature_without_value
| media_feature_with_value
| media_feature_allowing_operator_with_value
| media_feature_operator media_feature_allowing_operator_with_value {
$$ = $2;
$$->set_operator($1);
}
;
// Media feature: '(name:value)'
media_feature_block:
'(' maybe_whitespace media_feature ')' maybe_whitespace {
$$ = $3;
}
;
// Media feature list: '(name:value) [ and (name:value) ]'
media_feature_list:
// (name:value)
media_feature_block {
$$ = new cssom::MediaFeatures();
$$->push_back(MakeScopedRefPtrAndRelease($1));
}
// ... and (name:value)
| media_feature_list kMediaAndToken maybe_whitespace media_feature_block {
$$ = $1;
$$->push_back(MakeScopedRefPtrAndRelease($4));
}
;
// All tokens representing unknown media types.
media_type_unknown:
kIdentifierToken
// "Media query" mode operator names.
| kMediaAndToken
| kMediaMinimumToken
| kMediaMaximumToken
// "Media query" mode media feature tokens
| kLengthMediaFeatureTypeToken
| kOrientationMediaFeatureTypeToken
| kRatioMediaFeatureTypeToken
| kNonNegativeIntegerMediaFeatureTypeToken
| kResolutionMediaFeatureTypeToken
| kScanMediaFeatureTypeToken
| kZeroOrOneMediaFeatureTypeToken
;
// All tokens representing media types that are true on this platform.
media_type_known:
kAllMediaTypeToken
| kTVMediaTypeToken
| kScreenMediaTypeToken
;
// Returns true for known specified media types, otherwise false.
media_type_specified:
media_type_unknown {
$$ = false;
}
| media_type_known {
$$ = true;
}
;
// The names chosen for CSS media types reflect target devices for which the
// relevant properties make sense
// https://www.w3.org/TR/CSS21/media.html#media-types
// https://www.w3.org/TR/css3-mediaqueries/#media0
evaluated_media_type:
// @media [type]...
media_type_specified {
$$ = $1;
}
// @media not [type]...
| kMediaNotToken kWhitespaceToken media_type_specified {
$$ = !$3;
}
// @media only [type]...
| kMediaOnlyToken kWhitespaceToken media_type_specified {
$$ = $3;
}
// @media only not ... (special case)
| kMediaOnlyToken kWhitespaceToken kMediaNotToken {
$$ = false;
}
// @media not only ... (special case)
| kMediaNotToken kWhitespaceToken kMediaOnlyToken {
$$ = true;
}
;
// A media query consists of a media type and zero or more expressions that
// check for the conditions of particular media features.
// https://www.w3.org/TR/cssom/#media-queries
// https://www.w3.org/TR/css3-mediaqueries/#media0
media_query:
// @media {}
/* empty */ {
$$ = AddRef(new cssom::MediaQuery(true));
}
// @media (name:value)... {}
| media_feature_list {
scoped_ptr<cssom::MediaFeatures> media_features($1);
$$ = AddRef(new cssom::MediaQuery(true, media_features.Pass()));
}
// @media mediatype {}
| evaluated_media_type maybe_whitespace {
$$ = AddRef(new cssom::MediaQuery($1));
}
// @media mediatype and (name:value)... {}
| evaluated_media_type maybe_whitespace kMediaAndToken maybe_whitespace
media_feature_list {
scoped_ptr<cssom::MediaFeatures> media_features($5);
$$ = AddRef(new cssom::MediaQuery($1, media_features.Pass()));
}
// When an unknown media feature, an unknown media feature value, a malformed
// media query, or unexpected tokens is found, the media query must be
// represented as 'not all'.
// https://www.w3.org/TR/css3-mediaqueries/#error-handling
| errors {
$$ = AddRef(new cssom::MediaQuery(true));
}
;
// Several media queries can be combined in a media query list.
// https://www.w3.org/TR/cssom/#medialist
// https://www.w3.org/TR/css3-mediaqueries/#media0
media_list:
media_query {
$$ = AddRef(new cssom::MediaList(parser_impl->css_parser()));
$$->Append(MakeScopedRefPtrAndRelease($1));
}
| media_list comma media_query {
$$ = $1;
$$->Append(MakeScopedRefPtrAndRelease($3));
}
;
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Keyframe Rule and Keyframes Rule
// https://www.w3.org/TR/2013/WD-css3-animations-20130219/#CSSKeyframeRule-interface
// https://www.w3.org/TR/2013/WD-css3-animations-20130219/#CSSKeyframesRule-interface
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
at_keyframes_rule:
kKeyframesToken maybe_whitespace kIdentifierToken maybe_whitespace '{'
maybe_whitespace keyframe_rule_list '}' maybe_whitespace {
$$ = $7 ? AddRef(
new cssom::CSSKeyframesRule($3.ToString(),
MakeScopedRefPtrAndRelease($7))) : NULL;
}
;
keyframe_rule_list:
keyframe_rule {
$$ = AddRef(new cssom::CSSRuleList());
$$->AppendCSSRule(MakeScopedRefPtrAndRelease($1));
}
| error {
// The error message is logged by |keyframe_rule|, so it is not necessary to
// log it again.
$$ = NULL;
}
| keyframe_rule_list keyframe_rule {
$$ = $1;
scoped_refptr<cssom::CSSKeyframeRule> keyframe_rule(
MakeScopedRefPtrAndRelease($2));
if ($$) {
$$->AppendCSSRule(keyframe_rule);
}
}
;
keyframe_rule:
keyframe_selector style_declaration_block {
scoped_ptr<std::vector<float> > offsets($1);
scoped_refptr<cssom::CSSRuleStyleDeclaration> style(
MakeScopedRefPtrAndRelease($2));
const cssom::CSSDeclaredStyleData::PropertyValues& property_values = style->data()->declared_property_values();
for (cssom::CSSDeclaredStyleData::PropertyValues::const_iterator
property_iterator = property_values.begin();
property_iterator != property_values.end();
++property_iterator) {
if (property_iterator->second == cssom::KeywordValue::GetInherit() ||
property_iterator->second == cssom::KeywordValue::GetInitial()) {
parser_impl->LogError(
@2, "keyframe properties with initial or inherit are not supported");
YYERROR;
}
}
$$ = AddRef(new cssom::CSSKeyframeRule(*offsets, style));
}
;
keyframe_selector:
keyframe_offset {
$$ = new std::vector<float>(1, $1);
}
| keyframe_selector ',' maybe_whitespace keyframe_offset {
$$ = $1;
$$->push_back($4);
}
;
keyframe_offset:
kFromToken maybe_whitespace {
$$ = 0.0f;
}
| kToToken maybe_whitespace {
$$ = 1.0f;
}
| kPercentageToken maybe_whitespace {
$$ = $1 / 100.0f;
}
;
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Selectors.
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Some identifiers such as property names or values are recognized
// specifically by the scanner. We are merging those identifiers back together
// to allow their use in selectors.
identifier_token:
kIdentifierToken
// Property names.
| kAllToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAllProperty));
}
| kAnimationDelayToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationDelayProperty));
}
| kAnimationDirectionToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationDirectionProperty));
}
| kAnimationDurationToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationDurationProperty));
}
| kAnimationFillModeToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationFillModeProperty));
}
| kAnimationIterationCountToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationIterationCountProperty));
}
| kAnimationNameToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationNameProperty));
}
| kAnimationTimingFunctionToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationTimingFunctionProperty));
}
| kAnimationToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kAnimationProperty));
}
| kBackgroundColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBackgroundColorProperty));
}
| kBackgroundImageToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBackgroundImageProperty));
}
| kBackgroundPositionToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBackgroundPositionProperty));
}
| kBackgroundRepeatToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBackgroundRepeatProperty));
}
| kBackgroundSizeToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBackgroundSizeProperty));
}
| kBackgroundToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBackgroundProperty));
}
| kBorderToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderProperty));
}
| kBorderBottomToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderBottomProperty));
}
| kBorderBottomColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderBottomColorProperty));
}
| kBorderBottomStyleToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderBottomStyleProperty));
}
| kBorderBottomWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderBottomWidthProperty));
}
| kBorderLeftToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderLeftProperty));
}
| kBorderColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderColorProperty));
}
| kBorderLeftColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderLeftColorProperty));
}
| kBorderLeftStyleToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderLeftStyleProperty));
}
| kBorderLeftWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderLeftWidthProperty));
}
| kBorderRadiusToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderRadiusProperty));
}
| kBorderRightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderRightProperty));
}
| kBorderRightColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderRightColorProperty));
}
| kBorderRightStyleToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderRightStyleProperty));
}
| kBorderRightWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderRightWidthProperty));
}
| kBorderStyleToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderStyleProperty));
}
| kBorderTopToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderTopProperty));
}
| kBorderTopColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderTopColorProperty));
}
| kBorderTopStyleToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderTopStyleProperty));
}
| kBorderTopWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderTopWidthProperty));
}
| kBorderWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBorderWidthProperty));
}
| kBottomToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBottomProperty));
}
| kBoxShadowToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kBoxShadowProperty));
}
| kColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kColorProperty));
}
| kContentToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kContentProperty));
}
| kDisplayToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kDisplayProperty));
}
| kFilterToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kFilterProperty));
}
| kFontToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kFontProperty));
}
| kFontFamilyToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kFontFamilyProperty));
}
| kFontSizeToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kFontSizeProperty));
}
| kFontWeightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kFontWeightProperty));
}
| kHeightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kHeightProperty));
}
| kLeftToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kLeftProperty));
}
| kLineHeightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kLineHeightProperty));
}
| kMarginBottomToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMarginBottomProperty));
}
| kMarginLeftToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMarginLeftProperty));
}
| kMarginRightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMarginRightProperty));
}
| kMarginToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMarginProperty));
}
| kMarginTopToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMarginTopProperty));
}
| kMaxHeightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMaxHeightProperty));
}
| kMaxWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMaxWidthProperty));
}
| kMinHeightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMinHeightProperty));
}
| kMinWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kMinWidthProperty));
}
| kOpacityToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kOpacityProperty));
}
| kOutlineToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kOutlineProperty));
}
| kOutlineColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kOutlineColorProperty));
}
| kOutlineStyleToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kOutlineStyleProperty));
}
| kOutlineWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kOutlineWidthProperty));
}
| kOverflowToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kOverflowProperty));
}
| kOverflowWrapToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kOverflowWrapProperty));
}
| kPaddingBottomToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kPaddingBottomProperty));
}
| kPaddingLeftToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kPaddingLeftProperty));
}
| kPaddingRightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kPaddingRightProperty));
}
| kPaddingToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kPaddingProperty));
}
| kPaddingTopToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kPaddingTopProperty));
}
| kPointerEventsToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kPointerEventsProperty));
}
| kPositionToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kPositionProperty));
}
| kRightToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kRightProperty));
}
| kSrcToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kSrcProperty));
}
| kTextAlignToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTextAlignProperty));
}
| kTextDecorationToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTextDecorationProperty));
}
| kTextDecorationColorToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTextDecorationColorProperty));
}
| kTextDecorationLineToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTextDecorationLineProperty));
}
| kTextIndentToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTextIndentProperty));
}
| kTextOverflowToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTextOverflowProperty));
}
| kTextTransformToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTextTransformProperty));
}
| kTopToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTopProperty));
}
| kTransformToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTransformProperty));
}
| kTransformOriginToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTransformOriginProperty));
}
| kTransitionDelayToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTransitionDelayProperty));
}
| kTransitionDurationToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTransitionDurationProperty));
}
| kTransitionPropertyToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTransitionPropertyProperty));
}
| kTransitionTimingFunctionToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTransitionTimingFunctionProperty));
}
| kTransitionToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kTransitionProperty));
}
| kUnicodeRangePropertyToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kUnicodeRangeProperty));
}
| kVerticalAlignToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kVerticalAlignProperty));
}
| kVisibilityToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kVisibilityProperty));
}
| kWhiteSpacePropertyToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kWhiteSpaceProperty));
}
| kWidthToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kWidthProperty));
}
| kZIndexToken {
$$ = TrivialStringPiece::FromCString(
cssom::GetPropertyName(cssom::kZIndexProperty));
}
// Property values.
| kAbsoluteToken {
$$ = TrivialStringPiece::FromCString(cssom::kAbsoluteKeywordName);
}
| kAlternateToken {
$$ = TrivialStringPiece::FromCString(cssom::kAlternateKeywordName);
}
| kAlternateReverseToken {
$$ = TrivialStringPiece::FromCString(cssom::kAlternateReverseKeywordName);
}
| kAquaToken {
$$ = TrivialStringPiece::FromCString(cssom::kAquaKeywordName);
}
| kAtToken {
$$ = TrivialStringPiece::FromCString(cssom::kAtKeywordName);
}
| kAutoToken {
$$ = TrivialStringPiece::FromCString(cssom::kAutoKeywordName);
}
| kBackwardsToken {
$$ = TrivialStringPiece::FromCString(cssom::kBackwardsKeywordName);
}
| kBaselineToken {
$$ = TrivialStringPiece::FromCString(cssom::kBaselineKeywordName);
}
| kBlackToken {
$$ = TrivialStringPiece::FromCString(cssom::kBlackKeywordName);
}
| kBlockToken {
$$ = TrivialStringPiece::FromCString(cssom::kBlockKeywordName);
}
| kBlueToken {
$$ = TrivialStringPiece::FromCString(cssom::kBlueKeywordName);
}
| kBoldToken {
$$ = TrivialStringPiece::FromCString(cssom::kBoldKeywordName);
}
| kBothToken {
$$ = TrivialStringPiece::FromCString(cssom::kBothKeywordName);
}
// A rule for kBottomToken is already defined for the matching property name.
| kBreakWordToken {
$$ = TrivialStringPiece::FromCString(cssom::kBreakWordKeywordName);
}
| kCenterToken {
$$ = TrivialStringPiece::FromCString(cssom::kCenterKeywordName);
}
| kCircleToken {
$$ = TrivialStringPiece::FromCString(cssom::kCircleKeywordName);
}
| kClipToken {
$$ = TrivialStringPiece::FromCString(cssom::kClipKeywordName);
}
| kClosestCornerToken {
$$ = TrivialStringPiece::FromCString(cssom::kClosestCornerKeywordName);
}
| kClosestSideToken {
$$ = TrivialStringPiece::FromCString(cssom::kClosestSideKeywordName);
}
| kContainToken {
$$ = TrivialStringPiece::FromCString(cssom::kContainKeywordName);
}
| kCoverToken {
$$ = TrivialStringPiece::FromCString(cssom::kCoverKeywordName);
}
| kCursiveToken {
$$ = TrivialStringPiece::FromCString(cssom::kCursiveKeywordName);
}
| kEaseInOutToken {
$$ = TrivialStringPiece::FromCString(cssom::kEaseInOutKeywordName);
}
| kEaseInToken {
$$ = TrivialStringPiece::FromCString(cssom::kEaseInKeywordName);
}
| kEaseOutToken {
$$ = TrivialStringPiece::FromCString(cssom::kEaseOutKeywordName);
}
| kEaseToken {
$$ = TrivialStringPiece::FromCString(cssom::kEaseKeywordName);
}
| kEllipseToken {
$$ = TrivialStringPiece::FromCString(cssom::kEllipseKeywordName);
}
| kEllipsisToken {
$$ = TrivialStringPiece::FromCString(cssom::kEllipsisKeywordName);
}
| kEndToken {
$$ = TrivialStringPiece::FromCString(cssom::kEndKeywordName);
}
| kFantasyToken {
$$ = TrivialStringPiece::FromCString(cssom::kFantasyKeywordName);
}
| kFarthestCornerToken {
$$ = TrivialStringPiece::FromCString(cssom::kFarthestCornerKeywordName);
}
| kFarthestSideToken {
$$ = TrivialStringPiece::FromCString(cssom::kFarthestSideKeywordName);
}
| kFixedToken {
$$ = TrivialStringPiece::FromCString(cssom::kFixedKeywordName);
}
| kForwardsToken {
$$ = TrivialStringPiece::FromCString(cssom::kForwardsKeywordName);
}
| kFromToken {
$$ = TrivialStringPiece::FromCString(cssom::kFromKeywordName);
}
| kFuchsiaToken {
$$ = TrivialStringPiece::FromCString(cssom::kFuchsiaKeywordName);
}
| kGrayToken {
$$ = TrivialStringPiece::FromCString(cssom::kGrayKeywordName);
}
| kGreenToken {
$$ = TrivialStringPiece::FromCString(cssom::kGreenKeywordName);
}
| kHiddenToken {
$$ = TrivialStringPiece::FromCString(cssom::kHiddenKeywordName);
}
| kInfiniteToken {
$$ = TrivialStringPiece::FromCString(cssom::kInfiniteKeywordName);
}
| kInheritToken {
$$ = TrivialStringPiece::FromCString(cssom::kInheritKeywordName);
}
| kInitialToken {
$$ = TrivialStringPiece::FromCString(cssom::kInitialKeywordName);
}
| kInlineBlockToken {
$$ = TrivialStringPiece::FromCString(cssom::kInlineBlockKeywordName);
}
| kInlineToken {
$$ = TrivialStringPiece::FromCString(cssom::kInlineKeywordName);
}
| kInsetToken {
$$ = TrivialStringPiece::FromCString(cssom::kInsetKeywordName);
}
| kItalicToken {
$$ = TrivialStringPiece::FromCString(cssom::kItalicKeywordName);
}
| kLimeToken {
$$ = TrivialStringPiece::FromCString(cssom::kLimeKeywordName);
}
| kLinearToken {
$$ = TrivialStringPiece::FromCString(cssom::kLinearKeywordName);
}
| kLineThroughToken {
$$ = TrivialStringPiece::FromCString(cssom::kLineThroughKeywordName);
}
| kMaroonToken {
$$ = TrivialStringPiece::FromCString(cssom::kMaroonKeywordName);
}
| kMiddleToken {
$$ = TrivialStringPiece::FromCString(cssom::kMiddleKeywordName);
}
| kMonoscopicToken {
$$ = TrivialStringPiece::FromCString(cssom::kMonoscopicKeywordName);
}
| kMonospaceToken {
$$ = TrivialStringPiece::FromCString(cssom::kMonospaceKeywordName);
}
| kNavyToken {
$$ = TrivialStringPiece::FromCString(cssom::kNavyKeywordName);
}
| kNoneToken {
$$ = TrivialStringPiece::FromCString(cssom::kNoneKeywordName);
}
| kNoRepeatToken {
$$ = TrivialStringPiece::FromCString(cssom::kNoRepeatKeywordName);
}
| kNormalToken {
$$ = TrivialStringPiece::FromCString(cssom::kNormalKeywordName);
}
| kNoWrapToken {
$$ = TrivialStringPiece::FromCString(cssom::kNoWrapKeywordName);
}
| kObliqueToken {
$$ = TrivialStringPiece::FromCString(cssom::kObliqueKeywordName);
}
| kOliveToken {
$$ = TrivialStringPiece::FromCString(cssom::kOliveKeywordName);
}
| kPreToken {
$$ = TrivialStringPiece::FromCString(cssom::kPreKeywordName);
}
| kPreLineToken {
$$ = TrivialStringPiece::FromCString(cssom::kPreLineKeywordName);
}
| kPreWrapToken {
$$ = TrivialStringPiece::FromCString(cssom::kPreWrapKeywordName);
}
| kPurpleToken {
$$ = TrivialStringPiece::FromCString(cssom::kPurpleKeywordName);
}
| kRedToken {
$$ = TrivialStringPiece::FromCString(cssom::kRedKeywordName);
}
| kRepeatToken {
$$ = TrivialStringPiece::FromCString(cssom::kRepeatKeywordName);
}
| kRepeatXToken {
$$ = TrivialStringPiece::FromCString(cssom::kRepeatXKeywordName);
}
| kRepeatYToken {
$$ = TrivialStringPiece::FromCString(cssom::kRepeatYKeywordName);
}
| kRelativeToken {
$$ = TrivialStringPiece::FromCString(cssom::kRelativeKeywordName);
}
| kReverseToken {
$$ = TrivialStringPiece::FromCString(cssom::kReverseKeywordName);
}
| kSansSerifToken {
$$ = TrivialStringPiece::FromCString(cssom::kSansSerifKeywordName);
}
| kSerifToken {
$$ = TrivialStringPiece::FromCString(cssom::kSerifKeywordName);
}
| kSilverToken {
$$ = TrivialStringPiece::FromCString(cssom::kSilverKeywordName);
}
| kSolidToken {
$$ = TrivialStringPiece::FromCString(cssom::kSolidKeywordName);
}
| kStartToken {
$$ = TrivialStringPiece::FromCString(cssom::kStartKeywordName);
}
| kStaticToken {
$$ = TrivialStringPiece::FromCString(cssom::kStaticKeywordName);
}
| kStepEndToken {
$$ = TrivialStringPiece::FromCString(cssom::kStepEndKeywordName);
}
| kStepStartToken {
$$ = TrivialStringPiece::FromCString(cssom::kStepStartKeywordName);
}
| kStereoscopicLeftRightToken {
$$ = TrivialStringPiece::FromCString(
cssom::kStereoscopicLeftRightKeywordName);
}
| kStereoscopicTopBottomToken {
$$ = TrivialStringPiece::FromCString(
cssom::kStereoscopicTopBottomKeywordName);
}
| kTealToken {
$$ = TrivialStringPiece::FromCString(cssom::kTealKeywordName);
}
| kToToken {
$$ = TrivialStringPiece::FromCString(cssom::kToKeywordName);
}
// A rule for kTopToken is already defined for the matching property name.
| kTransparentToken {
$$ = TrivialStringPiece::FromCString(cssom::kTransparentKeywordName);
}
| kUppercaseToken {
$$ = TrivialStringPiece::FromCString(cssom::kUppercaseKeywordName);
}
| kVisibleToken {
$$ = TrivialStringPiece::FromCString(cssom::kVisibleKeywordName);
}
| kWhiteToken {
$$ = TrivialStringPiece::FromCString(cssom::kWhiteKeywordName);
}
| kYellowToken {
$$ = TrivialStringPiece::FromCString(cssom::kYellowKeywordName);
}
// Pseudo-class names.
| kActiveToken {
$$ = TrivialStringPiece::FromCString(cssom::kActivePseudoClassName);
}
| kEmptyToken {
$$ = TrivialStringPiece::FromCString(cssom::kEmptyPseudoClassName);
}
| kFocusToken {
$$ = TrivialStringPiece::FromCString(cssom::kFocusPseudoClassName);
}
| kHoverToken {
$$ = TrivialStringPiece::FromCString(cssom::kHoverPseudoClassName);
}
// Pseudo-element names.
| kAfterToken {
$$ = TrivialStringPiece::FromCString(cssom::kAfterPseudoElementName);
}
| kBeforeToken {
$$ = TrivialStringPiece::FromCString(cssom::kBeforePseudoElementName);
}
;
// The universal selector represents an element with any name.
// https://www.w3.org/TR/selectors4/#universal-selector
universal_selector_token:
'*' {
$$ = new cssom::UniversalSelector();
}
;
// A type selector represents an instance of the element type in the document
// tree.
// https://www.w3.org/TR/selectors4/#type-selector
type_selector_token:
identifier_token {
$$ = new cssom::TypeSelector($1.ToString());
}
;
attribute_match:
'=' maybe_whitespace {
$$ = cssom::AttributeSelector::kEquals;
}
| kIncludesToken maybe_whitespace {
$$ = cssom::AttributeSelector::kIncludes;
}
| kDashMatchToken maybe_whitespace {
$$ = cssom::AttributeSelector::kDashMatch;
}
| kBeginsWithToken maybe_whitespace {
$$ = cssom::AttributeSelector::kBeginsWith;
}
| kEndsWithToken maybe_whitespace {
$$ = cssom::AttributeSelector::kEndsWith;
}
| kContainsToken maybe_whitespace {
$$ = cssom::AttributeSelector::kContains;
}
// An attribute selector represents an element that has an attribute that
// matches the attribute represented by the attribute selector.
// https://www.w3.org/TR/selectors4/#attribute-selector
attribute_selector_token:
'[' maybe_whitespace identifier_token maybe_whitespace ']' {
$$ = new cssom::AttributeSelector($3.ToString());
}
| '[' maybe_whitespace identifier_token maybe_whitespace
attribute_match kStringToken maybe_whitespace ']' {
$$ = new cssom::AttributeSelector($3.ToString(), $5, $6.ToString());
}
| '[' maybe_whitespace identifier_token maybe_whitespace
attribute_match identifier_token maybe_whitespace ']' {
$$ = new cssom::AttributeSelector($3.ToString(), $5, $6.ToString());
}
;
// The class selector represents an element belonging to the class identified by
// the identifier.
// https://www.w3.org/TR/selectors4/#class-selector
class_selector_token:
'.' identifier_token {
$$ = new cssom::ClassSelector($2.ToString());
}
;
// An ID selector represents an element instance that has an identifier that
// matches the identifier in the ID selector.
// https://www.w3.org/TR/selectors4/#id-selector
id_selector_token:
kIdSelectorToken {
$$ = new cssom::IdSelector($1.ToString());
}
| kHexToken {
if (IsAsciiDigit(*$1.begin)) {
YYERROR;
}
$$ = new cssom::IdSelector($1.ToString());
}
;
// The pseudo-class concept is introduced to permit selection based on
// information that lies outside of the document tree or that can be awkward or
// impossible to express using the other simple selectors.
// https://www.w3.org/TR/selectors4/#pseudo-classes
pseudo_class_token:
// The :active pseudo-class applies while an element is being activated by the
// user. For example, between the times the user presses the mouse button and
// releases it. On systems with more than one mouse button, :active applies
// only to the primary or primary activation button (typically the "left"
// mouse button), and any aliases thereof.
// https://www.w3.org/TR/selectors4/#active-pseudo
':' kActiveToken {
$$ = new cssom::ActivePseudoClass();
}
// The :empty pseudo-class represents an element that has no children. In
// terms of the document tree, only element nodes and content nodes (such as
// DOM text nodes, CDATA nodes, and entity references) whose data has a
// non-zero length must be considered as affecting emptiness; comments,
// processing instructions, and other nodes must not affect whether an element
// is considered empty or not.
// https://www.w3.org/TR/selectors4/#empty-pseudo
| ':' kEmptyToken {
$$ = new cssom::EmptyPseudoClass();
}
// The :focus pseudo-class applies while an element has the focus (accepts
// keyboard or mouse events, or other forms of input).
// https://www.w3.org/TR/selectors4/#focus-pseudo
| ':' kFocusToken {
$$ = new cssom::FocusPseudoClass();
}
// The :hover pseudo-class applies while the user designates an element with a
// pointing device, but does not necessarily activate it. For example, a
// visual user agent could apply this pseudo-class when the cursor (mouse
// pointer) hovers over a box generated by the element. Interactive user
// agents that cannot detect hovering due to hardware limitations (e.g., a pen
// device that does not detect hovering) are still conforming.
// https://www.w3.org/TR/selectors4/#hover-pseudo
| ':' kHoverToken {
$$ = new cssom::HoverPseudoClass();
}
// The negation pseudo-class, :not(), is a functional pseudo-class taking a
// selector list as an argument. It represents an element that is not
// represented by its argument.
// https://www.w3.org/TR/selectors4/#negation-pseudo
| ':' kNotFunctionToken compound_selector_token ')' {
scoped_ptr<cssom::CompoundSelector> compound_selector($3);
if (compound_selector) {
scoped_ptr<cssom::NotPseudoClass> not_pseudo_class(new
cssom::NotPseudoClass());
not_pseudo_class->set_selector(compound_selector.Pass());
$$ = not_pseudo_class.release();
} else {
parser_impl->LogWarning(@1, "unsupported selector within :not()");
$$ = NULL;
}
}
| ':' kNotFunctionToken errors ')' {
parser_impl->LogWarning(@1, "unsupported selector within :not()");
$$ = NULL;
}
| ':' errors {
parser_impl->LogWarning(@1, "unsupported pseudo-class");
$$ = NULL;
}
;
// Pseudo-elements create abstractions about the document tree beyond those
// specified by the document language.
// https://www.w3.org/TR/selectors4/#pseudo-elements
pseudo_element_token:
// Authors specify the style and location of generated content with the
// :before and :after pseudo-elements.
// https://www.w3.org/TR/CSS21/generate.html#before-after-content
// User agents must also accept the previous one-colon notation for
// pseudo-elements introduced in CSS levels 1 and 2.
// https://www.w3.org/TR/selectors4/#pseudo-elements
':' kAfterToken {
$$ = new cssom::AfterPseudoElement();
}
| ':' kBeforeToken {
$$ = new cssom::BeforePseudoElement();
}
| ':' ':' kAfterToken {
$$ = new cssom::AfterPseudoElement();
}
| ':' ':' kBeforeToken {
$$ = new cssom::BeforePseudoElement();
}
| ':' ':' errors {
parser_impl->LogWarning(@1, "unsupported pseudo-element");
$$ = NULL;
}
;
// A simple selector represents an aspect of an element to be matched against.
// https://www.w3.org/TR/selectors4/#simple
simple_selector_token:
attribute_selector_token
| class_selector_token
| id_selector_token
| pseudo_class_token
| pseudo_element_token
| type_selector_token
| universal_selector_token
;
// A compound selector is a chain of simple selectors that are not separated by
// a combinator.
// https://www.w3.org/TR/selectors4/#compound
compound_selector_token:
simple_selector_token {
scoped_ptr<cssom::SimpleSelector> simple_selector($1);
if (simple_selector) {
$$ = new cssom::CompoundSelector();
$$->AppendSelector(simple_selector.Pass());
} else {
$$ = NULL;
}
}
| compound_selector_token simple_selector_token {
scoped_ptr<cssom::CompoundSelector> compound_selector($1);
scoped_ptr<cssom::SimpleSelector> simple_selector($2);
if (compound_selector && simple_selector) {
$$ = compound_selector.release();
$$->AppendSelector(simple_selector.Pass());
} else {
$$ = NULL;
}
}
;
// A combinator is punctuation that represents a particular kind of relationship
// between the selectors on either side.
// https://www.w3.org/TR/selectors4/#combinator
combinator:
kWhitespaceToken {
$$ = new cssom::DescendantCombinator();
}
| '>' maybe_whitespace {
$$ = new cssom::ChildCombinator();
}
| '+' maybe_whitespace {
$$ = new cssom::NextSiblingCombinator();
}
| '~' maybe_whitespace {
$$ = new cssom::FollowingSiblingCombinator();
}
;
// A complex selector is a chain of one or more compound selectors separated by
// combinators.
// https://www.w3.org/TR/selectors4/#complex
complex_selector:
compound_selector_token {
scoped_ptr<cssom::CompoundSelector> compound_selector($1);
if (compound_selector) {
$$ = new cssom::ComplexSelector();
$$->AppendSelector(compound_selector.Pass());
} else {
$$ = NULL;
}
}
| complex_selector combinator compound_selector_token {
scoped_ptr<cssom::ComplexSelector> complex_selector($1);
scoped_ptr<cssom::Combinator> combinator($2);
scoped_ptr<cssom::CompoundSelector> compound_selector($3);
if (complex_selector && compound_selector) {
$$ = complex_selector.release();
$$->AppendCombinatorAndSelector(combinator.Pass(),
compound_selector.Pass());
} else {
$$ = NULL;
}
}
| complex_selector kWhitespaceToken
;
// A selector list is a comma-separated list of selectors.
// https://www.w3.org/TR/selectors4/#selector-list
selector_list:
complex_selector {
scoped_ptr<cssom::ComplexSelector> complex_selector($1);
if (complex_selector) {
$$ = new cssom::Selectors();
$$->push_back(complex_selector.release());
} else {
$$ = NULL;
}
}
| selector_list comma complex_selector {
scoped_ptr<cssom::Selectors> selector_list($1);
scoped_ptr<cssom::ComplexSelector> complex_selector($3);
if (selector_list && complex_selector) {
$$ = selector_list.release();
$$->push_back(complex_selector.release());
} else {
$$ = NULL;
}
}
;
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Common rules used in property values.
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
auto:
kAutoToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetAuto().get());
}
// The scanner that we adopted from WebKit was built with assumption that sign
// is handled in the grammar. Practically this means that tokens of <number>
// and <real> types has to be prepended with this rule.
// https://www.w3.org/TR/css3-syntax/#consume-a-number
maybe_sign_token:
/* empty */ { $$ = 1; }
| '+' { $$ = 1; }
| '-' { $$ = -1; }
;
// This is for integers that can only have the values 0 or 1, including '-0'.
// As used in the 'grid' css media feature:
// https://www.w3.org/TR/css3-mediaqueries/#grid
zero_or_one:
integer {
if (($1 < 0) || ($1 > 1)) {
parser_impl->LogError(@1, "integer value must be 0 or 1");
YYERROR;
}
$$ = $1;
}
;
// An integer is one or more decimal digits "0" through "9". The first digit
// of an integer may be immediately preceded by "-" or "+" to indicate the sign.
// https://www.w3.org/TR/css3-values/#integers
integer:
maybe_sign_token kIntegerToken maybe_whitespace {
$$ = $1 * $2;
}
;
// Wrap the |integer| in order to validate if the integer is not negative
non_negative_integer:
integer {
if ($1 < 0) {
parser_impl->LogError(@1, "integer value must not be negative");
YYERROR;
}
$$ = $1;
}
;
// Wrap the |integer| in order to validate if the integer is positive
positive_integer:
integer {
if ($1 < 1) {
parser_impl->LogError(@1, "integer value must be positive");
YYERROR;
}
$$ = $1;
}
;
// A number is either an |integer| or zero or more decimal digits followed
// by a dot followed by one or more decimal digits.
// https://www.w3.org/TR/css3-values/#numbers
number:
integer { $$ = $1; }
| maybe_sign_token kRealToken maybe_whitespace { $$ = $1 * $2; }
;
// Wrap |number| and validates that it is not negative.
non_negative_number:
number {
if ($1 < 0) {
parser_impl->LogError(@1, "number value must not be negative");
YYERROR;
}
$$ = $1;
}
;
// Percentage values are always relative to another value, for example a length.
// Each property that allows percentages also defines the value to which
// the percentage refers.
// https://www.w3.org/TR/css3-values/#percentages
percentage:
maybe_sign_token kPercentageToken maybe_whitespace {
$$ = AddRef(new cssom::PercentageValue($1 * $2 / 100));
}
;
// Wrap the |percentage| in order to validate if the percentage is positive.
positive_percentage:
percentage {
scoped_refptr<cssom::PercentageValue> percentage =
MakeScopedRefPtrAndRelease($1);
if (percentage && percentage->value() < 0) {
parser_impl->LogError(@1, "negative values of percentage are illegal");
YYERROR;
}
$$ = AddRef(percentage.get());
}
;
// Opacity.
// https://www.w3.org/TR/css3-color/#alphavaluedt
alpha:
number {
// Any values outside the range 0.0 (fully transparent)
// to 1.0 (fully opaque) will be clamped to this range.
$$ = ClampToRange(0.0f, 1.0f, $1);
}
;
// Distance units.
// https://www.w3.org/TR/css3-values/#lengths
length:
number {
if ($1 != 0) {
parser_impl->LogError(
@1, "non-zero length is not allowed without unit identifier");
YYERROR;
}
$$ = AddRef(new cssom::LengthValue(0, cssom::kPixelsUnit));
}
| absolute_or_relative_length { $$ = $1; }
;
absolute_or_relative_length:
// Relative lengths.
// https://www.w3.org/TR/css3-values/#relative-lengths
maybe_sign_token kFontSizesAkaEmToken maybe_whitespace {
$$ = AddRef(new cssom::LengthValue($1 * $2, cssom::kFontSizesAkaEmUnit));
}
| maybe_sign_token kRootElementFontSizesAkaRemToken maybe_whitespace {
$$ = AddRef(new cssom::LengthValue($1 * $2,
cssom::kRootElementFontSizesAkaRemUnit));
}
| maybe_sign_token kViewportWidthPercentsAkaVwToken maybe_whitespace {
$$ = AddRef(new cssom::LengthValue($1 * $2,
cssom::kViewportWidthPercentsAkaVwUnit));
}
| maybe_sign_token kViewportHeightPercentsAkaVhToken maybe_whitespace {
$$ = AddRef(new cssom::LengthValue($1 * $2,
cssom::kViewportHeightPercentsAkaVhUnit));
}
// Absolute lengths.
// https://www.w3.org/TR/css3-values/#absolute-lengths
| maybe_sign_token kPixelsToken maybe_whitespace {
$$ = AddRef(new cssom::LengthValue($1 * $2, cssom::kPixelsUnit));
}
;
positive_length:
length {
scoped_refptr<cssom::LengthValue> length(MakeScopedRefPtrAndRelease($1));
if (length && length->value() < 0) {
parser_impl->LogError(@1, "negative values of length are illegal");
YYERROR;
}
$$ = AddRef(length.get());
}
;
// Ratio units.
// https://www.w3.org/TR/css3-mediaqueries/#values
ratio:
positive_integer '/' maybe_whitespace positive_integer {
$$ = AddRef(new cssom::RatioValue(math::Rational($1, $4)));
}
;
// Resolution units.
// https://www.w3.org/TR/css3-mediaqueries/#resolution0
resolution:
maybe_sign_token kDotsPerInchToken maybe_whitespace {
float value = $1 * $2;
if (value <= 0) {
parser_impl->LogError(@1, "resolution value must be positive");
YYERROR;
}
$$ = AddRef(new cssom::ResolutionValue(value, cssom::kDPIUnit));
}
| maybe_sign_token kDotsPerCentimeterToken maybe_whitespace {
float value = $1 * $2;
if (value <= 0) {
parser_impl->LogError(@1, "resolution value must be positive");
YYERROR;
}
$$ = AddRef(new cssom::ResolutionValue(value, cssom::kDPCMUnit));
}
;
// Angle units (returned synthetic value will always be in radians).
// https://www.w3.org/TR/css3-values/#angles
angle:
maybe_sign_token kDegreesToken maybe_whitespace {
$$ = $1 * $2 * (2 * static_cast<float>(M_PI) / 360.0f);
}
| maybe_sign_token kGradiansToken maybe_whitespace {
$$ = $1 * $2 * (2 * static_cast<float>(M_PI) / 400.0f);
}
| maybe_sign_token kRadiansToken maybe_whitespace {
$$ = $1 * $2;
}
| maybe_sign_token kTurnsToken maybe_whitespace {
$$ = $1 * $2 * 2 * static_cast<float>(M_PI);
}
;
// Time units (used by animations and transitions).
// https://www.w3.org/TR/css3-values/#time
time:
number {
$$ = base::TimeDelta::FromMilliseconds(
static_cast<int64>($1 * base::Time::kMillisecondsPerSecond)).
ToInternalValue();
if ($1 != 0) {
parser_impl->LogWarning(
@1, "non-zero time is not allowed without unit identifier");
}
}
| time_with_units_required
;
time_with_units_required:
maybe_sign_token kSecondsToken maybe_whitespace {
$$ = base::TimeDelta::FromMilliseconds(
static_cast<int64>($1 * $2 * base::Time::kMillisecondsPerSecond)).
ToInternalValue();
}
| maybe_sign_token kMillisecondsToken maybe_whitespace {
$$ = base::TimeDelta::FromMilliseconds(static_cast<int64>($1 * $2)).
ToInternalValue();
}
;
colon: ':' maybe_whitespace ;
comma: ',' maybe_whitespace ;
// All properties accept the CSS-wide keywords.
// https://www.w3.org/TR/css3-values/#common-keywords
common_values:
common_values_without_errors
| errors {
// If a user agent does not support a particular value, it should ignore
// that value when parsing style sheets, as if that value was an illegal
// value.
// https://www.w3.org/TR/CSS21/syndata.html#unsupported-values
//
// User agents must ignore a declaration with an illegal value.
// https://www.w3.org/TR/CSS21/syndata.html#illegalvalues
parser_impl->LogWarning(@1, "unsupported value");
$$ = NULL;
}
;
common_values_without_errors:
kInheritToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetInherit().get());
}
| kInitialToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetInitial().get());
}
;
color:
// Hexadecimal notation.
// https://www.w3.org/TR/css3-color/#numerical
kHexToken maybe_whitespace {
switch ($1.size()) {
// The three-digit RGB notation (#rgb) is converted into six-digit
// form (#rrggbb) by replicating digits.
case 3: {
uint32 rgb = ParseHexToken($1);
uint32 r = (rgb & 0xf00) >> 8;
uint32 g = (rgb & 0x0f0) >> 4;
uint32 b = (rgb & 0x00f);
$$ = AddRef(new cssom::RGBAColorValue((r << 28) | (r << 24) |
(g << 20) | (g << 16) |
(b << 12) | (b << 8) |
0xff));
break;
}
case 6: {
uint32 rgb = ParseHexToken($1);
$$ = AddRef(new cssom::RGBAColorValue((rgb << 8) | 0xff));
break;
}
default:
YYERROR;
break;
}
}
// RGB color model.
// https://www.w3.org/TR/css3-color/#rgb-color
| kRGBFunctionToken maybe_whitespace integer comma
integer comma integer ')' maybe_whitespace {
uint8 r = static_cast<uint8>(ClampToRange(0, 255, $3));
uint8 g = static_cast<uint8>(ClampToRange(0, 255, $5));
uint8 b = static_cast<uint8>(ClampToRange(0, 255, $7));
$$ = AddRef(new cssom::RGBAColorValue(r, g, b, 0xff));
}
// RGB color model with opacity.
// https://www.w3.org/TR/css3-color/#rgba-color
| kRGBAFunctionToken maybe_whitespace integer comma integer comma integer
comma alpha ')' maybe_whitespace {
uint8 r = static_cast<uint8>(ClampToRange(0, 255, $3));
uint8 g = static_cast<uint8>(ClampToRange(0, 255, $5));
uint8 b = static_cast<uint8>(ClampToRange(0, 255, $7));
float a = $9; // Already clamped.
$$ = AddRef(
new cssom::RGBAColorValue(r, g, b, static_cast<uint8>(a * 0xff)));
}
| kAquaToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetAqua().get());
}
| kBlackToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetBlack().get());
}
| kBlueToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetBlue().get());
}
| kFuchsiaToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetFuchsia().get());
}
| kGrayToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetGray().get());
}
| kGreenToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetGreen().get());
}
| kLimeToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetLime().get());
}
| kMaroonToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetMaroon().get());
}
| kNavyToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetNavy().get());
}
| kOliveToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetOlive().get());
}
| kPurpleToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetPurple().get());
}
| kRedToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetRed().get());
}
| kSilverToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetSilver().get());
}
| kTealToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetTeal().get());
}
| kTransparentToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetTransparent().get());
}
| kWhiteToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetWhite().get());
}
| kYellowToken maybe_whitespace {
$$ = AddRef(cssom::RGBAColorValue::GetYellow().get());
}
;
url:
kUriToken ')' maybe_whitespace {
$$ = AddRef(new cssom::URLValue($1.ToString()));
}
;
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
// Property values.
// ...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:...:.
length_percent_property_value:
length {
$$ = $1;
}
| percentage {
$$ = $1;
}
;
positive_length_percent_property_value:
positive_length {
$$ = $1;
}
| positive_percentage {
$$ = $1;
}
;
background_property_element:
color {
scoped_refptr<cssom::PropertyValue> color(MakeScopedRefPtrAndRelease($1));
if (!$<background_shorthand_layer>0->background_color) {
$<background_shorthand_layer>0->background_color = color;
} else {
parser_impl->LogError(
@1, "background-color value declared twice in background.");
$<background_shorthand_layer>0->error = true;
}
}
| background_image_property_list_element {
scoped_refptr<cssom::PropertyValue> image(MakeScopedRefPtrAndRelease($1));
if (!$<background_shorthand_layer>0->background_image) {
scoped_ptr<cssom::PropertyListValue::Builder>
background_image_builder(new cssom::PropertyListValue::Builder());
background_image_builder->reserve(1);
background_image_builder->push_back(image);
$<background_shorthand_layer>0->background_image =
new cssom::PropertyListValue(background_image_builder.Pass());
} else {
parser_impl->LogError(
@1, "background-image value declared twice in background.");
$<background_shorthand_layer>0->error = true;
}
}
;
maybe_background_size_property_value:
/* empty */ {
$$ = NULL;
}
| '/' maybe_whitespace background_size_property_value_without_common_values {
$$ = $3;
}
;
background_position_and_size_shorthand_property_value:
validated_position_property
maybe_background_size_property_value {
scoped_ptr<BackgroundShorthandLayer> shorthand_layer(
new BackgroundShorthandLayer());
shorthand_layer->background_position = MakeScopedRefPtrAndRelease($1);
if ($2) {
shorthand_layer->background_size = MakeScopedRefPtrAndRelease($2);
}
$$ = shorthand_layer.release();
}
;
background_repeat_shorthand_property_value:
background_repeat_property_value_without_common_values {
scoped_ptr<BackgroundShorthandLayer> shorthand_layer(
new BackgroundShorthandLayer());
shorthand_layer->background_repeat = MakeScopedRefPtrAndRelease($1);
$$ = shorthand_layer.release();
}
;
// 'background-size' property should follow with 'background-position' property
// and a '/'.
background_position_and_repeat_combination:
background_position_and_size_shorthand_property_value
| background_repeat_shorthand_property_value
| background_position_and_size_shorthand_property_value
background_repeat_shorthand_property_value {
scoped_ptr<BackgroundShorthandLayer> shorthand_layer($1);
scoped_ptr<BackgroundShorthandLayer> non_overlapped($2);
shorthand_layer->IntegrateNonOverlapped(*non_overlapped);
$$ = shorthand_layer.release();
}
| background_repeat_shorthand_property_value
background_position_and_size_shorthand_property_value {
scoped_ptr<BackgroundShorthandLayer> shorthand_layer($1);
scoped_ptr<BackgroundShorthandLayer> non_overlapped($2);
shorthand_layer->IntegrateNonOverlapped(*non_overlapped);
$$ = shorthand_layer.release();
}
;
final_background_layer_without_position_and_repeat:
/* empty */ {
// Initialize the background shorthand which is to be filled in by
// subsequent reductions.
$$ = new BackgroundShorthandLayer();
}
| final_background_layer background_property_element {
// Propagate the return value from the reduced list.
// Appending of the new background_property_element to the list is done
// within background_property_element's reduction.
$$ = $1;
}
;
// Only the final background layer is allowed to set the background color.
// https://www.w3.org/TR/css3-background/#ltfinal-bg-layergt
final_background_layer:
/* empty */ {
// Initialize the background shorthand which is to be filled in by
// subsequent reductions.
$$ = new BackgroundShorthandLayer();
}
| final_background_layer_without_position_and_repeat
background_position_and_repeat_combination {
scoped_ptr<BackgroundShorthandLayer> shorthand($1);
scoped_ptr<BackgroundShorthandLayer> background_values($2);
if (!shorthand->IsBackgroundPropertyOverlapped(*background_values.get())) {
shorthand->IntegrateNonOverlapped(*background_values.get());
$$ = shorthand.release();
} else {
parser_impl->LogError(
@1, "background-position or background-repeat declared twice in "
"background.");
$$ = new BackgroundShorthandLayer();
$$->error = true;
}
}
| final_background_layer background_property_element {
// Propagate the return value from the reduced list.
// Appending of the new background_property_element to the list is done
// within background_property_element's reduction.
$$ = $1;
}
;
// Shorthand property for setting most background properties at the same place.
// https://www.w3.org/TR/css3-background/#the-background
background_property_value:
final_background_layer
| common_values {
// Replicate the common value into each of the properties that background
// is a shorthand for.
scoped_ptr<BackgroundShorthandLayer> background(
new BackgroundShorthandLayer());
background->background_color = $1;
background->background_image = $1;
background->background_repeat = $1;
background->background_position = $1;
background->background_size = $1;
$$ = background.release();
}
;
// Background color of an element drawn behind any background images.
// https://www.w3.org/TR/css3-background/#the-background-color
background_color_property_value:
color { $$ = $1; }
| common_values
;
color_stop:
color {
$$ = new cssom::ColorStop(MakeScopedRefPtrAndRelease($1));
}
| color length_percent_property_value {
$$ = new cssom::ColorStop(MakeScopedRefPtrAndRelease($1),
MakeScopedRefPtrAndRelease($2));
}
;
// Only 2 or more color stops can make a valid color stop list.
comma_separated_color_stop_list:
color_stop comma color_stop {
$$ = new cssom::ColorStopList();
$$->push_back($1);
$$->push_back($3);
}
| comma_separated_color_stop_list comma color_stop {
$$ = $1;
$$->push_back($3);
}
;
side:
kBottomToken maybe_whitespace {
$$ = cssom::LinearGradientValue::kBottom;
}
| kLeftToken maybe_whitespace {
$$ = cssom::LinearGradientValue::kLeft;
}
| kRightToken maybe_whitespace {
$$ = cssom::LinearGradientValue::kRight;
}
| kTopToken maybe_whitespace {
$$ = cssom::LinearGradientValue::kTop;
}
;
side_or_corner:
side
| side side {
if ($1 == cssom::LinearGradientValue::kBottom) {
if($2 == cssom::LinearGradientValue::kLeft) {
$$ = cssom::LinearGradientValue::kBottomLeft;
} else if ($2 == cssom::LinearGradientValue::kRight) {
$$ = cssom::LinearGradientValue::kBottomRight;
} else {
parser_impl->LogWarning(@1, "Illegal corner value.");
}
} else if ($1 == cssom::LinearGradientValue::kLeft) {
if($2 == cssom::LinearGradientValue::kBottom) {
$$ = cssom::LinearGradientValue::kBottomLeft;
} else if ($2 == cssom::LinearGradientValue::kTop) {
$$ = cssom::LinearGradientValue::kTopLeft;
} else {
parser_impl->LogWarning(@1, "Illegal corner value.");
}
} else if ($1 == cssom::LinearGradientValue::kRight) {
if($2 == cssom::LinearGradientValue::kBottom) {
$$ = cssom::LinearGradientValue::kBottomRight;
} else if ($2 == cssom::LinearGradientValue::kTop) {
$$ = cssom::LinearGradientValue::kTopRight;
} else {
parser_impl->LogWarning(@1, "Illegal corner value.");
}
} else if ($1 == cssom::LinearGradientValue::kTop) {
if($2 == cssom::LinearGradientValue::kLeft) {
$$ = cssom::LinearGradientValue::kTopLeft;
} else if ($2 == cssom::LinearGradientValue::kRight) {
$$ = cssom::LinearGradientValue::kTopRight;
} else {
parser_impl->LogWarning(@1, "Illegal corner value.");
}
}
}
;
linear_gradient_params:
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($1);
// If the first argument to the linear gradient function is omitted, it
// defaults to 'to bottom'.
$$ = AddRef(new cssom::LinearGradientValue(
cssom::LinearGradientValue::kBottom, color_stop_list->Pass()));
}
| angle comma comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($3);
$$ = AddRef(new cssom::LinearGradientValue($1, color_stop_list->Pass()));
}
| kToToken kWhitespaceToken maybe_whitespace side_or_corner comma
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($6);
$$ = AddRef(new cssom::LinearGradientValue($4, color_stop_list->Pass()));
}
;
size_keyword:
kClosestSideToken maybe_whitespace {
$$ = cssom::RadialGradientValue::kClosestSide;
}
| kFarthestSideToken maybe_whitespace {
$$ = cssom::RadialGradientValue::kFarthestSide;
}
| kClosestCornerToken maybe_whitespace {
$$ = cssom::RadialGradientValue::kClosestCorner;
}
| kFarthestCornerToken maybe_whitespace {
$$ = cssom::RadialGradientValue::kFarthestCorner;
}
;
circle_with_size_keyword:
kCircleToken maybe_whitespace size_keyword {
$$ = $3;
}
| size_keyword kCircleToken maybe_whitespace {
$$ = $1;
}
;
// If <shape> is specified as 'circle' or is omitted, the <size> may be
// given explicitly as a single <length> which gives the radius of the
// circle explicitly. Negative values are invalid.
circle_with_positive_length:
positive_length {
scoped_ptr<cssom::PropertyListValue::Builder> property_value(
new cssom::PropertyListValue::Builder());
property_value->reserve(1);
property_value->push_back(MakeScopedRefPtrAndRelease($1));
$$ = AddRef(new cssom::PropertyListValue(property_value.Pass()));
}
| positive_length kCircleToken maybe_whitespace {
scoped_ptr<cssom::PropertyListValue::Builder> property_value(
new cssom::PropertyListValue::Builder());
property_value->reserve(1);
property_value->push_back(MakeScopedRefPtrAndRelease($1));
$$ = AddRef(new cssom::PropertyListValue(property_value.Pass()));
}
| kCircleToken maybe_whitespace positive_length {
scoped_ptr<cssom::PropertyListValue::Builder> property_value(
new cssom::PropertyListValue::Builder());
property_value->reserve(1);
property_value->push_back(MakeScopedRefPtrAndRelease($3));
$$ = AddRef(new cssom::PropertyListValue(property_value.Pass()));
}
;
maybe_ellipse_with_size_keyword:
kEllipseToken maybe_whitespace size_keyword {
$$ = $3;
}
| size_keyword kEllipseToken maybe_whitespace {
$$ = $1;
}
| size_keyword {
// If only a size keyword is specified, the ending shape defaults to an
// ellipse.
$$ = $1;
}
;
// If <shape> is specified as 'ellipse' or is omitted, the <size> may be
// given explicitly as [<length> | <percentage>]{2} which gives the size of
// the ellipse explicitly. Negative values are invalid.
ellipse_with_2_positive_length_percents:
positive_length_percent_property_value
positive_length_percent_property_value {
scoped_ptr<cssom::PropertyListValue::Builder> property_value(
new cssom::PropertyListValue::Builder());
property_value->reserve(2);
property_value->push_back(MakeScopedRefPtrAndRelease($1));
property_value->push_back(MakeScopedRefPtrAndRelease($2));
$$ = AddRef(new cssom::PropertyListValue(property_value.Pass()));
}
| positive_length_percent_property_value
positive_length_percent_property_value kEllipseToken maybe_whitespace {
scoped_ptr<cssom::PropertyListValue::Builder> property_value(
new cssom::PropertyListValue::Builder());
property_value->reserve(2);
property_value->push_back(MakeScopedRefPtrAndRelease($1));
property_value->push_back(MakeScopedRefPtrAndRelease($2));
$$ = AddRef(new cssom::PropertyListValue(property_value.Pass()));
}
| kEllipseToken maybe_whitespace positive_length_percent_property_value
positive_length_percent_property_value {
scoped_ptr<cssom::PropertyListValue::Builder> property_value(
new cssom::PropertyListValue::Builder());
property_value->reserve(2);
property_value->push_back(MakeScopedRefPtrAndRelease($3));
property_value->push_back(MakeScopedRefPtrAndRelease($4));
$$ = AddRef(new cssom::PropertyListValue(property_value.Pass()));
}
;
at_position:
kAtToken maybe_whitespace validated_position_property {
$$ = $3;
}
;
maybe_at_position:
/* empty */ {
$$ = NULL;
}
| at_position
;
// https://www.w3.org/TR/css3-images/#radial-gradients
radial_gradient_params:
circle_with_positive_length maybe_at_position comma
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($4);
$$ = AddRef(
new cssom::RadialGradientValue(cssom::RadialGradientValue::kCircle,
MakeScopedRefPtrAndRelease($1),
MakeScopedRefPtrAndRelease($2),
color_stop_list->Pass()));
}
| ellipse_with_2_positive_length_percents maybe_at_position comma
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($4);
$$ = AddRef(
new cssom::RadialGradientValue(cssom::RadialGradientValue::kEllipse,
MakeScopedRefPtrAndRelease($1),
MakeScopedRefPtrAndRelease($2),
color_stop_list->Pass()));
}
| circle_with_size_keyword maybe_at_position comma
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($4);
$$ = AddRef(
new cssom::RadialGradientValue(cssom::RadialGradientValue::kCircle,
$1,
MakeScopedRefPtrAndRelease($2),
color_stop_list->Pass()));
}
| maybe_ellipse_with_size_keyword maybe_at_position comma
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($4);
$$ = AddRef(
new cssom::RadialGradientValue(cssom::RadialGradientValue::kEllipse,
$1,
MakeScopedRefPtrAndRelease($2),
color_stop_list->Pass()));
}
| kCircleToken maybe_whitespace maybe_at_position comma
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($5);
$$ = AddRef(new cssom::RadialGradientValue(
cssom::RadialGradientValue::kCircle,
cssom::RadialGradientValue::kFarthestCorner,
MakeScopedRefPtrAndRelease($3),
color_stop_list->Pass()));
}
| kEllipseToken maybe_whitespace maybe_at_position comma
comma_separated_color_stop_list {
scoped_ptr<cssom::ColorStopList> color_stop_list($5);
$$ = AddRef(new cssom::RadialGradientValue(
cssom::RadialGradientValue::kEllipse,
cssom::RadialGradientValue::kFarthestCorner,
MakeScopedRefPtrAndRelease($3),
color_stop_list->Pass()));
}
| at_position comma comma_separated_color_stop_list {
// If no size or shape is specified, the ending shape defaults to an ellipse
// and the size defaults to 'farthest-corner'.
scoped_ptr<cssom::ColorStopList> color_stop_list($3);
$$ = AddRef(new cssom::RadialGradientValue(
cssom::RadialGradientValue::kEllipse,
cssom::RadialGradientValue::kFarthestCorner,
MakeScopedRefPtrAndRelease($1),
color_stop_list->Pass()));
}
| comma_separated_color_stop_list {
// If position is omitted as well, it defaults to 'center', indicated by
// passing in NULL.
scoped_ptr<cssom::ColorStopList> color_stop_list($1);
$$ = AddRef(new cssom::RadialGradientValue(
cssom::RadialGradientValue::kEllipse,
cssom::RadialGradientValue::kFarthestCorner,
NULL,
color_stop_list->Pass()));
}
;
background_image_property_list_element:
url { $$ = $1; }
| kLinearGradientFunctionToken maybe_whitespace linear_gradient_params ')' {
$$ = $3;
}
| kRadialGradientFunctionToken maybe_whitespace radial_gradient_params ')' {
$$ = $3;
}
| kNoneToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetNone().get());
}
;
comma_separated_background_image_list:
background_image_property_list_element {
$$ = new cssom::PropertyListValue::Builder();
$$->push_back(MakeScopedRefPtrAndRelease($1));
}
| comma_separated_background_image_list comma
background_image_property_list_element {
$$ = $1;
$$->push_back(MakeScopedRefPtrAndRelease($3));
}
;
// Images are drawn with the first specified one on top (closest to the user)
// and each subsequent image behind the previous one.
// https://www.w3.org/TR/css3-background/#the-background-image
background_image_property_value:
comma_separated_background_image_list {
scoped_ptr<cssom::PropertyListValue::Builder> property_value($1);
$$ = property_value
? AddRef(new cssom::PropertyListValue(property_value.Pass()))
: NULL;
}
| common_values
;
position_list_element:
kBottomToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetBottom().get());
}
| kCenterToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetCenter().get());
}
| kLeftToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetLeft().get());
}
| kRightToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetRight().get());
}
| kTopToken maybe_whitespace {
$$ = AddRef(cssom::KeywordValue::GetTop().get());
}
| length_percent_property_value
;
position_list:
position_list_element {
scoped_ptr<PositionParseStructure> position_info(
new PositionParseStructure());
position_info->PushBackElement(MakeScopedRefPtrAndRelease($1));
$$ = position_info.release();
}
| position_list
position_list_element {
scoped_ptr<PositionParseStructure> position_info($1);
scoped_refptr<cssom::PropertyValue> element(MakeScopedRefPtrAndRelease($2));
if (position_info &&
!position_info->PushBackElement(element)) {
parser_impl->LogWarning(@2, "invalid background position value");
$$ = NULL;
} else {
$$ = position_info.release();
}
}
;
validated_position_property:
position_list {
scoped_ptr<PositionParseStructure> position_info($1);
scoped_ptr<cssom::PropertyListValue::Builder> property_value;
if (!position_info) {
// No-ops.