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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 case CSSPropertyGridRowStart: | 439 case CSSPropertyGridRowStart: |
441 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 440 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
442 parsedValue = parseGridPosition(); | 441 parsedValue = parseGridPosition(); |
443 break; | 442 break; |
444 | 443 |
445 case CSSPropertyGridTemplateAreas: | 444 case CSSPropertyGridTemplateAreas: |
446 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 445 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
447 parsedValue = parseGridTemplateAreas(); | 446 parsedValue = parseGridTemplateAreas(); |
448 break; | 447 break; |
449 | 448 |
450 case CSSPropertyWebkitClipPath: | |
451 if (id == CSSValueNone) { | |
452 validPrimitive = true; | |
453 } else if (value->m_unit == CSSParserValue::Function) { | |
454 parsedValue = parseBasicShape(); | |
455 } else if (value->m_unit == CSSParserValue::URI) { | |
456 // TODO(timloh): This will allow trailing junk | |
457 return CSSURIValue::create(value->string); | |
458 } | |
459 break; | |
460 case CSSPropertyShapeOutside: | |
461 if (id == CSSValueNone) | |
462 validPrimitive = true; | |
463 else | |
464 parsedValue = parseShapeProperty(propId); | |
465 break; | |
466 | |
467 case CSSPropertyAlignContent: | 449 case CSSPropertyAlignContent: |
468 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 450 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
469 parsedValue = parseContentDistributionOverflowPosition(); | 451 parsedValue = parseContentDistributionOverflowPosition(); |
470 break; | 452 break; |
471 | 453 |
472 case CSSPropertyAlignSelf: | 454 case CSSPropertyAlignSelf: |
473 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 455 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
474 parsedValue = parseItemPositionOverflowPosition(); | 456 parsedValue = parseItemPositionOverflowPosition(); |
475 break; | 457 break; |
476 | 458 |
(...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 default: | 2160 default: |
2179 return parsedValues; | 2161 return parsedValues; |
2180 } | 2162 } |
2181 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); | 2163 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); |
2182 list.next(); | 2164 list.next(); |
2183 } | 2165 } |
2184 | 2166 |
2185 return parsedValues; | 2167 return parsedValues; |
2186 } | 2168 } |
2187 | 2169 |
2188 void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]) | |
2189 { | |
2190 if (radii[3]) | |
2191 return; | |
2192 if (!radii[2]) { | |
2193 if (!radii[1]) | |
2194 radii[1] = radii[0]; | |
2195 radii[2] = radii[0]; | |
2196 } | |
2197 radii[3] = radii[1]; | |
2198 } | |
2199 | |
2200 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseBasicSha
peInset(CSSParserValueList* args) | |
2201 { | |
2202 ASSERT(args); | |
2203 | |
2204 RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue:
:create(); | |
2205 | |
2206 CSSParserValue* argument = args->current(); | |
2207 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; | |
2208 bool hasRoundedInset = false; | |
2209 | |
2210 while (argument) { | |
2211 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS
SValueRound) { | |
2212 if (!args->next()) | |
2213 return nullptr; | |
2214 hasRoundedInset = true; | |
2215 break; | |
2216 } | |
2217 | |
2218 Units unitFlags = FLength | FPercent; | |
2219 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) | |
2220 return nullptr; | |
2221 | |
2222 widthArguments.append(createPrimitiveNumericValue(argument)); | |
2223 argument = args->next(); | |
2224 } | |
2225 | |
2226 switch (widthArguments.size()) { | |
2227 case 1: { | |
2228 shape->updateShapeSize1Value(widthArguments[0].get()); | |
2229 break; | |
2230 } | |
2231 case 2: { | |
2232 shape->updateShapeSize2Values(widthArguments[0].get(), widthArguments[1]
.get()); | |
2233 break; | |
2234 } | |
2235 case 3: { | |
2236 shape->updateShapeSize3Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get()); | |
2237 break; | |
2238 } | |
2239 case 4: { | |
2240 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get(), widthArguments[3].get()); | |
2241 break; | |
2242 } | |
2243 default: | |
2244 return nullptr; | |
2245 } | |
2246 | |
2247 if (hasRoundedInset) { | |
2248 // FIXME: Refactor completeBorderRadii and the array | |
2249 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]; | |
2250 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4]; | |
2251 if (!parseRadii(radii, radii2, args)) | |
2252 return nullptr; | |
2253 shape->setTopLeftRadius(CSSValuePair::create(radii[0].release(), radii2[
0].release(), CSSValuePair::DropIdenticalValues)); | |
2254 shape->setTopRightRadius(CSSValuePair::create(radii[1].release(), radii2
[1].release(), CSSValuePair::DropIdenticalValues)); | |
2255 shape->setBottomRightRadius(CSSValuePair::create(radii[2].release(), rad
ii2[2].release(), CSSValuePair::DropIdenticalValues)); | |
2256 shape->setBottomLeftRadius(CSSValuePair::create(radii[3].release(), radi
i2[3].release(), CSSValuePair::DropIdenticalValues)); | |
2257 } | |
2258 | |
2259 return shape.release(); | |
2260 } | |
2261 | |
2262 static bool isContentDistributionKeyword(CSSValueID id) | 2170 static bool isContentDistributionKeyword(CSSValueID id) |
2263 { | 2171 { |
2264 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround | 2172 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround |
2265 || id == CSSValueSpaceEvenly || id == CSSValueStretch; | 2173 || id == CSSValueSpaceEvenly || id == CSSValueStretch; |
2266 } | 2174 } |
2267 | 2175 |
2268 static bool isContentPositionKeyword(CSSValueID id) | 2176 static bool isContentPositionKeyword(CSSValueID id) |
2269 { | 2177 { |
2270 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter | 2178 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter |
2271 || id == CSSValueFlexStart || id == CSSValueFlexEnd | 2179 || id == CSSValueFlexStart || id == CSSValueFlexEnd |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 } | 2308 } |
2401 | 2309 |
2402 m_valueList->next(); | 2310 m_valueList->next(); |
2403 | 2311 |
2404 ASSERT(position); | 2312 ASSERT(position); |
2405 if (overflowAlignmentKeyword) | 2313 if (overflowAlignmentKeyword) |
2406 return CSSValuePair::create(position, overflowAlignmentKeyword, CSSValue
Pair::DropIdenticalValues); | 2314 return CSSValuePair::create(position, overflowAlignmentKeyword, CSSValue
Pair::DropIdenticalValues); |
2407 return position.release(); | 2315 return position.release(); |
2408 } | 2316 } |
2409 | 2317 |
2410 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS
SParserValue* value) | |
2411 { | |
2412 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) | |
2413 return cssValuePool().createIdentifierValue(value->id); | |
2414 | |
2415 if (!validUnit(value, FLength | FPercent | FNonNeg)) | |
2416 return nullptr; | |
2417 | |
2418 return createPrimitiveNumericValue(value); | |
2419 } | |
2420 | |
2421 PassRefPtrWillBeRawPtr<CSSBasicShapeCircleValue> CSSPropertyParser::parseBasicSh
apeCircle(CSSParserValueList* args) | |
2422 { | |
2423 ASSERT(args); | |
2424 | |
2425 // circle(radius) | |
2426 // circle(radius at <position>) | |
2427 // circle(at <position>) | |
2428 // where position defines centerX and centerY using a CSS <position> data ty
pe. | |
2429 RefPtrWillBeRawPtr<CSSBasicShapeCircleValue> shape = CSSBasicShapeCircleValu
e::create(); | |
2430 | |
2431 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | |
2432 // The call to parseFillPosition below should consume all of the | |
2433 // arguments except the first two. Thus, and index greater than one | |
2434 // indicates an invalid production. | |
2435 if (args->currentIndex() > 1) | |
2436 return nullptr; | |
2437 | |
2438 if (!args->currentIndex() && argument->id != CSSValueAt) { | |
2439 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | |
2440 shape->setRadius(radius); | |
2441 continue; | |
2442 } | |
2443 | |
2444 return nullptr; | |
2445 } | |
2446 | |
2447 if (argument->id == CSSValueAt && args->next()) { | |
2448 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | |
2449 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | |
2450 parseFillPosition(args, centerX, centerY); | |
2451 if (centerX && centerY && !args->current()) { | |
2452 shape->setCenterX(centerX); | |
2453 shape->setCenterY(centerY); | |
2454 } else { | |
2455 return nullptr; | |
2456 } | |
2457 } else { | |
2458 return nullptr; | |
2459 } | |
2460 } | |
2461 | |
2462 return shape.release(); | |
2463 } | |
2464 | |
2465 PassRefPtrWillBeRawPtr<CSSBasicShapeEllipseValue> CSSPropertyParser::parseBasicS
hapeEllipse(CSSParserValueList* args) | |
2466 { | |
2467 ASSERT(args); | |
2468 | |
2469 // ellipse(radiusX) | |
2470 // ellipse(radiusX at <position>) | |
2471 // ellipse(radiusX radiusY) | |
2472 // ellipse(radiusX radiusY at <position>) | |
2473 // ellipse(at <position>) | |
2474 // where position defines centerX and centerY using a CSS <position> data ty
pe. | |
2475 RefPtrWillBeRawPtr<CSSBasicShapeEllipseValue> shape = CSSBasicShapeEllipseVa
lue::create(); | |
2476 | |
2477 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | |
2478 // The call to parseFillPosition below should consume all of the | |
2479 // arguments except the first three. Thus, an index greater than two | |
2480 // indicates an invalid production. | |
2481 if (args->currentIndex() > 2) | |
2482 return nullptr; | |
2483 | |
2484 if (args->currentIndex() < 2 && argument->id != CSSValueAt) { | |
2485 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | |
2486 if (!shape->radiusX()) | |
2487 shape->setRadiusX(radius); | |
2488 else | |
2489 shape->setRadiusY(radius); | |
2490 continue; | |
2491 } | |
2492 | |
2493 return nullptr; | |
2494 } | |
2495 | |
2496 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) | |
2497 return nullptr; | |
2498 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | |
2499 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | |
2500 parseFillPosition(args, centerX, centerY); | |
2501 if (!centerX || !centerY || args->current()) | |
2502 return nullptr; | |
2503 | |
2504 shape->setCenterX(centerX); | |
2505 shape->setCenterY(centerY); | |
2506 } | |
2507 | |
2508 return shape.release(); | |
2509 } | |
2510 | |
2511 PassRefPtrWillBeRawPtr<CSSBasicShapePolygonValue> CSSPropertyParser::parseBasicS
hapePolygon(CSSParserValueList* args) | |
2512 { | |
2513 ASSERT(args); | |
2514 | |
2515 unsigned size = args->size(); | |
2516 if (!size) | |
2517 return nullptr; | |
2518 | |
2519 RefPtrWillBeRawPtr<CSSBasicShapePolygonValue> shape = CSSBasicShapePolygonVa
lue::create(); | |
2520 | |
2521 CSSParserValue* argument = args->current(); | |
2522 if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) { | |
2523 shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE
_NONZERO); | |
2524 args->next(); | |
2525 | |
2526 if (!consumeComma(args)) | |
2527 return nullptr; | |
2528 | |
2529 size -= 2; | |
2530 } | |
2531 | |
2532 // <length> <length>, ... <length> <length> -> each pair has 3 elements exce
pt the last one | |
2533 if (!size || (size % 3) - 2) | |
2534 return nullptr; | |
2535 | |
2536 while (true) { | |
2537 CSSParserValue* argumentX = args->current(); | |
2538 if (!argumentX || !validUnit(argumentX, FLength | FPercent)) | |
2539 return nullptr; | |
2540 RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericVa
lue(argumentX); | |
2541 | |
2542 CSSParserValue* argumentY = args->next(); | |
2543 if (!argumentY || !validUnit(argumentY, FLength | FPercent)) | |
2544 return nullptr; | |
2545 RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericVa
lue(argumentY); | |
2546 | |
2547 shape->appendPoint(xLength.release(), yLength.release()); | |
2548 | |
2549 if (!args->next()) | |
2550 break; | |
2551 if (!consumeComma(args)) | |
2552 return nullptr; | |
2553 } | |
2554 | |
2555 return shape.release(); | |
2556 } | |
2557 | |
2558 static bool isBoxValue(CSSValueID valueId) | |
2559 { | |
2560 switch (valueId) { | |
2561 case CSSValueContentBox: | |
2562 case CSSValuePaddingBox: | |
2563 case CSSValueBorderBox: | |
2564 case CSSValueMarginBox: | |
2565 return true; | |
2566 default: | |
2567 break; | |
2568 } | |
2569 | |
2570 return false; | |
2571 } | |
2572 | |
2573 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper
tyID propId) | |
2574 { | |
2575 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; | |
2576 if (parseFillImage(m_valueList, imageValue)) { | |
2577 m_valueList->next(); | |
2578 return imageValue.release(); | |
2579 } | |
2580 | |
2581 return parseBasicShapeAndOrBox(); | |
2582 } | |
2583 | |
2584 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() | |
2585 { | |
2586 CSSParserValue* value = m_valueList->current(); | |
2587 | |
2588 bool shapeFound = false; | |
2589 bool boxFound = false; | |
2590 CSSValueID valueId; | |
2591 | |
2592 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | |
2593 for (unsigned i = 0; i < 2; ++i) { | |
2594 if (!value) | |
2595 break; | |
2596 valueId = value->id; | |
2597 if (value->m_unit == CSSParserValue::Function && !shapeFound) { | |
2598 // parseBasicShape already asks for the next value list item. | |
2599 RefPtrWillBeRawPtr<CSSValue> shapeValue = parseBasicShape(); | |
2600 if (!shapeValue) | |
2601 return nullptr; | |
2602 list->append(shapeValue.release()); | |
2603 shapeFound = true; | |
2604 } else if (isBoxValue(valueId) && !boxFound) { | |
2605 list->append(parseValidPrimitive(valueId, value)); | |
2606 boxFound = true; | |
2607 m_valueList->next(); | |
2608 } else { | |
2609 return nullptr; | |
2610 } | |
2611 | |
2612 value = m_valueList->current(); | |
2613 } | |
2614 | |
2615 if (m_valueList->current()) | |
2616 return nullptr; | |
2617 return list.release(); | |
2618 } | |
2619 | |
2620 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShape() | |
2621 { | |
2622 CSSParserValue* value = m_valueList->current(); | |
2623 ASSERT(value->m_unit == CSSParserValue::Function); | |
2624 CSSParserValueList* args = value->function->args.get(); | |
2625 | |
2626 if (!args) | |
2627 return nullptr; | |
2628 | |
2629 RefPtrWillBeRawPtr<CSSValue> shape = nullptr; | |
2630 if (value->function->id == CSSValueCircle) | |
2631 shape = parseBasicShapeCircle(args); | |
2632 else if (value->function->id == CSSValueEllipse) | |
2633 shape = parseBasicShapeEllipse(args); | |
2634 else if (value->function->id == CSSValuePolygon) | |
2635 shape = parseBasicShapePolygon(args); | |
2636 else if (value->function->id == CSSValueInset) | |
2637 shape = parseBasicShapeInset(args); | |
2638 | |
2639 if (!shape) | |
2640 return nullptr; | |
2641 | |
2642 m_valueList->next(); | |
2643 | |
2644 return shape.release(); | |
2645 } | |
2646 | |
2647 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 2318 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
2648 { | 2319 { |
2649 bool isPercent; | 2320 bool isPercent; |
2650 double value; | 2321 double value; |
2651 | 2322 |
2652 if (m_parsedCalculation) { | 2323 if (m_parsedCalculation) { |
2653 isPercent = m_parsedCalculation->category() == CalcPercent; | 2324 isPercent = m_parsedCalculation->category() == CalcPercent; |
2654 value = m_parsedCalculation->doubleValue(); | 2325 value = m_parsedCalculation->doubleValue(); |
2655 m_parsedCalculation.release(); | 2326 m_parsedCalculation.release(); |
2656 } else { | 2327 } else { |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3325 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>&
result) | 2996 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>&
result) |
3326 { | 2997 { |
3327 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); | 2998 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); |
3328 } | 2999 } |
3329 | 3000 |
3330 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>&
result) | 3001 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>&
result) |
3331 { | 3002 { |
3332 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); | 3003 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
3333 } | 3004 } |
3334 | 3005 |
3335 bool CSSPropertyParser::parseRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4
], RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4], CSSParserValueList* args, CS
SPropertyID unresolvedProperty) | |
3336 { | |
3337 #if ENABLE(OILPAN) | |
3338 // Unconditionally zero initialize the arrays of raw pointers. | |
3339 memset(radii, 0, 4 * sizeof(radii[0])); | |
3340 memset(radii2, 0, 4 * sizeof(radii2[0])); | |
3341 #endif | |
3342 CSSParserValue* value = args->current(); | |
3343 int i; | |
3344 for (i = 0; i < 4 && value && value->m_unit != CSSParserValue::Operator;++i,
value = args->next()) { | |
3345 if (!validUnit(value, FLength | FPercent | FNonNeg)) | |
3346 return false; | |
3347 | |
3348 radii[i] = createPrimitiveNumericValue(value); | |
3349 } | |
3350 | |
3351 if (!i || (value && value->m_unit == CSSParserValue::Operator && value->iVal
ue != '/')) | |
3352 return false; | |
3353 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to border-radi
us: l1 / l2; | |
3354 if (!value && i == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa
dius) { | |
3355 radii2[0] = radii[1]; | |
3356 radii[1] = nullptr; | |
3357 completeBorderRadii(radii); | |
3358 completeBorderRadii(radii2); | |
3359 return true; | |
3360 } | |
3361 completeBorderRadii(radii); | |
3362 if (value) { | |
3363 value = args->next(); | |
3364 for (i = 0; i < 4 && value && validUnit(value, FLength | FPercent | FNon
Neg); ++i, value = args->next()) | |
3365 radii2[i] = createPrimitiveNumericValue(value); | |
3366 if (!i || value) | |
3367 return false; | |
3368 completeBorderRadii(radii2); | |
3369 } else { | |
3370 for (unsigned i = 0; i < 4; ++i) | |
3371 radii2[i] = radii[i]; | |
3372 } | |
3373 | |
3374 return true; | |
3375 } | |
3376 | |
3377 // This should go away once we drop support for -webkit-gradient | 3006 // This should go away once we drop support for -webkit-gradient |
3378 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) | 3007 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) |
3379 { | 3008 { |
3380 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 3009 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; |
3381 if (a->m_unit == CSSParserValue::Identifier) { | 3010 if (a->m_unit == CSSParserValue::Identifier) { |
3382 if ((a->id == CSSValueLeft && horizontal) | 3011 if ((a->id == CSSValueLeft && horizontal) |
3383 || (a->id == CSSValueTop && !horizontal)) | 3012 || (a->id == CSSValueTop && !horizontal)) |
3384 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType:
:Percentage); | 3013 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType:
:Percentage); |
3385 else if ((a->id == CSSValueRight && horizontal) | 3014 else if ((a->id == CSSValueRight && horizontal) |
3386 || (a->id == CSSValueBottom && !horizontal)) | 3015 || (a->id == CSSValueBottom && !horizontal)) |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4205 ASSERT(!m_parsedCalculation); | 3834 ASSERT(!m_parsedCalculation); |
4206 m_parsedCalculation = CSSCalcValue::create(args, range); | 3835 m_parsedCalculation = CSSCalcValue::create(args, range); |
4207 | 3836 |
4208 if (!m_parsedCalculation) | 3837 if (!m_parsedCalculation) |
4209 return false; | 3838 return false; |
4210 | 3839 |
4211 return true; | 3840 return true; |
4212 } | 3841 } |
4213 | 3842 |
4214 } // namespace blink | 3843 } // namespace blink |
OLD | NEW |