Commit b307f177 authored by hyatt@apple.com's avatar hyatt@apple.com
Browse files

Fix for http://bugs.webkit.org/show_bug.cgi?id=17559, media query tests crashing under

        guard malloc.  Pass along the style selector so it can be accessed, since it has not yet
        been assigned into the document's member variable.

        Reviewed by aroben

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSRuleSet::addRulesFromSheet):
        * css/MediaQueryEvaluator.cpp:
        (WebCore::MediaQueryEvaluator::eval):
        * css/MediaQueryEvaluator.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7499dd5a
2008-02-29 David Hyatt <hyatt@apple.com>
Fix for http://bugs.webkit.org/show_bug.cgi?id=17559, media query tests crashing under
guard malloc. Pass along the style selector so it can be accessed, since it has not yet
been assigned into the document's member variable.
Reviewed by aroben
* css/CSSStyleSelector.cpp:
(WebCore::CSSRuleSet::addRulesFromSheet):
* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::eval):
* css/MediaQueryEvaluator.h:
2008-02-29 David Hyatt <hyatt@apple.com>
 
<rdar://problem/5755916> REGRESSION: Loading HTML5 spec is 5x slower on TOT than in 3.0.4
......@@ -2204,7 +2204,7 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat
// No media implies "all", but if a media list exists it must
// contain our current medium
if (sheet->media() && !medium.eval(sheet->media()))
if (sheet->media() && !medium.eval(sheet->media(), styleSelector))
return; // the style sheet doesn't apply
int len = sheet->length();
......@@ -2218,14 +2218,14 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat
}
else if (item->isImportRule()) {
CSSImportRule* import = static_cast<CSSImportRule*>(item);
if (!import->media() || medium.eval(import->media()))
if (!import->media() || medium.eval(import->media(), styleSelector))
addRulesFromSheet(import->styleSheet(), medium, styleSelector);
}
else if (item->isMediaRule()) {
CSSMediaRule* r = static_cast<CSSMediaRule*>(item);
CSSRuleList* rules = r->cssRules();
if ((!r->media() || medium.eval(r->media())) && rules) {
if ((!r->media() || medium.eval(r->media(), styleSelector)) && rules) {
// Traverse child elements of the @media rule.
for (unsigned j = 0; j < rules->length(); j++) {
CSSRule *childItem = rules->item(j);
......
......@@ -123,7 +123,7 @@ static bool applyRestrictor(MediaQuery::Restrictor r, bool value)
return r == MediaQuery::Not ? !value : value;
}
bool MediaQueryEvaluator::eval(const MediaList* mediaList) const
bool MediaQueryEvaluator::eval(const MediaList* mediaList, CSSStyleSelector* styleSelector) const
{
if (!mediaList)
return true;
......@@ -144,8 +144,8 @@ bool MediaQueryEvaluator::eval(const MediaList* mediaList) const
size_t j = 0;
for (; j < exps->size(); ++j) {
bool exprResult = eval(exps->at(j));
if (exps->at(j)->isViewportDependent() && m_frame)
m_frame->document()->styleSelector()->addViewportDependentMediaQueryResult(exps->at(j), exprResult);
if (styleSelector && exps->at(j)->isViewportDependent())
styleSelector->addViewportDependentMediaQueryResult(exps->at(j), exprResult);
if (!exprResult)
break;
}
......
......@@ -31,6 +31,7 @@
#include "PlatformString.h"
namespace WebCore {
class CSSStyleSelector;
class Frame;
class RenderStyle;
class MediaList;
......@@ -74,10 +75,10 @@ public:
bool mediaTypeMatchSpecific(const char* mediaTypeToMatch) const;
/** Evaluates a list of media queries */
bool eval(const MediaList* query) const;
bool eval(const MediaList*, CSSStyleSelector* = 0) const;
/** Evaluates media query subexpression, ie "and (media-feature: value)" part */
bool eval(const MediaQueryExp* expr) const;
bool eval(const MediaQueryExp*) const;
private:
String m_mediaType;
......
Supports Markdown
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