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. |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
15 * its contributors may be used to endorse or promote products derived | 15 * its contributors may be used to endorse or promote products derived |
16 * from this software without specific prior written permission. | 16 * from this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 /** | |
31 * @unrestricted | |
32 */ | |
33 Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { | 30 Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { |
34 constructor() { | 31 constructor() { |
35 super(); | 32 super(); |
36 this.setMinimumSize(96, 26); | 33 this.setMinimumSize(96, 26); |
37 | 34 |
38 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this) ); | 35 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this) ); |
39 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind( this)); | 36 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind( this)); |
40 | 37 |
41 this._sectionsContainer = this.element.createChild('div'); | 38 this._sectionsContainer = this.element.createChild('div'); |
42 this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper(); | 39 this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper(); |
43 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi nkLength, /* useLinkDecorator */ true); | 40 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi nkLength, /* useLinkDecorator */ true); |
41 /** @type {?Elements.StylePropertyHighlighter} */ | |
42 this._decorator = null; | |
43 this._userOperation = false; | |
44 this._isEditingStyle = false; | |
45 /** @type {?RegExp} */ | |
46 this._filterRegex = null; | |
47 | |
48 /** @type {?Elements.StylePropertyTreeElement} */ | |
49 this._mouseDownTreeElement = null; | |
50 this._mouseDownTreeElementIsName = false; | |
51 this._mouseDownTreeElementIsValue = false; | |
44 | 52 |
45 this.element.classList.add('styles-pane'); | 53 this.element.classList.add('styles-pane'); |
46 | 54 |
47 /** @type {!Array<!Elements.SectionBlock>} */ | 55 /** @type {!Array<!Elements.SectionBlock>} */ |
48 this._sectionBlocks = []; | 56 this._sectionBlocks = []; |
49 Elements.StylesSidebarPane._instance = this; | 57 Elements.StylesSidebarPane._instance = this; |
50 UI.context.addFlavorChangeListener(SDK.DOMNode, this.forceUpdate, this); | 58 UI.context.addFlavorChangeListener(SDK.DOMNode, this.forceUpdate, this); |
51 } | 59 } |
52 | 60 |
53 /** | 61 /** |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 for (var section of block.sections) | 350 for (var section of block.sections) |
343 this._sectionsContainer.appendChild(section.element); | 351 this._sectionsContainer.appendChild(section.element); |
344 } | 352 } |
345 | 353 |
346 if (this._filterRegex) | 354 if (this._filterRegex) |
347 this._updateFilter(); | 355 this._updateFilter(); |
348 | 356 |
349 this._nodeStylesUpdatedForTest(node, true); | 357 this._nodeStylesUpdatedForTest(node, true); |
350 if (this._decorator) { | 358 if (this._decorator) { |
351 this._decorator.perform(); | 359 this._decorator.perform(); |
352 delete this._decorator; | 360 this._decorator = null; |
353 } | 361 } |
354 } | 362 } |
355 | 363 |
356 /** | 364 /** |
357 * @param {!SDK.DOMNode} node | 365 * @param {!SDK.DOMNode} node |
358 * @param {boolean} rebuild | 366 * @param {boolean} rebuild |
359 */ | 367 */ |
360 _nodeStylesUpdatedForTest(node, rebuild) { | 368 _nodeStylesUpdatedForTest(node, rebuild) { |
361 // For sniffing in tests. | 369 // For sniffing in tests. |
362 } | 370 } |
(...skipping 25 matching lines...) Expand all Loading... | |
388 if (!cssModel || !node) | 396 if (!cssModel || !node) |
389 return; | 397 return; |
390 this._userOperation = true; | 398 this._userOperation = true; |
391 cssModel.requestViaInspectorStylesheet(node, onViaInspectorStyleSheet.bind(t his)); | 399 cssModel.requestViaInspectorStylesheet(node, onViaInspectorStyleSheet.bind(t his)); |
392 | 400 |
393 /** | 401 /** |
394 * @param {?SDK.CSSStyleSheetHeader} styleSheetHeader | 402 * @param {?SDK.CSSStyleSheetHeader} styleSheetHeader |
395 * @this {Elements.StylesSidebarPane} | 403 * @this {Elements.StylesSidebarPane} |
396 */ | 404 */ |
397 function onViaInspectorStyleSheet(styleSheetHeader) { | 405 function onViaInspectorStyleSheet(styleSheetHeader) { |
398 delete this._userOperation; | 406 this._userOperation = false; |
399 this._createNewRuleInStyleSheet(styleSheetHeader); | 407 this._createNewRuleInStyleSheet(styleSheetHeader); |
400 } | 408 } |
401 } | 409 } |
402 | 410 |
403 /** | 411 /** |
404 * @param {?SDK.CSSStyleSheetHeader} styleSheetHeader | 412 * @param {?SDK.CSSStyleSheetHeader} styleSheetHeader |
405 */ | 413 */ |
406 _createNewRuleInStyleSheet(styleSheetHeader) { | 414 _createNewRuleInStyleSheet(styleSheetHeader) { |
407 if (!styleSheetHeader) | 415 if (!styleSheetHeader) |
408 return; | 416 return; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 allSections() { | 490 allSections() { |
483 var sections = []; | 491 var sections = []; |
484 for (var block of this._sectionBlocks) | 492 for (var block of this._sectionBlocks) |
485 sections = sections.concat(block.sections); | 493 sections = sections.concat(block.sections); |
486 return sections; | 494 return sections; |
487 } | 495 } |
488 }; | 496 }; |
489 | 497 |
490 Elements.StylesSidebarPane._maxLinkLength = 30; | 498 Elements.StylesSidebarPane._maxLinkLength = 30; |
491 | 499 |
492 /** | |
493 * @unrestricted | |
494 */ | |
495 Elements.SectionBlock = class { | 500 Elements.SectionBlock = class { |
496 /** | 501 /** |
497 * @param {?Element} titleElement | 502 * @param {?Element} titleElement |
498 */ | 503 */ |
499 constructor(titleElement) { | 504 constructor(titleElement) { |
500 this._titleElement = titleElement; | 505 this._titleElement = titleElement; |
501 this.sections = []; | 506 this.sections = []; |
502 } | 507 } |
503 | 508 |
504 /** | 509 /** |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 } | 550 } |
546 | 551 |
547 /** | 552 /** |
548 * @return {?Element} | 553 * @return {?Element} |
549 */ | 554 */ |
550 titleElement() { | 555 titleElement() { |
551 return this._titleElement; | 556 return this._titleElement; |
552 } | 557 } |
553 }; | 558 }; |
554 | 559 |
555 | |
556 /** | |
557 * @unrestricted | |
558 */ | |
559 Elements.StylePropertiesSection = class { | 560 Elements.StylePropertiesSection = class { |
560 /** | 561 /** |
561 * @param {!Elements.StylesSidebarPane} parentPane | 562 * @param {!Elements.StylesSidebarPane} parentPane |
562 * @param {!SDK.CSSMatchedStyles} matchedStyles | 563 * @param {!SDK.CSSMatchedStyles} matchedStyles |
563 * @param {!SDK.CSSStyleDeclaration} style | 564 * @param {!SDK.CSSStyleDeclaration} style |
564 */ | 565 */ |
565 constructor(parentPane, matchedStyles, style) { | 566 constructor(parentPane, matchedStyles, style) { |
566 this._parentPane = parentPane; | 567 this._parentPane = parentPane; |
567 this._style = style; | 568 this._style = style; |
568 this._matchedStyles = matchedStyles; | 569 this._matchedStyles = matchedStyles; |
569 this.editable = !!(style.styleSheetId && style.range); | 570 this.editable = !!(style.styleSheetId && style.range); |
571 /** @type {?number} */ | |
572 this._hoverTimer = null; | |
573 /** @type {?function(!Elements.StylePropertiesSection)} */ | |
574 this._afterUpdate = null; | |
575 this._willCauseCancelEditing = false; | |
570 | 576 |
571 var rule = style.parentRule; | 577 var rule = style.parentRule; |
572 this.element = createElementWithClass('div', 'styles-section matched-styles monospace'); | 578 this.element = createElementWithClass('div', 'styles-section matched-styles monospace'); |
573 this.element._section = this; | 579 this.element._section = this; |
574 | 580 |
575 this._titleElement = this.element.createChild('div', 'styles-section-title ' + (rule ? 'styles-selector' : '')); | 581 this._titleElement = this.element.createChild('div', 'styles-section-title ' + (rule ? 'styles-selector' : '')); |
576 | 582 |
577 this.propertiesTreeOutline = new UI.TreeOutlineInShadow(); | 583 this.propertiesTreeOutline = new UI.TreeOutlineInShadow(); |
578 this.propertiesTreeOutline.registerRequiredCSS('elements/stylesSectionTree.c ss'); | 584 this.propertiesTreeOutline.registerRequiredCSS('elements/stylesSectionTree.c ss'); |
579 this.propertiesTreeOutline.element.classList.add('style-properties', 'matche d-styles', 'monospace'); | 585 this.propertiesTreeOutline.element.classList.add('style-properties', 'matche d-styles', 'monospace'); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 child.setOverloaded(this._isPropertyOverloaded(child.property)); | 1056 child.setOverloaded(this._isPropertyOverloaded(child.property)); |
1051 child = child.traverseNextTreeElement(false, null, true); | 1057 child = child.traverseNextTreeElement(false, null, true); |
1052 } | 1058 } |
1053 } | 1059 } |
1054 this.afterUpdate(); | 1060 this.afterUpdate(); |
1055 } | 1061 } |
1056 | 1062 |
1057 afterUpdate() { | 1063 afterUpdate() { |
1058 if (this._afterUpdate) { | 1064 if (this._afterUpdate) { |
1059 this._afterUpdate(this); | 1065 this._afterUpdate(this); |
1060 delete this._afterUpdate; | 1066 this._afterUpdate = null; |
1061 this._afterUpdateFinishedForTest(); | 1067 this._afterUpdateFinishedForTest(); |
1062 } | 1068 } |
1063 } | 1069 } |
1064 | 1070 |
1065 _afterUpdateFinishedForTest() { | 1071 _afterUpdateFinishedForTest() { |
1066 } | 1072 } |
1067 | 1073 |
1068 onpopulate() { | 1074 onpopulate() { |
1069 var style = this._style; | 1075 var style = this._style; |
1070 for (var property of style.leadingProperties()) { | 1076 for (var property of style.leadingProperties()) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1183 var selectorMatchesFilter = !!regex && regex.test(selectors[i].textContent ); | 1189 var selectorMatchesFilter = !!regex && regex.test(selectors[i].textContent ); |
1184 selectors[i].classList.toggle('filter-match', selectorMatchesFilter); | 1190 selectors[i].classList.toggle('filter-match', selectorMatchesFilter); |
1185 } | 1191 } |
1186 } | 1192 } |
1187 | 1193 |
1188 /** | 1194 /** |
1189 * @return {boolean} | 1195 * @return {boolean} |
1190 */ | 1196 */ |
1191 _checkWillCancelEditing() { | 1197 _checkWillCancelEditing() { |
1192 var willCauseCancelEditing = this._willCauseCancelEditing; | 1198 var willCauseCancelEditing = this._willCauseCancelEditing; |
1193 delete this._willCauseCancelEditing; | 1199 this._willCauseCancelEditing = false; |
1194 return willCauseCancelEditing; | 1200 return willCauseCancelEditing; |
1195 } | 1201 } |
1196 | 1202 |
1197 /** | 1203 /** |
1198 * @param {!Event} event | 1204 * @param {!Event} event |
1199 */ | 1205 */ |
1200 _handleSelectorContainerClick(event) { | 1206 _handleSelectorContainerClick(event) { |
1201 if (this._checkWillCancelEditing() || !this.editable) | 1207 if (this._checkWillCancelEditing() || !this.editable) |
1202 return; | 1208 return; |
1203 if (event.target === this._selectorContainer) { | 1209 if (event.target === this._selectorContainer) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1340 | 1346 |
1341 /** | 1347 /** |
1342 * @param {boolean} success | 1348 * @param {boolean} success |
1343 * @this {Elements.StylePropertiesSection} | 1349 * @this {Elements.StylePropertiesSection} |
1344 */ | 1350 */ |
1345 function userCallback(success) { | 1351 function userCallback(success) { |
1346 if (success) { | 1352 if (success) { |
1347 this._matchedStyles.resetActiveProperties(); | 1353 this._matchedStyles.resetActiveProperties(); |
1348 this._parentPane._refreshUpdate(this); | 1354 this._parentPane._refreshUpdate(this); |
1349 } | 1355 } |
1350 delete this._parentPane._userOperation; | 1356 this._parentPane._userOperation = false; |
1351 this._editingMediaTextCommittedForTest(); | 1357 this._editingMediaTextCommittedForTest(); |
1352 } | 1358 } |
1353 | 1359 |
1354 // This gets deleted in finishOperation(), which is called both on success a nd failure. | 1360 // This gets deleted in finishOperation(), which is called both on success a nd failure. |
1355 this._parentPane._userOperation = true; | 1361 this._parentPane._userOperation = true; |
1356 this._parentPane.cssModel().setMediaText(media.styleSheetId, media.range, ne wContent).then(userCallback.bind(this)); | 1362 this._parentPane.cssModel().setMediaText(media.styleSheetId, media.range, ne wContent).then(userCallback.bind(this)); |
1357 } | 1363 } |
1358 | 1364 |
1359 _editingMediaTextCommittedForTest() { | 1365 _editingMediaTextCommittedForTest() { |
1360 } | 1366 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1467 return; | 1473 return; |
1468 } | 1474 } |
1469 var rule = this._style.parentRule; | 1475 var rule = this._style.parentRule; |
1470 if (!rule) | 1476 if (!rule) |
1471 return; | 1477 return; |
1472 | 1478 |
1473 /** | 1479 /** |
1474 * @this {Elements.StylePropertiesSection} | 1480 * @this {Elements.StylePropertiesSection} |
1475 */ | 1481 */ |
1476 function headerTextCommitted() { | 1482 function headerTextCommitted() { |
1477 delete this._parentPane._userOperation; | 1483 this._parentPane._userOperation = false; |
1478 this._moveEditorFromSelector(moveDirection); | 1484 this._moveEditorFromSelector(moveDirection); |
1479 this._editingSelectorCommittedForTest(); | 1485 this._editingSelectorCommittedForTest(); |
1480 } | 1486 } |
1481 | 1487 |
1482 // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure. | 1488 // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure. |
1483 this._parentPane._userOperation = true; | 1489 this._parentPane._userOperation = true; |
1484 this._setHeaderText(rule, newContent).then(headerTextCommitted.bind(this)); | 1490 this._setHeaderText(rule, newContent).then(headerTextCommitted.bind(this)); |
1485 } | 1491 } |
1486 | 1492 |
1487 /** | 1493 /** |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1536 | 1542 |
1537 editingSelectorCancelled() { | 1543 editingSelectorCancelled() { |
1538 this._editingSelectorEnded(); | 1544 this._editingSelectorEnded(); |
1539 | 1545 |
1540 // Mark the selectors in group if necessary. | 1546 // Mark the selectors in group if necessary. |
1541 // This is overridden by BlankStylePropertiesSection. | 1547 // This is overridden by BlankStylePropertiesSection. |
1542 this._markSelectorMatches(); | 1548 this._markSelectorMatches(); |
1543 } | 1549 } |
1544 }; | 1550 }; |
1545 | 1551 |
1546 | |
1547 /** | |
1548 * @unrestricted | |
1549 */ | |
1550 Elements.BlankStylePropertiesSection = class extends Elements.StylePropertiesSec tion { | 1552 Elements.BlankStylePropertiesSection = class extends Elements.StylePropertiesSec tion { |
1551 /** | 1553 /** |
1552 * @param {!Elements.StylesSidebarPane} stylesPane | 1554 * @param {!Elements.StylesSidebarPane} stylesPane |
1553 * @param {!SDK.CSSMatchedStyles} matchedStyles | 1555 * @param {!SDK.CSSMatchedStyles} matchedStyles |
1554 * @param {string} defaultSelectorText | 1556 * @param {string} defaultSelectorText |
1555 * @param {string} styleSheetId | 1557 * @param {string} styleSheetId |
1556 * @param {!Common.TextRange} ruleLocation | 1558 * @param {!Common.TextRange} ruleLocation |
1557 * @param {!SDK.CSSStyleDeclaration} insertAfterStyle | 1559 * @param {!SDK.CSSStyleDeclaration} insertAfterStyle |
1558 */ | 1560 */ |
1559 constructor(stylesPane, matchedStyles, defaultSelectorText, styleSheetId, rule Location, insertAfterStyle) { | 1561 constructor(stylesPane, matchedStyles, defaultSelectorText, styleSheetId, rule Location, insertAfterStyle) { |
1560 var cssModel = /** @type {!SDK.CSSModel} */ (stylesPane.cssModel()); | 1562 var cssModel = /** @type {!SDK.CSSModel} */ (stylesPane.cssModel()); |
1561 var rule = SDK.CSSStyleRule.createDummyRule(cssModel, defaultSelectorText); | 1563 var rule = SDK.CSSStyleRule.createDummyRule(cssModel, defaultSelectorText); |
1562 super(stylesPane, matchedStyles, rule.style); | 1564 super(stylesPane, matchedStyles, rule.style); |
1565 this._normal = false; | |
1563 this._ruleLocation = ruleLocation; | 1566 this._ruleLocation = ruleLocation; |
1564 this._styleSheetId = styleSheetId; | 1567 this._styleSheetId = styleSheetId; |
1565 this._selectorRefElement.removeChildren(); | 1568 this._selectorRefElement.removeChildren(); |
1566 this._selectorRefElement.appendChild(Elements.StylePropertiesSection._linkif yRuleLocation( | 1569 this._selectorRefElement.appendChild(Elements.StylePropertiesSection._linkif yRuleLocation( |
1567 cssModel, this._parentPane._linkifier, styleSheetId, this._actualRuleLoc ation())); | 1570 cssModel, this._parentPane._linkifier, styleSheetId, this._actualRuleLoc ation())); |
1568 if (insertAfterStyle && insertAfterStyle.parentRule) | 1571 if (insertAfterStyle && insertAfterStyle.parentRule) |
1569 this._createMediaList(insertAfterStyle.parentRule.media); | 1572 this._createMediaList(insertAfterStyle.parentRule.media); |
1570 this.element.classList.add('blank-section'); | 1573 this.element.classList.add('blank-section'); |
1571 } | 1574 } |
1572 | 1575 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1604 */ | 1607 */ |
1605 editingSelectorCommitted(element, newContent, oldContent, context, moveDirecti on) { | 1608 editingSelectorCommitted(element, newContent, oldContent, context, moveDirecti on) { |
1606 if (!this.isBlank) { | 1609 if (!this.isBlank) { |
1607 super.editingSelectorCommitted(element, newContent, oldContent, context, m oveDirection); | 1610 super.editingSelectorCommitted(element, newContent, oldContent, context, m oveDirection); |
1608 return; | 1611 return; |
1609 } | 1612 } |
1610 | 1613 |
1611 /** | 1614 /** |
1612 * @param {?SDK.CSSStyleRule} newRule | 1615 * @param {?SDK.CSSStyleRule} newRule |
1613 * @return {!Promise} | 1616 * @return {!Promise} |
1614 * @this {Elements.StylePropertiesSection} | 1617 * @this {Elements.BlankStylePropertiesSection} |
1615 */ | 1618 */ |
1616 function onRuleAdded(newRule) { | 1619 function onRuleAdded(newRule) { |
1617 if (!newRule) { | 1620 if (!newRule) { |
1618 this.editingSelectorCancelled(); | 1621 this.editingSelectorCancelled(); |
1619 this._editingSelectorCommittedForTest(); | 1622 this._editingSelectorCommittedForTest(); |
1620 return Promise.resolve(); | 1623 return Promise.resolve(); |
1621 } | 1624 } |
1622 return this._matchedStyles.addNewRule(newRule, this._matchedStyles.node()) | 1625 return this._matchedStyles.addNewRule(newRule, this._matchedStyles.node()) |
1623 .then(onAddedToCascade.bind(this, newRule)); | 1626 .then(onAddedToCascade.bind(this, newRule)); |
1624 } | 1627 } |
1625 | 1628 |
1626 /** | 1629 /** |
1627 * @param {!SDK.CSSStyleRule} newRule | 1630 * @param {!SDK.CSSStyleRule} newRule |
1628 * @this {Elements.StylePropertiesSection} | 1631 * @this {Elements.BlankStylePropertiesSection} |
1629 */ | 1632 */ |
1630 function onAddedToCascade(newRule) { | 1633 function onAddedToCascade(newRule) { |
1631 var doesSelectorAffectSelectedNode = this._matchedStyles.matchingSelectors (newRule).length > 0; | 1634 var doesSelectorAffectSelectedNode = this._matchedStyles.matchingSelectors (newRule).length > 0; |
1632 this._makeNormal(newRule); | 1635 this._makeNormal(newRule); |
1633 | 1636 |
1634 if (!doesSelectorAffectSelectedNode) | 1637 if (!doesSelectorAffectSelectedNode) |
1635 this.propertiesTreeOutline.element.classList.add('no-affect'); | 1638 this.propertiesTreeOutline.element.classList.add('no-affect'); |
1636 | 1639 |
1637 this._updateRuleOrigin(); | 1640 this._updateRuleOrigin(); |
1638 if (this.element.parentElement) // Might have been detached already. | 1641 if (this.element.parentElement) // Might have been detached already. |
1639 this._moveEditorFromSelector(moveDirection); | 1642 this._moveEditorFromSelector(moveDirection); |
1640 | 1643 |
1641 delete this._parentPane._userOperation; | 1644 this._parentPane._userOperation = false; |
1642 this._editingSelectorEnded(); | 1645 this._editingSelectorEnded(); |
1643 this._markSelectorMatches(); | 1646 this._markSelectorMatches(); |
1644 | 1647 |
1645 this._editingSelectorCommittedForTest(); | 1648 this._editingSelectorCommittedForTest(); |
1646 } | 1649 } |
1647 | 1650 |
1648 if (newContent) | 1651 if (newContent) |
1649 newContent = newContent.trim(); | 1652 newContent = newContent.trim(); |
1650 this._parentPane._userOperation = true; | 1653 this._parentPane._userOperation = true; |
1651 | 1654 |
1652 var cssModel = this._parentPane.cssModel(); | 1655 var cssModel = this._parentPane.cssModel(); |
1653 var ruleText = this._rulePrefix() + newContent + ' {}'; | 1656 var ruleText = this._rulePrefix() + newContent + ' {}'; |
1654 cssModel.addRule(this._styleSheetId, ruleText, this._ruleLocation).then(onRu leAdded.bind(this)); | 1657 cssModel.addRule(this._styleSheetId, ruleText, this._ruleLocation).then(onRu leAdded.bind(this)); |
1655 } | 1658 } |
1656 | 1659 |
1657 /** | 1660 /** |
1658 * @override | 1661 * @override |
1659 */ | 1662 */ |
1660 editingSelectorCancelled() { | 1663 editingSelectorCancelled() { |
1661 delete this._parentPane._userOperation; | 1664 this._parentPane._userOperation = false; |
1662 if (!this.isBlank) { | 1665 if (!this.isBlank) { |
1663 super.editingSelectorCancelled(); | 1666 super.editingSelectorCancelled(); |
1664 return; | 1667 return; |
1665 } | 1668 } |
1666 | 1669 |
1667 this._editingSelectorEnded(); | 1670 this._editingSelectorEnded(); |
1668 this._parentPane.removeSection(this); | 1671 this._parentPane.removeSection(this); |
1669 } | 1672 } |
1670 | 1673 |
1671 /** | 1674 /** |
1672 * @param {!SDK.CSSRule} newRule | 1675 * @param {!SDK.CSSRule} newRule |
1673 */ | 1676 */ |
1674 _makeNormal(newRule) { | 1677 _makeNormal(newRule) { |
1675 this.element.classList.remove('blank-section'); | 1678 this.element.classList.remove('blank-section'); |
1676 this._style = newRule.style; | 1679 this._style = newRule.style; |
1677 // FIXME: replace this instance by a normal Elements.StylePropertiesSection. | 1680 // FIXME: replace this instance by a normal Elements.StylePropertiesSection. |
1678 this._normal = true; | 1681 this._normal = true; |
1679 } | 1682 } |
1680 }; | 1683 }; |
1681 | 1684 |
1682 /** | |
1683 * @unrestricted | |
1684 */ | |
1685 Elements.KeyframePropertiesSection = class extends Elements.StylePropertiesSecti on { | 1685 Elements.KeyframePropertiesSection = class extends Elements.StylePropertiesSecti on { |
1686 /** | 1686 /** |
1687 * @param {!Elements.StylesSidebarPane} stylesPane | 1687 * @param {!Elements.StylesSidebarPane} stylesPane |
1688 * @param {!SDK.CSSMatchedStyles} matchedStyles | 1688 * @param {!SDK.CSSMatchedStyles} matchedStyles |
1689 * @param {!SDK.CSSStyleDeclaration} style | 1689 * @param {!SDK.CSSStyleDeclaration} style |
1690 */ | 1690 */ |
1691 constructor(stylesPane, matchedStyles, style) { | 1691 constructor(stylesPane, matchedStyles, style) { |
1692 super(stylesPane, matchedStyles, style); | 1692 super(stylesPane, matchedStyles, style); |
1693 this._selectorElement.className = 'keyframe-key'; | 1693 this._selectorElement.className = 'keyframe-key'; |
1694 } | 1694 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1756 this._selectorElement.textContent = this._style.parentRule.key().text; | 1756 this._selectorElement.textContent = this._style.parentRule.key().text; |
1757 } | 1757 } |
1758 | 1758 |
1759 /** | 1759 /** |
1760 * @override | 1760 * @override |
1761 */ | 1761 */ |
1762 _highlight() { | 1762 _highlight() { |
1763 } | 1763 } |
1764 }; | 1764 }; |
1765 | 1765 |
1766 /** | |
1767 * @unrestricted | |
1768 */ | |
1769 Elements.StylePropertyTreeElement = class extends UI.TreeElement { | 1766 Elements.StylePropertyTreeElement = class extends UI.TreeElement { |
1770 /** | 1767 /** |
1771 * @param {!Elements.StylesSidebarPane} stylesPane | 1768 * @param {!Elements.StylesSidebarPane} stylesPane |
1772 * @param {!SDK.CSSMatchedStyles} matchedStyles | 1769 * @param {!SDK.CSSMatchedStyles} matchedStyles |
1773 * @param {!SDK.CSSProperty} property | 1770 * @param {!SDK.CSSProperty} property |
1774 * @param {boolean} isShorthand | 1771 * @param {boolean} isShorthand |
1775 * @param {boolean} inherited | 1772 * @param {boolean} inherited |
1776 * @param {boolean} overloaded | 1773 * @param {boolean} overloaded |
1777 */ | 1774 */ |
1778 constructor(stylesPane, matchedStyles, property, isShorthand, inherited, overl oaded) { | 1775 constructor(stylesPane, matchedStyles, property, isShorthand, inherited, overl oaded) { |
1779 // Pass an empty title, the title gets made later in onattach. | 1776 // Pass an empty title, the title gets made later in onattach. |
1780 super('', isShorthand); | 1777 super('', isShorthand); |
1781 this._style = property.ownerStyle; | 1778 this._style = property.ownerStyle; |
1782 this._matchedStyles = matchedStyles; | 1779 this._matchedStyles = matchedStyles; |
1783 this.property = property; | 1780 this.property = property; |
1784 this._inherited = inherited; | 1781 this._inherited = inherited; |
1785 this._overloaded = overloaded; | 1782 this._overloaded = overloaded; |
1786 this.selectable = false; | 1783 this.selectable = false; |
1787 this._parentPane = stylesPane; | 1784 this._parentPane = stylesPane; |
1788 this.isShorthand = isShorthand; | 1785 this.isShorthand = isShorthand; |
1789 this._applyStyleThrottler = new Common.Throttler(0); | 1786 this._applyStyleThrottler = new Common.Throttler(0); |
1787 this._newProperty = false; | |
1788 this._expandedDueToFilter = false; | |
1789 this.valueElement = null; | |
1790 this.nameElement = null; | |
1791 this._expandElement = null; | |
1792 this._originalPropertyText = ''; | |
1793 this._prompt = null; | |
einbinder
2017/02/08 02:05:30
This was scary, working with TextPrompt without he
| |
1794 this._propertyHasBeenEditedIncrementally = false; | |
1790 } | 1795 } |
1791 | 1796 |
1792 /** | 1797 /** |
1793 * @return {boolean} | 1798 * @return {boolean} |
1794 */ | 1799 */ |
1795 _editable() { | 1800 _editable() { |
1796 return !!(this._style.styleSheetId && this._style.range); | 1801 return !!(this._style.styleSheetId && this._style.range); |
1797 } | 1802 } |
1798 | 1803 |
1799 /** | 1804 /** |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2031 var disabled = !event.target.checked; | 2036 var disabled = !event.target.checked; |
2032 var oldStyleRange = this._style.range; | 2037 var oldStyleRange = this._style.range; |
2033 if (!oldStyleRange) | 2038 if (!oldStyleRange) |
2034 return; | 2039 return; |
2035 | 2040 |
2036 /** | 2041 /** |
2037 * @param {boolean} success | 2042 * @param {boolean} success |
2038 * @this {Elements.StylePropertyTreeElement} | 2043 * @this {Elements.StylePropertyTreeElement} |
2039 */ | 2044 */ |
2040 function callback(success) { | 2045 function callback(success) { |
2041 delete this._parentPane._userOperation; | 2046 this._parentPane._userOperation = false; |
2042 | 2047 |
2043 if (!success) | 2048 if (!success) |
2044 return; | 2049 return; |
2045 this._matchedStyles.resetActiveProperties(); | 2050 this._matchedStyles.resetActiveProperties(); |
2046 this._updatePane(); | 2051 this._updatePane(); |
2047 this.styleTextAppliedForTest(); | 2052 this.styleTextAppliedForTest(); |
2048 } | 2053 } |
2049 | 2054 |
2050 event.consume(); | 2055 event.consume(); |
2051 this._parentPane._userOperation = true; | 2056 this._parentPane._userOperation = true; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2098 this._parentPane._mouseDownTreeElement = this; | 2103 this._parentPane._mouseDownTreeElement = this; |
2099 this._parentPane._mouseDownTreeElementIsName = | 2104 this._parentPane._mouseDownTreeElementIsName = |
2100 this.nameElement && this.nameElement.isSelfOrAncestor(event.target); | 2105 this.nameElement && this.nameElement.isSelfOrAncestor(event.target); |
2101 this._parentPane._mouseDownTreeElementIsValue = | 2106 this._parentPane._mouseDownTreeElementIsValue = |
2102 this.valueElement && this.valueElement.isSelfOrAncestor(event.target); | 2107 this.valueElement && this.valueElement.isSelfOrAncestor(event.target); |
2103 } | 2108 } |
2104 } | 2109 } |
2105 | 2110 |
2106 _resetMouseDownElement() { | 2111 _resetMouseDownElement() { |
2107 if (this._parentPane) { | 2112 if (this._parentPane) { |
2108 delete this._parentPane._mouseDownTreeElement; | 2113 this._parentPane._mouseDownTreeElement = null; |
2109 delete this._parentPane._mouseDownTreeElementIsName; | 2114 this._parentPane._mouseDownTreeElementIsName = false; |
2110 delete this._parentPane._mouseDownTreeElementIsValue; | 2115 this._parentPane._mouseDownTreeElementIsValue = false; |
2111 } | 2116 } |
2112 } | 2117 } |
2113 | 2118 |
2114 /** | 2119 /** |
2115 * @override | 2120 * @override |
2116 */ | 2121 */ |
2117 onexpand() { | 2122 onexpand() { |
2118 this._updateExpandElement(); | 2123 this._updateExpandElement(); |
2119 } | 2124 } |
2120 | 2125 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2499 editingCancelled(element, context) { | 2504 editingCancelled(element, context) { |
2500 this._removePrompt(); | 2505 this._removePrompt(); |
2501 this._revertStyleUponEditingCanceled(); | 2506 this._revertStyleUponEditingCanceled(); |
2502 // This should happen last, as it clears the info necessary to restore the p roperty value after [Page]Up/Down changes. | 2507 // This should happen last, as it clears the info necessary to restore the p roperty value after [Page]Up/Down changes. |
2503 this.editingEnded(context); | 2508 this.editingEnded(context); |
2504 } | 2509 } |
2505 | 2510 |
2506 _revertStyleUponEditingCanceled() { | 2511 _revertStyleUponEditingCanceled() { |
2507 if (this._propertyHasBeenEditedIncrementally) { | 2512 if (this._propertyHasBeenEditedIncrementally) { |
2508 this.applyStyleText(this._originalPropertyText, false); | 2513 this.applyStyleText(this._originalPropertyText, false); |
2509 delete this._originalPropertyText; | 2514 this._originalPropertyText = ''; |
einbinder
2017/02/08 02:05:29
I am a little concerned about originalPropertyText
| |
2510 } else if (this._newProperty) { | 2515 } else if (this._newProperty) { |
2511 this.treeOutline.removeChild(this); | 2516 this.treeOutline.removeChild(this); |
2512 } else { | 2517 } else { |
2513 this.updateTitle(); | 2518 this.updateTitle(); |
2514 } | 2519 } |
2515 } | 2520 } |
2516 | 2521 |
2517 /** | 2522 /** |
2518 * @param {string} moveDirection | 2523 * @param {string} moveDirection |
2519 * @return {?Elements.StylePropertyTreeElement} | 2524 * @return {?Elements.StylePropertyTreeElement} |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2748 * @return {boolean} | 2753 * @return {boolean} |
2749 */ | 2754 */ |
2750 isEventWithinDisclosureTriangle(event) { | 2755 isEventWithinDisclosureTriangle(event) { |
2751 return event.target === this._expandElement; | 2756 return event.target === this._expandElement; |
2752 } | 2757 } |
2753 }; | 2758 }; |
2754 | 2759 |
2755 /** @typedef {{expanded: boolean, hasChildren: boolean, isEditingName: boolean, previousContent: string}} */ | 2760 /** @typedef {{expanded: boolean, hasChildren: boolean, isEditingName: boolean, previousContent: string}} */ |
2756 Elements.StylePropertyTreeElement.Context; | 2761 Elements.StylePropertyTreeElement.Context; |
2757 | 2762 |
2758 /** | |
2759 * @unrestricted | |
2760 */ | |
2761 Elements.StylesSidebarPane.CSSPropertyPrompt = class extends UI.TextPrompt { | 2763 Elements.StylesSidebarPane.CSSPropertyPrompt = class extends UI.TextPrompt { |
2762 /** | 2764 /** |
2763 * @param {!Array<string>} cssCompletions | 2765 * @param {!Array<string>} cssCompletions |
2764 * @param {!Array<string>} cssVariables | 2766 * @param {!Array<string>} cssVariables |
2765 * @param {!Elements.StylePropertyTreeElement} treeElement | 2767 * @param {!Elements.StylePropertyTreeElement} treeElement |
2766 * @param {boolean} isEditingName | 2768 * @param {boolean} isEditingName |
2767 */ | 2769 */ |
2768 constructor(cssCompletions, cssVariables, treeElement, isEditingName) { | 2770 constructor(cssCompletions, cssVariables, treeElement, isEditingName) { |
2769 // Use the same callback both for applyItemCallback and acceptItemCallback. | 2771 // Use the same callback both for applyItemCallback and acceptItemCallback. |
2770 super(); | 2772 super(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2866 * @return {string} | 2868 * @return {string} |
2867 * @this {Elements.StylesSidebarPane.CSSPropertyPrompt} | 2869 * @this {Elements.StylesSidebarPane.CSSPropertyPrompt} |
2868 */ | 2870 */ |
2869 function customNumberHandler(prefix, number, suffix) { | 2871 function customNumberHandler(prefix, number, suffix) { |
2870 if (number !== 0 && !suffix.length && SDK.cssMetadata().isLengthProperty(t his._treeElement.property.name)) | 2872 if (number !== 0 && !suffix.length && SDK.cssMetadata().isLengthProperty(t his._treeElement.property.name)) |
2871 suffix = 'px'; | 2873 suffix = 'px'; |
2872 return prefix + number + suffix; | 2874 return prefix + number + suffix; |
2873 } | 2875 } |
2874 | 2876 |
2875 // Handle numeric value increment/decrement only at this point. | 2877 // Handle numeric value increment/decrement only at this point. |
2876 if (!this._isEditingName && | 2878 if (!this._isEditingName && this._treeElement.valueElement && |
einbinder
2017/02/08 02:05:29
valueElement could be null here. It shouldn't be b
| |
2877 UI.handleElementValueModifications( | 2879 UI.handleElementValueModifications( |
2878 event, this._treeElement.valueElement, finishHandler.bind(this), thi s._isValueSuggestion.bind(this), | 2880 event, this._treeElement.valueElement, finishHandler.bind(this), thi s._isValueSuggestion.bind(this), |
2879 customNumberHandler.bind(this))) | 2881 customNumberHandler.bind(this))) |
2880 return true; | 2882 return true; |
2881 | 2883 |
2882 return false; | 2884 return false; |
2883 } | 2885 } |
2884 | 2886 |
2885 /** | 2887 /** |
2886 * @param {string} word | 2888 * @param {string} word |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2935 if (index === 0) { | 2937 if (index === 0) { |
2936 var priority = this._isEditingName ? SDK.cssMetadata().propertyUsageWeig ht(completion) : 1; | 2938 var priority = this._isEditingName ? SDK.cssMetadata().propertyUsageWeig ht(completion) : 1; |
2937 prefixResults.push({text: completion, priority: priority}); | 2939 prefixResults.push({text: completion, priority: priority}); |
2938 } else if (index > -1) { | 2940 } else if (index > -1) { |
2939 anywhereResults.push({text: completion}); | 2941 anywhereResults.push({text: completion}); |
2940 } | 2942 } |
2941 } | 2943 } |
2942 } | 2944 } |
2943 }; | 2945 }; |
2944 | 2946 |
2945 /** | |
2946 * @unrestricted | |
2947 */ | |
2948 Elements.StylesSidebarPropertyRenderer = class { | 2947 Elements.StylesSidebarPropertyRenderer = class { |
2949 /** | 2948 /** |
2950 * @param {?SDK.CSSRule} rule | 2949 * @param {?SDK.CSSRule} rule |
2951 * @param {?SDK.DOMNode} node | 2950 * @param {?SDK.DOMNode} node |
2952 * @param {string} name | 2951 * @param {string} name |
2953 * @param {string} value | 2952 * @param {string} value |
2954 */ | 2953 */ |
2955 constructor(rule, node, name, value) { | 2954 constructor(rule, node, name, value) { |
2956 this._rule = rule; | 2955 this._rule = rule; |
2957 this._node = node; | 2956 this._node = node; |
2958 this._propertyName = name; | 2957 this._propertyName = name; |
2959 this._propertyValue = value; | 2958 this._propertyValue = value; |
2959 /** @type {?function(string):!Node} */ | |
2960 this._colorHandler = null; | |
2961 /** @type {?function(string):!Node} */ | |
2962 this._bezierHandler = null; | |
2963 /** @type {?function(string, string):!Node} */ | |
2964 this._shadowHandler = null; | |
2960 } | 2965 } |
2961 | 2966 |
2962 /** | 2967 /** |
2963 * @param {function(string):!Node} handler | 2968 * @param {function(string):!Node} handler |
2964 */ | 2969 */ |
2965 setColorHandler(handler) { | 2970 setColorHandler(handler) { |
2966 this._colorHandler = handler; | 2971 this._colorHandler = handler; |
2967 } | 2972 } |
2968 | 2973 |
2969 /** | 2974 /** |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3046 else if (this._node) | 3051 else if (this._node) |
3047 hrefUrl = this._node.resolveURL(url); | 3052 hrefUrl = this._node.resolveURL(url); |
3048 container.appendChild(Components.Linkifier.linkifyURL(hrefUrl || url, url, ' ', undefined, undefined, true)); | 3053 container.appendChild(Components.Linkifier.linkifyURL(hrefUrl || url, url, ' ', undefined, undefined, true)); |
3049 container.createTextChild(')'); | 3054 container.createTextChild(')'); |
3050 return container; | 3055 return container; |
3051 } | 3056 } |
3052 }; | 3057 }; |
3053 | 3058 |
3054 /** | 3059 /** |
3055 * @implements {UI.ToolbarItem.Provider} | 3060 * @implements {UI.ToolbarItem.Provider} |
3056 * @unrestricted | |
3057 */ | 3061 */ |
3058 Elements.StylesSidebarPane.ButtonProvider = class { | 3062 Elements.StylesSidebarPane.ButtonProvider = class { |
3059 constructor() { | 3063 constructor() { |
3060 this._button = new UI.ToolbarButton(Common.UIString('New Style Rule'), 'larg eicon-add'); | 3064 this._button = new UI.ToolbarButton(Common.UIString('New Style Rule'), 'larg eicon-add'); |
3061 this._button.addEventListener(UI.ToolbarButton.Events.Click, this._clicked, this); | 3065 this._button.addEventListener(UI.ToolbarButton.Events.Click, this._clicked, this); |
3062 var longclickTriangle = UI.Icon.create('largeicon-longclick-triangle', 'long -click-glyph'); | 3066 var longclickTriangle = UI.Icon.create('largeicon-longclick-triangle', 'long -click-glyph'); |
3063 this._button.element.appendChild(longclickTriangle); | 3067 this._button.element.appendChild(longclickTriangle); |
3064 | 3068 |
3065 new UI.LongClickController(this._button.element, this._longClicked.bind(this )); | 3069 new UI.LongClickController(this._button.element, this._longClicked.bind(this )); |
3066 UI.context.addFlavorChangeListener(SDK.DOMNode, onNodeChanged.bind(this)); | 3070 UI.context.addFlavorChangeListener(SDK.DOMNode, onNodeChanged.bind(this)); |
(...skipping 24 matching lines...) Expand all Loading... | |
3091 } | 3095 } |
3092 | 3096 |
3093 /** | 3097 /** |
3094 * @override | 3098 * @override |
3095 * @return {!UI.ToolbarItem} | 3099 * @return {!UI.ToolbarItem} |
3096 */ | 3100 */ |
3097 item() { | 3101 item() { |
3098 return this._button; | 3102 return this._button; |
3099 } | 3103 } |
3100 }; | 3104 }; |
OLD | NEW |