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 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1883 if (!foundStyle) | 1883 if (!foundStyle) |
1884 foundStyle = style; | 1884 foundStyle = style; |
1885 } | 1885 } |
1886 | 1886 |
1887 return foundStyle ? foundStyle : styles.at(0).get(); | 1887 return foundStyle ? foundStyle : styles.at(0).get(); |
1888 } | 1888 } |
1889 | 1889 |
1890 void InspectorCSSAgent::setLayoutEditorValue(ErrorString* errorString, Element*
element, CSSStyleDeclaration* style, CSSPropertyID propertyId, const String& val
ue, bool forceImportant) | 1890 void InspectorCSSAgent::setLayoutEditorValue(ErrorString* errorString, Element*
element, CSSStyleDeclaration* style, CSSPropertyID propertyId, const String& val
ue, bool forceImportant) |
1891 { | 1891 { |
1892 InspectorStyleSheetBase* inspectorStyleSheet = nullptr; | 1892 InspectorStyleSheetBase* inspectorStyleSheet = nullptr; |
1893 CSSRuleSourceData* sourceData = nullptr; | 1893 RefPtr<CSSRuleSourceData> sourceData; |
1894 // An absence of the parent rule means that given style is an inline style. | 1894 // An absence of the parent rule means that given style is an inline style. |
1895 if (style->parentRule()) { | 1895 if (style->parentRule()) { |
1896 InspectorStyleSheet* styleSheet = bindStyleSheet(style->parentStyleSheet
()); | 1896 InspectorStyleSheet* styleSheet = bindStyleSheet(style->parentStyleSheet
()); |
1897 inspectorStyleSheet = styleSheet; | 1897 inspectorStyleSheet = styleSheet; |
1898 sourceData = styleSheet->sourceDataForRule(style->parentRule()); | 1898 sourceData = styleSheet->sourceDataForRule(style->parentRule()); |
1899 } else { | 1899 } else { |
1900 InspectorStyleSheetForInlineStyle* inlineStyleSheet = asInspectorStyleSh
eet(element); | 1900 InspectorStyleSheetForInlineStyle* inlineStyleSheet = asInspectorStyleSh
eet(element); |
1901 inspectorStyleSheet = inlineStyleSheet; | 1901 inspectorStyleSheet = inlineStyleSheet; |
1902 sourceData = inlineStyleSheet->ruleSourceData(); | 1902 sourceData = inlineStyleSheet->ruleSourceData(); |
1903 } | 1903 } |
1904 | 1904 |
1905 if (!sourceData) { | 1905 if (!sourceData) { |
1906 *errorString = "Can't find a source to edit"; | 1906 *errorString = "Can't find a source to edit"; |
1907 return; | 1907 return; |
1908 } | 1908 } |
1909 | 1909 |
1910 Vector<StylePropertyShorthand, 4> shorthands; | 1910 Vector<StylePropertyShorthand, 4> shorthands; |
1911 getMatchingShorthandsForLonghand(propertyId, &shorthands); | 1911 getMatchingShorthandsForLonghand(propertyId, &shorthands); |
1912 | 1912 |
1913 String shorthand = shorthands.size() > 0 ? getPropertyNameString(shorthands
[0].id()) : String(); | 1913 String shorthand = shorthands.size() > 0 ? getPropertyNameString(shorthands
[0].id()) : String(); |
1914 String longhand = getPropertyNameString(propertyId); | 1914 String longhand = getPropertyNameString(propertyId); |
1915 | 1915 |
1916 int foundIndex = -1; | 1916 int foundIndex = -1; |
1917 HeapVector<CSSPropertySourceData> properties = sourceData->styleSourceData->
propertyData; | 1917 Vector<CSSPropertySourceData> properties = sourceData->styleSourceData->prop
ertyData; |
1918 for (unsigned i = 0; i < properties.size(); ++i) { | 1918 for (unsigned i = 0; i < properties.size(); ++i) { |
1919 CSSPropertySourceData property = properties[properties.size() - i - 1]; | 1919 CSSPropertySourceData property = properties[properties.size() - i - 1]; |
1920 String name = property.name; | 1920 String name = property.name; |
1921 if (property.disabled) | 1921 if (property.disabled) |
1922 continue; | 1922 continue; |
1923 | 1923 |
1924 if (name != shorthand && name != longhand) | 1924 if (name != shorthand && name != longhand) |
1925 continue; | 1925 continue; |
1926 | 1926 |
1927 if (property.important || foundIndex == -1) | 1927 if (property.important || foundIndex == -1) |
(...skipping 29 matching lines...) Expand all Loading... |
1957 changeRange.end = changeRange.start + newPropertyText.length(); | 1957 changeRange.end = changeRange.start + newPropertyText.length(); |
1958 } | 1958 } |
1959 CSSStyleDeclaration* resultStyle = setStyleText(errorString, inspectorStyleS
heet, bodyRange, styleText); | 1959 CSSStyleDeclaration* resultStyle = setStyleText(errorString, inspectorStyleS
heet, bodyRange, styleText); |
1960 if (resultStyle) | 1960 if (resultStyle) |
1961 frontend()->layoutEditorChange(inspectorStyleSheet->id(), inspectorStyle
Sheet->buildSourceRangeObject(changeRange)); | 1961 frontend()->layoutEditorChange(inspectorStyleSheet->id(), inspectorStyle
Sheet->buildSourceRangeObject(changeRange)); |
1962 } | 1962 } |
1963 | 1963 |
1964 void InspectorCSSAgent::layoutEditorItemSelected(Element* element, CSSStyleDecla
ration* style) | 1964 void InspectorCSSAgent::layoutEditorItemSelected(Element* element, CSSStyleDecla
ration* style) |
1965 { | 1965 { |
1966 InspectorStyleSheetBase* inspectorStyleSheet = nullptr; | 1966 InspectorStyleSheetBase* inspectorStyleSheet = nullptr; |
1967 CSSRuleSourceData* sourceData = nullptr; | 1967 RefPtr<CSSRuleSourceData> sourceData; |
1968 if (style->parentRule()) { | 1968 if (style->parentRule()) { |
1969 InspectorStyleSheet* styleSheet = bindStyleSheet(style->parentStyleSheet
()); | 1969 InspectorStyleSheet* styleSheet = bindStyleSheet(style->parentStyleSheet
()); |
1970 inspectorStyleSheet = styleSheet; | 1970 inspectorStyleSheet = styleSheet; |
1971 sourceData = styleSheet->sourceDataForRule(style->parentRule()); | 1971 sourceData = styleSheet->sourceDataForRule(style->parentRule()); |
1972 } else { | 1972 } else { |
1973 InspectorStyleSheetForInlineStyle* inlineStyleSheet = asInspectorStyleSh
eet(element); | 1973 InspectorStyleSheetForInlineStyle* inlineStyleSheet = asInspectorStyleSh
eet(element); |
1974 inspectorStyleSheet = inlineStyleSheet; | 1974 inspectorStyleSheet = inlineStyleSheet; |
1975 sourceData = inlineStyleSheet->ruleSourceData(); | 1975 sourceData = inlineStyleSheet->ruleSourceData(); |
1976 } | 1976 } |
1977 | 1977 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2072 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); | 2072 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); |
2073 visitor->trace(m_documentToCSSStyleSheets); | 2073 visitor->trace(m_documentToCSSStyleSheets); |
2074 visitor->trace(m_invalidatedDocuments); | 2074 visitor->trace(m_invalidatedDocuments); |
2075 visitor->trace(m_nodeToInspectorStyleSheet); | 2075 visitor->trace(m_nodeToInspectorStyleSheet); |
2076 visitor->trace(m_documentToViaInspectorStyleSheet); | 2076 visitor->trace(m_documentToViaInspectorStyleSheet); |
2077 visitor->trace(m_inspectorUserAgentStyleSheet); | 2077 visitor->trace(m_inspectorUserAgentStyleSheet); |
2078 InspectorBaseAgent::trace(visitor); | 2078 InspectorBaseAgent::trace(visitor); |
2079 } | 2079 } |
2080 | 2080 |
2081 } // namespace blink | 2081 } // namespace blink |
OLD | NEW |