Commit ffdd8ad5 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Reformat all of our .mjs files with clang-format --style=file

Tweak space-before-function-paren rules to be comatible with clang-format.

Change-Id: I686766972996f652a8ffe15f724227279117bbb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1767284
Commit-Queue: Fergal Daly <fergal@chromium.org>
Reviewed-by: default avatarDomenic Denicola <domenic@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690266}
parent d20f64b9
...@@ -272,7 +272,8 @@ module.exports = { ...@@ -272,7 +272,8 @@ module.exports = {
'space-before-function-paren': [ 'space-before-function-paren': [
'error', 'error',
{ {
anonymous: 'always', anonymous: 'never',
asyncArrow: 'always',
named: 'never' named: 'never'
} }
], ],
......
...@@ -37,7 +37,7 @@ function installGetter(proto, propName, getter) { ...@@ -37,7 +37,7 @@ function installGetter(proto, propName, getter) {
export function installPropertiesAndFunctions(proto, internals) { export function installPropertiesAndFunctions(proto, internals) {
reflection.installBool(proto, 'disabled'); reflection.installBool(proto, 'disabled');
reflection.installString(proto, 'name'); reflection.installString(proto, 'name');
installGetter(proto, 'type', function () { installGetter(proto, 'type', function() {
if (!(this instanceof proto.constructor)) { if (!(this instanceof proto.constructor)) {
throw new TypeError( throw new TypeError(
'The context object is not an instance of ' + proto.contructor.name); 'The context object is not an instance of ' + proto.contructor.name);
...@@ -45,28 +45,28 @@ export function installPropertiesAndFunctions(proto, internals) { ...@@ -45,28 +45,28 @@ export function installPropertiesAndFunctions(proto, internals) {
return this.localName; return this.localName;
}); });
installGetter(proto, 'form', function () { installGetter(proto, 'form', function() {
return this[internals].form; return this[internals].form;
}); });
installGetter(proto, 'willValidate', function () { installGetter(proto, 'willValidate', function() {
return this[internals].willValidate; return this[internals].willValidate;
}); });
installGetter(proto, 'validity', function () { installGetter(proto, 'validity', function() {
return this[internals].validity; return this[internals].validity;
}); });
installGetter(proto, 'validationMessage', function () { installGetter(proto, 'validationMessage', function() {
return this[internals].validationMessage; return this[internals].validationMessage;
}); });
installGetter(proto, 'labels', function () { installGetter(proto, 'labels', function() {
return this[internals].labels; return this[internals].labels;
}); });
proto.checkValidity = function () { proto.checkValidity = function() {
return this[internals].checkValidity(); return this[internals].checkValidity();
}; };
proto.reportValidity = function () { proto.reportValidity = function() {
return this[internals].reportValidity(); return this[internals].reportValidity();
}; };
proto.setCustomValidity = function (error) { proto.setCustomValidity = function(error) {
if (error === undefined) { if (error === undefined) {
throw new TypeError('Too few arguments'); throw new TypeError('Too few arguments');
} }
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import * as face from './face_utils.mjs';
import * as reflection from '../internal/reflection.mjs'; import * as reflection from '../internal/reflection.mjs';
import {SwitchTrack} from './track.mjs';
import * as face from './face_utils.mjs';
import * as style from './style.mjs'; import * as style from './style.mjs';
import {SwitchTrack} from './track.mjs';
const generateStyleSheet = style.styleSheetFactory(); const generateStyleSheet = style.styleSheetFactory();
...@@ -33,7 +34,8 @@ export class StdSwitchElement extends HTMLElement { ...@@ -33,7 +34,8 @@ export class StdSwitchElement extends HTMLElement {
constructor() { constructor() {
super(); super();
if (new.target !== StdSwitchElement) { if (new.target !== StdSwitchElement) {
throw new TypeError('Illegal constructor: StdSwitchElement is not ' + throw new TypeError(
'Illegal constructor: StdSwitchElement is not ' +
'extensible for now'); 'extensible for now');
} }
this[_internals] = this.attachInternals(); this[_internals] = this.attachInternals();
......
...@@ -173,7 +173,8 @@ export class StdToastElement extends HTMLElement { ...@@ -173,7 +173,8 @@ export class StdToastElement extends HTMLElement {
show({duration = DEFAULT_DURATION} = {}) { show({duration = DEFAULT_DURATION} = {}) {
if (duration <= 0) { if (duration <= 0) {
throw new RangeError(`Invalid Argument: duration must be greater ` + throw new RangeError(
`Invalid Argument: duration must be greater ` +
`than 0 [${duration} given]`); `than 0 [${duration} given]`);
} }
...@@ -224,12 +225,7 @@ delete StdToastElement.prototype.connectedCallback; ...@@ -224,12 +225,7 @@ delete StdToastElement.prototype.connectedCallback;
export function showToast(message, options = {}) { export function showToast(message, options = {}) {
const toast = new StdToastElement(message); const toast = new StdToastElement(message);
const { const {action, closeButton, type, ...showOptions} = options;
action,
closeButton,
type,
...showOptions
} = options;
if (isElement(action)) { if (isElement(action)) {
toast.action = action; toast.action = action;
...@@ -258,8 +254,7 @@ export function showToast(message, options = {}) { ...@@ -258,8 +254,7 @@ export function showToast(message, options = {}) {
return toast; return toast;
} }
const idGetter = const idGetter = Object.getOwnPropertyDescriptor(Element.prototype, 'id').get;
Object.getOwnPropertyDescriptor(Element.prototype, 'id').get;
function isElement(value) { function isElement(value) {
try { try {
idGetter.call(value); idGetter.call(value);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* @param {!Set} a A set of elements. * @param {!Set} a A set of elements.
* @param {!Set} b A set of elements. * @param {!Set} b A set of elements.
*/ */
export function difference(a, b) { export function difference(a, b) {
const result = new Set(); const result = new Set();
for (const element of a) { for (const element of a) {
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* element. * element.
* @package * @package
*/ */
import * as sets from './sets.mjs';
import * as findElement from './find-element.mjs'; import * as findElement from './find-element.mjs';
import * as sets from './sets.mjs';
// This controls how much above and below the current screen we // This controls how much above and below the current screen we
...@@ -61,7 +61,7 @@ const EMPTY_ELEMENT_BOUNDS = new ElementBounds(null, null); ...@@ -61,7 +61,7 @@ const EMPTY_ELEMENT_BOUNDS = new ElementBounds(null, null);
* *
* This tracks an average measured element size as elements are added * This tracks an average measured element size as elements are added
* and removed. * and removed.
*/ */
class SizeManager { class SizeManager {
#sizes = new WeakMap(); #sizes = new WeakMap();
...@@ -97,7 +97,8 @@ class SizeManager { ...@@ -97,7 +97,8 @@ class SizeManager {
return size === undefined ? this.#getAverageSize() : size; return size === undefined ? this.#getAverageSize() : size;
} }
#getAverageSize = () => { #getAverageSize =
() => {
return this.#measuredCount > 0 ? return this.#measuredCount > 0 ?
this.#totalMeasuredSize / this.#measuredCount : this.#totalMeasuredSize / this.#measuredCount :
DEFAULT_HEIGHT_ESTIMATE_PX; DEFAULT_HEIGHT_ESTIMATE_PX;
...@@ -127,7 +128,7 @@ class SizeManager { ...@@ -127,7 +128,7 @@ class SizeManager {
* It uses resize and intersection observers on all of the visible * It uses resize and intersection observers on all of the visible
* elements to ensure that changes that impact visibility cause us to * elements to ensure that changes that impact visibility cause us to
* recalulate things (e.g. scrolling, restyling). * recalulate things (e.g. scrolling, restyling).
*/ */
export class VisibilityManager { export class VisibilityManager {
#sizeManager = new SizeManager(); #sizeManager = new SizeManager();
#elements; #elements;
...@@ -163,7 +164,8 @@ export class VisibilityManager { ...@@ -163,7 +164,8 @@ export class VisibilityManager {
* Attempts to unlock a range of elements suitable for the current * Attempts to unlock a range of elements suitable for the current
* viewport. This causes one forced layout. * viewport. This causes one forced layout.
*/ */
#sync = () => { #sync =
() => {
if (this.#elements.length === 0) { if (this.#elements.length === 0) {
return; return;
} }
...@@ -218,9 +220,10 @@ export class VisibilityManager { ...@@ -218,9 +220,10 @@ export class VisibilityManager {
* @param {!number} low The lower bound to locate. * @param {!number} low The lower bound to locate.
* @param {!number} high The upper bound to locate. * @param {!number} high The upper bound to locate.
*/ */
#findElementBounds = (low, high) => { #findElementBounds =
const lowElement = findElement.findElement( (low, high) => {
this.#elements, low, findElement.BIAS_LOW); const lowElement =
findElement.findElement(this.#elements, low, findElement.BIAS_LOW);
const highElement = findElement.findElement( const highElement = findElement.findElement(
this.#elements, high, findElement.BIAS_HIGH); this.#elements, high, findElement.BIAS_HIGH);
...@@ -241,7 +244,8 @@ export class VisibilityManager { ...@@ -241,7 +244,8 @@ export class VisibilityManager {
* Updates the size manager with all of the currently revealed * Updates the size manager with all of the currently revealed
* elements' sizes. This will cause a forced layout. * elements' sizes. This will cause a forced layout.
*/ */
#measureRevealed = () => { #measureRevealed =
() => {
for (const element of this.#revealed) { for (const element of this.#revealed) {
this.#sizeManager.measure(element); this.#sizeManager.measure(element);
} }
...@@ -253,16 +257,20 @@ export class VisibilityManager { ...@@ -253,16 +257,20 @@ export class VisibilityManager {
* *
* @param {!Element} element The element to reveal. * @param {!Element} element The element to reveal.
*/ */
#reveal = element => { #reveal =
element => {
this.#revealed.add(element); this.#revealed.add(element);
this.#elementIntersectionObserver.observe(element); this.#elementIntersectionObserver.observe(element);
this.#elementResizeObserver.observe(element); this.#elementResizeObserver.observe(element);
this.#unlock(element); this.#unlock(element);
} }
#logLockingError = (operation, reason, element) => { #logLockingError =
(operation, reason, element) => {
// TODO: Figure out the LAPIs error/warning logging story. // TODO: Figure out the LAPIs error/warning logging story.
console.error('Rejected: ', operation, element, reason); // eslint-disable-line no-console console.error( // eslint-disable-line no-console
'Rejected: ', operation, element,
reason);
} }
/** /**
...@@ -270,7 +278,8 @@ export class VisibilityManager { ...@@ -270,7 +278,8 @@ export class VisibilityManager {
* *
* @param {!Element} element The element to unlock. * @param {!Element} element The element to unlock.
*/ */
#unlock = element => { #unlock =
element => {
element.displayLock.commit().catch(reason => { element.displayLock.commit().catch(reason => {
// Only warn if the unlocked failed and we should be revealed. // Only warn if the unlocked failed and we should be revealed.
if (this.#revealed.has(element)) { if (this.#revealed.has(element)) {
...@@ -285,15 +294,19 @@ export class VisibilityManager { ...@@ -285,15 +294,19 @@ export class VisibilityManager {
* *
* @param {!Element} element The element to hide. * @param {!Element} element The element to hide.
*/ */
#hide = element => { #hide =
element => {
this.#revealed.delete(element); this.#revealed.delete(element);
this.#elementIntersectionObserver.unobserve(element); this.#elementIntersectionObserver.unobserve(element);
this.#elementResizeObserver.unobserve(element); this.#elementResizeObserver.unobserve(element);
element.displayLock.acquire({ element.displayLock
.acquire({
timeout: Infinity, timeout: Infinity,
activatable: true, activatable: true,
size: [LOCKED_WIDTH_PX, this.#sizeManager.getHopefulSize(element)], size:
}).catch(reason => { [LOCKED_WIDTH_PX, this.#sizeManager.getHopefulSize(element)],
})
.catch(reason => {
// Only warn if the lock failed and we should be locked. // Only warn if the lock failed and we should be locked.
if (!this.#revealed.has(element)) { if (!this.#revealed.has(element)) {
this.#logLockingError('Acquire', reason, element); this.#logLockingError('Acquire', reason, element);
...@@ -307,7 +320,8 @@ export class VisibilityManager { ...@@ -307,7 +320,8 @@ export class VisibilityManager {
* *
* @param {!Element} element The element that was added. * @param {!Element} element The element that was added.
*/ */
#didAdd = element => { #didAdd =
element => {
// Added children should be invisible initially. We want to make them // Added children should be invisible initially. We want to make them
// invisible at this MutationObserver timing, so that there is no // invisible at this MutationObserver timing, so that there is no
// frame where the browser is asked to render all of the children // frame where the browser is asked to render all of the children
...@@ -321,7 +335,8 @@ export class VisibilityManager { ...@@ -321,7 +335,8 @@ export class VisibilityManager {
* *
* @param {!Element} element The element that was removed. * @param {!Element} element The element that was removed.
*/ */
#didRemove = element => { #didRemove =
element => {
// Removed children should be made visible again. We should stop // Removed children should be made visible again. We should stop
// observing them and discard any size info we have for them as it // observing them and discard any size info we have for them as it
// may have become incorrect. // may have become incorrect.
...@@ -404,4 +419,3 @@ export class VisibilityManager { ...@@ -404,4 +419,3 @@ export class VisibilityManager {
} }
} }
} }
...@@ -45,10 +45,8 @@ const StorageAreaAsyncIteratorPrototype = { ...@@ -45,10 +45,8 @@ const StorageAreaAsyncIteratorPrototype = {
}; };
Object.defineProperty( Object.defineProperty(
StorageAreaAsyncIteratorPrototype, StorageAreaAsyncIteratorPrototype, Symbol.toStringTag,
Symbol.toStringTag, {writable: false, enumerable: false});
{writable: false, enumerable: false}
);
function getNextIterResult(iter, performDatabaseOperation) { function getNextIterResult(iter, performDatabaseOperation) {
return performDatabaseOperation(async (transaction, store) => { return performDatabaseOperation(async (transaction, store) => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment