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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr
<CSSValue> value, bool important, bool implicit) | 76 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr
<CSSValue> value, bool important, bool implicit) |
77 { | 77 { |
78 ASSERT(!isPropertyAlias(propId)); | 78 ASSERT(!isPropertyAlias(propId)); |
79 | 79 |
80 int shorthandIndex = 0; | 80 int shorthandIndex = 0; |
81 bool setFromShorthand = false; | 81 bool setFromShorthand = false; |
82 | 82 |
83 if (m_currentShorthand) { | 83 if (m_currentShorthand) { |
84 Vector<StylePropertyShorthand, 4> shorthands; | 84 Vector<StylePropertyShorthand, 4> shorthands; |
85 getMatchingShorthandsForLonghand(propId, &shorthands); | 85 getMatchingShorthandsForLonghand(propId, &shorthands); |
86 // Viewport descriptors have width and height as shorthands, but it does
n't | 86 setFromShorthand = true; |
87 // make sense for CSSProperties.in to consider them as such. The shortha
nd | |
88 // index is only used by the inspector and doesn't affect viewport | |
89 // descriptors. | |
90 if (shorthands.isEmpty()) | |
91 ASSERT(m_currentShorthand == CSSPropertyWidth || m_currentShorthand
== CSSPropertyHeight); | |
92 else | |
93 setFromShorthand = true; | |
94 | |
95 if (shorthands.size() > 1) | 87 if (shorthands.size() > 1) |
96 shorthandIndex = indexOfShorthandForLonghand(m_currentShorthand, sho
rthands); | 88 shorthandIndex = indexOfShorthandForLonghand(m_currentShorthand, sho
rthands); |
97 } | 89 } |
98 | 90 |
99 m_parsedProperties.append(CSSProperty(propId, value, important, setFromShort
hand, shorthandIndex, m_implicitShorthand || implicit)); | 91 m_parsedProperties.append(CSSProperty(propId, value, important, setFromShort
hand, shorthandIndex, m_implicitShorthand || implicit)); |
100 } | 92 } |
101 | 93 |
102 void CSSPropertyParser::rollbackLastProperties(int num) | 94 void CSSPropertyParser::rollbackLastProperties(int num) |
103 { | 95 { |
104 ASSERT(num >= 0); | 96 ASSERT(num >= 0); |
(...skipping 6423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6528 | 6520 |
6529 ASSERT(!m_parsedCalculation); | 6521 ASSERT(!m_parsedCalculation); |
6530 m_parsedCalculation = CSSCalcValue::create(args, range); | 6522 m_parsedCalculation = CSSCalcValue::create(args, range); |
6531 | 6523 |
6532 if (!m_parsedCalculation) | 6524 if (!m_parsedCalculation) |
6533 return false; | 6525 return false; |
6534 | 6526 |
6535 return true; | 6527 return true; |
6536 } | 6528 } |
6537 | 6529 |
6538 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa
nt) | |
6539 { | |
6540 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | |
6541 | |
6542 CSSParserValue* value = m_valueList->current(); | |
6543 if (!value) | |
6544 return false; | |
6545 | |
6546 CSSValueID id = value->id; | |
6547 bool validPrimitive = false; | |
6548 | |
6549 switch (propId) { | |
6550 case CSSPropertyMinWidth: // auto | extend-to-zoom | <length> | <percentage> | |
6551 case CSSPropertyMaxWidth: | |
6552 case CSSPropertyMinHeight: | |
6553 case CSSPropertyMaxHeight: | |
6554 if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom) | |
6555 validPrimitive = true; | |
6556 else | |
6557 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); | |
6558 break; | |
6559 case CSSPropertyWidth: // shorthand | |
6560 return parseViewportShorthand(propId, CSSPropertyMinWidth, CSSPropertyMa
xWidth, important); | |
6561 case CSSPropertyHeight: | |
6562 return parseViewportShorthand(propId, CSSPropertyMinHeight, CSSPropertyM
axHeight, important); | |
6563 case CSSPropertyMinZoom: // auto | <number> | <percentage> | |
6564 case CSSPropertyMaxZoom: | |
6565 case CSSPropertyZoom: | |
6566 if (id == CSSValueAuto) | |
6567 validPrimitive = true; | |
6568 else | |
6569 validPrimitive = validUnit(value, FNumber | FPercent | FNonNeg); | |
6570 break; | |
6571 case CSSPropertyUserZoom: // zoom | fixed | |
6572 if (id == CSSValueZoom || id == CSSValueFixed) | |
6573 validPrimitive = true; | |
6574 break; | |
6575 case CSSPropertyOrientation: // auto | portrait | landscape | |
6576 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc
ape) | |
6577 validPrimitive = true; | |
6578 default: | |
6579 break; | |
6580 } | |
6581 | |
6582 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | |
6583 if (validPrimitive) { | |
6584 parsedValue = parseValidPrimitive(id, value); | |
6585 m_valueList->next(); | |
6586 } | |
6587 | |
6588 if (parsedValue) { | |
6589 if (!m_valueList->current() || inShorthand()) { | |
6590 addProperty(propId, parsedValue.release(), important); | |
6591 return true; | |
6592 } | |
6593 } | |
6594 | |
6595 return false; | |
6596 } | |
6597 | |
6598 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty
ID first, CSSPropertyID second, bool important) | |
6599 { | |
6600 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | |
6601 unsigned numValues = m_valueList->size(); | |
6602 | |
6603 if (numValues > 2) | |
6604 return false; | |
6605 | |
6606 ShorthandScope scope(this, propId); | |
6607 | |
6608 if (!parseViewportProperty(first, important)) | |
6609 return false; | |
6610 | |
6611 // If just one value is supplied, the second value | |
6612 // is implicitly initialized with the first value. | |
6613 if (numValues == 1) | |
6614 m_valueList->previous(); | |
6615 | |
6616 return parseViewportProperty(second, important); | |
6617 } | |
6618 | |
6619 template <typename CharacterType> | 6530 template <typename CharacterType> |
6620 static CSSPropertyID unresolvedCSSPropertyID(const CharacterType* propertyName,
unsigned length) | 6531 static CSSPropertyID unresolvedCSSPropertyID(const CharacterType* propertyName,
unsigned length) |
6621 { | 6532 { |
6622 char buffer[maxCSSPropertyNameLength + 1]; // 1 for null character | 6533 char buffer[maxCSSPropertyNameLength + 1]; // 1 for null character |
6623 | 6534 |
6624 for (unsigned i = 0; i != length; ++i) { | 6535 for (unsigned i = 0; i != length; ++i) { |
6625 CharacterType c = propertyName[i]; | 6536 CharacterType c = propertyName[i]; |
6626 if (c == 0 || c >= 0x7F) | 6537 if (c == 0 || c >= 0x7F) |
6627 return CSSPropertyInvalid; // illegal character | 6538 return CSSPropertyInvalid; // illegal character |
6628 buffer[i] = toASCIILower(c); | 6539 buffer[i] = toASCIILower(c); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7188 } | 7099 } |
7189 } | 7100 } |
7190 | 7101 |
7191 if (!list->length()) | 7102 if (!list->length()) |
7192 return nullptr; | 7103 return nullptr; |
7193 | 7104 |
7194 return list.release(); | 7105 return list.release(); |
7195 } | 7106 } |
7196 | 7107 |
7197 } // namespace blink | 7108 } // namespace blink |
OLD | NEW |