Bug 70116

Summary: CSSStyleSheet should only ever contain CSSRules.
Product: WebKit Reporter: Andreas Kling <kling>
Component: CSSAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: koivisto, luiz, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch koivisto: review+

Description Andreas Kling 2011-10-14 10:55:36 PDT
SSIA.
Comment 1 Andreas Kling 2011-10-14 11:05:29 PDT
Created attachment 111029 [details]
Proposed patch
Comment 2 WebKit Review Bot 2011-10-14 11:09:43 PDT
Attachment 111029 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/css/CSSStyleSelector.cpp:2005:  An else should appear on the same line as the preceding }  [whitespace/newline] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Antti Koivisto 2011-10-14 11:18:00 PDT
Comment on attachment 111029 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=111029&action=review

Nice! r=me, with one change.

> Source/WebCore/css/CSSStyleSheet.h:113
> +    unsigned length() const { return m_children.size(); }
> +    CSSRule* item(unsigned index) { return index < length() ? m_children.at(index).get() : 0; }

Just go ahead and expose the vector instead here 
const Vector<RefPtr<CSSRule> >& rules() const

> Source/WebCore/xml/XSLStyleSheet.h:60
> +    unsigned length() const { return m_children.size(); }
> +    StyleBase* item(unsigned index) { return index < length() ? m_children.at(index).get() : 0; }

here too
Comment 4 Antti Koivisto 2011-10-14 11:22:29 PDT
Actually, please land as-is, refactor the array interface separately.
Comment 5 Andreas Kling 2011-10-14 11:37:00 PDT
Committed r97485: <http://trac.webkit.org/changeset/97485>
Comment 6 Antti Koivisto 2011-10-14 11:43:04 PDT
Comment on attachment 111029 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=111029&action=review

> Source/WebCore/css/CSSRule.h:-66
> +    virtual bool isRule() const { return true; }
> +
>  protected:
>      CSSRule(CSSStyleSheet* parent)
>          : StyleBase(parent)
>      {
>      }
> -
> -private:
> -    virtual bool isRule() const { return true; }

Oh, no need make this public...

> Source/WebCore/css/CSSStyleSheet.cpp:108
> +    CSSRule* c = child.get();
> +    ASSERT(c->isRule());

... as these asserts are not really necessary at all!