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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 m_parsedProperties.append(CSSProperty(propId, value, important, setFromShort
hand, shorthandIndex, m_implicitShorthand || implicit)); | 86 m_parsedProperties.append(CSSProperty(propId, value, important, setFromShort
hand, shorthandIndex, m_implicitShorthand || implicit)); |
87 } | 87 } |
88 | 88 |
89 void CSSPropertyParser::rollbackLastProperties(int num) | 89 void CSSPropertyParser::rollbackLastProperties(int num) |
90 { | 90 { |
91 ASSERT(num >= 0); | 91 ASSERT(num >= 0); |
92 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); | 92 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); |
93 m_parsedProperties.shrink(m_parsedProperties.size() - num); | 93 m_parsedProperties.shrink(m_parsedProperties.size() - num); |
94 } | 94 } |
95 | 95 |
96 KURL CSSPropertyParser::completeURL(const String& url) const | |
97 { | |
98 return m_context.completeURL(url); | |
99 } | |
100 | |
101 bool CSSPropertyParser::validCalculationUnit(CSSParserValue* value, Units unitfl
ags, ReleaseParsedCalcValueCondition releaseCalc) | 96 bool CSSPropertyParser::validCalculationUnit(CSSParserValue* value, Units unitfl
ags, ReleaseParsedCalcValueCondition releaseCalc) |
102 { | 97 { |
103 bool mustBeNonNegative = unitflags & (FNonNeg | FPositiveInteger); | 98 bool mustBeNonNegative = unitflags & (FNonNeg | FPositiveInteger); |
104 | 99 |
105 if (!parseCalculation(value, mustBeNonNegative ? ValueRangeNonNegative : Val
ueRangeAll)) | 100 if (!parseCalculation(value, mustBeNonNegative ? ValueRangeNonNegative : Val
ueRangeAll)) |
106 return false; | 101 return false; |
107 | 102 |
108 bool b = false; | 103 bool b = false; |
109 switch (m_parsedCalculation->category()) { | 104 switch (m_parsedCalculation->category()) { |
110 case CalcLength: | 105 case CalcLength: |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 // in CSS 2.1 this got somewhat reduced: | 1293 // in CSS 2.1 this got somewhat reduced: |
1299 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 1294 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
1300 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() | 1295 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() |
1301 { | 1296 { |
1302 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 1297 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
1303 | 1298 |
1304 while (CSSParserValue* val = m_valueList->current()) { | 1299 while (CSSParserValue* val = m_valueList->current()) { |
1305 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 1300 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
1306 if (val->m_unit == CSSParserValue::URI) { | 1301 if (val->m_unit == CSSParserValue::URI) { |
1307 // url | 1302 // url |
1308 parsedValue = createCSSImageValueWithReferrer(val->string, completeU
RL(val->string)); | 1303 parsedValue = createCSSImageValueWithReferrer(val->string, m_context
); |
1309 } else if (val->m_unit == CSSParserValue::Function) { | 1304 } else if (val->m_unit == CSSParserValue::Function) { |
1310 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) | 1305 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) |
1311 CSSParserValueList* args = val->function->args.get(); | 1306 CSSParserValueList* args = val->function->args.get(); |
1312 if (!args) | 1307 if (!args) |
1313 return nullptr; | 1308 return nullptr; |
1314 if (val->function->id == CSSValueAttr) { | 1309 if (val->function->id == CSSValueAttr) { |
1315 parsedValue = parseAttr(args); | 1310 parsedValue = parseAttr(args); |
1316 } else if (val->function->id == CSSValueCounter) { | 1311 } else if (val->function->id == CSSValueCounter) { |
1317 parsedValue = parseCounterContent(args, false); | 1312 parsedValue = parseCounterContent(args, false); |
1318 } else if (val->function->id == CSSValueCounters) { | 1313 } else if (val->function->id == CSSValueCounters) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 return cssValuePool().createColorValue(c); | 1412 return cssValuePool().createColorValue(c); |
1418 } | 1413 } |
1419 | 1414 |
1420 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) | 1415 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) |
1421 { | 1416 { |
1422 if (valueList->current()->id == CSSValueNone) { | 1417 if (valueList->current()->id == CSSValueNone) { |
1423 value = cssValuePool().createIdentifierValue(CSSValueNone); | 1418 value = cssValuePool().createIdentifierValue(CSSValueNone); |
1424 return true; | 1419 return true; |
1425 } | 1420 } |
1426 if (valueList->current()->m_unit == CSSParserValue::URI) { | 1421 if (valueList->current()->m_unit == CSSParserValue::URI) { |
1427 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); | 1422 value = createCSSImageValueWithReferrer(valueList->current()->string, m_
context); |
1428 return true; | 1423 return true; |
1429 } | 1424 } |
1430 | 1425 |
1431 if (valueList->current()->m_unit == CSSParserValue::Function) { | 1426 if (valueList->current()->m_unit == CSSParserValue::Function) { |
1432 if (isGeneratedImageValue(valueList->current()->function->id)) | 1427 if (isGeneratedImageValue(valueList->current()->function->id)) |
1433 return parseGeneratedImage(valueList, value); | 1428 return parseGeneratedImage(valueList, value); |
1434 | 1429 |
1435 if (valueList->current()->function->id == CSSValueWebkitImageSet) { | 1430 if (valueList->current()->function->id == CSSValueWebkitImageSet) { |
1436 value = parseImageSet(m_valueList); | 1431 value = parseImageSet(m_valueList); |
1437 if (value) | 1432 if (value) |
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3760 { | 3755 { |
3761 CSSPropertyParser::ShorthandScope scope(this, propId); | 3756 CSSPropertyParser::ShorthandScope scope(this, propId); |
3762 while (CSSParserValue* val = m_valueList->current()) { | 3757 while (CSSParserValue* val = m_valueList->current()) { |
3763 context.setCanAdvance(false); | 3758 context.setCanAdvance(false); |
3764 | 3759 |
3765 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) | 3760 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) |
3766 context.commitForwardSlashOperator(); | 3761 context.commitForwardSlashOperator(); |
3767 | 3762 |
3768 if (!context.canAdvance() && context.allowImage()) { | 3763 if (!context.canAdvance() && context.allowImage()) { |
3769 if (val->m_unit == CSSParserValue::URI) { | 3764 if (val->m_unit == CSSParserValue::URI) { |
3770 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context.completeURL(val->string))); | 3765 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context)); |
3771 } else if (val->m_unit == CSSParserValue::Function) { | 3766 } else if (val->m_unit == CSSParserValue::Function) { |
3772 if (isGeneratedImageValue(val->function->id)) { | 3767 if (isGeneratedImageValue(val->function->id)) { |
3773 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 3768 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
3774 if (parseGeneratedImage(m_valueList, value)) | 3769 if (parseGeneratedImage(m_valueList, value)) |
3775 context.commitImage(value.release()); | 3770 context.commitImage(value.release()); |
3776 else | 3771 else |
3777 return false; | 3772 return false; |
3778 } else if (val->function->id == CSSValueWebkitImageSet) { | 3773 } else if (val->function->id == CSSValueWebkitImageSet) { |
3779 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueLi
st); | 3774 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueLi
st); |
3780 if (value) | 3775 if (value) |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4945 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) | 4940 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) |
4946 return nullptr; | 4941 return nullptr; |
4947 | 4942 |
4948 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 4943 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
4949 | 4944 |
4950 while (functionArgs->current()) { | 4945 while (functionArgs->current()) { |
4951 CSSParserValue* arg = functionArgs->current(); | 4946 CSSParserValue* arg = functionArgs->current(); |
4952 if (arg->m_unit != CSSParserValue::URI) | 4947 if (arg->m_unit != CSSParserValue::URI) |
4953 return nullptr; | 4948 return nullptr; |
4954 | 4949 |
4955 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg
->string, completeURL(arg->string)); | 4950 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg
->string, m_context); |
4956 imageSet->append(image); | 4951 imageSet->append(image); |
4957 | 4952 |
4958 arg = functionArgs->next(); | 4953 arg = functionArgs->next(); |
4959 if (!arg) | 4954 if (!arg) |
4960 return nullptr; | 4955 return nullptr; |
4961 | 4956 |
4962 if (arg->m_unit != CSSParserValue::DimensionList) | 4957 if (arg->m_unit != CSSParserValue::DimensionList) |
4963 return nullptr; | 4958 return nullptr; |
4964 ASSERT(arg->valueList->valueAt(0)->unit() == CSSPrimitiveValue::UnitType
::Number); | 4959 ASSERT(arg->valueList->valueAt(0)->unit() == CSSPrimitiveValue::UnitType
::Number); |
4965 ASSERT(arg->valueList->valueAt(1)->m_unit == CSSParserValue::Identifier)
; | 4960 ASSERT(arg->valueList->valueAt(1)->m_unit == CSSParserValue::Identifier)
; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5072 | 5067 |
5073 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); | 5068 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); |
5074 } | 5069 } |
5075 | 5070 |
5076 bool CSSPropertyParser::isSystemColor(CSSValueID id) | 5071 bool CSSPropertyParser::isSystemColor(CSSValueID id) |
5077 { | 5072 { |
5078 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; | 5073 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; |
5079 } | 5074 } |
5080 | 5075 |
5081 } // namespace blink | 5076 } // namespace blink |
OLD | NEW |