Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Format Closure library with clang-format
Browse files Browse the repository at this point in the history
RELNOTES: n/a
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=112731031
  • Loading branch information
joeltine authored and shicks committed Jan 23, 2016
1 parent 6ad65a8 commit e877b1e
Show file tree
Hide file tree
Showing 1,024 changed files with 37,436 additions and 37,440 deletions.
6 changes: 2 additions & 4 deletions closure/goog/a11y/aria/announcer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ goog.a11y.aria.Announcer.prototype.getLiveRegion_ = function(priority) {
liveRegion.style.top = '-1000px';
liveRegion.style.height = '1px';
liveRegion.style.overflow = 'hidden';
goog.a11y.aria.setState(liveRegion, goog.a11y.aria.State.LIVE,
priority);
goog.a11y.aria.setState(liveRegion, goog.a11y.aria.State.ATOMIC,
'true');
goog.a11y.aria.setState(liveRegion, goog.a11y.aria.State.LIVE, priority);
goog.a11y.aria.setState(liveRegion, goog.a11y.aria.State.ATOMIC, 'true');
this.domHelper_.getDocument().body.appendChild(liveRegion);
this.liveRegions_[priority] = liveRegion;
return liveRegion;
Expand Down
12 changes: 6 additions & 6 deletions closure/goog/a11y/aria/announcer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var mockClock;
function setUp() {
sandbox = goog.dom.getElement('sandbox');
someDiv = goog.dom.createDom(goog.dom.TagName.DIV, {id: 'someDiv'}, 'DIV');
someSpan = goog.dom.createDom(goog.dom.TagName.SPAN,
{id: 'someSpan'}, 'SPAN');
someSpan =
goog.dom.createDom(goog.dom.TagName.SPAN, {id: 'someSpan'}, 'SPAN');
sandbox.appendChild(someDiv);
someDiv.appendChild(someSpan);

Expand Down Expand Up @@ -91,8 +91,8 @@ function testAnnouncerAssertive() {
function testAnnouncerInIframe() {
var text = 'test content';
var frame = goog.dom.iframe.createWithContent(sandbox);
var helper = goog.dom.getDomHelper(
goog.dom.getFrameContentDocument(frame).body);
var helper =
goog.dom.getDomHelper(goog.dom.getFrameContentDocument(frame).body);
var announcer = new goog.a11y.aria.Announcer(helper);
announcer.say(text, 'polite', helper);
checkLiveRegionContains(text, 'polite', helper);
Expand All @@ -112,8 +112,8 @@ function testAnnouncerWithAriaHidden() {
// Announce a new message and make sure that the aria-hidden was removed.
announcer.say(text2);
checkLiveRegionContains(text2, 'polite');
assertEquals('',
goog.a11y.aria.getState(liveRegion, goog.a11y.aria.State.HIDDEN));
assertEquals(
'', goog.a11y.aria.getState(liveRegion, goog.a11y.aria.State.HIDDEN));
goog.dispose(announcer);
}

Expand Down
107 changes: 47 additions & 60 deletions closure/goog/a11y/aria/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,12 @@ goog.a11y.aria.ROLE_ATTRIBUTE_ = 'role';
* @private
*/
goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_ = [
goog.dom.TagName.A,
goog.dom.TagName.AREA,
goog.dom.TagName.BUTTON,
goog.dom.TagName.HEAD,
goog.dom.TagName.INPUT,
goog.dom.TagName.LINK,
goog.dom.TagName.MENU,
goog.dom.TagName.META,
goog.dom.TagName.OPTGROUP,
goog.dom.TagName.OPTION,
goog.dom.TagName.PROGRESS,
goog.dom.TagName.STYLE,
goog.dom.TagName.SELECT,
goog.dom.TagName.SOURCE,
goog.dom.TagName.TEXTAREA,
goog.dom.TagName.TITLE,
goog.dom.TagName.TRACK
goog.dom.TagName.A, goog.dom.TagName.AREA, goog.dom.TagName.BUTTON,

This comment has been minimized.

Copy link
@Dominator008

Dominator008 Jan 24, 2016

Contributor

This change is weird. The original version looked better, and resembled what I saw by running clang-format with style="Google".

This comment has been minimized.

Copy link
@concavelenz

concavelenz via email Jan 25, 2016

Contributor

This comment has been minimized.

Copy link
@Dominator008

Dominator008 Jan 25, 2016

Contributor

I thought arrays would be formatted as

var foo = [
  bar,
  baz,
  ...
];

and not

var foo = [
  bar, baz,
  ...
];

This comment has been minimized.

Copy link
@joeltine

joeltine Jan 25, 2016

Author Contributor

It actually was that way to begin with, but we ran into issues where long array literals were bloating code.

goog.dom.TagName.HEAD, goog.dom.TagName.INPUT, goog.dom.TagName.LINK,
goog.dom.TagName.MENU, goog.dom.TagName.META, goog.dom.TagName.OPTGROUP,
goog.dom.TagName.OPTION, goog.dom.TagName.PROGRESS, goog.dom.TagName.STYLE,
goog.dom.TagName.SELECT, goog.dom.TagName.SOURCE, goog.dom.TagName.TEXTAREA,
goog.dom.TagName.TITLE, goog.dom.TagName.TRACK
];


Expand All @@ -84,20 +73,13 @@ goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_ = [
* @private @const
*/
goog.a11y.aria.CONTAINER_ROLES_ = [
goog.a11y.aria.Role.COMBOBOX,
goog.a11y.aria.Role.GRID,
goog.a11y.aria.Role.GROUP,
goog.a11y.aria.Role.LISTBOX,
goog.a11y.aria.Role.MENU,
goog.a11y.aria.Role.MENUBAR,
goog.a11y.aria.Role.RADIOGROUP,
goog.a11y.aria.Role.ROW,
goog.a11y.aria.Role.ROWGROUP,
goog.a11y.aria.Role.TAB_LIST,
goog.a11y.aria.Role.TEXTBOX,
goog.a11y.aria.Role.TOOLBAR,
goog.a11y.aria.Role.TREE,
goog.a11y.aria.Role.TREEGRID
goog.a11y.aria.Role.COMBOBOX, goog.a11y.aria.Role.GRID,
goog.a11y.aria.Role.GROUP, goog.a11y.aria.Role.LISTBOX,
goog.a11y.aria.Role.MENU, goog.a11y.aria.Role.MENUBAR,
goog.a11y.aria.Role.RADIOGROUP, goog.a11y.aria.Role.ROW,
goog.a11y.aria.Role.ROWGROUP, goog.a11y.aria.Role.TAB_LIST,
goog.a11y.aria.Role.TEXTBOX, goog.a11y.aria.Role.TOOLBAR,
goog.a11y.aria.Role.TREE, goog.a11y.aria.Role.TREEGRID
];


Expand All @@ -119,8 +101,9 @@ goog.a11y.aria.setRole = function(element, roleName) {
goog.a11y.aria.removeRole(element);
} else {
if (goog.asserts.ENABLE_ASSERTS) {
goog.asserts.assert(goog.object.containsValue(
goog.a11y.aria.Role, roleName), 'No such ARIA role ' + roleName);
goog.asserts.assert(
goog.object.containsValue(goog.a11y.aria.Role, roleName),
'No such ARIA role ' + roleName);
}
element.setAttribute(goog.a11y.aria.ROLE_ATTRIBUTE_, roleName);
}
Expand Down Expand Up @@ -228,8 +211,9 @@ goog.a11y.aria.getState = function(element, stateName) {
// getState(...) and setState(...) methods.

var attr =
/** @type {string|number|boolean} */ (element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName)));
/** @type {string|number|boolean} */ (
element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName)));
var isNullOrUndefined = attr == null || attr == undefined;
return isNullOrUndefined ? '' : String(attr);
};
Expand All @@ -243,8 +227,8 @@ goog.a11y.aria.getState = function(element, stateName) {
* @return {?Element} DOM node of the activedescendant, if found.
*/
goog.a11y.aria.getActiveDescendant = function(element) {
var id = goog.a11y.aria.getState(
element, goog.a11y.aria.State.ACTIVEDESCENDANT);
var id =
goog.a11y.aria.getState(element, goog.a11y.aria.State.ACTIVEDESCENDANT);
return goog.dom.getOwnerDocument(element).getElementById(id);
};

Expand Down Expand Up @@ -295,20 +279,20 @@ goog.a11y.aria.setLabel = function(element, label) {
* the roles.
*/
goog.a11y.aria.assertRoleIsSetInternalUtil = function(element, allowedRoles) {
if (goog.array.contains(goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_,
element.tagName)) {
if (goog.array.contains(
goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_, element.tagName)) {
return;
}
var elementRole = /** @type {string}*/ (goog.a11y.aria.getRole(element));
goog.asserts.assert(elementRole != null,
'The element ARIA role cannot be null.');
goog.asserts.assert(
elementRole != null, 'The element ARIA role cannot be null.');

goog.asserts.assert(goog.array.contains(allowedRoles, elementRole),
goog.asserts.assert(
goog.array.contains(allowedRoles, elementRole),
'Non existing or incorrect role set for element.' +
'The role set is "' + elementRole +
'". The role should be any of "' + allowedRoles +
'". Check the ARIA specification for more details ' +
'http://www.w3.org/TR/wai-aria/roles.');
'The role set is "' + elementRole + '". The role should be any of "' +
allowedRoles + '". Check the ARIA specification for more details ' +
'http://www.w3.org/TR/wai-aria/roles.');
};


Expand All @@ -321,11 +305,12 @@ goog.a11y.aria.assertRoleIsSetInternalUtil = function(element, allowedRoles) {
*/
goog.a11y.aria.getStateBoolean = function(element, stateName) {
var attr =
/** @type {string|boolean} */ (element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName)));
/** @type {string|boolean} */ (
element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName)));
goog.asserts.assert(
goog.isBoolean(attr) || attr == null || attr == 'true' ||
attr == 'false');
attr == 'false');
if (attr == null) {
return attr;
}
Expand All @@ -342,10 +327,11 @@ goog.a11y.aria.getStateBoolean = function(element, stateName) {
*/
goog.a11y.aria.getStateNumber = function(element, stateName) {
var attr =
/** @type {string|number} */ (element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName)));
goog.asserts.assert((attr == null || !isNaN(Number(attr))) &&
!goog.isBoolean(attr));
/** @type {string|number} */ (
element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName)));
goog.asserts.assert(
(attr == null || !isNaN(Number(attr))) && !goog.isBoolean(attr));
return attr == null ? null : Number(attr);
};

Expand All @@ -358,9 +344,10 @@ goog.a11y.aria.getStateNumber = function(element, stateName) {
* the state value is empty string or not set.
*/
goog.a11y.aria.getStateString = function(element, stateName) {
var attr = element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName));
goog.asserts.assert((attr == null || goog.isString(attr)) &&
var attr =
element.getAttribute(goog.a11y.aria.getAriaAttributeName_(stateName));
goog.asserts.assert(
(attr == null || goog.isString(attr)) &&
(attr == '' || isNaN(Number(attr))) && attr != 'true' && attr != 'false');
return (attr == null || attr == '') ? null : attr;
};
Expand All @@ -376,8 +363,8 @@ goog.a11y.aria.getStateString = function(element, stateName) {
* value of the state attribute.
*/
goog.a11y.aria.getStringArrayStateInternalUtil = function(element, stateName) {
var attrValue = element.getAttribute(
goog.a11y.aria.getAriaAttributeName_(stateName));
var attrValue =
element.getAttribute(goog.a11y.aria.getAriaAttributeName_(stateName));
return goog.a11y.aria.splitStringOnWhitespace_(attrValue);
};

Expand Down Expand Up @@ -430,8 +417,8 @@ goog.a11y.aria.splitStringOnWhitespace_ = function(stringValue) {
goog.a11y.aria.getAriaAttributeName_ = function(ariaName) {
if (goog.asserts.ENABLE_ASSERTS) {
goog.asserts.assert(ariaName, 'ARIA attribute cannot be empty.');
goog.asserts.assert(goog.object.containsValue(
goog.a11y.aria.State, ariaName),
goog.asserts.assert(
goog.object.containsValue(goog.a11y.aria.State, ariaName),
'No such ARIA attribute ' + ariaName);
}
return goog.a11y.aria.ARIA_PREFIX_ + ariaName;
Expand Down
Loading

0 comments on commit e877b1e

Please sign in to comment.