Commit d41cebd0 authored by apavlov@chromium.org's avatar apavlov@chromium.org

2011-01-20 Alexander Pavlov <apavlov@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: Crash when adding a rule for an ImageDocument
        https://bugs.webkit.org/show_bug.cgi?id=52811

        * inspector/InspectorCSSAgent.cpp:
        (WebCore::InspectorCSSAgent::addRule2):
        (WebCore::InspectorCSSAgent::viaInspectorStyleSheet):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 51223959
2011-01-20 Alexander Pavlov <apavlov@chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: Crash when adding a rule for an ImageDocument
https://bugs.webkit.org/show_bug.cgi?id=52811
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::addRule2):
(WebCore::InspectorCSSAgent::viaInspectorStyleSheet):
2011-01-20 Ilya Tikhonovsky <loislo@chromium.org>
Reviewed by Pavel Feldman.
......@@ -349,6 +349,8 @@ void InspectorCSSAgent::addRule2(const long contextNodeId, const String& selecto
return;
InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(node->document(), true);
if (!inspectorStyleSheet)
return;
CSSStyleRule* newRule = inspectorStyleSheet->addRule(selector);
if (!newRule)
return;
......@@ -447,8 +449,17 @@ InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
RefPtr<Element> styleElement = document->createElement("style", ec);
if (!ec)
styleElement->setAttribute("type", "text/css", ec);
if (!ec)
document->head()->appendChild(styleElement, ec);
if (!ec) {
ContainerNode* targetNode;
// HEAD is absent in ImageDocuments, for example.
if (document->head())
targetNode = document->head();
else if (document->body())
targetNode = document->body();
else
return 0;
targetNode->appendChild(styleElement, ec);
}
if (ec)
return 0;
StyleSheetList* styleSheets = document->styleSheets();
......
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