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

Unified Diff: Source/devtools/front_end/ScreencastView.js

Issue 23537022: Add navigation controls to DevTools screencast view (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Polished styles, added icons Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Source/devtools/front_end/screencastView.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ScreencastView.js
diff --git a/Source/devtools/front_end/ScreencastView.js b/Source/devtools/front_end/ScreencastView.js
index bc0264cffa914636d3631f5c69cdb14cb32895dc..2b6bc4fa04629179e35eb2be0b07c1f7905e0cb0 100644
--- a/Source/devtools/front_end/ScreencastView.js
+++ b/Source/devtools/front_end/ScreencastView.js
@@ -40,6 +40,9 @@ WebInspector.ScreencastView = function()
this.element.addStyleClass("fill");
this.element.addStyleClass("screencast");
+
+ this._createNavigationBar();
+
this._viewportElement = this.element.createChild("div", "screencast-viewport hidden");
this._canvasElement = this._viewportElement.createChild("canvas");
this._canvasElement.tabIndex = 1;
@@ -74,6 +77,8 @@ WebInspector.ScreencastView = function()
WebInspector.ScreencastView._bordersSize = 40;
+WebInspector.ScreencastView._HttpRegex = /^https?:\/\/(.+)/;
+
WebInspector.ScreencastView.prototype = {
wasShown: function()
{
@@ -620,5 +625,77 @@ WebInspector.ScreencastView.prototype = {
return context.createPattern(pattern, "repeat");
},
+ _createNavigationBar: function()
+ {
+ this._navigationBar = this.element.createChild("div", "screencast-navigation");
+
+ this._navigationBack = this._navigationBar.createChild("button", "back");
+ this._navigationBack.disabled = true;
+ this._navigationBack.addEventListener("click", this._navigateToHistoryEntry.bind(this, -1), false);
+
+ this._navigationForward = this._navigationBar.createChild("button", "forward");
+ this._navigationForward.disabled = true;
+ this._navigationForward.addEventListener("click", this._navigateToHistoryEntry.bind(this, 1), false);
+
+ this._navigationReload = this._navigationBar.createChild("button", "reload");
+ this._navigationReload.addEventListener("click", this._navigateReload.bind(this), false);
+
+ this._navigationUrl = this._navigationBar.createChild("input");
+ this._navigationUrl.type = "text";
+ this._navigationUrl.addEventListener('keyup', this._navigationUrlKeyUp.bind(this), true);
+
+ this._requestNavigationHistory();
+ WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._requestNavigationHistory, this);
+ },
+
+ _navigateToHistoryEntry: function(offset)
+ {
+ var newIndex = this._historyIndex + offset;
+ if (newIndex < 0 || newIndex >= this._historyEntries.length)
+ return;
+ PageAgent.navigateToHistoryEntry(this._historyEntries[newIndex].id);
+ this._requestNavigationHistory();
+ },
+
+ _navigateReload: function()
+ {
+ PageAgent.reload();
+ },
+
+ _navigationUrlKeyUp: function(event)
+ {
+ if (event.keyIdentifier != 'Enter')
+ return;
+ var url = this._navigationUrl.value;
+ if (!url)
+ return;
+ if (!url.match(WebInspector.ScreencastView._HttpRegex))
+ url = "http://" + url;
+ PageAgent.navigate(url);
+ },
+
+ _requestNavigationHistory: function()
+ {
+ PageAgent.getNavigationHistory(this._onNavigationHistory.bind(this));
+ },
+
+ _onNavigationHistory: function(error, currentIndex, entries)
+ {
+ if (error)
+ return;
+
+ this._historyIndex = currentIndex;
+ this._historyEntries = entries;
+
+ this._navigationBack.disabled = currentIndex == 0;
+ this._navigationForward.disabled = currentIndex == (entries.length - 1);
+
+ var url = entries[currentIndex].url;
+ var match = url.match(WebInspector.ScreencastView._HttpRegex);
+ if (match)
+ url = match[1];
+ this._navigationUrl.value = url;
+ },
+
__proto__: WebInspector.View.prototype
}
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Source/devtools/front_end/screencastView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698