Web Inspector: Separate creating a style sheet from adding a new rule in the protocol
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Aug 2015 17:59:27 +0000 (17:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Aug 2015 17:59:27 +0000 (17:59 +0000)
commit5e7f347b2f9731963197d8f1d6fee1fb9ba2ded8
treeac670eae9c524ccef0246befa6ea4f5e8b9d996c
parent02e6fd9cd9b9f36b23ca22a6106eb6ae2026f5d3
Web Inspector: Separate creating a style sheet from adding a new rule in the protocol
https://bugs.webkit.org/show_bug.cgi?id=148502

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-08-28
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* inspector/protocol/CSS.json:
Add CSS.createStyleSheet. Modify CSS.addRule.

Source/WebCore:

Tests: inspector/css/createStyleSheet.html
       inspector/css/manager-preferredInspectorStyleSheetForFrame.html

* inspector/InspectorCSSAgent.h:
Allow for multiple inspector style sheets per document.

* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::createStyleSheet):
(WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): Added.
(WebCore::InspectorCSSAgent::viaInspectorStyleSheet): Deleted.
Extract and generalize creating a via-inspector stylesheet here.

(WebCore::InspectorCSSAgent::addRule):
Lookup stylesheet to add a rule to via the provided stylesheet id.

(WebCore::InspectorCSSAgent::bindStyleSheet):
(WebCore::InspectorCSSAgent::detectOrigin):
Update to account for a list of stylesheets per document instead of one.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule):
(WebCore::InspectorStyleSheetForInlineStyle::setStyleText):

Source/WebInspectorUI:

The backend allows creating multiple stylesheets. This patch makes
the frontend have a preferred InspectorStyleSheet per-frame.

* UserInterface/Base/Object.js:
(WebInspector.Object.singleFireEventListener):
Return the wrapped listener so it can be removed if needed.

* UserInterface/Models/CSSStyleSheet.js:
(WebInspector.CSSStyleSheet.prototype.isInspectorStyleSheet):
Helper to check if the current stylesheet is an inspector created stylesheet.

* UserInterface/Controllers/CSSStyleManager.js:
(WebInspector.CSSStyleManager.prototype.preferredInspectorStyleSheetForFrame):
(WebInspector.CSSStyleManager.prototype.preferredInspectorStyleSheetForFrame.documentNodeAvailable):
(WebInspector.CSSStyleManager.prototype.preferredInspectorStyleSheetForFrame.bodyNodeAvailable):
(WebInspector.CSSStyleManager.prototype.preferredInspectorStyleSheetForFrame.cssRuleAvailable):
(WebInspector.CSSStyleManager.prototype._inspectorStyleSheetsForFrame):
Lookup the inspector stylesheet for a particular frame. If one doesn't exist create it.
For legacy backends, exploit "addRule" to create the inspector stylesheet.

* UserInterface/Models/DOMNode.js:
* UserInterface/Models/DOMNodeStyles.js:
(WebInspector.DOMNodeStyles.prototype.addEmptyRule.inspectorStyleSheetAvailable):
(WebInspector.DOMNodeStyles.prototype.addEmptyRule):
Currently add all new rules to the inspector stylesheet.

LayoutTests:

* inspector/css/createStyleSheet-expected.txt: Added.
* inspector/css/createStyleSheet.html: Added.
* inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt: Added.
* inspector/css/manager-preferredInspectorStyleSheetForFrame.html: Added.
* inspector/css/stylesheet-events-inspector-stylesheet-expected.txt:
* inspector/css/stylesheet-events-inspector-stylesheet.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189104 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/css/createStyleSheet-expected.txt [new file with mode: 0644]
LayoutTests/inspector/css/createStyleSheet.html [new file with mode: 0644]
LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt [new file with mode: 0644]
LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html [new file with mode: 0644]
LayoutTests/inspector/css/stylesheet-events-inspector-stylesheet-expected.txt
LayoutTests/inspector/css/stylesheet-events-inspector-stylesheet.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/CSS.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/inspector/InspectorCSSAgent.h
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Object.js
Source/WebInspectorUI/UserInterface/Controllers/CSSStyleManager.js
Source/WebInspectorUI/UserInterface/Models/CSSStyleSheet.js
Source/WebInspectorUI/UserInterface/Models/DOMNode.js
Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js