Diff
Modified: trunk/LayoutTests/ChangeLog (144024 => 144025)
--- trunk/LayoutTests/ChangeLog 2013-02-26 09:13:32 UTC (rev 144024)
+++ trunk/LayoutTests/ChangeLog 2013-02-26 09:15:17 UTC (rev 144025)
@@ -1,3 +1,13 @@
+2013-02-26 Alexander Pavlov <[email protected]>
+
+ Web Inspector: CSSAgent.setStyleSheetText crashes on inline styles
+ https://bugs.webkit.org/show_bug.cgi?id=110359
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/styles/styles-new-API-expected.txt:
+ * inspector/styles/styles-new-API.html:
+
2013-02-26 Tien-Ren Chen <[email protected]>
Implement coordinated scrollbar for subframes and overflow:scroll
Modified: trunk/LayoutTests/inspector/styles/styles-new-API-expected.txt (144024 => 144025)
--- trunk/LayoutTests/inspector/styles/styles-new-API-expected.txt 2013-02-26 09:13:32 UTC (rev 144024)
+++ trunk/LayoutTests/inspector/styles/styles-new-API-expected.txt 2013-02-26 09:15:17 UTC (rev 144025)
@@ -134,6 +134,12 @@
=== Attributes style for table ===
['width':'50%'] @[undefined-undefined] style
+=== Stylesheet-for-inline-style text ===
+
+
+=== Stylesheet-for-inline-style modification result ===
+NotSupportedError
+
=== All stylesheets ===
StyleSheet: '@charset "UTF-8";
Modified: trunk/LayoutTests/inspector/styles/styles-new-API.html (144024 => 144025)
--- trunk/LayoutTests/inspector/styles/styles-new-API.html 2013-02-26 09:13:32 UTC (rev 144024)
+++ trunk/LayoutTests/inspector/styles/styles-new-API.html 2013-02-26 09:15:17 UTC (rev 144025)
@@ -118,7 +118,7 @@
InspectorTest.addResult("");
InspectorTest.addResult("=== Attributes style for table ===");
InspectorTest.dumpStyle(attributesStyle);
- test_styleSheets();
+ test_inlineStyleSheetModification(inlineStyle);
}
function nodeCallback(node)
@@ -128,6 +128,27 @@
InspectorTest.nodeWithId("thetable", nodeCallback);
}
+ function test_inlineStyleSheetModification(inlineStyle)
+ {
+ CSSAgent.getStyleSheetText(inlineStyle.styleId.styleSheetId, textCallback);
+
+ function textCallback(error, result)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Stylesheet-for-inline-style text ===");
+ InspectorTest.addResult(result);
+ CSSAgent.setStyleSheetText(inlineStyle.styleId.styleSheetId, "", setTextCallback);
+ }
+
+ function setTextCallback(error, result)
+ {
+ InspectorTest.addResult("");
+ InspectorTest.addResult("=== Stylesheet-for-inline-style modification result ===");
+ InspectorTest.addResult(error);
+ test_styleSheets();
+ }
+ }
+
function test_styleSheets()
{
var newStyleSheetText =
Modified: trunk/Source/WebCore/ChangeLog (144024 => 144025)
--- trunk/Source/WebCore/ChangeLog 2013-02-26 09:13:32 UTC (rev 144024)
+++ trunk/Source/WebCore/ChangeLog 2013-02-26 09:15:17 UTC (rev 144025)
@@ -1,3 +1,23 @@
+2013-02-26 Alexander Pavlov <[email protected]>
+
+ Web Inspector: CSSAgent.setStyleSheetText crashes on inline styles
+ https://bugs.webkit.org/show_bug.cgi?id=110359
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::SetStyleSheetTextAction::undo): Pass ExceptionCode into setText().
+ (WebCore::InspectorCSSAgent::SetStyleSheetTextAction::redo): Ditto.
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::InspectorStyleSheet::setText): Make use of checkPageStyleSheet().
+ (WebCore::InspectorStyleSheet::setRuleSelector): Ditto.
+ (WebCore::InspectorStyleSheet::addRule): Ditto.
+ (WebCore::InspectorStyleSheet::deleteRule): Ditto.
+ (WebCore::InspectorStyleSheet::checkPageStyleSheet):
+ Return NOT_SUPPORTED_ERR if no m_pageStyleSheet.
+ (WebCore::InspectorStyleSheet::setStyleText): Check field directly.
+ * inspector/InspectorStyleSheet.h:
+
2013-02-26 Tien-Ren Chen <[email protected]>
Implement coordinated scrollbar for subframes and overflow:scroll
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (144024 => 144025)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2013-02-26 09:13:32 UTC (rev 144024)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2013-02-26 09:15:17 UTC (rev 144025)
@@ -318,18 +318,18 @@
return redo(ec);
}
- virtual bool undo(ExceptionCode&)
+ virtual bool undo(ExceptionCode& ec)
{
- if (m_styleSheet->setText(m_oldText)) {
+ if (m_styleSheet->setText(m_oldText, ec)) {
m_styleSheet->reparseStyleSheet(m_oldText);
return true;
}
return false;
}
- virtual bool redo(ExceptionCode&)
+ virtual bool redo(ExceptionCode& ec)
{
- if (m_styleSheet->setText(m_text)) {
+ if (m_styleSheet->setText(m_text, ec)) {
m_styleSheet->reparseStyleSheet(m_text);
return true;
}
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (144024 => 144025)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2013-02-26 09:13:32 UTC (rev 144024)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2013-02-26 09:15:17 UTC (rev 144025)
@@ -780,8 +780,10 @@
}
}
-bool InspectorStyleSheet::setText(const String& text)
+bool InspectorStyleSheet::setText(const String& text, ExceptionCode& ec)
{
+ if (!checkPageStyleSheet(ec))
+ return false;
if (!m_parsedStyleSheet)
return false;
@@ -803,6 +805,8 @@
bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String& selector, ExceptionCode& ec)
{
+ if (!checkPageStyleSheet(ec))
+ return false;
CSSStyleRule* rule = ruleForId(id);
if (!rule) {
ec = NOT_FOUND_ERR;
@@ -837,6 +841,8 @@
CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode& ec)
{
+ if (!checkPageStyleSheet(ec))
+ return 0;
if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) {
ec = SYNTAX_ERR;
return 0;
@@ -874,7 +880,7 @@
styleSheetText.append(selector);
styleSheetText.appendLiteral(" {}");
// Using setText() as this operation changes the style sheet rule set.
- setText(styleSheetText.toString());
+ setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION);
fireStyleSheetChanged();
@@ -883,6 +889,8 @@
bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionCode& ec)
{
+ if (!checkPageStyleSheet(ec))
+ return false;
RefPtr<CSSStyleRule> rule = ruleForId(id);
if (!rule) {
ec = NOT_FOUND_ERR;
@@ -908,7 +916,7 @@
String sheetText = m_parsedStyleSheet->text();
sheetText.remove(sourceData->ruleHeaderRange.start, sourceData->ruleBodyRange.end - sourceData->ruleHeaderRange.start + 1);
- setText(sheetText);
+ setText(sheetText, ASSERT_NO_EXCEPTION);
fireStyleSheetChanged();
return true;
}
@@ -1177,6 +1185,15 @@
return UINT_MAX;
}
+bool InspectorStyleSheet::checkPageStyleSheet(ExceptionCode& ec) const
+{
+ if (!m_pageStyleSheet) {
+ ec = NOT_SUPPORTED_ERR;
+ return false;
+ }
+ return true;
+}
+
bool InspectorStyleSheet::ensureParsedDataReady()
{
return ensureText() && ensureSourceData();
@@ -1222,7 +1239,7 @@
bool InspectorStyleSheet::setStyleText(CSSStyleDeclaration* style, const String& text)
{
- if (!pageStyleSheet())
+ if (!m_pageStyleSheet)
return false;
if (!ensureParsedDataReady())
return false;
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.h (144024 => 144025)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.h 2013-02-26 09:13:32 UTC (rev 144024)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.h 2013-02-26 09:15:17 UTC (rev 144025)
@@ -185,7 +185,7 @@
String finalURL() const;
CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet.get(); }
void reparseStyleSheet(const String&);
- bool setText(const String&);
+ bool setText(const String&, ExceptionCode&);
String ruleSelector(const InspectorCSSId&, ExceptionCode&);
bool setRuleSelector(const InspectorCSSId&, const String& selector, ExceptionCode&);
CSSStyleRule* addRule(const String& selector, ExceptionCode&);
@@ -226,6 +226,7 @@
friend class InspectorStyle;
static void collectFlatRules(PassRefPtr<CSSRuleList>, CSSStyleRuleVector* result);
+ bool checkPageStyleSheet(ExceptionCode&) const;
bool ensureText() const;
bool ensureSourceData();
void ensureFlatRules() const;