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

Side by Side Diff: components/neterror/resources/offline.js

Issue 2144933002: Fix the T-Rex easter egg on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 | ios/web/web_state/web_view_internal_creation_util.mm » ('j') | 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 (function() { 4 (function() {
5 'use strict'; 5 'use strict';
6 /** 6 /**
7 * T-Rex runner. 7 * T-Rex runner.
8 * @param {string} outerContainerId Outer containing element id. 8 * @param {string} outerContainerId Outer containing element id.
9 * @param {Object} opt_config 9 * @param {Object} opt_config
10 * @constructor 10 * @constructor
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 */ 285 */
286 loadImages: function() { 286 loadImages: function() {
287 if (IS_HIDPI) { 287 if (IS_HIDPI) {
288 Runner.imageSprite = document.getElementById('offline-resources-2x'); 288 Runner.imageSprite = document.getElementById('offline-resources-2x');
289 this.spriteDef = Runner.spriteDefinition.HDPI; 289 this.spriteDef = Runner.spriteDefinition.HDPI;
290 } else { 290 } else {
291 Runner.imageSprite = document.getElementById('offline-resources-1x'); 291 Runner.imageSprite = document.getElementById('offline-resources-1x');
292 this.spriteDef = Runner.spriteDefinition.LDPI; 292 this.spriteDef = Runner.spriteDefinition.LDPI;
293 } 293 }
294 294
295 this.init(); 295 if (!Runner.imageSprite.complete) {
edwardjung 2016/07/18 10:37:11 Do a positive check for the 'complete' property.
kkhorimoto 2016/07/20 01:18:29 Done.
296 // If the images are not yet loaded, add a listener.
297 Runner.imageSprite.runner = this;
298
299 Runner.imageSprite.onload = function() {
300 this.runner.init();
301 }
edwardjung 2016/07/18 10:37:11 I would use the addEventListener style of attachin
kkhorimoto 2016/07/20 01:18:29 Done.
302 } else {
303 this.init();
304 }
296 }, 305 },
297 306
298 /** 307 /**
299 * Load and decode base 64 encoded sounds. 308 * Load and decode base 64 encoded sounds.
300 */ 309 */
301 loadSounds: function() { 310 loadSounds: function() {
302 if (!IS_IOS) { 311 if (!IS_IOS) {
303 this.audioContext = new AudioContext(); 312 this.audioContext = new AudioContext();
304 313
305 var resourceTemplate = 314 var resourceTemplate =
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 if (IS_MOBILE && this.activated) { 662 if (IS_MOBILE && this.activated) {
654 e.preventDefault(); 663 e.preventDefault();
655 } 664 }
656 665
657 if (e.target != this.detailsButton) { 666 if (e.target != this.detailsButton) {
658 if (!this.crashed && (Runner.keycodes.JUMP[e.keyCode] || 667 if (!this.crashed && (Runner.keycodes.JUMP[e.keyCode] ||
659 e.type == Runner.events.TOUCHSTART)) { 668 e.type == Runner.events.TOUCHSTART)) {
660 if (!this.activated) { 669 if (!this.activated) {
661 this.loadSounds(); 670 this.loadSounds();
662 this.activated = true; 671 this.activated = true;
663 errorPageController.trackEasterEgg(); 672 if (errorPageController) {
673 errorPageController.trackEasterEgg();
674 }
edwardjung 2016/07/18 10:37:11 Will there ever be an instance where errorPageCont
kkhorimoto 2016/07/20 01:18:29 errorPageController is consistently nil on iOS. S
edwardjung 2016/07/20 21:37:57 errorPageController is exposed from NetErrorPageCo
664 } 675 }
665 676
666 if (!this.tRex.jumping && !this.tRex.ducking) { 677 if (!this.tRex.jumping && !this.tRex.ducking) {
667 this.playSound(this.soundFx.BUTTON_PRESS); 678 this.playSound(this.soundFx.BUTTON_PRESS);
668 this.tRex.startJump(this.currentSpeed); 679 this.tRex.startJump(this.currentSpeed);
669 } 680 }
670 } 681 }
671 682
672 if (this.crashed && e.type == Runner.events.TOUCHSTART && 683 if (this.crashed && e.type == Runner.events.TOUCHSTART &&
673 e.currentTarget == this.containerEl) { 684 e.currentTarget == this.containerEl) {
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 2691
2681 /** 2692 /**
2682 * Add a new cloud to the horizon. 2693 * Add a new cloud to the horizon.
2683 */ 2694 */
2684 addCloud: function() { 2695 addCloud: function() {
2685 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD, 2696 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD,
2686 this.dimensions.WIDTH)); 2697 this.dimensions.WIDTH));
2687 } 2698 }
2688 }; 2699 };
2689 })(); 2700 })();
OLDNEW
« no previous file with comments | « no previous file | ios/web/web_state/web_view_internal_creation_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698