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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/animation/AnimationModel.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month 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) 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 4
5 5
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @extends {WebInspector.SDKModel} 8 * @extends {WebInspector.SDKModel}
9 * @param {!WebInspector.Target} target 9 * @param {!WebInspector.Target} target
10 */ 10 */
11 WebInspector.AnimationModel = function(target) 11 WebInspector.AnimationModel = function(target)
12 { 12 {
13 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target); 13 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target);
14 this._agent = target.animationAgent(); 14 this._agent = target.animationAgent();
15 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this )); 15 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this ));
16 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */ 16 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */
17 this._animationsById = new Map(); 17 this._animationsById = new Map();
18 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationGroup>} */ 18 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationGroup>} */
19 this._animationGroups = new Map(); 19 this._animationGroups = new Map();
20 /** @type {!Array.<string>} */ 20 /** @type {!Array.<string>} */
21 this._pendingAnimations = []; 21 this._pendingAnimations = [];
22 this._playbackRate = 1; 22 this._playbackRate = 1;
23 var resourceTreeModel = /** @type {!WebInspector.ResourceTreeModel} */ (WebI nspector.ResourceTreeModel.fromTarget(target)); 23 var resourceTreeModel = /** @type {!WebInspector.ResourceTreeModel} */ (WebI nspector.ResourceTreeModel.fromTarget(target));
24 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Mai nFrameNavigated, this._reset, this); 24 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Mai nFrameNavigated, this._reset, this);
25 this._screenshotCapture = new WebInspector.AnimationModel.ScreenshotCapture( target, this, resourceTreeModel); 25 this._screenshotCapture = new WebInspector.AnimationModel.ScreenshotCapture( target, this, resourceTreeModel);
26 } 26 };
27 27
28 /** @enum {symbol} */ 28 /** @enum {symbol} */
29 WebInspector.AnimationModel.Events = { 29 WebInspector.AnimationModel.Events = {
30 AnimationGroupStarted: Symbol("AnimationGroupStarted"), 30 AnimationGroupStarted: Symbol("AnimationGroupStarted"),
31 ModelReset: Symbol("ModelReset") 31 ModelReset: Symbol("ModelReset")
32 } 32 };
33 33
34 WebInspector.AnimationModel.prototype = { 34 WebInspector.AnimationModel.prototype = {
35 _reset: function() 35 _reset: function()
36 { 36 {
37 this._animationsById.clear(); 37 this._animationsById.clear();
38 this._animationGroups.clear(); 38 this._animationGroups.clear();
39 this._pendingAnimations = []; 39 this._pendingAnimations = [];
40 this.dispatchEventToListeners(WebInspector.AnimationModel.Events.ModelRe set); 40 this.dispatchEventToListeners(WebInspector.AnimationModel.Events.ModelRe set);
41 }, 41 },
42 42
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 ensureEnabled: function() 192 ensureEnabled: function()
193 { 193 {
194 if (this._enabled) 194 if (this._enabled)
195 return; 195 return;
196 this._agent.enable(); 196 this._agent.enable();
197 this._enabled = true; 197 this._enabled = true;
198 }, 198 },
199 199
200 __proto__: WebInspector.SDKModel.prototype 200 __proto__: WebInspector.SDKModel.prototype
201 } 201 };
202 202
203 WebInspector.AnimationModel._symbol = Symbol("AnimationModel"); 203 WebInspector.AnimationModel._symbol = Symbol("AnimationModel");
204 204
205 /** 205 /**
206 * @param {!WebInspector.Target} target 206 * @param {!WebInspector.Target} target
207 * @return {?WebInspector.AnimationModel} 207 * @return {?WebInspector.AnimationModel}
208 */ 208 */
209 WebInspector.AnimationModel.fromTarget = function(target) 209 WebInspector.AnimationModel.fromTarget = function(target)
210 { 210 {
211 if (!target.hasDOMCapability()) 211 if (!target.hasDOMCapability())
212 return null; 212 return null;
213 if (!target[WebInspector.AnimationModel._symbol]) 213 if (!target[WebInspector.AnimationModel._symbol])
214 target[WebInspector.AnimationModel._symbol] = new WebInspector.Animation Model(target); 214 target[WebInspector.AnimationModel._symbol] = new WebInspector.Animation Model(target);
215 215
216 return target[WebInspector.AnimationModel._symbol]; 216 return target[WebInspector.AnimationModel._symbol];
217 } 217 };
218 218
219 /** 219 /**
220 * @constructor 220 * @constructor
221 * @extends {WebInspector.SDKObject} 221 * @extends {WebInspector.SDKObject}
222 * @param {!WebInspector.Target} target 222 * @param {!WebInspector.Target} target
223 * @param {!AnimationAgent.Animation} payload 223 * @param {!AnimationAgent.Animation} payload
224 */ 224 */
225 WebInspector.AnimationModel.Animation = function(target, payload) 225 WebInspector.AnimationModel.Animation = function(target, payload)
226 { 226 {
227 WebInspector.SDKObject.call(this, target); 227 WebInspector.SDKObject.call(this, target);
228 this._payload = payload; 228 this._payload = payload;
229 this._source = new WebInspector.AnimationModel.AnimationEffect(this.target() , this._payload.source); 229 this._source = new WebInspector.AnimationModel.AnimationEffect(this.target() , this._payload.source);
230 } 230 };
231 231
232 /** 232 /**
233 * @param {!WebInspector.Target} target 233 * @param {!WebInspector.Target} target
234 * @param {!AnimationAgent.Animation} payload 234 * @param {!AnimationAgent.Animation} payload
235 * @return {!WebInspector.AnimationModel.Animation} 235 * @return {!WebInspector.AnimationModel.Animation}
236 */ 236 */
237 WebInspector.AnimationModel.Animation.parsePayload = function(target, payload) 237 WebInspector.AnimationModel.Animation.parsePayload = function(target, payload)
238 { 238 {
239 return new WebInspector.AnimationModel.Animation(target, payload); 239 return new WebInspector.AnimationModel.Animation(target, payload);
240 } 240 };
241 241
242 /** @enum {string} */ 242 /** @enum {string} */
243 WebInspector.AnimationModel.Animation.Type = { 243 WebInspector.AnimationModel.Animation.Type = {
244 CSSTransition: "CSSTransition", 244 CSSTransition: "CSSTransition",
245 CSSAnimation: "CSSAnimation", 245 CSSAnimation: "CSSAnimation",
246 WebAnimation: "WebAnimation" 246 WebAnimation: "WebAnimation"
247 } 247 };
248 248
249 WebInspector.AnimationModel.Animation.prototype = { 249 WebInspector.AnimationModel.Animation.prototype = {
250 /** 250 /**
251 * @return {!AnimationAgent.Animation} 251 * @return {!AnimationAgent.Animation}
252 */ 252 */
253 payload: function() 253 payload: function()
254 { 254 {
255 return this._payload; 255 return this._payload;
256 }, 256 },
257 257
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 /** 425 /**
426 * @return {string} 426 * @return {string}
427 */ 427 */
428 _cssId: function() 428 _cssId: function()
429 { 429 {
430 return this._payload.cssId || ""; 430 return this._payload.cssId || "";
431 }, 431 },
432 432
433 __proto__: WebInspector.SDKObject.prototype 433 __proto__: WebInspector.SDKObject.prototype
434 } 434 };
435 435
436 /** 436 /**
437 * @constructor 437 * @constructor
438 * @extends {WebInspector.SDKObject} 438 * @extends {WebInspector.SDKObject}
439 * @param {!WebInspector.Target} target 439 * @param {!WebInspector.Target} target
440 * @param {!AnimationAgent.AnimationEffect} payload 440 * @param {!AnimationAgent.AnimationEffect} payload
441 */ 441 */
442 WebInspector.AnimationModel.AnimationEffect = function(target, payload) 442 WebInspector.AnimationModel.AnimationEffect = function(target, payload)
443 { 443 {
444 WebInspector.SDKObject.call(this, target); 444 WebInspector.SDKObject.call(this, target);
445 this._payload = payload; 445 this._payload = payload;
446 if (payload.keyframesRule) 446 if (payload.keyframesRule)
447 this._keyframesRule = new WebInspector.AnimationModel.KeyframesRule(targ et, payload.keyframesRule); 447 this._keyframesRule = new WebInspector.AnimationModel.KeyframesRule(targ et, payload.keyframesRule);
448 this._delay = this._payload.delay; 448 this._delay = this._payload.delay;
449 this._duration = this._payload.duration; 449 this._duration = this._payload.duration;
450 } 450 };
451 451
452 WebInspector.AnimationModel.AnimationEffect.prototype = { 452 WebInspector.AnimationModel.AnimationEffect.prototype = {
453 /** 453 /**
454 * @return {number} 454 * @return {number}
455 */ 455 */
456 delay: function() 456 delay: function()
457 { 457 {
458 return this._delay; 458 return this._delay;
459 }, 459 },
460 460
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 545
546 /** 546 /**
547 * @return {string} 547 * @return {string}
548 */ 548 */
549 easing: function() 549 easing: function()
550 { 550 {
551 return this._payload.easing; 551 return this._payload.easing;
552 }, 552 },
553 553
554 __proto__: WebInspector.SDKObject.prototype 554 __proto__: WebInspector.SDKObject.prototype
555 } 555 };
556 556
557 /** 557 /**
558 * @constructor 558 * @constructor
559 * @extends {WebInspector.SDKObject} 559 * @extends {WebInspector.SDKObject}
560 * @param {!WebInspector.Target} target 560 * @param {!WebInspector.Target} target
561 * @param {!AnimationAgent.KeyframesRule} payload 561 * @param {!AnimationAgent.KeyframesRule} payload
562 */ 562 */
563 WebInspector.AnimationModel.KeyframesRule = function(target, payload) 563 WebInspector.AnimationModel.KeyframesRule = function(target, payload)
564 { 564 {
565 WebInspector.SDKObject.call(this, target); 565 WebInspector.SDKObject.call(this, target);
566 this._payload = payload; 566 this._payload = payload;
567 this._keyframes = this._payload.keyframes.map(function(keyframeStyle) { 567 this._keyframes = this._payload.keyframes.map(function(keyframeStyle) {
568 return new WebInspector.AnimationModel.KeyframeStyle(target, keyframeSty le); 568 return new WebInspector.AnimationModel.KeyframeStyle(target, keyframeSty le);
569 }); 569 });
570 } 570 };
571 571
572 WebInspector.AnimationModel.KeyframesRule.prototype = { 572 WebInspector.AnimationModel.KeyframesRule.prototype = {
573 /** 573 /**
574 * @param {!Array.<!AnimationAgent.KeyframeStyle>} payload 574 * @param {!Array.<!AnimationAgent.KeyframeStyle>} payload
575 */ 575 */
576 _setKeyframesPayload: function(payload) 576 _setKeyframesPayload: function(payload)
577 { 577 {
578 this._keyframes = payload.map(function(keyframeStyle) { 578 this._keyframes = payload.map(function(keyframeStyle) {
579 return new WebInspector.AnimationModel.KeyframeStyle(this._target, k eyframeStyle); 579 return new WebInspector.AnimationModel.KeyframeStyle(this._target, k eyframeStyle);
580 }); 580 });
581 }, 581 },
582 582
583 /** 583 /**
584 * @return {string|undefined} 584 * @return {string|undefined}
585 */ 585 */
586 name: function() 586 name: function()
587 { 587 {
588 return this._payload.name; 588 return this._payload.name;
589 }, 589 },
590 590
591 /** 591 /**
592 * @return {!Array.<!WebInspector.AnimationModel.KeyframeStyle>} 592 * @return {!Array.<!WebInspector.AnimationModel.KeyframeStyle>}
593 */ 593 */
594 keyframes: function() 594 keyframes: function()
595 { 595 {
596 return this._keyframes; 596 return this._keyframes;
597 }, 597 },
598 598
599 __proto__: WebInspector.SDKObject.prototype 599 __proto__: WebInspector.SDKObject.prototype
600 } 600 };
601 601
602 /** 602 /**
603 * @constructor 603 * @constructor
604 * @extends {WebInspector.SDKObject} 604 * @extends {WebInspector.SDKObject}
605 * @param {!WebInspector.Target} target 605 * @param {!WebInspector.Target} target
606 * @param {!AnimationAgent.KeyframeStyle} payload 606 * @param {!AnimationAgent.KeyframeStyle} payload
607 */ 607 */
608 WebInspector.AnimationModel.KeyframeStyle = function(target, payload) 608 WebInspector.AnimationModel.KeyframeStyle = function(target, payload)
609 { 609 {
610 WebInspector.SDKObject.call(this, target); 610 WebInspector.SDKObject.call(this, target);
611 this._payload = payload; 611 this._payload = payload;
612 this._offset = this._payload.offset; 612 this._offset = this._payload.offset;
613 } 613 };
614 614
615 WebInspector.AnimationModel.KeyframeStyle.prototype = { 615 WebInspector.AnimationModel.KeyframeStyle.prototype = {
616 /** 616 /**
617 * @return {string} 617 * @return {string}
618 */ 618 */
619 offset: function() 619 offset: function()
620 { 620 {
621 return this._offset; 621 return this._offset;
622 }, 622 },
623 623
(...skipping 15 matching lines...) Expand all
639 639
640 /** 640 /**
641 * @return {string} 641 * @return {string}
642 */ 642 */
643 easing: function() 643 easing: function()
644 { 644 {
645 return this._payload.easing; 645 return this._payload.easing;
646 }, 646 },
647 647
648 __proto__: WebInspector.SDKObject.prototype 648 __proto__: WebInspector.SDKObject.prototype
649 } 649 };
650 650
651 /** 651 /**
652 * @constructor 652 * @constructor
653 * @extends {WebInspector.SDKObject} 653 * @extends {WebInspector.SDKObject}
654 * @param {!WebInspector.AnimationModel} model 654 * @param {!WebInspector.AnimationModel} model
655 * @param {string} id 655 * @param {string} id
656 * @param {!Array.<!WebInspector.AnimationModel.Animation>} animations 656 * @param {!Array.<!WebInspector.AnimationModel.Animation>} animations
657 */ 657 */
658 WebInspector.AnimationModel.AnimationGroup = function(model, id, animations) 658 WebInspector.AnimationModel.AnimationGroup = function(model, id, animations)
659 { 659 {
660 WebInspector.SDKObject.call(this, model.target()); 660 WebInspector.SDKObject.call(this, model.target());
661 this._model = model; 661 this._model = model;
662 this._id = id; 662 this._id = id;
663 this._animations = animations; 663 this._animations = animations;
664 this._paused = false; 664 this._paused = false;
665 this._screenshots = []; 665 this._screenshots = [];
666 this._screenshotImages = []; 666 this._screenshotImages = [];
667 } 667 };
668 668
669 WebInspector.AnimationModel.AnimationGroup.prototype = { 669 WebInspector.AnimationModel.AnimationGroup.prototype = {
670 /** 670 /**
671 * @return {string} 671 * @return {string}
672 */ 672 */
673 id: function() 673 id: function()
674 { 674 {
675 return this._id; 675 return this._id;
676 }, 676 },
677 677
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 for (var i = 0; i < this._screenshots.length; ++i) { 821 for (var i = 0; i < this._screenshots.length; ++i) {
822 var image = new Image(); 822 var image = new Image();
823 image.src = "data:image/jpeg;base64," + this._screenshots[i]; 823 image.src = "data:image/jpeg;base64," + this._screenshots[i];
824 this._screenshotImages.push(image); 824 this._screenshotImages.push(image);
825 } 825 }
826 this._screenshots = []; 826 this._screenshots = [];
827 return this._screenshotImages; 827 return this._screenshotImages;
828 }, 828 },
829 829
830 __proto__: WebInspector.SDKObject.prototype 830 __proto__: WebInspector.SDKObject.prototype
831 } 831 };
832 832
833 833
834 /** 834 /**
835 * @constructor 835 * @constructor
836 * @implements {AnimationAgent.Dispatcher} 836 * @implements {AnimationAgent.Dispatcher}
837 */ 837 */
838 WebInspector.AnimationDispatcher = function(animationModel) 838 WebInspector.AnimationDispatcher = function(animationModel)
839 { 839 {
840 this._animationModel = animationModel; 840 this._animationModel = animationModel;
841 } 841 };
842 842
843 WebInspector.AnimationDispatcher.prototype = { 843 WebInspector.AnimationDispatcher.prototype = {
844 /** 844 /**
845 * @override 845 * @override
846 * @param {string} id 846 * @param {string} id
847 */ 847 */
848 animationCreated: function(id) 848 animationCreated: function(id)
849 { 849 {
850 this._animationModel.animationCreated(id); 850 this._animationModel.animationCreated(id);
851 }, 851 },
852 852
853 /** 853 /**
854 * @override 854 * @override
855 * @param {string} id 855 * @param {string} id
856 */ 856 */
857 animationCanceled: function(id) 857 animationCanceled: function(id)
858 { 858 {
859 this._animationModel._animationCanceled(id); 859 this._animationModel._animationCanceled(id);
860 }, 860 },
861 861
862 /** 862 /**
863 * @override 863 * @override
864 * @param {!AnimationAgent.Animation} payload 864 * @param {!AnimationAgent.Animation} payload
865 */ 865 */
866 animationStarted: function(payload) 866 animationStarted: function(payload)
867 { 867 {
868 this._animationModel.animationStarted(payload); 868 this._animationModel.animationStarted(payload);
869 } 869 }
870 } 870 };
871 871
872 /** 872 /**
873 * @constructor 873 * @constructor
874 * @param {!WebInspector.Target} target 874 * @param {!WebInspector.Target} target
875 * @param {!WebInspector.AnimationModel} model 875 * @param {!WebInspector.AnimationModel} model
876 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel 876 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel
877 */ 877 */
878 WebInspector.AnimationModel.ScreenshotCapture = function(target, model, resource TreeModel) 878 WebInspector.AnimationModel.ScreenshotCapture = function(target, model, resource TreeModel)
879 { 879 {
880 this._target = target; 880 this._target = target;
881 /** @type {!Array<!WebInspector.AnimationModel.ScreenshotCapture.Request>} * / 881 /** @type {!Array<!WebInspector.AnimationModel.ScreenshotCapture.Request>} * /
882 this._requests = []; 882 this._requests = [];
883 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Scr eencastFrame, this._screencastFrame, this); 883 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Scr eencastFrame, this._screencastFrame, this);
884 this._model = model; 884 this._model = model;
885 this._model.addEventListener(WebInspector.AnimationModel.Events.ModelReset, this._stopScreencast, this); 885 this._model.addEventListener(WebInspector.AnimationModel.Events.ModelReset, this._stopScreencast, this);
886 } 886 };
887 887
888 /** @typedef {{ endTime: number, screenshots: !Array.<string>}} */ 888 /** @typedef {{ endTime: number, screenshots: !Array.<string>}} */
889 WebInspector.AnimationModel.ScreenshotCapture.Request; 889 WebInspector.AnimationModel.ScreenshotCapture.Request;
890 890
891 WebInspector.AnimationModel.ScreenshotCapture.prototype = { 891 WebInspector.AnimationModel.ScreenshotCapture.prototype = {
892 /** 892 /**
893 * @param {number} duration 893 * @param {number} duration
894 * @param {!Array<string>} screenshots 894 * @param {!Array<string>} screenshots
895 */ 895 */
896 captureScreenshots: function(duration, screenshots) 896 captureScreenshots: function(duration, screenshots)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 { 939 {
940 if (!this._capturing) 940 if (!this._capturing)
941 return; 941 return;
942 942
943 delete this._stopTimer; 943 delete this._stopTimer;
944 delete this._endTime; 944 delete this._endTime;
945 this._requests = []; 945 this._requests = [];
946 this._capturing = false; 946 this._capturing = false;
947 this._target.pageAgent().stopScreencast(); 947 this._target.pageAgent().stopScreencast();
948 } 948 }
949 } 949 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698