| 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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 if (!builder.isEmpty()) | 734 if (!builder.isEmpty()) |
| 735 builder.append(" "); | 735 builder.append(" "); |
| 736 builder.append(individualValue); | 736 builder.append(individualValue); |
| 737 } | 737 } |
| 738 | 738 |
| 739 return builder.toString(); | 739 return builder.toString(); |
| 740 } | 740 } |
| 741 return value; | 741 return value; |
| 742 } | 742 } |
| 743 | 743 |
| 744 String InspectorStyle::shorthandPriority(const String& shorthandProperty) const | |
| 745 { | |
| 746 String priority = m_style->getPropertyPriority(shorthandProperty); | |
| 747 if (priority.isEmpty()) { | |
| 748 for (unsigned i = 0; i < m_style->length(); ++i) { | |
| 749 String individualProperty = m_style->item(i); | |
| 750 if (m_style->getPropertyShorthand(individualProperty) != shorthandPr
operty) | |
| 751 continue; | |
| 752 priority = m_style->getPropertyPriority(individualProperty); | |
| 753 break; | |
| 754 } | |
| 755 } | |
| 756 return priority; | |
| 757 } | |
| 758 | |
| 759 Vector<String> InspectorStyle::longhandProperties(const String& shorthandPropert
y) const | |
| 760 { | |
| 761 Vector<String> properties; | |
| 762 HashSet<String> foundProperties; | |
| 763 for (unsigned i = 0; i < m_style->length(); ++i) { | |
| 764 String individualProperty = m_style->item(i); | |
| 765 if (foundProperties.contains(individualProperty) || m_style->getProperty
Shorthand(individualProperty) != shorthandProperty) | |
| 766 continue; | |
| 767 | |
| 768 foundProperties.add(individualProperty); | |
| 769 properties.append(individualProperty); | |
| 770 } | |
| 771 return properties; | |
| 772 } | |
| 773 | |
| 774 NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const | 744 NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const |
| 775 { | 745 { |
| 776 DEFINE_STATIC_LOCAL(String, defaultPrefix, (" ")); | 746 DEFINE_STATIC_LOCAL(String, defaultPrefix, (" ")); |
| 777 | 747 |
| 778 if (m_formatAcquired) | 748 if (m_formatAcquired) |
| 779 return m_format; | 749 return m_format; |
| 780 | 750 |
| 781 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); | 751 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); |
| 782 Vector<CSSPropertySourceData>* sourcePropertyData = sourceData ? &(sourceDat
a->styleSourceData->propertyData) : 0; | 752 Vector<CSSPropertySourceData>* sourcePropertyData = sourceData ? &(sourceDat
a->styleSourceData->propertyData) : 0; |
| 783 int propertyCount; | 753 int propertyCount; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 } | 851 } |
| 882 } | 852 } |
| 883 | 853 |
| 884 InspectorStyleSheet::InspectorStyleSheet(InspectorPageAgent* pageAgent, Inspecto
rResourceAgent* resourceAgent, const String& id, PassRefPtr<CSSStyleSheet> pageS
tyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& docume
ntURL, Listener* listener) | 854 InspectorStyleSheet::InspectorStyleSheet(InspectorPageAgent* pageAgent, Inspecto
rResourceAgent* resourceAgent, const String& id, PassRefPtr<CSSStyleSheet> pageS
tyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& docume
ntURL, Listener* listener) |
| 885 : m_pageAgent(pageAgent) | 855 : m_pageAgent(pageAgent) |
| 886 , m_resourceAgent(resourceAgent) | 856 , m_resourceAgent(resourceAgent) |
| 887 , m_id(id) | 857 , m_id(id) |
| 888 , m_pageStyleSheet(pageStyleSheet) | 858 , m_pageStyleSheet(pageStyleSheet) |
| 889 , m_origin(origin) | 859 , m_origin(origin) |
| 890 , m_documentURL(documentURL) | 860 , m_documentURL(documentURL) |
| 891 , m_isRevalidating(false) | |
| 892 , m_listener(listener) | 861 , m_listener(listener) |
| 893 { | 862 { |
| 894 m_parsedStyleSheet = new ParsedStyleSheet(); | 863 m_parsedStyleSheet = new ParsedStyleSheet(); |
| 895 } | 864 } |
| 896 | 865 |
| 897 InspectorStyleSheet::~InspectorStyleSheet() | 866 InspectorStyleSheet::~InspectorStyleSheet() |
| 898 { | 867 { |
| 899 delete m_parsedStyleSheet; | 868 delete m_parsedStyleSheet; |
| 900 } | 869 } |
| 901 | 870 |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 text.replace(bodyStart, bodyEnd - bodyStart, newStyleText); | 1473 text.replace(bodyStart, bodyEnd - bodyStart, newStyleText); |
| 1505 *result = text; | 1474 *result = text; |
| 1506 return true; | 1475 return true; |
| 1507 } | 1476 } |
| 1508 | 1477 |
| 1509 InspectorCSSId InspectorStyleSheet::ruleId(CSSStyleRule* rule) const | 1478 InspectorCSSId InspectorStyleSheet::ruleId(CSSStyleRule* rule) const |
| 1510 { | 1479 { |
| 1511 return ruleOrStyleId(rule->style()); | 1480 return ruleOrStyleId(rule->style()); |
| 1512 } | 1481 } |
| 1513 | 1482 |
| 1514 void InspectorStyleSheet::revalidateStyle(CSSStyleDeclaration* pageStyle) | |
| 1515 { | |
| 1516 if (m_isRevalidating) | |
| 1517 return; | |
| 1518 | |
| 1519 m_isRevalidating = true; | |
| 1520 ensureFlatRules(); | |
| 1521 for (unsigned i = 0, size = m_flatRules.size(); i < size; ++i) { | |
| 1522 CSSStyleRule* parsedRule = InspectorCSSAgent::asCSSStyleRule(m_flatRules
.at(i).get()); | |
| 1523 if (parsedRule && parsedRule->style() == pageStyle) { | |
| 1524 if (parsedRule->styleRule()->properties().asText() != pageStyle->css
Text()) | |
| 1525 setStyleText(pageStyle, pageStyle->cssText()); | |
| 1526 break; | |
| 1527 } | |
| 1528 } | |
| 1529 m_isRevalidating = false; | |
| 1530 } | |
| 1531 | |
| 1532 bool InspectorStyleSheet::originalStyleSheetText(String* result) const | 1483 bool InspectorStyleSheet::originalStyleSheetText(String* result) const |
| 1533 { | 1484 { |
| 1534 bool success = inlineStyleSheetText(result); | 1485 bool success = inlineStyleSheetText(result); |
| 1535 if (!success) | 1486 if (!success) |
| 1536 success = resourceStyleSheetText(result); | 1487 success = resourceStyleSheetText(result); |
| 1537 return success; | 1488 return success; |
| 1538 } | 1489 } |
| 1539 | 1490 |
| 1540 bool InspectorStyleSheet::resourceStyleSheetText(String* result) const | 1491 bool InspectorStyleSheet::resourceStyleSheetText(String* result) const |
| 1541 { | 1492 { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 | 1644 |
| 1694 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); | 1645 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); |
| 1695 RuleSourceDataList ruleSourceDataResult; | 1646 RuleSourceDataList ruleSourceDataResult; |
| 1696 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet().contents(), &ruleSourceDataResult); | 1647 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet().contents(), &ruleSourceDataResult); |
| 1697 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet().contents()); | 1648 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet().contents()); |
| 1698 return ruleSourceDataResult.first().release(); | 1649 return ruleSourceDataResult.first().release(); |
| 1699 } | 1650 } |
| 1700 | 1651 |
| 1701 } // namespace WebCore | 1652 } // namespace WebCore |
| 1702 | 1653 |
| OLD | NEW |