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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 case CSSPropertyWebkitTextEmphasisColor: | 604 case CSSPropertyWebkitTextEmphasisColor: |
605 case CSSPropertyWebkitTextFillColor: | 605 case CSSPropertyWebkitTextFillColor: |
606 case CSSPropertyWebkitTextStrokeColor: | 606 case CSSPropertyWebkitTextStrokeColor: |
607 if (propId == CSSPropertyTextDecorationColor | 607 if (propId == CSSPropertyTextDecorationColor |
608 && !RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | 608 && !RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
609 return false; | 609 return false; |
610 | 610 |
611 if ((id >= CSSValueAqua && id <= CSSValueWebkitText) || id == CSSValueMe
nu) { | 611 if ((id >= CSSValueAqua && id <= CSSValueWebkitText) || id == CSSValueMe
nu) { |
612 validPrimitive = isValueAllowedInMode(id, m_context.mode()); | 612 validPrimitive = isValueAllowedInMode(id, m_context.mode()); |
613 } else { | 613 } else { |
614 parsedValue = parseColor(); | 614 if (!inQuirksMode()) { |
| 615 parsedValue = parseColor(); |
| 616 if (parsedValue) |
| 617 m_valueList->next(); |
| 618 break; |
| 619 } |
| 620 |
| 621 bool acceptQuirkyColors = false; |
| 622 switch (propId) { |
| 623 case CSSPropertyBackgroundColor: |
| 624 if (!inShorthand()) |
| 625 acceptQuirkyColors = true; |
| 626 break; |
| 627 case CSSPropertyBorderBottomColor: |
| 628 case CSSPropertyBorderLeftColor: |
| 629 case CSSPropertyBorderRightColor: |
| 630 case CSSPropertyBorderTopColor: |
| 631 case CSSPropertyColor: |
| 632 acceptQuirkyColors = true; |
| 633 break; |
| 634 default: |
| 635 break; |
| 636 } |
| 637 parsedValue = parseColor(0, acceptQuirkyColors); |
615 if (parsedValue) | 638 if (parsedValue) |
616 m_valueList->next(); | 639 m_valueList->next(); |
617 } | 640 } |
618 break; | 641 break; |
619 | 642 |
620 case CSSPropertyCursor: { | 643 case CSSPropertyCursor: { |
621 // Grammar defined by CSS3 UI and modified by CSS4 images: | 644 // Grammar defined by CSS3 UI and modified by CSS4 images: |
622 // [ [<image> [<x> <y>]?,]* | 645 // [ [<image> [<x> <y>]?,]* |
623 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | | 646 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | |
624 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | | 647 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | |
(...skipping 4803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5428 if (v->unit != CSSParserValue::Operator && v->iValue != ',') | 5451 if (v->unit != CSSParserValue::Operator && v->iValue != ',') |
5429 return false; | 5452 return false; |
5430 v = args->next(); | 5453 v = args->next(); |
5431 if (!validUnit(v, FNumber, HTMLStandardMode)) | 5454 if (!validUnit(v, FNumber, HTMLStandardMode)) |
5432 return false; | 5455 return false; |
5433 colorArray[3] = std::max(0.0, std::min(1.0, v->fValue)); | 5456 colorArray[3] = std::max(0.0, std::min(1.0, v->fValue)); |
5434 } | 5457 } |
5435 return true; | 5458 return true; |
5436 } | 5459 } |
5437 | 5460 |
5438 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value) | 5461 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value, bool acceptQuirkyColors) |
5439 { | 5462 { |
5440 RGBA32 c = Color::transparent; | 5463 RGBA32 c = Color::transparent; |
5441 if (!parseColorFromValue(value ? value : m_valueList->current(), c)) | 5464 if (!parseColorFromValue(value ? value : m_valueList->current(), c, acceptQu
irkyColors)) |
5442 return nullptr; | 5465 return nullptr; |
5443 return cssValuePool().createColorValue(c); | 5466 return cssValuePool().createColorValue(c); |
5444 } | 5467 } |
5445 | 5468 |
5446 bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c) | 5469 bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bo
ol acceptQuirkyColors) |
5447 { | 5470 { |
5448 if (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_NUMBER | 5471 if (acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_NUMBER |
5449 && value->fValue >= 0. && value->fValue < 1000000.) { | 5472 && value->fValue >= 0. && value->fValue < 1000000.) { |
5450 String str = String::format("%06d", static_cast<int>((value->fValue+.5))
); | 5473 String str = String::format("%06d", static_cast<int>((value->fValue+.5))
); |
5451 // FIXME: This should be strict parsing for SVG as well. | 5474 // FIXME: This should be strict parsing for SVG as well. |
5452 if (!fastParseColor(c, str, !inQuirksMode())) | 5475 if (!fastParseColor(c, str, !acceptQuirkyColors)) |
5453 return false; | 5476 return false; |
5454 } else if (value->unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR || | 5477 } else if (value->unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR |
5455 value->unit == CSSPrimitiveValue::CSS_IDENT || | 5478 || value->unit == CSSPrimitiveValue::CSS_IDENT |
5456 (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_DIMENSI
ON)) { | 5479 || (acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_DIMENSIO
N)) { |
5457 if (!fastParseColor(c, value->string, !inQuirksMode() && value->unit ==
CSSPrimitiveValue::CSS_IDENT)) | 5480 if (!fastParseColor(c, value->string, !acceptQuirkyColors && value->unit
== CSSPrimitiveValue::CSS_IDENT)) |
5458 return false; | 5481 return false; |
5459 } else if (value->unit == CSSParserValue::Function && | 5482 } else if (value->unit == CSSParserValue::Function && |
5460 value->function->args != 0 && | 5483 value->function->args != 0 && |
5461 value->function->args->size() == 5 /* rgb + two commas */ && | 5484 value->function->args->size() == 5 /* rgb + two commas */ && |
5462 equalIgnoringCase(value->function->name, "rgb(")) { | 5485 equalIgnoringCase(value->function->name, "rgb(")) { |
5463 int colorValues[3]; | 5486 int colorValues[3]; |
5464 if (!parseColorParameters(value, colorValues, false)) | 5487 if (!parseColorParameters(value, colorValues, false)) |
5465 return false; | 5488 return false; |
5466 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]); | 5489 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]); |
5467 } else { | 5490 } else { |
(...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8516 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); | 8539 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
8517 if (!seenStroke) | 8540 if (!seenStroke) |
8518 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); | 8541 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); |
8519 if (!seenMarkers) | 8542 if (!seenMarkers) |
8520 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); | 8543 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); |
8521 | 8544 |
8522 return parsedValues.release(); | 8545 return parsedValues.release(); |
8523 } | 8546 } |
8524 | 8547 |
8525 } // namespace blink | 8548 } // namespace blink |
OLD | NEW |