DevTools: [SSP] show source location for the newly inserted style rules.

To achieve the specified goal, the patch does the following:
- StylePropertiesSection.styleRule no longer has sourceURL as it could
be always fetched from styleRule.rule
- StylePropertiesSection._createRuleOrigin is receiving CSSRule and
ruleLocation as arguments
- BlankStylePropertiesSection is taught to infer the actual rule
location of the rule that will be inserted

Layout Test change: the CSSOM rule now don't show source location (used to be "located" on first line)

R=pfeldman, vsevik, apavlov

Review URL: https://codereview.chromium.org/474433004

git-svn-id: svn://svn.chromium.org/blink/trunk@180348 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 045324c6
......@@ -5,7 +5,7 @@ element.style { ()
[expanded]
@media all (cssom-media-insert-crash.html)
#box { (cssom-media-ins…t-crash.html:1 -> cssom-media-insert-crash.html:1:1)
#box { ()
background: red;
color: white;
......
......@@ -889,6 +889,39 @@ WebInspector.CSSStyleDeclaration.prototype = {
}
}
/**
* @constructor
* @param {!CSSAgent.Selector} payload
*/
WebInspector.CSSRuleSelector = function(payload)
{
this.value = payload.value;
if (payload.range)
this.range = WebInspector.TextRange.fromObject(payload.range);
}
/**
* @param {!CSSAgent.Selector} payload
* @return {!WebInspector.CSSRuleSelector}
*/
WebInspector.CSSRuleSelector.parsePayload = function(payload)
{
return new WebInspector.CSSRuleSelector(payload)
}
WebInspector.CSSRuleSelector.prototype = {
/**
* @param {!WebInspector.TextRange} oldRange
* @param {!WebInspector.TextRange} newRange
*/
sourceStyleRuleEdited: function(oldRange, newRange)
{
if (!this.range)
return;
this.range = this.range.rebaseAfterTextEdit(oldRange, newRange);
}
}
/**
* @constructor
* @param {!WebInspector.CSSStyleModel} cssModel
......@@ -901,11 +934,12 @@ WebInspector.CSSRule = function(cssModel, payload, matchingSelectors)
this.styleSheetId = payload.styleSheetId;
if (matchingSelectors)
this.matchingSelectors = matchingSelectors;
this.selectors = payload.selectorList.selectors;
for (var i = 0; i < this.selectors.length; ++i) {
var selector = this.selectors[i];
if (selector.range)
selector.range = WebInspector.TextRange.fromObject(selector.range);
/** @type {!Array.<!WebInspector.CSSRuleSelector>} */
this.selectors = [];
for (var i = 0; i < payload.selectorList.selectors.length; ++i) {
var selectorPayload = payload.selectorList.selectors[i];
this.selectors.push(WebInspector.CSSRuleSelector.parsePayload(selectorPayload));
}
this.selectorText = this.selectors.select("value").join(", ");
......@@ -948,11 +982,8 @@ WebInspector.CSSRule.prototype = {
if (this.styleSheetId === styleSheetId) {
if (this.selectorRange)
this.selectorRange = this.selectorRange.rebaseAfterTextEdit(oldRange, newRange);
for (var i = 0; i < this.selectors.length; ++i) {
var selector = this.selectors[i];
if (selector.range)
selector.range = selector.range.rebaseAfterTextEdit(oldRange, newRange);
}
for (var i = 0; i < this.selectors.length; ++i)
this.selectors[i].sourceStyleRuleEdited(oldRange, newRange);
}
if (this.media) {
for (var i = 0; i < this.media.length; ++i)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment