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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 2153263002: DevTools: [SSP] simplify Control-Click functionality (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ssp
Patch Set: rebaseline Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/elements/elementsPanel.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 this.setMinimumSize(96, 26); 37 this.setMinimumSize(96, 26);
38 38
39 WebInspector.moduleSetting("colorFormat").addChangeListener(this.update.bind (this)); 39 WebInspector.moduleSetting("colorFormat").addChangeListener(this.update.bind (this));
40 WebInspector.moduleSetting("textEditorIndent").addChangeListener(this.update .bind(this)); 40 WebInspector.moduleSetting("textEditorIndent").addChangeListener(this.update .bind(this));
41 41
42 this._sectionsContainer = this.element.createChild("div"); 42 this._sectionsContainer = this.element.createChild("div");
43 this._swatchPopoverHelper = new WebInspector.SwatchPopoverHelper(); 43 this._swatchPopoverHelper = new WebInspector.SwatchPopoverHelper();
44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter()); 44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter());
45 45
46 this.element.classList.add("styles-pane"); 46 this.element.classList.add("styles-pane");
47 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind( this), false);
48 this._keyDownBound = this._keyDown.bind(this);
49 this._keyUpBound = this._keyUp.bind(this);
50 47
51 /** @type {!Array<!WebInspector.SectionBlock>} */ 48 /** @type {!Array<!WebInspector.SectionBlock>} */
52 this._sectionBlocks = []; 49 this._sectionBlocks = [];
53 WebInspector.StylesSidebarPane._instance = this; 50 WebInspector.StylesSidebarPane._instance = this;
54 51
55 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this); 52 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this);
56 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.forc eUpdate, this); 53 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.forc eUpdate, this);
57 } 54 }
58 55
59 /** 56 /**
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 this._updateFilter(); 220 this._updateFilter();
224 this._nodeStylesUpdatedForTest(node, false); 221 this._nodeStylesUpdatedForTest(node, false);
225 }, 222 },
226 223
227 /** 224 /**
228 * @override 225 * @override
229 * @return {!Promise.<?>} 226 * @return {!Promise.<?>}
230 */ 227 */
231 doUpdate: function() 228 doUpdate: function()
232 { 229 {
233 this._discardElementUnderMouse();
234
235 return this._fetchMatchedCascade() 230 return this._fetchMatchedCascade()
236 .then(this._innerRebuildUpdate.bind(this)); 231 .then(this._innerRebuildUpdate.bind(this));
237 }, 232 },
238 233
239 _resetCache: function() 234 _resetCache: function()
240 { 235 {
241 if (this.cssModel()) 236 if (this.cssModel())
242 this.cssModel().discardCachedMatchedCascade(); 237 this.cssModel().discardCachedMatchedCascade();
243 }, 238 },
244 239
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 464
470 _updateFilter: function() 465 _updateFilter: function()
471 { 466 {
472 for (var block of this._sectionBlocks) 467 for (var block of this._sectionBlocks)
473 block.updateFilter(); 468 block.updateFilter();
474 }, 469 },
475 470
476 /** 471 /**
477 * @override 472 * @override
478 */ 473 */
479 wasShown: function()
480 {
481 WebInspector.ElementsSidebarPane.prototype.wasShown.call(this);
482 this.element.ownerDocument.body.addEventListener("keydown", this._keyDow nBound, false);
483 this.element.ownerDocument.body.addEventListener("keyup", this._keyUpBou nd, false);
484 },
485
486 /**
487 * @override
488 */
489 willHide: function() 474 willHide: function()
490 { 475 {
491 this.element.ownerDocument.body.removeEventListener("keydown", this._key DownBound, false);
492 this.element.ownerDocument.body.removeEventListener("keyup", this._keyUp Bound, false);
493 this._swatchPopoverHelper.hide(); 476 this._swatchPopoverHelper.hide();
494 this._discardElementUnderMouse();
495 WebInspector.ElementsSidebarPane.prototype.willHide.call(this); 477 WebInspector.ElementsSidebarPane.prototype.willHide.call(this);
496 }, 478 },
497 479
498 _discardElementUnderMouse: function()
499 {
500 if (this._elementUnderMouse)
501 this._elementUnderMouse.classList.remove("styles-panel-hovered");
502 delete this._elementUnderMouse;
503 },
504
505 /**
506 * @param {!Event} event
507 */
508 _mouseMovedOverElement: function(event)
509 {
510 if (this._elementUnderMouse && event.target !== this._elementUnderMouse)
511 this._discardElementUnderMouse();
512 this._elementUnderMouse = event.target;
513 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(/** @type {!MouseEv ent} */(event))) {
514 this._elementUnderMouse.classList.add("styles-panel-hovered");
515 var selectorElement = this._elementUnderMouse.enclosingNodeOrSelfWit hClass("selector");
516 var sectionElement = selectorElement ? selectorElement.enclosingNode OrSelfWithClass("styles-section") : null;
517 if (sectionElement)
518 sectionElement._section.makeHoverableSelectorsMode();
519 }
520 },
521
522 /**
523 * @param {!Event} event
524 */
525 _keyDown: function(event)
526 {
527 if ((!WebInspector.isMac() && event.keyCode === WebInspector.KeyboardSho rtcut.Keys.Ctrl.code) ||
528 (WebInspector.isMac() && event.keyCode === WebInspector.KeyboardShor tcut.Keys.Meta.code)) {
529 if (this._elementUnderMouse)
530 this._elementUnderMouse.classList.add("styles-panel-hovered");
531 }
532 },
533
534 /**
535 * @param {!Event} event
536 */
537 _keyUp: function(event)
538 {
539 if ((!WebInspector.isMac() && event.keyCode === WebInspector.KeyboardSho rtcut.Keys.Ctrl.code) ||
540 (WebInspector.isMac() && event.keyCode === WebInspector.KeyboardShor tcut.Keys.Meta.code)) {
541 this._discardElementUnderMouse();
542 }
543 },
544
545 /** 480 /**
546 * @return {!Array<!WebInspector.StylePropertiesSection>} 481 * @return {!Array<!WebInspector.StylePropertiesSection>}
547 */ 482 */
548 allSections: function() 483 allSections: function()
549 { 484 {
550 var sections = []; 485 var sections = [];
551 for (var block of this._sectionBlocks) 486 for (var block of this._sectionBlocks)
552 sections = sections.concat(block.sections); 487 sections = sections.concat(block.sections);
553 return sections; 488 return sections;
554 }, 489 },
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 selectorContainer.addEventListener("click", this._handleSelectorContainerCli ck.bind(this), false); 643 selectorContainer.addEventListener("click", this._handleSelectorContainerCli ck.bind(this), false);
709 644
710 var closeBrace = this.element.createChild("div", "sidebar-pane-closing-brace "); 645 var closeBrace = this.element.createChild("div", "sidebar-pane-closing-brace ");
711 closeBrace.textContent = "}"; 646 closeBrace.textContent = "}";
712 647
713 this._createHoverMenuToolbar(closeBrace); 648 this._createHoverMenuToolbar(closeBrace);
714 649
715 this._selectorElement.addEventListener("click", this._handleSelectorClick.bi nd(this), false); 650 this._selectorElement.addEventListener("click", this._handleSelectorClick.bi nd(this), false);
716 this.element.addEventListener("mousedown", this._handleEmptySpaceMouseDown.b ind(this), false); 651 this.element.addEventListener("mousedown", this._handleEmptySpaceMouseDown.b ind(this), false);
717 this.element.addEventListener("click", this._handleEmptySpaceClick.bind(this ), false); 652 this.element.addEventListener("click", this._handleEmptySpaceClick.bind(this ), false);
653 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), fal se);
654 this.element.addEventListener("mouseleave", this._setSectionHovered.bind(thi s, false), false);
718 655
719 if (rule) { 656 if (rule) {
720 // Prevent editing the user agent and user rules. 657 // Prevent editing the user agent and user rules.
721 if (rule.isUserAgent() || rule.isInjected()) { 658 if (rule.isUserAgent() || rule.isInjected()) {
722 this.editable = false; 659 this.editable = false;
723 } else { 660 } else {
724 // Check this is a real CSSRule, not a bogus object coming from WebI nspector.BlankStylePropertiesSection. 661 // Check this is a real CSSRule, not a bogus object coming from WebI nspector.BlankStylePropertiesSection.
725 if (rule.styleSheetId) 662 if (rule.styleSheetId)
726 this.navigable = !!rule.resourceURL(); 663 this.navigable = !!rule.resourceURL();
727 } 664 }
(...skipping 11 matching lines...) Expand all
739 676
740 if (!this.editable) 677 if (!this.editable)
741 this.element.classList.add("read-only"); 678 this.element.classList.add("read-only");
742 679
743 this._markSelectorMatches(); 680 this._markSelectorMatches();
744 this.onpopulate(); 681 this.onpopulate();
745 } 682 }
746 683
747 WebInspector.StylePropertiesSection.prototype = { 684 WebInspector.StylePropertiesSection.prototype = {
748 /** 685 /**
686 * @param {boolean} isHovered
687 */
688 _setSectionHovered: function(isHovered)
689 {
690 this.element.classList.toggle("styles-panel-hovered", isHovered);
691 if (this._hoverableSelectorsMode !== isHovered) {
692 this._hoverableSelectorsMode = isHovered;
693 this._markSelectorMatches();
694 }
695 },
696
697 /**
698 * @param {!Event} event
699 */
700 _onMouseMove: function(event)
701 {
702 var hasCtrlOrMeta = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(/** @type {!MouseEvent} */(event));
703 this._setSectionHovered(hasCtrlOrMeta);
704 },
705
706 /**
749 * @param {!Element} container 707 * @param {!Element} container
750 */ 708 */
751 _createHoverMenuToolbar: function(container) 709 _createHoverMenuToolbar: function(container)
752 { 710 {
753 if (!this.editable) 711 if (!this.editable)
754 return; 712 return;
755 var items = []; 713 var items = [];
756 var colorButton = new WebInspector.ToolbarButton(WebInspector.UIString(" Add color"), "foreground-color-toolbar-item"); 714 var colorButton = new WebInspector.ToolbarButton(WebInspector.UIString(" Add color"), "foreground-color-toolbar-item");
757 colorButton.addEventListener("click", this._onInsertColorPropertyClick.b ind(this)); 715 colorButton.addEventListener("click", this._onInsertColorPropertyClick.b ind(this));
758 items.push(colorButton); 716 items.push(colorButton);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 hasMatchingChild |= child._updateFilter(); 1085 hasMatchingChild |= child._updateFilter();
1128 1086
1129 var regex = this._parentPane.filterRegex(); 1087 var regex = this._parentPane.filterRegex();
1130 var hideRule = !hasMatchingChild && !!regex && !regex.test(this.element. textContent); 1088 var hideRule = !hasMatchingChild && !!regex && !regex.test(this.element. textContent);
1131 this.element.classList.toggle("hidden", hideRule); 1089 this.element.classList.toggle("hidden", hideRule);
1132 if (!hideRule && this._style.parentRule) 1090 if (!hideRule && this._style.parentRule)
1133 this._markSelectorHighlights(); 1091 this._markSelectorHighlights();
1134 return !hideRule; 1092 return !hideRule;
1135 }, 1093 },
1136 1094
1137 makeHoverableSelectorsMode: function()
1138 {
1139 if (this._hoverableSelectorsMode)
1140 return;
1141 this._hoverableSelectorsMode = true;
1142 this._markSelectorMatches();
1143 },
1144
1145 _markSelectorMatches: function() 1095 _markSelectorMatches: function()
1146 { 1096 {
1147 var rule = this._style.parentRule; 1097 var rule = this._style.parentRule;
1148 if (!rule) 1098 if (!rule)
1149 return; 1099 return;
1150 1100
1151 this._mediaListElement.classList.toggle("media-matches", this._matchedSt yles.mediaMatches(this._style)); 1101 this._mediaListElement.classList.toggle("media-matches", this._matchedSt yles.mediaMatches(this._style));
1152 1102
1153 if (!this._matchedStyles.hasMatchingSelectors(/** @type {!WebInspector.C SSStyleRule} */(rule)))
1154 return;
1155
1156 var selectorTexts = rule.selectors.map(selector => selector.text); 1103 var selectorTexts = rule.selectors.map(selector => selector.text);
1157
1158 var matchingSelectorIndexes = this._matchedStyles.matchingSelectors(/** @type {!WebInspector.CSSStyleRule} */(rule)); 1104 var matchingSelectorIndexes = this._matchedStyles.matchingSelectors(/** @type {!WebInspector.CSSStyleRule} */(rule));
1159 var matchingSelectors = new Array(selectorTexts.length).fill(false); 1105 var matchingSelectors = new Array(selectorTexts.length).fill(false);
1160 for (var matchingIndex of matchingSelectorIndexes) 1106 for (var matchingIndex of matchingSelectorIndexes)
1161 matchingSelectors[matchingIndex] = true; 1107 matchingSelectors[matchingIndex] = true;
1162 1108
1163 var fragment = this._hoverableSelectorsMode ? this._renderHoverableSelec tors(selectorTexts, matchingSelectors) : this._renderSimplifiedSelectors(selecto rTexts, matchingSelectors); 1109 var fragment = this._hoverableSelectorsMode ? this._renderHoverableSelec tors(selectorTexts, matchingSelectors) : this._renderSimplifiedSelectors(selecto rTexts, matchingSelectors);
1164 this._selectorElement.removeChildren(); 1110 this._selectorElement.removeChildren();
1165 this._selectorElement.appendChild(fragment); 1111 this._selectorElement.appendChild(fragment);
1166 this._markSelectorHighlights(); 1112 this._markSelectorHighlights();
1167 }, 1113 },
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 3111
3166 /** 3112 /**
3167 * @override 3113 * @override
3168 * @return {!WebInspector.ToolbarItem} 3114 * @return {!WebInspector.ToolbarItem}
3169 */ 3115 */
3170 item: function() 3116 item: function()
3171 { 3117 {
3172 return this._button; 3118 return this._button;
3173 } 3119 }
3174 } 3120 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/elements/elementsPanel.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698