Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: Source/web/resources/calendarPicker.js

Issue 564053002: AX: Calendar Picker: Apply aria-activedescendant to YearListView. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix the test for Windows Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/forms/calendar-picker/date-picker-ax-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 "use strict"; 1 "use strict";
2 /* 2 /*
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 ScrollView.prototype.contentPositionForContentOffset = function(offset) { 1553 ScrollView.prototype.contentPositionForContentOffset = function(offset) {
1554 return offset - this._partitionNumber * ScrollView.PartitionHeight; 1554 return offset - this._partitionNumber * ScrollView.PartitionHeight;
1555 }; 1555 };
1556 1556
1557 /** 1557 /**
1558 * @constructor 1558 * @constructor
1559 * @extends View 1559 * @extends View
1560 */ 1560 */
1561 function ListCell() { 1561 function ListCell() {
1562 View.call(this, createElement("div", ListCell.ClassNameListCell)); 1562 View.call(this, createElement("div", ListCell.ClassNameListCell));
1563 this.element.setAttribute("role", "gridcell");
1564 1563
1565 /** 1564 /**
1566 * @type {!number} 1565 * @type {!number}
1567 */ 1566 */
1568 this.row = NaN; 1567 this.row = NaN;
1569 /** 1568 /**
1570 * @type {!number} 1569 * @type {!number}
1571 */ 1570 */
1572 this._width = 0; 1571 this._width = 0;
1573 /** 1572 /**
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 this.label.style.lineHeight = (YearListCell.Height - YearListCell.BorderBott omWidth) + "px"; 2136 this.label.style.lineHeight = (YearListCell.Height - YearListCell.BorderBott omWidth) + "px";
2138 2137
2139 /** 2138 /**
2140 * @type {!Array} Array of the 12 month button elements. 2139 * @type {!Array} Array of the 12 month button elements.
2141 * @const 2140 * @const
2142 */ 2141 */
2143 this.monthButtons = []; 2142 this.monthButtons = [];
2144 var monthChooserElement = createElement("div", YearListCell.ClassNameMonthCh ooser); 2143 var monthChooserElement = createElement("div", YearListCell.ClassNameMonthCh ooser);
2145 for (var r = 0; r < YearListCell.ButtonRows; ++r) { 2144 for (var r = 0; r < YearListCell.ButtonRows; ++r) {
2146 var buttonsRow = createElement("div", YearListCell.ClassNameMonthButtons Row); 2145 var buttonsRow = createElement("div", YearListCell.ClassNameMonthButtons Row);
2146 buttonsRow.setAttribute("role", "row");
2147 for (var c = 0; c < YearListCell.ButtonColumns; ++c) { 2147 for (var c = 0; c < YearListCell.ButtonColumns; ++c) {
2148 var month = c + r * YearListCell.ButtonColumns; 2148 var month = c + r * YearListCell.ButtonColumns;
2149 var button = createElement("div", YearListCell.ClassNameMonthButton, shortMonthLabels[month]); 2149 var button = createElement("div", YearListCell.ClassNameMonthButton, shortMonthLabels[month]);
2150 button.setAttribute("role", "gridcell");
2150 button.dataset.month = month; 2151 button.dataset.month = month;
2151 buttonsRow.appendChild(button); 2152 buttonsRow.appendChild(button);
2152 this.monthButtons.push(button); 2153 this.monthButtons.push(button);
2153 } 2154 }
2154 monthChooserElement.appendChild(buttonsRow); 2155 monthChooserElement.appendChild(buttonsRow);
2155 } 2156 }
2156 this.element.appendChild(monthChooserElement); 2157 this.element.appendChild(monthChooserElement);
2157 2158
2158 /** 2159 /**
2159 * @type {!boolean} 2160 * @type {!boolean}
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 2469
2469 /** 2470 /**
2470 * @param {!number} row 2471 * @param {!number} row
2471 * @return {!YearListCell} 2472 * @return {!YearListCell}
2472 * @override 2473 * @override
2473 */ 2474 */
2474 YearListView.prototype.prepareNewCell = function(row) { 2475 YearListView.prototype.prepareNewCell = function(row) {
2475 var cell = YearListCell._recycleBin.pop() || new YearListCell(global.params. shortMonthLabels); 2476 var cell = YearListCell._recycleBin.pop() || new YearListCell(global.params. shortMonthLabels);
2476 cell.reset(row); 2477 cell.reset(row);
2477 cell.setSelected(this.selectedRow === row); 2478 cell.setSelected(this.selectedRow === row);
2478 if (this.highlightedMonth && row === this.highlightedMonth.year - 1) {
2479 cell.monthButtons[this.highlightedMonth.month].classList.add(YearListCel l.ClassNameHighlighted);
2480 }
2481 for (var i = 0; i < cell.monthButtons.length; ++i) { 2479 for (var i = 0; i < cell.monthButtons.length; ++i) {
2482 var month = new Month(row + 1, i); 2480 var month = new Month(row + 1, i);
2481 cell.monthButtons[i].id = month.toString();
2483 cell.monthButtons[i].setAttribute("aria-disabled", this._minimumMonth > month || this._maximumMonth < month ? "true" : "false"); 2482 cell.monthButtons[i].setAttribute("aria-disabled", this._minimumMonth > month || this._maximumMonth < month ? "true" : "false");
2483 cell.monthButtons[i].setAttribute("aria-label", month.toLocaleString());
2484 }
2485 if (this.highlightedMonth && row === this.highlightedMonth.year - 1) {
2486 var monthButton = cell.monthButtons[this.highlightedMonth.month];
2487 monthButton.classList.add(YearListCell.ClassNameHighlighted);
2488 // aira-activedescendant assumes both elements have renderers, and
2489 // |monthButton| might have no renderer yet.
2490 var element = this.element;
2491 setTimeout(function() {
2492 element.setAttribute("aria-activedescendant", monthButton.id);
2493 }, 0);
2484 } 2494 }
2485 var animator = this._runningAnimators[row]; 2495 var animator = this._runningAnimators[row];
2486 if (animator) 2496 if (animator)
2487 cell.setHeight(animator.currentValue); 2497 cell.setHeight(animator.currentValue);
2488 else if (row === this.selectedRow) 2498 else if (row === this.selectedRow)
2489 cell.setHeight(YearListCell.SelectedHeight); 2499 cell.setHeight(YearListCell.SelectedHeight);
2490 else 2500 else
2491 cell.setHeight(YearListCell.Height); 2501 cell.setHeight(YearListCell.Height);
2492 return cell; 2502 return cell;
2493 }; 2503 };
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 }; 2609 };
2600 2610
2601 YearListView.prototype.dehighlightMonth = function() { 2611 YearListView.prototype.dehighlightMonth = function() {
2602 if (!this.highlightedMonth) 2612 if (!this.highlightedMonth)
2603 return; 2613 return;
2604 var monthButton = this.buttonForMonth(this.highlightedMonth); 2614 var monthButton = this.buttonForMonth(this.highlightedMonth);
2605 if (monthButton) { 2615 if (monthButton) {
2606 monthButton.classList.remove(YearListCell.ClassNameHighlighted); 2616 monthButton.classList.remove(YearListCell.ClassNameHighlighted);
2607 } 2617 }
2608 this.highlightedMonth = null; 2618 this.highlightedMonth = null;
2619 this.element.removeAttribute("aria-activedescendant");
2609 }; 2620 };
2610 2621
2611 /** 2622 /**
2612 * @param {!Month} month 2623 * @param {!Month} month
2613 */ 2624 */
2614 YearListView.prototype.highlightMonth = function(month) { 2625 YearListView.prototype.highlightMonth = function(month) {
2615 if (this.highlightedMonth && this.highlightedMonth.equals(month)) 2626 if (this.highlightedMonth && this.highlightedMonth.equals(month))
2616 return; 2627 return;
2617 this.dehighlightMonth(); 2628 this.dehighlightMonth();
2618 this.highlightedMonth = month; 2629 this.highlightedMonth = month;
2619 if (!this.highlightedMonth) 2630 if (!this.highlightedMonth)
2620 return; 2631 return;
2621 var monthButton = this.buttonForMonth(this.highlightedMonth); 2632 var monthButton = this.buttonForMonth(this.highlightedMonth);
2622 if (monthButton) { 2633 if (monthButton) {
2623 monthButton.classList.add(YearListCell.ClassNameHighlighted); 2634 monthButton.classList.add(YearListCell.ClassNameHighlighted);
2635 this.element.setAttribute("aria-activedescendant", monthButton.id);
2624 } 2636 }
2625 }; 2637 };
2626 2638
2627 /** 2639 /**
2628 * @param {!Month} month 2640 * @param {!Month} month
2629 */ 2641 */
2630 YearListView.prototype.show = function(month) { 2642 YearListView.prototype.show = function(month) {
2631 this._ignoreMouseOutUntillNextMouseOver = true; 2643 this._ignoreMouseOutUntillNextMouseOver = true;
2632 2644
2633 this.scrollToRow(month.year - 1, false); 2645 this.scrollToRow(month.year - 1, false);
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 /** 3037 /**
3026 * @constructor 3038 * @constructor
3027 * @extends ListCell 3039 * @extends ListCell
3028 */ 3040 */
3029 function DayCell() { 3041 function DayCell() {
3030 ListCell.call(this); 3042 ListCell.call(this);
3031 this.element.classList.add(DayCell.ClassNameDayCell); 3043 this.element.classList.add(DayCell.ClassNameDayCell);
3032 this.element.style.width = DayCell.Width + "px"; 3044 this.element.style.width = DayCell.Width + "px";
3033 this.element.style.height = DayCell.Height + "px"; 3045 this.element.style.height = DayCell.Height + "px";
3034 this.element.style.lineHeight = (DayCell.Height - DayCell.PaddingSize * 2) + "px"; 3046 this.element.style.lineHeight = (DayCell.Height - DayCell.PaddingSize * 2) + "px";
3047 this.element.setAttribute("role", "gridcell");
3035 /** 3048 /**
3036 * @type {?Day} 3049 * @type {?Day}
3037 */ 3050 */
3038 this.day = null; 3051 this.day = null;
3039 }; 3052 };
3040 3053
3041 DayCell.prototype = Object.create(ListCell.prototype); 3054 DayCell.prototype = Object.create(ListCell.prototype);
3042 3055
3043 DayCell.Width = 34; 3056 DayCell.Width = 34;
3044 DayCell.Height = hasInaccuratePointingDevice() ? 34 : 20; 3057 DayCell.Height = hasInaccuratePointingDevice() ? 34 : 20;
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
4066 event.stopPropagation(); 4079 event.stopPropagation();
4067 event.preventDefault(); 4080 event.preventDefault();
4068 } 4081 }
4069 }; 4082 };
4070 4083
4071 if (window.dialogArguments) { 4084 if (window.dialogArguments) {
4072 initialize(dialogArguments); 4085 initialize(dialogArguments);
4073 } else { 4086 } else {
4074 window.addEventListener("message", handleMessage, false); 4087 window.addEventListener("message", handleMessage, false);
4075 } 4088 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/calendar-picker/date-picker-ax-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698