|
Line 0
a/Source/WebInspectorUI/UserInterface/Views/ReplayDashboardView.js_sec1
|
|
|
1 |
/* |
| 2 |
* Copyright (C) 2014 University of Washington. All rights reserved. |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions |
| 6 |
* are met: |
| 7 |
* 1. Redistributions of source code must retain the above copyright |
| 8 |
* notice, this list of conditions and the following disclaimer. |
| 9 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 10 |
* notice, this list of conditions and the following disclaimer in the |
| 11 |
* documentation and/or other materials provided with the distribution. |
| 12 |
* |
| 13 |
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 |
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 |
* THE POSSIBILITY OF SUCH DAMAGE. |
| 24 |
*/ |
| 25 |
|
| 26 |
WebInspector.ReplayDashboardView = function(representedObject) |
| 27 |
{ |
| 28 |
WebInspector.DashboardView.call(this, representedObject, "replay"); |
| 29 |
|
| 30 |
this._navigationBar = new WebInspector.NavigationBar; |
| 31 |
this.element.appendChild(this._navigationBar.element); |
| 32 |
|
| 33 |
replayManager = WebInspector.replayManager; |
| 34 |
|
| 35 |
this._captureButtonItem = new WebInspector.ActivateButtonNavigationItem("replay-dashboard-capture", WebInspector.UIString("Start Recording"), WebInspector.UIString("Stop Recording"), "Images/ReplayReadyButton.svg", 16, 16); |
| 36 |
this._captureButtonItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, this._captureButtonItemClicked, this); |
| 37 |
this._captureButtonItem.hidden = true; |
| 38 |
this._navigationBar.addNavigationItem(this._captureButtonItem); |
| 39 |
|
| 40 |
this._replayButtonItem = new WebInspector.ToggleButtonNavigationItem("replay-dashboard-replay", WebInspector.UIString("Start Playback"), WebInspector.UIString("Pause Playback"), "Images/ReplayPlayButton.svg", "Images/ReplayPauseButton.svg", 16, 16); |
| 41 |
this._replayButtonItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, this._replayButtonItemClicked, this); |
| 42 |
this._replayButtonItem.hidden = true; |
| 43 |
this._navigationBar.addNavigationItem(this._replayButtonItem); |
| 44 |
|
| 45 |
// Add events required to track capture and replay state. |
| 46 |
WebInspector.replayManager.addEventListener(WebInspector.ReplayManager.Event.CaptureStarted, this._captureStarted, this); |
| 47 |
WebInspector.replayManager.addEventListener(WebInspector.ReplayManager.Event.CaptureStopped, this._captureStopped, this); |
| 48 |
WebInspector.replayManager.addEventListener(WebInspector.ReplayManager.Event.PlaybackStarted, this._playbackStarted, this); |
| 49 |
WebInspector.replayManager.addEventListener(WebInspector.ReplayManager.Event.PlaybackPaused, this._playbackPaused, this); |
| 50 |
WebInspector.replayManager.addEventListener(WebInspector.ReplayManager.Event.PlaybackFinished, this._playbackFinished, this); |
| 51 |
|
| 52 |
// Manually initialize style classes by querying current replay state. |
| 53 |
if (WebInspector.replayManager.sessionState === WebInspector.ReplayManager.SessionState.Capturing) |
| 54 |
this._captureStarted(); |
| 55 |
else if (WebInspector.replayManager.sessionState === WebInspector.ReplayManager.SessionState.Inactive) |
| 56 |
this._captureStopped(); |
| 57 |
// ReplayManager.sessionState must be Replaying. |
| 58 |
else if (WebInspector.replayManager.segmentState === WebInspector.ReplayManager.SegmentState.Dispatching) |
| 59 |
this._playbackStarted(); |
| 60 |
// ReplayManager.sessionState must be Unloaded or Loaded, so execution is paused. |
| 61 |
else |
| 62 |
this._playbackPaused(); |
| 63 |
}; |
| 64 |
|
| 65 |
// Class names for top-level flex items within the replay dashboard. |
| 66 |
WebInspector.ReplayDashboardView.RecordingContainerStyleClassName = "recording-container"; |
| 67 |
|
| 68 |
// Class names for single buttons. |
| 69 |
WebInspector.ReplayDashboardView.RecordButtonStyleClassName = "record-button"; |
| 70 |
WebInspector.ReplayDashboardView.ReplayButtonStyleClassName = "replay-button"; |
| 71 |
|
| 72 |
WebInspector.ReplayDashboardView.prototype = { |
| 73 |
constructor: WebInspector.ReplayDashboardView, |
| 74 |
__proto__: WebInspector.DashboardView.prototype, |
| 75 |
|
| 76 |
// Private |
| 77 |
|
| 78 |
_captureButtonItemClicked: function() |
| 79 |
{ |
| 80 |
if (WebInspector.replayManager.sessionState !== WebInspector.ReplayManager.SessionState.Capturing) |
| 81 |
WebInspector.replayManager.startCapturing(); |
| 82 |
else |
| 83 |
WebInspector.replayManager.stopCapturing(); |
| 84 |
}, |
| 85 |
|
| 86 |
_replayButtonItemClicked: function(event) |
| 87 |
{ |
| 88 |
console.assert(WebInspector.replayManager.sessionState !== WebInspector.ReplayManager.SessionState.Capturing, "Tried to start replaying while SessionState is Capturing!"); |
| 89 |
|
| 90 |
if (WebInspector.replayManager.sessionState === WebInspector.ReplayManager.SessionState.Inactive) |
| 91 |
WebInspector.replayManager.replayToCompletion(); |
| 92 |
else if (WebInspector.replayManager.segmentState === WebInspector.ReplayManager.SegmentState.Dispatching) |
| 93 |
WebInspector.replayManager.pausePlayback(); |
| 94 |
else |
| 95 |
WebInspector.replayManager.replayToCompletion(); |
| 96 |
}, |
| 97 |
|
| 98 |
_captureStarted: function() |
| 99 |
{ |
| 100 |
this._captureButtonItem.hidden = false; |
| 101 |
this._captureButtonItem.activated = true; |
| 102 |
this._replayButtonItem.hidden = true; |
| 103 |
}, |
| 104 |
|
| 105 |
_captureStopped: function() |
| 106 |
{ |
| 107 |
this._captureButtonItem.activated = false; |
| 108 |
this._captureButtonItem.hidden = true; |
| 109 |
this._replayButtonItem.hidden = false; |
| 110 |
}, |
| 111 |
|
| 112 |
_playbackStarted: function() |
| 113 |
{ |
| 114 |
this._replayButtonItem.toggled = true; |
| 115 |
}, |
| 116 |
|
| 117 |
_playbackPaused: function() |
| 118 |
{ |
| 119 |
this._replayButtonItem.toggled = false; |
| 120 |
}, |
| 121 |
|
| 122 |
_playbackFinished: function() |
| 123 |
{ |
| 124 |
this._replayButtonItem.toggled = false; |
| 125 |
} |
| 126 |
}; |