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

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

Issue 1954763003: Merge "print_preview: Workaround of focus-scroll issue." to M51 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | 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 // 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 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Draggable control for setting a page margin. 9 * Draggable control for setting a page margin.
10 * @param {!print_preview.ticket_items.CustomMargins.Orientation} orientation 10 * @param {!print_preview.ticket_items.CustomMargins.Orientation} orientation
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 this.textbox_ = null; 342 this.textbox_ = null;
343 this.marginLineEl_ = null; 343 this.marginLineEl_ = null;
344 }, 344 },
345 345
346 /** 346 /**
347 * @param {boolean} isFocused Whether the margin control is in focus. 347 * @param {boolean} isFocused Whether the margin control is in focus.
348 * @private 348 * @private
349 */ 349 */
350 setIsFocused_: function(isFocused) { 350 setIsFocused_: function(isFocused) {
351 this.isFocused_ = isFocused; 351 this.isFocused_ = isFocused;
352 // TODO(tkent): This is a workaround of a preview-area scrolling
353 // issue. Blink scrolls preview-area on focus, but we don't want it. We
354 // should adjust scroll position of PDF preview and positions of
355 // MarginContgrols here, or restructure the HTML so that the PDF review
356 // and MarginControls are on the single scrollable container.
357 // crbug.com/601341
358 if (isFocused) {
359 var previewArea = $('preview-area');
360 previewArea.scrollTop = 0;
361 previewArea.scrollLeft = 0;
362 }
352 }, 363 },
353 364
354 /** 365 /**
355 * Called whenever a mousedown event occurs on the component. 366 * Called whenever a mousedown event occurs on the component.
356 * @param {MouseEvent} event The event that occured. 367 * @param {MouseEvent} event The event that occured.
357 * @private 368 * @private
358 */ 369 */
359 onMouseDown_: function(event) { 370 onMouseDown_: function(event) {
360 if (!this.textbox_.disabled && 371 if (!this.textbox_.disabled &&
361 event.button == 0 && 372 event.button == 0 &&
362 (event.target == this.getElement() || 373 (event.target == this.getElement() ||
363 event.target == this.marginLineEl_)) { 374 event.target == this.marginLineEl_)) {
364 this.mouseStartPositionInPixels_ = 375 this.mouseStartPositionInPixels_ =
365 new print_preview.Coordinate2d(event.x, event.y); 376 new print_preview.Coordinate2d(event.x, event.y);
366 this.marginStartPositionInPixels_ = new print_preview.Coordinate2d( 377 this.marginStartPositionInPixels_ = new print_preview.Coordinate2d(
367 this.getElement().offsetLeft, this.getElement().offsetTop); 378 this.getElement().offsetLeft, this.getElement().offsetTop);
368 this.setIsInError(false); 379 this.setIsInError(false);
369 cr.dispatchSimpleEvent(this, MarginControl.EventType.DRAG_START); 380 cr.dispatchSimpleEvent(this, MarginControl.EventType.DRAG_START);
370 } 381 }
371 }, 382 },
372 383
373 /** 384 /**
374 * Called when opacity CSS transition ends. 385 * Called when opacity CSS transition ends.
375 * @private 386 * @private
376 */ 387 */
377 onWebkitTransitionEnd_: function(event) { 388 onWebkitTransitionEnd_: function(event) {
378 if (event.propertyName != 'opacity') 389 if (event.propertyName != 'opacity')
379 return; 390 return;
380 var elStyle = window.getComputedStyle(this.getElement()); 391 var elStyle = window.getComputedStyle(this.getElement());
381 var opacity = parseInt(elStyle.getPropertyValue('opacity'), 10); 392 var disabled = parseInt(elStyle.getPropertyValue('opacity'), 10) == 0;
382 this.textbox_.setAttribute('aria-hidden', opacity == 0); 393 this.textbox_.setAttribute('aria-hidden', disabled);
394 this.textbox_.disabled = disabled;
383 }, 395 },
384 396
385 /** 397 /**
386 * Called when textbox content changes. Starts text change timeout. 398 * Called when textbox content changes. Starts text change timeout.
387 * @private 399 * @private
388 */ 400 */
389 onTextboxInput_: function(event) { 401 onTextboxInput_: function(event) {
390 if (this.textTimeout_) { 402 if (this.textTimeout_) {
391 clearTimeout(this.textTimeout_); 403 clearTimeout(this.textTimeout_);
392 this.textTimeout_ = null; 404 this.textTimeout_ = null;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 this.setIsFocused_(false); 444 this.setIsFocused_(false);
433 cr.dispatchSimpleEvent(this, MarginControl.EventType.TEXT_CHANGE); 445 cr.dispatchSimpleEvent(this, MarginControl.EventType.TEXT_CHANGE);
434 } 446 }
435 }; 447 };
436 448
437 // Export 449 // Export
438 return { 450 return {
439 MarginControl: MarginControl 451 MarginControl: MarginControl
440 }; 452 };
441 }); 453 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698