| Index: third_party/WebKit/Source/devtools/front_end/common/CSSShadowModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/common/CSSShadowModel.js b/third_party/WebKit/Source/devtools/front_end/common/CSSShadowModel.js
|
| index f372d6f85f29efded224526226c5ba6852594944..8b8d71a8a7bf7eb514d99e6ebb2dff4df5d0a8e0 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/common/CSSShadowModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/common/CSSShadowModel.js
|
| @@ -18,6 +18,8 @@ WebInspector.CSSShadowModel = function(isBoxShadow)
|
| this._format = [WebInspector.CSSShadowModel._Part.OffsetX, WebInspector.CSSShadowModel._Part.OffsetY];
|
| }
|
|
|
| +WebInspector.CSSShadowModel.PropertyRegex = /((?:-webkit-)?box|text)-shadow\s*?:.+?[;\n\r]/g;
|
| +
|
| /**
|
| * @enum {string}
|
| */
|
| @@ -48,6 +50,31 @@ WebInspector.CSSShadowModel.parseBoxShadow = function(text)
|
| return WebInspector.CSSShadowModel._parseShadow(text, true);
|
| }
|
|
|
| +/**
|
| + * @param {string} text
|
| + * @return {!Array<{text: string, position: number}>}
|
| + */
|
| +WebInspector.CSSShadowModel.splitShadows = function(text)
|
| +{
|
| + // This function removes the whitespace around each shadow but not inside.
|
| + var shadowTexts = WebInspector.CSSShadowModel._splitShadowsByCommas(text);
|
| + var shadowPositions = [];
|
| + var index = 0;
|
| + for (var i = 0; i < shadowTexts.length; i++) {
|
| + var shadowText = shadowTexts[i];
|
| + var position = shadowText.search(/\S/);
|
| + if (position === -1)
|
| + return []
|
| + shadowPositions.push({
|
| + text: shadowText.trim(),
|
| + position: index + position
|
| + });
|
| + // +1 for the comma that was removed.
|
| + index = index + shadowText.length + 1;
|
| + }
|
| + return shadowPositions;
|
| +}
|
| +
|
| WebInspector.CSSShadowModel.prototype = {
|
| /**
|
| * @param {boolean} inset
|
| @@ -198,19 +225,7 @@ WebInspector.CSSShadowModel.prototype = {
|
| */
|
| WebInspector.CSSShadowModel._parseShadow = function(text, isBoxShadow)
|
| {
|
| - var shadowTexts = [];
|
| - // Split by commas that aren't inside of color values to get the individual shadow values.
|
| - var splits = WebInspector.TextUtils.splitStringByRegexes(text, [WebInspector.Color.Regex, /,/g]);
|
| - var currentIndex = 0;
|
| - for (var i = 0; i < splits.length; i++) {
|
| - if (splits[i].regexIndex === 1) {
|
| - var comma = splits[i];
|
| - shadowTexts.push(text.substring(currentIndex, comma.position));
|
| - currentIndex = comma.position + 1;
|
| - }
|
| - }
|
| - shadowTexts.push(text.substring(currentIndex, text.length));
|
| -
|
| + var shadowTexts = WebInspector.CSSShadowModel._splitShadowsByCommas(text);
|
| var shadows = [];
|
| for (var i = 0; i < shadowTexts.length; i++) {
|
| var shadow = new WebInspector.CSSShadowModel(isBoxShadow);
|
| @@ -290,6 +305,27 @@ WebInspector.CSSShadowModel._parseShadow = function(text, isBoxShadow)
|
| }
|
|
|
| /**
|
| + * @param {string} text
|
| + * @return {!Array<string>}
|
| + */
|
| +WebInspector.CSSShadowModel._splitShadowsByCommas = function(text)
|
| +{
|
| + var shadowTexts = [];
|
| + // Split by commas that aren't inside of color values to get the individual shadow values.
|
| + var splits = WebInspector.TextUtils.splitStringByRegexes(text, [WebInspector.Color.Regex, /,/g]);
|
| + var currentIndex = 0;
|
| + for (var i = 0; i < splits.length; i++) {
|
| + if (splits[i].regexIndex === 1) {
|
| + var comma = splits[i];
|
| + shadowTexts.push(text.substring(currentIndex, comma.position));
|
| + currentIndex = comma.position + 1;
|
| + }
|
| + }
|
| + shadowTexts.push(text.substring(currentIndex, text.length));
|
| + return shadowTexts;
|
| +}
|
| +
|
| +/**
|
| * @constructor
|
| * @param {number} amount
|
| * @param {string} unit
|
|
|