~ubuntu-branches/ubuntu/lucid/webkit/lucid-updates

« back to all changes in this revision

Viewing changes to WebCore/inspector/InspectorDOMAgent.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2010-01-06 21:25:06 UTC
  • mfrom: (1.2.6 upstream) (4.3.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100106212506-gd0czn4zrwf1j19l
* New upstream release
- adds basic Content-Encoding support, thanks to soup
  (Closes: #529271)
- fixes over-advertising content types as supported by
  the media player (Closes: #559420)
* debian/control:
- updated libsoup build requirement (>= 2.28.2)
* debian/libwebkit-1.0-2.symbols:
- updated with new symbols
* debian/copyright:
- updated information since 1.1.17
* Imported patch from https://bugs.webkit.org/show_bug.cgi?id=30623
- I am shipping this patch because I believe it is correct, it is the
  way to go, it fixes a race, and it needs testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "CookieJar.h"
40
40
#include "DOMWindow.h"
41
41
#include "Document.h"
 
42
#include "DocumentType.h"
42
43
#include "Event.h"
43
44
#include "EventListener.h"
44
45
#include "EventNames.h"
68
69
 
69
70
InspectorDOMAgent::~InspectorDOMAgent()
70
71
{
71
 
    setDocument(0);
 
72
    reset();
72
73
}
73
74
 
74
 
void InspectorDOMAgent::setDocument(Document* doc)
 
75
void InspectorDOMAgent::reset()
75
76
{
76
 
    if (doc == mainFrameDocument())
77
 
        return;
78
77
    discardBindings();
79
78
 
80
79
    ListHashSet<RefPtr<Document> > copy = m_documents;
82
81
        stopListening((*it).get());
83
82
 
84
83
    ASSERT(!m_documents.size());
 
84
}
 
85
 
 
86
void InspectorDOMAgent::setDocument(Document* doc)
 
87
{
 
88
    if (doc == mainFrameDocument())
 
89
        return;
 
90
 
 
91
    reset();
85
92
 
86
93
    if (doc) {
87
94
        startListening(doc);
88
 
        if (doc->documentElement()) {
 
95
        if (doc->documentElement())
89
96
            pushDocumentToFrontend();
90
 
        }
91
 
    }
 
97
    } else
 
98
        m_frontend->setDocument(ScriptObject());
92
99
}
93
100
 
94
101
void InspectorDOMAgent::releaseDanglingNodes()
239
246
    }
240
247
}
241
248
 
242
 
void InspectorDOMAgent::pushDocumentToFrontend()
 
249
bool InspectorDOMAgent::pushDocumentToFrontend()
243
250
{
244
251
    Document* document = mainFrameDocument();
 
252
    if (!document)
 
253
        return false;
245
254
    if (!m_documentNodeToIdMap.contains(document))
246
255
        m_frontend->setDocument(buildObjectForNode(document, 2, &m_documentNodeToIdMap));
 
256
    return true;
247
257
}
248
258
 
249
259
void InspectorDOMAgent::pushChildNodesToFrontend(long nodeId)
279
289
    return 0;
280
290
}
281
291
 
 
292
Node* InspectorDOMAgent::nodeForPath(const String& path)
 
293
{
 
294
    // The path is of form "1,HTML,2,BODY,1,DIV"
 
295
    Node* node = mainFrameDocument();
 
296
    if (!node)
 
297
        return 0;
 
298
 
 
299
    Vector<String> pathTokens;
 
300
    path.split(",", false, pathTokens);
 
301
    for (size_t i = 0; i < pathTokens.size() - 1; i += 2) {
 
302
        bool success = true;
 
303
        unsigned childNumber = pathTokens[i].toUInt(&success);
 
304
        if (!success)
 
305
            return 0;
 
306
        if (childNumber >= innerChildNodeCount(node))
 
307
            return 0;
 
308
 
 
309
        Node* child = innerFirstChild(node);
 
310
        String childName = pathTokens[i + 1];
 
311
        for (size_t j = 0; child && j < childNumber; ++j)
 
312
            child = innerNextSibling(child);
 
313
 
 
314
        if (!child || child->nodeName() != childName)
 
315
            return 0;
 
316
        node = child;
 
317
    }
 
318
    return node;
 
319
}
 
320
 
282
321
void InspectorDOMAgent::getChildNodes(long callId, long nodeId)
283
322
{
284
323
    pushChildNodesToFrontend(nodeId);
290
329
    ASSERT(nodeToPush);  // Invalid input
291
330
 
292
331
    // If we are sending information to the client that is currently being created. Send root node first.
293
 
    pushDocumentToFrontend();
 
332
    if (!pushDocumentToFrontend())
 
333
        return 0;
294
334
 
295
335
    // Return id in case the node is known.
296
336
    long result = m_documentNodeToIdMap.get(nodeToPush);
483
523
        if (children.length() > 0)
484
524
            value.set("children", children);
485
525
    }
 
526
    if (node->nodeType() == Node::DOCUMENT_TYPE_NODE) {
 
527
        DocumentType* docType = static_cast<DocumentType*>(node);
 
528
        value.set("publicId", docType->publicId());
 
529
        value.set("systemId", docType->systemId());
 
530
        value.set("internalSubset", docType->internalSubset());
 
531
    }
486
532
    return value;
487
533
}
488
534
 
570
616
    return node;
571
617
}
572
618
 
573
 
int InspectorDOMAgent::innerChildNodeCount(Node* node)
 
619
unsigned InspectorDOMAgent::innerChildNodeCount(Node* node)
574
620
{
575
 
    int count = 0;
 
621
    unsigned count = 0;
576
622
    Node* child = innerFirstChild(node);
577
623
    while (child) {
578
624
        count++;