Commit d230f670 authored by timothy@apple.com's avatar timothy@apple.com

Fixes a regression where clicking a resource URL in the Console would not

show the resource in the Resources panel.

https://bugs.webkit.org/show_bug.cgi?id=18493

Reviewed by Adam Roben.

* page/inspector/Console.js:
(WebInspector.Console.prototype._messagesClicked): Removed console-message-url
handling to show resources. This is now handled by WebInspector.showResourceForURL.
(WebInspector.ConsoleMessage.prototype.toMessageElement): Add the webkit-html-resource-link
class name to the URL anchor. Also add the line number as a property to the anchor.
* page/inspector/ResourcesPanel.js:
(WebInspector.ResourcesPanel): Add a reference to the tree element to each calculator.
(WebInspector.ResourcesPanel.prototype.showResource): Select and reveal the resource in
the sidebar. Call showLine on the resource view if it is implemented.
(WebInspector.ResourcesPanel.prototype.closeVisibleResource): Select the current calculator's
tree element in the sidebar.
(WebInspector.ResourcesPanel.prototype._graphSelected): Call closeVisibleResource after
the calculator changes since closeVisibleResource uses the calculator.
* page/inspector/SourceView.js:
(WebInspector.SourceView.prototype.sourceRow): Early return if the line is null/zero.
(WebInspector.SourceView.prototype.showLine):  Renamed from showSourceLine.
* page/inspector/inspector.css:
(body.console-visible #main-panels): Made the bottom 24px to match
the height of #main-status-bar.
(.console-message-url): Make the color important so it wins over
the .webkit-html-resource-link rule.
(.resource-view .resource-view-content): Made more generic from .image
so all resource views get sized correctly.
(.resource-view.image .resource-view-content): Removed.
* page/inspector/inspector.js:
(WebInspector.documentClick): Pass the line number from the anchor to
WebInspector.showResourceForURL.
(WebInspector.showResourceForURL): Add line number support. Pass the line
to ResourcesPanel.showResource.
(WebInspector.addMainEventListeners): Use bind for the event listeners.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f02b6bcb
2008-04-14 Timothy Hatcher <timothy@apple.com>
Fixes a regression where clicking a resource URL in the Console would not
show the resource in the Resources panel.
https://bugs.webkit.org/show_bug.cgi?id=18493
Reviewed by Adam Roben.
* page/inspector/Console.js:
(WebInspector.Console.prototype._messagesClicked): Removed console-message-url
handling to show resources. This is now handled by WebInspector.showResourceForURL.
(WebInspector.ConsoleMessage.prototype.toMessageElement): Add the webkit-html-resource-link
class name to the URL anchor. Also add the line number as a property to the anchor.
* page/inspector/ResourcesPanel.js:
(WebInspector.ResourcesPanel): Add a reference to the tree element to each calculator.
(WebInspector.ResourcesPanel.prototype.showResource): Select and reveal the resource in
the sidebar. Call showLine on the resource view if it is implemented.
(WebInspector.ResourcesPanel.prototype.closeVisibleResource): Select the current calculator's
tree element in the sidebar.
(WebInspector.ResourcesPanel.prototype._graphSelected): Call closeVisibleResource after
the calculator changes since closeVisibleResource uses the calculator.
* page/inspector/SourceView.js:
(WebInspector.SourceView.prototype.sourceRow): Early return if the line is null/zero.
(WebInspector.SourceView.prototype.showLine): Renamed from showSourceLine.
* page/inspector/inspector.css:
(body.console-visible #main-panels): Made the bottom 24px to match
the height of #main-status-bar.
(.console-message-url): Make the color important so it wins over
the .webkit-html-resource-link rule.
(.resource-view .resource-view-content): Made more generic from .image
so all resource views get sized correctly.
(.resource-view.image .resource-view-content): Removed.
* page/inspector/inspector.js:
(WebInspector.documentClick): Pass the line number from the anchor to
WebInspector.showResourceForURL.
(WebInspector.showResourceForURL): Add line number support. Pass the line
to ResourcesPanel.showResource.
(WebInspector.addMainEventListeners): Use bind for the event listeners.
2008-04-14 Xan Lopez <xan@gnome.org>
Reviewed by Alp Toker.
......@@ -259,26 +259,10 @@ WebInspector.Console.prototype = {
_messagesClicked: function(event)
{
var link = event.target.enclosingNodeOrSelfWithNodeName("a");
if (link && link.representedNode) {
WebInspector.updateFocusedNode(link.representedNode);
if (!link || !link.representedNode)
return;
}
var messageElement = event.target.enclosingNodeOrSelfWithClass("console-message");
if (!messageElement)
return;
if (!messageElement.message)
return;
var resource = messageElement.message.resource;
if (!resource)
return;
if (link && link.hasStyleClass("console-message-url")) {
// FIXME: show the source in the Resources panel and scroll to the line.
}
WebInspector.updateFocusedNode(link.representedNode);
event.stopPropagation();
event.preventDefault();
},
......@@ -514,7 +498,9 @@ WebInspector.ConsoleMessage.prototype = {
if (this.url && this.url !== "undefined") {
var urlElement = document.createElement("a");
urlElement.className = "console-message-url";
urlElement.className = "console-message-url webkit-html-resource-link";
urlElement.href = this.url;
urlElement.lineNumber = this.line;
if (this.line > 0)
urlElement.textContent = WebInspector.UIString("%s (line %d)", this.url, this.line);
......
......@@ -86,10 +86,12 @@ WebInspector.ResourcesPanel = function()
var timeGraphItem = new WebInspector.SidebarTreeElement("resources-time-graph-sidebar-item", WebInspector.UIString("Time"));
timeGraphItem.calculator = new WebInspector.ResourceTransferTimeCalculator();
timeGraphItem.onselect = this._graphSelected.bind(this);
timeGraphItem.calculator._graphsTreeElement = timeGraphItem;
var sizeGraphItem = new WebInspector.SidebarTreeElement("resources-size-graph-sidebar-item", WebInspector.UIString("Size"));
sizeGraphItem.calculator = new WebInspector.ResourceTransferSizeCalculator();
sizeGraphItem.onselect = this._graphSelected.bind(this);
sizeGraphItem.calculator._graphsTreeElement = sizeGraphItem;
this.graphsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("GRAPHS"), {}, true);
this.sidebarTree.appendChild(this.graphsTreeElement);
......@@ -296,7 +298,7 @@ WebInspector.ResourcesPanel.prototype = {
barRightElement.style.right = (100 - percentages.end) + "%";
},
showResource: function(resource)
showResource: function(resource, line)
{
if (!resource)
return;
......@@ -310,6 +312,14 @@ WebInspector.ResourcesPanel.prototype = {
resource._resourcesView = this._createResourceView(resource);
resource._resourcesView.show();
if (line && resource._resourcesView.showLine)
resource._resourcesView.showLine(line);
if (resource._resourcesTreeElement) {
resource._resourcesTreeElement.reveal();
resource._resourcesTreeElement.select(true);
}
this.visibleResource = resource;
this._updateSidebarWidth();
......@@ -319,10 +329,13 @@ WebInspector.ResourcesPanel.prototype = {
{
this.containerElement.removeStyleClass("viewing-resource");
this._updateDividersLabelBarPosition();
if (this.visibleResource && this.visibleResource._resourcesView)
this.visibleResource._resourcesView.hide();
delete this.visibleResource;
this.calculator._graphsTreeElement.select(true);
this._updateSidebarWidth();
},
......@@ -810,8 +823,8 @@ WebInspector.ResourcesPanel.prototype = {
_graphSelected: function(treeElement)
{
this.closeVisibleResource();
this.calculator = treeElement.calculator;
this.closeVisibleResource();
this.containerElement.scrollTop = 0;
},
......
......@@ -66,6 +66,9 @@ WebInspector.SourceView.prototype = {
sourceRow: function(lineNumber)
{
if (!lineNumber)
return;
this.setupSourceFrameIfNeeded();
var doc = this.frameElement.contentDocument;
......@@ -79,7 +82,7 @@ WebInspector.SourceView.prototype = {
return rows[lineNumber];
},
showSourceLine: function(lineNumber)
showLine: function(lineNumber)
{
var row = this.sourceRow(lineNumber);
if (!row)
......
......@@ -169,6 +169,10 @@ body.console-visible #main-status-bar * {
cursor: default;
}
body.console-visible #main-panels {
bottom: 24px;
}
.status-bar {
background-color: rgb(235, 235, 235);
background-image: url(Images/statusbarBackground.png);
......@@ -366,7 +370,7 @@ body.console-visible #console {
}
.console-message-url {
color: rgb(33%, 33%, 33%);
color: rgb(33%, 33%, 33%) !important;
cursor: pointer;
}
......@@ -423,6 +427,14 @@ body.console-visible #console {
display: block;
}
.resource-view .resource-view-content {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.resource-view.font {
font-size: 60px;
white-space: pre-wrap;
......@@ -440,12 +452,6 @@ body.console-visible #console {
bottom: 0;
}
.resource-view.image .resource-view-content {
position: relative;
width: 100%;
height: 100%;
}
.resource-view.image .resource-view-content > .image {
position: relative;
height: 70%;
......
......@@ -332,7 +332,7 @@ WebInspector.documentClick = function(event)
if (!anchor.hasStyleClass("webkit-html-resource-link"))
return;
if (WebInspector.showResourceForURL(anchor.getAttribute("href"))) {
if (WebInspector.showResourceForURL(anchor.href, anchor.lineNumber)) {
event.preventDefault();
event.stopPropagation();
}
......@@ -703,14 +703,14 @@ WebInspector.resourceForURL = function(url)
return null;
}
WebInspector.showResourceForURL = function(url)
WebInspector.showResourceForURL = function(url, line)
{
var resource = this.resourceForURL(url);
if (!resource)
return false;
this.currentPanel = this.panels.resources;
this.panels.resources.showResource(resource);
this.panels.resources.showResource(resource, line);
return true;
}
......@@ -726,9 +726,9 @@ WebInspector.linkifyURL = function(url, linkText, classes, isExternal)
WebInspector.addMainEventListeners = function(doc)
{
doc.defaultView.addEventListener("focus", function(event) { WebInspector.windowFocused(event) }, true);
doc.defaultView.addEventListener("blur", function(event) { WebInspector.windowBlured(event) }, true);
doc.addEventListener("click", function(event) { WebInspector.documentClick(event) }, true);
doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), true);
doc.defaultView.addEventListener("blur", this.windowBlured.bind(this), true);
doc.addEventListener("click", this.documentClick.bind(this), true);
}
WebInspector.performSearch = function(query)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment