Changeset 127700 in webkit


Ignore:
Timestamp:
Sep 5, 2012 11:48:50 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Protocol Extension: Add "regionLayoutUpdate" event
https://bugs.webkit.org/show_bug.cgi?id=93443

Patch by Andrei Poenaru <poenaru@adobe.com> on 2012-09-05
Reviewed by Alexander Pavlov.

Source/WebCore:

Added "regionLayoutUpdate" event to the protocol.

Removed "getFlowByName" from protocol.

The front-end keeps in sync the requested Named Flow Collections.

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

  • dom/NamedFlowCollection.cpp:

(WebCore::NamedFlowCollection::ensureFlowWithName):
(WebCore::NamedFlowCollection::discardNamedFlow):

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

(UpdateRegionLayoutTask):
(WebCore::UpdateRegionLayoutTask::reset):
(WebCore):
(WebCore::UpdateRegionLayoutTask::UpdateRegionLayoutTask):
(WebCore::UpdateRegionLayoutTask::scheduleFor):
(WebCore::UpdateRegionLayoutTask::onTimer):
(WebCore::InspectorCSSAgent::reset):
(WebCore::InspectorCSSAgent::didCreateNamedFlow):
(WebCore::InspectorCSSAgent::willRemoveNamedFlow):
(WebCore::InspectorCSSAgent::didUpdateRegionLayout):
(WebCore::InspectorCSSAgent::regionLayoutUpdated):
(WebCore::InspectorCSSAgent::getNamedFlowCollection):
(WebCore::InspectorCSSAgent::documentNodeWithRequestedFlowsId):

  • inspector/InspectorCSSAgent.h:

(WebCore):
(InspectorCSSAgent):

  • inspector/InspectorInstrumentation.cpp:

(WebCore):
(WebCore::InspectorInstrumentation::didCreateNamedFlowImpl):
(WebCore::InspectorInstrumentation::willRemoveNamedFlowImpl):
(WebCore::InspectorInstrumentation::didUpdateRegionLayoutImpl):

  • inspector/InspectorInstrumentation.h:

(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::didCreateNamedFlow):
(WebCore::InspectorInstrumentation::willRemoveNamedFlow):
(WebCore):
(WebCore::InspectorInstrumentation::didUpdateRegionLayout):

  • inspector/front-end/CSSStyleModel.js:

(WebInspector.CSSStyleModel):
(WebInspector.CSSStyleModel.prototype.getNamedFlowCollectionAsync.callback):
(WebInspector.CSSStyleModel.prototype.getNamedFlowCollectionAsync):
(WebInspector.CSSStyleModel.prototype.getFlowByNameAsync.callback):
(WebInspector.CSSStyleModel.prototype.getFlowByNameAsync):
(WebInspector.CSSStyleModel.prototype._namedFlowCreated):
(WebInspector.CSSStyleModel.prototype._namedFlowRemoved):
(WebInspector.CSSStyleModel.prototype._regionLayoutUpdated):
(WebInspector.CSSStyleModel.prototype._resetNamedFlowCollections):
(WebInspector.CSSDispatcher.prototype.namedFlowCreated):
(WebInspector.CSSDispatcher.prototype.namedFlowRemoved):
(WebInspector.CSSDispatcher.prototype.regionLayoutUpdated):
(WebInspector.NamedFlow):
(WebInspector.NamedFlowCollection):
(WebInspector.NamedFlowCollection.prototype.appendNamedFlow):
(WebInspector.NamedFlowCollection.prototype.removeNamedFlow):
(WebInspector.NamedFlowCollection.prototype.flowByName):

  • rendering/RenderNamedFlowThread.cpp:

(WebCore::RenderNamedFlowThread::dispatchRegionLayoutUpdateEvent):

LayoutTests:

Validate "regionLayoutUpdate" event.

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127698 r127700  
     12012-09-05  Andrei Poenaru  <poenaru@adobe.com>
     2
     3        Web Inspector: Protocol Extension: Add "regionLayoutUpdate" event
     4        https://bugs.webkit.org/show_bug.cgi?id=93443
     5
     6        Reviewed by Alexander Pavlov.
     7
     8        Validate "regionLayoutUpdate" event.
     9
     10        * inspector/styles/protocol-css-regions-commands-expected.txt:
     11        * inspector/styles/protocol-css-regions-commands.html:
     12
    1132012-09-03  Geoffrey Garen  <ggaren@apple.com>
    214
  • trunk/LayoutTests/inspector/styles/protocol-css-regions-commands-expected.txt

    r127500 r127700  
    55namedFlowCreated Bug 92739
    66namedFlowRemoved Bug 92739
     7regionLayoutUpdated Bug 93443
     8This text is from CSS Named Flow "flow3".
    79
    810
    9 Running: testGetNamedFlowCollection1
     11Running: testGetNamedFlowCollection
    1012=== CSS Named Flows in main document ===
    1113* Named Flow "flow1"
     
    1921Regions: 1
    2022
    21 Running: testGetNamedFlowCollection2
     23Running: testGetNamedFlowCollectionWithInvalidDocument
    2224=== CSS Named Flows in #fake-document ===
    2325#fake-document is not a document
    2426
    25 Running: testGetFlowByName1
     27Running: testGetFlowByName
    2628=== Named Flow "flow2" from main document ===
    2729* Named Flow "flow2"
     
    2931Regions: 2
    3032
    31 Running: testGetFlowByName2
     33Running: testGetFlowByNameWithInvalidName
    3234=== Name Flow "flow4" from main document ===
    3335There is no Named Flow "flow4" in the main document
     
    3638NamedFlowCreated: "tmpNamedFlow"
    3739
     40Running: testRegionLayoutUpdated
     41RegionLayoutUpdated: "flow3"
     42
    3843Running: testNamedFlowRemoved
    3944NamedFlowRemoved: "tmpNamedFlow"
  • trunk/LayoutTests/inspector/styles/protocol-css-regions-commands.html

    r127500 r127700  
    2222{
    2323    var article = document.createElement("article");
     24    var div = document.createElement("div");
     25
    2426    article.id = "tmpArticle";
    25     article.style.webkitFlowInto = "tmpNamedFlow";
     27    article.style["-webkit-flow-into"] = "tmpNamedFlow";
     28    article.textContent = "This text is from CSS Named Flow \"tmpNamedFlow\"";
     29
     30    div.id = "tmpDiv";
     31    div.style["-webkit-flow-from"] = "tmpNamedFlow";
     32    div.style["height"] = "5px";
     33    div.style["width"] = "20px";
    2634
    2735    document.body.appendChild(article);
     36    document.body.appendChild(div);
    2837}
    2938
    3039function removeNamedFlow()
    3140{
    32     var article = document.getElementById("tmpArticle");
    33 
    34     document.body.removeChild(article);
     41    document.body.removeChild(document.getElementById("tmpArticle"));
     42    document.body.removeChild(document.getElementById("tmpDiv"));
    3543}
    3644
     
    3947    WebInspector.showPanel("elements");
    4048    InspectorTest.runTestSuite([
    41         function testGetNamedFlowCollection1(next)
     49        function testGetNamedFlowCollection(next)
    4250        {
    4351            WebInspector.domAgent.requestDocument(documentCallback);
     
    4856            }
    4957
    50             function namedFlowCallback(namedFlows)
     58            function namedFlowCallback(namedFlowMap)
    5159            {
    5260                InspectorTest.addResult("=== CSS Named Flows in main document ===");
    5361
    54                 if (!namedFlows) {
     62                if (!namedFlowMap) {
    5563                    InspectorTest.addResult("[!] Failed to get Named Flows");
    5664                    InspectorTest.completeTest();
    5765                    return;
    5866                }
     67
     68                namedFlows = [];
     69                for (var flowName in namedFlowMap)
     70                    namedFlows.push(namedFlowMap[flowName]);
    5971
    6072                namedFlows.sort(function (nf1, nf2) {
     
    6981        },
    7082
    71         function testGetNamedFlowCollection2(next)
     83        function testGetNamedFlowCollectionWithInvalidDocument(next)
    7284        {
    7385            WebInspector.domAgent.requestDocument(documentCallback);
     
    8395            }
    8496
    85             function namedFlowCallback(namedFlows)
     97            function namedFlowCallback(namedFlowMap)
    8698            {
    8799                InspectorTest.addResult("=== CSS Named Flows in #fake-document ===");
    88100
    89                 if (namedFlows) {
     101                if (namedFlowMap) {
    90102                    InspectorTest.addResult("[!] Failed");
    91103                    InspectorTest.completeTest();
     
    98110        },
    99111
    100         function testGetFlowByName1(next)
     112        function testGetFlowByName(next)
    101113        {
    102114            WebInspector.domAgent.requestDocument(documentCallback);
     
    123135        },
    124136
    125         function testGetFlowByName2(next)
     137        function testGetFlowByNameWithInvalidName(next)
    126138        {
    127139            WebInspector.domAgent.requestDocument(documentCallback);
     
    154166            function callback(event)
    155167            {
     168                if (event.data.name !== "tmpNamedFlow")
     169                    return;
     170
    156171                WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowCreated, callback, this);
    157172
    158                 if (event.data.name !== "tmpNamedFlow") {
    159                     Inspector.addResult("[!] Failed");
    160                     InspectorTest.completeTest();
    161                     return;
    162                 }
    163 
    164173                InspectorTest.addResult("NamedFlowCreated: \"tmpNamedFlow\"");
     174                next();
     175            }
     176        },
     177
     178        function testRegionLayoutUpdated(next)
     179        {
     180            WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.RegionLayoutUpdated, callback, this);
     181            InspectorTest.evaluateInPage("document.getElementById(\"region3\").style[\"width\"] = \"200px\"");
     182
     183            function callback(event)
     184            {
     185                if (event.data.name !== "flow3")
     186                    return;
     187
     188                WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.RegionLayoutUpdated, callback, this);
     189
     190                InspectorTest.addResult("RegionLayoutUpdated: \"flow3\"");
    165191                next();
    166192            }
     
    174200            function callback(event)
    175201            {
     202                if (event.data.flowName !== "tmpNamedFlow")
     203                    return;
     204
    176205                WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, callback, this);
    177                 if (event.data.name !== "tmpNamedFlow") {
    178                     Inspector.addResult("[!] Failed");
    179                     InspectorTest.completeTest();
    180                     return;
    181                 }
    182206
    183207                InspectorTest.addResult("NamedFlowRemoved: \"tmpNamedFlow\"");
     
    205229    <li>namedFlowCreated <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li>
    206230    <li>namedFlowRemoved <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li>
     231    <li>regionLayoutUpdated <a href="https://bugs.webkit.org/show_bug.cgi?id=93443">Bug 93443</a></li>
    207232</ul>
    208233</p>
     
    217242<div style="-webkit-flow-from: flow2"></div>
    218243
    219 <article style="-webkit-flow-into: flow3"></article>
    220 <div style="-webkit-flow-from: flow3"></div>
     244<article style="-webkit-flow-into: flow3">
     245    This text is from CSS Named Flow "flow3".
     246</article>
     247<div id="region3" style="-webkit-flow-from: flow3; height: 20px; width: 5px"></div>
    221248
    222249<div id="fake-document"></div>
  • trunk/Source/WebCore/ChangeLog

    r127699 r127700  
     12012-09-05  Andrei Poenaru  <poenaru@adobe.com>
     2
     3        Web Inspector: Protocol Extension: Add "regionLayoutUpdate" event
     4        https://bugs.webkit.org/show_bug.cgi?id=93443
     5
     6        Reviewed by Alexander Pavlov.
     7
     8        Added "regionLayoutUpdate" event to the protocol.
     9
     10        Removed "getFlowByName" from protocol.
     11
     12        The front-end keeps in sync the requested Named Flow Collections.
     13
     14        Modified existing test: inspector/styles/protocol-css-regions-commands.html
     15
     16        * dom/NamedFlowCollection.cpp:
     17        (WebCore::NamedFlowCollection::ensureFlowWithName):
     18        (WebCore::NamedFlowCollection::discardNamedFlow):
     19        * inspector/Inspector.json:
     20        * inspector/InspectorCSSAgent.cpp:
     21        (UpdateRegionLayoutTask):
     22        (WebCore::UpdateRegionLayoutTask::reset):
     23        (WebCore):
     24        (WebCore::UpdateRegionLayoutTask::UpdateRegionLayoutTask):
     25        (WebCore::UpdateRegionLayoutTask::scheduleFor):
     26        (WebCore::UpdateRegionLayoutTask::onTimer):
     27        (WebCore::InspectorCSSAgent::reset):
     28        (WebCore::InspectorCSSAgent::didCreateNamedFlow):
     29        (WebCore::InspectorCSSAgent::willRemoveNamedFlow):
     30        (WebCore::InspectorCSSAgent::didUpdateRegionLayout):
     31        (WebCore::InspectorCSSAgent::regionLayoutUpdated):
     32        (WebCore::InspectorCSSAgent::getNamedFlowCollection):
     33        (WebCore::InspectorCSSAgent::documentNodeWithRequestedFlowsId):
     34        * inspector/InspectorCSSAgent.h:
     35        (WebCore):
     36        (InspectorCSSAgent):
     37        * inspector/InspectorInstrumentation.cpp:
     38        (WebCore):
     39        (WebCore::InspectorInstrumentation::didCreateNamedFlowImpl):
     40        (WebCore::InspectorInstrumentation::willRemoveNamedFlowImpl):
     41        (WebCore::InspectorInstrumentation::didUpdateRegionLayoutImpl):
     42        * inspector/InspectorInstrumentation.h:
     43        (InspectorInstrumentation):
     44        (WebCore::InspectorInstrumentation::didCreateNamedFlow):
     45        (WebCore::InspectorInstrumentation::willRemoveNamedFlow):
     46        (WebCore):
     47        (WebCore::InspectorInstrumentation::didUpdateRegionLayout):
     48        * inspector/front-end/CSSStyleModel.js:
     49        (WebInspector.CSSStyleModel):
     50        (WebInspector.CSSStyleModel.prototype.getNamedFlowCollectionAsync.callback):
     51        (WebInspector.CSSStyleModel.prototype.getNamedFlowCollectionAsync):
     52        (WebInspector.CSSStyleModel.prototype.getFlowByNameAsync.callback):
     53        (WebInspector.CSSStyleModel.prototype.getFlowByNameAsync):
     54        (WebInspector.CSSStyleModel.prototype._namedFlowCreated):
     55        (WebInspector.CSSStyleModel.prototype._namedFlowRemoved):
     56        (WebInspector.CSSStyleModel.prototype._regionLayoutUpdated):
     57        (WebInspector.CSSStyleModel.prototype._resetNamedFlowCollections):
     58        (WebInspector.CSSDispatcher.prototype.namedFlowCreated):
     59        (WebInspector.CSSDispatcher.prototype.namedFlowRemoved):
     60        (WebInspector.CSSDispatcher.prototype.regionLayoutUpdated):
     61        (WebInspector.NamedFlow):
     62        (WebInspector.NamedFlowCollection):
     63        (WebInspector.NamedFlowCollection.prototype.appendNamedFlow):
     64        (WebInspector.NamedFlowCollection.prototype.removeNamedFlow):
     65        (WebInspector.NamedFlowCollection.prototype.flowByName):
     66        * rendering/RenderNamedFlowThread.cpp:
     67        (WebCore::RenderNamedFlowThread::dispatchRegionLayoutUpdateEvent):
     68
    1692012-09-05  Dana Jansens  <danakj@chromium.org>
    270
  • trunk/Source/WebCore/dom/NamedFlowCollection.cpp

    r127500 r127700  
    8282    m_namedFlows.add(newFlow.get());
    8383
    84     InspectorInstrumentation::didCreateNamedFlow(m_document, newFlow->name());
     84    InspectorInstrumentation::didCreateNamedFlow(m_document, newFlow.get());
    8585
    8686    return newFlow.release();
     
    9696    ASSERT(m_namedFlows.contains(namedFlow));
    9797
     98    InspectorInstrumentation::willRemoveNamedFlow(m_document, namedFlow);
     99
    98100    m_namedFlows.remove(namedFlow);
    99 
    100     InspectorInstrumentation::didRemoveNamedFlow(m_document, namedFlow->name());
    101101}
    102102
  • trunk/Source/WebCore/inspector/Inspector.json

    r127500 r127700  
    24132413                "description": "Returns the Named Flows from the document.",
    24142414                "hidden": true
    2415             },
    2416             {
    2417                 "name": "getFlowByName",
    2418                 "parameters": [
    2419                     { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
    2420                     { "name": "name", "type": "string", "description": "Named Flow identifier." }
    2421                 ],
    2422                 "returns": [
    2423                     { "name": "namedFlow", "$ref": "NamedFlow", "description": "A Named Flow." }
    2424                 ],
    2425                 "description": "Returns the Named Flow identified by the given name",
    2426                 "hidden": true
    24272415            }
    24282416        ],
     
    24422430                "name": "namedFlowCreated",
    24432431                "parameters": [
     2432                    { "name": "namedFlow", "$ref": "NamedFlow", "description": "The new Named Flow." }
     2433                ],
     2434                "description": "Fires when a Named Flow is created.",
     2435                "hidden": true
     2436            },
     2437            {
     2438                "name": "namedFlowRemoved",
     2439                "parameters": [
    24442440                    { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
    2445                     { "name": "namedFlow", "type": "string", "description": "Identifier of the new Named Flow." }
    2446                 ],
    2447                 "description": "Fires when a Named Flow is created.",
    2448                 "hidden": true
    2449             },
    2450             {
    2451                 "name": "namedFlowRemoved",
    2452                 "parameters": [
    2453                     { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
    2454                     { "name": "namedFlow", "type": "string", "description": "Identifier of the removed Named Flow." }
     2441                    { "name": "flowName", "type": "string", "description": "Identifier of the removed Named Flow." }
    24552442                ],
    24562443                "description": "Fires when a Named Flow is removed: has no associated content nodes and regions.",
     2444                "hidden": true
     2445            },
     2446            {
     2447                "name": "regionLayoutUpdated",
     2448                "parameters": [
     2449                    { "name": "namedFlow", "$ref": "NamedFlow", "description": "The Named Flow whose layout may have changed." }
     2450                ],
     2451                "description": "Fires when a Named Flow's layout may have changed.",
    24572452                "hidden": true
    24582453            }
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r127500 r127700  
    227227}
    228228
     229class UpdateRegionLayoutTask {
     230public:
     231    UpdateRegionLayoutTask(InspectorCSSAgent*);
     232    void scheduleFor(WebKitNamedFlow*, int documentNodeId);
     233    void reset() { m_timer.stop(); }
     234    void onTimer(Timer<UpdateRegionLayoutTask>*);
     235
     236private:
     237    InspectorCSSAgent* m_cssAgent;
     238    Timer<UpdateRegionLayoutTask> m_timer;
     239    HashMap<WebKitNamedFlow*, int> m_namedFlows;
     240};
     241
     242UpdateRegionLayoutTask::UpdateRegionLayoutTask(InspectorCSSAgent* cssAgent)
     243    : m_cssAgent(cssAgent)
     244    , m_timer(this, &UpdateRegionLayoutTask::onTimer)
     245{
     246}
     247
     248void UpdateRegionLayoutTask::scheduleFor(WebKitNamedFlow* namedFlow, int documentNodeId)
     249{
     250    m_namedFlows.add(namedFlow, documentNodeId);
     251
     252    if (!m_timer.isActive())
     253        m_timer.startOneShot(0);
     254}
     255
     256void UpdateRegionLayoutTask::onTimer(Timer<UpdateRegionLayoutTask>*)
     257{
     258    // The timer is stopped on m_cssAgent destruction, so this method will never be called after m_cssAgent has been destroyed.
     259    for (HashMap<WebKitNamedFlow*, int>::iterator it = m_namedFlows.begin(), end = m_namedFlows.end(); it != end; ++it)
     260        m_cssAgent->regionLayoutUpdated(it->first, it->second);
     261
     262    m_namedFlows.clear();
     263}
     264
    229265class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action {
    230266    WTF_MAKE_NONCOPYABLE(StyleSheetAction);
     
    519555    m_documentToInspectorStyleSheet.clear();
    520556    m_namedFlowCollectionsRequested.clear();
     557    if (m_updateRegionLayoutTask)
     558        m_updateRegionLayoutTask->reset();
    521559    resetPseudoStates();
    522560}
     
    538576}
    539577
    540 void InspectorCSSAgent::didCreateNamedFlow(Document* document, const AtomicString& name)
    541 {
    542     int nodeId = m_domAgent->boundNodeId(document);
    543     if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId))
    544         return;
    545 
    546     m_frontend->namedFlowCreated(nodeId, name.string());
    547 }
    548 
    549 void InspectorCSSAgent::didRemoveNamedFlow(Document* document, const AtomicString& name)
    550 {
    551     int nodeId = m_domAgent->boundNodeId(document);
    552     if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId))
    553         return;
    554 
    555     m_frontend->namedFlowRemoved(nodeId, name.string());
     578void InspectorCSSAgent::didCreateNamedFlow(Document* document, WebKitNamedFlow* namedFlow)
     579{
     580    int documentNodeId = documentNodeWithRequestedFlowsId(document);
     581    if (!documentNodeId)
     582        return;
     583
     584    ErrorString errorString;
     585    m_frontend->namedFlowCreated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
     586}
     587
     588void InspectorCSSAgent::willRemoveNamedFlow(Document* document, WebKitNamedFlow* namedFlow)
     589{
     590    int documentNodeId = documentNodeWithRequestedFlowsId(document);
     591    if (!documentNodeId)
     592        return;
     593
     594    m_frontend->namedFlowRemoved(documentNodeId, namedFlow->name().string());
     595}
     596
     597void InspectorCSSAgent::didUpdateRegionLayout(Document* document, WebKitNamedFlow* namedFlow)
     598{
     599    int documentNodeId = documentNodeWithRequestedFlowsId(document);
     600    if (!documentNodeId)
     601        return;
     602
     603    if (!m_updateRegionLayoutTask)
     604        m_updateRegionLayoutTask = adoptPtr(new UpdateRegionLayoutTask(this));
     605    m_updateRegionLayoutTask->scheduleFor(namedFlow, documentNodeId);
     606}
     607
     608void InspectorCSSAgent::regionLayoutUpdated(WebKitNamedFlow* namedFlow, int documentNodeId)
     609{
     610    if (namedFlow->flowState() == WebKitNamedFlow::FlowStateNull)
     611        return;
     612
     613    ErrorString errorString;
     614    m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
    556615}
    557616
     
    829888
    830889    m_namedFlowCollectionsRequested.add(documentNodeId);
     890
    831891    Vector<RefPtr<WebKitNamedFlow> > namedFlowsVector = document->namedFlows()->namedFlows();
    832892    RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> > namedFlows = TypeBuilder::Array<TypeBuilder::CSS::NamedFlow>::create();
    833893
    834 
    835894    for (Vector<RefPtr<WebKitNamedFlow> >::iterator it = namedFlowsVector.begin(); it != namedFlowsVector.end(); ++it)
    836895        namedFlows->addItem(buildObjectForNamedFlow(errorString, it->get(), documentNodeId));
    837896
    838897    result = namedFlows.release();
    839 }
    840 
    841 void InspectorCSSAgent::getFlowByName(ErrorString* errorString, int documentNodeId, const String& flowName, RefPtr<TypeBuilder::CSS::NamedFlow>& result)
    842 {
    843     Document* document = m_domAgent->assertDocument(errorString, documentNodeId);
    844     if (!document)
    845         return;
    846 
    847     WebKitNamedFlow* webkitNamedFlow = document->namedFlows()->flowByName(flowName);
    848     if (!webkitNamedFlow) {
    849         *errorString = "No target CSS Named Flow found";
    850         return;
    851     }
    852 
    853     RefPtr<WebKitNamedFlow> protector(webkitNamedFlow);
    854     result = buildObjectForNamedFlow(errorString, webkitNamedFlow, documentNodeId);
    855898}
    856899
     
    932975    }
    933976    return toElement(node);
     977}
     978
     979int InspectorCSSAgent::documentNodeWithRequestedFlowsId(Document* document)
     980{
     981    int documentNodeId = m_domAgent->boundNodeId(document);
     982    if (!documentNodeId || !m_namedFlowCollectionsRequested.contains(documentNodeId))
     983        return 0;
     984
     985    return documentNodeId;
    934986}
    935987
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.h

    r127500 r127700  
    5656class SelectorProfile;
    5757class StyleResolver;
     58class UpdateRegionLayoutTask;
    5859
    5960#if ENABLE(INSPECTOR)
     
    100101    void reset();
    101102    void mediaQueryResultChanged();
    102     void didCreateNamedFlow(Document*, const AtomicString& name);
    103     void didRemoveNamedFlow(Document*, const AtomicString& name);
     103    void didCreateNamedFlow(Document*, WebKitNamedFlow*);
     104    void willRemoveNamedFlow(Document*, WebKitNamedFlow*);
     105    void didUpdateRegionLayout(Document*, WebKitNamedFlow*);
     106    void regionLayoutUpdated(WebKitNamedFlow*, int documentNodeId);
    104107
    105108    virtual void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >&);
     
    117120    virtual void forcePseudoState(ErrorString*, int nodeId, const RefPtr<InspectorArray>& forcedPseudoClasses);
    118121    virtual void getNamedFlowCollection(ErrorString*, int documentNodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result);
    119     virtual void getFlowByName(ErrorString*, int documentNodeId, const String& flowName, RefPtr<TypeBuilder::CSS::NamedFlow>& result);
    120122
    121123    virtual void startSelectorProfiler(ErrorString*);
     
    146148    InspectorStyleSheetForInlineStyle* asInspectorStyleSheet(Element* element);
    147149    Element* elementForId(ErrorString*, int nodeId);
     150    int documentNodeWithRequestedFlowsId(Document*);
    148151    void collectStyleSheets(CSSStyleSheet*, TypeBuilder::Array<WebCore::TypeBuilder::CSS::CSSStyleSheetHeader>*);
    149152
     
    177180    NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState;
    178181    HashSet<int> m_namedFlowCollectionsRequested;
     182    OwnPtr<UpdateRegionLayoutTask> m_updateRegionLayoutTask;
    179183
    180184    int m_lastStyleSheetId;
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r127500 r127700  
    232232}
    233233
    234 void InspectorInstrumentation::didCreateNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)
     234void InspectorInstrumentation::didCreateNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow)
    235235{
    236236    if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
    237         cssAgent->didCreateNamedFlow(document, name);
    238 }
    239 
    240 void InspectorInstrumentation::didRemoveNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)
     237        cssAgent->didCreateNamedFlow(document, namedFlow);
     238}
     239
     240void InspectorInstrumentation::willRemoveNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow)
    241241{
    242242    if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
    243         cssAgent->didRemoveNamedFlow(document, name);
     243        cssAgent->willRemoveNamedFlow(document, namedFlow);
     244}
     245
     246void InspectorInstrumentation::didUpdateRegionLayoutImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow)
     247{
     248    if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
     249        cssAgent->didUpdateRegionLayout(document, namedFlow);
    244250}
    245251
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r127500 r127700  
    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);
     116    static void didCreateNamedFlow(Document*, WebKitNamedFlow*);
     117    static void willRemoveNamedFlow(Document*, WebKitNamedFlow*);
     118    static void didUpdateRegionLayout(Document*, WebKitNamedFlow*);
    118119
    119120    static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags);
     
    291292    static void didPushShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
    292293    static void willPopShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
    293     static void didCreateNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
    294     static void didRemoveNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
     294    static void didCreateNamedFlowImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*);
     295    static void willRemoveNamedFlowImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*);
     296    static void didUpdateRegionLayoutImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*);
    295297
    296298    static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags);
     
    562564}
    563565
    564 inline 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 
    573 inline 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);
     566inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, WebKitNamedFlow* namedFlow)
     567{
     568#if ENABLE(INSPECTOR)
     569    FAST_RETURN_IF_NO_FRONTENDS(void());
     570    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
     571        didCreateNamedFlowImpl(instrumentingAgents, document, namedFlow);
     572#endif
     573}
     574
     575inline void InspectorInstrumentation::willRemoveNamedFlow(Document* document, WebKitNamedFlow* namedFlow)
     576{
     577#if ENABLE(INSPECTOR)
     578    FAST_RETURN_IF_NO_FRONTENDS(void());
     579    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
     580        willRemoveNamedFlowImpl(instrumentingAgents, document, namedFlow);
     581#endif
     582}
     583
     584inline void InspectorInstrumentation::didUpdateRegionLayout(Document* document, WebKitNamedFlow* namedFlow)
     585{
     586#if ENABLE(INSPECTOR)
     587    FAST_RETURN_IF_NO_FRONTENDS(void());
     588    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
     589        didUpdateRegionLayoutImpl(instrumentingAgents, document, namedFlow);
    579590#endif
    580591}
  • trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js

    r127500 r127700  
    4040    WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoCompleted, this._undoRedoCompleted, this);
    4141    this._resourceBinding = new WebInspector.CSSStyleModelResourceBinding(this);
     42    this._namedFlowCollections = {};
     43    WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._resetNamedFlowCollections, this);
    4244    InspectorBackend.registerCSSDispatcher(new WebInspector.CSSDispatcher(this));
    4345    CSSAgent.enable();
     
    5961    MediaQueryResultChanged: "MediaQueryResultChanged",
    6062    NamedFlowCreated: "NamedFlowCreated",
    61     NamedFlowRemoved: "NamedFlowRemoved"
     63    NamedFlowRemoved: "NamedFlowRemoved",
     64    RegionLayoutUpdated: "RegionLayoutUpdated"
    6265}
    6366
     
    173176    /**
    174177     * @param {DOMAgent.NodeId} nodeId
    175      * @param {function(?Array.<WebInspector.NamedFlow>)} userCallback
    176      */
    177     getNamedFlowCollectionAsync: function(nodeId, userCallback)
    178     {
     178     * @param {function(Object)} userCallback
     179     */
     180    getNamedFlowCollectionAsync: function(documentNodeId, userCallback)
     181    {
     182        var namedFlowCollection = this._namedFlowCollections[documentNodeId];
     183        if (namedFlowCollection) {
     184            userCallback(namedFlowCollection.namedFlowMap);
     185            return;
     186        }
     187
    179188        /**
    180189         * @param {function(?Array.<WebInspector.NamedFlow>)} userCallback
     
    186195            if (error || !namedFlowPayload)
    187196                userCallback(null);
    188             else
    189                 userCallback(WebInspector.NamedFlow.parsePayloadArray(namedFlowPayload));
    190         }
    191 
    192         CSSAgent.getNamedFlowCollection(nodeId, callback.bind(this, userCallback));
     197            else {
     198                var namedFlowCollection = new WebInspector.NamedFlowCollection(namedFlowPayload);
     199                this._namedFlowCollections[documentNodeId] = namedFlowCollection;
     200                userCallback(namedFlowCollection.namedFlowMap);
     201            }
     202        }
     203
     204        CSSAgent.getNamedFlowCollection(documentNodeId, callback.bind(this, userCallback));
    193205    },
    194206
     
    198210     * @param {function(?WebInspector.NamedFlow)} userCallback
    199211     */
    200     getFlowByNameAsync: function(nodeId, flowName, userCallback)
    201     {
     212    getFlowByNameAsync: function(documentNodeId, flowName, userCallback)
     213    {
     214        var namedFlowCollection = this._namedFlowCollections[documentNodeId];
     215        if (namedFlowCollection) {
     216            userCallback(namedFlowCollection.flowByName(flowName));
     217            return;
     218        }
     219
    202220        /**
    203221         * @param {function(?WebInspector.NamedFlow)} userCallback
    204          * @param {?Protocol.Error} error
    205          * @param {?CSSAgent.NamedFlow=} namedFlowPayload
    206          */
    207         function callback(userCallback, error, namedFlowPayload)
    208         {
    209             if (error || !namedFlowPayload)
     222         * @param {?CSSAgent.NamedFlow=} namedFlowMap
     223         */
     224        function callback(userCallback, namedFlowMap)
     225        {
     226            if (error || !namedFlowMap)
    210227                userCallback(null);
    211228            else
    212                 userCallback(WebInspector.NamedFlow.parsePayload(namedFlowPayload));
    213         }
    214 
    215         CSSAgent.getFlowByName(nodeId, flowName, callback.bind(this, userCallback));
     229                userCallback(this._namedFlowCollections[documentNodeId].flowByName(flowName));
     230        }
     231
     232        this.getNamedFlowCollectionAsync(documentNodeId, callback.bind(this, userCallback));
    216233    },
    217234
     
    351368
    352369    /**
     370     * @param {CSSAgent.NamedFlow} namedFlowPayload
     371     */
     372    _namedFlowCreated: function(namedFlowPayload)
     373    {
     374        var namedFlow = WebInspector.NamedFlow.parsePayload(namedFlowPayload);
     375        var namedFlowCollection = this._namedFlowCollections[namedFlow.documentNodeId];
     376
     377        if (!namedFlowCollection)
     378            return;
     379
     380        namedFlowCollection.appendNamedFlow(namedFlow);
     381        this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated, namedFlow);
     382    },
     383
     384    /**
    353385     * @param {DOMAgent.NodeId} documentNodeId
    354      * @param {string} name
    355      */
    356     _namedFlowCreated: function(documentNodeId, name)
    357     {
    358         if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated))
     386     * @param {string} flowName
     387     */
     388    _namedFlowRemoved: function(documentNodeId, flowName)
     389    {
     390        var namedFlowCollection = this._namedFlowCollections[documentNodeId];
     391
     392        if (!namedFlowCollection)
    359393            return;
    360394
    361         /**
    362         * @param {WebInspector.DOMDocument} root
    363         */
    364         function callback(root)
    365         {
    366             // FIXME: At the moment we only want support for NamedFlows in the main document
    367             if (documentNodeId !== root.id)
    368                 return;
    369 
    370             this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated, { documentNodeId: documentNodeId, name: name });
    371         }
    372 
    373         WebInspector.domAgent.requestDocument(callback.bind(this));
    374     },
    375 
    376     /**
    377      * @param {DOMAgent.NodeId} documentNodeId
    378      * @param {string} name
    379      */
    380     _namedFlowRemoved: function(documentNodeId, name)
    381     {
    382         if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved))
     395        namedFlowCollection.removeNamedFlow(flowName);
     396        this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, { documentNodeId: documentNodeId, flowName: flowName });
     397    },
     398
     399    /**
     400     * @param {CSSAgent.NamedFlow} namedFlowPayload
     401     */
     402    _regionLayoutUpdated: function(namedFlowPayload)
     403    {
     404        var namedFlow = WebInspector.NamedFlow.parsePayload(namedFlowPayload);
     405        var namedFlowCollection = this._namedFlowCollections[namedFlow.documentNodeId];
     406
     407        if (!namedFlowCollection)
    383408            return;
    384409
    385         /**
    386         * @param {WebInspector.DOMDocument} root
    387         */
    388         function callback(root)
    389         {
    390             // FIXME: At the moment we only want support for NamedFlows in the main document
    391             if (documentNodeId !== root.id)
    392                 return;
    393 
    394             this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, { documentNodeId: documentNodeId, name: name });
    395         }
    396 
    397         WebInspector.domAgent.requestDocument(callback.bind(this));
     410        namedFlowCollection.appendNamedFlow(namedFlow);
     411        this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.RegionLayoutUpdated, namedFlow);
    398412    },
    399413
     
    462476    {
    463477        this._sourceMappings = {};
     478    },
     479
     480    _resetNamedFlowCollections: function()
     481    {
     482        this._namedFlowCollections = {};
    464483    },
    465484
     
    13271346
    13281347    /**
     1348     * @param {CSSAgent.NamedFlow} namedFlowPayload
     1349     */
     1350    namedFlowCreated: function(namedFlowPayload)
     1351    {
     1352        this._cssModel._namedFlowCreated(namedFlowPayload);
     1353    },
     1354
     1355    /**
    13291356     * @param {DOMAgent.NodeId} documentNodeId
    1330      * @param {string} name
    1331      */
    1332     namedFlowCreated: function(documentNodeId, name)
    1333     {
    1334         this._cssModel._namedFlowCreated(documentNodeId, name);
    1335     },
    1336 
    1337     /**
    1338      * @param {DOMAgent.NodeId} documentNodeId
    1339      * @param {string} name
    1340      */
    1341     namedFlowRemoved: function(documentNodeId, name)
    1342     {
    1343         this._cssModel._namedFlowRemoved(documentNodeId, name);
     1357     * @param {string} flowName
     1358     */
     1359    namedFlowRemoved: function(documentNodeId, flowName)
     1360    {
     1361        this._cssModel._namedFlowRemoved(documentNodeId, flowName);
     1362    },
     1363
     1364    /**
     1365     * @param {CSSAgent.NamedFlow} namedFlowPayload
     1366     */
     1367    regionLayoutUpdated: function(namedFlowPayload)
     1368    {
     1369        this._cssModel._regionLayoutUpdated(namedFlowPayload);
    13441370    }
    13451371}
     
    13511377WebInspector.NamedFlow = function(payload)
    13521378{
    1353     this.nodeId = payload.documentNodeId;
     1379    this.documentNodeId = payload.documentNodeId;
    13541380    this.name = payload.name;
    13551381    this.overset = payload.overset;
     
    13681394
    13691395/**
    1370  * @param {?Array.<CSSAgent.NamedFlow>=} namedFlowPayload
    1371  * @return {?Array.<WebInspector.NamedFlow>}
    1372  */
    1373 WebInspector.NamedFlow.parsePayloadArray = function(namedFlowPayload)
    1374 {
    1375     if (!namedFlowPayload)
    1376         return null;
    1377 
    1378     var parsedArray = [];
    1379     for (var i = 0; i < namedFlowPayload.length; ++i)
    1380         parsedArray[i] = WebInspector.NamedFlow.parsePayload(namedFlowPayload[i]);
    1381     return parsedArray;
    1382 }
    1383 
     1396 * @constructor
     1397 * @param {Array.<CSSAgent.NamedFlow>} payload
     1398 */
     1399WebInspector.NamedFlowCollection = function(payload)
     1400{
     1401    this.namedFlowMap = {};
     1402
     1403    for (var i = 0; i < payload.length; ++i) {
     1404        var namedFlow = WebInspector.NamedFlow.parsePayload(payload[i]);
     1405        this.namedFlowMap[namedFlow.name] = namedFlow;
     1406    }
     1407}
     1408
     1409WebInspector.NamedFlowCollection.prototype = {
     1410    /**
     1411     * @param {WebInspector.NamedFlow} namedFlow
     1412     */
     1413    appendNamedFlow: function(namedFlow)
     1414    {
     1415        this.namedFlowMap[namedFlow.name] = namedFlow;
     1416    },
     1417
     1418    /**
     1419     * @param {string} flowName
     1420     */
     1421    removeNamedFlow: function(flowName)
     1422    {
     1423        delete this.namedFlowMap[flowName];
     1424    },
     1425
     1426    /**
     1427     * @param {string} flowName
     1428     * @return {WebInspector.NamedFlow}
     1429     */
     1430    flowByName: function(flowName)
     1431    {
     1432        var namedFlow = this.namedFlowMap[flowName];
     1433
     1434        if (!namedFlow)
     1435            return null;
     1436        return namedFlow;
     1437    }
     1438}
    13841439/**
    13851440 * @type {WebInspector.CSSStyleModel}
  • trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp

    r127500 r127700  
    2828
    2929#include "FlowThreadController.h"
     30#include "InspectorInstrumentation.h"
    3031#include "RenderRegion.h"
    3132#include "RenderView.h"
     
    358359{
    359360    RenderFlowThread::dispatchRegionLayoutUpdateEvent();
     361    InspectorInstrumentation::didUpdateRegionLayout(document(), m_namedFlow.get());
    360362
    361363    if (!m_regionLayoutUpdateEventTimer.isActive() && m_namedFlow->hasEventListeners())
Note: See TracChangeset for help on using the changeset viewer.