Changeset 124778 in webkit


Ignore:
Timestamp:
Aug 6, 2012 9:39:56 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Protocol: Add "namedFlowCreated" and "namedFlowRemoved" events
https://bugs.webkit.org/show_bug.cgi?id=92739

Patch by Andrei Poenaru <poenaru@adobe.com> on 2012-08-06
Reviewed by Pavel Feldman.

Source/WebCore:

Implemented "namedFlowCreated" and "namedFlowRemoved" events.

Modified test: inspector/styles/protocol-css-regions-commands.html.

  • dom/WebKitNamedFlowCollection.cpp:

(WebCore::WebKitNamedFlowCollection::ensureFlowWithName):
(WebCore::WebKitNamedFlowCollection::discardNamedFlow):

  • inspector/Inspector.json:
  • inspector/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::reset):
(WebCore::InspectorCSSAgent::didCreateNamedFlow):
(WebCore):
(WebCore::InspectorCSSAgent::didRemoveNamedFlow):
(WebCore::InspectorCSSAgent::getNamedFlowCollection):

  • inspector/InspectorCSSAgent.h:

(InspectorCSSAgent):

  • inspector/InspectorInstrumentation.cpp:

(WebCore):
(WebCore::InspectorInstrumentation::didCreateNamedFlowImpl):
(WebCore::InspectorInstrumentation::didRemoveNamedFlowImpl):

  • inspector/InspectorInstrumentation.h:

(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::didCreateNamedFlow):
(WebCore):
(WebCore::InspectorInstrumentation::didRemoveNamedFlow):

  • inspector/front-end/CSSStyleModel.js:

(WebInspector.CSSStyleModel.prototype._namedFlowCreated.callback):
(WebInspector.CSSStyleModel.prototype._namedFlowCreated):
(WebInspector.CSSStyleModel.prototype._namedFlowRemoved.callback):
(WebInspector.CSSStyleModel.prototype._namedFlowRemoved):
(WebInspector.CSSDispatcher.prototype.styleSheetChanged):
(WebInspector.CSSDispatcher.prototype.namedFlowCreated):
(WebInspector.CSSDispatcher.prototype.namedFlowRemoved):

LayoutTests:

Modified test so that it validates the implemented events.

  • inspector/styles/protocol-css-regions-commands-expected.txt:
  • inspector/styles/protocol-css-regions-commands.html:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r124775 r124778  
     12012-08-06  Andrei Poenaru  <poenaru@adobe.com>
     2
     3        Web Inspector: Protocol: Add "namedFlowCreated" and "namedFlowRemoved" events
     4        https://bugs.webkit.org/show_bug.cgi?id=92739
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Modified test so that it validates the implemented events.
     9
     10        * inspector/styles/protocol-css-regions-commands-expected.txt:
     11        * inspector/styles/protocol-css-regions-commands.html:
     12
    1132012-08-06  Zan Dobersek  <zandobersek@gmail.com>
    214
  • trunk/LayoutTests/inspector/styles/protocol-css-regions-commands-expected.txt

    r123459 r124778  
    1 Tests the following commands:
     1Tests the following commands and events:
    22
    33getNamedFlowCollection Bug 91607
    44getFlowByName Bug 91855
     5namedFlowCreated Bug 92739
     6namedFlowRemoved Bug 92739
    57
    68
     
    2022There is no Named Flow "flow4" in the main document
    2123
     24Running: testNamedFlowCreated
     25NamedFlowCreated: "tmpNamedFlow"
     26
     27Running: testNamedFlowRemoved
     28NamedFlowRemoved: "tmpNamedFlow"
     29
  • trunk/LayoutTests/inspector/styles/protocol-css-regions-commands.html

    r123459 r124778  
    1717
    1818    runTest();
     19}
     20
     21function createNamedFlow()
     22{
     23    var article = document.createElement("article");
     24    article.id = "tmpArticle";
     25    article.style.webkitFlowInto = "tmpNamedFlow";
     26
     27    document.body.appendChild(article);
     28}
     29
     30function removeNamedFlow()
     31{
     32    var article = document.getElementById("tmpArticle");
     33
     34    document.body.removeChild(article);
    1935}
    2036
     
    100116            }
    101117        },
     118
     119        function testNamedFlowCreated(next)
     120        {
     121            WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.NamedFlowCreated, callback, this);
     122            InspectorTest.evaluateInPage("createNamedFlow()");
     123
     124            function callback(event)
     125            {
     126                WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowCreated, callback, this);
     127
     128                if (event.data.name !== "tmpNamedFlow") {
     129                    Inspector.addResult("[!] Failed");
     130                    InspectorTest.completeTest();
     131                    return;
     132                }
     133
     134                InspectorTest.addResult("NamedFlowCreated: \"tmpNamedFlow\"");
     135                next();
     136            }
     137        },
     138
     139        function testNamedFlowRemoved(next)
     140        {
     141            WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, callback, this);
     142            InspectorTest.evaluateInPage("removeNamedFlow()");
     143
     144            function callback(event)
     145            {
     146                WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, callback, this);
     147                if (event.data.name !== "tmpNamedFlow") {
     148                    Inspector.addResult("[!] Failed");
     149                    InspectorTest.completeTest();
     150                    return;
     151                }
     152
     153                InspectorTest.addResult("NamedFlowRemoved: \"tmpNamedFlow\"");
     154                next();
     155            }
     156        }
    102157    ]);
    103158}
     
    107162<body onload="createDynamicElements()">
    108163<p>
    109 Tests the following commands:
     164Tests the following commands and events:
    110165<ul>
    111166    <li>getNamedFlowCollection <a href="https://bugs.webkit.org/show_bug.cgi?id=91607">Bug 91607</a></li>
    112167    <li>getFlowByName <a href="https://bugs.webkit.org/show_bug.cgi?id=91855">Bug 91855</a></li>
     168    <li>namedFlowCreated <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li>
     169    <li>namedFlowRemoved <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li>
    113170</ul>
    114171</p>
  • trunk/Source/WebCore/ChangeLog

    r124776 r124778  
     12012-08-06  Andrei Poenaru  <poenaru@adobe.com>
     2
     3        Web Inspector: Protocol: Add "namedFlowCreated" and "namedFlowRemoved" events
     4        https://bugs.webkit.org/show_bug.cgi?id=92739
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Implemented "namedFlowCreated" and "namedFlowRemoved" events.
     9
     10        Modified test: inspector/styles/protocol-css-regions-commands.html.
     11
     12        * dom/WebKitNamedFlowCollection.cpp:
     13        (WebCore::WebKitNamedFlowCollection::ensureFlowWithName):
     14        (WebCore::WebKitNamedFlowCollection::discardNamedFlow):
     15        * inspector/Inspector.json:
     16        * inspector/InspectorCSSAgent.cpp:
     17        (WebCore::InspectorCSSAgent::reset):
     18        (WebCore::InspectorCSSAgent::didCreateNamedFlow):
     19        (WebCore):
     20        (WebCore::InspectorCSSAgent::didRemoveNamedFlow):
     21        (WebCore::InspectorCSSAgent::getNamedFlowCollection):
     22        * inspector/InspectorCSSAgent.h:
     23        (InspectorCSSAgent):
     24        * inspector/InspectorInstrumentation.cpp:
     25        (WebCore):
     26        (WebCore::InspectorInstrumentation::didCreateNamedFlowImpl):
     27        (WebCore::InspectorInstrumentation::didRemoveNamedFlowImpl):
     28        * inspector/InspectorInstrumentation.h:
     29        (InspectorInstrumentation):
     30        (WebCore::InspectorInstrumentation::didCreateNamedFlow):
     31        (WebCore):
     32        (WebCore::InspectorInstrumentation::didRemoveNamedFlow):
     33        * inspector/front-end/CSSStyleModel.js:
     34        (WebInspector.CSSStyleModel.prototype._namedFlowCreated.callback):
     35        (WebInspector.CSSStyleModel.prototype._namedFlowCreated):
     36        (WebInspector.CSSStyleModel.prototype._namedFlowRemoved.callback):
     37        (WebInspector.CSSStyleModel.prototype._namedFlowRemoved):
     38        (WebInspector.CSSDispatcher.prototype.styleSheetChanged):
     39        (WebInspector.CSSDispatcher.prototype.namedFlowCreated):
     40        (WebInspector.CSSDispatcher.prototype.namedFlowRemoved):
     41
    1422012-08-06  Abhishek Arya  <inferno@chromium.org>
    243
  • trunk/Source/WebCore/dom/WebKitNamedFlowCollection.cpp

    r123205 r124778  
    3232
    3333#include "Document.h"
     34#include "InspectorInstrumentation.h"
    3435#include "WebKitNamedFlow.h"
    3536
     
    8081    m_namedFlows.add(newFlow.get());
    8182
     83    InspectorInstrumentation::didCreateNamedFlow(m_document, newFlow->name());
     84
    8285    return newFlow.release();
    8386}
     
    9396
    9497    m_namedFlows.remove(namedFlow);
     98
     99    InspectorInstrumentation::didRemoveNamedFlow(m_document, namedFlow->name());
    95100}
    96101
  • trunk/Source/WebCore/inspector/Inspector.json

    r124765 r124778  
    23742374                ],
    23752375                "description": "Fired whenever a stylesheet is changed as a result of the client operation."
     2376            },
     2377            {
     2378                "name": "namedFlowCreated",
     2379                "parameters": [
     2380                    { "name": "nodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
     2381                    { "name": "namedFlow", "type": "string", "description": "Identifier of the new Named Flow." }
     2382                ],
     2383                "description": "Fires when a Named Flow is created.",
     2384                "hidden": true
     2385            },
     2386            {
     2387                "name": "namedFlowRemoved",
     2388                "parameters": [
     2389                    { "name": "nodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
     2390                    { "name": "namedFlow", "type": "string", "description": "Identifier of the removed Named Flow." }
     2391                ],
     2392                "description": "Fires when a Named Flow is removed: has no associated content nodes and regions.",
     2393                "hidden": true
    23762394            }
    23772395        ]
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r124760 r124778  
    517517    m_nodeToInspectorStyleSheet.clear();
    518518    m_documentToInspectorStyleSheet.clear();
     519    m_namedFlowCollectionsRequested.clear();
    519520    resetPseudoStates();
    520521}
     
    534535    if (m_frontend)
    535536        m_frontend->mediaQueryResultChanged();
     537}
     538
     539void InspectorCSSAgent::didCreateNamedFlow(Document* document, const AtomicString& name)
     540{
     541    int nodeId = m_domAgent->boundNodeId(document);
     542    if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId))
     543        return;
     544
     545    m_frontend->namedFlowCreated(nodeId, name.string());
     546}
     547
     548void InspectorCSSAgent::didRemoveNamedFlow(Document* document, const AtomicString& name)
     549{
     550    int nodeId = m_domAgent->boundNodeId(document);
     551    if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId))
     552        return;
     553
     554    m_frontend->namedFlowRemoved(nodeId, name.string());
    536555}
    537556
     
    812831        return;
    813832
     833    m_namedFlowCollectionsRequested.add(nodeId);
     834
    814835    Vector<String> namedFlowsVector = document->namedFlows()->namedFlowsNames();
    815836    RefPtr<TypeBuilder::Array<String> > namedFlows = TypeBuilder::Array<String>::create();
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.h

    r123612 r124778  
    3737
    3838#include <wtf/HashMap.h>
     39#include <wtf/HashSet.h>
    3940#include <wtf/PassRefPtr.h>
    4041#include <wtf/RefPtr.h>
     
    9899    void reset();
    99100    void mediaQueryResultChanged();
     101    void didCreateNamedFlow(Document*, const AtomicString& name);
     102    void didRemoveNamedFlow(Document*, const AtomicString& name);
    100103
    101104    virtual void getComputedStyleForNode(ErrorString*, int nodeId, const RefPtr<InspectorArray>* forcedPseudoClasses, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >&);
     
    170173    DocumentToViaInspectorStyleSheet m_documentToInspectorStyleSheet;
    171174    NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState;
     175    HashSet<int> m_namedFlowCollectionsRequested;
    172176
    173177    int m_lastStyleSheetId;
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r124484 r124778  
    233233}
    234234
     235void InspectorInstrumentation::didCreateNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)
     236{
     237    if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
     238        cssAgent->didCreateNamedFlow(document, name);
     239}
     240
     241void InspectorInstrumentation::didRemoveNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)
     242{
     243    if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
     244        cssAgent->didRemoveNamedFlow(document, name);
     245}
     246
    235247void InspectorInstrumentation::mouseDidMoveOverElementImpl(InstrumentingAgents* instrumentingAgents, const HitTestResult& result, unsigned modifierFlags)
    236248{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r124484 r124778  
    114114    static void didPushShadowRoot(Element* host, ShadowRoot*);
    115115    static void willPopShadowRoot(Element* host, ShadowRoot*);
     116    static void didCreateNamedFlow(Document*, const AtomicString& name);
     117    static void didRemoveNamedFlow(Document*, const AtomicString& name);
    116118
    117119    static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags);
     
    291293    static void didPushShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
    292294    static void willPopShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
     295    static void didCreateNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
     296    static void didRemoveNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
    293297
    294298    static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags);
     
    558562}
    559563
     564inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, const AtomicString& name)
     565{
     566#if ENABLE(INSPECTOR)
     567    FAST_RETURN_IF_NO_FRONTENDS(void());
     568    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
     569        didCreateNamedFlowImpl(instrumentingAgents, document, name);
     570#endif
     571}
     572
     573inline void InspectorInstrumentation::didRemoveNamedFlow(Document* document, const AtomicString& name)
     574{
     575#if ENABLE(INSPECTOR)
     576    FAST_RETURN_IF_NO_FRONTENDS(void());
     577    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
     578        didRemoveNamedFlowImpl(instrumentingAgents, document, name);
     579#endif
     580}
     581
    560582inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const HitTestResult& result, unsigned modifierFlags)
    561583{
  • trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js

    r123768 r124778  
    5757WebInspector.CSSStyleModel.Events = {
    5858    StyleSheetChanged: "StyleSheetChanged",
    59     MediaQueryResultChanged: "MediaQueryResultChanged"
     59    MediaQueryResultChanged: "MediaQueryResultChanged",
     60    NamedFlowCreated: "NamedFlowCreated",
     61    NamedFlowRemoved: "NamedFlowRemoved"
    6062}
    6163
     
    338340
    339341        this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged, { styleSheetId: styleSheetId, majorChange: majorChange });
     342    },
     343
     344    /**
     345     * @param {DOMAgent.NodeId} documentNodeId
     346     * @param {string} name
     347     */
     348    _namedFlowCreated: function(documentNodeId, name)
     349    {
     350        if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated))
     351            return;
     352
     353        /**
     354        * @param {WebInspector.DOMDocument} root
     355        */
     356        function callback(root)
     357        {
     358            // FIXME: At the moment we only want support for NamedFlows in the main document
     359            if (documentNodeId !== root.id)
     360                return;
     361
     362            this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated, { documentNodeId: documentNodeId, name: name });
     363        }
     364
     365        WebInspector.domAgent.requestDocument(callback.bind(this));
     366    },
     367
     368    /**
     369     * @param {DOMAgent.NodeId} documentNodeId
     370     * @param {string} name
     371     */
     372    _namedFlowRemoved: function(documentNodeId, name)
     373    {
     374        if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved))
     375            return;
     376
     377        /**
     378        * @param {WebInspector.DOMDocument} root
     379        */
     380        function callback(root)
     381        {
     382            // FIXME: At the moment we only want support for NamedFlows in the main document
     383            if (documentNodeId !== root.id)
     384                return;
     385
     386            this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, { documentNodeId: documentNodeId, name: name });
     387        }
     388
     389        WebInspector.domAgent.requestDocument(callback.bind(this));
    340390    },
    341391
     
    12661316    {
    12671317        this._cssModel._fireStyleSheetChanged(styleSheetId);
     1318    },
     1319
     1320    /**
     1321     * @param {DOMAgent.NodeId} documentNodeId
     1322     * @param {string} name
     1323     */
     1324    namedFlowCreated: function(documentNodeId, name)
     1325    {
     1326        this._cssModel._namedFlowCreated(documentNodeId, name);
     1327    },
     1328
     1329    /**
     1330     * @param {DOMAgent.NodeId} documentNodeId
     1331     * @param {string} name
     1332     */
     1333    namedFlowRemoved: function(documentNodeId, name)
     1334    {
     1335        this._cssModel._namedFlowRemoved(documentNodeId, name);
    12681336    }
    12691337}
Note: See TracChangeset for help on using the changeset viewer.