| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 addButton.id = "add-style-button-test-id"; | 48 addButton.id = "add-style-button-test-id"; |
| 49 addButton.title = WebInspector.UIString("New Style Rule"); | 49 addButton.title = WebInspector.UIString("New Style Rule"); |
| 50 addButton.addEventListener("click", this._createNewRule.bind(this), false); | 50 addButton.addEventListener("click", this._createNewRule.bind(this), false); |
| 51 this.titleElement.appendChild(addButton); | 51 this.titleElement.appendChild(addButton); |
| 52 | 52 |
| 53 this._computedStylePane = computedStylePane; | 53 this._computedStylePane = computedStylePane; |
| 54 computedStylePane.setHostingPane(this); | 54 computedStylePane.setHostingPane(this); |
| 55 this._setPseudoClassCallback = setPseudoClassCallback; | 55 this._setPseudoClassCallback = setPseudoClassCallback; |
| 56 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this), true); | 56 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this), true); |
| 57 WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSetting
Changed.bind(this)); | 57 WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSetting
Changed.bind(this)); |
| 58 WebInspector.settings.showUserAgentStyles.addChangeListener(this._showUserAg
entStylesSettingChanged.bind(this)); |
| 58 | 59 |
| 59 this._createElementStatePane(); | 60 this._createElementStatePane(); |
| 60 this.bodyElement.appendChild(this._elementStatePane); | 61 this.bodyElement.appendChild(this._elementStatePane); |
| 61 this._sectionsContainer = document.createElement("div"); | 62 this._sectionsContainer = document.createElement("div"); |
| 62 this.bodyElement.appendChild(this._sectionsContainer); | 63 this.bodyElement.appendChild(this._sectionsContainer); |
| 63 | 64 |
| 64 this._spectrumHelper = new WebInspector.SpectrumPopupHelper(); | 65 this._spectrumHelper = new WebInspector.SpectrumPopupHelper(); |
| 65 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); | 66 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); |
| 66 | 67 |
| 67 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty
leSheetAdded, this._styleSheetOrMediaQueryResultChanged, this); | |
| 68 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty
leSheetRemoved, this._styleSheetOrMediaQueryResultChanged, this); | |
| 69 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty
leSheetChanged, this._styleSheetOrMediaQueryResultChanged, this); | |
| 70 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Med
iaQueryResultChanged, this._styleSheetOrMediaQueryResultChanged, this); | |
| 71 WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModi
fied, this._attributeChanged, this); | |
| 72 WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemo
ved, this._attributeChanged, this); | |
| 73 WebInspector.settings.showUserAgentStyles.addChangeListener(this._showUserAg
entStylesSettingChanged.bind(this)); | |
| 74 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.FrameResized, this._frameResized, this); | |
| 75 this.element.classList.add("styles-pane"); | 68 this.element.classList.add("styles-pane"); |
| 76 this.element.classList.toggle("show-user-styles", WebInspector.settings.show
UserAgentStyles.get()); | 69 this.element.classList.toggle("show-user-styles", WebInspector.settings.show
UserAgentStyles.get()); |
| 77 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind(
this), false); | 70 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind(
this), false); |
| 78 document.body.addEventListener("keydown", this._keyDown.bind(this), false); | 71 document.body.addEventListener("keydown", this._keyDown.bind(this), false); |
| 79 document.body.addEventListener("keyup", this._keyUp.bind(this), false); | 72 document.body.addEventListener("keyup", this._keyUp.bind(this), false); |
| 80 } | 73 } |
| 81 | 74 |
| 82 // Keep in sync with RenderStyleConstants.h PseudoId enum. Array below contains
pseudo id names for corresponding enum indexes. | 75 // Keep in sync with RenderStyleConstants.h PseudoId enum. Array below contains
pseudo id names for corresponding enum indexes. |
| 83 // First item is empty due to its artificial NOPSEUDO nature in the enum. | 76 // First item is empty due to its artificial NOPSEUDO nature in the enum. |
| 84 // FIXME: find a way of generating this mapping or getting it from combination o
f RenderStyleConstants and CSSSelector.cpp at | 77 // FIXME: find a way of generating this mapping or getting it from combination o
f RenderStyleConstants and CSSSelector.cpp at |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 function searchHandler(regex) | 197 function searchHandler(regex) |
| 205 { | 198 { |
| 206 this._filterRegex = regex; | 199 this._filterRegex = regex; |
| 207 } | 200 } |
| 208 | 201 |
| 209 return filterInput; | 202 return filterInput; |
| 210 }, | 203 }, |
| 211 | 204 |
| 212 get _forcedPseudoClasses() | 205 get _forcedPseudoClasses() |
| 213 { | 206 { |
| 214 return this.node ? (this.node.getUserProperty(WebInspector.CSSStyleModel
.PseudoStatePropertyName) || undefined) : undefined; | 207 return this._node ? (this._node.getUserProperty(WebInspector.CSSStyleMod
el.PseudoStatePropertyName) || undefined) : undefined; |
| 215 }, | 208 }, |
| 216 | 209 |
| 217 _updateForcedPseudoStateInputs: function() | 210 _updateForcedPseudoStateInputs: function() |
| 218 { | 211 { |
| 219 if (!this.node) | 212 if (!this._node) |
| 220 return; | 213 return; |
| 221 | 214 |
| 222 var hasPseudoType = !!this.node.pseudoType(); | 215 var hasPseudoType = !!this._node.pseudoType(); |
| 223 this._elementStateButton.classList.toggle("hidden", hasPseudoType); | 216 this._elementStateButton.classList.toggle("hidden", hasPseudoType); |
| 224 this._elementStatePane.classList.toggle("expanded", !hasPseudoType && th
is._elementStateButton.classList.contains("toggled")); | 217 this._elementStatePane.classList.toggle("expanded", !hasPseudoType && th
is._elementStateButton.classList.contains("toggled")); |
| 225 | 218 |
| 226 var nodePseudoState = this._forcedPseudoClasses; | 219 var nodePseudoState = this._forcedPseudoClasses; |
| 227 if (!nodePseudoState) | 220 if (!nodePseudoState) |
| 228 nodePseudoState = []; | 221 nodePseudoState = []; |
| 229 | 222 |
| 230 var inputs = this._elementStatePane.inputs; | 223 var inputs = this._elementStatePane.inputs; |
| 231 for (var i = 0; i < inputs.length; ++i) | 224 for (var i = 0; i < inputs.length; ++i) |
| 232 inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0; | 225 inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0; |
| 233 }, | 226 }, |
| 234 | 227 |
| 235 /** | 228 /** |
| 236 * @param {?WebInspector.DOMNode} node | 229 * @param {?WebInspector.DOMNode} node |
| 237 * @param {boolean=} forceUpdate | 230 * @param {boolean=} forceUpdate |
| 238 */ | 231 */ |
| 239 update: function(node, forceUpdate) | 232 update: function(node, forceUpdate) |
| 240 { | 233 { |
| 241 this._spectrumHelper.hide(); | 234 this._spectrumHelper.hide(); |
| 242 this._discardElementUnderMouse(); | 235 this._discardElementUnderMouse(); |
| 243 | 236 |
| 244 var refresh = false; | 237 var refresh = false; |
| 245 | 238 |
| 246 if (forceUpdate) | 239 if (forceUpdate) |
| 247 delete this.node; | 240 delete this._node; |
| 248 | 241 |
| 249 if (!forceUpdate && (node === this.node)) | 242 if (!forceUpdate && (node === this._node)) |
| 250 refresh = true; | 243 refresh = true; |
| 251 | 244 |
| 252 if (node && node.nodeType() === Node.TEXT_NODE && node.parentNode) | 245 if (node && node.nodeType() === Node.TEXT_NODE && node.parentNode) |
| 253 node = node.parentNode; | 246 node = node.parentNode; |
| 254 | 247 |
| 255 if (node && node.nodeType() !== Node.ELEMENT_NODE) | 248 if (node && node.nodeType() !== Node.ELEMENT_NODE) |
| 256 node = null; | 249 node = null; |
| 257 | 250 |
| 258 if (node) | 251 if (node) { |
| 259 this.node = node; | 252 this._updateTarget(node.target()); |
| 260 else | 253 this._node = node; |
| 261 node = this.node; | 254 } else |
| 255 node = this._node; |
| 262 | 256 |
| 263 this._updateForcedPseudoStateInputs(); | 257 this._updateForcedPseudoStateInputs(); |
| 264 | 258 |
| 265 if (refresh) | 259 if (refresh) |
| 266 this._refreshUpdate(); | 260 this._refreshUpdate(); |
| 267 else | 261 else |
| 268 this._rebuildUpdate(); | 262 this._rebuildUpdate(); |
| 269 }, | 263 }, |
| 270 | 264 |
| 271 /** | 265 /** |
| 266 * @param {!WebInspector.Target} target |
| 267 */ |
| 268 _updateTarget: function(target) |
| 269 { |
| 270 if (this._target === target) |
| 271 return; |
| 272 if (this._target) { |
| 273 this._target.cssModel.removeEventListener(WebInspector.CSSStyleModel
.Events.StyleSheetAdded, this._styleSheetOrMediaQueryResultChanged, this); |
| 274 this._target.cssModel.removeEventListener(WebInspector.CSSStyleModel
.Events.StyleSheetRemoved, this._styleSheetOrMediaQueryResultChanged, this); |
| 275 this._target.cssModel.removeEventListener(WebInspector.CSSStyleModel
.Events.StyleSheetChanged, this._styleSheetOrMediaQueryResultChanged, this); |
| 276 this._target.cssModel.removeEventListener(WebInspector.CSSStyleModel
.Events.MediaQueryResultChanged, this._styleSheetOrMediaQueryResultChanged, this
); |
| 277 this._target.domModel.removeEventListener(WebInspector.DOMModel.Even
ts.AttrModified, this._attributeChanged, this); |
| 278 this._target.domModel.removeEventListener(WebInspector.DOMModel.Even
ts.AttrRemoved, this._attributeChanged, this); |
| 279 this._target.resourceTreeModel.removeEventListener(WebInspector.Reso
urceTreeModel.EventTypes.FrameResized, this._frameResized, this); |
| 280 } |
| 281 this._target = target; |
| 282 this._target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events
.StyleSheetAdded, this._styleSheetOrMediaQueryResultChanged, this); |
| 283 this._target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events
.StyleSheetRemoved, this._styleSheetOrMediaQueryResultChanged, this); |
| 284 this._target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events
.StyleSheetChanged, this._styleSheetOrMediaQueryResultChanged, this); |
| 285 this._target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events
.MediaQueryResultChanged, this._styleSheetOrMediaQueryResultChanged, this); |
| 286 this._target.domModel.addEventListener(WebInspector.DOMModel.Events.Attr
Modified, this._attributeChanged, this); |
| 287 this._target.domModel.addEventListener(WebInspector.DOMModel.Events.Attr
Removed, this._attributeChanged, this); |
| 288 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre
eModel.EventTypes.FrameResized, this._frameResized, this); |
| 289 }, |
| 290 |
| 291 /** |
| 272 * @param {!WebInspector.StylePropertiesSection=} editedSection | 292 * @param {!WebInspector.StylePropertiesSection=} editedSection |
| 273 * @param {boolean=} forceFetchComputedStyle | 293 * @param {boolean=} forceFetchComputedStyle |
| 274 * @param {function()=} userCallback | 294 * @param {function()=} userCallback |
| 275 */ | 295 */ |
| 276 _refreshUpdate: function(editedSection, forceFetchComputedStyle, userCallbac
k) | 296 _refreshUpdate: function(editedSection, forceFetchComputedStyle, userCallbac
k) |
| 277 { | 297 { |
| 278 var callbackWrapper = function() | 298 var callbackWrapper = function() |
| 279 { | 299 { |
| 280 if (this._filterRegex) | 300 if (this._filterRegex) |
| 281 this._updateFilter(false); | 301 this._updateFilter(false); |
| 282 if (userCallback) | 302 if (userCallback) |
| 283 userCallback(); | 303 userCallback(); |
| 284 }.bind(this); | 304 }.bind(this); |
| 285 | 305 |
| 286 if (this._refreshUpdateInProgress) { | 306 if (this._refreshUpdateInProgress) { |
| 287 this._lastNodeForInnerRefresh = this.node; | 307 this._lastNodeForInnerRefresh = this._node; |
| 288 return; | 308 return; |
| 289 } | 309 } |
| 290 | 310 |
| 291 var node = this._validateNode(userCallback); | 311 var node = this._validateNode(userCallback); |
| 292 if (!node) | 312 if (!node) |
| 293 return; | 313 return; |
| 294 | 314 |
| 295 /** | 315 /** |
| 296 * @param {?WebInspector.CSSStyleDeclaration} computedStyle | 316 * @param {?WebInspector.CSSStyleDeclaration} computedStyle |
| 297 * @this {WebInspector.StylesSidebarPane} | 317 * @this {WebInspector.StylesSidebarPane} |
| 298 */ | 318 */ |
| 299 function computedStyleCallback(computedStyle) | 319 function computedStyleCallback(computedStyle) |
| 300 { | 320 { |
| 301 delete this._refreshUpdateInProgress; | 321 delete this._refreshUpdateInProgress; |
| 302 | 322 |
| 303 if (this._lastNodeForInnerRefresh) { | 323 if (this._lastNodeForInnerRefresh) { |
| 304 delete this._lastNodeForInnerRefresh; | 324 delete this._lastNodeForInnerRefresh; |
| 305 this._refreshUpdate(editedSection, forceFetchComputedStyle, call
backWrapper); | 325 this._refreshUpdate(editedSection, forceFetchComputedStyle, call
backWrapper); |
| 306 return; | 326 return; |
| 307 } | 327 } |
| 308 | 328 |
| 309 if (this.node === node && computedStyle) | 329 if (this._node === node && computedStyle) |
| 310 this._innerRefreshUpdate(node, computedStyle, editedSection); | 330 this._innerRefreshUpdate(node, computedStyle, editedSection); |
| 311 | 331 |
| 312 callbackWrapper(); | 332 callbackWrapper(); |
| 313 } | 333 } |
| 314 | 334 |
| 315 if (this._computedStylePane.isShowing() || forceFetchComputedStyle) { | 335 if (this._computedStylePane.isShowing() || forceFetchComputedStyle) { |
| 316 this._refreshUpdateInProgress = true; | 336 this._refreshUpdateInProgress = true; |
| 317 WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCa
llback.bind(this)); | 337 this._target.cssModel.getComputedStyleAsync(node.id, computedStyleCa
llback.bind(this)); |
| 318 } else { | 338 } else { |
| 319 this._innerRefreshUpdate(node, null, editedSection); | 339 this._innerRefreshUpdate(node, null, editedSection); |
| 320 callbackWrapper(); | 340 callbackWrapper(); |
| 321 } | 341 } |
| 322 }, | 342 }, |
| 323 | 343 |
| 324 _rebuildUpdate: function() | 344 _rebuildUpdate: function() |
| 325 { | 345 { |
| 326 if (this._rebuildUpdateInProgress) { | 346 if (this._rebuildUpdateInProgress) { |
| 327 this._lastNodeForInnerRebuild = this.node; | 347 this._lastNodeForInnerRebuild = this._node; |
| 328 return; | 348 return; |
| 329 } | 349 } |
| 330 | 350 |
| 331 var node = this._validateNode(); | 351 var node = this._validateNode(); |
| 332 if (!node) | 352 if (!node) |
| 333 return; | 353 return; |
| 334 | 354 |
| 335 this._rebuildUpdateInProgress = true; | 355 this._rebuildUpdateInProgress = true; |
| 336 | 356 |
| 337 var resultStyles = {}; | 357 var resultStyles = {}; |
| 338 | 358 |
| 339 /** | 359 /** |
| 340 * @param {?*} matchedResult | 360 * @param {?*} matchedResult |
| 341 * @this {WebInspector.StylesSidebarPane} | 361 * @this {WebInspector.StylesSidebarPane} |
| 342 */ | 362 */ |
| 343 function stylesCallback(matchedResult) | 363 function stylesCallback(matchedResult) |
| 344 { | 364 { |
| 345 delete this._rebuildUpdateInProgress; | 365 delete this._rebuildUpdateInProgress; |
| 346 | 366 |
| 347 var lastNodeForRebuild = this._lastNodeForInnerRebuild; | 367 var lastNodeForRebuild = this._lastNodeForInnerRebuild; |
| 348 if (lastNodeForRebuild) { | 368 if (lastNodeForRebuild) { |
| 349 delete this._lastNodeForInnerRebuild; | 369 delete this._lastNodeForInnerRebuild; |
| 350 if (lastNodeForRebuild !== this.node) { | 370 if (lastNodeForRebuild !== this._node) { |
| 351 this._rebuildUpdate(); | 371 this._rebuildUpdate(); |
| 352 return; | 372 return; |
| 353 } | 373 } |
| 354 } | 374 } |
| 355 | 375 |
| 356 if (matchedResult && this.node === node) { | 376 if (matchedResult && this._node === node) { |
| 357 resultStyles.matchedCSSRules = matchedResult.matchedCSSRules; | 377 resultStyles.matchedCSSRules = matchedResult.matchedCSSRules; |
| 358 resultStyles.pseudoElements = matchedResult.pseudoElements; | 378 resultStyles.pseudoElements = matchedResult.pseudoElements; |
| 359 resultStyles.inherited = matchedResult.inherited; | 379 resultStyles.inherited = matchedResult.inherited; |
| 360 this._innerRebuildUpdate(node, resultStyles); | 380 this._innerRebuildUpdate(node, resultStyles); |
| 361 } | 381 } |
| 362 | 382 |
| 363 if (lastNodeForRebuild) { | 383 if (lastNodeForRebuild) { |
| 364 // lastNodeForRebuild is the same as this.node - another rebuild
has been requested. | 384 // lastNodeForRebuild is the same as this.node - another rebuild
has been requested. |
| 365 this._rebuildUpdate(); | 385 this._rebuildUpdate(); |
| 366 return; | 386 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 379 | 399 |
| 380 /** | 400 /** |
| 381 * @param {?WebInspector.CSSStyleDeclaration} computedStyle | 401 * @param {?WebInspector.CSSStyleDeclaration} computedStyle |
| 382 */ | 402 */ |
| 383 function computedCallback(computedStyle) | 403 function computedCallback(computedStyle) |
| 384 { | 404 { |
| 385 resultStyles.computedStyle = computedStyle; | 405 resultStyles.computedStyle = computedStyle; |
| 386 } | 406 } |
| 387 | 407 |
| 388 if (this._computedStylePane.isShowing()) | 408 if (this._computedStylePane.isShowing()) |
| 389 WebInspector.cssModel.getComputedStyleAsync(node.id, computedCallbac
k); | 409 this._target.cssModel.getComputedStyleAsync(node.id, computedCallbac
k); |
| 390 WebInspector.cssModel.getInlineStylesAsync(node.id, inlineCallback); | 410 this._target.cssModel.getInlineStylesAsync(node.id, inlineCallback); |
| 391 WebInspector.cssModel.getMatchedStylesAsync(node.id, true, true, stylesC
allback.bind(this)); | 411 this._target.cssModel.getMatchedStylesAsync(node.id, true, true, stylesC
allback.bind(this)); |
| 392 }, | 412 }, |
| 393 | 413 |
| 394 /** | 414 /** |
| 395 * @param {function()=} userCallback | 415 * @param {function()=} userCallback |
| 396 */ | 416 */ |
| 397 _validateNode: function(userCallback) | 417 _validateNode: function(userCallback) |
| 398 { | 418 { |
| 399 if (!this.node) { | 419 if (!this._node) { |
| 400 this._sectionsContainer.removeChildren(); | 420 this._sectionsContainer.removeChildren(); |
| 401 this._computedStylePane.bodyElement.removeChildren(); | 421 this._computedStylePane.bodyElement.removeChildren(); |
| 402 this.sections = {}; | 422 this.sections = {}; |
| 403 if (userCallback) | 423 if (userCallback) |
| 404 userCallback(); | 424 userCallback(); |
| 405 return null; | 425 return null; |
| 406 } | 426 } |
| 407 return this.node; | 427 return this._node; |
| 408 }, | 428 }, |
| 409 | 429 |
| 410 _styleSheetOrMediaQueryResultChanged: function() | 430 _styleSheetOrMediaQueryResultChanged: function() |
| 411 { | 431 { |
| 412 if (this._userOperation || this._isEditingStyle) | 432 if (this._userOperation || this._isEditingStyle) |
| 413 return; | 433 return; |
| 414 | 434 |
| 415 this._rebuildUpdate(); | 435 this._rebuildUpdate(); |
| 416 }, | 436 }, |
| 417 | 437 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 440 return; | 460 return; |
| 441 | 461 |
| 442 if (!this._canAffectCurrentStyles(event.data.node)) | 462 if (!this._canAffectCurrentStyles(event.data.node)) |
| 443 return; | 463 return; |
| 444 | 464 |
| 445 this._rebuildUpdate(); | 465 this._rebuildUpdate(); |
| 446 }, | 466 }, |
| 447 | 467 |
| 448 _canAffectCurrentStyles: function(node) | 468 _canAffectCurrentStyles: function(node) |
| 449 { | 469 { |
| 450 return this.node && (this.node === node || node.parentNode === this.node
.parentNode || node.isAncestor(this.node)); | 470 return this._node && (this._node === node || node.parentNode === this._n
ode.parentNode || node.isAncestor(this._node)); |
| 451 }, | 471 }, |
| 452 | 472 |
| 453 _innerRefreshUpdate: function(node, computedStyle, editedSection) | 473 _innerRefreshUpdate: function(node, computedStyle, editedSection) |
| 454 { | 474 { |
| 455 for (var pseudoId in this.sections) { | 475 for (var pseudoId in this.sections) { |
| 456 var styleRules = this._refreshStyleRules(this.sections[pseudoId], co
mputedStyle); | 476 var styleRules = this._refreshStyleRules(this.sections[pseudoId], co
mputedStyle); |
| 457 var usedProperties = {}; | 477 var usedProperties = {}; |
| 458 this._markUsedProperties(styleRules, usedProperties); | 478 this._markUsedProperties(styleRules, usedProperties); |
| 459 this._refreshSectionsForStyleRules(styleRules, usedProperties, edite
dSection); | 479 this._refreshSectionsForStyleRules(styleRules, usedProperties, edite
dSection); |
| 460 } | 480 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 event.consume(); | 782 event.consume(); |
| 763 this.expand(); | 783 this.expand(); |
| 764 this.addBlankSection().startEditingSelector(); | 784 this.addBlankSection().startEditingSelector(); |
| 765 }, | 785 }, |
| 766 | 786 |
| 767 /** | 787 /** |
| 768 * @return {!WebInspector.BlankStylePropertiesSection} | 788 * @return {!WebInspector.BlankStylePropertiesSection} |
| 769 */ | 789 */ |
| 770 addBlankSection: function() | 790 addBlankSection: function() |
| 771 { | 791 { |
| 772 var blankSection = new WebInspector.BlankStylePropertiesSection(this, th
is.node ? WebInspector.DOMPresentationUtils.simpleSelector(this.node) : ""); | 792 var blankSection = new WebInspector.BlankStylePropertiesSection(this, th
is._node ? WebInspector.DOMPresentationUtils.simpleSelector(this._node) : ""); |
| 773 | 793 |
| 774 var elementStyleSection = this.sections[0][1]; | 794 var elementStyleSection = this.sections[0][1]; |
| 775 this._sectionsContainer.insertBefore(blankSection.element, elementStyleS
ection.element.nextSibling); | 795 this._sectionsContainer.insertBefore(blankSection.element, elementStyleS
ection.element.nextSibling); |
| 776 | 796 |
| 777 this.sections[0].splice(2, 0, blankSection); | 797 this.sections[0].splice(2, 0, blankSection); |
| 778 | 798 |
| 779 return blankSection; | 799 return blankSection; |
| 780 }, | 800 }, |
| 781 | 801 |
| 782 removeSection: function(section) | 802 removeSection: function(section) |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 if (media.sourceURL) { | 1101 if (media.sourceURL) { |
| 1082 var refElement = mediaDataElement.createChild("div", "subtitle")
; | 1102 var refElement = mediaDataElement.createChild("div", "subtitle")
; |
| 1083 var rawLocation; | 1103 var rawLocation; |
| 1084 var mediaHeader; | 1104 var mediaHeader; |
| 1085 if (media.range) { | 1105 if (media.range) { |
| 1086 mediaHeader = media.header(); | 1106 mediaHeader = media.header(); |
| 1087 if (mediaHeader) { | 1107 if (mediaHeader) { |
| 1088 var lineNumber = media.lineNumberInSource(); | 1108 var lineNumber = media.lineNumberInSource(); |
| 1089 var columnNumber = media.columnNumberInSource(); | 1109 var columnNumber = media.columnNumberInSource(); |
| 1090 console.assert(typeof lineNumber !== "undefined" && type
of columnNumber !== "undefined"); | 1110 console.assert(typeof lineNumber !== "undefined" && type
of columnNumber !== "undefined"); |
| 1091 rawLocation = new WebInspector.CSSLocation(WebInspector.
cssModel.target(), media.sourceURL, lineNumber, columnNumber); | 1111 rawLocation = new WebInspector.CSSLocation(this._parentP
ane._target, media.sourceURL, lineNumber, columnNumber); |
| 1092 } | 1112 } |
| 1093 } | 1113 } |
| 1094 | 1114 |
| 1095 var anchor; | 1115 var anchor; |
| 1096 if (rawLocation) | 1116 if (rawLocation) |
| 1097 anchor = this._parentPane._linkifier.linkifyCSSLocation(medi
aHeader.id, rawLocation); | 1117 anchor = this._parentPane._linkifier.linkifyCSSLocation(medi
aHeader.id, rawLocation); |
| 1098 else { | 1118 else { |
| 1099 // The "linkedStylesheet" case. | 1119 // The "linkedStylesheet" case. |
| 1100 anchor = WebInspector.linkifyResourceAsNode(media.sourceURL,
undefined, "subtitle", media.sourceURL); | 1120 anchor = WebInspector.linkifyResourceAsNode(media.sourceURL,
undefined, "subtitle", media.sourceURL); |
| 1101 } | 1121 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 this.element.classList.add("styles-show-inherited"); // This one is rela
ted to inherited rules, not computed style. | 1173 this.element.classList.add("styles-show-inherited"); // This one is rela
ted to inherited rules, not computed style. |
| 1154 | 1174 |
| 1155 if (this.navigable) | 1175 if (this.navigable) |
| 1156 this.element.classList.add("navigable"); | 1176 this.element.classList.add("navigable"); |
| 1157 | 1177 |
| 1158 if (!this.editable) | 1178 if (!this.editable) |
| 1159 this.element.classList.add("read-only"); | 1179 this.element.classList.add("read-only"); |
| 1160 } | 1180 } |
| 1161 | 1181 |
| 1162 WebInspector.StylePropertiesSection.prototype = { | 1182 WebInspector.StylePropertiesSection.prototype = { |
| 1163 get pane() | |
| 1164 { | |
| 1165 return this._parentPane; | |
| 1166 }, | |
| 1167 | |
| 1168 collapse: function() | 1183 collapse: function() |
| 1169 { | 1184 { |
| 1170 // Overriding with empty body. | 1185 // Overriding with empty body. |
| 1171 }, | 1186 }, |
| 1172 | 1187 |
| 1173 handleClick: function() | 1188 handleClick: function() |
| 1174 { | 1189 { |
| 1175 // Avoid consuming events. | 1190 // Avoid consuming events. |
| 1176 }, | 1191 }, |
| 1177 | 1192 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 | 1399 |
| 1385 var selectors = rule.selectors; | 1400 var selectors = rule.selectors; |
| 1386 var fragment = document.createDocumentFragment(); | 1401 var fragment = document.createDocumentFragment(); |
| 1387 var currentMatch = 0; | 1402 var currentMatch = 0; |
| 1388 for (var i = 0; i < selectors.length ; ++i) { | 1403 for (var i = 0; i < selectors.length ; ++i) { |
| 1389 if (i) | 1404 if (i) |
| 1390 fragment.appendChild(document.createTextNode(", ")); | 1405 fragment.appendChild(document.createTextNode(", ")); |
| 1391 var isSelectorMatching = matchingSelectors[currentMatch] === i; | 1406 var isSelectorMatching = matchingSelectors[currentMatch] === i; |
| 1392 if (isSelectorMatching) | 1407 if (isSelectorMatching) |
| 1393 ++currentMatch; | 1408 ++currentMatch; |
| 1394 var rawLocation = new WebInspector.CSSLocation(WebInspector.cssModel
.target(), rule.sourceURL, rule.lineNumberInSource(i), rule.columnNumberInSource
(i)); | 1409 var rawLocation = new WebInspector.CSSLocation(this._parentPane._tar
get, rule.sourceURL, rule.lineNumberInSource(i), rule.columnNumberInSource(i)); |
| 1395 var matchingSelectorClass = isSelectorMatching ? " selector-matches"
: ""; | 1410 var matchingSelectorClass = isSelectorMatching ? " selector-matches"
: ""; |
| 1396 var selectorElement = document.createElement("span"); | 1411 var selectorElement = document.createElement("span"); |
| 1397 selectorElement.className = "simple-selector" + matchingSelectorClas
s; | 1412 selectorElement.className = "simple-selector" + matchingSelectorClas
s; |
| 1398 if (rule.id) | 1413 if (rule.id) |
| 1399 selectorElement._selectorIndex = i; | 1414 selectorElement._selectorIndex = i; |
| 1400 selectorElement.textContent = selectors[i].value; | 1415 selectorElement.textContent = selectors[i].value; |
| 1401 | 1416 |
| 1402 fragment.appendChild(selectorElement); | 1417 fragment.appendChild(selectorElement); |
| 1403 } | 1418 } |
| 1404 | 1419 |
| 1405 this._selectorElement.removeChildren(); | 1420 this._selectorElement.removeChildren(); |
| 1406 this._selectorElement.appendChild(fragment); | 1421 this._selectorElement.appendChild(fragment); |
| 1407 this._markSelectorHighlights(); | 1422 this._markSelectorHighlights(); |
| 1408 }, | 1423 }, |
| 1409 | 1424 |
| 1410 _markSelectorHighlights: function() | 1425 _markSelectorHighlights: function() |
| 1411 { | 1426 { |
| 1412 var selectors = this._selectorElement.getElementsByClassName("simple-sel
ector"); | 1427 var selectors = this._selectorElement.getElementsByClassName("simple-sel
ector"); |
| 1413 var regex = this.pane.filterRegex(); | 1428 var regex = this._parentPane.filterRegex(); |
| 1414 for (var i = 0; i < selectors.length; ++i) { | 1429 for (var i = 0; i < selectors.length; ++i) { |
| 1415 var selectorMatchesFilter = regex && regex.test(selectors[i].textCon
tent); | 1430 var selectorMatchesFilter = regex && regex.test(selectors[i].textCon
tent); |
| 1416 selectors[i].classList.toggle("filter-match", selectorMatchesFilter)
; | 1431 selectors[i].classList.toggle("filter-match", selectorMatchesFilter)
; |
| 1417 } | 1432 } |
| 1418 }, | 1433 }, |
| 1419 | 1434 |
| 1420 _checkWillCancelEditing: function() | 1435 _checkWillCancelEditing: function() |
| 1421 { | 1436 { |
| 1422 var willCauseCancelEditing = this._willCauseCancelEditing; | 1437 var willCauseCancelEditing = this._willCauseCancelEditing; |
| 1423 delete this._willCauseCancelEditing; | 1438 delete this._willCauseCancelEditing; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 { | 1474 { |
| 1460 var link = WebInspector.linkifyResourceAsNode(url, line, "", url + "
:" + (line + 1)); | 1475 var link = WebInspector.linkifyResourceAsNode(url, line, "", url + "
:" + (line + 1)); |
| 1461 link.classList.add("webkit-html-resource-link"); | 1476 link.classList.add("webkit-html-resource-link"); |
| 1462 link.setAttribute("data-uncopyable", link.textContent); | 1477 link.setAttribute("data-uncopyable", link.textContent); |
| 1463 link.textContent = ""; | 1478 link.textContent = ""; |
| 1464 return link; | 1479 return link; |
| 1465 } | 1480 } |
| 1466 | 1481 |
| 1467 if (this.styleRule.sourceURL) { | 1482 if (this.styleRule.sourceURL) { |
| 1468 var firstMatchingIndex = this.styleRule.rule.matchingSelectors && th
is.rule.matchingSelectors.length ? this.rule.matchingSelectors[0] : 0; | 1483 var firstMatchingIndex = this.styleRule.rule.matchingSelectors && th
is.rule.matchingSelectors.length ? this.rule.matchingSelectors[0] : 0; |
| 1469 var matchingSelectorLocation = new WebInspector.CSSLocation(WebInspe
ctor.cssModel.target(), this.styleRule.sourceURL, this.rule.lineNumberInSource(f
irstMatchingIndex), this.rule.columnNumberInSource(firstMatchingIndex)); | 1484 var matchingSelectorLocation = new WebInspector.CSSLocation(this._pa
rentPane._target, this.styleRule.sourceURL, this.rule.lineNumberInSource(firstMa
tchingIndex), this.rule.columnNumberInSource(firstMatchingIndex)); |
| 1470 return this._parentPane._linkifier.linkifyCSSLocation(this.rule.id.s
tyleSheetId, matchingSelectorLocation) || linkifyUncopyable(this.styleRule.sourc
eURL, this.rule.lineNumberInSource()); | 1485 return this._parentPane._linkifier.linkifyCSSLocation(this.rule.id.s
tyleSheetId, matchingSelectorLocation) || linkifyUncopyable(this.styleRule.sourc
eURL, this.rule.lineNumberInSource()); |
| 1471 } | 1486 } |
| 1472 | 1487 |
| 1473 if (!this.rule) | 1488 if (!this.rule) |
| 1474 return document.createTextNode(""); | 1489 return document.createTextNode(""); |
| 1475 | 1490 |
| 1476 if (this.rule.isUserAgent) | 1491 if (this.rule.isUserAgent) |
| 1477 return document.createTextNode(WebInspector.UIString("user agent sty
lesheet")); | 1492 return document.createTextNode(WebInspector.UIString("user agent sty
lesheet")); |
| 1478 if (this.rule.isUser) | 1493 if (this.rule.isUser) |
| 1479 return document.createTextNode(WebInspector.UIString("user styleshee
t")); | 1494 return document.createTextNode(WebInspector.UIString("user styleshee
t")); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1503 return; | 1518 return; |
| 1504 } | 1519 } |
| 1505 this.expand(); | 1520 this.expand(); |
| 1506 this.addNewBlankProperty().startEditing(); | 1521 this.addNewBlankProperty().startEditing(); |
| 1507 }, | 1522 }, |
| 1508 | 1523 |
| 1509 _handleSelectorClick: function(event) | 1524 _handleSelectorClick: function(event) |
| 1510 { | 1525 { |
| 1511 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && this.navi
gable && event.target.classList.contains("simple-selector")) { | 1526 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && this.navi
gable && event.target.classList.contains("simple-selector")) { |
| 1512 var index = event.target._selectorIndex; | 1527 var index = event.target._selectorIndex; |
| 1513 var styleSheetHeader = WebInspector.cssModel.styleSheetHeaderForId(t
his.rule.id.styleSheetId); | 1528 var styleSheetHeader = this._parentPane._target.cssModel.styleSheetH
eaderForId(this.rule.id.styleSheetId); |
| 1514 var uiLocation = styleSheetHeader.rawLocationToUILocation(this.rule.
lineNumberInSource(index), this.rule.columnNumberInSource(index)); | 1529 var uiLocation = styleSheetHeader.rawLocationToUILocation(this.rule.
lineNumberInSource(index), this.rule.columnNumberInSource(index)); |
| 1515 WebInspector.Revealer.reveal(uiLocation); | 1530 WebInspector.Revealer.reveal(uiLocation); |
| 1516 return; | 1531 return; |
| 1517 } | 1532 } |
| 1518 this._startEditingOnMouseEvent(); | 1533 this._startEditingOnMouseEvent(); |
| 1519 event.consume(true); | 1534 event.consume(true); |
| 1520 }, | 1535 }, |
| 1521 | 1536 |
| 1522 _startEditingOnMouseEvent: function() | 1537 _startEditingOnMouseEvent: function() |
| 1523 { | 1538 { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 this._editingSelectorEnded(); | 1598 this._editingSelectorEnded(); |
| 1584 if (newContent) | 1599 if (newContent) |
| 1585 newContent = newContent.trim(); | 1600 newContent = newContent.trim(); |
| 1586 if (newContent === oldContent) { | 1601 if (newContent === oldContent) { |
| 1587 // Revert to a trimmed version of the selector if need be. | 1602 // Revert to a trimmed version of the selector if need be. |
| 1588 this._selectorElement.textContent = newContent; | 1603 this._selectorElement.textContent = newContent; |
| 1589 this._moveEditorFromSelector(moveDirection); | 1604 this._moveEditorFromSelector(moveDirection); |
| 1590 return; | 1605 return; |
| 1591 } | 1606 } |
| 1592 | 1607 |
| 1593 var selectedNode = this._parentPane.node; | 1608 var selectedNode = this._parentPane._node; |
| 1594 | 1609 |
| 1595 /** | 1610 /** |
| 1596 * @param {!WebInspector.CSSRule} newRule | 1611 * @param {!WebInspector.CSSRule} newRule |
| 1597 * @this {WebInspector.StylePropertiesSection} | 1612 * @this {WebInspector.StylePropertiesSection} |
| 1598 */ | 1613 */ |
| 1599 function successCallback(newRule) | 1614 function successCallback(newRule) |
| 1600 { | 1615 { |
| 1601 var doesAffectSelectedNode = newRule.matchingSelectors.length > 0; | 1616 var doesAffectSelectedNode = newRule.matchingSelectors.length > 0; |
| 1602 if (!doesAffectSelectedNode) { | 1617 if (!doesAffectSelectedNode) { |
| 1603 this.noAffect = true; | 1618 this.noAffect = true; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1620 * @this {WebInspector.StylePropertiesSection} | 1635 * @this {WebInspector.StylePropertiesSection} |
| 1621 */ | 1636 */ |
| 1622 function finishOperationAndMoveEditor(direction) | 1637 function finishOperationAndMoveEditor(direction) |
| 1623 { | 1638 { |
| 1624 delete this._parentPane._userOperation; | 1639 delete this._parentPane._userOperation; |
| 1625 this._moveEditorFromSelector(direction); | 1640 this._moveEditorFromSelector(direction); |
| 1626 } | 1641 } |
| 1627 | 1642 |
| 1628 // This gets deleted in finishOperationAndMoveEditor(), which is called
both on success and failure. | 1643 // This gets deleted in finishOperationAndMoveEditor(), which is called
both on success and failure. |
| 1629 this._parentPane._userOperation = true; | 1644 this._parentPane._userOperation = true; |
| 1630 WebInspector.cssModel.setRuleSelector(this.rule.id, selectedNode ? selec
tedNode.id : 0, newContent, successCallback.bind(this), finishOperationAndMoveEd
itor.bind(this, moveDirection)); | 1645 this._parentPane._target.cssModel.setRuleSelector(this.rule.id, selected
Node ? selectedNode.id : 0, newContent, successCallback.bind(this), finishOperat
ionAndMoveEditor.bind(this, moveDirection)); |
| 1631 }, | 1646 }, |
| 1632 | 1647 |
| 1633 _updateRuleOrigin: function() | 1648 _updateRuleOrigin: function() |
| 1634 { | 1649 { |
| 1635 this._selectorRefElement.removeChildren(); | 1650 this._selectorRefElement.removeChildren(); |
| 1636 this._selectorRefElement.appendChild(this._createRuleOriginNode()); | 1651 this._selectorRefElement.appendChild(this._createRuleOriginNode()); |
| 1637 }, | 1652 }, |
| 1638 | 1653 |
| 1639 _editingSelectorEnded: function() | 1654 _editingSelectorEnded: function() |
| 1640 { | 1655 { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 | 1874 |
| 1860 delete this._parentPane._userOperation; | 1875 delete this._parentPane._userOperation; |
| 1861 this._editingSelectorEnded(); | 1876 this._editingSelectorEnded(); |
| 1862 this._markSelectorMatches(); | 1877 this._markSelectorMatches(); |
| 1863 } | 1878 } |
| 1864 | 1879 |
| 1865 if (newContent) | 1880 if (newContent) |
| 1866 newContent = newContent.trim(); | 1881 newContent = newContent.trim(); |
| 1867 this._parentPane._userOperation = true; | 1882 this._parentPane._userOperation = true; |
| 1868 | 1883 |
| 1869 WebInspector.cssModel.requestViaInspectorStylesheet(this.pane.node, viaI
nspectorCallback.bind(this)); | 1884 var cssModel = this._parentPane._target.cssModel; |
| 1885 cssModel.requestViaInspectorStylesheet(this._parentPane._node, viaInspec
torCallback.bind(this)); |
| 1870 | 1886 |
| 1871 /** | 1887 /** |
| 1872 * @this {WebInspector.BlankStylePropertiesSection} | 1888 * @this {WebInspector.BlankStylePropertiesSection} |
| 1873 * @param {?WebInspector.CSSStyleSheetHeader} styleSheetHeader | 1889 * @param {?WebInspector.CSSStyleSheetHeader} styleSheetHeader |
| 1874 */ | 1890 */ |
| 1875 function viaInspectorCallback(styleSheetHeader) | 1891 function viaInspectorCallback(styleSheetHeader) |
| 1876 { | 1892 { |
| 1877 if (!styleSheetHeader) { | 1893 if (!styleSheetHeader) { |
| 1878 this.editingSelectorCancelled(); | 1894 this.editingSelectorCancelled(); |
| 1879 return; | 1895 return; |
| 1880 } | 1896 } |
| 1881 WebInspector.cssModel.addRule(styleSheetHeader.id, this.pane.node, n
ewContent, successCallback.bind(this), this.editingSelectorCancelled.bind(this))
; | 1897 cssModel.addRule(styleSheetHeader.id, this._parentPane._node, newCon
tent, successCallback.bind(this), this.editingSelectorCancelled.bind(this)); |
| 1882 } | 1898 } |
| 1883 }, | 1899 }, |
| 1884 | 1900 |
| 1885 editingSelectorCancelled: function() | 1901 editingSelectorCancelled: function() |
| 1886 { | 1902 { |
| 1887 delete this._parentPane._userOperation; | 1903 delete this._parentPane._userOperation; |
| 1888 if (!this.isBlank) { | 1904 if (!this.isBlank) { |
| 1889 WebInspector.StylePropertiesSection.prototype.editingSelectorCancell
ed.call(this); | 1905 WebInspector.StylePropertiesSection.prototype.editingSelectorCancell
ed.call(this); |
| 1890 return; | 1906 return; |
| 1891 } | 1907 } |
| 1892 | 1908 |
| 1893 this._editingSelectorEnded(); | 1909 this._editingSelectorEnded(); |
| 1894 this.pane.removeSection(this); | 1910 this._parentPane.removeSection(this); |
| 1895 }, | 1911 }, |
| 1896 | 1912 |
| 1897 makeNormal: function(styleRule) | 1913 makeNormal: function(styleRule) |
| 1898 { | 1914 { |
| 1899 this.element.classList.remove("blank-section"); | 1915 this.element.classList.remove("blank-section"); |
| 1900 this.styleRule = styleRule; | 1916 this.styleRule = styleRule; |
| 1901 this.rule = styleRule.rule; | 1917 this.rule = styleRule.rule; |
| 1902 | 1918 |
| 1903 // FIXME: replace this instance by a normal WebInspector.StyleProperties
Section. | 1919 // FIXME: replace this instance by a normal WebInspector.StyleProperties
Section. |
| 1904 this._normal = true; | 1920 this._normal = true; |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2358 WebInspector.StylePropertyTreeElementBase.call(this, styleRule, style, prope
rty, inherited, false, false); | 2374 WebInspector.StylePropertyTreeElementBase.call(this, styleRule, style, prope
rty, inherited, false, false); |
| 2359 this._stylesPane = stylesPane; | 2375 this._stylesPane = stylesPane; |
| 2360 } | 2376 } |
| 2361 | 2377 |
| 2362 WebInspector.ComputedStylePropertyTreeElement.prototype = { | 2378 WebInspector.ComputedStylePropertyTreeElement.prototype = { |
| 2363 /** | 2379 /** |
| 2364 * @return {?WebInspector.DOMNode} | 2380 * @return {?WebInspector.DOMNode} |
| 2365 */ | 2381 */ |
| 2366 node: function() | 2382 node: function() |
| 2367 { | 2383 { |
| 2368 return this._stylesPane.node; | 2384 return this._stylesPane._node; |
| 2369 }, | 2385 }, |
| 2370 | 2386 |
| 2371 /** | 2387 /** |
| 2372 * @return {?WebInspector.StylesSidebarPane} | 2388 * @return {?WebInspector.StylesSidebarPane} |
| 2373 */ | 2389 */ |
| 2374 editablePane: function() | 2390 editablePane: function() |
| 2375 { | 2391 { |
| 2376 return null; | 2392 return null; |
| 2377 }, | 2393 }, |
| 2378 | 2394 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 this._parentPane = stylesPane; | 2426 this._parentPane = stylesPane; |
| 2411 this.isShorthand = isShorthand; | 2427 this.isShorthand = isShorthand; |
| 2412 } | 2428 } |
| 2413 | 2429 |
| 2414 WebInspector.StylePropertyTreeElement.prototype = { | 2430 WebInspector.StylePropertyTreeElement.prototype = { |
| 2415 /** | 2431 /** |
| 2416 * @return {?WebInspector.DOMNode} | 2432 * @return {?WebInspector.DOMNode} |
| 2417 */ | 2433 */ |
| 2418 node: function() | 2434 node: function() |
| 2419 { | 2435 { |
| 2420 return this._parentPane.node; | 2436 return this._parentPane._node; |
| 2421 }, | 2437 }, |
| 2422 | 2438 |
| 2423 /** | 2439 /** |
| 2424 * @return {?WebInspector.StylesSidebarPane} | 2440 * @return {?WebInspector.StylesSidebarPane} |
| 2425 */ | 2441 */ |
| 2426 editablePane: function() | 2442 editablePane: function() |
| 2427 { | 2443 { |
| 2428 return this._parentPane; | 2444 return this._parentPane; |
| 2429 }, | 2445 }, |
| 2430 | 2446 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2443 { | 2459 { |
| 2444 return this.treeOutline && this.treeOutline.section; | 2460 return this.treeOutline && this.treeOutline.section; |
| 2445 }, | 2461 }, |
| 2446 | 2462 |
| 2447 /** | 2463 /** |
| 2448 * @param {function()=} userCallback | 2464 * @param {function()=} userCallback |
| 2449 */ | 2465 */ |
| 2450 _updatePane: function(userCallback) | 2466 _updatePane: function(userCallback) |
| 2451 { | 2467 { |
| 2452 var section = this.section(); | 2468 var section = this.section(); |
| 2453 if (section && section.pane) | 2469 if (section && section._parentPane) |
| 2454 section.pane._refreshUpdate(section, false, userCallback); | 2470 section._parentPane._refreshUpdate(section, false, userCallback); |
| 2455 else { | 2471 else { |
| 2456 if (userCallback) | 2472 if (userCallback) |
| 2457 userCallback(); | 2473 userCallback(); |
| 2458 } | 2474 } |
| 2459 }, | 2475 }, |
| 2460 | 2476 |
| 2461 /** | 2477 /** |
| 2462 * @param {?Event} event | 2478 * @param {?Event} event |
| 2463 */ | 2479 */ |
| 2464 toggleEnabled: function(event) | 2480 toggleEnabled: function(event) |
| 2465 { | 2481 { |
| 2466 var disabled = !event.target.checked; | 2482 var disabled = !event.target.checked; |
| 2467 | 2483 |
| 2468 /** | 2484 /** |
| 2469 * @param {?WebInspector.CSSStyleDeclaration} newStyle | 2485 * @param {?WebInspector.CSSStyleDeclaration} newStyle |
| 2470 * @this {WebInspector.StylePropertyTreeElement} | 2486 * @this {WebInspector.StylePropertyTreeElement} |
| 2471 */ | 2487 */ |
| 2472 function callback(newStyle) | 2488 function callback(newStyle) |
| 2473 { | 2489 { |
| 2474 delete this._parentPane._userOperation; | 2490 delete this._parentPane._userOperation; |
| 2475 | 2491 |
| 2476 if (!newStyle) | 2492 if (!newStyle) |
| 2477 return; | 2493 return; |
| 2478 | 2494 |
| 2479 newStyle.parentRule = this.style.parentRule; | 2495 newStyle.parentRule = this.style.parentRule; |
| 2480 this.style = newStyle; | 2496 this.style = newStyle; |
| 2481 this._styleRule.style = newStyle; | 2497 this._styleRule.style = newStyle; |
| 2482 | 2498 |
| 2483 var section = this.section(); | 2499 var section = this.section(); |
| 2484 if (section && section.pane) | 2500 if (section && section._parentPane) |
| 2485 section.pane.dispatchEventToListeners("style property toggled"); | 2501 section._parentPane.dispatchEventToListeners("style property tog
gled"); |
| 2486 | 2502 |
| 2487 this._updatePane(); | 2503 this._updatePane(); |
| 2488 } | 2504 } |
| 2489 | 2505 |
| 2490 this._parentPane._userOperation = true; | 2506 this._parentPane._userOperation = true; |
| 2491 this.property.setDisabled(disabled, callback.bind(this)); | 2507 this.property.setDisabled(disabled, callback.bind(this)); |
| 2492 event.consume(); | 2508 event.consume(); |
| 2493 }, | 2509 }, |
| 2494 | 2510 |
| 2495 onpopulate: function() | 2511 onpopulate: function() |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3046 var section = this.section(); | 3062 var section = this.section(); |
| 3047 styleText = styleText.replace(/\s/g, " ").trim(); // Replace with
whitespace. | 3063 styleText = styleText.replace(/\s/g, " ").trim(); // Replace with
whitespace. |
| 3048 var styleTextLength = styleText.length; | 3064 var styleTextLength = styleText.length; |
| 3049 if (!styleTextLength && updateInterface && !isRevert && this._newPropert
y && !this._hasBeenModifiedIncrementally()) { | 3065 if (!styleTextLength && updateInterface && !isRevert && this._newPropert
y && !this._hasBeenModifiedIncrementally()) { |
| 3050 // The user deleted everything and never applied a new property valu
e via Up/Down scrolling/live editing, so remove the tree element and update. | 3066 // The user deleted everything and never applied a new property valu
e via Up/Down scrolling/live editing, so remove the tree element and update. |
| 3051 this.parent.removeChild(this); | 3067 this.parent.removeChild(this); |
| 3052 section.afterUpdate(); | 3068 section.afterUpdate(); |
| 3053 return; | 3069 return; |
| 3054 } | 3070 } |
| 3055 | 3071 |
| 3056 var currentNode = this._parentPane.node; | 3072 var currentNode = this._parentPane._node; |
| 3057 if (updateInterface) | 3073 if (updateInterface) |
| 3058 this._parentPane._userOperation = true; | 3074 this._parentPane._userOperation = true; |
| 3059 | 3075 |
| 3060 /** | 3076 /** |
| 3061 * @param {function()} userCallback | 3077 * @param {function()} userCallback |
| 3062 * @param {string} originalPropertyText | 3078 * @param {string} originalPropertyText |
| 3063 * @param {?WebInspector.CSSStyleDeclaration} newStyle | 3079 * @param {?WebInspector.CSSStyleDeclaration} newStyle |
| 3064 * @this {WebInspector.StylePropertyTreeElement} | 3080 * @this {WebInspector.StylePropertyTreeElement} |
| 3065 */ | 3081 */ |
| 3066 function callback(userCallback, originalPropertyText, newStyle) | 3082 function callback(userCallback, originalPropertyText, newStyle) |
| 3067 { | 3083 { |
| 3068 if (!newStyle) { | 3084 if (!newStyle) { |
| 3069 if (updateInterface) { | 3085 if (updateInterface) { |
| 3070 // It did not apply, cancel editing. | 3086 // It did not apply, cancel editing. |
| 3071 this._revertStyleUponEditingCanceled(originalPropertyText); | 3087 this._revertStyleUponEditingCanceled(originalPropertyText); |
| 3072 } | 3088 } |
| 3073 userCallback(); | 3089 userCallback(); |
| 3074 return; | 3090 return; |
| 3075 } | 3091 } |
| 3076 | 3092 |
| 3077 if (this._newProperty) | 3093 if (this._newProperty) |
| 3078 this._newPropertyInStyle = true; | 3094 this._newPropertyInStyle = true; |
| 3079 newStyle.parentRule = this.style.parentRule; | 3095 newStyle.parentRule = this.style.parentRule; |
| 3080 this.style = newStyle; | 3096 this.style = newStyle; |
| 3081 this.property = newStyle.propertyAt(this.property.index); | 3097 this.property = newStyle.propertyAt(this.property.index); |
| 3082 this._styleRule.style = this.style; | 3098 this._styleRule.style = this.style; |
| 3083 | 3099 |
| 3084 if (section && section.pane) | 3100 if (section && section._parentPane) |
| 3085 section.pane.dispatchEventToListeners("style edited"); | 3101 section._parentPane.dispatchEventToListeners("style edited"); |
| 3086 | 3102 |
| 3087 if (updateInterface && currentNode === this.node()) { | 3103 if (updateInterface && currentNode === this.node()) { |
| 3088 this._updatePane(userCallback); | 3104 this._updatePane(userCallback); |
| 3089 return; | 3105 return; |
| 3090 } | 3106 } |
| 3091 | 3107 |
| 3092 userCallback(); | 3108 userCallback(); |
| 3093 } | 3109 } |
| 3094 | 3110 |
| 3095 // Append a ";" if the new text does not end in ";". | 3111 // Append a ";" if the new text does not end in ";". |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3239 return; | 3255 return; |
| 3240 } | 3256 } |
| 3241 | 3257 |
| 3242 var results = this._cssCompletions.startsWith(prefix); | 3258 var results = this._cssCompletions.startsWith(prefix); |
| 3243 var selectedIndex = this._cssCompletions.mostUsedOf(results); | 3259 var selectedIndex = this._cssCompletions.mostUsedOf(results); |
| 3244 completionsReadyCallback(results, selectedIndex); | 3260 completionsReadyCallback(results, selectedIndex); |
| 3245 }, | 3261 }, |
| 3246 | 3262 |
| 3247 __proto__: WebInspector.TextPrompt.prototype | 3263 __proto__: WebInspector.TextPrompt.prototype |
| 3248 } | 3264 } |
| OLD | NEW |