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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 | 544 |
545 // This method does the following preprocessing of |propertyText| with |overwrit
e| == false and |index| past the last active property: | 545 // This method does the following preprocessing of |propertyText| with |overwrit
e| == false and |index| past the last active property: |
546 // - If the last property (if present) has no closing ";", the ";" is prepended
to the current |propertyText| value. | 546 // - If the last property (if present) has no closing ";", the ";" is prepended
to the current |propertyText| value. |
547 // - A heuristic formatting is attempted to retain the style structure. | 547 // - A heuristic formatting is attempted to retain the style structure. |
548 // | 548 // |
549 // The propertyText (if not empty) is checked to be a valid style declaration (c
ontaining at least one property). If not, | 549 // The propertyText (if not empty) is checked to be a valid style declaration (c
ontaining at least one property). If not, |
550 // the method returns false (denoting an error). | 550 // the method returns false (denoting an error). |
551 bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText,
bool overwrite, String* oldText, ExceptionState& es) | 551 bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText,
bool overwrite, String* oldText, ExceptionState& es) |
552 { | 552 { |
553 ASSERT(m_parentStyleSheet); | 553 ASSERT(m_parentStyleSheet); |
554 DEFINE_STATIC_LOCAL(String, bogusPropertyName, (ASCIILiteral("-webkit-boguz-
propertee"))); | 554 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee")); |
555 | 555 |
556 if (!m_parentStyleSheet->ensureParsedDataReady()) { | 556 if (!m_parentStyleSheet->ensureParsedDataReady()) { |
557 es.throwDOMException(NotFoundError); | 557 es.throwDOMException(NotFoundError); |
558 return false; | 558 return false; |
559 } | 559 } |
560 | 560 |
561 if (!propertyText.stripWhiteSpace().isEmpty()) { | 561 if (!propertyText.stripWhiteSpace().isEmpty()) { |
562 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS
et::create(); | 562 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS
et::create(); |
563 String declarationText = propertyText + " " + bogusPropertyName + ": non
e"; | 563 String declarationText = propertyText + " " + bogusPropertyName + ": non
e"; |
564 RuleSourceDataList sourceData; | 564 RuleSourceDataList sourceData; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 continue; | 864 continue; |
865 | 865 |
866 foundProperties.add(individualProperty); | 866 foundProperties.add(individualProperty); |
867 properties.append(individualProperty); | 867 properties.append(individualProperty); |
868 } | 868 } |
869 return properties; | 869 return properties; |
870 } | 870 } |
871 | 871 |
872 NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const | 872 NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const |
873 { | 873 { |
874 DEFINE_STATIC_LOCAL(String, defaultPrefix, (ASCIILiteral(" "))); | 874 DEFINE_STATIC_LOCAL(String, defaultPrefix, (" ")); |
875 | 875 |
876 if (m_formatAcquired) | 876 if (m_formatAcquired) |
877 return m_format; | 877 return m_format; |
878 | 878 |
879 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); | 879 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); |
880 Vector<CSSPropertySourceData>* sourcePropertyData = sourceData ? &(sourceDat
a->styleSourceData->propertyData) : 0; | 880 Vector<CSSPropertySourceData>* sourcePropertyData = sourceData ? &(sourceDat
a->styleSourceData->propertyData) : 0; |
881 int propertyCount; | 881 int propertyCount; |
882 if (!sourcePropertyData || !(propertyCount = sourcePropertyData->size())) { | 882 if (!sourcePropertyData || !(propertyCount = sourcePropertyData->size())) { |
883 m_format.first = "\n"; | 883 m_format.first = "\n"; |
884 m_format.second = defaultPrefix; | 884 m_format.second = defaultPrefix; |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 | 1811 |
1812 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); | 1812 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); |
1813 RuleSourceDataList ruleSourceDataResult; | 1813 RuleSourceDataList ruleSourceDataResult; |
1814 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); | 1814 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); |
1815 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get
(), m_styleText, &handler, m_element->document()->elementSheet()->contents()); | 1815 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get
(), m_styleText, &handler, m_element->document()->elementSheet()->contents()); |
1816 return ruleSourceDataResult.first().release(); | 1816 return ruleSourceDataResult.first().release(); |
1817 } | 1817 } |
1818 | 1818 |
1819 } // namespace WebCore | 1819 } // namespace WebCore |
1820 | 1820 |
OLD | NEW |