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 = {
'space-before-function-paren': [
'error',
{
anonymous: 'always',
anonymous: 'never',
asyncArrow: 'always',
named: 'never'
}
],
......
......@@ -37,7 +37,7 @@ function installGetter(proto, propName, getter) {
export function installPropertiesAndFunctions(proto, internals) {
reflection.installBool(proto, 'disabled');
reflection.installString(proto, 'name');
installGetter(proto, 'type', function () {
installGetter(proto, 'type', function() {
if (!(this instanceof proto.constructor)) {
throw new TypeError(
'The context object is not an instance of ' + proto.contructor.name);
......@@ -45,28 +45,28 @@ export function installPropertiesAndFunctions(proto, internals) {
return this.localName;
});
installGetter(proto, 'form', function () {
installGetter(proto, 'form', function() {
return this[internals].form;
});
installGetter(proto, 'willValidate', function () {
installGetter(proto, 'willValidate', function() {
return this[internals].willValidate;
});
installGetter(proto, 'validity', function () {
installGetter(proto, 'validity', function() {
return this[internals].validity;
});
installGetter(proto, 'validationMessage', function () {
installGetter(proto, 'validationMessage', function() {
return this[internals].validationMessage;
});
installGetter(proto, 'labels', function () {
installGetter(proto, 'labels', function() {
return this[internals].labels;
});
proto.checkValidity = function () {
proto.checkValidity = function() {
return this[internals].checkValidity();
};
proto.reportValidity = function () {
proto.reportValidity = function() {
return this[internals].reportValidity();
};
proto.setCustomValidity = function (error) {
proto.setCustomValidity = function(error) {
if (error === undefined) {
throw new TypeError('Too few arguments');
}
......
......@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as face from './face_utils.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 {SwitchTrack} from './track.mjs';
const generateStyleSheet = style.styleSheetFactory();
......@@ -33,7 +34,8 @@ export class StdSwitchElement extends HTMLElement {
constructor() {
super();
if (new.target !== StdSwitchElement) {
throw new TypeError('Illegal constructor: StdSwitchElement is not ' +
throw new TypeError(
'Illegal constructor: StdSwitchElement is not ' +
'extensible for now');
}
this[_internals] = this.attachInternals();
......
......@@ -173,7 +173,8 @@ export class StdToastElement extends HTMLElement {
show({duration = DEFAULT_DURATION} = {}) {
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]`);
}
......@@ -224,12 +225,7 @@ delete StdToastElement.prototype.connectedCallback;
export function showToast(message, options = {}) {
const toast = new StdToastElement(message);
const {
action,
closeButton,
type,
...showOptions
} = options;
const {action, closeButton, type, ...showOptions} = options;
if (isElement(action)) {
toast.action = action;
......@@ -258,8 +254,7 @@ export function showToast(message, options = {}) {
return toast;
}
const idGetter =
Object.getOwnPropertyDescriptor(Element.prototype, 'id').get;
const idGetter = Object.getOwnPropertyDescriptor(Element.prototype, 'id').get;
function isElement(value) {
try {
idGetter.call(value);
......
......@@ -12,7 +12,7 @@
*
* @param {!Set} a A set of elements.
* @param {!Set} b A set of elements.
*/
*/
export function difference(a, b) {
const result = new Set();
for (const element of a) {
......
......@@ -7,8 +7,8 @@
* element.
* @package
*/
import * as sets from './sets.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
......@@ -61,7 +61,7 @@ const EMPTY_ELEMENT_BOUNDS = new ElementBounds(null, null);
*
* This tracks an average measured element size as elements are added
* and removed.
*/
*/
class SizeManager {
#sizes = new WeakMap();
......@@ -97,7 +97,8 @@ class SizeManager {
return size === undefined ? this.#getAverageSize() : size;
}
#getAverageSize = () => {
#getAverageSize =
() => {
return this.#measuredCount > 0 ?
this.#totalMeasuredSize / this.#measuredCount :
DEFAULT_HEIGHT_ESTIMATE_PX;
......@@ -127,7 +128,7 @@ class SizeManager {
* It uses resize and intersection observers on all of the visible
* elements to ensure that changes that impact visibility cause us to
* recalulate things (e.g. scrolling, restyling).
*/
*/
export class VisibilityManager {
#sizeManager = new SizeManager();
#elements;
......@@ -163,7 +164,8 @@ export class VisibilityManager {
* Attempts to unlock a range of elements suitable for the current
* viewport. This causes one forced layout.
*/
#sync = () => {
#sync =
() => {
if (this.#elements.length === 0) {
return;
}
......@@ -218,9 +220,10 @@ export class VisibilityManager {
* @param {!number} low The lower bound to locate.
* @param {!number} high The upper bound to locate.
*/
#findElementBounds = (low, high) => {
const lowElement = findElement.findElement(
this.#elements, low, findElement.BIAS_LOW);
#findElementBounds =
(low, high) => {
const lowElement =
findElement.findElement(this.#elements, low, findElement.BIAS_LOW);
const highElement = findElement.findElement(
this.#elements, high, findElement.BIAS_HIGH);
......@@ -241,7 +244,8 @@ export class VisibilityManager {
* Updates the size manager with all of the currently revealed
* elements' sizes. This will cause a forced layout.
*/
#measureRevealed = () => {
#measureRevealed =
() => {
for (const element of this.#revealed) {
this.#sizeManager.measure(element);
}
......@@ -253,16 +257,20 @@ export class VisibilityManager {
*
* @param {!Element} element The element to reveal.
*/
#reveal = element => {
#reveal =
element => {
this.#revealed.add(element);
this.#elementIntersectionObserver.observe(element);
this.#elementResizeObserver.observe(element);
this.#unlock(element);
}
#logLockingError = (operation, reason, element) => {
#logLockingError =
(operation, reason, element) => {
// 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 {
*
* @param {!Element} element The element to unlock.
*/
#unlock = element => {
#unlock =
element => {
element.displayLock.commit().catch(reason => {
// Only warn if the unlocked failed and we should be revealed.
if (this.#revealed.has(element)) {
......@@ -285,15 +294,19 @@ export class VisibilityManager {
*
* @param {!Element} element The element to hide.
*/
#hide = element => {
#hide =
element => {
this.#revealed.delete(element);
this.#elementIntersectionObserver.unobserve(element);
this.#elementResizeObserver.unobserve(element);
element.displayLock.acquire({
element.displayLock
.acquire({
timeout: Infinity,
activatable: true,
size: [LOCKED_WIDTH_PX, this.#sizeManager.getHopefulSize(element)],
}).catch(reason => {
size:
[LOCKED_WIDTH_PX, this.#sizeManager.getHopefulSize(element)],
})
.catch(reason => {
// Only warn if the lock failed and we should be locked.
if (!this.#revealed.has(element)) {
this.#logLockingError('Acquire', reason, element);
......@@ -307,7 +320,8 @@ export class VisibilityManager {
*
* @param {!Element} element The element that was added.
*/
#didAdd = element => {
#didAdd =
element => {
// Added children should be invisible initially. We want to make them
// invisible at this MutationObserver timing, so that there is no
// frame where the browser is asked to render all of the children
......@@ -321,7 +335,8 @@ export class VisibilityManager {
*
* @param {!Element} element The element that was removed.
*/
#didRemove = element => {
#didRemove =
element => {
// Removed children should be made visible again. We should stop
// observing them and discard any size info we have for them as it
// may have become incorrect.
......@@ -404,4 +419,3 @@ export class VisibilityManager {
}
}
}
......@@ -45,10 +45,8 @@ const StorageAreaAsyncIteratorPrototype = {
};
Object.defineProperty(
StorageAreaAsyncIteratorPrototype,
Symbol.toStringTag,
{writable: false, enumerable: false}
);
StorageAreaAsyncIteratorPrototype, Symbol.toStringTag,
{writable: false, enumerable: false});
function getNextIterResult(iter, performDatabaseOperation) {
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