Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / timeline_track_view.html
index b826bd1..7e2246e 100644 (file)
@@ -114,6 +114,8 @@ tvcm.exportTo('tracing', function() {
       this.appendChild(this.dragBox_);
       this.hideDragBox_();
 
+      this.initHintText_();
+
       this.bindEventListener_(document, 'keypress', this.onKeypress_, this);
       this.bindEventListener_(document, 'keydown', this.onKeydown_, this);
       this.bindEventListener_(document, 'keyup', this.onKeyup_, this);
@@ -231,7 +233,7 @@ tvcm.exportTo('tracing', function() {
       if (!model)
         throw new Error('Model cannot be null');
 
-      var modelInstanceChanged = this.model_ != model;
+      var modelInstanceChanged = this.model_ !== model;
       this.model_ = model;
       this.modelTrack_.model = model;
 
@@ -247,6 +249,10 @@ tvcm.exportTo('tracing', function() {
     },
 
     setInitialViewport_: function() {
+      // We need the canvas size to be up-to-date at this point. We maybe in
+      // here before the raf fires, so the size may have not been updated since
+      // the canvas was resized.
+      this.modelTrackContainer_.updateCanvasSizeIfNeeded_();
       var w = this.modelTrackContainer_.canvas.width;
 
       var min;
@@ -255,13 +261,14 @@ tvcm.exportTo('tracing', function() {
       if (this.model_.bounds.isEmpty) {
         min = 0;
         range = 1000;
-      } else if (this.model_.bounds.range == 0) {
+      } else if (this.model_.bounds.range === 0) {
         min = this.model_.bounds.min;
         range = 1000;
       } else {
         min = this.model_.bounds.min;
         range = this.model_.bounds.range;
       }
+
       var boost = range * 0.15;
       tempDisplayTransform.set(this.viewport_.currentDisplayTransform);
       tempDisplayTransform.xSetWorldBounds(min - boost,
@@ -528,12 +535,13 @@ tvcm.exportTo('tracing', function() {
         return;
 
       var worldCenter = bounds.center;
+      var viewCenter = this.modelTrackContainer_.canvas.width / 2;
       var adjustedWorldRange = bounds.range * 1.25;
       var newScale = this.modelTrackContainer_.canvas.width /
           adjustedWorldRange;
       var zoomInRatio = newScale / this.viewport_.currentDisplayTransform.scaleX;
       var animation = new tracing.TimelineDisplayTransformZoomToAnimation(
-          worldCenter, 'center',
+          worldCenter, viewCenter,
           this.viewport_.currentDisplayTransform.panY,
           zoomInRatio);
       this.viewport_.queueDisplayTransformAnimation(animation);
@@ -693,6 +701,7 @@ tvcm.exportTo('tracing', function() {
         this.selection_ = new Selection();
 
       tvcm.dispatchSimpleEvent(this, 'selectionChange');
+      this.showHintText_('Press \'m\' to mark current selection');
 
       if (this.selectionOfInterest.length) {
         var track = this.viewport_.trackForEvent(this.selectionOfInterest[0]);
@@ -972,7 +981,9 @@ tvcm.exportTo('tracing', function() {
           loVX, hiVX, loY, hiY, selection);
 
       // Activate the new selection.
-      this.setSelectionAndClearHighlight(selection);
+      var selection_change_event = new tracing.RequestSelectionChangeEvent();
+      selection_change_event.selection = selection;
+      this.dispatchEvent(selection_change_event);
     },
 
     onBeginZoom_: function(e) {
@@ -1058,6 +1069,31 @@ tvcm.exportTo('tracing', function() {
       tempDisplayTransform.panY -= yDelta;
       vp.setDisplayTransformImmediately(tempDisplayTransform);
       this.storeLastTouchPositions_(e);
+    },
+
+    initHintText_: function() {
+      this.hintTextBox_ = this.ownerDocument.createElement('div');
+      this.hintTextBox_.className = 'hint-text';
+      this.hintTextBox_.style.display = 'none';
+      this.appendChild(this.hintTextBox_);
+
+      this.pendingHintTextClearTimeout_ = undefined;
+    },
+
+    showHintText_: function(text) {
+      if (this.pendingHintTextClearTimeout_) {
+        window.clearTimeout(this.pendingHintTextClearTimeout_);
+        this.pendingHintTextClearTimeout_ = undefined;
+      }
+      this.pendingHintTextClearTimeout_ = setTimeout(
+          this.hideHintText_.bind(this), 1000);
+      this.hintTextBox_.textContent = text;
+      this.hintTextBox_.style.display = '';
+    },
+
+    hideHintText_: function() {
+      this.pendingHintTextClearTimeout_ = undefined;
+      this.hintTextBox_.style.display = 'none';
     }
   };