⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 144025 in webkit


Ignore:
Timestamp:
Feb 26, 2013, 1:15:17 AM (14 years ago)
Author:
apavlov@chromium.org
Message:

Web Inspector: CSSAgent.setStyleSheetText crashes on inline styles
https://bugs.webkit.org/show_bug.cgi?id=110359

Reviewed by Pavel Feldman.

Source/WebCore:

  • 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:

LayoutTests:

  • inspector/styles/styles-new-API-expected.txt:
  • inspector/styles/styles-new-API.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r144024 r144025  
     12013-02-26  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Web Inspector: CSSAgent.setStyleSheetText crashes on inline styles
     4        https://bugs.webkit.org/show_bug.cgi?id=110359
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/styles/styles-new-API-expected.txt:
     9        * inspector/styles/styles-new-API.html:
     10
    1112013-02-26  Tien-Ren Chen  <trchen@chromium.org>
    212
  • trunk/LayoutTests/inspector/styles/styles-new-API-expected.txt

    r125399 r144025  
    134134=== Attributes style for table ===
    135135['width':'50%'] @[undefined-undefined] style
     136
     137=== Stylesheet-for-inline-style text ===
     138
     139
     140=== Stylesheet-for-inline-style modification result ===
     141NotSupportedError
    136142
    137143=== All stylesheets ===
  • trunk/LayoutTests/inspector/styles/styles-new-API.html

    r130511 r144025  
    119119            InspectorTest.addResult("=== Attributes style for table ===");
    120120            InspectorTest.dumpStyle(attributesStyle);
     121            test_inlineStyleSheetModification(inlineStyle);
     122        }
     123
     124        function nodeCallback(node)
     125        {
     126            CSSAgent.getInlineStylesForNode(node.id, callback);
     127        }
     128        InspectorTest.nodeWithId("thetable", nodeCallback);
     129    }
     130
     131    function test_inlineStyleSheetModification(inlineStyle)
     132    {
     133        CSSAgent.getStyleSheetText(inlineStyle.styleId.styleSheetId, textCallback);
     134
     135        function textCallback(error, result)
     136        {
     137            InspectorTest.addResult("");
     138            InspectorTest.addResult("=== Stylesheet-for-inline-style text ===");
     139            InspectorTest.addResult(result);
     140            CSSAgent.setStyleSheetText(inlineStyle.styleId.styleSheetId, "", setTextCallback);
     141        }
     142
     143        function setTextCallback(error, result)
     144        {
     145            InspectorTest.addResult("");
     146            InspectorTest.addResult("=== Stylesheet-for-inline-style modification result ===");
     147            InspectorTest.addResult(error);
    121148            test_styleSheets();
    122149        }
    123 
    124         function nodeCallback(node)
    125         {
    126             CSSAgent.getInlineStylesForNode(node.id, callback);
    127         }
    128         InspectorTest.nodeWithId("thetable", nodeCallback);
    129150    }
    130151
  • trunk/Source/WebCore/ChangeLog

    r144024 r144025  
     12013-02-26  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Web Inspector: CSSAgent.setStyleSheetText crashes on inline styles
     4        https://bugs.webkit.org/show_bug.cgi?id=110359
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/InspectorCSSAgent.cpp:
     9        (WebCore::InspectorCSSAgent::SetStyleSheetTextAction::undo): Pass ExceptionCode into setText().
     10        (WebCore::InspectorCSSAgent::SetStyleSheetTextAction::redo): Ditto.
     11        * inspector/InspectorStyleSheet.cpp:
     12        (WebCore::InspectorStyleSheet::setText): Make use of checkPageStyleSheet().
     13        (WebCore::InspectorStyleSheet::setRuleSelector): Ditto.
     14        (WebCore::InspectorStyleSheet::addRule): Ditto.
     15        (WebCore::InspectorStyleSheet::deleteRule): Ditto.
     16        (WebCore::InspectorStyleSheet::checkPageStyleSheet):
     17          Return NOT_SUPPORTED_ERR if no m_pageStyleSheet.
     18        (WebCore::InspectorStyleSheet::setStyleText): Check field directly.
     19        * inspector/InspectorStyleSheet.h:
     20
    1212013-02-26  Tien-Ren Chen  <trchen@chromium.org>
    222
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r143333 r144025  
    319319    }
    320320
    321     virtual bool undo(ExceptionCode&)
    322     {
    323         if (m_styleSheet->setText(m_oldText)) {
     321    virtual bool undo(ExceptionCode& ec)
     322    {
     323        if (m_styleSheet->setText(m_oldText, ec)) {
    324324            m_styleSheet->reparseStyleSheet(m_oldText);
    325325            return true;
     
    328328    }
    329329
    330     virtual bool redo(ExceptionCode&)
    331     {
    332         if (m_styleSheet->setText(m_text)) {
     330    virtual bool redo(ExceptionCode& ec)
     331    {
     332        if (m_styleSheet->setText(m_text, ec)) {
    333333            m_styleSheet->reparseStyleSheet(m_text);
    334334            return true;
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r143926 r144025  
    781781}
    782782
    783 bool InspectorStyleSheet::setText(const String& text)
    784 {
     783bool InspectorStyleSheet::setText(const String& text, ExceptionCode& ec)
     784{
     785    if (!checkPageStyleSheet(ec))
     786        return false;
    785787    if (!m_parsedStyleSheet)
    786788        return false;
     
    804806bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String& selector, ExceptionCode& ec)
    805807{
     808    if (!checkPageStyleSheet(ec))
     809        return false;
    806810    CSSStyleRule* rule = ruleForId(id);
    807811    if (!rule) {
     
    838842CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode& ec)
    839843{
     844    if (!checkPageStyleSheet(ec))
     845        return 0;
    840846    if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) {
    841847        ec = SYNTAX_ERR;
     
    875881    styleSheetText.appendLiteral(" {}");
    876882    // Using setText() as this operation changes the style sheet rule set.
    877     setText(styleSheetText.toString());
     883    setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION);
    878884
    879885    fireStyleSheetChanged();
     
    884890bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionCode& ec)
    885891{
     892    if (!checkPageStyleSheet(ec))
     893        return false;
    886894    RefPtr<CSSStyleRule> rule = ruleForId(id);
    887895    if (!rule) {
     
    909917    String sheetText = m_parsedStyleSheet->text();
    910918    sheetText.remove(sourceData->ruleHeaderRange.start, sourceData->ruleBodyRange.end - sourceData->ruleHeaderRange.start + 1);
    911     setText(sheetText);
     919    setText(sheetText, ASSERT_NO_EXCEPTION);
    912920    fireStyleSheetChanged();
    913921    return true;
     
    11781186}
    11791187
     1188bool InspectorStyleSheet::checkPageStyleSheet(ExceptionCode& ec) const
     1189{
     1190    if (!m_pageStyleSheet) {
     1191        ec = NOT_SUPPORTED_ERR;
     1192        return false;
     1193    }
     1194    return true;
     1195}
     1196
    11801197bool InspectorStyleSheet::ensureParsedDataReady()
    11811198{
     
    12231240bool InspectorStyleSheet::setStyleText(CSSStyleDeclaration* style, const String& text)
    12241241{
    1225     if (!pageStyleSheet())
     1242    if (!m_pageStyleSheet)
    12261243        return false;
    12271244    if (!ensureParsedDataReady())
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.h

    r138460 r144025  
    186186    CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet.get(); }
    187187    void reparseStyleSheet(const String&);
    188     bool setText(const String&);
     188    bool setText(const String&, ExceptionCode&);
    189189    String ruleSelector(const InspectorCSSId&, ExceptionCode&);
    190190    bool setRuleSelector(const InspectorCSSId&, const String& selector, ExceptionCode&);
     
    227227
    228228    static void collectFlatRules(PassRefPtr<CSSRuleList>, CSSStyleRuleVector* result);
     229    bool checkPageStyleSheet(ExceptionCode&) const;
    229230    bool ensureText() const;
    230231    bool ensureSourceData();
Note: See TracChangeset for help on using the changeset viewer.