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 * |
11 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
12 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
13 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
14 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
15 * | 15 * |
16 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 * Library General Public License for more details. | 19 * Library General Public License for more details. |
20 * | 20 * |
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/CSSBasicShapeValues.h" | |
31 #include "core/css/CSSBorderImage.h" | 30 #include "core/css/CSSBorderImage.h" |
32 #include "core/css/CSSContentDistributionValue.h" | 31 #include "core/css/CSSContentDistributionValue.h" |
33 #include "core/css/CSSCrossfadeValue.h" | 32 #include "core/css/CSSCrossfadeValue.h" |
34 #include "core/css/CSSCustomIdentValue.h" | 33 #include "core/css/CSSCustomIdentValue.h" |
35 #include "core/css/CSSFunctionValue.h" | 34 #include "core/css/CSSFunctionValue.h" |
36 #include "core/css/CSSGridLineNamesValue.h" | 35 #include "core/css/CSSGridLineNamesValue.h" |
37 #include "core/css/CSSImageSetValue.h" | 36 #include "core/css/CSSImageSetValue.h" |
38 #include "core/css/CSSPrimitiveValueMappings.h" | 37 #include "core/css/CSSPrimitiveValueMappings.h" |
39 #include "core/css/CSSProperty.h" | 38 #include "core/css/CSSProperty.h" |
40 #include "core/css/CSSPropertyMetadata.h" | 39 #include "core/css/CSSPropertyMetadata.h" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 case CSSPropertyGridRowStart: | 449 case CSSPropertyGridRowStart: |
451 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 450 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
452 parsedValue = parseGridPosition(); | 451 parsedValue = parseGridPosition(); |
453 break; | 452 break; |
454 | 453 |
455 case CSSPropertyGridTemplateAreas: | 454 case CSSPropertyGridTemplateAreas: |
456 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 455 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
457 parsedValue = parseGridTemplateAreas(); | 456 parsedValue = parseGridTemplateAreas(); |
458 break; | 457 break; |
459 | 458 |
460 case CSSPropertyWebkitClipPath: | |
461 if (id == CSSValueNone) { | |
462 validPrimitive = true; | |
463 } else if (value->m_unit == CSSParserValue::Function) { | |
464 parsedValue = parseBasicShape(); | |
465 } else if (value->m_unit == CSSParserValue::URI) { | |
466 // TODO(timloh): This will allow trailing junk | |
467 return CSSURIValue::create(value->string); | |
468 } | |
469 break; | |
470 case CSSPropertyShapeOutside: | |
471 if (id == CSSValueNone) | |
472 validPrimitive = true; | |
473 else | |
474 parsedValue = parseShapeProperty(propId); | |
475 break; | |
476 | |
477 case CSSPropertyAlignContent: | 459 case CSSPropertyAlignContent: |
478 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 460 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
479 parsedValue = parseContentDistributionOverflowPosition(); | 461 parsedValue = parseContentDistributionOverflowPosition(); |
480 break; | 462 break; |
481 | 463 |
482 case CSSPropertyAlignSelf: | 464 case CSSPropertyAlignSelf: |
483 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 465 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
484 parsedValue = parseItemPositionOverflowPosition(); | 466 parsedValue = parseItemPositionOverflowPosition(); |
485 break; | 467 break; |
486 | 468 |
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 default: | 2136 default: |
2155 return parsedValues; | 2137 return parsedValues; |
2156 } | 2138 } |
2157 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); | 2139 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); |
2158 list.next(); | 2140 list.next(); |
2159 } | 2141 } |
2160 | 2142 |
2161 return parsedValues; | 2143 return parsedValues; |
2162 } | 2144 } |
2163 | 2145 |
2164 void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]) | |
2165 { | |
2166 if (radii[3]) | |
2167 return; | |
2168 if (!radii[2]) { | |
2169 if (!radii[1]) | |
2170 radii[1] = radii[0]; | |
2171 radii[2] = radii[0]; | |
2172 } | |
2173 radii[3] = radii[1]; | |
2174 } | |
2175 | |
2176 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseBasicSha
peInset(CSSParserValueList* args) | |
2177 { | |
2178 ASSERT(args); | |
2179 | |
2180 RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue:
:create(); | |
2181 | |
2182 CSSParserValue* argument = args->current(); | |
2183 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; | |
2184 bool hasRoundedInset = false; | |
2185 | |
2186 while (argument) { | |
2187 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS
SValueRound) { | |
2188 if (!args->next()) | |
2189 return nullptr; | |
2190 hasRoundedInset = true; | |
2191 break; | |
2192 } | |
2193 | |
2194 Units unitFlags = FLength | FPercent; | |
2195 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) | |
2196 return nullptr; | |
2197 | |
2198 widthArguments.append(createPrimitiveNumericValue(argument)); | |
2199 argument = args->next(); | |
2200 } | |
2201 | |
2202 switch (widthArguments.size()) { | |
2203 case 1: { | |
2204 shape->updateShapeSize1Value(widthArguments[0].get()); | |
2205 break; | |
2206 } | |
2207 case 2: { | |
2208 shape->updateShapeSize2Values(widthArguments[0].get(), widthArguments[1]
.get()); | |
2209 break; | |
2210 } | |
2211 case 3: { | |
2212 shape->updateShapeSize3Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get()); | |
2213 break; | |
2214 } | |
2215 case 4: { | |
2216 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get(), widthArguments[3].get()); | |
2217 break; | |
2218 } | |
2219 default: | |
2220 return nullptr; | |
2221 } | |
2222 | |
2223 if (hasRoundedInset) { | |
2224 // FIXME: Refactor completeBorderRadii and the array | |
2225 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]; | |
2226 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4]; | |
2227 if (!parseRadii(radii, radii2, args)) | |
2228 return nullptr; | |
2229 shape->setTopLeftRadius(CSSValuePair::create(radii[0].release(), radii2[
0].release(), CSSValuePair::DropIdenticalValues)); | |
2230 shape->setTopRightRadius(CSSValuePair::create(radii[1].release(), radii2
[1].release(), CSSValuePair::DropIdenticalValues)); | |
2231 shape->setBottomRightRadius(CSSValuePair::create(radii[2].release(), rad
ii2[2].release(), CSSValuePair::DropIdenticalValues)); | |
2232 shape->setBottomLeftRadius(CSSValuePair::create(radii[3].release(), radi
i2[3].release(), CSSValuePair::DropIdenticalValues)); | |
2233 } | |
2234 | |
2235 return shape.release(); | |
2236 } | |
2237 | |
2238 static bool isContentDistributionKeyword(CSSValueID id) | 2146 static bool isContentDistributionKeyword(CSSValueID id) |
2239 { | 2147 { |
2240 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround | 2148 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround |
2241 || id == CSSValueSpaceEvenly || id == CSSValueStretch; | 2149 || id == CSSValueSpaceEvenly || id == CSSValueStretch; |
2242 } | 2150 } |
2243 | 2151 |
2244 static bool isContentPositionKeyword(CSSValueID id) | 2152 static bool isContentPositionKeyword(CSSValueID id) |
2245 { | 2153 { |
2246 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter | 2154 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter |
2247 || id == CSSValueFlexStart || id == CSSValueFlexEnd | 2155 || id == CSSValueFlexStart || id == CSSValueFlexEnd |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2376 } | 2284 } |
2377 | 2285 |
2378 m_valueList->next(); | 2286 m_valueList->next(); |
2379 | 2287 |
2380 ASSERT(position); | 2288 ASSERT(position); |
2381 if (overflowAlignmentKeyword) | 2289 if (overflowAlignmentKeyword) |
2382 return CSSValuePair::create(position, overflowAlignmentKeyword, CSSValue
Pair::DropIdenticalValues); | 2290 return CSSValuePair::create(position, overflowAlignmentKeyword, CSSValue
Pair::DropIdenticalValues); |
2383 return position.release(); | 2291 return position.release(); |
2384 } | 2292 } |
2385 | 2293 |
2386 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS
SParserValue* value) | |
2387 { | |
2388 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) | |
2389 return cssValuePool().createIdentifierValue(value->id); | |
2390 | |
2391 if (!validUnit(value, FLength | FPercent | FNonNeg)) | |
2392 return nullptr; | |
2393 | |
2394 return createPrimitiveNumericValue(value); | |
2395 } | |
2396 | |
2397 PassRefPtrWillBeRawPtr<CSSBasicShapeCircleValue> CSSPropertyParser::parseBasicSh
apeCircle(CSSParserValueList* args) | |
2398 { | |
2399 ASSERT(args); | |
2400 | |
2401 // circle(radius) | |
2402 // circle(radius at <position>) | |
2403 // circle(at <position>) | |
2404 // where position defines centerX and centerY using a CSS <position> data ty
pe. | |
2405 RefPtrWillBeRawPtr<CSSBasicShapeCircleValue> shape = CSSBasicShapeCircleValu
e::create(); | |
2406 | |
2407 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | |
2408 // The call to parseFillPosition below should consume all of the | |
2409 // arguments except the first two. Thus, and index greater than one | |
2410 // indicates an invalid production. | |
2411 if (args->currentIndex() > 1) | |
2412 return nullptr; | |
2413 | |
2414 if (!args->currentIndex() && argument->id != CSSValueAt) { | |
2415 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | |
2416 shape->setRadius(radius); | |
2417 continue; | |
2418 } | |
2419 | |
2420 return nullptr; | |
2421 } | |
2422 | |
2423 if (argument->id == CSSValueAt && args->next()) { | |
2424 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | |
2425 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | |
2426 parseFillPosition(args, centerX, centerY); | |
2427 if (centerX && centerY && !args->current()) { | |
2428 shape->setCenterX(centerX); | |
2429 shape->setCenterY(centerY); | |
2430 } else { | |
2431 return nullptr; | |
2432 } | |
2433 } else { | |
2434 return nullptr; | |
2435 } | |
2436 } | |
2437 | |
2438 return shape.release(); | |
2439 } | |
2440 | |
2441 PassRefPtrWillBeRawPtr<CSSBasicShapeEllipseValue> CSSPropertyParser::parseBasicS
hapeEllipse(CSSParserValueList* args) | |
2442 { | |
2443 ASSERT(args); | |
2444 | |
2445 // ellipse(radiusX) | |
2446 // ellipse(radiusX at <position>) | |
2447 // ellipse(radiusX radiusY) | |
2448 // ellipse(radiusX radiusY at <position>) | |
2449 // ellipse(at <position>) | |
2450 // where position defines centerX and centerY using a CSS <position> data ty
pe. | |
2451 RefPtrWillBeRawPtr<CSSBasicShapeEllipseValue> shape = CSSBasicShapeEllipseVa
lue::create(); | |
2452 | |
2453 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | |
2454 // The call to parseFillPosition below should consume all of the | |
2455 // arguments except the first three. Thus, an index greater than two | |
2456 // indicates an invalid production. | |
2457 if (args->currentIndex() > 2) | |
2458 return nullptr; | |
2459 | |
2460 if (args->currentIndex() < 2 && argument->id != CSSValueAt) { | |
2461 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | |
2462 if (!shape->radiusX()) | |
2463 shape->setRadiusX(radius); | |
2464 else | |
2465 shape->setRadiusY(radius); | |
2466 continue; | |
2467 } | |
2468 | |
2469 return nullptr; | |
2470 } | |
2471 | |
2472 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) | |
2473 return nullptr; | |
2474 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | |
2475 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | |
2476 parseFillPosition(args, centerX, centerY); | |
2477 if (!centerX || !centerY || args->current()) | |
2478 return nullptr; | |
2479 | |
2480 shape->setCenterX(centerX); | |
2481 shape->setCenterY(centerY); | |
2482 } | |
2483 | |
2484 return shape.release(); | |
2485 } | |
2486 | |
2487 PassRefPtrWillBeRawPtr<CSSBasicShapePolygonValue> CSSPropertyParser::parseBasicS
hapePolygon(CSSParserValueList* args) | |
2488 { | |
2489 ASSERT(args); | |
2490 | |
2491 unsigned size = args->size(); | |
2492 if (!size) | |
2493 return nullptr; | |
2494 | |
2495 RefPtrWillBeRawPtr<CSSBasicShapePolygonValue> shape = CSSBasicShapePolygonVa
lue::create(); | |
2496 | |
2497 CSSParserValue* argument = args->current(); | |
2498 if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) { | |
2499 shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE
_NONZERO); | |
2500 args->next(); | |
2501 | |
2502 if (!consumeComma(args)) | |
2503 return nullptr; | |
2504 | |
2505 size -= 2; | |
2506 } | |
2507 | |
2508 // <length> <length>, ... <length> <length> -> each pair has 3 elements exce
pt the last one | |
2509 if (!size || (size % 3) - 2) | |
2510 return nullptr; | |
2511 | |
2512 while (true) { | |
2513 CSSParserValue* argumentX = args->current(); | |
2514 if (!argumentX || !validUnit(argumentX, FLength | FPercent)) | |
2515 return nullptr; | |
2516 RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericVa
lue(argumentX); | |
2517 | |
2518 CSSParserValue* argumentY = args->next(); | |
2519 if (!argumentY || !validUnit(argumentY, FLength | FPercent)) | |
2520 return nullptr; | |
2521 RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericVa
lue(argumentY); | |
2522 | |
2523 shape->appendPoint(xLength.release(), yLength.release()); | |
2524 | |
2525 if (!args->next()) | |
2526 break; | |
2527 if (!consumeComma(args)) | |
2528 return nullptr; | |
2529 } | |
2530 | |
2531 return shape.release(); | |
2532 } | |
2533 | |
2534 static bool isBoxValue(CSSValueID valueId) | |
2535 { | |
2536 switch (valueId) { | |
2537 case CSSValueContentBox: | |
2538 case CSSValuePaddingBox: | |
2539 case CSSValueBorderBox: | |
2540 case CSSValueMarginBox: | |
2541 return true; | |
2542 default: | |
2543 break; | |
2544 } | |
2545 | |
2546 return false; | |
2547 } | |
2548 | |
2549 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper
tyID propId) | |
2550 { | |
2551 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; | |
2552 if (parseFillImage(m_valueList, imageValue)) { | |
2553 m_valueList->next(); | |
2554 return imageValue.release(); | |
2555 } | |
2556 | |
2557 return parseBasicShapeAndOrBox(); | |
2558 } | |
2559 | |
2560 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() | |
2561 { | |
2562 CSSParserValue* value = m_valueList->current(); | |
2563 | |
2564 bool shapeFound = false; | |
2565 bool boxFound = false; | |
2566 CSSValueID valueId; | |
2567 | |
2568 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | |
2569 for (unsigned i = 0; i < 2; ++i) { | |
2570 if (!value) | |
2571 break; | |
2572 valueId = value->id; | |
2573 if (value->m_unit == CSSParserValue::Function && !shapeFound) { | |
2574 // parseBasicShape already asks for the next value list item. | |
2575 RefPtrWillBeRawPtr<CSSValue> shapeValue = parseBasicShape(); | |
2576 if (!shapeValue) | |
2577 return nullptr; | |
2578 list->append(shapeValue.release()); | |
2579 shapeFound = true; | |
2580 } else if (isBoxValue(valueId) && !boxFound) { | |
2581 list->append(parseValidPrimitive(valueId, value)); | |
2582 boxFound = true; | |
2583 m_valueList->next(); | |
2584 } else { | |
2585 return nullptr; | |
2586 } | |
2587 | |
2588 value = m_valueList->current(); | |
2589 } | |
2590 | |
2591 if (m_valueList->current()) | |
2592 return nullptr; | |
2593 return list.release(); | |
2594 } | |
2595 | |
2596 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShape() | |
2597 { | |
2598 CSSParserValue* value = m_valueList->current(); | |
2599 ASSERT(value->m_unit == CSSParserValue::Function); | |
2600 CSSParserValueList* args = value->function->args.get(); | |
2601 | |
2602 if (!args) | |
2603 return nullptr; | |
2604 | |
2605 RefPtrWillBeRawPtr<CSSValue> shape = nullptr; | |
2606 if (value->function->id == CSSValueCircle) | |
2607 shape = parseBasicShapeCircle(args); | |
2608 else if (value->function->id == CSSValueEllipse) | |
2609 shape = parseBasicShapeEllipse(args); | |
2610 else if (value->function->id == CSSValuePolygon) | |
2611 shape = parseBasicShapePolygon(args); | |
2612 else if (value->function->id == CSSValueInset) | |
2613 shape = parseBasicShapeInset(args); | |
2614 | |
2615 if (!shape) | |
2616 return nullptr; | |
2617 | |
2618 m_valueList->next(); | |
2619 | |
2620 return shape.release(); | |
2621 } | |
2622 | |
2623 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 2294 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
2624 { | 2295 { |
2625 bool isPercent; | 2296 bool isPercent; |
2626 double value; | 2297 double value; |
2627 | 2298 |
2628 if (m_parsedCalculation) { | 2299 if (m_parsedCalculation) { |
2629 isPercent = m_parsedCalculation->category() == CalcPercent; | 2300 isPercent = m_parsedCalculation->category() == CalcPercent; |
2630 value = m_parsedCalculation->doubleValue(); | 2301 value = m_parsedCalculation->doubleValue(); |
2631 m_parsedCalculation.release(); | 2302 m_parsedCalculation.release(); |
2632 } else { | 2303 } else { |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3301 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>&
result) | 2972 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>&
result) |
3302 { | 2973 { |
3303 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); | 2974 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); |
3304 } | 2975 } |
3305 | 2976 |
3306 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>&
result) | 2977 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>&
result) |
3307 { | 2978 { |
3308 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); | 2979 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
3309 } | 2980 } |
3310 | 2981 |
3311 bool CSSPropertyParser::parseRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4
], RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4], CSSParserValueList* args, CS
SPropertyID unresolvedProperty) | |
3312 { | |
3313 #if ENABLE(OILPAN) | |
3314 // Unconditionally zero initialize the arrays of raw pointers. | |
3315 memset(radii, 0, 4 * sizeof(radii[0])); | |
3316 memset(radii2, 0, 4 * sizeof(radii2[0])); | |
3317 #endif | |
3318 CSSParserValue* value = args->current(); | |
3319 int i; | |
3320 for (i = 0; i < 4 && value && value->m_unit != CSSParserValue::Operator;++i,
value = args->next()) { | |
3321 if (!validUnit(value, FLength | FPercent | FNonNeg)) | |
3322 return false; | |
3323 | |
3324 radii[i] = createPrimitiveNumericValue(value); | |
3325 } | |
3326 | |
3327 if (!i || (value && value->m_unit == CSSParserValue::Operator && value->iVal
ue != '/')) | |
3328 return false; | |
3329 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to border-radi
us: l1 / l2; | |
3330 if (!value && i == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa
dius) { | |
3331 radii2[0] = radii[1]; | |
3332 radii[1] = nullptr; | |
3333 completeBorderRadii(radii); | |
3334 completeBorderRadii(radii2); | |
3335 return true; | |
3336 } | |
3337 completeBorderRadii(radii); | |
3338 if (value) { | |
3339 value = args->next(); | |
3340 for (i = 0; i < 4 && value && validUnit(value, FLength | FPercent | FNon
Neg); ++i, value = args->next()) | |
3341 radii2[i] = createPrimitiveNumericValue(value); | |
3342 if (!i || value) | |
3343 return false; | |
3344 completeBorderRadii(radii2); | |
3345 } else { | |
3346 for (unsigned i = 0; i < 4; ++i) | |
3347 radii2[i] = radii[i]; | |
3348 } | |
3349 | |
3350 return true; | |
3351 } | |
3352 | |
3353 // This should go away once we drop support for -webkit-gradient | 2982 // This should go away once we drop support for -webkit-gradient |
3354 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) | 2983 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) |
3355 { | 2984 { |
3356 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 2985 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; |
3357 if (a->m_unit == CSSParserValue::Identifier) { | 2986 if (a->m_unit == CSSParserValue::Identifier) { |
3358 if ((a->id == CSSValueLeft && horizontal) | 2987 if ((a->id == CSSValueLeft && horizontal) |
3359 || (a->id == CSSValueTop && !horizontal)) | 2988 || (a->id == CSSValueTop && !horizontal)) |
3360 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType:
:Percentage); | 2989 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType:
:Percentage); |
3361 else if ((a->id == CSSValueRight && horizontal) | 2990 else if ((a->id == CSSValueRight && horizontal) |
3362 || (a->id == CSSValueBottom && !horizontal)) | 2991 || (a->id == CSSValueBottom && !horizontal)) |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4181 ASSERT(!m_parsedCalculation); | 3810 ASSERT(!m_parsedCalculation); |
4182 m_parsedCalculation = CSSCalcValue::create(args, range); | 3811 m_parsedCalculation = CSSCalcValue::create(args, range); |
4183 | 3812 |
4184 if (!m_parsedCalculation) | 3813 if (!m_parsedCalculation) |
4185 return false; | 3814 return false; |
4186 | 3815 |
4187 return true; | 3816 return true; |
4188 } | 3817 } |
4189 | 3818 |
4190 } // namespace blink | 3819 } // namespace blink |
OLD | NEW |