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 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 if (pos < end) { | 964 if (pos < end) { |
965 if (isCSSSpace(*pos)) | 965 if (isCSSSpace(*pos)) |
966 return nullptr; | 966 return nullptr; |
967 } | 967 } |
968 } | 968 } |
969 return transformList.release(); | 969 return transformList.release(); |
970 } | 970 } |
971 | 971 |
972 static bool parseTranslateTransform(MutableStylePropertySet* properties, CSSProp
ertyID propertyID, const String& string, bool important) | 972 static bool parseTranslateTransform(MutableStylePropertySet* properties, CSSProp
ertyID propertyID, const String& string, bool important) |
973 { | 973 { |
974 if (propertyID != CSSPropertyWebkitTransform) | 974 if (propertyID != CSSPropertyTransform && propertyID != CSSPropertyWebkitTra
nsform) |
975 return false; | 975 return false; |
976 if (string.isEmpty()) | 976 if (string.isEmpty()) |
977 return false; | 977 return false; |
978 RefPtrWillBeRawPtr<CSSValueList> transformList = nullptr; | 978 RefPtrWillBeRawPtr<CSSValueList> transformList = nullptr; |
979 if (string.is8Bit()) { | 979 if (string.is8Bit()) { |
980 const LChar* pos = string.characters8(); | 980 const LChar* pos = string.characters8(); |
981 const LChar* end = pos + string.length(); | 981 const LChar* end = pos + string.length(); |
982 transformList = parseTranslateTransformList(pos, end); | 982 transformList = parseTranslateTransformList(pos, end); |
983 if (!transformList) | 983 if (!transformList) |
984 return false; | 984 return false; |
985 } else { | 985 } else { |
986 const UChar* pos = string.characters16(); | 986 const UChar* pos = string.characters16(); |
987 const UChar* end = pos + string.length(); | 987 const UChar* end = pos + string.length(); |
988 transformList = parseTranslateTransformList(pos, end); | 988 transformList = parseTranslateTransformList(pos, end); |
989 if (!transformList) | 989 if (!transformList) |
990 return false; | 990 return false; |
991 } | 991 } |
992 properties->addParsedProperty(CSSProperty(CSSPropertyWebkitTransform, transf
ormList.release(), important)); | 992 properties->addParsedProperty(CSSProperty(propertyID, transformList.release(
), important)); |
993 return true; | 993 return true; |
994 } | 994 } |
995 | 995 |
996 PassRefPtrWillBeRawPtr<CSSValueList> BisonCSSParser::parseFontFaceValue(const At
omicString& string) | 996 PassRefPtrWillBeRawPtr<CSSValueList> BisonCSSParser::parseFontFaceValue(const At
omicString& string) |
997 { | 997 { |
998 if (string.isEmpty()) | 998 if (string.isEmpty()) |
999 return nullptr; | 999 return nullptr; |
1000 RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = MutableStylePropert
ySet::create(); | 1000 RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = MutableStylePropert
ySet::create(); |
1001 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML
QuirksMode, 0)) | 1001 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML
QuirksMode, 0)) |
1002 return nullptr; | 1002 return nullptr; |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 bool unknown() const { return m_type == CSSTransformValue::UnknownTransformO
peration; } | 1411 bool unknown() const { return m_type == CSSTransformValue::UnknownTransformO
peration; } |
1412 bool hasCorrectArgCount(unsigned argCount) { return m_argCount == argCount |
| (m_allowSingleArgument && argCount == 1); } | 1412 bool hasCorrectArgCount(unsigned argCount) { return m_argCount == argCount |
| (m_allowSingleArgument && argCount == 1); } |
1413 | 1413 |
1414 private: | 1414 private: |
1415 CSSTransformValue::TransformOperationType m_type; | 1415 CSSTransformValue::TransformOperationType m_type; |
1416 unsigned m_argCount; | 1416 unsigned m_argCount; |
1417 bool m_allowSingleArgument; | 1417 bool m_allowSingleArgument; |
1418 CSSPropertyParser::Units m_unit; | 1418 CSSPropertyParser::Units m_unit; |
1419 }; | 1419 }; |
1420 | 1420 |
1421 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform() | 1421 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(CSSProper
tyID propId) |
1422 { | 1422 { |
1423 if (!m_valueList) | 1423 if (!m_valueList) |
1424 return nullptr; | 1424 return nullptr; |
1425 | 1425 |
1426 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 1426 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
1427 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 1427 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
1428 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue(
value); | 1428 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue(
propId, value); |
1429 if (!parsedTransformValue) | 1429 if (!parsedTransformValue) |
1430 return nullptr; | 1430 return nullptr; |
1431 | 1431 |
1432 list->append(parsedTransformValue.release()); | 1432 list->append(parsedTransformValue.release()); |
1433 } | 1433 } |
1434 | 1434 |
1435 return list.release(); | 1435 return list.release(); |
1436 } | 1436 } |
1437 | 1437 |
1438 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(CSSParse
rValue *value) | 1438 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(CSSPrope
rtyID propId, CSSParserValue *value) |
1439 { | 1439 { |
1440 if (value->unit != CSSParserValue::Function || !value->function) | 1440 if (value->unit != CSSParserValue::Function || !value->function) |
1441 return nullptr; | 1441 return nullptr; |
1442 | 1442 |
1443 // Every primitive requires at least one argument. | 1443 // Every primitive requires at least one argument. |
1444 CSSParserValueList* args = value->function->args.get(); | 1444 CSSParserValueList* args = value->function->args.get(); |
1445 if (!args) | 1445 if (!args) |
1446 return nullptr; | 1446 return nullptr; |
1447 | 1447 |
1448 // See if the specified primitive is one we understand. | 1448 // See if the specified primitive is one we understand. |
(...skipping 23 matching lines...) Expand all Loading... |
1472 } else if (info.type() == CSSTransformValue::Translate3DTransformOperati
on && argNumber == 2) { | 1472 } else if (info.type() == CSSTransformValue::Translate3DTransformOperati
on && argNumber == 2) { |
1473 // 3rd param of translate3d() cannot be a percentage | 1473 // 3rd param of translate3d() cannot be a percentage |
1474 if (!validUnit(a, FLength, HTMLStandardMode)) | 1474 if (!validUnit(a, FLength, HTMLStandardMode)) |
1475 return nullptr; | 1475 return nullptr; |
1476 } else if (info.type() == CSSTransformValue::TranslateZTransformOperatio
n && !argNumber) { | 1476 } else if (info.type() == CSSTransformValue::TranslateZTransformOperatio
n && !argNumber) { |
1477 // 1st param of translateZ() cannot be a percentage | 1477 // 1st param of translateZ() cannot be a percentage |
1478 if (!validUnit(a, FLength, HTMLStandardMode)) | 1478 if (!validUnit(a, FLength, HTMLStandardMode)) |
1479 return nullptr; | 1479 return nullptr; |
1480 } else if (info.type() == CSSTransformValue::PerspectiveTransformOperati
on && !argNumber) { | 1480 } else if (info.type() == CSSTransformValue::PerspectiveTransformOperati
on && !argNumber) { |
1481 // 1st param of perspective() must be a non-negative number (depreca
ted) or length. | 1481 // 1st param of perspective() must be a non-negative number (depreca
ted) or length. |
1482 if (!validUnit(a, FNumber | FLength | FNonNeg, HTMLStandardMode)) | 1482 if ((propId == CSSPropertyWebkitTransform && !validUnit(a, FNumber |
FLength | FNonNeg, HTMLStandardMode)) |
| 1483 || (propId == CSSPropertyTransform && !validUnit(a, FLength | FN
onNeg, HTMLStandardMode))) |
1483 return nullptr; | 1484 return nullptr; |
1484 } else if (!validUnit(a, unit, HTMLStandardMode)) { | 1485 } else if (!validUnit(a, unit, HTMLStandardMode)) { |
1485 return nullptr; | 1486 return nullptr; |
1486 } | 1487 } |
1487 | 1488 |
1488 // Add the value to the current transform operation. | 1489 // Add the value to the current transform operation. |
1489 transformValue->append(createPrimitiveNumericValue(a)); | 1490 transformValue->append(createPrimitiveNumericValue(a)); |
1490 | 1491 |
1491 a = args->next(); | 1492 a = args->next(); |
1492 if (!a) | 1493 if (!a) |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 rule->setProperties(createStylePropertySet()); | 2186 rule->setProperties(createStylePropertySet()); |
2186 clearProperties(); | 2187 clearProperties(); |
2187 | 2188 |
2188 StyleRuleViewport* result = rule.get(); | 2189 StyleRuleViewport* result = rule.get(); |
2189 m_parsedRules.append(rule.release()); | 2190 m_parsedRules.append(rule.release()); |
2190 | 2191 |
2191 return result; | 2192 return result; |
2192 } | 2193 } |
2193 | 2194 |
2194 } | 2195 } |
OLD | NEW |