Changeset 158854 in webkit


Ignore:
Timestamp:
Nov 7, 2013 10:05:55 AM (10 years ago)
Author:
Alexandru Chiculita
Message:

Web Inspector: CSS Regions: Removing a content node of a ContentFlow from the DOM will send a 0 nodeId
https://bugs.webkit.org/show_bug.cgi?id=123577

Source/WebCore:

Reviewed by Timothy Hatcher.

Test: inspector-protocol/model/content-flow-content-removal.html

Do not send unregister events for the content nodes of a flow when the element is not part of the DOM
anymore. We already send an unbind event, so the inspector is already notified that the node was removed.

  • inspector/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):

Source/WebInspectorUI:

Reviewed by Timothy Hatcher.

Fixed the content node removal from the content flow.

  • UserInterface/ContentFlowTreeContentView.js:
  • UserInterface/DOMTreeManager.js:

(WebInspector.DOMTreeManager):
(WebInspector.DOMTreeManager.prototype._createContentFlowFromPayload): Registered all the content nodes
in the _contentNodesToFlowsMap.
(WebInspector.DOMTreeManager.prototype._unbind): Added call to _removeContentNodeFromFlowIfNeeded.
(WebInspector.DOMTreeManager.prototype._removeContentNodeFromFlowIfNeeded): Called from _unbind to check
and remove a node from it's parent content flow if needed.
(WebInspector.DOMTreeManager.prototype.unregisteredNamedFlowContentElement):

LayoutTests:

Reviewed by Timothy Hatcher.

Added test to check that the notification that an element was removed from the ContentFlow is handled
correctly in the WebInspector even if the element is not part of the DOM anymore.

  • inspector-protocol/model/content-flow-content-removal-expected.txt: Added.
  • inspector-protocol/model/content-flow-content-removal.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r158853 r158854  
     12013-11-07  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        Web Inspector: CSS Regions: Removing a content node of a ContentFlow from the DOM will send a 0 nodeId
     4        https://bugs.webkit.org/show_bug.cgi?id=123577
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Added test to check that the notification that an element was removed from the ContentFlow is handled
     9        correctly in the WebInspector even if the element is not part of the DOM anymore.
     10
     11        * inspector-protocol/model/content-flow-content-removal-expected.txt: Added.
     12        * inspector-protocol/model/content-flow-content-removal.html: Added.
     13
    1142013-10-24  Jer Noble  <jer.noble@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r158853 r158854  
     12013-11-07  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        Web Inspector: CSS Regions: Removing a content node of a ContentFlow from the DOM will send a 0 nodeId
     4        https://bugs.webkit.org/show_bug.cgi?id=123577
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Test: inspector-protocol/model/content-flow-content-removal.html
     9
     10        Do not send unregister events for the content nodes of a flow when the element is not part of the DOM
     11        anymore. We already send an unbind event, so the inspector is already notified that the node was removed.
     12
     13        * inspector/InspectorCSSAgent.cpp:
     14        (WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):
     15
    1162013-10-30  Jer Noble  <jer.noble@apple.com>
    217
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r158415 r158854  
    776776    ErrorString errorString;
    777777    int contentElementNodeId = m_domAgent->pushNodeToFrontend(&errorString, documentNodeId, contentElement);
     778    if (!contentElementNodeId) {
     779        // We've already notified that the DOM node was removed from the DOM, so there's no need to send another event.
     780        return;
     781    }
    778782    m_frontend->unregisteredNamedFlowContentElement(documentNodeId, namedFlow->name().string(), contentElementNodeId);
    779783}
  • trunk/Source/WebInspectorUI/ChangeLog

    r158816 r158854  
     12013-11-07  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        Web Inspector: CSS Regions: Removing a content node of a ContentFlow from the DOM will send a 0 nodeId
     4        https://bugs.webkit.org/show_bug.cgi?id=123577
     5
     6        Reviewed by  Timothy Hatcher.
     7
     8        Fixed the content node removal from the content flow.
     9
     10        * UserInterface/ContentFlowTreeContentView.js:
     11        * UserInterface/DOMTreeManager.js:
     12        (WebInspector.DOMTreeManager):
     13        (WebInspector.DOMTreeManager.prototype._createContentFlowFromPayload): Registered all the content nodes
     14        in the _contentNodesToFlowsMap.
     15        (WebInspector.DOMTreeManager.prototype._unbind): Added call to _removeContentNodeFromFlowIfNeeded.
     16        (WebInspector.DOMTreeManager.prototype._removeContentNodeFromFlowIfNeeded): Called from _unbind to check
     17        and remove a node from it's parent content flow if needed.
     18        (WebInspector.DOMTreeManager.prototype.unregisteredNamedFlowContentElement):
     19
    1202013-11-06  Timothy Hatcher  <timothy@apple.com>
    221
  • trunk/Source/WebInspectorUI/UserInterface/ContentFlowTreeContentView.js

    r158788 r158854  
    184184        contentNodeOutline.element.remove();
    185185
    186         this._nodesMap.remove(event.data.node.id);
     186        this._nodesMap.delete(event.data.node.id);
    187187    }
    188188};
  • trunk/Source/WebInspectorUI/UserInterface/DOMTreeManager.js

    r158159 r158854  
    4141    this._attributeLoadNodeIds = {};
    4242    this._flows = {};
     43    this._contentNodesToFlowsMap = new Map;
    4344}
    4445
     
    338339    _unbind: function(node)
    339340    {
     341        this._removeContentNodeFromFlowIfNeeded(node);
     342
    340343        delete this._idToDOMNode[node.id];
    341344        for (var i = 0; node.children && i < node.children.length; ++i)
     
    537540    {
    538541        // FIXME: Collect the regions from the payload.
    539         return new WebInspector.ContentFlow(flowPayload.documentNodeId, flowPayload.name, flowPayload.overset, flowPayload.content.map(this.nodeForId.bind(this)));
     542        var flow = new WebInspector.ContentFlow(flowPayload.documentNodeId, flowPayload.name, flowPayload.overset, flowPayload.content.map(this.nodeForId.bind(this)));
     543
     544        for (var contentNode of flow.contentNodes) {
     545            console.assert(!this._contentNodesToFlowsMap.has(contentNode.id));
     546            this._contentNodesToFlowsMap.set(contentNode.id, flow);
     547        }
     548
     549        return flow;
    540550    },
    541551
     
    558568                return;
    559569            }
     570            this._contentNodesToFlowsMap.clear();
    560571            var contentFlows = [];
    561572            for (var i = 0; i < flows.length; ++i) {
     
    615626        var flowKey = WebInspector.DOMTreeManager._flowPayloadHashKey({documentNodeId: documentNodeIdentifier, name: flowName});
    616627        console.assert(this._flows.hasOwnProperty(flowKey));
     628        console.assert(!this._contentNodesToFlowsMap.has(contentNodeId));
    617629
    618630        var flow = this._flows[flowKey];
    619631        var contentNode = this.nodeForId(contentNodeId);
     632
     633        this._contentNodesToFlowsMap.set(contentNode.id, flow);
    620634
    621635        if (nextContentElementNodeId)
     
    625639    },
    626640
     641    _removeContentNodeFromFlowIfNeeded: function(node)
     642    {
     643        if (!this._contentNodesToFlowsMap.has(node.id))
     644            return;
     645        var flow = this._contentNodesToFlowsMap.get(node.id);
     646        this._contentNodesToFlowsMap.delete(node.id);
     647        flow.removeContentNode(node);
     648    },
     649
    627650    unregisteredNamedFlowContentElement: function(documentNodeIdentifier, flowName, contentNodeId)
    628651    {
    629         var flowKey = WebInspector.DOMTreeManager._flowPayloadHashKey({documentNodeId: documentNodeIdentifier, name: flowName});
    630         console.assert(this._flows.hasOwnProperty(flowKey));
    631         this._flows[flowKey].removeContentNode(this.nodeForId(contentNodeId));
     652        console.assert(this._contentNodesToFlowsMap.has(contentNodeId));
     653
     654        var flow = this._contentNodesToFlowsMap.get(contentNodeId);
     655        console.assert(flow.id === WebInspector.DOMTreeManager._flowPayloadHashKey({documentNodeId: documentNodeIdentifier, name: flowName}));
     656
     657        this._contentNodesToFlowsMap.delete(contentNodeId);
     658        flow.removeContentNode(this.nodeForId(contentNodeId));
    632659    }
    633660}
Note: See TracChangeset for help on using the changeset viewer.