Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/core/css/CSSParser-in.cpp

Issue 22215002: Allow grid positions to be named grid areas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSParser.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 case CSSPropertyGridColumnStart: 2444 case CSSPropertyGridColumnStart:
2445 case CSSPropertyGridRowEnd: 2445 case CSSPropertyGridRowEnd:
2446 case CSSPropertyGridRowStart: 2446 case CSSPropertyGridRowStart:
2447 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 2447 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
2448 return false; 2448 return false;
2449 parsedValue = parseGridPosition(); 2449 parsedValue = parseGridPosition();
2450 break; 2450 break;
2451 2451
2452 case CSSPropertyGridColumn: 2452 case CSSPropertyGridColumn:
2453 case CSSPropertyGridRow: 2453 case CSSPropertyGridRow:
2454 case CSSPropertyGridArea:
2455 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 2454 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
2456 return false; 2455 return false;
2457 return parseGridItemPositionShorthand(propId, important); 2456 return parseGridItemPositionShorthand(propId, important);
2458 2457
2458 case CSSPropertyGridArea:
2459 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
2460 return false;
2461 return parseGridAreaShorthand(important);
2462
2459 case CSSPropertyGridTemplate: 2463 case CSSPropertyGridTemplate:
2460 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 2464 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
2461 return false; 2465 return false;
2462 parsedValue = parseGridTemplate(); 2466 parsedValue = parseGridTemplate();
2463 break; 2467 break;
2464 2468
2465 case CSSPropertyWebkitMarginCollapse: { 2469 case CSSPropertyWebkitMarginCollapse: {
2466 if (num == 1) { 2470 if (num == 1) {
2467 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 2471 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
2468 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) 2472 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant))
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after
4568 PassRefPtr<CSSValue> CSSParser::parseGridPosition() 4572 PassRefPtr<CSSValue> CSSParser::parseGridPosition()
4569 { 4573 {
4570 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 4574 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4571 4575
4572 CSSParserValue* value = m_valueList->current(); 4576 CSSParserValue* value = m_valueList->current();
4573 if (value->id == CSSValueAuto) { 4577 if (value->id == CSSValueAuto) {
4574 m_valueList->next(); 4578 m_valueList->next();
4575 return cssValuePool().createIdentifierValue(CSSValueAuto); 4579 return cssValuePool().createIdentifierValue(CSSValueAuto);
4576 } 4580 }
4577 4581
4582 if (value->id != CSSValueSpan && value->unit == CSSPrimitiveValue::CSS_IDENT ) {
4583 m_valueList->next();
4584 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_ STRING);
4585 }
4586
4578 RefPtr<CSSPrimitiveValue> numericValue; 4587 RefPtr<CSSPrimitiveValue> numericValue;
4579 RefPtr<CSSPrimitiveValue> gridLineName; 4588 RefPtr<CSSPrimitiveValue> gridLineName;
4580 bool hasSeenSpanKeyword = false; 4589 bool hasSeenSpanKeyword = false;
4581 4590
4582 if (parseIntegerOrStringFromGridPosition(numericValue, gridLineName)) { 4591 if (parseIntegerOrStringFromGridPosition(numericValue, gridLineName)) {
4583 value = m_valueList->current(); 4592 value = m_valueList->current();
4584 if (value && value->id == CSSValueSpan) { 4593 if (value && value->id == CSSValueSpan) {
4585 hasSeenSpanKeyword = true; 4594 hasSeenSpanKeyword = true;
4586 m_valueList->next(); 4595 m_valueList->next();
4587 } 4596 }
(...skipping 20 matching lines...) Expand all
4608 if (hasSeenSpanKeyword) 4617 if (hasSeenSpanKeyword)
4609 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); 4618 values->append(cssValuePool().createIdentifierValue(CSSValueSpan));
4610 if (numericValue) 4619 if (numericValue)
4611 values->append(numericValue.release()); 4620 values->append(numericValue.release());
4612 if (gridLineName) 4621 if (gridLineName)
4613 values->append(gridLineName.release()); 4622 values->append(gridLineName.release());
4614 ASSERT(values->length()); 4623 ASSERT(values->length());
4615 return values.release(); 4624 return values.release();
4616 } 4625 }
4617 4626
4627 static PassRefPtr<CSSValue> gridMissingGridPositionValue(CSSValue* value)
4628 {
4629 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isString())
4630 return value;
4631
4632 return cssValuePool().createIdentifierValue(CSSValueAuto);
4633 }
4634
4618 bool CSSParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId, bool i mportant) 4635 bool CSSParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId, bool i mportant)
4619 { 4636 {
4620 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4621
4622 ShorthandScope scope(this, shorthandId); 4637 ShorthandScope scope(this, shorthandId);
4623 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); 4638 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId);
4624 if (!parseValue(shorthand.properties()[0], important)) 4639 ASSERT(shorthand.length() == 2);
4640
4641 RefPtr<CSSValue> startValue = parseGridPosition();
4642 if (!startValue)
4625 return false; 4643 return false;
4626 4644
4627 size_t index = 1; 4645 RefPtr<CSSValue> endValue;
4628 for (; index < shorthand.length(); ++index) { 4646 if (m_valueList->current()) {
4629 if (!m_valueList->current())
4630 break;
4631
4632 if (!isForwardSlashOperator(m_valueList->current())) 4647 if (!isForwardSlashOperator(m_valueList->current()))
4633 return false; 4648 return false;
4634 4649
4635 if (!m_valueList->next()) 4650 if (!m_valueList->next())
4636 return false; 4651 return false;
4637 4652
4638 if (!parseValue(shorthand.properties()[index], important)) 4653 endValue = parseGridPosition();
4654 if (!endValue || m_valueList->current())
4639 return false; 4655 return false;
4656 } else {
4657 endValue = gridMissingGridPositionValue(startValue.get());
4640 } 4658 }
4641 4659
4642 // Only one value out of the 2 positions was specified, the opposite value s hould be set to 'auto'. 4660 addProperty(shorthand.properties()[0], startValue, important);
4643 // FIXME: If the first property was <ident>, the opposite value should be th e same <ident>. 4661 addProperty(shorthand.properties()[1], endValue, important);
4644 for (; index < shorthand.length(); ++index)
4645 addProperty(shorthand.properties()[index], cssValuePool().createIdentifi erValue(CSSValueAuto), important);
4646
4647 return true; 4662 return true;
4648 } 4663 }
4649 4664
4665 bool CSSParser::parseGridAreaShorthand(bool important)
4666 {
4667 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4668
4669 ShorthandScope scope(this, CSSPropertyGridArea);
4670 const StylePropertyShorthand& shorthand = gridAreaShorthand();
4671 ASSERT(shorthand.length() == 4);
4672
4673 RefPtr<CSSValue> rowStartValue = parseGridPosition();
4674 if (!rowStartValue)
4675 return false;
4676
4677 RefPtr<CSSValue> columnStartValue;
4678 if (!parseSingleGridAreaLonghand(columnStartValue))
4679 return false;
4680
4681 RefPtr<CSSValue> rowEndValue;
4682 if (!parseSingleGridAreaLonghand(rowEndValue))
4683 return false;
4684
4685 RefPtr<CSSValue> columnEndValue;
4686 if (!parseSingleGridAreaLonghand(columnEndValue))
4687 return false;
4688
4689 if (!columnStartValue)
4690 columnStartValue = gridMissingGridPositionValue(rowStartValue.get());
4691
4692 if (!rowEndValue)
4693 rowEndValue = gridMissingGridPositionValue(rowStartValue.get());
4694
4695 if (!columnEndValue)
4696 columnEndValue = gridMissingGridPositionValue(columnStartValue.get());
4697
4698 addProperty(CSSPropertyGridRowStart, rowStartValue, important);
4699 addProperty(CSSPropertyGridColumnStart, columnStartValue, important);
4700 addProperty(CSSPropertyGridRowEnd, rowEndValue, important);
4701 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important);
4702 return true;
4703 }
4704
4705 bool CSSParser::parseSingleGridAreaLonghand(RefPtr<CSSValue>& property)
4706 {
4707 if (!m_valueList->current())
4708 return true;
4709
4710 if (!isForwardSlashOperator(m_valueList->current()))
4711 return false;
4712
4713 if (!m_valueList->next())
4714 return false;
4715
4716 property = parseGridPosition();
4717 return true;
4718 }
4719
4650 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important) 4720 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important)
4651 { 4721 {
4652 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 4722 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4653 4723
4654 CSSParserValue* value = m_valueList->current(); 4724 CSSParserValue* value = m_valueList->current();
4655 if (value->id == CSSValueNone) { 4725 if (value->id == CSSValueNone) {
4656 if (m_valueList->next()) 4726 if (m_valueList->next())
4657 return false; 4727 return false;
4658 4728
4659 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant); 4729 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
(...skipping 7181 matching lines...) Expand 10 before | Expand all | Expand 10 after
11841 { 11911 {
11842 // The tokenizer checks for the construct of an+b. 11912 // The tokenizer checks for the construct of an+b.
11843 // However, since the {ident} rule precedes the {nth} rule, some of those 11913 // However, since the {ident} rule precedes the {nth} rule, some of those
11844 // tokens are identified as string literal. Furthermore we need to accept 11914 // tokens are identified as string literal. Furthermore we need to accept
11845 // "odd" and "even" which does not match to an+b. 11915 // "odd" and "even" which does not match to an+b.
11846 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11916 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11847 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11917 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11848 } 11918 }
11849 11919
11850 } 11920 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSParser.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698