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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 static bool hasVendorSpecificPrefix(const CharType* string, size_t stringLength) | 612 static bool hasVendorSpecificPrefix(const CharType* string, size_t stringLength) |
613 { | 613 { |
614 for (size_t i = 1; i < stringLength; ++i) { | 614 for (size_t i = 1; i < stringLength; ++i) { |
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, unsi gned offset = 0) |
pfeldman
2013/06/21 12:20:45
Do not use default values.
| |
623 { | 623 { |
624 const size_t stringLength = string.length(); | 624 const size_t stringLength = string.length() - offset; |
625 if (stringLength < 4 || string[0] != '-') | 625 if (stringLength < 4 || string[offset] != '-') |
626 return false; | 626 return false; |
627 | 627 |
628 static const char webkitPrefix[] = "-webkit-"; | 628 static const char webkitPrefix[] = "-webkit-"; |
629 if (stringLength > 8 && string.startsWithIgnoringCase(webkitPrefix)) | 629 if (stringLength > 8 && string.containsIgnoringCaseAt(webkitPrefix, offset)) |
630 return false; | 630 return false; |
631 | 631 |
632 return string.is8Bit() ? hasVendorSpecificPrefix(string.characters8(), strin gLength) : hasVendorSpecificPrefix(string.characters16(), stringLength); | 632 return string.is8Bit() ? hasVendorSpecificPrefix(string.characters8() + offs et, stringLength) : hasVendorSpecificPrefix(string.characters16() + offset, stri ngLength); |
633 } | |
634 | |
635 static bool isIgnoredPropertyName(const CSSParserString& content) | |
pfeldman
2013/06/21 12:20:45
isValidPropertyName
| |
636 { | |
637 if (content.equalIgnoringCase("animation") | |
638 || content.equalIgnoringCase("font-size-adjust") | |
639 || content.equalIgnoringCase("transform") | |
640 || content.equalIgnoringCase("user-select") | |
641 || content.equalIgnoringCase("-webkit-flex-pack") | |
642 || content.equalIgnoringCase("-webkit-text-size-adjust")) | |
643 return true; | |
644 | |
645 return false; | |
633 } | 646 } |
634 | 647 |
635 // static | 648 // static |
636 bool InspectorCSSAgent::cssErrorFilter(const CSSParserString& content, int prope rtyId, int errorType) | 649 bool InspectorCSSAgent::cssErrorFilter(const CSSParserString& content, int prope rtyId, int errorType) |
637 { | 650 { |
638 const size_t contentLength = content.length(); | 651 const size_t contentLength = content.length(); |
639 | 652 |
640 switch (errorType) { | 653 switch (errorType) { |
641 case CSSParser::PropertyDeclarationError: | 654 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 | 655 // 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] == '*') | 656 if (contentLength && content[0] == '*') |
644 return false; | 657 return false; |
645 | 658 |
646 // The "filter" property is commonly used instead of "opacity" for IE9. | 659 // The "filter" property is commonly used instead of "opacity" for IE9. |
647 if (propertyId == CSSPropertyFilter) | 660 if (propertyId == CSSPropertyFilter) |
648 return false; | 661 return false; |
662 | |
649 break; | 663 break; |
650 | 664 |
651 case CSSParser::InvalidPropertyValueError: | 665 case CSSParser::InvalidPropertyValueError: |
652 // The "filter" property is commonly used instead of "opacity" for IE9. | 666 // The "filter" property is commonly used instead of "opacity" for IE9. |
653 if (propertyId == CSSPropertyFilter) | 667 if (propertyId == CSSPropertyFilter) |
654 return false; | 668 return false; |
655 | 669 |
656 // Value might be a vendor-specific function. | 670 // Value might be a vendor-specific function. |
657 if (hasNonWebkitVendorSpecificPrefix(content)) | 671 if (hasNonWebkitVendorSpecificPrefix(content)) |
658 return false; | 672 return false; |
659 | 673 |
660 // IE-only "cursor: hand". | 674 // IE-only "cursor: hand". |
661 if (propertyId == CSSPropertyCursor && content.equalIgnoringCase("hand") ) | 675 if (propertyId == CSSPropertyCursor && content.equalIgnoringCase("hand") ) |
662 return false; | 676 return false; |
663 | 677 |
664 // Ignore properties like "property: value \9". This trick used in boots rtap for IE-only properies. | 678 // 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') | 679 if (contentLength > 2 && content[contentLength - 2] == '\\' && (content[ contentLength - 1] == '9' || content[contentLength - 1] == '0')) |
666 return false; | 680 return false; |
681 | |
682 // Another hack like "property: value\0/". | |
683 if (contentLength > 3 && content[contentLength - 3] == '\\' && content[c ontentLength - 2] == '0' && content[contentLength - 1] == '/') | |
684 return false; | |
685 | |
686 // Popular value prefixes valid in other browsers. | |
687 if (content.startsWithIgnoringCase("linear-gradient")) | |
688 return false; | |
689 if (content.startsWithIgnoringCase("-webkit-flexbox")) | |
690 return false; | |
691 | |
667 break; | 692 break; |
668 | 693 |
669 case CSSParser::InvalidPropertyError: | 694 case CSSParser::InvalidPropertyError: |
670 if (hasNonWebkitVendorSpecificPrefix(content)) | 695 if (hasNonWebkitVendorSpecificPrefix(content)) |
671 return false; | 696 return false; |
672 | 697 |
673 // Another hack to make IE-only property. | 698 // Another hack to make IE-only property. |
674 if (contentLength && content[0] == '_') | 699 if (contentLength && content[0] == '_') |
675 return false; | 700 return false; |
676 | 701 |
677 // IE-only set of properties. | 702 // IE-only set of properties. |
678 if (content.startsWithIgnoringCase("scrollbar-")) | 703 if (content.startsWithIgnoringCase("scrollbar-")) |
679 return false; | 704 return false; |
680 | 705 |
681 // Unsupported standard property. | 706 if (isIgnoredPropertyName(content)) |
682 if (content.equalIgnoringCase("font-size-adjust")) | |
683 return false; | 707 return false; |
708 | |
709 break; | |
710 | |
711 case CSSParser::InvalidRuleError: | |
712 if (contentLength > 4 && content[0] == '@') { | |
713 if (hasNonWebkitVendorSpecificPrefix(content, 1)) | |
714 return false; | |
715 if (content.containsIgnoringCaseAt("keyframes", 1)) | |
716 return false; | |
717 } | |
684 break; | 718 break; |
685 } | 719 } |
686 return true; | 720 return true; |
687 } | 721 } |
688 | 722 |
689 InspectorCSSAgent::InspectorCSSAgent(InstrumentingAgents* instrumentingAgents, I nspectorCompositeState* state, InspectorDOMAgent* domAgent, InspectorPageAgent* pageAgent) | 723 InspectorCSSAgent::InspectorCSSAgent(InstrumentingAgents* instrumentingAgents, I nspectorCompositeState* state, InspectorDOMAgent* domAgent, InspectorPageAgent* pageAgent) |
690 : InspectorBaseAgent<InspectorCSSAgent>("CSS", instrumentingAgents, state) | 724 : InspectorBaseAgent<InspectorCSSAgent>("CSS", instrumentingAgents, state) |
691 , m_frontend(0) | 725 , m_frontend(0) |
692 , m_domAgent(domAgent) | 726 , m_domAgent(domAgent) |
693 , m_pageAgent(pageAgent) | 727 , m_pageAgent(pageAgent) |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1688 documentsToChange.add(element->ownerDocument()); | 1722 documentsToChange.add(element->ownerDocument()); |
1689 } | 1723 } |
1690 | 1724 |
1691 m_nodeIdToForcedPseudoState.clear(); | 1725 m_nodeIdToForcedPseudoState.clear(); |
1692 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) | 1726 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) |
1693 (*it)->styleResolverChanged(RecalcStyleImmediately); | 1727 (*it)->styleResolverChanged(RecalcStyleImmediately); |
1694 } | 1728 } |
1695 | 1729 |
1696 } // namespace WebCore | 1730 } // namespace WebCore |
1697 | 1731 |
OLD | NEW |