blob: 98902cedeca43357bcd1d82fcda48497f4ebb092 [file] [log] [blame]
Blink Reformat4c46d092018-04-07 15:32:371/*
2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
Tim van der Lippe97611c92020-02-12 16:56:5828
Paul Lewis6d4ebb22020-08-04 12:02:5529// @ts-nocheck
30// TODO(crbug.com/1011811): Enable TypeScript compiler checks
31
Tim van der Lippe97611c92020-02-12 16:56:5832import * as Common from '../common/common.js';
Tim van der Lippe97611c92020-02-12 16:56:5833import * as SDK from '../sdk/sdk.js';
34import * as UI from '../ui/ui.js';
35
Tim van der Lippeaabc8302019-12-10 15:34:4536import {ElementsSidebarPane} from './ElementsSidebarPane.js';
Blink Reformat4c46d092018-04-07 15:32:3737
38/**
39 * @unrestricted
40 */
Tim van der Lippeaabc8302019-12-10 15:34:4541export class MetricsSidebarPane extends ElementsSidebarPane {
Blink Reformat4c46d092018-04-07 15:32:3742 constructor() {
43 super();
44 this.registerRequiredCSS('elements/metricsSidebarPane.css');
45
Tim van der Lippe97611c92020-02-12 16:56:5846 /** @type {?SDK.CSSStyleDeclaration.CSSStyleDeclaration} */
Blink Reformat4c46d092018-04-07 15:32:3747 this._inlineStyle = null;
48 }
49
50 /**
51 * @override
52 * @protected
53 * @return {!Promise.<?>}
54 */
55 doUpdate() {
56 // "style" attribute might have changed. Update metrics unless they are being edited
57 // (if a CSS property is added, a StyleSheetChanged event is dispatched).
Tim van der Lippe1d6e57a2019-09-30 11:55:3458 if (this._isEditingMetrics) {
Blink Reformat4c46d092018-04-07 15:32:3759 return Promise.resolve();
Tim van der Lippe1d6e57a2019-09-30 11:55:3460 }
Blink Reformat4c46d092018-04-07 15:32:3761
62 // FIXME: avoid updates of a collapsed pane.
63 const node = this.node();
64 const cssModel = this.cssModel();
65 if (!node || node.nodeType() !== Node.ELEMENT_NODE || !cssModel) {
66 this.contentElement.removeChildren();
67 return Promise.resolve();
68 }
69
70 /**
71 * @param {?Map.<string, string>} style
Tim van der Lippe13f71fb2019-11-29 11:17:3972 * @this {MetricsSidebarPane}
Blink Reformat4c46d092018-04-07 15:32:3773 */
74 function callback(style) {
Tim van der Lippe1d6e57a2019-09-30 11:55:3475 if (!style || this.node() !== node) {
Blink Reformat4c46d092018-04-07 15:32:3776 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:3477 }
Blink Reformat4c46d092018-04-07 15:32:3778 this._updateMetrics(style);
79 }
80 /**
81 * @param {?SDK.CSSModel.InlineStyleResult} inlineStyleResult
Tim van der Lippe13f71fb2019-11-29 11:17:3982 * @this {MetricsSidebarPane}
Blink Reformat4c46d092018-04-07 15:32:3783 */
84 function inlineStyleCallback(inlineStyleResult) {
Tim van der Lippe1d6e57a2019-09-30 11:55:3485 if (inlineStyleResult && this.node() === node) {
Blink Reformat4c46d092018-04-07 15:32:3786 this._inlineStyle = inlineStyleResult.inlineStyle;
Tim van der Lippe1d6e57a2019-09-30 11:55:3487 }
Blink Reformat4c46d092018-04-07 15:32:3788 }
89
90 const promises = [
91 cssModel.computedStylePromise(node.id).then(callback.bind(this)),
92 cssModel.inlineStylesPromise(node.id).then(inlineStyleCallback.bind(this))
93 ];
94 return Promise.all(promises);
95 }
96
97 /**
98 * @override
99 */
100 onCSSModelChanged() {
101 this.update();
102 }
103
104 /**
105 * @param {!Map.<string, string>} style
106 * @param {string} propertyName
107 * @return {number}
108 */
109 _getPropertyValueAsPx(style, propertyName) {
110 return Number(style.get(propertyName).replace(/px$/, '') || 0);
111 }
112
113 /**
114 * @param {!Map.<string, string>} computedStyle
115 * @param {string} componentName
116 */
117 _getBox(computedStyle, componentName) {
118 const suffix = componentName === 'border' ? '-width' : '';
119 const left = this._getPropertyValueAsPx(computedStyle, componentName + '-left' + suffix);
120 const top = this._getPropertyValueAsPx(computedStyle, componentName + '-top' + suffix);
121 const right = this._getPropertyValueAsPx(computedStyle, componentName + '-right' + suffix);
122 const bottom = this._getPropertyValueAsPx(computedStyle, componentName + '-bottom' + suffix);
123 return {left: left, top: top, right: right, bottom: bottom};
124 }
125
126 /**
127 * @param {boolean} showHighlight
128 * @param {string} mode
129 * @param {!Event} event
130 */
131 _highlightDOMNode(showHighlight, mode, event) {
132 event.consume();
133 if (showHighlight && this.node()) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34134 if (this._highlightMode === mode) {
Blink Reformat4c46d092018-04-07 15:32:37135 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34136 }
Blink Reformat4c46d092018-04-07 15:32:37137 this._highlightMode = mode;
138 this.node().highlight(mode);
139 } else {
140 delete this._highlightMode;
Tim van der Lippe97611c92020-02-12 16:56:58141 SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight();
Blink Reformat4c46d092018-04-07 15:32:37142 }
143
144 for (let i = 0; this._boxElements && i < this._boxElements.length; ++i) {
145 const element = this._boxElements[i];
Tim van der Lippe1d6e57a2019-09-30 11:55:34146 if (!this.node() || mode === 'all' || element._name === mode) {
Blink Reformat4c46d092018-04-07 15:32:37147 element.style.backgroundColor = element._backgroundColor;
Tim van der Lippe1d6e57a2019-09-30 11:55:34148 } else {
Blink Reformat4c46d092018-04-07 15:32:37149 element.style.backgroundColor = '';
Tim van der Lippe1d6e57a2019-09-30 11:55:34150 }
Blink Reformat4c46d092018-04-07 15:32:37151 }
152 }
153
154 /**
155 * @param {!Map.<string, string>} style
156 */
157 _updateMetrics(style) {
158 // Updating with computed style.
159 const metricsElement = createElement('div');
160 metricsElement.className = 'metrics';
161 const self = this;
162
163 /**
164 * @param {!Map.<string, string>} style
165 * @param {string} name
166 * @param {string} side
167 * @param {string} suffix
Tim van der Lippe13f71fb2019-11-29 11:17:39168 * @this {MetricsSidebarPane}
Blink Reformat4c46d092018-04-07 15:32:37169 */
170 function createBoxPartElement(style, name, side, suffix) {
171 const propertyName = (name !== 'position' ? name + '-' : '') + side + suffix;
172 let value = style.get(propertyName);
Tim van der Lippe1d6e57a2019-09-30 11:55:34173 if (value === '' || (name !== 'position' && value === '0px')) {
Blink Reformat4c46d092018-04-07 15:32:37174 value = '\u2012';
Tim van der Lippe1d6e57a2019-09-30 11:55:34175 } else if (name === 'position' && value === 'auto') {
Blink Reformat4c46d092018-04-07 15:32:37176 value = '\u2012';
Tim van der Lippe1d6e57a2019-09-30 11:55:34177 }
Blink Reformat4c46d092018-04-07 15:32:37178 value = value.replace(/px$/, '');
179 value = Number.toFixedIfFloating(value);
180
181 const element = createElement('div');
182 element.className = side;
183 element.textContent = value;
184 element.addEventListener('dblclick', this.startEditing.bind(this, element, name, propertyName, style), false);
185 return element;
186 }
187
188 /**
189 * @param {!Map.<string, string>} style
190 * @return {string}
191 */
192 function getContentAreaWidthPx(style) {
193 let width = style.get('width').replace(/px$/, '');
194 if (!isNaN(width) && style.get('box-sizing') === 'border-box') {
195 const borderBox = self._getBox(style, 'border');
196 const paddingBox = self._getBox(style, 'padding');
197
198 width = width - borderBox.left - borderBox.right - paddingBox.left - paddingBox.right;
199 }
200
201 return Number.toFixedIfFloating(width.toString());
202 }
203
204 /**
205 * @param {!Map.<string, string>} style
206 * @return {string}
207 */
208 function getContentAreaHeightPx(style) {
209 let height = style.get('height').replace(/px$/, '');
210 if (!isNaN(height) && style.get('box-sizing') === 'border-box') {
211 const borderBox = self._getBox(style, 'border');
212 const paddingBox = self._getBox(style, 'padding');
213
214 height = height - borderBox.top - borderBox.bottom - paddingBox.top - paddingBox.bottom;
215 }
216
217 return Number.toFixedIfFloating(height.toString());
218 }
219
220 // Display types for which margin is ignored.
221 const noMarginDisplayType = {
222 'table-cell': true,
223 'table-column': true,
224 'table-column-group': true,
225 'table-footer-group': true,
226 'table-header-group': true,
227 'table-row': true,
228 'table-row-group': true
229 };
230
231 // Display types for which padding is ignored.
232 const noPaddingDisplayType = {
233 'table-column': true,
234 'table-column-group': true,
235 'table-footer-group': true,
236 'table-header-group': true,
237 'table-row': true,
238 'table-row-group': true
239 };
240
241 // Position types for which top, left, bottom and right are ignored.
242 const noPositionType = {'static': true};
243
244 const boxes = ['content', 'padding', 'border', 'margin', 'position'];
245 const boxColors = [
246 Common.Color.PageHighlight.Content, Common.Color.PageHighlight.Padding, Common.Color.PageHighlight.Border,
Tim van der Lippe97611c92020-02-12 16:56:58247 Common.Color.PageHighlight.Margin, Common.Color.Color.fromRGBA([0, 0, 0, 0])
Blink Reformat4c46d092018-04-07 15:32:37248 ];
249 const boxLabels = [
Tim van der Lippe97611c92020-02-12 16:56:58250 Common.UIString.UIString('content'), Common.UIString.UIString('padding'), Common.UIString.UIString('border'),
251 Common.UIString.UIString('margin'), Common.UIString.UIString('position')
Blink Reformat4c46d092018-04-07 15:32:37252 ];
253 let previousBox = null;
254 this._boxElements = [];
255 for (let i = 0; i < boxes.length; ++i) {
256 const name = boxes[i];
257
Tim van der Lippe1d6e57a2019-09-30 11:55:34258 if (name === 'margin' && noMarginDisplayType[style.get('display')]) {
Blink Reformat4c46d092018-04-07 15:32:37259 continue;
Tim van der Lippe1d6e57a2019-09-30 11:55:34260 }
261 if (name === 'padding' && noPaddingDisplayType[style.get('display')]) {
Blink Reformat4c46d092018-04-07 15:32:37262 continue;
Tim van der Lippe1d6e57a2019-09-30 11:55:34263 }
264 if (name === 'position' && noPositionType[style.get('position')]) {
Blink Reformat4c46d092018-04-07 15:32:37265 continue;
Tim van der Lippe1d6e57a2019-09-30 11:55:34266 }
Blink Reformat4c46d092018-04-07 15:32:37267
268 const boxElement = createElement('div');
269 boxElement.className = name;
270 boxElement._backgroundColor = boxColors[i].asString(Common.Color.Format.RGBA);
271 boxElement._name = name;
272 boxElement.style.backgroundColor = boxElement._backgroundColor;
273 boxElement.addEventListener(
274 'mouseover', this._highlightDOMNode.bind(this, true, name === 'position' ? 'all' : name), false);
275 this._boxElements.push(boxElement);
276
277 if (name === 'content') {
278 const widthElement = createElement('span');
279 widthElement.textContent = getContentAreaWidthPx(style);
280 widthElement.addEventListener(
281 'dblclick', this.startEditing.bind(this, widthElement, 'width', 'width', style), false);
282
283 const heightElement = createElement('span');
284 heightElement.textContent = getContentAreaHeightPx(style);
285 heightElement.addEventListener(
286 'dblclick', this.startEditing.bind(this, heightElement, 'height', 'height', style), false);
287
288 boxElement.appendChild(widthElement);
Mathias Bynens23ee1aa2020-03-02 12:06:38289 boxElement.createTextChild(' × ');
Blink Reformat4c46d092018-04-07 15:32:37290 boxElement.appendChild(heightElement);
291 } else {
292 const suffix = (name === 'border' ? '-width' : '');
293
294 const labelElement = createElement('div');
295 labelElement.className = 'label';
296 labelElement.textContent = boxLabels[i];
297 boxElement.appendChild(labelElement);
298
299 boxElement.appendChild(createBoxPartElement.call(this, style, name, 'top', suffix));
300 boxElement.appendChild(createElement('br'));
301 boxElement.appendChild(createBoxPartElement.call(this, style, name, 'left', suffix));
302
Tim van der Lippe1d6e57a2019-09-30 11:55:34303 if (previousBox) {
Blink Reformat4c46d092018-04-07 15:32:37304 boxElement.appendChild(previousBox);
Tim van der Lippe1d6e57a2019-09-30 11:55:34305 }
Blink Reformat4c46d092018-04-07 15:32:37306
307 boxElement.appendChild(createBoxPartElement.call(this, style, name, 'right', suffix));
308 boxElement.appendChild(createElement('br'));
309 boxElement.appendChild(createBoxPartElement.call(this, style, name, 'bottom', suffix));
310 }
311
312 previousBox = boxElement;
313 }
314
315 metricsElement.appendChild(previousBox);
316 metricsElement.addEventListener('mouseover', this._highlightDOMNode.bind(this, false, 'all'), false);
Changhao Han1d41edd2020-09-14 03:02:22317 metricsElement.addEventListener('mouseleave', this._highlightDOMNode.bind(this, false, 'all'), false);
Blink Reformat4c46d092018-04-07 15:32:37318 this.contentElement.removeChildren();
319 this.contentElement.appendChild(metricsElement);
Blink Reformat4c46d092018-04-07 15:32:37320 }
321
322 /**
323 * @param {!Element} targetElement
324 * @param {string} box
325 * @param {string} styleProperty
326 * @param {!Map.<string, string>} computedStyle
327 */
328 startEditing(targetElement, box, styleProperty, computedStyle) {
Tim van der Lippe97611c92020-02-12 16:56:58329 if (UI.UIUtils.isBeingEdited(targetElement)) {
Blink Reformat4c46d092018-04-07 15:32:37330 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34331 }
Blink Reformat4c46d092018-04-07 15:32:37332
333 const context = {box: box, styleProperty: styleProperty, computedStyle: computedStyle};
334 const boundKeyDown = this._handleKeyDown.bind(this, context, styleProperty);
335 context.keyDownHandler = boundKeyDown;
336 targetElement.addEventListener('keydown', boundKeyDown, false);
337
338 this._isEditingMetrics = true;
339
340 const config =
341 new UI.InplaceEditor.Config(this._editingCommitted.bind(this), this.editingCancelled.bind(this), context);
Tim van der Lippe97611c92020-02-12 16:56:58342 UI.InplaceEditor.InplaceEditor.startEditing(targetElement, config);
Blink Reformat4c46d092018-04-07 15:32:37343
344 targetElement.getComponentSelection().selectAllChildren(targetElement);
345 }
346
347 _handleKeyDown(context, styleProperty, event) {
348 const element = event.currentTarget;
349
350 /**
351 * @param {string} originalValue
352 * @param {string} replacementString
Tim van der Lippe13f71fb2019-11-29 11:17:39353 * @this {MetricsSidebarPane}
Blink Reformat4c46d092018-04-07 15:32:37354 */
355 function finishHandler(originalValue, replacementString) {
356 this._applyUserInput(element, replacementString, originalValue, context, false);
357 }
358
359 /**
360 * @param {string} prefix
361 * @param {number} number
362 * @param {string} suffix
363 * @return {string}
364 */
365 function customNumberHandler(prefix, number, suffix) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34366 if (styleProperty !== 'margin' && number < 0) {
Blink Reformat4c46d092018-04-07 15:32:37367 number = 0;
Tim van der Lippe1d6e57a2019-09-30 11:55:34368 }
Blink Reformat4c46d092018-04-07 15:32:37369 return prefix + number + suffix;
370 }
371
Tim van der Lippe97611c92020-02-12 16:56:58372 UI.UIUtils.handleElementValueModifications(
373 event, element, finishHandler.bind(this), undefined, customNumberHandler);
Blink Reformat4c46d092018-04-07 15:32:37374 }
375
376 editingEnded(element, context) {
377 delete this.originalPropertyData;
378 delete this.previousPropertyDataCandidate;
379 element.removeEventListener('keydown', context.keyDownHandler, false);
380 delete this._isEditingMetrics;
381 }
382
383 editingCancelled(element, context) {
384 if ('originalPropertyData' in this && this._inlineStyle) {
385 if (!this.originalPropertyData) {
386 // An added property, remove the last property in the style.
387 const pastLastSourcePropertyIndex = this._inlineStyle.pastLastSourcePropertyIndex();
Tim van der Lippe1d6e57a2019-09-30 11:55:34388 if (pastLastSourcePropertyIndex) {
Blink Reformat4c46d092018-04-07 15:32:37389 this._inlineStyle.allProperties()[pastLastSourcePropertyIndex - 1].setText('', false);
Tim van der Lippe1d6e57a2019-09-30 11:55:34390 }
Blink Reformat4c46d092018-04-07 15:32:37391 } else {
392 this._inlineStyle.allProperties()[this.originalPropertyData.index].setText(
393 this.originalPropertyData.propertyText, false);
394 }
395 }
396 this.editingEnded(element, context);
397 this.update();
398 }
399
400 _applyUserInput(element, userInput, previousContent, context, commitEditor) {
401 if (!this._inlineStyle) {
402 // Element has no renderer.
403 return this.editingCancelled(element, context); // nothing changed, so cancel
404 }
405
Tim van der Lippe1d6e57a2019-09-30 11:55:34406 if (commitEditor && userInput === previousContent) {
407 return this.editingCancelled(element, context);
408 } // nothing changed, so cancel
Blink Reformat4c46d092018-04-07 15:32:37409
Tim van der Lippe1d6e57a2019-09-30 11:55:34410 if (context.box !== 'position' && (!userInput || userInput === '\u2012')) {
Blink Reformat4c46d092018-04-07 15:32:37411 userInput = '0px';
Tim van der Lippe1d6e57a2019-09-30 11:55:34412 } else if (context.box === 'position' && (!userInput || userInput === '\u2012')) {
Blink Reformat4c46d092018-04-07 15:32:37413 userInput = 'auto';
Tim van der Lippe1d6e57a2019-09-30 11:55:34414 }
Blink Reformat4c46d092018-04-07 15:32:37415
416 userInput = userInput.toLowerCase();
417 // Append a "px" unit if the user input was just a number.
Tim van der Lippe1d6e57a2019-09-30 11:55:34418 if (/^\d+$/.test(userInput)) {
Blink Reformat4c46d092018-04-07 15:32:37419 userInput += 'px';
Tim van der Lippe1d6e57a2019-09-30 11:55:34420 }
Blink Reformat4c46d092018-04-07 15:32:37421
422 const styleProperty = context.styleProperty;
423 const computedStyle = context.computedStyle;
424
425 if (computedStyle.get('box-sizing') === 'border-box' && (styleProperty === 'width' || styleProperty === 'height')) {
426 if (!userInput.match(/px$/)) {
Paul Lewisa83ea612020-03-04 13:01:36427 Common.Console.Console.instance().error(
Blink Reformat4c46d092018-04-07 15:32:37428 'For elements with box-sizing: border-box, only absolute content area dimensions can be applied');
429 return;
430 }
431
432 const borderBox = this._getBox(computedStyle, 'border');
433 const paddingBox = this._getBox(computedStyle, 'padding');
434 let userValuePx = Number(userInput.replace(/px$/, ''));
Tim van der Lippe1d6e57a2019-09-30 11:55:34435 if (isNaN(userValuePx)) {
Blink Reformat4c46d092018-04-07 15:32:37436 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34437 }
438 if (styleProperty === 'width') {
Blink Reformat4c46d092018-04-07 15:32:37439 userValuePx += borderBox.left + borderBox.right + paddingBox.left + paddingBox.right;
Tim van der Lippe1d6e57a2019-09-30 11:55:34440 } else {
Blink Reformat4c46d092018-04-07 15:32:37441 userValuePx += borderBox.top + borderBox.bottom + paddingBox.top + paddingBox.bottom;
Tim van der Lippe1d6e57a2019-09-30 11:55:34442 }
Blink Reformat4c46d092018-04-07 15:32:37443
444 userInput = userValuePx + 'px';
445 }
446
447 this.previousPropertyDataCandidate = null;
448
449 const allProperties = this._inlineStyle.allProperties();
450 for (let i = 0; i < allProperties.length; ++i) {
451 const property = allProperties[i];
Tim van der Lippe1d6e57a2019-09-30 11:55:34452 if (property.name !== context.styleProperty || !property.activeInStyle()) {
Blink Reformat4c46d092018-04-07 15:32:37453 continue;
Tim van der Lippe1d6e57a2019-09-30 11:55:34454 }
Blink Reformat4c46d092018-04-07 15:32:37455
456 this.previousPropertyDataCandidate = property;
457 property.setValue(userInput, commitEditor, true, callback.bind(this));
458 return;
459 }
460
461 this._inlineStyle.appendProperty(context.styleProperty, userInput, callback.bind(this));
462
463 /**
464 * @param {boolean} success
Tim van der Lippe13f71fb2019-11-29 11:17:39465 * @this {MetricsSidebarPane}
Blink Reformat4c46d092018-04-07 15:32:37466 */
467 function callback(success) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34468 if (!success) {
Blink Reformat4c46d092018-04-07 15:32:37469 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34470 }
471 if (!('originalPropertyData' in this)) {
Blink Reformat4c46d092018-04-07 15:32:37472 this.originalPropertyData = this.previousPropertyDataCandidate;
Tim van der Lippe1d6e57a2019-09-30 11:55:34473 }
Blink Reformat4c46d092018-04-07 15:32:37474
Tim van der Lippe1d6e57a2019-09-30 11:55:34475 if (typeof this._highlightMode !== 'undefined') {
Blink Reformat4c46d092018-04-07 15:32:37476 this.node().highlight(this._highlightMode);
Tim van der Lippe1d6e57a2019-09-30 11:55:34477 }
Blink Reformat4c46d092018-04-07 15:32:37478
Tim van der Lippe1d6e57a2019-09-30 11:55:34479 if (commitEditor) {
Blink Reformat4c46d092018-04-07 15:32:37480 this.update();
Tim van der Lippe1d6e57a2019-09-30 11:55:34481 }
Blink Reformat4c46d092018-04-07 15:32:37482 }
483 }
484
485 _editingCommitted(element, userInput, previousContent, context) {
486 this.editingEnded(element, context);
487 this._applyUserInput(element, userInput, previousContent, context, true);
488 }
Tim van der Lippe13f71fb2019-11-29 11:17:39489}