OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 int c = string[i]; | 615 int c = string[i]; |
616 if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z')) | 616 if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z')) |
617 return i >= 2 && c == '-'; | 617 return i >= 2 && c == '-'; |
618 } | 618 } |
619 return false; | 619 return false; |
620 } | 620 } |
621 | 621 |
622 static bool hasNonWebkitVendorSpecificPrefix(const CSSParserString& string) | 622 static bool hasNonWebkitVendorSpecificPrefix(const CSSParserString& string) |
623 { | 623 { |
624 const size_t stringLength = string.length(); | 624 const size_t stringLength = string.length(); |
| 625 // 4 corresponds to "-o-x" - the shortest vendor-prefixed property name. |
625 if (stringLength < 4 || string[0] != '-') | 626 if (stringLength < 4 || string[0] != '-') |
626 return false; | 627 return false; |
627 | 628 |
628 static const char webkitPrefix[] = "-webkit-"; | 629 static const char webkitPrefix[] = "-webkit-"; |
629 if (stringLength > 8 && string.startsWithIgnoringCase(webkitPrefix)) | 630 if (stringLength > 8 && string.startsWithIgnoringCase(webkitPrefix)) |
630 return false; | 631 return false; |
631 | 632 |
632 return string.is8Bit() ? hasVendorSpecificPrefix(string.characters8(), strin
gLength) : hasVendorSpecificPrefix(string.characters16(), stringLength); | 633 return string.is8Bit() ? hasVendorSpecificPrefix(string.characters8(), strin
gLength) : hasVendorSpecificPrefix(string.characters16(), stringLength); |
633 } | 634 } |
634 | 635 |
| 636 static bool isValidPropertyName(const CSSParserString& content) |
| 637 { |
| 638 if (content.equalIgnoringCase("animation") |
| 639 || content.equalIgnoringCase("font-size-adjust") |
| 640 || content.equalIgnoringCase("transform") |
| 641 || content.equalIgnoringCase("user-select") |
| 642 || content.equalIgnoringCase("-webkit-flex-pack") |
| 643 || content.equalIgnoringCase("-webkit-text-size-adjust")) |
| 644 return true; |
| 645 |
| 646 return false; |
| 647 } |
| 648 |
635 // static | 649 // static |
636 bool InspectorCSSAgent::cssErrorFilter(const CSSParserString& content, int prope
rtyId, int errorType) | 650 bool InspectorCSSAgent::cssErrorFilter(const CSSParserString& content, int prope
rtyId, int errorType) |
637 { | 651 { |
638 const size_t contentLength = content.length(); | 652 const size_t contentLength = content.length(); |
639 | 653 |
640 switch (errorType) { | 654 switch (errorType) { |
641 case CSSParser::PropertyDeclarationError: | 655 case CSSParser::PropertyDeclarationError: |
642 // Ignore errors like "*property: value". This trick is used for IE7: ht
tp://stackoverflow.com/questions/4563651/what-does-an-asterisk-do-in-a-css-prope
rty-name | 656 // Ignore errors like "*property: value". This trick is used for IE7: ht
tp://stackoverflow.com/questions/4563651/what-does-an-asterisk-do-in-a-css-prope
rty-name |
643 if (contentLength && content[0] == '*') | 657 if (contentLength && content[0] == '*') |
644 return false; | 658 return false; |
645 | 659 |
646 // The "filter" property is commonly used instead of "opacity" for IE9. | 660 // The "filter" property is commonly used instead of "opacity" for IE9. |
647 if (propertyId == CSSPropertyFilter) | 661 if (propertyId == CSSPropertyFilter) |
648 return false; | 662 return false; |
| 663 |
649 break; | 664 break; |
650 | 665 |
651 case CSSParser::InvalidPropertyValueError: | 666 case CSSParser::InvalidPropertyValueError: |
652 // The "filter" property is commonly used instead of "opacity" for IE9. | 667 // The "filter" property is commonly used instead of "opacity" for IE9. |
653 if (propertyId == CSSPropertyFilter) | 668 if (propertyId == CSSPropertyFilter) |
654 return false; | 669 return false; |
655 | 670 |
656 // Value might be a vendor-specific function. | 671 // Value might be a vendor-specific function. |
657 if (hasNonWebkitVendorSpecificPrefix(content)) | 672 if (hasNonWebkitVendorSpecificPrefix(content)) |
658 return false; | 673 return false; |
659 | 674 |
660 // IE-only "cursor: hand". | 675 // IE-only "cursor: hand". |
661 if (propertyId == CSSPropertyCursor && content.equalIgnoringCase("hand")
) | 676 if (propertyId == CSSPropertyCursor && content.equalIgnoringCase("hand")
) |
662 return false; | 677 return false; |
663 | 678 |
664 // Ignore properties like "property: value \9". This trick used in boots
rtap for IE-only properies. | 679 // Ignore properties like "property: value \9" (common IE hack) or "prop
erty: value \0" (IE 8 hack). |
665 if (contentLength > 2 && content[contentLength - 2] == '\\' && content[c
ontentLength - 1] == '9') | 680 if (contentLength > 2 && content[contentLength - 2] == '\\' && (content[
contentLength - 1] == '9' || content[contentLength - 1] == '0')) |
666 return false; | 681 return false; |
| 682 |
| 683 // Another hack like "property: value\0/". |
| 684 if (contentLength > 3 && content[contentLength - 3] == '\\' && content[c
ontentLength - 2] == '0' && content[contentLength - 1] == '/') |
| 685 return false; |
| 686 |
| 687 // Popular value prefixes valid in other browsers. |
| 688 if (content.startsWithIgnoringCase("linear-gradient")) |
| 689 return false; |
| 690 if (content.startsWithIgnoringCase("-webkit-flexbox")) |
| 691 return false; |
| 692 |
667 break; | 693 break; |
668 | 694 |
669 case CSSParser::InvalidPropertyError: | 695 case CSSParser::InvalidPropertyError: |
670 if (hasNonWebkitVendorSpecificPrefix(content)) | 696 if (hasNonWebkitVendorSpecificPrefix(content)) |
671 return false; | 697 return false; |
672 | 698 |
673 // Another hack to make IE-only property. | 699 // Another hack to make IE-only property. |
674 if (contentLength && content[0] == '_') | 700 if (contentLength && content[0] == '_') |
675 return false; | 701 return false; |
676 | 702 |
677 // IE-only set of properties. | 703 // IE-only set of properties. |
678 if (content.startsWithIgnoringCase("scrollbar-")) | 704 if (content.startsWithIgnoringCase("scrollbar-")) |
679 return false; | 705 return false; |
680 | 706 |
681 // Unsupported standard property. | 707 if (isValidPropertyName(content)) |
682 if (content.equalIgnoringCase("font-size-adjust")) | |
683 return false; | 708 return false; |
| 709 |
684 break; | 710 break; |
| 711 |
| 712 case CSSParser::InvalidRuleError: |
| 713 // Block error reporting for @-rules for now to avoid noise. |
| 714 if (contentLength > 4 && content[0] == '@') |
| 715 return false; |
| 716 return true; |
685 } | 717 } |
686 return true; | 718 return true; |
687 } | 719 } |
688 | 720 |
689 InspectorCSSAgent::InspectorCSSAgent(InstrumentingAgents* instrumentingAgents, I
nspectorCompositeState* state, InspectorDOMAgent* domAgent, InspectorPageAgent*
pageAgent) | 721 InspectorCSSAgent::InspectorCSSAgent(InstrumentingAgents* instrumentingAgents, I
nspectorCompositeState* state, InspectorDOMAgent* domAgent, InspectorPageAgent*
pageAgent) |
690 : InspectorBaseAgent<InspectorCSSAgent>("CSS", instrumentingAgents, state) | 722 : InspectorBaseAgent<InspectorCSSAgent>("CSS", instrumentingAgents, state) |
691 , m_frontend(0) | 723 , m_frontend(0) |
692 , m_domAgent(domAgent) | 724 , m_domAgent(domAgent) |
693 , m_pageAgent(pageAgent) | 725 , m_pageAgent(pageAgent) |
694 , m_lastStyleSheetId(1) | 726 , m_lastStyleSheetId(1) |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 documentsToChange.add(element->ownerDocument()); | 1720 documentsToChange.add(element->ownerDocument()); |
1689 } | 1721 } |
1690 | 1722 |
1691 m_nodeIdToForcedPseudoState.clear(); | 1723 m_nodeIdToForcedPseudoState.clear(); |
1692 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1724 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1693 (*it)->styleResolverChanged(RecalcStyleImmediately); | 1725 (*it)->styleResolverChanged(RecalcStyleImmediately); |
1694 } | 1726 } |
1695 | 1727 |
1696 } // namespace WebCore | 1728 } // namespace WebCore |
1697 | 1729 |
OLD | NEW |