Changeset 56383 in webkit


Ignore:
Timestamp:
Mar 23, 2010 12:07:38 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-03-22 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Dave Hyatt.

Web Inspector: display CSS selector source line in the styles sidebar pane.

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

This change adds a sourceLine field into the CSSStyleRule that is populated
from within the parser. CSSParser is now keeping track of the line numbers
and last selector line number that is being used while creating CSSStyleRules.

Test: inspector/styles-source-lines.html

  • css/CSSGrammar.y:
  • css/CSSParser.cpp: (WebCore::CSSParser::CSSParser): (WebCore::CSSParser::lex): (WebCore::CSSParser::countLines): (WebCore::CSSParser::createStyleRule):
  • css/CSSParser.h: (WebCore::CSSParser::updateLastSelectorLine):
  • css/CSSStyleRule.cpp: (WebCore::CSSStyleRule::CSSStyleRule):
  • css/CSSStyleRule.h: (WebCore::CSSStyleRule::create): (WebCore::CSSStyleRule::sourceLine):
  • css/tokenizer.flex:
  • inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::buildObjectForRule):
  • inspector/front-end/DOMAgent.js: (WebInspector.CSSStyleDeclaration.parseRule):
  • inspector/front-end/StylesSidebarPane.js: (WebInspector.StylePropertiesSection):
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r56382 r56383  
     12010-03-22  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Web Inspector: display CSS selector source line in the styles sidebar pane.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=36414
     8
     9        This change adds a sourceLine field into the CSSStyleRule that is populated
     10        from within the parser. CSSParser is now keeping track of the line numbers
     11        and last selector line number that is being used while creating CSSStyleRules.
     12
     13        * inspector/styles-source-lines-expected.txt: Added.
     14        * inspector/styles-source-lines.html: Added.
     15
    1162010-03-22  Qi Zhang  <qi.2.zhang@nokia.com>
    217
  • trunk/WebCore/ChangeLog

    r56382 r56383  
     12010-03-22  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Web Inspector: display CSS selector source line in the styles sidebar pane.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=36414
     8
     9        This change adds a sourceLine field into the CSSStyleRule that is populated
     10        from within the parser. CSSParser is now keeping track of the line numbers
     11        and last selector line number that is being used while creating CSSStyleRules.
     12
     13        Test: inspector/styles-source-lines.html
     14
     15        * css/CSSGrammar.y:
     16        * css/CSSParser.cpp:
     17        (WebCore::CSSParser::CSSParser):
     18        (WebCore::CSSParser::lex):
     19        (WebCore::CSSParser::countLines):
     20        (WebCore::CSSParser::createStyleRule):
     21        * css/CSSParser.h:
     22        (WebCore::CSSParser::updateLastSelectorLine):
     23        * css/CSSStyleRule.cpp:
     24        (WebCore::CSSStyleRule::CSSStyleRule):
     25        * css/CSSStyleRule.h:
     26        (WebCore::CSSStyleRule::create):
     27        (WebCore::CSSStyleRule::sourceLine):
     28        * css/tokenizer.flex:
     29        * inspector/InspectorDOMAgent.cpp:
     30        (WebCore::InspectorDOMAgent::buildObjectForRule):
     31        * inspector/front-end/DOMAgent.js:
     32        (WebInspector.CSSStyleDeclaration.parseRule):
     33        * inspector/front-end/StylesSidebarPane.js:
     34        (WebInspector.StylePropertiesSection):
     35
    1362010-03-22  Qi Zhang  <qi.2.zhang@nokia.com>
    237
  • trunk/WebCore/css/CSSGrammar.y

    r56187 r56383  
    787787            $$->shrink(0);
    788788            $$->append(p->sinkFloatingSelector($1));
     789            p->updateLastSelectorLine();
    789790        }
    790791    }
     
    794795            $$ = $1;
    795796            $$->append(p->sinkFloatingSelector($4));
     797            p->updateLastSelectorLine();
    796798        } else
    797799            $$ = 0;
  • trunk/WebCore/css/CSSParser.cpp

    r56167 r56383  
    144144    , m_data(0)
    145145    , yy_start(1)
     146    , m_line(0)
     147    , m_lastSelectorLine(0)
    146148    , m_allowImportRules(true)
    147149    , m_allowVariablesRules(true)
     
    46934695    YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType);
    46944696    int length;
    4695    
     4697
    46964698    lex();
    46974699
     
    49184920}
    49194921
     4922void CSSParser::countLines()
     4923{
     4924    for (UChar* current = yytext; current < yytext + yyleng; ++current) {
     4925        if (*current == '\n')
     4926            ++m_line;
     4927    }
     4928}
     4929
    49204930CSSSelector* CSSParser::createFloatingSelector()
    49214931{
     
    50875097    CSSStyleRule* result = 0;
    50885098    if (selectors) {
    5089         RefPtr<CSSStyleRule> rule = CSSStyleRule::create(m_styleSheet);
     5099        RefPtr<CSSStyleRule> rule = CSSStyleRule::create(m_styleSheet, m_lastSelectorLine);
    50905100        rule->adoptSelectorVector(*selectors);
    50915101        if (m_hasFontFaceOnlyValues)
  • trunk/WebCore/css/CSSParser.h

    r55576 r56383  
    196196        void addUnresolvedProperty(int propId, bool important);
    197197        void invalidBlockHit();
    198        
     198
    199199        Vector<CSSSelector*>* reusableSelectorVector() { return &m_reusableSelectorVector; }
     200
     201        void updateLastSelectorLine() { m_lastSelectorLine = m_line; }
    200202
    201203        bool m_strict;
     
    228230        int token() { return yyTok; }
    229231        UChar* text(int* length);
     232        void countLines();
    230233        int lex();
    231234       
     
    254257        int yyTok;
    255258        int yy_start;
     259        int m_line;
     260        int m_lastSelectorLine;
    256261
    257262        bool m_allowImportRules;
  • trunk/WebCore/css/CSSStyleRule.cpp

    r39441 r56383  
    2828namespace WebCore {
    2929
    30 CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent)
     30CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int sourceLine)
    3131    : CSSRule(parent)
     32    , m_sourceLine(sourceLine)
    3233{
    3334}
  • trunk/WebCore/css/CSSStyleRule.h

    r39441 r56383  
    3535class CSSStyleRule : public CSSRule {
    3636public:
    37     static PassRefPtr<CSSStyleRule> create(CSSStyleSheet* parent)
     37    static PassRefPtr<CSSStyleRule> create(CSSStyleSheet* parent, int sourceLine)
    3838    {
    39         return adoptRef(new CSSStyleRule(parent));
     39        return adoptRef(new CSSStyleRule(parent, sourceLine));
    4040    }
    4141    virtual ~CSSStyleRule();
     
    5959    virtual void addSubresourceStyleURLs(ListHashSet<KURL>& urls);
    6060
     61    int sourceLine() { return m_sourceLine; }
     62
    6163private:
    62     CSSStyleRule(CSSStyleSheet* parent);
     64    CSSStyleRule(CSSStyleSheet* parent, int sourceLine);
    6365
    6466    virtual bool isStyleRule() { return true; }
     
    6971    RefPtr<CSSMutableStyleDeclaration> m_style;
    7072    CSSSelectorList m_selectorList;
     73    int m_sourceLine;
    7174};
    7275
  • trunk/WebCore/css/tokenizer.flex

    r45919 r56383  
    2929%%
    3030
    31 \/\*[^*]*\*+([^/*][^*]*\*+)*\/  /* ignore comments */
     31\/\*[^*]*\*+([^/*][^*]*\*+)*\/ {countLines(); /* ignore comments */ }
    3232
    33 [ \t\r\n\f]+            {yyTok = WHITESPACE; return yyTok;}
     33[ \t\r\n\f]+            {countLines(); yyTok = WHITESPACE; return yyTok;}
    3434
    3535"<!--"                  {yyTok = SGML_CD; return yyTok;}
  • trunk/WebCore/inspector/InspectorDOMAgent.cpp

    r56353 r56383  
    11031103    result.set("selectorText", rule->selectorText());
    11041104    result.set("cssText", rule->cssText());
     1105    result.set("sourceLine", rule->sourceLine());
    11051106    if (parentStyleSheet) {
    11061107        ScriptObject parentStyleSheetValue = m_frontend->newScriptObject();
  • trunk/WebCore/inspector/front-end/DOMAgent.js

    r56161 r56383  
    551551    rule.isUser = payload.isUser;
    552552    rule.isViaInspector = payload.isViaInspector;
     553    rule.sourceLine = payload.sourceLine;
    553554    if (payload.parentStyleSheet)
    554555        rule.parentStyleSheet = { href: payload.parentStyleSheet.href };
  • trunk/WebCore/inspector/front-end/StylesSidebarPane.js

    r56237 r56383  
    491491            if (this.styleRule.parentStyleSheet && this.styleRule.parentStyleSheet.href) {
    492492                var url = this.styleRule.parentStyleSheet.href;
    493                 subtitle = WebInspector.linkifyURL(url, WebInspector.displayNameForURL(url));
    494                 this.subtitleElement.addStyleClass("file");
     493                this.subtitleElement.appendChild(WebInspector.linkifyResourceAsNode(url, "resources", this.rule.sourceLine + 1));
    495494            } else if (isUserAgent)
    496495                subtitle = WebInspector.UIString("user agent stylesheet");
     
    504503        if (isInherited)
    505504            this.element.addStyleClass("show-inherited");
    506         this.subtitle = subtitle;
     505        if (subtitle)
     506            this.subtitle = subtitle;
    507507    }
    508508
Note: See TracChangeset for help on using the changeset viewer.