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

Side by Side Diff: chrome/browser/resources/print_preview/previewarea/preview_area.js

Issue 601083004: Enable a11y audit for chrome://print and fix failing tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @typedef {{accessibility: Function, 6 * @typedef {{accessibility: Function,
7 * documentLoadComplete: Function, 7 * documentLoadComplete: Function,
8 * getHeight: Function, 8 * getHeight: Function,
9 * getHorizontalScrollbarThickness: Function, 9 * getHorizontalScrollbarThickness: Function,
10 * getPageLocationNormalized: Function, 10 * getPageLocationNormalized: Function,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 PreviewArea.Classes_ = { 192 PreviewArea.Classes_ = {
193 COMPATIBILITY_OBJECT: 'preview-area-compatibility-object', 193 COMPATIBILITY_OBJECT: 'preview-area-compatibility-object',
194 OUT_OF_PROCESS_COMPATIBILITY_OBJECT: 194 OUT_OF_PROCESS_COMPATIBILITY_OBJECT:
195 'preview-area-compatibility-object-out-of-process', 195 'preview-area-compatibility-object-out-of-process',
196 CUSTOM_MESSAGE_TEXT: 'preview-area-custom-message-text', 196 CUSTOM_MESSAGE_TEXT: 'preview-area-custom-message-text',
197 MESSAGE: 'preview-area-message', 197 MESSAGE: 'preview-area-message',
198 INVISIBLE: 'invisible', 198 INVISIBLE: 'invisible',
199 OPEN_SYSTEM_DIALOG_BUTTON: 'preview-area-open-system-dialog-button', 199 OPEN_SYSTEM_DIALOG_BUTTON: 'preview-area-open-system-dialog-button',
200 OPEN_SYSTEM_DIALOG_BUTTON_THROBBER: 200 OPEN_SYSTEM_DIALOG_BUTTON_THROBBER:
201 'preview-area-open-system-dialog-button-throbber', 201 'preview-area-open-system-dialog-button-throbber',
202 OVERLAY: 'preview-area-overlay-layer' 202 OVERLAY: 'preview-area-overlay-layer',
203 OVERLAYED: 'preview-area-overlayed',
204 MARGIN_CONTROL: 'margin-control',
205 PREVIEW_AREA: 'preview-area-plugin-wrapper'
203 }; 206 };
204 207
205 /** 208 /**
206 * Enumeration of IDs shown in the preview area. 209 * Enumeration of IDs shown in the preview area.
207 * @enum {string} 210 * @enum {string}
208 * @private 211 * @private
209 */ 212 */
210 PreviewArea.MessageId_ = { 213 PreviewArea.MessageId_ = {
211 CUSTOM: 'custom', 214 CUSTOM: 'custom',
212 LOADING: 'loading', 215 LOADING: 'loading',
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 var customMessageTextEl = this.getElement().getElementsByClassName( 500 var customMessageTextEl = this.getElement().getElementsByClassName(
498 PreviewArea.Classes_.CUSTOM_MESSAGE_TEXT)[0]; 501 PreviewArea.Classes_.CUSTOM_MESSAGE_TEXT)[0];
499 customMessageTextEl.textContent = opt_message; 502 customMessageTextEl.textContent = opt_message;
500 } else if (messageId == PreviewArea.MessageId_.LOADING) { 503 } else if (messageId == PreviewArea.MessageId_.LOADING) {
501 jumpingDotsEl.classList.add('jumping-dots'); 504 jumpingDotsEl.classList.add('jumping-dots');
502 } 505 }
503 var messageEl = this.getElement().getElementsByClassName( 506 var messageEl = this.getElement().getElementsByClassName(
504 PreviewArea.MessageIdClassMap_[messageId])[0]; 507 PreviewArea.MessageIdClassMap_[messageId])[0];
505 setIsVisible(messageEl, true); 508 setIsVisible(messageEl, true);
506 509
507 // Show overlay. 510 this.setOverlayVisible_(true);
508 this.overlayEl_.classList.remove(PreviewArea.Classes_.INVISIBLE);
509 }, 511 },
510 512
511 /** 513 /**
512 * Hides the message overlay. 514 * Set the visibility of the message overlay.
Dan Beam 2014/10/21 01:16:31 @param {boolean} visible Whether to make the overl
hcarmona 2014/10/21 21:32:37 Done.
513 * @private 515 * @private
514 */ 516 */
515 hideOverlay_: function() { 517 setOverlayVisible_: function(visible) {
516 this.overlayEl_.classList.add(PreviewArea.Classes_.INVISIBLE); 518 this.overlayEl_.classList.toggle(
517 // Disable jumping animation to conserve cycles. 519 PreviewArea.Classes_.INVISIBLE,
518 var jumpingDotsEl = this.getElement().querySelector( 520 !visible);
519 '.preview-area-loading-message-jumping-dots'); 521
520 jumpingDotsEl.classList.remove('jumping-dots'); 522 // Hide/show all controls that will overlap when the overlay is visible.
523 var marginControls = this.getElement().getElementsByClassName(
524 PreviewArea.Classes_.MARGIN_CONTROL);
525 for (var i = 0; i < marginControls.length; ++i) {
526 marginControls[i].classList.toggle(
527 PreviewArea.Classes_.OVERLAYED,
528 visible);
Dan Beam 2014/10/21 01:16:31 nit: marginControls[i].classList.toggle(Preview
hcarmona 2014/10/21 21:32:37 Done.
529 }
530 var previewAreaControls = this.getElement().getElementsByClassName(
531 PreviewArea.Classes_.PREVIEW_AREA);
532 for (var i = 0; i < previewAreaControls.length; ++i) {
533 previewAreaControls[i].classList.toggle(
534 PreviewArea.Classes_.OVERLAYED,
535 visible);
536 }
537
538 if (!visible) {
539 // Disable jumping animation to conserve cycles.
540 var jumpingDotsEl = this.getElement().querySelector(
541 '.preview-area-loading-message-jumping-dots');
542 jumpingDotsEl.classList.remove('jumping-dots');
543 }
521 }, 544 },
522 545
523 /** 546 /**
524 * Creates a preview plugin and adds it to the DOM. 547 * Creates a preview plugin and adds it to the DOM.
525 * @param {string} srcUrl Initial URL of the plugin. 548 * @param {string} srcUrl Initial URL of the plugin.
526 * @private 549 * @private
527 */ 550 */
528 createPlugin_: function(srcUrl) { 551 createPlugin_: function(srcUrl) {
529 if (this.plugin_) { 552 if (this.plugin_) {
530 console.warn('Pdf preview plugin already created'); 553 console.warn('Pdf preview plugin already created');
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 this.plugin_.setPageNumbers(JSON.stringify( 730 this.plugin_.setPageNumbers(JSON.stringify(
708 this.printTicketStore_.pageRange.getPageNumberSet().asArray())); 731 this.printTicketStore_.pageRange.getPageNumberSet().asArray()));
709 if (this.zoomLevel_ != null && this.pageOffset_ != null) { 732 if (this.zoomLevel_ != null && this.pageOffset_ != null) {
710 this.plugin_.setZoomLevel(this.zoomLevel_); 733 this.plugin_.setZoomLevel(this.zoomLevel_);
711 this.plugin_.setPageXOffset(this.pageOffset_.x); 734 this.plugin_.setPageXOffset(this.pageOffset_.x);
712 this.plugin_.setPageYOffset(this.pageOffset_.y); 735 this.plugin_.setPageYOffset(this.pageOffset_.y);
713 } else { 736 } else {
714 this.plugin_.fitToHeight(); 737 this.plugin_.fitToHeight();
715 } 738 }
716 } 739 }
717 this.hideOverlay_(); 740 this.setOverlayVisible_(false);
718 this.isPluginReloaded_ = true; 741 this.isPluginReloaded_ = true;
719 this.dispatchPreviewGenerationDoneIfReady_(); 742 this.dispatchPreviewGenerationDoneIfReady_();
720 }, 743 },
721 744
722 /** 745 /**
723 * Called when the preview plugin's visual state has changed. This is a 746 * Called when the preview plugin's visual state has changed. This is a
724 * consequence of scrolling or zooming the plugin. Updates the custom 747 * consequence of scrolling or zooming the plugin. Updates the custom
725 * margins component if shown. 748 * margins component if shown.
726 * @private 749 * @private
727 */ 750 */
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 new print_preview.Size(viewportWidth, viewportHeight)); 794 new print_preview.Size(viewportWidth, viewportHeight));
772 } 795 }
773 } 796 }
774 }; 797 };
775 798
776 // Export 799 // Export
777 return { 800 return {
778 PreviewArea: PreviewArea 801 PreviewArea: PreviewArea
779 }; 802 };
780 }); 803 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698