Commit 4b23f436 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org
Browse files

2011-02-24 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: move querySelectorAll from CSS agent to DOM agent where it belongs.
        https://bugs.webkit.org/show_bug.cgi?id=55131

        * http/tests/inspector/inspector-test.js:
        * inspector/elements/dom-agent-query-selector-expected.txt: Added.
        * inspector/elements/dom-agent-query-selector.html: Added.
2011-02-24  Pavel Feldman  <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: move querySelectorAll from CSS agent to DOM agent where it belongs.
        https://bugs.webkit.org/show_bug.cgi?id=55131

        Test: inspector/elements/dom-agent-query-selector.html

        * inspector/Inspector.idl:
        * inspector/InspectorCSSAgent.cpp:
        * inspector/InspectorCSSAgent.h:
        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::nodeToSelectOn):
        (WebCore::InspectorDOMAgent::querySelector):
        (WebCore::InspectorDOMAgent::querySelectorAll):
        * inspector/InspectorDOMAgent.h:
        * inspector/front-end/AuditRules.js:
        (WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun):
        * inspector/front-end/CSSStyleModel.js:
        (WebInspector.CSSStyleModel.prototype.setRuleSelector.callback):
        (WebInspector.CSSStyleModel.prototype.setRuleSelector):
        (WebInspector.CSSStyleModel.prototype.addRule.callback):
        (WebInspector.CSSStyleModel.prototype.addRule):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79583 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 83a1e4ac
2011-02-24 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: move querySelectorAll from CSS agent to DOM agent where it belongs.
https://bugs.webkit.org/show_bug.cgi?id=55131
* http/tests/inspector/inspector-test.js:
* inspector/elements/dom-agent-query-selector-expected.txt: Added.
* inspector/elements/dom-agent-query-selector.html: Added.
2011-02-24 Eric Seidel <eric@webkit.org>
Reviewed by Adam Barth.
Fragment parsing does not need to use HTMLSourceTracker
https://bugs.webkit.org/show_bug.cgi?id=55011
Remove support of XSS-filtering innerHTML content.
* http/tests/security/xssAuditor/dom-write-innerHTML-expected.txt:
2011-02-24 Pavel Feldman <pfeldman@chromium.org>
Not reviewed: beautified inspector test suite output.
* http/tests/inspector/debugger-test.js:
(initialize_DebuggerTest.InspectorTest.runDebuggerTestSuite.runner):
(initialize_DebuggerTest.InspectorTest.runDebuggerTestSuite):
* http/tests/inspector/inspector-test.js:
(initialize_InspectorTest.InspectorTest.runTestSuite.runner):
(initialize_InspectorTest.InspectorTest.runTestSuite):
* inspector/debugger/source-frame-expected.txt:
* inspector/elements/insert-node-collapsed-expected.txt:
* inspector/elements/insert-node-expected.txt:
* inspector/elements/modify-chardata-expected.txt:
* inspector/elements/remove-node-expected.txt:
* inspector/elements/set-attribute-expected.txt:
2011-02-24 Adam Roben <aroben@apple.com>
 
Update Windows XP test results after r78846
......
Tests DOMAgent.querySelector and DOMAgent.querySelectorAll.
Running: testDocumentQuerySelector
node id: id1
Running: testDocumentQuerySelectorAll
node id: id1
node id: id2
node id: id3
node id: id4
node id: id5
node id: id6
Running: testQuerySelector
node id: id3
Running: testQuerySelectorAll
node id: id3
node id: id4
node id: id5
node id: id6
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>
function test()
{
InspectorTest.selectNodeWithId("container", step1);
function step1(node)
{
var containerId = node.id;
InspectorTest.runTestSuite([
function testDocumentQuerySelector(next)
{
DOMAgent.querySelector(containerId, "div.foo", true, dumpNodes.bind(null, next));
},
function testDocumentQuerySelectorAll(next)
{
DOMAgent.querySelectorAll(containerId, "div.foo", true, dumpNodes.bind(null, next));
},
function testQuerySelector(next)
{
DOMAgent.querySelector(containerId, "div.foo", false, dumpNodes.bind(null, next));
},
function testQuerySelectorAll(next)
{
DOMAgent.querySelectorAll(containerId, "div.foo", false, dumpNodes.bind(null, next));
}
]);
}
function dumpNodes(next, nodeIds)
{
if (!(nodeIds instanceof Array))
nodeIds = [nodeIds];
for (var i = 0; i < nodeIds.length; ++i) {
var node = WebInspector.domAgent.nodeForId(nodeIds[i]);
InspectorTest.addResult("node id: " + node.getAttribute("id"));
}
next();
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests DOMAgent.querySelector and DOMAgent.querySelectorAll.
</p>
<div id="id1" class="foo"></div>
<div id="id2" class="foo"></div>
<div id="container">
<div id="id3" class="foo"></div>
<div id="id4" class="foo"></div>
<div id="id5" class="foo"></div>
<div id="id6" class="foo"></div>
</div>
</body>
</html>
2011-02-24 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: move querySelectorAll from CSS agent to DOM agent where it belongs.
https://bugs.webkit.org/show_bug.cgi?id=55131
Test: inspector/elements/dom-agent-query-selector.html
* inspector/Inspector.idl:
* inspector/InspectorCSSAgent.cpp:
* inspector/InspectorCSSAgent.h:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::nodeToSelectOn):
(WebCore::InspectorDOMAgent::querySelector):
(WebCore::InspectorDOMAgent::querySelectorAll):
* inspector/InspectorDOMAgent.h:
* inspector/front-end/AuditRules.js:
(WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun):
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel.prototype.setRuleSelector.callback):
(WebInspector.CSSStyleModel.prototype.setRuleSelector):
(WebInspector.CSSStyleModel.prototype.addRule.callback):
(WebInspector.CSSStyleModel.prototype.addRule):
2011-02-24 Eric Seidel <eric@webkit.org>
Reviewed by Adam Barth.
Fragment parsing does not need to use HTMLSourceTracker
https://bugs.webkit.org/show_bug.cgi?id=55011
Any performance gains from this patch are likely
the result of working around:
https://bugs.webkit.org/show_bug.cgi?id=55005
(Which suggests that fixing bug 55005 will speed
up normal HTML parsing substantially.)
Assuming I ran the numbers correct, here is the
change from PerformanceTests/Parser/tiny-innerHTML:
Before patch:
avg 5586.1
median 5594
stdev 41.295157101045135
min 5425
max 5633
After Patch:
avg 2603.9
median 2609.5
stdev 32.500615378789355
min 2475
max 2649
Removing just the HTMLSourceTracker calls brought our
score from 5500 to 5200, removing the XSSFilter as well
brought it to 2600 on my machine.
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::HTMLDocumentParser):
(WebCore::HTMLDocumentParser::pumpTokenizer):
* html/parser/HTMLDocumentParser.h:
2011-02-24 Amruth Raj <amruthraj@motorola.com> and Ravi Phaneendra Kasibhatla <ravi.kasibhatla@motorola.com> and Alejandro G. Castro <alex@igalia.com>
Reviewed by Martin Robinson.
......
......@@ -146,6 +146,8 @@ module core {
interface [Conditional=INSPECTOR] DOM {
void getChildNodes(in long nodeId);
void querySelector(in long nodeId, in String selectors, in boolean documentWide, out long elementId);
void querySelectorAll(in long nodeId, in String selectors, in boolean documentWide, out Array result);
void setAttribute(in long elementId, in String name, in String value, out boolean success);
void removeAttribute(in long elementId, in String name, out boolean success);
void setTextNodeValue(in long nodeId, in String value, out boolean success);
......@@ -187,7 +189,6 @@ module core {
void setRuleSelector(in Object ruleId, in String selector, out Value rule);
void addRule(in long contextNodeId, in String selector, out Value rule);
void getSupportedCSSProperties(out Array cssProperties);
void querySelectorAll(in long documentId, in String selector, out Array result);
};
interface [Conditional=INSPECTOR] Timeline {
......
......@@ -361,26 +361,6 @@ void InspectorCSSAgent::getSupportedCSSProperties(ErrorString*, RefPtr<Inspector
*cssProperties = properties.release();
}
void InspectorCSSAgent::querySelectorAll(ErrorString*, const long nodeId, const String& selector, RefPtr<InspectorArray>* result)
{
Node* node = m_domAgent->nodeForId(nodeId);
if (!node)
return;
if (!node->isDocumentNode())
node = node->ownerDocument();
if (!node)
return;
ExceptionCode ec = 0;
RefPtr<NodeList> nodes = static_cast<Document*>(node)->querySelectorAll(selector, ec);
if (ec)
return;
for (unsigned i = 0; i < nodes->length(); ++i) {
Node* affectedNode = nodes->item(i);
long id = m_domAgent->pushNodePathToFrontend(affectedNode);
(*result)->pushNumber(id);
}
}
// static
Element* InspectorCSSAgent::inlineStyleElement(CSSStyleDeclaration* style)
{
......
......@@ -71,7 +71,6 @@ public:
void setRuleSelector(ErrorString* error, const RefPtr<InspectorObject>& ruleId, const String& selector, RefPtr<InspectorValue>* result);
void addRule(ErrorString* error, const long contextNodeId, const String& selector, RefPtr<InspectorValue>* result);
void getSupportedCSSProperties(ErrorString* error, RefPtr<InspectorArray>* result);
void querySelectorAll(ErrorString* error, const long nodeId, const String& selector, RefPtr<InspectorArray>* result);
private:
typedef HashMap<String, RefPtr<InspectorStyleSheet> > IdToInspectorStyleSheet;
......
......@@ -358,6 +358,21 @@ void InspectorDOMAgent::unbind(Node* node, NodeToIdMap* nodesMap)
}
}
Node* InspectorDOMAgent::nodeToSelectOn(long nodeId, bool documentWide)
{
Node* node;
if (!nodeId)
node = m_document.get();
else
node = nodeForId(nodeId);
if (!node)
return 0;
if (documentWide && nodeId)
node = node->ownerDocument();
return node;
}
bool InspectorDOMAgent::pushDocumentToFrontend()
{
if (!m_document)
......@@ -413,6 +428,37 @@ void InspectorDOMAgent::getChildNodes(ErrorString*, long nodeId)
pushChildNodesToFrontend(nodeId);
}
void InspectorDOMAgent::querySelector(ErrorString*, long nodeId, const String& selectors, bool documentWide, long* elementId)
{
*elementId = 0;
Node* node = nodeToSelectOn(nodeId, documentWide);
if (!node)
return;
ExceptionCode ec = 0;
RefPtr<Element> element = node->querySelector(selectors, ec);
if (ec)
return;
if (element)
*elementId = pushNodePathToFrontend(element.get());
}
void InspectorDOMAgent::querySelectorAll(ErrorString*, long nodeId, const String& selectors, bool documentWide, RefPtr<InspectorArray>* result)
{
Node* node = nodeToSelectOn(nodeId, documentWide);
if (!node)
return;
ExceptionCode ec = 0;
RefPtr<NodeList> nodes = node->querySelectorAll(selectors, ec);
if (ec)
return;
for (unsigned i = 0; i < nodes->length(); ++i)
(*result)->pushNumber(pushNodePathToFrontend(nodes->item(i)));
}
long InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
{
ASSERT(nodeToPush); // Invalid input
......
......@@ -101,6 +101,8 @@ public:
Vector<Document*> documents();
void reset();
void querySelector(ErrorString*, long nodeId, const String& selectors, bool documentWide, long* elementId);
void querySelectorAll(ErrorString*, long nodeId, const String& selectors, bool documentWide, RefPtr<InspectorArray>* result);
// Methods called from the frontend for DOM nodes inspection.
void getChildNodes(ErrorString*, long nodeId);
void setAttribute(ErrorString*, long elementId, const String& name, const String& value, bool* success);
......@@ -159,6 +161,8 @@ private:
long bind(Node*, NodeToIdMap*);
void unbind(Node*, NodeToIdMap*);
Node* nodeToSelectOn(long nodeId, bool documentWide);
bool pushDocumentToFrontend();
bool hasBreakpoint(Node*, long type);
......
......@@ -723,50 +723,7 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = {
WebInspector.cssModel.getStylesAsync(nodeIds[i], imageStylesReady.bind(this, nodeIds[i], i === nodeIds.length - 1));
}
function receivedImages(arrayElements)
{
if (!arrayElements)
return callback(null);
var nodeIds = [];
function appendId(lastCall, nodeId)
{
if (nodeId)
nodeIds.push(nodeId);
if (lastCall)
getStyles(nodeIds);
}
for (var i = 0; arrayElements && i < arrayElements.length; ++i) {
var value = arrayElements[i].value;
value.pushNodeToFrontend(appendId.bind(this, i === arrayElements.length - 1));
}
}
function receivedImagesArray(payload)
{
if (!payload)
return callback(null);
var nodeIdsArray = WebInspector.RemoteObject.fromPayload(payload);
nodeIdsArray.getOwnProperties(false, receivedImages);
}
function pushImageNodes()
{
var result = [];
var nodes = document.getElementsByTagName("img");
for (var i = 0; i < nodes.length; ++i) {
if (nodes[i].src)
result.push(nodes[i]);
}
return result;
}
RuntimeAgent.evaluate("(" + pushImageNodes + ")()", "", false, receivedImagesArray);
DOMAgent.querySelectorAll(0, "img[src]", true, getStyles);
}
}
......
......@@ -127,7 +127,7 @@ WebInspector.CSSStyleModel.prototype = {
if (!rulePayload)
failureCallback();
else
CSSAgent.querySelectorAll(nodeId, newSelector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
DOMAgent.querySelectorAll(nodeId, newSelector, true, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
}
CSSAgent.setRuleSelector(ruleId, newSelector, callback.bind(this, nodeId, successCallback, failureCallback));
......@@ -149,7 +149,7 @@ WebInspector.CSSStyleModel.prototype = {
// Invalid syntax for a selector
failureCallback();
} else
CSSAgent.querySelectorAll(nodeId, selector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
DOMAgent.querySelectorAll(nodeId, selector, true, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
}
CSSAgent.addRule(nodeId, selector, callback.bind(this, successCallback, failureCallback, selector));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment