Changeset 187519 in webkit
- Timestamp:
- Jul 28, 2015, 2:53:10 PM (10 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r187507 r187519 1 2015-07-28 Brian J. Burg <burg@cs.washington.edu> 2 3 Web Inspector: Convert NavigationItem subclasses to ES6 4 https://bugs.webkit.org/show_bug.cgi?id=147364 5 6 Reviewed by Timothy Hatcher. 7 8 Convert remaining NavigationItem subclasses to use ES6 class. 9 10 Also promote the _additionalClassNames to be a protected getter, 11 and inline the style class names that are only used in one place. 12 13 Mechanical changes are elided from the changelog. 14 15 * UserInterface/Views/ActivateButtonNavigationItem.js: 16 (WebInspector.ActivateButtonNavigationItem): 17 (WebInspector.ActivateButtonNavigationItem.prototype.get additionalClassNames): 18 * UserInterface/Views/ActivateButtonToolbarItem.js: 19 (WebInspector.ActivateButtonToolbarItem): 20 * UserInterface/Views/ButtonNavigationItem.js: 21 (WebInspector.ButtonNavigationItem): 22 (WebInspector.ButtonNavigationItem.prototype.get additionalClassNames): 23 * UserInterface/Views/ButtonToolbarItem.js: 24 (WebInspector.ButtonToolbarItem): 25 * UserInterface/Views/ControlToolbarItem.js: 26 (WebInspector.ControlToolbarItem): 27 (WebInspector.ControlToolbarItem.prototype.get additionalClassNames): 28 * UserInterface/Views/DividerNavigationItem.js: 29 (WebInspector.DividerNavigationItem): 30 (WebInspector.DividerNavigationItem.prototype.get additionalClassNames): 31 * UserInterface/Views/FlexibleSpaceNavigationItem.js: 32 (WebInspector.FlexibleSpaceNavigationItem): 33 (WebInspector.FlexibleSpaceNavigationItem.prototype.get additionalClassNames): 34 * UserInterface/Views/HierarchicalPathNavigationItem.js: 35 (WebInspector.HierarchicalPathNavigationItem.prototype.get additionalClassNames): 36 (WebInspector.HierarchicalPathNavigationItem.prototype.get _additionalClassNames): Deleted. 37 * UserInterface/Views/NavigationItem.js: 38 (WebInspector.NavigationItem): 39 (WebInspector.NavigationItem.prototype.get _classNames): 40 * UserInterface/Views/RadioButtonNavigationItem.js: 41 (WebInspector.RadioButtonNavigationItem): 42 (WebInspector.RadioButtonNavigationItem.prototype.get additionalClassNames): 43 * UserInterface/Views/ToggleButtonNavigationItem.js: 44 (WebInspector.ToggleButtonNavigationItem): 45 (WebInspector.ToggleButtonNavigationItem.prototype.get additionalClassNames): 46 * UserInterface/Views/ToggleControlToolbarItem.js: 47 (WebInspector.ToggleControlToolbarItem): 48 (WebInspector.ToggleControlToolbarItem.prototype.get additionalClassNames): 49 1 50 2015-07-28 Joseph Pecoraro <pecoraro@apple.com> 2 51 -
trunk/Source/WebInspectorUI/UserInterface/Views/ActivateButtonNavigationItem.js
r166041 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.ActivateButtonNavigationItem = function(identifier, defaultToolTip, activatedToolTip, image, imageWidth, imageHeight, suppressEmboss, role)26 WebInspector.ActivateButtonNavigationItem = class ActivateButtonNavigationItem extends WebInspector.ButtonNavigationItem 27 27 { 28 WebInspector.ButtonNavigationItem.call(this, identifier, defaultToolTip, image, imageWidth, imageHeight, suppressEmboss, role); 28 constructor(identifier, defaultToolTip, activatedToolTip, image, imageWidth, imageHeight, suppressEmboss, role) 29 { 30 super(identifier, defaultToolTip, image, imageWidth, imageHeight, suppressEmboss, role); 29 31 30 this._defaultToolTip = defaultToolTip; 31 this._activatedToolTip = activatedToolTip || defaultToolTip; 32 this._role = role; 33 }; 34 35 WebInspector.ActivateButtonNavigationItem.StyleClassName = "activate"; 36 WebInspector.ActivateButtonNavigationItem.ActivatedStyleClassName = "activated"; 37 38 WebInspector.ActivateButtonNavigationItem.prototype = { 39 constructor: WebInspector.ActivateButtonNavigationItem, 32 this._defaultToolTip = defaultToolTip; 33 this._activatedToolTip = activatedToolTip || defaultToolTip; 34 this._role = role; 35 } 40 36 41 37 // Public … … 44 40 { 45 41 return this._defaultToolTip; 46 } ,42 } 47 43 48 44 get activatedToolTip() 49 45 { 50 46 return this._activatedToolTip; 51 } ,47 } 52 48 53 49 get activated() 54 50 { 55 51 return this.element.classList.contains(WebInspector.ActivateButtonNavigationItem.ActivatedStyleClassName); 56 } ,52 } 57 53 58 54 set activated(flag) … … 69 65 this.element.removeAttribute("aria-selected"); 70 66 } 71 } ,67 } 72 68 73 generateStyleText : function(parentSelector)69 generateStyleText(parentSelector) 74 70 { 75 71 var classNames = this._classNames.join("."); … … 94 90 95 91 return styleText; 96 } ,92 } 97 93 98 // Pr ivate94 // Protected 99 95 100 _additionalClassNames: [WebInspector.ActivateButtonNavigationItem.StyleClassName, WebInspector.ButtonNavigationItem.StyleClassName] 96 get additionalClassNames() 97 { 98 return ["activate", "button"]; 99 } 101 100 }; 102 101 103 WebInspector.ActivateButtonNavigationItem. prototype.__proto__ = WebInspector.ButtonNavigationItem.prototype;102 WebInspector.ActivateButtonNavigationItem.ActivatedStyleClassName = "activated"; -
trunk/Source/WebInspectorUI/UserInterface/Views/ActivateButtonToolbarItem.js
r183338 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.ActivateButtonToolbarItem = function(identifier, defaultToolTip, activatedToolTip, label, image, suppressEmboss, role)26 WebInspector.ActivateButtonToolbarItem = class ActivateButtonToolbarItem extends WebInspector.ActivateButtonNavigationItem 27 27 { 28 WebInspector.ActivateButtonNavigationItem.call(this, identifier, defaultToolTip, activatedToolTip, image, 32, 32, suppressEmboss, role); 28 constructor(identifier, defaultToolTip, activatedToolTip, label, image, suppressEmboss, role) 29 { 30 super(identifier, defaultToolTip, activatedToolTip, image, 32, 32, suppressEmboss, role); 29 31 30 if (typeof label === "string") {31 this._labelElement = document.createElement("div");32 this._labelElement.className = WebInspector.ButtonToolbarItem.LabelStyleClassName;33 this._element.appendChild(this._labelElement);32 if (typeof label === "string") { 33 this._labelElement = document.createElement("div"); 34 this._labelElement.className = WebInspector.ButtonToolbarItem.LabelStyleClassName; 35 this._element.appendChild(this._labelElement); 34 36 35 this.label = label; 37 this.label = label; 38 } 36 39 } 37 };38 39 WebInspector.ActivateButtonToolbarItem.prototype = {40 constructor: WebInspector.ActivateButtonToolbarItem,41 40 42 41 // Public … … 45 44 { 46 45 return this._labelElement.textContent; 47 } ,46 } 48 47 49 48 set label(newLabel) … … 56 55 } 57 56 }; 58 59 WebInspector.ActivateButtonToolbarItem.prototype.__proto__ = WebInspector.ActivateButtonNavigationItem.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/ButtonNavigationItem.js
r173436 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.ButtonNavigationItem = function(identifier, toolTipOrLabel, image, imageWidth, imageHeight, suppressEmboss, role, label) { 27 WebInspector.NavigationItem.call(this, identifier); 28 29 console.assert(identifier); 30 console.assert(toolTipOrLabel); 31 32 this.toolTip = toolTipOrLabel; 33 34 this._element.addEventListener("click", this._mouseClicked.bind(this)); 35 36 this._element.setAttribute("role", role || "button"); 37 38 if (label) 39 this._element.setAttribute("aria-label", label); 40 41 this._imageWidth = imageWidth || 16; 42 this._imageHeight = imageHeight || 16; 43 this._suppressEmboss = suppressEmboss || false; 44 45 if (suppressEmboss) 46 this._element.classList.add(WebInspector.ButtonNavigationItem.SuppressEmbossStyleClassName); 47 48 if (image) 49 this.image = image; 50 else 51 this.label = toolTipOrLabel; 52 }; 53 54 WebInspector.ButtonNavigationItem.StyleClassName = "button"; 26 WebInspector.ButtonNavigationItem = class ButtonNavigationItem extends WebInspector.NavigationItem 27 { 28 constructor(identifier, toolTipOrLabel, image, imageWidth, imageHeight, suppressEmboss, role, label) 29 { 30 super(identifier); 31 32 this._embossedImageStates = WebInspector.ButtonNavigationItem.States; 33 this._imageCacheable = true; 34 35 console.assert(identifier); 36 console.assert(toolTipOrLabel); 37 38 this.toolTip = toolTipOrLabel; 39 40 this._element.addEventListener("click", this._mouseClicked.bind(this)); 41 42 this._element.setAttribute("role", role || "button"); 43 44 if (label) 45 this._element.setAttribute("aria-label", label); 46 47 this._imageWidth = imageWidth || 16; 48 this._imageHeight = imageHeight || 16; 49 this._suppressEmboss = suppressEmboss || false; 50 51 if (suppressEmboss) 52 this._element.classList.add(WebInspector.ButtonNavigationItem.SuppressEmbossStyleClassName); 53 54 if (image) 55 this.image = image; 56 else 57 this.label = toolTipOrLabel; 58 } 59 60 // Public 61 62 get toolTip() 63 { 64 return this._element.title; 65 } 66 67 set toolTip(newToolTip) 68 { 69 console.assert(newToolTip); 70 if (!newToolTip) 71 return; 72 73 this._element.title = newToolTip; 74 } 75 76 get label() 77 { 78 return this._element.textContent; 79 } 80 81 set label(newLabel) 82 { 83 this._element.classList.add(WebInspector.ButtonNavigationItem.TextOnlyClassName); 84 this._element.textContent = newLabel || ""; 85 if (this.parentNavigationBar) 86 this.parentNavigationBar.updateLayout(); 87 } 88 89 get image() 90 { 91 return this._image; 92 } 93 94 set image(newImage) 95 { 96 if (!newImage) { 97 this._element.removeChildren(); 98 return; 99 } 100 101 this._element.removeChildren(); 102 this._element.classList.remove(WebInspector.ButtonNavigationItem.TextOnlyClassName); 103 104 this._image = newImage; 105 106 this._glyphElement = document.createElement("div"); 107 this._glyphElement.className = "glyph"; 108 this._element.appendChild(this._glyphElement); 109 110 this._updateImage(); 111 } 112 113 get enabled() 114 { 115 return !this._element.classList.contains(WebInspector.ButtonNavigationItem.DisabledStyleClassName); 116 } 117 118 set enabled(flag) 119 { 120 if (flag) 121 this._element.classList.remove(WebInspector.ButtonNavigationItem.DisabledStyleClassName); 122 else 123 this._element.classList.add(WebInspector.ButtonNavigationItem.DisabledStyleClassName); 124 } 125 126 get suppressBezel() 127 { 128 return this._element.classList.contains(WebInspector.ButtonNavigationItem.SuppressBezelStyleClassName); 129 } 130 131 set suppressBezel(flag) 132 { 133 if (flag) 134 this._element.classList.add(WebInspector.ButtonNavigationItem.SuppressBezelStyleClassName); 135 else 136 this._element.classList.remove(WebInspector.ButtonNavigationItem.SuppressBezelStyleClassName); 137 } 138 139 generateStyleText(parentSelector) 140 { 141 var classNames = this._classNames.join("."); 142 143 if (this._suppressEmboss) 144 var styleText = parentSelector + " ." + classNames + " > .glyph { width: " + this._imageWidth + "px; height: " + this._imageHeight + "px; }\n"; 145 else { 146 // Default state. 147 var styleText = parentSelector + " ." + classNames + " > .glyph { background-image: -webkit-canvas(" + this._canvasIdentifier() + "); background-size: " + this._imageWidth + "px " + this._imageHeight + "px; }\n"; 148 149 // Pressed state. 150 styleText += parentSelector + " ." + classNames + ":not(.disabled):active > .glyph { background-image: -webkit-canvas(" + this._canvasIdentifier(WebInspector.ButtonNavigationItem.States.Active) + "); }\n"; 151 152 // Focused state. 153 styleText += parentSelector + " ." + classNames + ":not(.disabled):focus > .glyph { background-image: -webkit-canvas(" + this._canvasIdentifier(WebInspector.ButtonNavigationItem.States.Focus) + "); }\n"; 154 } 155 156 return styleText; 157 } 158 159 // Protected 160 161 get additionalClassNames() 162 { 163 return ["button"]; 164 } 165 166 // Private 167 168 _mouseClicked(event) 169 { 170 if (!this.enabled) 171 return; 172 this.dispatchEventToListeners(WebInspector.ButtonNavigationItem.Event.Clicked); 173 } 174 175 _canvasIdentifier(state) 176 { 177 console.assert(!this._suppressEmboss); 178 return "navigation-item-" + this._identifier + "-" + (state || WebInspector.ButtonNavigationItem.States.Normal); 179 } 180 181 _updateImage() 182 { 183 if (this._suppressEmboss) 184 this._glyphElement.style.webkitMask = "url(" + this._image + ")"; 185 else 186 this._generateImages(); 187 } 188 189 _generateImages() 190 { 191 console.assert(!this._suppressEmboss); 192 if (this._suppressEmboss) 193 return; 194 generateEmbossedImages(this.image, this._imageWidth, this._imageHeight, this._embossedImageStates, this._canvasIdentifier.bind(this), !this._imageCacheable); 195 } 196 } 197 55 198 WebInspector.ButtonNavigationItem.DisabledStyleClassName = "disabled"; 56 199 WebInspector.ButtonNavigationItem.SuppressBezelStyleClassName = "suppress-bezel"; … … 67 210 Clicked: "button-navigation-item-clicked" 68 211 }; 69 70 WebInspector.ButtonNavigationItem.prototype = {71 constructor: WebInspector.ButtonNavigationItem,72 73 // Public74 75 get toolTip()76 {77 return this._element.title;78 },79 80 set toolTip(newToolTip)81 {82 console.assert(newToolTip);83 if (!newToolTip)84 return;85 86 this._element.title = newToolTip;87 },88 89 get label()90 {91 return this._element.textContent;92 },93 94 set label(newLabel)95 {96 this._element.classList.add(WebInspector.ButtonNavigationItem.TextOnlyClassName);97 this._element.textContent = newLabel || "";98 if (this.parentNavigationBar)99 this.parentNavigationBar.updateLayout();100 },101 102 get image()103 {104 return this._image;105 },106 107 set image(newImage)108 {109 if (!newImage) {110 this._element.removeChildren();111 return;112 }113 114 this._element.removeChildren();115 this._element.classList.remove(WebInspector.ButtonNavigationItem.TextOnlyClassName);116 117 this._image = newImage;118 119 this._glyphElement = document.createElement("div");120 this._glyphElement.className = "glyph";121 this._element.appendChild(this._glyphElement);122 123 this._updateImage();124 },125 126 get enabled()127 {128 return !this._element.classList.contains(WebInspector.ButtonNavigationItem.DisabledStyleClassName);129 },130 131 set enabled(flag)132 {133 if (flag)134 this._element.classList.remove(WebInspector.ButtonNavigationItem.DisabledStyleClassName);135 else136 this._element.classList.add(WebInspector.ButtonNavigationItem.DisabledStyleClassName);137 },138 139 get suppressBezel()140 {141 return this._element.classList.contains(WebInspector.ButtonNavigationItem.SuppressBezelStyleClassName);142 },143 144 set suppressBezel(flag)145 {146 if (flag)147 this._element.classList.add(WebInspector.ButtonNavigationItem.SuppressBezelStyleClassName);148 else149 this._element.classList.remove(WebInspector.ButtonNavigationItem.SuppressBezelStyleClassName);150 },151 152 generateStyleText: function(parentSelector)153 {154 var classNames = this._classNames.join(".");155 156 if (this._suppressEmboss)157 var styleText = parentSelector + " ." + classNames + " > .glyph { width: " + this._imageWidth + "px; height: " + this._imageHeight + "px; }\n";158 else {159 // Default state.160 var styleText = parentSelector + " ." + classNames + " > .glyph { background-image: -webkit-canvas(" + this._canvasIdentifier() + "); background-size: " + this._imageWidth + "px " + this._imageHeight + "px; }\n";161 162 // Pressed state.163 styleText += parentSelector + " ." + classNames + ":not(.disabled):active > .glyph { background-image: -webkit-canvas(" + this._canvasIdentifier(WebInspector.ButtonNavigationItem.States.Active) + "); }\n";164 165 // Focused state.166 styleText += parentSelector + " ." + classNames + ":not(.disabled):focus > .glyph { background-image: -webkit-canvas(" + this._canvasIdentifier(WebInspector.ButtonNavigationItem.States.Focus) + "); }\n";167 }168 169 return styleText;170 },171 172 // Private173 174 _additionalClassNames: [WebInspector.ButtonNavigationItem.StyleClassName],175 _embossedImageStates: WebInspector.ButtonNavigationItem.States,176 _imageCacheable: true,177 178 _mouseClicked: function(event)179 {180 if (!this.enabled)181 return;182 this.dispatchEventToListeners(WebInspector.ButtonNavigationItem.Event.Clicked);183 },184 185 _canvasIdentifier: function(state)186 {187 console.assert(!this._suppressEmboss);188 return "navigation-item-" + this._identifier + "-" + (state || WebInspector.ButtonNavigationItem.States.Normal);189 },190 191 _updateImage: function()192 {193 if (this._suppressEmboss)194 this._glyphElement.style.webkitMask = "url(" + this._image + ")";195 else196 this._generateImages();197 },198 199 _generateImages: function()200 {201 console.assert(!this._suppressEmboss);202 if (this._suppressEmboss)203 return;204 generateEmbossedImages(this.image, this._imageWidth, this._imageHeight, this._embossedImageStates, this._canvasIdentifier.bind(this), !this._imageCacheable);205 }206 };207 208 WebInspector.ButtonNavigationItem.prototype.__proto__ = WebInspector.NavigationItem.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/ButtonToolbarItem.js
r183338 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.ButtonToolbarItem = function(identifier, toolTip, label, image, suppressEmboss, role)26 WebInspector.ButtonToolbarItem = class ButtonToolbarItem extends WebInspector.ButtonNavigationItem 27 27 { 28 WebInspector.ButtonNavigationItem.call(this, identifier, toolTip, image, 16, 16, suppressEmboss, role); 28 constructor(identifier, toolTip, label, image, suppressEmboss, role) 29 { 30 super(identifier, toolTip, image, 16, 16, suppressEmboss, role); 29 31 30 if (typeof label === "string") {31 this._labelElement = document.createElement("div");32 this._labelElement.className = WebInspector.ButtonToolbarItem.LabelStyleClassName;33 this._element.appendChild(this._labelElement);32 if (typeof label === "string") { 33 this._labelElement = document.createElement("div"); 34 this._labelElement.className = WebInspector.ButtonToolbarItem.LabelStyleClassName; 35 this._element.appendChild(this._labelElement); 34 36 35 this.label = label; 37 this.label = label; 38 } 36 39 } 37 };38 39 WebInspector.ButtonToolbarItem.LabelStyleClassName = "label";40 41 WebInspector.ButtonToolbarItem.prototype = {42 constructor: WebInspector.ButtonToolbarItem,43 40 44 41 // Public … … 47 44 { 48 45 return this._labelElement.textContent; 49 } ,46 } 50 47 51 48 set label(newLabel) … … 59 56 }; 60 57 61 WebInspector.ButtonToolbarItem. prototype.__proto__ = WebInspector.ButtonNavigationItem.prototype;58 WebInspector.ButtonToolbarItem.LabelStyleClassName = "label"; -
trunk/Source/WebInspectorUI/UserInterface/Views/ControlToolbarItem.js
r164543 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.ControlToolbarItem = function(identifier, toolTip, image, imageWidth, imageHeight)26 WebInspector.ControlToolbarItem = class ControlToolbarItem extends WebInspector.ButtonNavigationItem 27 27 { 28 WebInspector.ButtonNavigationItem.call(this, identifier, toolTip, image, imageWidth, imageHeight, false); 28 constructor(identifier, toolTip, image, imageWidth, imageHeight) 29 { 30 super(identifier, toolTip, image, imageWidth, imageHeight, false); 31 } 32 33 // Protected 34 35 get additionalClassNames() 36 { 37 return ["control"]; 38 } 29 39 }; 30 31 WebInspector.ControlToolbarItem.StyleClassName = "control";32 33 WebInspector.ControlToolbarItem.prototype = {34 constructor: WebInspector.ControlToolbarItem,35 36 // Private37 38 _additionalClassNames: [WebInspector.ControlToolbarItem.StyleClassName],39 };40 41 WebInspector.ControlToolbarItem.prototype.__proto__ = WebInspector.ButtonNavigationItem.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/DividerNavigationItem.js
r164543 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.DividerNavigationItem = function(identifier) { 27 WebInspector.NavigationItem.call(this, identifier); 26 WebInspector.DividerNavigationItem = class DividerNavigationItem extends WebInspector.NavigationItem 27 { 28 constructor(identifier) 29 { 30 super(identifier); 31 } 32 33 // Protected 34 35 get additionalClassNames() 36 { 37 return ["divider"]; 38 } 28 39 }; 29 30 WebInspector.DividerNavigationItem.StyleClassName = "divider";31 32 WebInspector.DividerNavigationItem.prototype = {33 constructor: WebInspector.DividerNavigationItem,34 35 // Private36 37 _additionalClassNames: [WebInspector.DividerNavigationItem.StyleClassName],38 };39 40 WebInspector.DividerNavigationItem.prototype.__proto__ = WebInspector.NavigationItem.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/FlexibleSpaceNavigationItem.js
r164543 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.FlexibleSpaceNavigationItem = function(identifier) { 27 WebInspector.NavigationItem.call(this, identifier); 26 WebInspector.FlexibleSpaceNavigationItem = class FlexibleSpaceNavigationItem extends WebInspector.NavigationItem 27 { 28 constructor(identifier) 29 { 30 super(identifier); 31 } 32 33 // Protected 34 35 get additionalClassNames() 36 { 37 return ["flexible-space"]; 38 } 28 39 }; 29 30 WebInspector.FlexibleSpaceNavigationItem.StyleClassName = "flexible-space";31 32 WebInspector.FlexibleSpaceNavigationItem.prototype = {33 constructor: WebInspector.FlexibleSpaceNavigationItem,34 35 // Private36 37 _additionalClassNames: [WebInspector.FlexibleSpaceNavigationItem.StyleClassName],38 };39 40 WebInspector.FlexibleSpaceNavigationItem.prototype.__proto__ = WebInspector.NavigationItem.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathNavigationItem.js
r183565 r187519 220 220 // Protected 221 221 222 // FIXME: Should not be prefixed with an underscore. 223 get _additionalClassNames() 222 get additionalClassNames() 224 223 { 225 224 return ["hierarchical-path"]; -
trunk/Source/WebInspectorUI/UserInterface/Views/NavigationItem.js
r182990 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.NavigationItem = function(identifier, role, label) { 27 // FIXME: Convert this to a WebInspector.Object subclass, and call super(). 28 // WebInspector.Object.call(this); 26 WebInspector.NavigationItem = class NavigationItem extends WebInspector.Object 27 { 28 constructor(identifier, role, label) 29 { 30 super(); 29 31 30 this._identifier = identifier || null;32 this._identifier = identifier || null; 31 33 32 this._element = document.createElement("div");33 this._hidden = false;34 this._element = document.createElement("div"); 35 this._hidden = false; 34 36 35 if (role)36 this._element.setAttribute("role", role);37 if (label)38 this._element.setAttribute("aria-label", label);37 if (role) 38 this._element.setAttribute("role", role); 39 if (label) 40 this._element.setAttribute("aria-label", label); 39 41 40 this._element.classList.add(...this._classNames); 41 this._element.navigationItem = this; 42 }; 43 44 WebInspector.NavigationItem.StyleClassName = "item"; 45 WebInspector.NavigationItem.HiddenStyleClassName = "hidden"; 46 47 48 WebInspector.NavigationItem.prototype = { 49 constructor: WebInspector.NavigationItem, 42 this._element.classList.add(...this._classNames); 43 this._element.navigationItem = this; 44 } 50 45 51 46 // Public … … 54 49 { 55 50 return this._identifier; 56 } ,51 } 57 52 58 53 get element() 59 54 { 60 55 return this._element; 61 } ,56 } 62 57 63 58 get parentNavigationBar() 64 59 { 65 60 return this._parentNavigationBar; 66 } ,61 } 67 62 68 updateLayout : function(expandOnly)63 updateLayout(expandOnly) 69 64 { 70 65 // Implemented by subclasses. 71 } ,66 } 72 67 73 68 get hidden() 74 69 { 75 70 return this._hidden; 76 } ,71 } 77 72 78 73 set hidden(flag) … … 83 78 this._hidden = flag; 84 79 85 if (flag) 86 this._element.classList.add(WebInspector.NavigationItem.HiddenStyleClassName); 87 else 88 this._element.classList.remove(WebInspector.NavigationItem.HiddenStyleClassName); 80 this._element.classList.toggle("hidden", flag); 89 81 90 82 if (this._parentNavigationBar) 91 83 this._parentNavigationBar.updateLayoutSoon(); 92 } ,84 } 93 85 94 86 // Private … … 96 88 get _classNames() 97 89 { 98 var classNames = [ WebInspector.NavigationItem.StyleClassName];90 var classNames = ["item"]; 99 91 if (this._identifier) 100 92 classNames.push(this._identifier); 101 if (this. _additionalClassNames instanceof Array)102 classNames = classNames.concat(this. _additionalClassNames);93 if (this.additionalClassNames instanceof Array) 94 classNames = classNames.concat(this.additionalClassNames); 103 95 return classNames; 104 96 } 105 97 }; 106 107 WebInspector.NavigationItem.prototype.__proto__ = WebInspector.Object.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/RadioButtonNavigationItem.js
r182142 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.RadioButtonNavigationItem = function(identifier, toolTip, image, imageWidth, imageHeight) { 27 WebInspector.ButtonNavigationItem.call(this, identifier, toolTip, image, imageWidth, imageHeight, null, "tab"); 28 }; 29 30 WebInspector.RadioButtonNavigationItem.StyleClassName = "radio"; 31 WebInspector.RadioButtonNavigationItem.ActiveStyleClassName = "active"; 32 WebInspector.RadioButtonNavigationItem.SelectedStyleClassName = "selected"; 33 34 WebInspector.RadioButtonNavigationItem.prototype = { 35 constructor: WebInspector.RadioButtonNavigationItem, 26 WebInspector.RadioButtonNavigationItem = class RadioButtonNavigationItem extends WebInspector.ButtonNavigationItem 27 { 28 constructor(identifier, toolTip, image, imageWidth, imageHeight) 29 { 30 super(identifier, toolTip, image, imageWidth, imageHeight, null, "tab"); 31 } 36 32 37 33 // Public … … 40 36 { 41 37 return this.element.classList.contains(WebInspector.RadioButtonNavigationItem.SelectedStyleClassName); 42 } ,38 } 43 39 44 40 set selected(flag) … … 51 47 this.element.setAttribute("aria-selected", "false"); 52 48 } 53 } ,49 } 54 50 55 51 get active() 56 52 { 57 53 return this.element.classList.contains(WebInspector.RadioButtonNavigationItem.ActiveStyleClassName); 58 } ,54 } 59 55 60 56 set active(flag) … … 64 60 else 65 61 this.element.classList.remove(WebInspector.RadioButtonNavigationItem.ActiveStyleClassName); 66 } ,62 } 67 63 68 generateStyleText : function(parentSelector)64 generateStyleText(parentSelector) 69 65 { 70 66 var classNames = this._classNames.join("."); … … 80 76 81 77 return styleText; 82 } ,78 } 83 79 84 updateLayout : function(expandOnly)80 updateLayout(expandOnly) 85 81 { 86 82 if (expandOnly) … … 102 98 this.element.setAttribute("aria-selected", "false"); 103 99 } 104 } ,100 } 105 101 106 // Pr ivate102 // Protected 107 103 108 _additionalClassNames: [WebInspector.RadioButtonNavigationItem.StyleClassName, WebInspector.ButtonNavigationItem.StyleClassName], 104 get additionalClassNames() 105 { 106 return ["radio", "button"]; 107 } 109 108 }; 110 109 111 WebInspector.RadioButtonNavigationItem.prototype.__proto__ = WebInspector.ButtonNavigationItem.prototype; 110 WebInspector.RadioButtonNavigationItem.StyleClassName = "radio"; 111 WebInspector.RadioButtonNavigationItem.ActiveStyleClassName = "active"; 112 WebInspector.RadioButtonNavigationItem.SelectedStyleClassName = "selected"; -
trunk/Source/WebInspectorUI/UserInterface/Views/ToggleButtonNavigationItem.js
r164543 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.ToggleButtonNavigationItem = function(identifier, defaultToolTip, alternateToolTip, defaultImage, alternateImage, imageWidth, imageHeight, suppressEmboss) { 27 WebInspector.ButtonNavigationItem.call(this, identifier, defaultToolTip, defaultImage, imageWidth, imageHeight, suppressEmboss); 26 WebInspector.ToggleButtonNavigationItem = class ToggleButtonNavigationItem extends WebInspector.ButtonNavigationItem 27 { 28 constructor(identifier, defaultToolTip, alternateToolTip, defaultImage, alternateImage, imageWidth, imageHeight, suppressEmboss) 29 { 30 super(identifier, defaultToolTip, defaultImage, imageWidth, imageHeight, suppressEmboss); 28 31 29 this._toggled = false; 30 this._defaultImage = defaultImage; 31 this._alternateImage = alternateImage; 32 this._defaultToolTip = defaultToolTip; 33 this._alternateToolTip = alternateToolTip || defaultToolTip; 34 }; 32 // The image isn't cacheable because it dynamically changes and the same canvas identifier is reused. 33 // FIXME: We could try overriding _canvasIdentifier() to return different identifiers. If we did that 34 // we would also need to override generateStyleText() to use the different identifiers. 35 this._imageCacheable = false; 35 36 36 WebInspector.ToggleButtonNavigationItem.StyleClassName = "toggle"; 37 38 WebInspector.ToggleButtonNavigationItem.prototype = { 39 constructor: WebInspector.ToggleButtonNavigationItem, 37 this._toggled = false; 38 this._defaultImage = defaultImage; 39 this._alternateImage = alternateImage; 40 this._defaultToolTip = defaultToolTip; 41 this._alternateToolTip = alternateToolTip || defaultToolTip; 42 } 40 43 41 44 // Public … … 44 47 { 45 48 return this._defaultToolTip; 46 } ,49 } 47 50 48 51 get alternateToolTip() 49 52 { 50 53 return this._alternateToolTip; 51 } ,54 } 52 55 53 56 set alternateToolTip(toolTip) … … 57 60 if (this._toggled) 58 61 this.toolTip = this._alternateToolTip; 59 } ,62 } 60 63 61 64 get defaultImage() 62 65 { 63 66 return this._defaultImage; 64 } ,67 } 65 68 66 69 get alternateImage() 67 70 { 68 71 return this._alternateImage; 69 } ,72 } 70 73 71 74 set alternateImage(image) … … 75 78 if (this._toggled) 76 79 this.image = this._alternateImage; 77 } ,80 } 78 81 79 82 get toggled() 80 83 { 81 84 return this._toggled; 82 } ,85 } 83 86 84 87 set toggled(flag) … … 98 101 this.image = this._defaultImage; 99 102 } 100 } ,103 } 101 104 102 // Pr ivate105 // Protected 103 106 104 _additionalClassNames: [WebInspector.ToggleButtonNavigationItem.StyleClassName, WebInspector.ButtonNavigationItem.StyleClassName], 105 106 // The image isn't cacheable because it dynamically changes and the same canvas identifier is reused. 107 // FIXME: We could try overriding _canvasIdentifier() to return different identifiers. If we did that 108 // we would also need to override generateStyleText() to use the different identifiers. 109 _imageCacheable: false 107 get additionalClassNames() 108 { 109 return ["toggle", "button"]; 110 } 110 111 }; 111 112 WebInspector.ToggleButtonNavigationItem.prototype.__proto__ = WebInspector.ButtonNavigationItem.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/ToggleControlToolbarItem.js
r164543 r187519 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector.ToggleControlToolbarItem = function(identifier, defaultToolTip, alternateToolTip, defaultImage, alternateImage, imageWidth, imageHeight) { 27 WebInspector.ToggleButtonNavigationItem.call(this, identifier, defaultToolTip, alternateToolTip, defaultImage, alternateImage, imageWidth, imageHeight, false); 26 WebInspector.ToggleControlToolbarItem = class ToggleControlToolbarItem extends WebInspector.ToggleButtonNavigationItem 27 { 28 constructor(identifier, defaultToolTip, alternateToolTip, defaultImage, alternateImage, imageWidth, imageHeight) 29 { 30 super(identifier, defaultToolTip, alternateToolTip, defaultImage, alternateImage, imageWidth, imageHeight, false); 31 } 32 33 // Protected 34 35 get additionalClassNames() 36 { 37 return ["toggle", "control"]; 38 } 28 39 }; 29 30 WebInspector.ToggleControlToolbarItem.StyleClassName = "toggle";31 32 WebInspector.ToggleControlToolbarItem.prototype = {33 constructor: WebInspector.ToggleControlToolbarItem,34 35 // Private36 37 _additionalClassNames: [WebInspector.ToggleControlToolbarItem.StyleClassName, WebInspector.ControlToolbarItem.StyleClassName]38 };39 40 WebInspector.ToggleControlToolbarItem.prototype.__proto__ = WebInspector.ToggleButtonNavigationItem.prototype;
Note:
See TracChangeset
for help on using the changeset viewer.