Changeset 31909 in webkit


Ignore:
Timestamp:
Apr 15, 2008 10:24:09 AM (16 years ago)
Author:
timothy@apple.com
Message:

Fixes the regression where error and warning bubbles would not be added
to the source view of a resource.

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

Reviewed by Adam Roben.

  • css/view-source.css:

(.webkit-html-message-bubble): Add a min-height to make sure the border-radius
has enough room to apply.

  • page/inspector/Console.js:

(WebInspector.Console.prototype.addMessage): Removed code that added messages
to resource panels and incremented error and warning counts on resources.
Now just call ResourcesPanel.addMessageToResource after assigning the resource
to the console message.
(WebInspector.Console.prototype.clearMessages): Removed code that cleared error
and warning counts from resources an call ResourcesPanel.clearMessages.

  • page/inspector/ResourcesPanel.js:

(WebInspector.ResourcesPanel.prototype.addMessageToResource): Call addMessage
on the resource's view, if it is implemented.
(WebInspector.ResourcesPanel.prototype.clearMessages): Call clearMessages
on all the resource views for the ones that implement it.
(WebInspector.ResourcesPanel.prototype.refreshResource): Call _resourceView
to make the resource's view if needed. Use a local view variable.
(WebInspector.ResourcesPanel.prototype._resourceView): Added helper function
to create a resource view if needed.

  • page/inspector/SourceView.js:

(WebInspector.SourceView.prototype.setupSourceFrameIfNeeded): Delete the
_frameNeedsSetup property at the beginning to prevent recursion. Get the
length of the messages array when assigning the local length variable.
(WebInspector.SourceView.prototype.addMessage): Renamed from addMessageToSource.
(WebInspector.SourceView.prototype.clearMessages): Added. Clear all the message
bubbles that might be sprinkled in the source. Also clears the messages array.
(WebInspector.SourceView.prototype._addMessageToSource): Create the image
element in the Inspector's document so we can use relative image URLs. Then
adopt the image element into the frame's document.

Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31908 r31909  
     12008-04-15  Timothy Hatcher  <timothy@apple.com>
     2
     3        Fixes the regression where error and warning bubbles would not be added
     4        to the source view of a resource.
     5
     6        https://bugs.webkit.org/show_bug.cgi?id=18495
     7
     8        Reviewed by Adam Roben.
     9
     10        * css/view-source.css:
     11        (.webkit-html-message-bubble): Add a min-height to make sure the border-radius
     12        has enough room to apply.
     13        * page/inspector/Console.js:
     14        (WebInspector.Console.prototype.addMessage): Removed code that added messages
     15        to resource panels and incremented error and warning counts on resources.
     16        Now just call ResourcesPanel.addMessageToResource after assigning the resource
     17        to the console message.
     18        (WebInspector.Console.prototype.clearMessages): Removed code that cleared error
     19        and warning counts from resources an call ResourcesPanel.clearMessages.
     20        * page/inspector/ResourcesPanel.js:
     21        (WebInspector.ResourcesPanel.prototype.addMessageToResource): Call addMessage
     22        on the resource's view, if it is implemented.
     23        (WebInspector.ResourcesPanel.prototype.clearMessages): Call clearMessages
     24        on all the resource views for the ones that implement it.
     25        (WebInspector.ResourcesPanel.prototype.refreshResource): Call _resourceView
     26        to make the resource's view if needed. Use a local view variable.
     27        (WebInspector.ResourcesPanel.prototype._resourceView): Added helper function
     28        to create a resource view if needed.
     29        * page/inspector/SourceView.js:
     30        (WebInspector.SourceView.prototype.setupSourceFrameIfNeeded): Delete the
     31        _frameNeedsSetup property at the beginning to prevent recursion. Get the
     32        length of the messages array when assigning the local length variable.
     33        (WebInspector.SourceView.prototype.addMessage): Renamed from addMessageToSource.
     34        (WebInspector.SourceView.prototype.clearMessages): Added. Clear all the message
     35        bubbles that might be sprinkled in the source. Also clears the messages array.
     36        (WebInspector.SourceView.prototype._addMessageToSource): Create the image
     37        element in the Inspector's document so we can use relative image URLs. Then
     38        adopt the image element into the frame's document.
     39
    1402008-04-15  Brady Eidson  <beidson@apple.com>
    241
  • trunk/WebCore/css/view-source.css

    r31639 r31909  
    124124    -webkit-border-radius: 9px;
    125125    -webkit-border-fit: lines;
     126    min-height: 13px;
    126127    font-size: 9px;
    127128    font-family: Lucida Grande;
  • trunk/WebCore/page/inspector/Console.js

    r31889 r31909  
    136136    addMessage: function(msg)
    137137    {
    138 /*
    139         FIXME: Re-implement addMessageToSource in SourceView and ResourcesPanel.
    140138        if (msg.url in WebInspector.resourceURLMap) {
    141139            msg.resource = WebInspector.resourceURLMap[msg.url];
    142             switch (msg.level) {
    143                 case WebInspector.ConsoleMessage.MessageLevel.Warning:
    144                     ++msg.resource.warnings;
    145                     if (msg.resource.panel.addMessageToSource)
    146                         msg.resource.panel.addMessageToSource(msg);
    147                     break;
    148                 case WebInspector.ConsoleMessage.MessageLevel.Error:
    149                     ++msg.resource.errors;
    150                     if (msg.resource.panel.addMessageToSource)
    151                         msg.resource.panel.addMessageToSource(msg);
    152                     break;
    153             }
    154         }
    155 */
     140            WebInspector.panels.resources.addMessageToResource(msg.resource, msg);
     141        }
    156142
    157143        this.messages.push(msg);
     
    164150    clearMessages: function()
    165151    {
    166         for (var i = 0; i < this.messages.length; ++i) {
    167             var resource = this.messages[i].resource;
    168             if (!resource)
    169                 continue;
    170             resource.errors = 0;
    171             resource.warnings = 0;
    172         }
     152        WebInspector.panels.resources.clearMessages();
    173153
    174154        this.messages = [];
  • trunk/WebCore/page/inspector/ResourcesPanel.js

    r31885 r31909  
    261261    },
    262262
     263    addMessageToResource: function(resource, msg)
     264    {
     265        if (!resource)
     266            return;
     267
     268        var view = this._resourceView(resource);
     269        if (view.addMessage)
     270            view.addMessage(msg);
     271    },
     272
     273    clearMessages: function()
     274    {
     275        var resourcesLength = this._resources.length;
     276        for (var i = 0; i < resourcesLength; ++i) {
     277            var resource = this._resources[i];
     278            var view = resource._resourcesView;
     279            if (!view || !view.clearMessages)
     280                continue;
     281            view.clearMessages();
     282        }
     283    },
     284
    263285    refreshResource: function(resource, skipBoundaryUpdate, skipSort, immediate)
    264286    {
     
    309331            this.visibleResource._resourcesView.hide();
    310332
    311         if (!resource._resourcesView)
    312             resource._resourcesView = this._createResourceView(resource);
    313         resource._resourcesView.show();
    314 
    315         if (line && resource._resourcesView.showLine)
    316             resource._resourcesView.showLine(line);
     333        var view = this._resourceView(resource);
     334        view.show();
     335
     336        if (line && view.showLine)
     337            view.showLine(line);
    317338
    318339        if (resource._resourcesTreeElement) {
     
    849870    },
    850871
     872    _resourceView: function(resource)
     873    {
     874        if (!resource)
     875            return null;
     876        if (!resource._resourcesView)
     877            resource._resourcesView = this._createResourceView(resource);
     878        return resource._resourcesView;
     879    },
     880
    851881    _createResourceView: function(resource)
    852882    {
  • trunk/WebCore/page/inspector/SourceView.js

    r31885 r31909  
    5252    {
    5353        if (this._frameNeedsSetup) {
     54            delete this._frameNeedsSetup;
     55
    5456            this.attach();
    5557
     
    5759            WebInspector.addMainEventListeners(this.frameElement.contentDocument);
    5860
    59             var length = this.messages;
     61            var length = this.messages.length;
    6062            for (var i = 0; i < length; ++i)
    6163                this._addMessageToSource(this.messages[i]);
    62 
    63             delete this._frameNeedsSetup;
    6464        }
    6565    },
     
    9191    },
    9292
    93     addMessageToSource: function(msg)
     93    addMessage: function(msg)
    9494    {
    9595        this.messages.push(msg);
    9696        if (!this._frameNeedsSetup)
    9797            this._addMessageToSource(msg);
     98    },
     99
     100    clearMessages: function()
     101    {
     102        this.messages = [];
     103
     104        if (this._frameNeedsSetup)
     105            return;
     106
     107        var bubbles = this.frameElement.contentDocument.querySelectorAll(".webkit-html-message-bubble");
     108        if (!bubbles)
     109            return;
     110
     111        for (var i = 0; i < bubbles.length; ++i) {
     112            var bubble = bubbles[i];
     113            bubble.parentNode.removeChild(bubble);
     114        }
    98115    },
    99116
     
    130147        errorDiv.appendChild(lineDiv);
    131148
    132         var image = doc.createElement("img");
     149        // Create the image element in the Inspector's document so we can use relative image URLs.
     150        var image = document.createElement("img");
    133151        image.src = imageURL;
    134152        image.className = "webkit-html-message-icon";
     153
     154        // Adopt the image element since it wasn't created in doc.
     155        image = doc.adoptNode(image);
    135156        lineDiv.appendChild(image);
    136157
Note: See TracChangeset for help on using the changeset viewer.