Commit 87ec60d7 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2010-05-27 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: Get CSS rule offsets lazily.

        https://bugs.webkit.org/show_bug.cgi?id=39832

        * inspector/InspectorCSSStore.cpp:
        (WebCore::InspectorCSSStore::getStartEndOffsets):
        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::buildObjectForRule):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60297 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 15c6409e
Tests that proper start/end offset positions are reported for CSS rule bodies.
body: [5-28]
body.main1: [98-124]
body.main2: [150-169]
<html>
<head>
<link rel="stylesheet" href="resources/styles-source-offsets.css" -->
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="elements-tests.js"></script>
<script>
function doit()
{
function callback(styles)
{
if (styles === "refreshing")
return;
var matchedCSSRules = styles.matchedCSSRules;
for (var i = 0; i < matchedCSSRules.length; ++i)
output(matchedCSSRules[i].selectorText + ": [" + matchedCSSRules[i].bodyStartOffset + "-" + matchedCSSRules[i].bodyEndOffset + "]");
notifyDone();
}
evaluateInWebInspector("frontend_dumpBodyOffsets", callback);
}
// Frontend functions.
function frontend_dumpBodyOffsets(testController)
{
if (!WebInspector.panels.resources.resourceTrackingEnabled) {
InspectorBackend.enableResourceTracking(false);
return "refreshing";
}
testController.waitUntilDone();
frontend_expandDOMSubtree(WebInspector.domAgent.document);
testController.runAfterPendingDispatches(function() {
function callback(styles)
{
testController.notifyDone(styles);
}
InspectorBackend.getStyles(WebInspector.Callback.wrap(callback), WebInspector.domAgent.document.body.id, true);
});
}
</script>
</head>
<body class="main1 main2" onload="onload()">
<p>
Tests that proper start/end offset positions are reported for CSS rule bodies.
</p>
</body>
</html>
2010-05-27 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: Get CSS rule offsets lazily.
https://bugs.webkit.org/show_bug.cgi?id=39832
* inspector/InspectorCSSStore.cpp:
(WebCore::InspectorCSSStore::getStartEndOffsets):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForRule):
2010-05-27 Anders Bakken <agbakken@gmail.com>
Reviewed by David Levin.
......
......@@ -123,7 +123,7 @@ SourceRange InspectorCSSStore::getStartEndOffsets(CSSStyleRule* rule)
InspectorResource* resource = m_inspectorController->resourceForURL(parentStyleSheet->finalURL().string());
if (resource) {
offsetVector = new Vector<SourceRange>;
RefPtr<CSSStyleSheet> newStyleSheet = CSSStyleSheet::create();
RefPtr<CSSStyleSheet> newStyleSheet = CSSStyleSheet::create(parentStyleSheet->ownerNode());
CSSParser p;
p.parseSheet(newStyleSheet.get(), resource->sourceString(), offsetVector);
m_styleSheetToOffsets.set(parentStyleSheet, offsetVector);
......
......@@ -1190,11 +1190,6 @@ ScriptObject InspectorDOMAgent::buildObjectForRule(Document* ownerDocument, CSSS
result.set("selectorText", rule->selectorText());
result.set("cssText", rule->cssText());
result.set("sourceLine", rule->sourceLine());
std::pair<unsigned, unsigned> startEnd = cssStore()->getStartEndOffsets(rule);
if (startEnd.second) {
result.set("bodyStartOffset", startEnd.first);
result.set("bodyEndOffset", startEnd.second);
}
if (parentStyleSheet) {
ScriptObject parentStyleSheetValue = m_frontend->newScriptObject();
result.set("parentStyleSheet", parentStyleSheetValue);
......
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