Changeset 128291 in webkit
- Timestamp:
- Sep 12, 2012 4:36:15 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r128288 r128291 1 2012-09-12 Alexander Pavlov <apavlov@chromium.org> 2 3 Web Inspector: [Elements] Sidebar panes not updated on style changes due to "class" attribute modifications 4 https://bugs.webkit.org/show_bug.cgi?id=95722 5 6 Reviewed by Vsevolod Vlasov. 7 8 * inspector/elements/edit-style-attribute.html: Renamed events on which to listen. 9 * inspector/styles/override-screen-size.html: Drive-by: fixed race condition that was resulting in this test's failures. 10 * inspector/styles/styles-update-from-js-expected.txt: 11 * inspector/styles/styles-update-from-js.html: Added test cases for style updates on ancestor and sibling attributes' changes. 12 1 13 2012-09-12 Csaba Osztrogonác <ossy@webkit.org> 2 14 -
trunk/LayoutTests/inspector/elements/edit-style-attribute-expected.txt
r112668 r128291 5 5 6 6 Running: testSetNewValue 7 WebInspector.DOMAgent.Events. StyleInvalidated should be issued7 WebInspector.DOMAgent.Events.AttrModified should be issued 8 8 9 9 Running: testSetSameValue -
trunk/LayoutTests/inspector/elements/edit-style-attribute.html
r126589 r128291 32 32 InspectorTest.evaluateInPage("testSetNewValue()"); 33 33 34 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events. StyleInvalidated, listener);34 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModified, listener); 35 35 function listener(event) 36 36 { 37 InspectorTest.addResult("WebInspector.DOMAgent.Events. StyleInvalidated should be issued");38 WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events. StyleInvalidated, listener);37 InspectorTest.addResult("WebInspector.DOMAgent.Events.AttrModified should be issued"); 38 WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events.AttrModified, listener); 39 39 next(); 40 40 } … … 45 45 InspectorTest.evaluateInPage("testSetSameValue()"); 46 46 47 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events. StyleInvalidated, listener);47 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModified, listener); 48 48 function listener(event) 49 49 { 50 InspectorTest.addResult("WebInspector.DOMAgent.Events. StyleInvalidated should not be issued");51 WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events. StyleInvalidated, listener);50 InspectorTest.addResult("WebInspector.DOMAgent.Events.AttrModified should not be issued"); 51 WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events.AttrModified, listener); 52 52 } 53 53 … … 56 56 { 57 57 InspectorTest.addResult("WebInspector.DOMNode.prototype._setAttributesPayload should be called"); 58 WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events. StyleInvalidated, listener);58 WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events.AttrModified, listener); 59 59 next(); 60 60 } -
trunk/LayoutTests/inspector/styles/override-screen-size.html
r113709 r128291 159 159 function overrideAndDumpData(width, height, callback) 160 160 { 161 function selectCallback()161 function finalCallback() 162 162 { 163 163 InspectorTest.addResult("Main style:"); … … 166 166 } 167 167 168 var gotSizes; 169 var gotStyles; 170 function stylesCallback() 171 { 172 if (gotSizes) 173 return finalCallback(); 174 gotStyles = true; 175 } 176 177 function sizesCallback() 178 { 179 gotSizes = true; 180 if (gotStyles) 181 finalCallback(); 182 } 183 168 184 function applyCallback() 169 185 { 170 getAndDumpSizes(s electCallback);186 getAndDumpSizes(sizesCallback); 171 187 } 172 188 173 189 InspectorTest.addResult("Override: " + width + "x" + height); 190 InspectorTest.waitForStyles("main", stylesCallback); 174 191 applyOverride(width, height, applyCallback); 175 192 } … … 183 200 InspectorTest.addResult("Window from page: " + result.inner); 184 201 InspectorTest.addResult("Body from page: " + result.body); 185 callback(); 202 if (callback) 203 callback(); 186 204 } 187 205 -
trunk/LayoutTests/inspector/styles/styles-update-from-js-expected.txt
r126656 r128291 1 Tests that changes to an inline style from JavaScript are reflected in the Styles pane and Elements tree.1 Tests that changes to an inline style and ancestor/sibling className from JavaScript are reflected in the Styles pane and Elements tree. 2 2 3 3 … … 5 5 6 6 Running: testSetStyleAttribute 7 <div id="container" style="color: #daC0DE; border: 1px solid black;"> </div>7 <div id="container" style="color: #daC0DE; border: 1px solid black;">…</div> 8 8 [expanded] 9 9 element.style { () … … 23 23 border-left-width: 1px; 24 24 25 ======== Matched CSS Rules ======== 26 [expanded] 27 div { (user agent stylesheet) 28 display: block; 29 25 30 26 31 27 32 Running: testSetStyleCSSText 28 <div id="container" style="color: rgb(192, 255, 238);"> </div>33 <div id="container" style="color: rgb(192, 255, 238);">…</div> 29 34 [expanded] 30 35 element.style { () 31 36 color: #C0FFEE; 32 37 38 ======== Matched CSS Rules ======== 39 [expanded] 40 div { (user agent stylesheet) 41 display: block; 42 33 43 34 44 35 45 Running: testSetViaParsedAttributes 36 <div id="container" style="color: rgb(192, 255, 238); border: 3px dashed green;"> </div>46 <div id="container" style="color: rgb(192, 255, 238); border: 3px dashed green;">…</div> 37 47 [expanded] 38 48 element.style { () … … 52 62 border-left-width: 3px; 53 63 64 ======== Matched CSS Rules ======== 65 [expanded] 66 div { (user agent stylesheet) 67 display: block; 54 68 55 69 70 71 Running: testSetViaAncestorClass 72 <div id="child"></div> 73 [expanded] 74 element.style { () 75 76 ======== Matched CSS Rules ======== 77 [expanded] 78 .red div:first-child { (styles-update-from-js.html:4) 79 background-color: red; 80 81 [expanded] 82 div { (user agent stylesheet) 83 display: block; 84 85 ======== Inherited from div#container.red ======== 86 [expanded] 87 Style Attribute { () 88 color: #C0FFEE; 89 90 91 92 Running: testSetViaSiblingAttr 93 <div id="childSibling"></div> 94 [expanded] 95 element.style { () 96 97 ======== Matched CSS Rules ======== 98 [expanded] 99 div[foo="bar"] + div { (styles-update-from-js.html:8) 100 background-color: blue; 101 102 [expanded] 103 div { (user agent stylesheet) 104 display: block; 105 106 ======== Inherited from div#container.red ======== 107 [expanded] 108 Style Attribute { () 109 color: #C0FFEE; 110 111 112 -
trunk/LayoutTests/inspector/styles/styles-update-from-js.html
r125014 r128291 1 1 <html> 2 2 <head> 3 <style> 4 .red div:first-child { 5 background-color: red; 6 } 7 8 div[foo="bar"] + div { 9 background-color: blue; 10 } 11 12 </style> 3 13 <script src="../../http/tests/inspector/inspector-test.js"></script> 4 14 <script src="../../http/tests/inspector/elements-test.js"></script> … … 19 29 style.border = "2px dashed green"; 20 30 style.borderWidth = "3px"; 31 } 32 33 function modifyContainerClass() 34 { 35 document.getElementById("container").className = "red"; 36 } 37 38 function modifyChildAttr() 39 { 40 document.getElementById("child").setAttribute("foo", "bar"); 21 41 } 22 42 … … 45 65 waitAndDumpAttributeAndStyles(next); 46 66 InspectorTest.evaluateInPage("modifyParsedAttributes()"); 67 }, 68 69 function testSetViaAncestorClass(next) 70 { 71 InspectorTest.selectNodeAndWaitForStyles("child", callback); 72 73 function callback() 74 { 75 waitAndDumpAttributeAndStyles(next, "child"); 76 InspectorTest.evaluateInPage("modifyContainerClass()"); 77 } 78 }, 79 80 function testSetViaSiblingAttr(next) 81 { 82 InspectorTest.selectNodeAndWaitForStyles("childSibling", callback); 83 84 function callback() 85 { 86 waitAndDumpAttributeAndStyles(next, "childSibling"); 87 InspectorTest.evaluateInPage("modifyChildAttr()"); 88 } 47 89 } 48 90 ]); 49 91 50 function waitAndDumpAttributeAndStyles(next )92 function waitAndDumpAttributeAndStyles(next, id) 51 93 { 94 id = id || "container"; 52 95 function callback() 53 96 { 54 dumpAttributeAndStyles( );97 dumpAttributeAndStyles(id); 55 98 next(); 56 99 } 57 InspectorTest.waitForStyles( "container", callback);100 InspectorTest.waitForStyles(id, callback); 58 101 } 59 102 60 function dumpAttributeAndStyles( )103 function dumpAttributeAndStyles(id) 61 104 { 62 var treeElement = findNodeTreeElement( )105 var treeElement = findNodeTreeElement(id); 63 106 if (!treeElement) { 64 InspectorTest.addResult("' container' tree element not found");107 InspectorTest.addResult("'" + id + "' tree element not found"); 65 108 return; 66 109 } 67 110 InspectorTest.addResult(treeElement.listItemElement.textContent.replace(/\u200b/g, "")); 68 InspectorTest.dumpSelectedElementStyles(true , true);111 InspectorTest.dumpSelectedElementStyles(true); 69 112 } 70 113 71 function findNodeTreeElement( )114 function findNodeTreeElement(id) 72 115 { 73 116 WebInspector.panels.elements.treeOutline._updateModifiedNodes(); 74 var expandedNode = InspectorTest.expandedNodeWithId( "container");117 var expandedNode = InspectorTest.expandedNodeWithId(id); 75 118 if (!expandedNode) { 76 InspectorTest.addResult("' container' node not found");119 InspectorTest.addResult("'" + id + "' node not found"); 77 120 InspectorTest.completeTest(); 78 121 } … … 85 128 <body onload="runTest()"> 86 129 <p> 87 Tests that changes to an inline style from JavaScript are reflected in the Styles pane and Elements tree.130 Tests that changes to an inline style and ancestor/sibling className from JavaScript are reflected in the Styles pane and Elements tree. 88 131 </p> 89 132 90 <div id="container" style="font-weight:bold">< /div>133 <div id="container" style="font-weight:bold"><div id="child"></div><div id="childSibling"></div></div> 91 134 92 135 </body> -
trunk/Source/WebCore/ChangeLog
r128290 r128291 1 2012-09-12 Alexander Pavlov <apavlov@chromium.org> 2 3 Web Inspector: [Elements] Sidebar panes not updated on style changes due to "class" attribute modifications 4 https://bugs.webkit.org/show_bug.cgi?id=95722 5 6 Reviewed by Vsevolod Vlasov. 7 8 The DOMAgent StyleInvalidated event has been removed in favor of the StylesSidebarPane explicitly listening on the 9 AttrModified/AttrRemoved events that result in those same updates. 10 11 * inspector/front-end/DOMAgent.js: 12 (WebInspector.DOMAgent.prototype._attributeModified): 13 (WebInspector.DOMAgent.prototype._loadNodeAttributes): 14 (WebInspector.DOMAgent.prototype._childNodeRemoved): 15 * inspector/front-end/ElementsTreeOutline.js: 16 (WebInspector.ElementsTreeElement.prototype.updateSelection): Drive-by: avoid a costly synchronous layout during DOM tree updates. 17 * inspector/front-end/StylesSidebarPane.js: 18 (WebInspector.StylesSidebarPane): 19 (WebInspector.StylesSidebarPane.prototype._attributeChanged): 20 (WebInspector.StylesSidebarPane.prototype._canAffectCurrentStyles): 21 1 22 2012-09-12 Simon Hausmann <simon.hausmann@nokia.com> 2 23 -
trunk/Source/WebCore/inspector/front-end/DOMAgent.js
r126576 r128291 795 795 ChildNodeCountUpdated: "ChildNodeCountUpdated", 796 796 InspectElementRequested: "InspectElementRequested", 797 StyleInvalidated: "StyleInvalidated",798 797 UndoRedoRequested: "UndoRedoRequested", 799 798 UndoRedoCompleted: "UndoRedoCompleted" … … 917 916 if (!node) 918 917 return; 919 var issueStyleInvalidated = name === "style" && value !== node.getAttribute("style");920 918 921 919 node._setAttribute(name, value); 922 920 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrModified, { node: node, name: name }); 923 if (issueStyleInvalidated)924 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.StyleInvalidated, node)925 921 }, 926 922 … … 966 962 var node = this._idToDOMNode[nodeId]; 967 963 if (node) { 968 if (node._setAttributesPayload(attributes)) {964 if (node._setAttributesPayload(attributes)) 969 965 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrModified, { node: node, name: "style" }); 970 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.StyleInvalidated, node);971 }972 966 } 973 967 } … … 1081 1075 parent._removeChild(node); 1082 1076 this._unbind(node); 1083 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeRemoved, {node: node, parent:parent});1077 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeRemoved, {node: node, parent: parent}); 1084 1078 }, 1085 1079 -
trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js
r128043 r128291 813 813 return; 814 814 815 if (document.body.offsetWidth <= 0) { 816 // The stylesheet hasn't loaded yet or the window is closed, 817 // so we can't calculate what is need. Return early. 818 return; 815 if (!this._readyToUpdateSelection) { 816 if (document.body.offsetWidth > 0) 817 this._readyToUpdateSelection = true; 818 else { 819 // The stylesheet hasn't loaded yet or the window is closed, 820 // so we can't calculate what we need. Return early. 821 return; 822 } 819 823 } 820 824 -
trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js
r127142 r128291 98 98 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._styleSheetOrMediaQueryResultChanged, this); 99 99 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.MediaQueryResultChanged, this._styleSheetOrMediaQueryResultChanged, this); 100 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModified, this._attributesModified, this); 101 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrRemoved, this._attributesRemoved, this); 102 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.StyleInvalidated, this._styleInvalidated, this); 100 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModified, this._attributeChanged, this); 101 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrRemoved, this._attributeChanged, this); 103 102 WebInspector.settings.showUserAgentStyles.addChangeListener(this._showUserAgentStylesSettingChanged.bind(this)); 104 103 } … … 315 314 }, 316 315 317 _attributesModified: function(event) 318 { 319 if (this.node !== event.data.node) 320 return; 321 322 // Changing style attribute will anyways generate _styleInvalidated message. 323 if (event.data.name === "style") 324 return; 325 326 // "class" (or any other) attribute might have changed. Update styles unless they are being edited. 327 if (!this._isEditingStyle && !this._userOperation) 328 this._rebuildUpdate(); 329 }, 330 331 _attributesRemoved: function(event) 332 { 333 if (this.node !== event.data.node) 334 return; 335 336 // "style" attribute might have been removed. 337 if (!this._isEditingStyle && !this._userOperation) 338 this._rebuildUpdate(); 339 }, 340 341 _styleInvalidated: function(event) 342 { 343 if (this.node !== event.data) 344 return; 345 346 if (!this._isEditingStyle && !this._userOperation) 347 this._rebuildUpdate(); 316 _attributeChanged: function(event) 317 { 318 // Any attribute removal or modification can affect the styles of "related" nodes. 319 // Do not touch the styles if they are being edited. 320 if (this._isEditingStyle || this._userOperation) 321 return; 322 323 if (!this._canAffectCurrentStyles(event.data.node)) 324 return; 325 326 this._rebuildUpdate(); 327 }, 328 329 _canAffectCurrentStyles: function(node) 330 { 331 return this.node && (this.node === node || node.parentNode === this.node.parentNode || node.isAncestor(this.node)); 348 332 }, 349 333
Note: See TracChangeset
for help on using the changeset viewer.