Title: [88348] trunk/Source/WebCore
Revision
88348
Author
[email protected]
Date
2011-06-08 07:58:32 -0700 (Wed, 08 Jun 2011)

Log Message

2011-06-08  Vsevolod Vlasov  <[email protected]>

        Reviewed by Pavel Feldman.

        Web Inspector: Render non-document HTML resources as HTML
        https://bugs.webkit.org/show_bug.cgi?id=58886

        * English.lproj/localizedStrings.js:
        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * inspector/front-end/NetworkItemView.js:
        (WebInspector.NetworkItemView):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype._mimeTypeIsConsistentWithType):
        (WebInspector.Resource.prototype.hasErrorStatusCode):
        * inspector/front-end/ResourceHTMLView.js: Added.
        (WebInspector.ResourceHTMLView):
        (WebInspector.ResourceHTMLView.prototype.hasContent):
        (WebInspector.ResourceHTMLView.prototype.show):
        (WebInspector.ResourceHTMLView.prototype.hide):
        (WebInspector.ResourceHTMLView.prototype._createIFrame):
        * inspector/front-end/ResourcePreviewView.js: Added.
        (WebInspector.ResourcePreviewView):
        (WebInspector.ResourcePreviewView.prototype.hasContent):
        (WebInspector.ResourcePreviewView.prototype.show):
        (WebInspector.ResourcePreviewView.prototype._ensureInnerViewShown.callback):
        (WebInspector.ResourcePreviewView.prototype._ensureInnerViewShown):
        (WebInspector.ResourcePreviewView.prototype._createInnerView):
        * inspector/front-end/Settings.js:
        (WebInspector.Settings):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/inspector.css:
        (.resource-view.html iframe):
        * inspector/front-end/inspector.html:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (88347 => 88348)


--- trunk/Source/WebCore/ChangeLog	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/ChangeLog	2011-06-08 14:58:32 UTC (rev 88348)
@@ -1,3 +1,38 @@
+2011-06-08  Vsevolod Vlasov  <[email protected]>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Render non-document HTML resources as HTML
+        https://bugs.webkit.org/show_bug.cgi?id=58886
+
+        * English.lproj/localizedStrings.js:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/front-end/NetworkItemView.js:
+        (WebInspector.NetworkItemView):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype._mimeTypeIsConsistentWithType):
+        (WebInspector.Resource.prototype.hasErrorStatusCode):
+        * inspector/front-end/ResourceHTMLView.js: Added.
+        (WebInspector.ResourceHTMLView):
+        (WebInspector.ResourceHTMLView.prototype.hasContent):
+        (WebInspector.ResourceHTMLView.prototype.show):
+        (WebInspector.ResourceHTMLView.prototype.hide):
+        (WebInspector.ResourceHTMLView.prototype._createIFrame):
+        * inspector/front-end/ResourcePreviewView.js: Added.
+        (WebInspector.ResourcePreviewView):
+        (WebInspector.ResourcePreviewView.prototype.hasContent):
+        (WebInspector.ResourcePreviewView.prototype.show):
+        (WebInspector.ResourcePreviewView.prototype._ensureInnerViewShown.callback):
+        (WebInspector.ResourcePreviewView.prototype._ensureInnerViewShown):
+        (WebInspector.ResourcePreviewView.prototype._createInnerView):
+        * inspector/front-end/Settings.js:
+        (WebInspector.Settings):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.css:
+        (.resource-view.html iframe):
+        * inspector/front-end/inspector.html:
+
 2011-05-18  Pavel Podivilov  <[email protected]>
 
         Reviewed by Yury Semikhatsky.

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js


(Binary files differ)

Modified: trunk/Source/WebCore/WebCore.gypi (88347 => 88348)


--- trunk/Source/WebCore/WebCore.gypi	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/WebCore.gypi	2011-06-08 14:58:32 UTC (rev 88348)
@@ -6262,10 +6262,12 @@
             'inspector/front-end/ResourceCookiesView.js',
             'inspector/front-end/ResourceHeadersView.js',
             'inspector/front-end/ResourceJSONView.js',
+            'inspector/front-end/ResourceHTMLView.js',
             'inspector/front-end/ResourceTimingView.js',
             'inspector/front-end/ResourceTreeModel.js',
             'inspector/front-end/ResourceView.js',
             'inspector/front-end/ResourcesPanel.js',
+            'inspector/front-end/ResourcePreviewView.js',
             'inspector/front-end/ScopeChainSidebarPane.js',
             'inspector/front-end/Script.js',
             'inspector/front-end/ScriptFormatter.js',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (88347 => 88348)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-06-08 14:58:32 UTC (rev 88348)
@@ -68009,6 +68009,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\ResourceHTMLView.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\ResourceHeadersView.js"
 					>
 				</File>
@@ -68021,6 +68025,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\ResourcePreviewView.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\ResourceTimingView.js"
 					>
 				</File>

Modified: trunk/Source/WebCore/inspector/front-end/NetworkItemView.js (88347 => 88348)


--- trunk/Source/WebCore/inspector/front-end/NetworkItemView.js	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/inspector/front-end/NetworkItemView.js	2011-06-08 14:58:32 UTC (rev 88348)
@@ -33,23 +33,17 @@
     WebInspector.View.call(this);
 
     this.element.addStyleClass("network-item-view");
-
-    this._headersView = new WebInspector.ResourceHeadersView(resource);
     this._tabbedPane = new WebInspector.TabbedPane(this.element);
-    this._tabbedPane.appendTab("headers", WebInspector.UIString("Headers"), this._headersView);
 
-    var contentView = WebInspector.NetworkItemView._contentViewForResource(resource);
-    if (contentView.hasContent())
-        this._tabbedPane.appendTab("content", WebInspector.UIString("Content"), contentView);
+    var headersView = new WebInspector.ResourceHeadersView(resource);
+    this._tabbedPane.appendTab("headers", WebInspector.UIString("Headers"), headersView);
 
-    if (resource.type === WebInspector.Resource.Type.XHR && resource.content) {
-        var parsedJSON = WebInspector.ResourceJSONView.parseJSON(resource.content);
-        if (parsedJSON) {
-            var jsonView = new WebInspector.ResourceJSONView(resource, parsedJSON);
-            this._tabbedPane.appendTab("json", WebInspector.UIString("JSON"), jsonView);
-        }
-    }
+    var responseView = new WebInspector.ResourceSourceFrame(resource);
+    var previewView = new WebInspector.ResourcePreviewView(resource, responseView);
 
+    this._tabbedPane.appendTab("preview", WebInspector.UIString("Preview"), previewView);
+    this._tabbedPane.appendTab("response", WebInspector.UIString("Response"), responseView);
+
     if (Preferences.showCookiesTab) {
         this._cookiesView = new WebInspector.ResourceCookiesView(resource);
         this._tabbedPane.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookiesView);
@@ -63,13 +57,6 @@
     this._tabbedPane.addEventListener("tab-selected", this._tabSelected, this);
 }
 
-WebInspector.NetworkItemView._contentViewForResource = function(resource)
-{
-    if (WebInspector.ResourceView.hasTextContent(resource))
-        return new WebInspector.ResourceSourceFrame(resource)
-    return WebInspector.ResourceView.nonSourceViewForResource(resource);
-}
-
 WebInspector.NetworkItemView.prototype = {
     show: function(parentElement)
     {

Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (88347 => 88348)


--- trunk/Source/WebCore/inspector/front-end/Resource.js	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js	2011-06-08 14:58:32 UTC (rev 88348)
@@ -745,7 +745,7 @@
         // Also, if a URL like http://localhost/wiki/load.php?debug=true&lang=en produces text/css and gets reloaded,
         // it is 304 Not Modified and its guessed mime-type is text/php, which is wrong.
         // Don't check for mime-types in 304-resources.
-        if (this.statusCode >= 400 || this.statusCode === 304)
+        if (this.hasErrorStatusCode() || this.statusCode === 304)
             return true;
 
         if (typeof this.type === "undefined"
@@ -879,7 +879,7 @@
     {
         return this.url.match(/^data:/i);
     },
-    
+
     requestContentType: function()
     {
         return this.requestHeaderValue("Content-Type");
@@ -889,7 +889,12 @@
     {
         return "text/ping" === this.requestContentType();
     },
-    
+
+    hasErrorStatusCode: function()
+    {
+        return this.statusCode >= 400;
+    },
+
     _contentURL: function()
     {
         const maxDataUrlSize = 1024 * 1024;

Added: trunk/Source/WebCore/inspector/front-end/ResourceHTMLView.js (0 => 88348)


--- trunk/Source/WebCore/inspector/front-end/ResourceHTMLView.js	                        (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/ResourceHTMLView.js	2011-06-08 14:58:32 UTC (rev 88348)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.ResourceHTMLView = function(resource)
+{
+    WebInspector.ResourceView.call(this, resource);
+    this.element.addStyleClass("html");
+}
+
+WebInspector.ResourceHTMLView.prototype = {
+    hasContent: function()
+    {
+        return true;
+    },
+
+    show: function(parentElement)
+    {
+        WebInspector.ResourceView.prototype.show.call(this, parentElement);
+        this._createIFrame();
+    },
+
+    hide: function(parentElement)
+    {
+        WebInspector.ResourceView.prototype.hide.call(this, parentElement);
+        this.element.removeChildren();
+    },
+
+    _createIFrame: function()
+    {
+        // We need to create iframe again each time because contentDocument 
+        // is deleted when iframe is removed from its parent.
+        var iframe = document.createElement("iframe");
+        this.element.appendChild(iframe);
+        iframe.setAttribute("sandbox", ""); // Forbid to run _javascript_ and set unique origin.
+
+        iframe.contentDocument.body.innerHTML = this.resource.content;
+    }
+}
+
+WebInspector.ResourceHTMLView.prototype.__proto__ = WebInspector.ResourceView.prototype;

Added: trunk/Source/WebCore/inspector/front-end/ResourcePreviewView.js (0 => 88348)


--- trunk/Source/WebCore/inspector/front-end/ResourcePreviewView.js	                        (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/ResourcePreviewView.js	2011-06-08 14:58:32 UTC (rev 88348)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.ResourcePreviewView = function(resource, sourceView)
+{
+    WebInspector.ResourceView.call(this, resource);
+    this._sourceView = sourceView;
+}
+
+WebInspector.ResourcePreviewView.prototype = {
+    hasContent: function()
+    {
+        return true;
+    },
+
+    show: function(parentElement)
+    {
+        WebInspector.ResourceView.prototype.show.call(this, parentElement);
+        this._ensureInnerViewShown();
+    },
+
+    _ensureInnerViewShown: function()
+    {
+        if (this._innerViewShowRequested)
+            return;
+        this._innerViewShowRequested = true;
+
+        function callback()
+        {
+            this._createInnerView(callback).show(this.element);
+        }
+
+        this.resource.requestContent(callback.bind(this));
+    },
+
+    _createInnerView: function(callback)
+    {
+        if (this.resource.hasErrorStatusCode() && this.resource.content)
+            return new WebInspector.ResourceHTMLView(this.resource);
+
+        if (this.resource.category === WebInspector.resourceCategories.xhr && this.resource.content) {
+            var parsedJSON = WebInspector.ResourceJSONView.parseJSON(this.resource.content);
+            if (parsedJSON)
+                return new WebInspector.ResourceJSONView(this.resource, parsedJSON);
+        }
+
+        if (WebInspector.ResourceView.hasTextContent(this.resource))
+            return this._sourceView;
+
+        return WebInspector.ResourceView.nonSourceViewForResource(this.resource);
+    },
+    
+    
+}
+
+WebInspector.ResourcePreviewView.prototype.__proto__ = WebInspector.ResourceView.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (88347 => 88348)


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2011-06-08 14:58:32 UTC (rev 88348)
@@ -69,7 +69,7 @@
     this.installApplicationSetting("pauseOnExceptionStateString", WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions);
     this.installApplicationSetting("resourcesLargeRows", true);
     this.installApplicationSetting("resourcesSortOptions", {timeOption: "responseTime", sizeOption: "transferSize"});
-    this.installApplicationSetting("resourceViewTab", "content");
+    this.installApplicationSetting("resourceViewTab", "preview");
     this.installApplicationSetting("showInheritedComputedStyleProperties", false);
     this.installApplicationSetting("showUserAgentStyles", true);
     this.installApplicationSetting("watchExpressions", []);

Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (88347 => 88348)


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2011-06-08 14:58:32 UTC (rev 88348)
@@ -83,6 +83,7 @@
     <file>ResourceCategory.js</file>
     <file>ResourceCookiesView.js</file>
     <file>ResourceJSONView.js</file>
+    <file>ResourceHTMLView.js</file>
     <file>ResourceHeadersView.js</file>
     <file>ResourceTimingView.js</file>
     <file>ResourceTreeModel.js</file>

Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (88347 => 88348)


--- trunk/Source/WebCore/inspector/front-end/inspector.css	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css	2011-06-08 14:58:32 UTC (rev 88348)
@@ -4548,3 +4548,8 @@
 .resource-view.json {
     padding: 5px;
 }
+
+.resource-view.html iframe {
+    width: 100%;
+    height: 100%;
+}

Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (88347 => 88348)


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2011-06-08 14:52:16 UTC (rev 88347)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2011-06-08 14:58:32 UTC (rev 88348)
@@ -124,6 +124,8 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to