Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/CSSShadowModel.js

Issue 2252913002: DevTools: Box-shadow editor initial implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shadowIcon
Patch Set: Merge Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {boolean} isBoxShadow
7 */ 8 */
8 WebInspector.CSSShadowModel = function() 9 WebInspector.CSSShadowModel = function(isBoxShadow)
9 { 10 {
11 this._isBoxShadow = isBoxShadow;
10 this._inset = false; 12 this._inset = false;
11 this._offsetX = WebInspector.CSSLength.zero(); 13 this._offsetX = WebInspector.CSSLength.zero();
12 this._offsetY = WebInspector.CSSLength.zero(); 14 this._offsetY = WebInspector.CSSLength.zero();
13 this._blurRadius = WebInspector.CSSLength.zero(); 15 this._blurRadius = WebInspector.CSSLength.zero();
14 this._spreadRadius = WebInspector.CSSLength.zero(); 16 this._spreadRadius = WebInspector.CSSLength.zero();
15 this._color = /** @type {!WebInspector.Color} */ (WebInspector.Color.parse(" black")); 17 this._color = /** @type {!WebInspector.Color} */ (WebInspector.Color.parse(" black"));
16 this._format = [WebInspector.CSSShadowModel._Part.OffsetX, WebInspector.CSSS hadowModel._Part.OffsetY]; 18 this._format = [WebInspector.CSSShadowModel._Part.OffsetX, WebInspector.CSSS hadowModel._Part.OffsetY];
17 } 19 }
18 20
19 /** 21 /**
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 */ 54 */
53 setInset: function(inset) 55 setInset: function(inset)
54 { 56 {
55 this._inset = inset; 57 this._inset = inset;
56 if (this._format.indexOf(WebInspector.CSSShadowModel._Part.Inset) === -1 ) 58 if (this._format.indexOf(WebInspector.CSSShadowModel._Part.Inset) === -1 )
57 this._format.unshift(WebInspector.CSSShadowModel._Part.Inset); 59 this._format.unshift(WebInspector.CSSShadowModel._Part.Inset);
58 }, 60 },
59 61
60 /** 62 /**
61 * @param {!WebInspector.CSSLength} offsetX 63 * @param {!WebInspector.CSSLength} offsetX
64 */
65 setOffsetX: function(offsetX)
66 {
67 this._offsetX = offsetX;
68 },
69
70 /**
62 * @param {!WebInspector.CSSLength} offsetY 71 * @param {!WebInspector.CSSLength} offsetY
63 */ 72 */
64 setOffset: function(offsetX, offsetY) 73 setOffsetY: function(offsetY)
65 { 74 {
66 this._offsetX = offsetX;
67 this._offsetY = offsetY; 75 this._offsetY = offsetY;
68 }, 76 },
69 77
70 /** 78 /**
71 * @param {!WebInspector.CSSLength} blurRadius 79 * @param {!WebInspector.CSSLength} blurRadius
72 */ 80 */
73 setBlurRadius: function(blurRadius) 81 setBlurRadius: function(blurRadius)
74 { 82 {
75 this._blurRadius = blurRadius; 83 this._blurRadius = blurRadius;
76 if (this._format.indexOf(WebInspector.CSSShadowModel._Part.BlurRadius) = == -1) { 84 if (this._format.indexOf(WebInspector.CSSShadowModel._Part.BlurRadius) = == -1) {
(...skipping 21 matching lines...) Expand all
98 setColor: function(color) 106 setColor: function(color)
99 { 107 {
100 this._color = color; 108 this._color = color;
101 if (this._format.indexOf(WebInspector.CSSShadowModel._Part.Color) === -1 ) 109 if (this._format.indexOf(WebInspector.CSSShadowModel._Part.Color) === -1 )
102 this._format.push(WebInspector.CSSShadowModel._Part.Color); 110 this._format.push(WebInspector.CSSShadowModel._Part.Color);
103 }, 111 },
104 112
105 /** 113 /**
106 * @return {boolean} 114 * @return {boolean}
107 */ 115 */
116 isBoxShadow: function()
117 {
118 return this._isBoxShadow;
119 },
120
121 /**
122 * @return {boolean}
123 */
108 inset: function() 124 inset: function()
109 { 125 {
110 return this._inset; 126 return this._inset;
111 }, 127 },
112 128
113 /** 129 /**
114 * @return {!WebInspector.CSSLength} 130 * @return {!WebInspector.CSSLength}
115 */ 131 */
116 offsetX: function() 132 offsetX: function()
117 { 133 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (splits[i].regexIndex === 1) { 206 if (splits[i].regexIndex === 1) {
191 var comma = splits[i]; 207 var comma = splits[i];
192 shadowTexts.push(text.substring(currentIndex, comma.position)); 208 shadowTexts.push(text.substring(currentIndex, comma.position));
193 currentIndex = comma.position + 1; 209 currentIndex = comma.position + 1;
194 } 210 }
195 } 211 }
196 shadowTexts.push(text.substring(currentIndex, text.length)); 212 shadowTexts.push(text.substring(currentIndex, text.length));
197 213
198 var shadows = []; 214 var shadows = [];
199 for (var i = 0; i < shadowTexts.length; i++) { 215 for (var i = 0; i < shadowTexts.length; i++) {
200 var shadow = new WebInspector.CSSShadowModel(); 216 var shadow = new WebInspector.CSSShadowModel(isBoxShadow);
201 shadow._format = []; 217 shadow._format = [];
202 var nextPartAllowed = true; 218 var nextPartAllowed = true;
203 var regexes = [/inset/gi, WebInspector.Color.Regex, WebInspector.CSSLeng th.Regex]; 219 var regexes = [/inset/gi, WebInspector.Color.Regex, WebInspector.CSSLeng th.Regex];
204 var results = WebInspector.TextUtils.splitStringByRegexes(shadowTexts[i] , regexes); 220 var results = WebInspector.TextUtils.splitStringByRegexes(shadowTexts[i] , regexes);
205 for (var j = 0; j < results.length; j++) { 221 for (var j = 0; j < results.length; j++) {
206 var result = results[j]; 222 var result = results[j];
207 if (result.regexIndex === -1) { 223 if (result.regexIndex === -1) {
208 // Don't allow anything other than inset, color, length values, and whitespace. 224 // Don't allow anything other than inset, color, length values, and whitespace.
209 if (/\S/.test(result.value)) 225 if (/\S/.test(result.value))
210 return []; 226 return [];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 334
319 WebInspector.CSSLength.prototype = { 335 WebInspector.CSSLength.prototype = {
320 /** 336 /**
321 * @return {string} 337 * @return {string}
322 */ 338 */
323 asCSSText: function() 339 asCSSText: function()
324 { 340 {
325 return this.amount + this.unit; 341 return this.amount + this.unit;
326 } 342 }
327 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698