Chromium Code Reviews| 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 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1207 case CSSPropertyGridAutoRows: | 1207 case CSSPropertyGridAutoRows: |
| 1208 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 1208 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 1209 return false; | 1209 return false; |
| 1210 parsedValue = parseGridTrackSize(*m_valueList); | 1210 parsedValue = parseGridTrackSize(*m_valueList); |
| 1211 break; | 1211 break; |
| 1212 | 1212 |
| 1213 case CSSPropertyGridTemplateColumns: | 1213 case CSSPropertyGridTemplateColumns: |
| 1214 case CSSPropertyGridTemplateRows: | 1214 case CSSPropertyGridTemplateRows: |
| 1215 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 1215 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 1216 return false; | 1216 return false; |
| 1217 return parseGridTrackList(propId, important); | 1217 parsedValue = parseGridTrackList(important); |
| 1218 break; | |
| 1218 | 1219 |
| 1219 case CSSPropertyGridColumnEnd: | 1220 case CSSPropertyGridColumnEnd: |
| 1220 case CSSPropertyGridColumnStart: | 1221 case CSSPropertyGridColumnStart: |
| 1221 case CSSPropertyGridRowEnd: | 1222 case CSSPropertyGridRowEnd: |
| 1222 case CSSPropertyGridRowStart: | 1223 case CSSPropertyGridRowStart: |
| 1223 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 1224 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 1224 return false; | 1225 return false; |
| 1225 parsedValue = parseGridPosition(); | 1226 parsedValue = parseGridPosition(); |
| 1226 break; | 1227 break; |
| 1227 | 1228 |
| 1228 case CSSPropertyGridColumn: | 1229 case CSSPropertyGridColumn: |
| 1229 case CSSPropertyGridRow: | 1230 case CSSPropertyGridRow: |
| 1230 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 1231 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 1231 return false; | 1232 return false; |
| 1232 return parseGridItemPositionShorthand(propId, important); | 1233 return parseGridItemPositionShorthand(propId, important); |
| 1233 | 1234 |
| 1234 case CSSPropertyGridArea: | 1235 case CSSPropertyGridArea: |
| 1235 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 1236 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 1236 return false; | 1237 return false; |
| 1237 return parseGridAreaShorthand(important); | 1238 return parseGridAreaShorthand(important); |
| 1238 | 1239 |
| 1239 case CSSPropertyGridTemplateAreas: | 1240 case CSSPropertyGridTemplateAreas: |
| 1240 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 1241 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 1241 return false; | 1242 return false; |
| 1242 parsedValue = parseGridTemplateAreas(); | 1243 parsedValue = parseGridTemplateAreas(); |
| 1243 break; | 1244 break; |
| 1244 | 1245 |
| 1246 case CSSPropertyGridTemplate: | |
| 1247 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | |
| 1248 return false; | |
| 1249 return parseGridTemplateShorthand(important); | |
| 1250 | |
| 1245 case CSSPropertyWebkitMarginCollapse: { | 1251 case CSSPropertyWebkitMarginCollapse: { |
| 1246 if (num == 1) { | 1252 if (num == 1) { |
| 1247 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); | 1253 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); |
| 1248 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) | 1254 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) |
| 1249 return false; | 1255 return false; |
| 1250 CSSValue* value = m_parsedProperties.last().value(); | 1256 CSSValue* value = m_parsedProperties.last().value(); |
| 1251 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); | 1257 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); |
| 1252 return true; | 1258 return true; |
| 1253 } | 1259 } |
| 1254 else if (num == 2) { | 1260 else if (num == 2) { |
| (...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3436 return false; | 3442 return false; |
| 3437 } else { | 3443 } else { |
| 3438 endValue = gridMissingGridPositionValue(startValue.get()); | 3444 endValue = gridMissingGridPositionValue(startValue.get()); |
| 3439 } | 3445 } |
| 3440 | 3446 |
| 3441 addProperty(shorthand.properties()[0], startValue, important); | 3447 addProperty(shorthand.properties()[0], startValue, important); |
| 3442 addProperty(shorthand.properties()[1], endValue, important); | 3448 addProperty(shorthand.properties()[1], endValue, important); |
| 3443 return true; | 3449 return true; |
| 3444 } | 3450 } |
| 3445 | 3451 |
| 3452 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS Value> templateColumns, bool important) | |
| 3453 { | |
| 3454 NamedGridAreaMap gridAreaMap; | |
| 3455 size_t rowCount = 0; | |
| 3456 size_t columnCount = 0; | |
| 3457 bool trailingIdentWasAdded = false; | |
| 3458 RefPtr<CSSValueList> templateRows = CSSValueList::createSpaceSeparated(); | |
| 3459 | |
| 3460 // At least template-areas strings must be defined. | |
| 3461 if (!m_valueList->current()) | |
| 3462 return false; | |
| 3463 | |
| 3464 while (m_valueList->current()) { | |
| 3465 // Handle leading <custom-ident>*. | |
| 3466 if (m_valueList->current()->unit == CSSParserValue::ValueList) { | |
| 3467 if (trailingIdentWasAdded) { | |
| 3468 // A row's trailing ident must be concatenated with the next row 's leading one. | |
| 3469 parseGridLineNames(*m_valueList, *templateRows, static_cast<CSSG ridLineNamesValue*>(templateRows->item(templateRows->length() - 1))); | |
| 3470 } else { | |
| 3471 parseGridLineNames(*m_valueList, *templateRows); | |
| 3472 } | |
| 3473 } | |
| 3474 | |
| 3475 // Handle a template-area's row. | |
| 3476 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | |
| 3477 return false; | |
| 3478 ++rowCount; | |
| 3479 | |
| 3480 // Handle template-rows's track-size. | |
| 3481 if (m_valueList->current() && m_valueList->current()->unit != CSSParserV alue::ValueList && m_valueList->current()->unit != CSSPrimitiveValue::CSS_STRING ) { | |
| 3482 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); | |
| 3483 if (!value) | |
| 3484 return false; | |
| 3485 templateRows->append(value); | |
| 3486 } else { | |
| 3487 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to)); | |
| 3488 } | |
| 3489 | |
| 3490 // This will handle the trailing/leading <custom-ident>* in the grammar. | |
| 3491 trailingIdentWasAdded = false; | |
| 3492 if (m_valueList->current() && m_valueList->current()->unit == CSSParserV alue::ValueList) { | |
| 3493 parseGridLineNames(*m_valueList, *templateRows); | |
| 3494 trailingIdentWasAdded = true; | |
| 3495 } | |
| 3496 } | |
| 3497 | |
| 3498 // [<track-list> /]? | |
| 3499 if (templateColumns) | |
| 3500 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); | |
| 3501 else | |
| 3502 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important); | |
| 3503 | |
| 3504 // [<line-names>? <string> [<track-size> <line-names>]? ]+ | |
| 3505 RefPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::create(gridAreaM ap, rowCount, columnCount); | |
| 3506 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important ); | |
| 3507 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); | |
| 3508 | |
| 3509 | |
| 3510 return true; | |
| 3511 } | |
| 3512 | |
| 3513 | |
| 3514 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) | |
| 3515 { | |
| 3516 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
| 3517 | |
| 3518 ShorthandScope scope(this, CSSPropertyGridTemplate); | |
| 3519 ASSERT(gridTemplateShorthand().length() == 3); | |
| 3520 | |
| 3521 // At least "none" must be defined. | |
| 3522 if (!m_valueList->current()) | |
| 3523 return false; | |
| 3524 | |
| 3525 RefPtr<CSSValue> columnsValue; | |
| 3526 unsigned index = 0; | |
| 3527 bool firstValueIsNone = false; | |
| 3528 | |
| 3529 // 1- 'none' case. | |
|
Julien - ping for review
2014/03/31 17:56:29
We should probably amend this as it's not just the
jfernandez
2014/03/31 23:02:14
Actually, the 'none' / <grid-template-rows> case i
| |
| 3530 if ((firstValueIsNone = m_valueList->current()->id == CSSValueNone)) { | |
|
Julien - ping for review
2014/03/31 17:56:29
I would put the |firstValueIsNone| override outsi
jfernandez
2014/03/31 23:02:14
Done.
| |
| 3531 if (!m_valueList->next()) { | |
| 3532 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIde ntifierValue(CSSValueNone), important); | |
| 3533 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdenti fierValue(CSSValueNone), important); | |
| 3534 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important); | |
| 3535 return true; | |
| 3536 } | |
| 3537 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); | |
| 3538 } else { | |
| 3539 columnsValue = parseGridTrackList(important); | |
| 3540 } | |
| 3541 | |
| 3542 | |
| 3543 // 2- <grid-template-columns> / <grid-template-columns> syntax. | |
| 3544 if (columnsValue) { | |
| 3545 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next())) | |
| 3546 return false; | |
| 3547 index = m_valueList->currentIndex(); | |
| 3548 if (RefPtr<CSSValue> rowsValue = parseGridTrackList(important)) { | |
| 3549 if (m_valueList->current()) | |
| 3550 return false; | |
| 3551 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important) ; | |
| 3552 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); | |
| 3553 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important); | |
| 3554 return true; | |
| 3555 } | |
| 3556 } | |
| 3557 | |
| 3558 | |
| 3559 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax. | |
| 3560 // The template-columns <track-list> can't be 'none'. | |
| 3561 if (firstValueIsNone) | |
| 3562 return false; | |
| 3563 // It requires to rewind parsing due to previous syntax failures. | |
| 3564 m_valueList->setCurrentIndex(index); | |
| 3565 return parseGridTemplateRowsAndAreas(columnsValue, important); | |
| 3566 } | |
| 3567 | |
| 3446 bool CSSPropertyParser::parseGridAreaShorthand(bool important) | 3568 bool CSSPropertyParser::parseGridAreaShorthand(bool important) |
| 3447 { | 3569 { |
| 3448 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3570 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3449 | 3571 |
| 3450 ShorthandScope scope(this, CSSPropertyGridArea); | 3572 ShorthandScope scope(this, CSSPropertyGridArea); |
| 3451 const StylePropertyShorthand& shorthand = gridAreaShorthand(); | 3573 const StylePropertyShorthand& shorthand = gridAreaShorthand(); |
| 3452 ASSERT_UNUSED(shorthand, shorthand.length() == 4); | 3574 ASSERT_UNUSED(shorthand, shorthand.length() == 4); |
| 3453 | 3575 |
| 3454 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); | 3576 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); |
| 3455 if (!rowStartValue) | 3577 if (!rowStartValue) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3491 if (!isForwardSlashOperator(m_valueList->current())) | 3613 if (!isForwardSlashOperator(m_valueList->current())) |
| 3492 return false; | 3614 return false; |
| 3493 | 3615 |
| 3494 if (!m_valueList->next()) | 3616 if (!m_valueList->next()) |
| 3495 return false; | 3617 return false; |
| 3496 | 3618 |
| 3497 property = parseGridPosition(); | 3619 property = parseGridPosition(); |
| 3498 return true; | 3620 return true; |
| 3499 } | 3621 } |
| 3500 | 3622 |
| 3501 void CSSPropertyParser::parseGridLineNames(CSSParserValueList* parserValueList, CSSValueList& valueList) | 3623 void CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal ueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames) |
| 3502 { | 3624 { |
| 3503 ASSERT(parserValueList->current() && parserValueList->current()->unit == CSS ParserValue::ValueList); | 3625 ASSERT(inputList.current() && inputList.current()->unit == CSSParserValue::V alueList); |
| 3504 | 3626 |
| 3505 CSSParserValueList* identList = parserValueList->current()->valueList; | 3627 CSSParserValueList* identList = inputList.current()->valueList; |
| 3506 if (!identList->size()) { | 3628 if (!identList->size()) { |
| 3507 parserValueList->next(); | 3629 inputList.next(); |
| 3508 return; | 3630 return; |
| 3509 } | 3631 } |
| 3510 | 3632 |
| 3511 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue: :create(); | 3633 // Need to ensure the identList is at the heading index, since the parserLis t might have been rewound. |
| 3634 identList->setCurrentIndex(0); | |
| 3635 | |
| 3636 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = previousNamedAreaTrail ingLineNames ? previousNamedAreaTrailingLineNames : CSSGridLineNamesValue::creat e(); | |
| 3512 while (CSSParserValue* identValue = identList->current()) { | 3637 while (CSSParserValue* identValue = identList->current()) { |
| 3513 ASSERT(identValue->unit == CSSPrimitiveValue::CSS_IDENT); | 3638 ASSERT(identValue->unit == CSSPrimitiveValue::CSS_IDENT); |
| 3514 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveStringVa lue(identValue); | 3639 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveStringVa lue(identValue); |
| 3515 lineNames->append(lineName.release()); | 3640 lineNames->append(lineName.release()); |
| 3516 identList->next(); | 3641 identList->next(); |
| 3517 } | 3642 } |
| 3518 valueList.append(lineNames.release()); | 3643 if (!previousNamedAreaTrailingLineNames) |
| 3644 valueList.append(lineNames.release()); | |
| 3519 | 3645 |
| 3520 parserValueList->next(); | 3646 inputList.next(); |
| 3521 } | 3647 } |
| 3522 | 3648 |
| 3523 bool CSSPropertyParser::parseGridTrackList(CSSPropertyID propId, bool important) | 3649 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList(bool impo rtant) |
| 3524 { | 3650 { |
| 3525 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3651 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3526 | 3652 |
| 3527 CSSParserValue* value = m_valueList->current(); | 3653 CSSParserValue* value = m_valueList->current(); |
| 3528 if (value->id == CSSValueNone) { | 3654 if (value->id == CSSValueNone) { |
| 3529 if (m_valueList->next()) | 3655 m_valueList->next(); |
| 3530 return false; | 3656 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 3531 | |
| 3532 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant); | |
| 3533 return true; | |
| 3534 } | 3657 } |
| 3535 | 3658 |
| 3536 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); | 3659 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); |
| 3537 // Handle leading <ident>*. | 3660 // Handle leading <ident>*. |
| 3538 value = m_valueList->current(); | 3661 value = m_valueList->current(); |
| 3539 if (value && value->unit == CSSParserValue::ValueList) | 3662 if (value && value->unit == CSSParserValue::ValueList) |
| 3540 parseGridLineNames(m_valueList.get(), *values); | 3663 parseGridLineNames(*m_valueList, *values); |
| 3541 | 3664 |
| 3542 bool seenTrackSizeOrRepeatFunction = false; | 3665 bool seenTrackSizeOrRepeatFunction = false; |
| 3543 while (CSSParserValue* currentValue = m_valueList->current()) { | 3666 while (CSSParserValue* currentValue = m_valueList->current()) { |
| 3667 if (isForwardSlashOperator(currentValue)) | |
| 3668 break; | |
| 3544 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) { | 3669 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) { |
| 3545 if (!parseGridTrackRepeatFunction(*values)) | 3670 if (!parseGridTrackRepeatFunction(*values)) |
| 3546 return false; | 3671 return nullptr; |
| 3547 seenTrackSizeOrRepeatFunction = true; | 3672 seenTrackSizeOrRepeatFunction = true; |
| 3548 } else { | 3673 } else { |
| 3549 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); | 3674 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); |
| 3550 if (!value) | 3675 if (!value) |
| 3551 return false; | 3676 return nullptr; |
| 3552 values->append(value); | 3677 values->append(value); |
| 3553 seenTrackSizeOrRepeatFunction = true; | 3678 seenTrackSizeOrRepeatFunction = true; |
| 3554 } | 3679 } |
| 3555 // This will handle the trailing <ident>* in the grammar. | 3680 // This will handle the trailing <ident>* in the grammar. |
| 3556 value = m_valueList->current(); | 3681 value = m_valueList->current(); |
| 3557 if (value && value->unit == CSSParserValue::ValueList) | 3682 if (value && value->unit == CSSParserValue::ValueList) |
| 3558 parseGridLineNames(m_valueList.get(), *values); | 3683 parseGridLineNames(*m_valueList, *values); |
| 3559 } | 3684 } |
| 3560 | 3685 |
| 3561 // We should have found a <track-size> or else it is not a valid <track-list > | 3686 // We should have found a <track-size> or else it is not a valid <track-list > |
| 3562 if (!seenTrackSizeOrRepeatFunction) | 3687 if (!seenTrackSizeOrRepeatFunction) |
| 3563 return false; | 3688 return nullptr; |
| 3564 | 3689 |
| 3565 addProperty(propId, values.release(), important); | 3690 return values; |
| 3566 return true; | |
| 3567 } | 3691 } |
| 3568 | 3692 |
| 3569 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list) | 3693 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list) |
| 3570 { | 3694 { |
| 3571 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ; | 3695 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ; |
| 3572 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1))) | 3696 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1))) |
| 3573 return false; | 3697 return false; |
| 3574 | 3698 |
| 3575 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); | 3699 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); |
| 3576 size_t repetitions = arguments->valueAt(0)->fValue; | 3700 size_t repetitions = arguments->valueAt(0)->fValue; |
| 3577 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated(); | 3701 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated(); |
| 3578 arguments->next(); // Skip the repetition count. | 3702 arguments->next(); // Skip the repetition count. |
| 3579 arguments->next(); // Skip the comma. | 3703 arguments->next(); // Skip the comma. |
| 3580 | 3704 |
| 3581 // Handle leading <ident>*. | 3705 // Handle leading <ident>*. |
| 3582 CSSParserValue* currentValue = arguments->current(); | 3706 CSSParserValue* currentValue = arguments->current(); |
| 3583 if (currentValue && currentValue->unit == CSSParserValue::ValueList) | 3707 if (currentValue && currentValue->unit == CSSParserValue::ValueList) |
| 3584 parseGridLineNames(arguments, *repeatedValues); | 3708 parseGridLineNames(*arguments, *repeatedValues); |
| 3585 | 3709 |
| 3586 while (arguments->current()) { | 3710 while (arguments->current()) { |
| 3587 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); | 3711 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); |
| 3588 if (!trackSize) | 3712 if (!trackSize) |
| 3589 return false; | 3713 return false; |
| 3590 | 3714 |
| 3591 repeatedValues->append(trackSize); | 3715 repeatedValues->append(trackSize); |
| 3592 | 3716 |
| 3593 // This takes care of any trailing <ident>* in the grammar. | 3717 // This takes care of any trailing <ident>* in the grammar. |
| 3594 currentValue = arguments->current(); | 3718 currentValue = arguments->current(); |
| 3595 if (currentValue && currentValue->unit == CSSParserValue::ValueList) | 3719 if (currentValue && currentValue->unit == CSSParserValue::ValueList) |
| 3596 parseGridLineNames(arguments, *repeatedValues); | 3720 parseGridLineNames(*arguments, *repeatedValues); |
| 3597 } | 3721 } |
| 3598 | 3722 |
| 3599 for (size_t i = 0; i < repetitions; ++i) { | 3723 for (size_t i = 0; i < repetitions; ++i) { |
| 3600 for (size_t j = 0; j < repeatedValues->length(); ++j) | 3724 for (size_t j = 0; j < repeatedValues->length(); ++j) |
| 3601 list.append(repeatedValues->itemWithoutBoundsCheck(j)); | 3725 list.append(repeatedValues->itemWithoutBoundsCheck(j)); |
| 3602 } | 3726 } |
| 3603 | 3727 |
| 3604 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. | 3728 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. |
| 3605 m_valueList->next(); | 3729 m_valueList->next(); |
| 3606 return true; | 3730 return true; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3654 | 3778 |
| 3655 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); | 3779 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); |
| 3656 } | 3780 } |
| 3657 | 3781 |
| 3658 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) | 3782 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) |
| 3659 return nullptr; | 3783 return nullptr; |
| 3660 | 3784 |
| 3661 return createPrimitiveNumericValue(currentValue); | 3785 return createPrimitiveNumericValue(currentValue); |
| 3662 } | 3786 } |
| 3663 | 3787 |
| 3788 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount) | |
| 3789 { | |
| 3790 CSSParserValue* currentValue = m_valueList->current(); | |
| 3791 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_STRING) | |
| 3792 return false; | |
| 3793 | |
| 3794 String gridRowNames = currentValue->string; | |
| 3795 if (!gridRowNames.length()) | |
| 3796 return false; | |
| 3797 | |
| 3798 Vector<String> columnNames; | |
| 3799 gridRowNames.split(' ', columnNames); | |
| 3800 | |
| 3801 if (!columnCount) { | |
| 3802 columnCount = columnNames.size(); | |
| 3803 ASSERT(columnCount); | |
| 3804 } else if (columnCount != columnNames.size()) { | |
| 3805 // The declaration is invalid is all the rows don't have the number of c olumns. | |
| 3806 return false; | |
| 3807 } | |
| 3808 | |
| 3809 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { | |
| 3810 const String& gridAreaName = columnNames[currentCol]; | |
| 3811 | |
| 3812 // Unamed areas are always valid (we consider them to be 1x1). | |
| 3813 if (gridAreaName == ".") | |
| 3814 continue; | |
| 3815 | |
| 3816 // We handle several grid areas with the same name at once to simplify t he validation code. | |
| 3817 size_t lookAheadCol; | |
| 3818 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++look AheadCol) { | |
| 3819 if (columnNames[lookAheadCol + 1] != gridAreaName) | |
| 3820 break; | |
| 3821 } | |
| 3822 | |
| 3823 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaName); | |
| 3824 if (gridAreaIt == gridAreaMap.end()) { | |
| 3825 gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount, rowC ount), GridSpan(currentCol, lookAheadCol))); | |
| 3826 } else { | |
| 3827 GridCoordinate& gridCoordinate = gridAreaIt->value; | |
| 3828 | |
| 3829 // The following checks test that the grid area is a single filled-i n rectangle. | |
| 3830 // 1. The new row is adjacent to the previously parsed row. | |
| 3831 if (rowCount != gridCoordinate.rows.initialPositionIndex + 1) | |
| 3832 return false; | |
| 3833 | |
| 3834 // 2. The new area starts at the same position as the previously par sed area. | |
| 3835 if (currentCol != gridCoordinate.columns.initialPositionIndex) | |
| 3836 return false; | |
| 3837 | |
| 3838 // 3. The new area ends at the same position as the previously parse d area. | |
| 3839 if (lookAheadCol != gridCoordinate.columns.finalPositionIndex) | |
| 3840 return false; | |
| 3841 | |
| 3842 ++gridCoordinate.rows.finalPositionIndex; | |
| 3843 } | |
| 3844 currentCol = lookAheadCol; | |
| 3845 } | |
| 3846 | |
| 3847 m_valueList->next(); | |
| 3848 return true; | |
| 3849 } | |
| 3850 | |
| 3664 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() | 3851 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() |
| 3665 { | 3852 { |
| 3666 NamedGridAreaMap gridAreaMap; | 3853 NamedGridAreaMap gridAreaMap; |
| 3667 size_t rowCount = 0; | 3854 size_t rowCount = 0; |
| 3668 size_t columnCount = 0; | 3855 size_t columnCount = 0; |
| 3669 | 3856 |
| 3670 while (CSSParserValue* currentValue = m_valueList->current()) { | 3857 while (m_valueList->current()) { |
| 3671 if (currentValue->unit != CSSPrimitiveValue::CSS_STRING) | 3858 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) |
| 3672 return nullptr; | 3859 return nullptr; |
| 3673 | |
| 3674 String gridRowNames = currentValue->string; | |
| 3675 if (!gridRowNames.length()) | |
| 3676 return nullptr; | |
| 3677 | |
| 3678 Vector<String> columnNames; | |
| 3679 gridRowNames.split(' ', columnNames); | |
| 3680 | |
| 3681 if (!columnCount) { | |
| 3682 columnCount = columnNames.size(); | |
| 3683 ASSERT(columnCount); | |
| 3684 } else if (columnCount != columnNames.size()) { | |
| 3685 // The declaration is invalid is all the rows don't have the number of columns. | |
| 3686 return nullptr; | |
| 3687 } | |
| 3688 | |
| 3689 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { | |
| 3690 const String& gridAreaName = columnNames[currentCol]; | |
| 3691 | |
| 3692 // Unamed areas are always valid (we consider them to be 1x1). | |
| 3693 if (gridAreaName == ".") | |
| 3694 continue; | |
| 3695 | |
| 3696 // We handle several grid areas with the same name at once to simpli fy the validation code. | |
| 3697 size_t lookAheadCol; | |
| 3698 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++ lookAheadCol) { | |
| 3699 if (columnNames[lookAheadCol + 1] != gridAreaName) | |
| 3700 break; | |
| 3701 } | |
| 3702 | |
| 3703 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaNam e); | |
| 3704 if (gridAreaIt == gridAreaMap.end()) { | |
| 3705 gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount, rowCount), GridSpan(currentCol, lookAheadCol))); | |
| 3706 } else { | |
| 3707 GridCoordinate& gridCoordinate = gridAreaIt->value; | |
| 3708 | |
| 3709 // The following checks test that the grid area is a single fill ed-in rectangle. | |
| 3710 // 1. The new row is adjacent to the previously parsed row. | |
| 3711 if (rowCount != gridCoordinate.rows.initialPositionIndex + 1) | |
| 3712 return nullptr; | |
| 3713 | |
| 3714 // 2. The new area starts at the same position as the previously parsed area. | |
| 3715 if (currentCol != gridCoordinate.columns.initialPositionIndex) | |
| 3716 return nullptr; | |
| 3717 | |
| 3718 // 3. The new area ends at the same position as the previously p arsed area. | |
| 3719 if (lookAheadCol != gridCoordinate.columns.finalPositionIndex) | |
| 3720 return nullptr; | |
| 3721 | |
| 3722 ++gridCoordinate.rows.finalPositionIndex; | |
| 3723 } | |
| 3724 currentCol = lookAheadCol; | |
| 3725 } | |
| 3726 | |
| 3727 ++rowCount; | 3860 ++rowCount; |
| 3728 m_valueList->next(); | |
| 3729 } | 3861 } |
| 3730 | 3862 |
| 3731 if (!rowCount || !columnCount) | 3863 if (!rowCount || !columnCount) |
| 3732 return nullptr; | 3864 return nullptr; |
| 3733 | 3865 |
| 3734 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ; | 3866 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ; |
| 3735 } | 3867 } |
| 3736 | 3868 |
| 3737 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse rValueList* args, bool counters) | 3869 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse rValueList* args, bool counters) |
| 3738 { | 3870 { |
| (...skipping 4714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8453 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); | 8585 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
| 8454 if (!seenStroke) | 8586 if (!seenStroke) |
| 8455 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); | 8587 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); |
| 8456 if (!seenMarkers) | 8588 if (!seenMarkers) |
| 8457 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); | 8589 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); |
| 8458 | 8590 |
| 8459 return parsedValues.release(); | 8591 return parsedValues.release(); |
| 8460 } | 8592 } |
| 8461 | 8593 |
| 8462 } // namespace WebCore | 8594 } // namespace WebCore |
| OLD | NEW |