Changeset 33991 in webkit


Ignore:
Timestamp:
May 21, 2008 8:31:50 PM (16 years ago)
Author:
timothy@apple.com
Message:

Adds the Request and Response headers to the Resource view.

<rdar://problem/5940782> REGRESSION: Resource Request and Response
headers aren't shown (18451)

Reviewed by Adam Roben.

  • English.lproj/localizedStrings.js: Added new strings.
  • css/view-source.css: Add comments to make sure a couple of

style rules stay in sync with inspector.css.

  • page/inspector/Resource.js:

(WebInspector.Resource.prototype.set url): Dispatch an event when
this property changes.
(WebInspector.Resource.prototype.set requestHeaders): Ditto.
(WebInspector.Resource.prototype.set responseHeaders): Ditto.

  • page/inspector/ResourceView.js:

(WebInspector.ResourceView): Add new elements for the headers
and a headers TreeOutline. Add event listeners for resource
property changes. Calls the three new refresh functions.
(WebInspector.ResourceView.prototype.set headersVisible): Implemented.
Toggles the headers-visible class name.
(WebInspector.ResourceView.prototype._refreshURL): Update the URL
tree element.
(WebInspector.ResourceView.prototype._refreshRequestHeaders): Call _refreshHeaders.
(WebInspector.ResourceView.prototype._refreshResponseHeaders): Ditto.
(WebInspector.ResourceView.prototype._refreshHeaders): Remove the previous
headers fromm the tree element. Loop throuh the headers and create new
tree elements and append them.

  • page/inspector/ResourcesPanel.js:

(WebInspector.ResourcesPanel.prototype._updateSidebarWidth): Call resize
on the visible view if it is implemented.

  • page/inspector/SourceFrame.js:

(WebInspector.SourceFrame.prototype.get autoSizeToFitContentHeight):
(WebInspector.SourceFrame.prototype.set autoSizeToFitContentHeight):
(WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
(WebInspector.SourceFrame.prototype._loaded):
(WebInspector.SourceFrame.prototype._windowResized):

  • page/inspector/SourceView.js:

(WebInspector.SourceView): Move the SourceFrame creation so it is
available when headersVisible is set. Add a gutter element to fill
the vertical space no covered by the SourceFrame now.
(WebInspector.SourceView.prototype.set headersVisible): Set the
SourceFrame.autoSizeToFitContentHeight when this property changes.
(WebInspector.SourceView.prototype.resize): Call SourceFrame.sizeToFitContentHeight
when autoSizeToFitContentHeight is true. This happens when resizing the
Resources sidebar.

  • page/inspector/inspector.css: Add a copy of webkit-line-gutter-backdrop

and a comment to keep in sync with view-source.css. Adds other styles
for the headers area of resource-view.

Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r33990 r33991  
     12008-05-21  Timothy Hatcher  <timothy@apple.com>
     2
     3        Adds the Request and Response headers to the Resource view.
     4
     5        <rdar://problem/5940782> REGRESSION: Resource Request and Response
     6        headers aren't shown (18451)
     7
     8        Reviewed by Adam Roben.
     9
     10        * English.lproj/localizedStrings.js: Added new strings.
     11        * css/view-source.css: Add comments to make sure a couple of
     12        style rules stay in sync with inspector.css.
     13        * page/inspector/Resource.js:
     14        (WebInspector.Resource.prototype.set url): Dispatch an event when
     15        this property changes.
     16        (WebInspector.Resource.prototype.set requestHeaders): Ditto.
     17        (WebInspector.Resource.prototype.set responseHeaders): Ditto.
     18        * page/inspector/ResourceView.js:
     19        (WebInspector.ResourceView): Add new elements for the headers
     20        and a headers TreeOutline. Add event listeners for resource
     21        property changes. Calls the three new refresh functions.
     22        (WebInspector.ResourceView.prototype.set headersVisible): Implemented.
     23        Toggles the headers-visible class name.
     24        (WebInspector.ResourceView.prototype._refreshURL): Update the URL
     25        tree element.
     26        (WebInspector.ResourceView.prototype._refreshRequestHeaders): Call _refreshHeaders.
     27        (WebInspector.ResourceView.prototype._refreshResponseHeaders): Ditto.
     28        (WebInspector.ResourceView.prototype._refreshHeaders): Remove the previous
     29        headers fromm the tree element. Loop throuh the headers and create new
     30        tree elements and append them.
     31        * page/inspector/ResourcesPanel.js:
     32        (WebInspector.ResourcesPanel.prototype._updateSidebarWidth): Call resize
     33        on the visible view if it is implemented.
     34        * page/inspector/SourceFrame.js:
     35        (WebInspector.SourceFrame.prototype.get autoSizesToFitContentHeight):
     36        (WebInspector.SourceFrame.prototype.set autoSizesToFitContentHeight):
     37        (WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
     38        (WebInspector.SourceFrame.prototype._loaded):
     39        (WebInspector.SourceFrame.prototype._windowResized):
     40        * page/inspector/SourceView.js:
     41        (WebInspector.SourceView): Move the SourceFrame creation so it is
     42        available when headersVisible is set. Add a gutter element to fill
     43        the vertical space no covered by the SourceFrame now.
     44        (WebInspector.SourceView.prototype.set headersVisible): Set the
     45        SourceFrame.autoSizesToFitContentHeight when this property changes.
     46        (WebInspector.SourceView.prototype.resize): Call SourceFrame.sizeToFitContentHeight
     47        when autoSizesToFitContentHeight is true. This happens when resizing the
     48        Resources sidebar.
     49        * page/inspector/inspector.css: Add a copy of webkit-line-gutter-backdrop
     50        and a comment to keep in sync with view-source.css. Adds other styles
     51        for the headers area of resource-view.
     52
    1532008-05-21  Sam Weinig  <sam@webkit.org>
    254
  • trunk/WebCore/css/view-source.css

    r33395 r33991  
    4444
    4545.webkit-line-gutter-backdrop, .webkit-line-number {
     46    /* Keep this in sync with inspector.css (.webkit-line-gutter-backdrop) */
    4647    -webkit-box-sizing: border-box;
    4748    padding: 0 4px !important;
     
    5354
    5455.webkit-line-gutter-backdrop {
     56    /* Keep this in sync with inspector.css (.webkit-line-gutter-backdrop) */
    5557    position: absolute;
    5658    z-index: -1;
  • trunk/WebCore/page/inspector/Resource.js

    r33525 r33991  
    9494        var oldURL = this._url;
    9595        this._url = x;
     96
     97        // FIXME: We should make the WebInspector object listen for the "url changed" event.
     98        // Then resourceURLChanged can be removed.
    9699        WebInspector.resourceURLChanged(this, oldURL);
     100
     101        this.dispatchEventToListeners("url changed");
    97102    },
    98103
     
    342347        delete this._sortedRequestHeaders;
    343348
    344         if (WebInspector.panels.resources)
    345             WebInspector.panels.resources.refreshResource(this);
     349        this.dispatchEventToListeners("requestHeaders changed");
    346350    },
    347351
     
    374378        delete this._sortedResponseHeaders;
    375379
    376         if (WebInspector.panels.resources)
    377             WebInspector.panels.resources.refreshResource(this);
     380        this.dispatchEventToListeners("responseHeaders changed");
    378381    },
    379382
  • trunk/WebCore/page/inspector/ResourceView.js

    r33411 r33991  
    3535    this.resource = resource;
    3636
    37     // FIXME: Implement the setter for headersVisible when the header element is added.
     37    this.headersElement = document.createElement("div");
     38    this.headersElement.className = "resource-view-headers";
     39    this.element.appendChild(this.headersElement);
    3840
    3941    this.contentElement = document.createElement("div");
    4042    this.contentElement.className = "resource-view-content";
    4143    this.element.appendChild(this.contentElement);
     44
     45    this.headersListElement = document.createElement("ol");
     46    this.headersListElement.className = "outline-disclosure";
     47    this.headersElement.appendChild(this.headersListElement);
     48
     49    this.headersTreeOutline = new TreeOutline(this.headersListElement);
     50    this.headersTreeOutline.expandTreeElementsWhenArrowing = true;
     51
     52    this.urlTreeElement = new TreeElement("", null, false);
     53    this.urlTreeElement.selectable = false;
     54    this.headersTreeOutline.appendChild(this.urlTreeElement);
     55
     56    this.requestHeadersTreeElement = new TreeElement("", null, true);
     57    this.requestHeadersTreeElement.expanded = false;
     58    this.requestHeadersTreeElement.selectable = false;
     59    this.headersTreeOutline.appendChild(this.requestHeadersTreeElement);
     60
     61    this.responseHeadersTreeElement = new TreeElement("", null, true);
     62    this.responseHeadersTreeElement.expanded = false;
     63    this.responseHeadersTreeElement.selectable = false;
     64    this.headersTreeOutline.appendChild(this.responseHeadersTreeElement);
     65
     66    this.headersVisible = true;
     67
     68    resource.addEventListener("url changed", this._refreshURL, this);
     69    resource.addEventListener("requestHeaders changed", this._refreshRequestHeaders, this);
     70    resource.addEventListener("responseHeaders changed", this._refreshResponseHeaders, this);
     71
     72    this._refreshURL();
     73    this._refreshRequestHeaders();
     74    this._refreshResponseHeaders();
    4275}
    4376
     
    5588        this._headersVisible = x;
    5689
    57         if (x) {
    58             // FIXME: Implement this when headers are added.
    59         } else {
    60             // FIXME: Implement this when headers are added.
    61         }
     90        if (x)
     91            this.element.addStyleClass("headers-visible");
     92        else
     93            this.element.removeStyleClass("headers-visible");
    6294    },
    6395
     
    6698        if (!this.element.parentNode)
    6799            document.getElementById("resource-views").appendChild(this.element);
     100    },
     101
     102    _refreshURL: function()
     103    {
     104        this.urlTreeElement.title = this.resource.url.escapeHTML();
     105    },
     106
     107    _refreshRequestHeaders: function()
     108    {
     109        this._refreshHeaders(WebInspector.UIString("Request Headers"), this.resource.sortedRequestHeaders, this.requestHeadersTreeElement);
     110    },
     111
     112    _refreshResponseHeaders: function()
     113    {
     114        this._refreshHeaders(WebInspector.UIString("Response Headers"), this.resource.sortedResponseHeaders, this.responseHeadersTreeElement);
     115    },
     116
     117    _refreshHeaders: function(title, headers, headersTreeElement)
     118    {
     119        headersTreeElement.removeChildren();
     120
     121        var length = headers.length;
     122        headersTreeElement.title = title.escapeHTML() + "<span class=\"header-count\">" + WebInspector.UIString(" (%d)", length) + "</span>";
     123        headersTreeElement.hidden = !length;
     124
     125        var length = headers.length;
     126        for (var i = 0; i < length; ++i) {
     127            var title = "<div class=\"header-name\">" + headers[i].header.escapeHTML() + ":</div>";
     128            title += "<div class=\"header-value\">" + headers[i].value.escapeHTML() + "</div>"
     129
     130            var headerTreeElement = new TreeElement(title, null, false);
     131            headerTreeElement.selectable = false;
     132            headersTreeElement.appendChild(headerTreeElement);
     133        }
    68134    }
    69135}
  • trunk/WebCore/page/inspector/ResourcesPanel.js

    r33411 r33991  
    10541054        this._updateGraphBars();
    10551055        this._updateGraphDividersIfNeeded();
     1056
     1057        var visibleResourceView = this.visibleResourceView;
     1058        if (visibleResourceView && "resize" in visibleResourceView)
     1059            visibleResourceView.resize();
    10561060    }
    10571061}
  • trunk/WebCore/page/inspector/SourceFrame.js

    r33408 r33991  
    5555    },
    5656
     57    get autoSizesToFitContentHeight()
     58    {
     59        return this._autoSizesToFitContentHeight;
     60    },
     61
     62    set autoSizesToFitContentHeight(x)
     63    {
     64        if (this._autoSizesToFitContentHeight === x)
     65            return;
     66
     67        this._autoSizesToFitContentHeight = x;
     68
     69        if (this._autoSizesToFitContentHeight) {
     70            this._windowResizeListener = this._windowResized.bind(this);
     71            window.addEventListener("resize", this._windowResizeListener, false);
     72            this.sizeToFitContentHeight();
     73        } else {
     74            this.element.style.removeProperty("height");
     75            if (this.element.contentDocument)
     76                this.element.contentDocument.body.addStyleClass("webkit-height-sized-to-fit");
     77            window.removeEventListener("resize", this._windowResizeListener, false);
     78            delete this._windowResizeListener;
     79        }
     80    },
     81
    5782    sourceRow: function(lineNumber)
    5883    {
     
    129154            var bubble = bubbles[i];
    130155            bubble.parentNode.removeChild(bubble);
     156        }
     157    },
     158
     159    sizeToFitContentHeight: function()
     160    {
     161        if (this.element.contentDocument) {
     162            this.element.style.setProperty("height", this.element.contentDocument.body.offsetHeight + "px");
     163            this.element.contentDocument.body.addStyleClass("webkit-height-sized-to-fit");
    131164        }
    132165    },
     
    155188        styleText += ".webkit-breakpoint-disabled.webkit-execution-line .webkit-line-number { color: transparent; background-image: -webkit-canvas(breakpoint-disabled-program-counter); }\n";
    156189        styleText += ".webkit-execution-line .webkit-line-content { background-color: rgb(171, 191, 254); outline: 1px solid rgb(64, 115, 244); }\n";
     190        styleText += ".webkit-height-sized-to-fit { overflow-y: hidden }\n";
    157191
    158192        styleElement.textContent = styleText;
     
    169203        this._addExistingBreakpointsToSource();
    170204        this._updateExecutionLine();
     205
     206        if (this.autoSizesToFitContentHeight)
     207            this.sizeToFitContentHeight();
     208    },
     209
     210    _windowResized: function(event)
     211    {
     212        if (!this._autoSizesToFitContentHeight)
     213            return;
     214        this.sizeToFitContentHeight();
    171215    },
    172216
  • trunk/WebCore/page/inspector/SourceView.js

    r33411 r33991  
    2929WebInspector.SourceView = function(resource)
    3030{
     31    // Set the sourceFrame first since WebInspector.ResourceView will set headersVisible
     32    // and our override of headersVisible needs the sourceFrame.
     33    this.sourceFrame = new WebInspector.SourceFrame(null, this._addBreakpoint.bind(this));
     34
    3135    WebInspector.ResourceView.call(this, resource);
    3236
     
    3741    this._frameNeedsSetup = true;
    3842
    39     this.sourceFrame = new WebInspector.SourceFrame(null, this._addBreakpoint.bind(this));
     43    this.contentElement.appendChild(this.sourceFrame.element);
    4044
    41     this.contentElement.appendChild(this.sourceFrame.element);
     45    var gutterElement = document.createElement("div");
     46    gutterElement.className = "webkit-line-gutter-backdrop";
     47    this.element.appendChild(gutterElement);
    4248}
    4349
    4450WebInspector.SourceView.prototype = {
     51    set headersVisible(x)
     52    {
     53        if (x === this._headersVisible)
     54            return;
     55
     56        var superSetter = WebInspector.ResourceView.prototype.__lookupSetter__("headersVisible");
     57        if (superSetter)
     58            superSetter.call(this, x);
     59
     60        this.sourceFrame.autoSizesToFitContentHeight = x;
     61    },
     62
    4563    show: function(parentElement)
    4664    {
    4765        WebInspector.ResourceView.prototype.show.call(this, parentElement);
    4866        this.setupSourceFrameIfNeeded();
     67    },
     68
     69    resize: function()
     70    {
     71        if (this.sourceFrame.autoSizesToFitContentHeight)
     72            this.sourceFrame.sizeToFitContentHeight();
    4973    },
    5074
  • trunk/WebCore/page/inspector/inspector.css

    r33976 r33991  
    529529    right: 0;
    530530    bottom: 0;
     531    overflow: hidden;
    531532}
    532533
     
    535536}
    536537
     538.resource-view.headers-visible {
     539    overflow-y: auto;
     540    overflow-x: hidden;
     541}
     542
     543.resource-view-headers {
     544    display: none;
     545    padding: 6px;
     546    border-bottom: 1px solid rgb(64%, 64%, 64%);
     547    background-color: white;
     548    -webkit-user-select: text;
     549}
     550
     551.resource-view-headers .outline-disclosure .parent {
     552    -webkit-user-select: none;
     553    font-weight: bold;
     554}
     555
     556.resource-view.headers-visible .resource-view-headers {
     557    display: block;
     558}
     559
     560.resource-view-headers .outline-disclosure .children li {
     561    white-space: nowrap;
     562}
     563
     564.resource-view-headers .outline-disclosure li.expanded .header-count {
     565    display: none;
     566}
     567
     568.resource-view-headers .outline-disclosure .header-name {
     569    color: rgb(33%, 33%, 33%);
     570    display: inline-block;
     571    width: 105px;
     572    text-align: right;
     573    margin-right: 0.5em;
     574    font-weight: bold;
     575    vertical-align: top;
     576    overflow: hidden;
     577    text-overflow: ellipsis;
     578}
     579
     580.resource-view-headers .outline-disclosure .header-value {
     581    display: inline-block;
     582    white-space: normal;
     583    word-break: break-word;
     584    vertical-align: top;
     585    margin-right: 100px;
     586}
     587
    537588.resource-view .resource-view-content {
    538589    position: absolute;
     
    541592    left: 0;
    542593    bottom: 0;
     594}
     595
     596.resource-view.headers-visible .resource-view-content {
     597    position: relative;
     598    top: auto;
     599    right: auto;
     600    left: auto;
     601    bottom: auto;
     602}
     603
     604.resource-view.headers-visible .source-view-frame {
     605    height: auto;
     606}
     607
     608.webkit-line-gutter-backdrop {
     609    /* Keep this in sync with view-source.css (.webkit-line-gutter-backdrop) */
     610    width: 31px;
     611    background-color: rgb(240, 240, 240);
     612    border-right: 1px solid rgb(187, 187, 187);
     613    position: absolute;
     614    z-index: -1;
     615    left: 0;
     616    top: 0;
     617    height: 100%
    543618}
    544619
Note: See TracChangeset for help on using the changeset viewer.