Changeset 56237 in webkit
- Timestamp:
- Mar 19, 2010 6:35:09 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56236 r56237 1 2010-03-19 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: editing shorthands does not always work. 6 7 https://bugs.webkit.org/show_bug.cgi?id=36362 8 9 * inspector/InspectorDOMAgent.cpp: 10 (WebCore::InspectorDOMAgent::applyStyleText): 11 (WebCore::InspectorDOMAgent::populateObjectWithStyleProperties): 12 (WebCore::InspectorDOMAgent::shorthandValue): 13 * inspector/InspectorDOMAgent.h: 14 * inspector/front-end/StylesSidebarPane.js: 15 (WebInspector.StylePropertyTreeElement.prototype): 16 * inspector/front-end/inspector.css: 17 (.section .properties li.disabled .enabled-button): 18 * inspector/front-end/inspector.js: 19 (WebInspector.startEditing.editingCommitted): 20 1 21 2010-03-19 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> 2 22 -
trunk/WebCore/inspector/InspectorDOMAgent.cpp
r56161 r56237 795 795 int styleTextLength = styleText.length(); 796 796 797 // Create a new element to parse the user input CSS. 798 ExceptionCode ec = 0; 799 RefPtr<Element> parseElement = mainFrameDocument()->createElement("span", ec); 800 if (!ec) 801 parseElement->setAttribute("style", styleText, ec); 802 if (ec) { 803 m_frontend->didApplyStyleText(callId, false, ScriptValue::undefined(), m_frontend->newScriptArray()); 804 return; 805 } 806 807 CSSStyleDeclaration* tempStyle = parseElement->style(); 808 if ((tempStyle && tempStyle->length()) || !styleTextLength) { 797 RefPtr<CSSMutableStyleDeclaration> tempMutableStyle = CSSMutableStyleDeclaration::create(); 798 tempMutableStyle->parseDeclaration(styleText); 799 CSSStyleDeclaration* tempStyle = static_cast<CSSStyleDeclaration*>(tempMutableStyle.get()); 800 801 if (tempStyle->length() || !styleTextLength) { 809 802 ExceptionCode ec = 0; 810 803 // The input was parsable or the user deleted everything, so remove the … … 813 806 if (style->getPropertyShorthand(propertyName).isEmpty()) { 814 807 Vector<String> longhandProps = longhandProperties(style, propertyName); 815 for (unsigned i = 0; i < longhandProps.size(); ++i)808 for (unsigned i = 0; !ec && i < longhandProps.size(); ++i) 816 809 style->removeProperty(longhandProps[i], ec); 817 810 } else … … 841 834 Vector<String> changedProperties; 842 835 843 Vector<String> uniqueProperties = uniqueStyleProperties(tempStyle); 844 for (unsigned i = 0; i < uniqueProperties.size(); ++i) { 845 String name = uniqueProperties[i]; 836 for (unsigned i = 0; i < tempStyle->length(); ++i) { 837 String name = tempStyle->item(i); 846 838 String shorthand = tempStyle->getPropertyShorthand(name); 847 839 … … 852 844 String priority; 853 845 if (!shorthand.isEmpty()) { 854 value = tempStyle->getPropertyValue(shorthand);846 value = shorthandValue(tempStyle, shorthand); 855 847 priority = shorthandPriority(tempStyle, shorthand); 856 848 foundShorthands.add(shorthand); … … 1063 1055 if (!shorthand.isEmpty() && !foundShorthands.contains(shorthand)) { 1064 1056 foundShorthands.add(shorthand); 1065 shorthandValues.set(shorthand, s tyle->getPropertyValue(shorthand));1057 shorthandValues.set(shorthand, shorthandValue(style, shorthand)); 1066 1058 } 1067 1059 property.set("value", style->getPropertyValue(name)); … … 1118 1110 } 1119 1111 1120 Vector<String> InspectorDOMAgent::uniqueStyleProperties(CSSStyleDeclaration* style)1121 {1122 Vector<String> properties;1123 HashSet<String> foundProperties;1124 1125 for (unsigned i = 0; i < style->length(); ++i) {1126 String property = style->item(i);1127 if (foundProperties.contains(property))1128 continue;1129 foundProperties.add(property);1130 properties.append(property);1131 }1132 return properties;1133 }1134 1135 1112 Vector<String> InspectorDOMAgent::longhandProperties(CSSStyleDeclaration* style, const String& shorthandProperty) 1136 1113 { … … 1147 1124 1148 1125 return properties; 1126 } 1127 1128 String InspectorDOMAgent::shorthandValue(CSSStyleDeclaration* style, const String& shorthandProperty) 1129 { 1130 String value = style->getPropertyValue(shorthandProperty); 1131 if (value.isEmpty()) { 1132 // Some shorthands (like border) return a null value, so compute a shorthand value. 1133 // FIXME: remove this when http://bugs.webkit.org/show_bug.cgi?id=15823 is fixed. 1134 for (unsigned i = 0; i < style->length(); ++i) { 1135 String individualProperty = style->item(i); 1136 if (style->getPropertyShorthand(individualProperty) != shorthandProperty) 1137 continue; 1138 if (style->isPropertyImplicit(individualProperty)) 1139 continue; 1140 String individualValue = style->getPropertyValue(individualProperty); 1141 if (individualValue == "initial") 1142 continue; 1143 if (value.length()) 1144 value.append(" "); 1145 value.append(individualValue); 1146 } 1147 } 1148 return value; 1149 1149 } 1150 1150 -
trunk/WebCore/inspector/InspectorDOMAgent.h
r56107 r56237 162 162 ScriptObject buildObjectForRule(CSSStyleRule*); 163 163 ScriptObject buildObjectForStyleSheet(CSSStyleSheet*); 164 Vector<String> uniqueStyleProperties(CSSStyleDeclaration*);165 164 Vector<String> longhandProperties(CSSStyleDeclaration*, const String& shorthandProperty); 165 String shorthandValue(CSSStyleDeclaration*, const String& shorthandProperty); 166 166 String shorthandPriority(CSSStyleDeclaration*, const String& shorthandProperty); 167 167 bool ruleAffectsNode(CSSStyleRule*, Node*); -
trunk/WebCore/inspector/front-end/StylesSidebarPane.js
r56161 r56237 1381 1381 var section = this.treeOutline.section; 1382 1382 var elementsPanel = WebInspector.panels.elements; 1383 var styleTextLength = styleText.trim().length; 1383 styleText = styleText.replace(/\s/g, " ").trim(); // replace with whitespace. 1384 var styleTextLength = styleText.length; 1384 1385 if (!styleTextLength && updateInterface) { 1385 1386 if (this._newProperty) { … … 1427 1428 self.updateAll(true); 1428 1429 } 1429 InspectorBackend.applyStyleText(WebInspector.Callback.wrap(callback), this.style.id, styleText .trim(), this.name);1430 InspectorBackend.applyStyleText(WebInspector.Callback.wrap(callback), this.style.id, styleText, this.name); 1430 1431 } 1431 1432 } -
trunk/WebCore/inspector/front-end/inspector.css
r56161 r56237 1573 1573 } 1574 1574 1575 .section .properties li.disabled .enabled-button { 1576 display: block; 1577 } 1578 1575 1579 .section .properties .name, .event-properties .name { 1576 1580 color: rgb(136, 19, 145);
Note: See TracChangeset
for help on using the changeset viewer.