1<!DOCTYPE html> 2<!-- 3Copyright (c) 2015 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/model/location.html"> 9<link rel="import" href="/tracing/model/annotation.html"> 10<link rel="import" href="/tracing/model/rect_annotation.html"> 11<link rel="import" href="/tracing/ui/annotations/comment_box_annotation_view.html"> 12 13<script> 14'use strict'; 15 16tr.exportTo('tr.model', function() { 17 18 function CommentBoxAnnotation(location, text) { 19 tr.model.Annotation.apply(this, arguments); 20 21 this.location = location; 22 this.text = text; 23 } 24 25 CommentBoxAnnotation.fromDict = function(dict) { 26 var args = dict.args; 27 var location = 28 new tr.model.Location(args.location.xWorld, args.location.yComponents); 29 return new tr.model.CommentBoxAnnotation(location, args.text); 30 }; 31 32 CommentBoxAnnotation.prototype = { 33 __proto__: tr.model.Annotation.prototype, 34 35 onRemove: function() { 36 this.view_.removeTextArea(); 37 }, 38 39 toDict: function() { 40 return { 41 typeName: 'comment_box', 42 args: { 43 text: this.text, 44 location: this.location.toDict() 45 } 46 }; 47 }, 48 49 createView_: function(viewport) { 50 return new tr.ui.annotations.CommentBoxAnnotationView(viewport, this); 51 } 52 }; 53 54 tr.model.Annotation.register( 55 CommentBoxAnnotation, {typeName: 'comment_box'}); 56 57 return { 58 CommentBoxAnnotation: CommentBoxAnnotation 59 }; 60}); 61</script> 62