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

Side by Side Diff: chrome/browser/resources/ntp4/tile_page.js

Issue 10092017: Mac: Prevent NTP mousewheel events from being suppressed on Lion. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Whoops - send message to class, not metaclass. Created 8 years, 8 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 cr.define('ntp', function() { 5 cr.define('ntp', function() {
6 'use strict'; 6 'use strict';
7 7
8 // We can't pass the currently dragging tile via dataTransfer because of 8 // We can't pass the currently dragging tile via dataTransfer because of
9 // http://crbug.com/31037 9 // http://crbug.com/31037
10 var currentlyDraggingTile = null; 10 var currentlyDraggingTile = null;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 grid.tileSpacingFraction); 392 grid.tileSpacingFraction);
393 // Tile-related pixel values for the minimum narrow display. 393 // Tile-related pixel values for the minimum narrow display.
394 grid.wideTileValues = tileValuesForGrid(grid.minWideWidth, 394 grid.wideTileValues = tileValuesForGrid(grid.minWideWidth,
395 grid.maxColCount, 395 grid.maxColCount,
396 grid.tileSpacingFraction); 396 grid.tileSpacingFraction);
397 }; 397 };
398 398
399 TilePage.prototype = { 399 TilePage.prototype = {
400 __proto__: HTMLDivElement.prototype, 400 __proto__: HTMLDivElement.prototype,
401 401
402 initialize: function() { 402 initialize: function(ignoreMouseWheelEvents) {
403 this.className = 'tile-page'; 403 this.className = 'tile-page';
404 404
405 // Div that acts as a custom scrollbar. The scrollbar has to live 405 // Div that acts as a custom scrollbar. The scrollbar has to live
406 // outside the content div so it doesn't flicker when scrolling (due to 406 // outside the content div so it doesn't flicker when scrolling (due to
407 // repainting after the scroll, then repainting again when moved in the 407 // repainting after the scroll, then repainting again when moved in the
408 // onScroll handler). |scrollbar_| is only aesthetic, and it only 408 // onScroll handler). |scrollbar_| is only aesthetic, and it only
409 // represents the thumb. Actual events are still handled by the invisible 409 // represents the thumb. Actual events are still handled by the invisible
410 // native scrollbars. This div gives us more flexibility with the visuals. 410 // native scrollbars. This div gives us more flexibility with the visuals.
411 this.scrollbar_ = this.ownerDocument.createElement('div'); 411 this.scrollbar_ = this.ownerDocument.createElement('div');
412 this.scrollbar_.className = 'tile-page-scrollbar'; 412 this.scrollbar_.className = 'tile-page-scrollbar';
(...skipping 28 matching lines...) Expand all
441 // These are properties used in updateTopMargin. 441 // These are properties used in updateTopMargin.
442 this.animatedTopMarginPx_ = 0; 442 this.animatedTopMarginPx_ = 0;
443 this.topMarginPx_ = 0; 443 this.topMarginPx_ = 0;
444 444
445 this.eventTracker = new EventTracker(); 445 this.eventTracker = new EventTracker();
446 this.eventTracker.add(window, 'resize', this.onResize_.bind(this)); 446 this.eventTracker.add(window, 'resize', this.onResize_.bind(this));
447 447
448 this.addEventListener('DOMNodeInsertedIntoDocument', 448 this.addEventListener('DOMNodeInsertedIntoDocument',
449 this.onNodeInsertedIntoDocument_); 449 this.onNodeInsertedIntoDocument_);
450 450
451 this.addEventListener('mousewheel', this.onMouseWheel_);
452 this.content_.addEventListener('scroll', this.onScroll_.bind(this)); 451 this.content_.addEventListener('scroll', this.onScroll_.bind(this));
453 452
454 this.dragWrapper_ = new cr.ui.DragWrapper(this.tileGrid_, this); 453 this.dragWrapper_ = new cr.ui.DragWrapper(this.tileGrid_, this);
455 454
456 this.addEventListener('cardselected', this.handleCardSelection_); 455 this.addEventListener('cardselected', this.handleCardSelection_);
457 this.addEventListener('carddeselected', this.handleCardDeselection_); 456 this.addEventListener('carddeselected', this.handleCardDeselection_);
458 this.addEventListener('focus', this.handleFocus_); 457 this.addEventListener('focus', this.handleFocus_);
459 this.addEventListener('keydown', this.handleKeyDown_); 458 this.addEventListener('keydown', this.handleKeyDown_);
460 this.addEventListener('mousedown', this.handleMouseDown_); 459 this.addEventListener('mousedown', this.handleMouseDown_);
461 460
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 * Places an element at the bottom of the content div. Used in bare-minimum 1045 * Places an element at the bottom of the content div. Used in bare-minimum
1047 * mode to hold #footer. 1046 * mode to hold #footer.
1048 * @param {HTMLElement} footerNode The node to append to content. 1047 * @param {HTMLElement} footerNode The node to append to content.
1049 */ 1048 */
1050 appendFooter: function(footerNode) { 1049 appendFooter: function(footerNode) {
1051 this.footerNode_ = footerNode; 1050 this.footerNode_ = footerNode;
1052 this.content_.appendChild(footerNode); 1051 this.content_.appendChild(footerNode);
1053 }, 1052 },
1054 1053
1055 /** 1054 /**
1056 * Scrolls the page in response to a mousewheel event.
1057 * @param {Event} e The mousewheel event.
1058 */
1059 handleMouseWheel: function(e) {
1060 this.content_.scrollTop -= e.wheelDeltaY / 3;
1061 },
1062
1063 /**
1064 * Handles mouse wheels on |this|. We handle this explicitly because we want
1065 * a consistent experience whether the user scrolls on the page or on the
1066 * page switcher (handleMouseWheel provides a common conversion factor
1067 * between wheel delta and scroll delta).
1068 * @param {Event} e The mousewheel event.
1069 * @private
1070 */
1071 onMouseWheel_: function(e) {
1072 if (e.wheelDeltaY == 0)
1073 return;
1074
1075 this.handleMouseWheel(e);
1076 e.preventDefault();
1077 e.stopPropagation();
1078 },
1079
1080 /**
1081 * Handler for the 'scroll' event on |content_|. 1055 * Handler for the 'scroll' event on |content_|.
1082 * @param {Event} e The scroll event. 1056 * @param {Event} e The scroll event.
1083 * @private 1057 * @private
1084 */ 1058 */
1085 onScroll_: function(e) { 1059 onScroll_: function(e) {
1086 this.queueUpdateScrollbars_(); 1060 this.queueUpdateScrollbars_();
1087 }, 1061 },
1088 1062
1089 /** 1063 /**
1090 * ID of scrollbar update timer. If 0, there's no scrollbar re-calc queued. 1064 * ID of scrollbar update timer. If 0, there's no scrollbar re-calc queued.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 assert(false); 1307 assert(false);
1334 }, 1308 },
1335 }; 1309 };
1336 1310
1337 return { 1311 return {
1338 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1312 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1339 setCurrentDropEffect: setCurrentDropEffect, 1313 setCurrentDropEffect: setCurrentDropEffect,
1340 TilePage: TilePage, 1314 TilePage: TilePage,
1341 }; 1315 };
1342 }); 1316 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698