OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 10 matching lines...) Expand all Loading... |
21 * You should have received a copy of the GNU Library General Public License | 21 * You should have received a copy of the GNU Library General Public License |
22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/css/parser/CSSPropertyParser.h" | 27 #include "core/css/parser/CSSPropertyParser.h" |
28 | 28 |
29 #include "core/StylePropertyShorthand.h" | 29 #include "core/StylePropertyShorthand.h" |
30 #include "core/css/CSSBorderImage.h" | 30 #include "core/css/CSSBorderImage.h" |
31 #include "core/css/CSSContentDistributionValue.h" | |
32 #include "core/css/CSSCrossfadeValue.h" | 31 #include "core/css/CSSCrossfadeValue.h" |
33 #include "core/css/CSSCustomIdentValue.h" | 32 #include "core/css/CSSCustomIdentValue.h" |
34 #include "core/css/CSSFunctionValue.h" | 33 #include "core/css/CSSFunctionValue.h" |
35 #include "core/css/CSSGridLineNamesValue.h" | 34 #include "core/css/CSSGridLineNamesValue.h" |
36 #include "core/css/CSSImageSetValue.h" | 35 #include "core/css/CSSImageSetValue.h" |
37 #include "core/css/CSSPrimitiveValueMappings.h" | 36 #include "core/css/CSSPrimitiveValueMappings.h" |
38 #include "core/css/CSSProperty.h" | 37 #include "core/css/CSSProperty.h" |
39 #include "core/css/CSSPropertyMetadata.h" | 38 #include "core/css/CSSPropertyMetadata.h" |
40 #include "core/css/CSSQuadValue.h" | 39 #include "core/css/CSSQuadValue.h" |
41 #include "core/css/CSSReflectValue.h" | 40 #include "core/css/CSSReflectValue.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 case CSSPropertyWebkitBoxReflect: | 392 case CSSPropertyWebkitBoxReflect: |
394 if (id == CSSValueNone) | 393 if (id == CSSValueNone) |
395 validPrimitive = true; | 394 validPrimitive = true; |
396 else | 395 else |
397 parsedValue = parseReflect(); | 396 parsedValue = parseReflect(); |
398 break; | 397 break; |
399 case CSSPropertyFontSizeAdjust: // none | <number> | 398 case CSSPropertyFontSizeAdjust: // none | <number> |
400 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); | 399 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); |
401 validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber
| FNonNeg); | 400 validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber
| FNonNeg); |
402 break; | 401 break; |
403 case CSSPropertyJustifyContent: | 402 |
404 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
405 parsedValue = parseContentDistributionOverflowPosition(); | |
406 break; | |
407 case CSSPropertyJustifySelf: | 403 case CSSPropertyJustifySelf: |
408 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 404 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
409 parsedValue = parseItemPositionOverflowPosition(); | 405 parsedValue = parseItemPositionOverflowPosition(); |
410 break; | 406 break; |
411 case CSSPropertyJustifyItems: | 407 case CSSPropertyJustifyItems: |
412 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 408 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
413 | 409 |
414 if ((parsedValue = parseLegacyPosition())) | 410 if ((parsedValue = parseLegacyPosition())) |
415 break; | 411 break; |
416 | 412 |
(...skipping 22 matching lines...) Expand all Loading... |
439 case CSSPropertyGridRowStart: | 435 case CSSPropertyGridRowStart: |
440 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 436 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
441 parsedValue = parseGridPosition(); | 437 parsedValue = parseGridPosition(); |
442 break; | 438 break; |
443 | 439 |
444 case CSSPropertyGridTemplateAreas: | 440 case CSSPropertyGridTemplateAreas: |
445 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 441 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
446 parsedValue = parseGridTemplateAreas(); | 442 parsedValue = parseGridTemplateAreas(); |
447 break; | 443 break; |
448 | 444 |
449 case CSSPropertyAlignContent: | |
450 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
451 parsedValue = parseContentDistributionOverflowPosition(); | |
452 break; | 445 break; |
453 | 446 |
454 case CSSPropertyAlignSelf: | 447 case CSSPropertyAlignSelf: |
455 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 448 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
456 parsedValue = parseItemPositionOverflowPosition(); | 449 parsedValue = parseItemPositionOverflowPosition(); |
457 break; | 450 break; |
458 | 451 |
459 case CSSPropertyAlignItems: | 452 case CSSPropertyAlignItems: |
460 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 453 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
461 parsedValue = parseItemPositionOverflowPosition(); | 454 parsedValue = parseItemPositionOverflowPosition(); |
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 default: | 2153 default: |
2161 return parsedValues; | 2154 return parsedValues; |
2162 } | 2155 } |
2163 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); | 2156 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); |
2164 list.next(); | 2157 list.next(); |
2165 } | 2158 } |
2166 | 2159 |
2167 return parsedValues; | 2160 return parsedValues; |
2168 } | 2161 } |
2169 | 2162 |
2170 static bool isContentDistributionKeyword(CSSValueID id) | |
2171 { | |
2172 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround | |
2173 || id == CSSValueSpaceEvenly || id == CSSValueStretch; | |
2174 } | |
2175 | |
2176 static bool isContentPositionKeyword(CSSValueID id) | |
2177 { | |
2178 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter | |
2179 || id == CSSValueFlexStart || id == CSSValueFlexEnd | |
2180 || id == CSSValueLeft || id == CSSValueRight; | |
2181 } | |
2182 | |
2183 static bool isBaselinePositionKeyword(CSSValueID id) | 2163 static bool isBaselinePositionKeyword(CSSValueID id) |
2184 { | 2164 { |
2185 return id == CSSValueBaseline || id == CSSValueLastBaseline; | 2165 return id == CSSValueBaseline || id == CSSValueLastBaseline; |
2186 } | 2166 } |
2187 | 2167 |
2188 static bool isAlignmentOverflowKeyword(CSSValueID id) | 2168 static bool isAlignmentOverflowKeyword(CSSValueID id) |
2189 { | 2169 { |
2190 return id == CSSValueUnsafe || id == CSSValueSafe; | 2170 return id == CSSValueUnsafe || id == CSSValueSafe; |
2191 } | 2171 } |
2192 | 2172 |
(...skipping 21 matching lines...) Expand all Loading... |
2214 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) | 2194 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) |
2215 return nullptr; | 2195 return nullptr; |
2216 } else { | 2196 } else { |
2217 return nullptr; | 2197 return nullptr; |
2218 } | 2198 } |
2219 | 2199 |
2220 m_valueList->next(); | 2200 m_valueList->next(); |
2221 return CSSValuePair::create(cssValuePool().createIdentifierValue(CSSValueLeg
acy), cssValuePool().createIdentifierValue(value->id), CSSValuePair::DropIdentic
alValues); | 2201 return CSSValuePair::create(cssValuePool().createIdentifierValue(CSSValueLeg
acy), cssValuePool().createIdentifierValue(value->id), CSSValuePair::DropIdentic
alValues); |
2222 } | 2202 } |
2223 | 2203 |
2224 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver
flowPosition() | |
2225 { | |
2226 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi
on>? && <content-position> ] | |
2227 // <baseline-position> = baseline | last-baseline; | |
2228 // <content-distribution> = space-between | space-around | space-evenly | st
retch; | |
2229 // <content-position> = center | start | end | flex-start | flex-end | left
| right; | |
2230 // <overflow-position> = true | safe | |
2231 | |
2232 // auto | <baseline-position> | |
2233 CSSParserValue* value = m_valueList->current(); | |
2234 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { | |
2235 m_valueList->next(); | |
2236 return CSSContentDistributionValue::create(CSSValueInvalid, value->id, C
SSValueInvalid); | |
2237 } | |
2238 | |
2239 CSSValueID distribution = CSSValueInvalid; | |
2240 CSSValueID position = CSSValueInvalid; | |
2241 CSSValueID overflow = CSSValueInvalid; | |
2242 while (value) { | |
2243 if (isContentDistributionKeyword(value->id)) { | |
2244 if (distribution != CSSValueInvalid) | |
2245 return nullptr; | |
2246 distribution = value->id; | |
2247 } else if (isContentPositionKeyword(value->id)) { | |
2248 if (position != CSSValueInvalid) | |
2249 return nullptr; | |
2250 position = value->id; | |
2251 } else if (isAlignmentOverflowKeyword(value->id)) { | |
2252 if (overflow != CSSValueInvalid) | |
2253 return nullptr; | |
2254 overflow = value->id; | |
2255 } else { | |
2256 return nullptr; | |
2257 } | |
2258 value = m_valueList->next(); | |
2259 } | |
2260 | |
2261 // The grammar states that we should have at least <content-distribution> or | |
2262 // <content-position> ( <content-distribution> || <content-position> ). | |
2263 if (position == CSSValueInvalid && distribution == CSSValueInvalid) | |
2264 return nullptr; | |
2265 | |
2266 // The grammar states that <overflow-position> must be associated to <conten
t-position>. | |
2267 if (overflow != CSSValueInvalid && position == CSSValueInvalid) | |
2268 return nullptr; | |
2269 | |
2270 return CSSContentDistributionValue::create(distribution, position, overflow)
; | |
2271 } | |
2272 | |
2273 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseItemPositionOverflowPos
ition() | 2204 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseItemPositionOverflowPos
ition() |
2274 { | 2205 { |
2275 // auto | stretch | <baseline-position> | [<item-position> && <overflow-posi
tion>? ] | 2206 // auto | stretch | <baseline-position> | [<item-position> && <overflow-posi
tion>? ] |
2276 // <baseline-position> = baseline | last-baseline; | 2207 // <baseline-position> = baseline | last-baseline; |
2277 // <item-position> = center | start | end | self-start | self-end | flex-sta
rt | flex-end | left | right; | 2208 // <item-position> = center | start | end | self-start | self-end | flex-sta
rt | flex-end | left | right; |
2278 // <overflow-position> = true | safe | 2209 // <overflow-position> = true | safe |
2279 | 2210 |
2280 CSSParserValue* value = m_valueList->current(); | 2211 CSSParserValue* value = m_valueList->current(); |
2281 ASSERT(value); | 2212 ASSERT(value); |
2282 | 2213 |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3834 ASSERT(!m_parsedCalculation); | 3765 ASSERT(!m_parsedCalculation); |
3835 m_parsedCalculation = CSSCalcValue::create(args, range); | 3766 m_parsedCalculation = CSSCalcValue::create(args, range); |
3836 | 3767 |
3837 if (!m_parsedCalculation) | 3768 if (!m_parsedCalculation) |
3838 return false; | 3769 return false; |
3839 | 3770 |
3840 return true; | 3771 return true; |
3841 } | 3772 } |
3842 | 3773 |
3843 } // namespace blink | 3774 } // namespace blink |
OLD | NEW |