Changeset 88950 in webkit
- Timestamp:
- Jun 15, 2011 10:02:00 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r88949 r88950 1 2011-06-15 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Serious performance regression during continuous focused element style updates 6 https://bugs.webkit.org/show_bug.cgi?id=61038 7 8 * inspector/elements/edit-dom-actions.html: 9 * inspector/elements/set-attribute.html: 10 * inspector/styles/styles-update-from-js-expected.txt: 11 * inspector/styles/styles-update-from-js.html: 12 1 13 2011-06-15 Martin Robinson <mrobinson@igalia.com> 2 14 -
trunk/LayoutTests/inspector/elements/edit-dom-actions.html
r86570 r88950 55 55 function testBody(node, done) 56 56 { 57 editNodePartAndRun(node, "webkit-html-attribute", "bar=\"edited attribute\"", done );57 editNodePartAndRun(node, "webkit-html-attribute", "bar=\"edited attribute\"", done, true); 58 58 } 59 59 }, … … 65 65 function testBody(node, done) 66 66 { 67 editNodePartAndRun(node, "webkit-html-attribute", "", done );67 editNodePartAndRun(node, "webkit-html-attribute", "", done, true); 68 68 } 69 69 }, … … 85 85 editorElement.textContent = "newattr=\"new-value\""; 86 86 editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); 87 InspectorTest. runAfterPendingDispatches(done);87 InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "updateModifiedNodes", done); 88 88 } 89 89 } … … 128 128 function step2() 129 129 { 130 130 InspectorTest.addResult("==== after ===="); 131 131 InspectorTest.dumpElementsTree(testNode); 132 132 next(); … … 142 142 } 143 143 144 function editNodePartAndRun(node, className, newValue, step2 )144 function editNodePartAndRun(node, className, newValue, step2, useSniffer) 145 145 { 146 146 var editorElement = editNodePart(node, className); 147 147 editorElement.textContent = newValue; 148 148 editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); 149 InspectorTest.runAfterPendingDispatches(step2); 149 if (useSniffer) 150 InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "updateModifiedNodes", step2); 151 else 152 InspectorTest.runAfterPendingDispatches(step2); 150 153 } 151 154 } -
trunk/LayoutTests/inspector/elements/set-attribute.html
r78576 r88950 42 42 next(); 43 43 } 44 InspectorTest.evaluateInPage("setAttribute('name', 'value')", callback); 44 InspectorTest.evaluateInPage("setAttribute('name', 'value')"); 45 InspectorTest.addSniffer(WebInspector.StylesSidebarPane.prototype, "_rebuildUpdate", callback); 45 46 }, 46 47 … … 52 53 next(); 53 54 } 54 InspectorTest.evaluateInPage("removeAttribute('name')", callback); 55 InspectorTest.evaluateInPage("removeAttribute('name')"); 56 InspectorTest.addSniffer(WebInspector.StylesSidebarPane.prototype, "_rebuildUpdate", callback); 55 57 } 56 58 ]); -
trunk/LayoutTests/inspector/styles/styles-update-from-js-expected.txt
r88337 r88950 46 46 47 47 48 Inline style invalidated 3 times 48 49 -
trunk/LayoutTests/inspector/styles/styles-update-from-js.html
r88347 r88950 24 24 { 25 25 var sniffCount = 0; 26 var inlineStyleInvalidationCount = 0; 26 27 27 28 InspectorTest.selectNodeWithId("container"); 28 29 InspectorTest.addSniffer(WebInspector.StylesSidebarPane.prototype, "_rebuildUpdate", snifferCallback, true); 30 InspectorTest.addSniffer(WebInspector.DOMDispatcher.prototype, "inlineStyleInvalidated", inlineStyleInvalidatedSniffer, true); 31 32 function inlineStyleInvalidatedSniffer() 33 { 34 inlineStyleInvalidationCount += 1; 35 } 29 36 30 37 function snifferCallback() … … 49 56 InspectorTest.addResult("Modified parsed attributes"); 50 57 dumpAttributeAndStyles(); 58 InspectorTest.addResult("Inline style invalidated " + inlineStyleInvalidationCount + " times"); 51 59 InspectorTest.completeTest(); 52 60 break; -
trunk/Source/WebCore/ChangeLog
r88948 r88950 1 2011-06-15 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Serious performance regression during continuous focused element style updates 6 https://bugs.webkit.org/show_bug.cgi?id=61038 7 8 Inline style invalidation events are coalesced in the backend and sent over the wire on timer. 9 10 * inspector/Inspector.json: 11 * inspector/InspectorDOMAgent.cpp: 12 (WebCore::RevalidateStyleAttributeTask::onTimer): 13 (WebCore::InspectorDOMAgent::getAttributes): 14 (WebCore::InspectorDOMAgent::didModifyDOMAttr): 15 (WebCore::InspectorDOMAgent::styleAttributeInvalidated): 16 * inspector/InspectorDOMAgent.h: 17 * inspector/InspectorStyleSheet.cpp: 18 (WebCore::InspectorStyleSheetForInlineStyle::didModifyElementAttribute): 19 (WebCore::InspectorStyleSheetForInlineStyle::text): 20 (WebCore::InspectorStyleSheetForInlineStyle::setStyleText): 21 (WebCore::InspectorStyleSheetForInlineStyle::ensureParsedDataReady): 22 (WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges): 23 * inspector/InspectorStyleSheet.h: 24 * inspector/front-end/DOMAgent.js: 25 (WebInspector.DOMAgent): 26 (WebInspector.DOMAgent.prototype._attributesUpdated): 27 (WebInspector.DOMAgent.prototype._loadNodeAttributesSoon): 28 (WebInspector.DOMAgent.prototype._loadNodeAttributes): 29 (WebInspector.DOMDispatcher.prototype.attributesUpdated): 30 (WebInspector.DOMDispatcher.prototype.inlineStyleInvalidated): 31 1 32 2011-06-15 Jer Noble <jer.noble@apple.com> 2 33 -
trunk/Source/WebCore/inspector/Inspector.json
r88943 r88950 783 783 ], 784 784 "description": "DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type." 785 }, 786 { 787 "id": "Attributes", 788 "type": "object", 789 "properties": [ 790 { "name": "id", "type": "integer", "description": "Element id to get attributes for." }, 791 { "name": "attributes", "type": "array", "items": { "type": "string" }, "description": "An interleaved array of node attribute names and values." } 792 ], 793 "description": "A holder structure for all attributes of a single node." 785 794 } 786 795 ], … … 974 983 ], 975 984 "description": "Resolves JavaScript node object for given node id." 985 }, 986 { 987 "name": "getAttributes", 988 "parameters": [ 989 { "name": "nodeIds", "type": "array", "items": { "type": "integer" }, "description": "Ids of the nodes to retrieve attibutes for." } 990 ], 991 "returns": [ 992 { "name": "attributes", "type": "array", "items": { "type": "Attributes" }, "description": "Attribute holders for the requested nodes." } 993 ], 994 "description": "Returns attributes for the specified nodes." 976 995 } 977 996 ], … … 992 1011 "name": "attributesUpdated", 993 1012 "parameters": [ 994 { "name": "id", "type": "integer", "description": "Id of the node that has changed." }, 995 { "name": "attributes", "type": "array", "items": { "$ref": "DOMAttribute"}, "description": "New attributes value." } 1013 { "name": "nodeId", "type": "integer", "description": "Id of the node that has changed." } 996 1014 ], 997 1015 "description": "Fired when <code>Element</code>'s attributes are updated." 1016 }, 1017 { 1018 "name": "inlineStyleInvalidated", 1019 "parameters": [ 1020 { "name": "nodeIds", "type": "array", "items": { "type": "integer" }, "description": "Ids of the nodes for which the inline styles have been invalidated." } 1021 ], 1022 "description": "Fired when <code>Element</code>'s inline style is modified via a CSS property modification." 998 1023 }, 999 1024 { -
trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp
r88331 r88950 250 250 { 251 251 // The timer is stopped on m_domAgent destruction, so this method will never be called after m_domAgent has been destroyed. 252 Vector<Element*> elements; 252 253 for (HashSet<RefPtr<Element> >::iterator it = m_elements.begin(), end = m_elements.end(); it != end; ++it) 253 m_domAgent->didModifyDOMAttr(it->get()); 254 elements.append(it->get()); 255 m_domAgent->styleAttributeInvalidated(elements); 254 256 255 257 m_elements.clear(); … … 1021 1023 } 1022 1024 *result = resolveNode(node); 1025 } 1026 1027 void InspectorDOMAgent::getAttributes(ErrorString*, const RefPtr<InspectorArray>& nodeIds, RefPtr<InspectorArray>* result) 1028 { 1029 for (unsigned i = 0, size = nodeIds->length(); i < size; ++i) { 1030 RefPtr<InspectorValue> nodeIdValue = nodeIds->get(i); 1031 int nodeId; 1032 if (!nodeIdValue->asNumber(&nodeId)) 1033 continue; 1034 Node* node = nodeForId(nodeId); 1035 if (node && node->isElementNode()) { 1036 RefPtr<InspectorObject> entry = InspectorObject::create(); 1037 entry->setNumber("id", nodeId); 1038 entry->setArray("attributes", buildArrayForElementAttributes(static_cast<Element*>(node))); 1039 (*result)->pushObject(entry.release()); 1040 } 1041 } 1023 1042 } 1024 1043 … … 1303 1322 void InspectorDOMAgent::didModifyDOMAttr(Element* element) 1304 1323 { 1305 int id = m_documentNodeToIdMap.get(element);1324 int id = boundNodeId(element); 1306 1325 // If node is not mapped yet -> ignore the event. 1307 1326 if (!id) … … 1311 1330 m_domListener->didModifyDOMAttr(element); 1312 1331 1313 m_frontend->attributesUpdated(id, buildArrayForElementAttributes(element)); 1332 m_frontend->attributesUpdated(id); 1333 } 1334 1335 void InspectorDOMAgent::styleAttributeInvalidated(const Vector<Element*>& elements) 1336 { 1337 RefPtr<InspectorArray> nodeIds = InspectorArray::create(); 1338 for (unsigned i = 0, size = elements.size(); i < size; ++i) { 1339 Element* element = elements.at(i); 1340 int id = boundNodeId(element); 1341 // If node is not mapped yet -> ignore the event. 1342 if (!id) 1343 continue; 1344 1345 if (m_domListener) 1346 m_domListener->didModifyDOMAttr(element); 1347 nodeIds->pushNumber(id); 1348 } 1349 m_frontend->inlineStyleInvalidated(nodeIds.release()); 1314 1350 } 1315 1351 -
trunk/Source/WebCore/inspector/InspectorDOMAgent.h
r88331 r88950 127 127 void cancelSearch(ErrorString*); 128 128 void resolveNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* result); 129 void getAttributes(ErrorString*, const RefPtr<InspectorArray>& nodeIds, RefPtr<InspectorArray>* result); 129 130 void setInspectModeEnabled(ErrorString*, bool enabled); 130 131 void pushNodeToFrontend(ErrorString*, const String& objectId, int* nodeId); … … 147 148 void didRemoveDOMNode(Node*); 148 149 void didModifyDOMAttr(Element*); 150 void styleAttributeInvalidated(const Vector<Element*>& elements); 149 151 void characterDataModified(CharacterData*); 150 152 void didInvalidateStyleAttr(Node*); -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r85603 r88950 1185 1185 void InspectorStyleSheetForInlineStyle::didModifyElementAttribute() 1186 1186 { 1187 String newStyleText = elementStyleText(); 1188 bool shouldDropSourceData = false; 1189 if (m_element->isStyledElement() && m_element->style() != m_inspectorStyle->cssStyle()) { 1187 m_isStyleTextValid = false; 1188 if (m_element->isStyledElement() && m_element->style() != m_inspectorStyle->cssStyle()) 1190 1189 m_inspectorStyle = InspectorStyle::create(InspectorCSSId(id(), 0), inlineStyle(), this); 1191 shouldDropSourceData = true; 1192 } 1193 if (newStyleText != m_styleText) { 1194 m_styleText = newStyleText; 1195 shouldDropSourceData = true; 1196 } 1197 if (shouldDropSourceData) 1198 m_ruleSourceData.clear(); 1190 m_ruleSourceData.clear(); 1199 1191 } 1200 1192 1201 1193 bool InspectorStyleSheetForInlineStyle::text(String* result) const 1202 1194 { 1195 if (!m_isStyleTextValid) { 1196 m_styleText = elementStyleText(); 1197 m_isStyleTextValid = true; 1198 } 1203 1199 *result = m_styleText; 1204 1200 return true; … … 1211 1207 m_element->setAttribute("style", text, ec); 1212 1208 m_styleText = text; 1209 m_isStyleTextValid = true; 1213 1210 m_ruleSourceData.clear(); 1214 1211 return !ec; … … 1227 1224 m_ruleSourceData.clear(); 1228 1225 m_styleText = currentStyleText; 1226 m_isStyleTextValid = true; 1229 1227 } 1230 1228 … … 1258 1256 } 1259 1257 1260 bool InspectorStyleSheetForInlineStyle::getStyleAttributeRanges(RefPtr<CSSStyleSourceData>* result) 1258 bool InspectorStyleSheetForInlineStyle::getStyleAttributeRanges(RefPtr<CSSStyleSourceData>* result) const 1261 1259 { 1262 1260 if (!m_element->isStyledElement()) -
trunk/Source/WebCore/inspector/InspectorStyleSheet.h
r84148 r88950 248 248 CSSStyleDeclaration* inlineStyle() const; 249 249 const String& elementStyleText() const; 250 bool getStyleAttributeRanges(RefPtr<CSSStyleSourceData>* result) ;250 bool getStyleAttributeRanges(RefPtr<CSSStyleSourceData>* result) const; 251 251 252 252 RefPtr<Element> m_element; … … 254 254 RefPtr<InspectorStyle> m_inspectorStyle; 255 255 256 // Contains "style" attribute value and should always be up-to-date. 257 String m_styleText; 256 // Contains "style" attribute value. 257 mutable String m_styleText; 258 mutable bool m_isStyleTextValid; 258 259 }; 259 260 -
trunk/Source/WebCore/inspector/front-end/DOMAgent.js
r88331 r88950 326 326 this._idToDOMNode = null; 327 327 this._document = null; 328 this._attributeLoadNodeIds = {}; 328 329 InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatcher(this)); 329 330 } … … 414 415 }, 415 416 416 _attributesUpdated: function(nodeId, attrsArray) 417 { 418 var node = this._idToDOMNode[nodeId]; 419 node._setAttributesPayload(attrsArray); 420 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrModified, node); 417 _attributesUpdated: function(nodeIds) 418 { 419 this._loadNodeAttributesSoon(nodeIds); 420 }, 421 422 _loadNodeAttributesSoon: function(nodeIds) 423 { 424 for (var i = 0; i < nodeIds.length; ++i) 425 this._attributeLoadNodeIds[nodeIds[i]] = true; 426 if ("_loadNodeAttributesTimeout" in this) 427 return; 428 this._loadNodeAttributesTimeout = setTimeout(this._loadNodeAttributes.bind(this), 0); 429 }, 430 431 _loadNodeAttributes: function() 432 { 433 function callback(nodeAttributes) 434 { 435 if (!nodeAttributes) 436 return; 437 for (var i = 0; i < nodeAttributes.length; ++i) { 438 var entry = nodeAttributes[i]; 439 var node = this._idToDOMNode[entry.id]; 440 node._setAttributesPayload(entry.attributes); 441 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrModified, node); 442 } 443 } 444 445 delete this._loadNodeAttributesTimeout; 446 447 var nodeIds = []; 448 for (var nodeId in this._attributeLoadNodeIds) 449 nodeIds.push(Number(nodeId)); 450 DOMAgent.getAttributes(nodeIds, this._wrapClientCallback(callback.bind(this))); 451 this._attributeLoadNodeIds = {}; 421 452 }, 422 453 … … 543 574 }, 544 575 545 attributesUpdated: function(nodeId, attrsArray) 546 { 547 this._domAgent._attributesUpdated(nodeId, attrsArray); 576 attributesUpdated: function(nodeId) 577 { 578 this._domAgent._attributesUpdated([nodeId]); 579 }, 580 581 inlineStyleInvalidated: function(nodeIds) 582 { 583 this._domAgent._attributesUpdated(nodeIds); 548 584 }, 549 585
Note: See TracChangeset
for help on using the changeset viewer.