Commit f1550984 authored by ariya@webkit.org's avatar ariya@webkit.org

2009-05-12 Antonio Gomes <antonio.gomes@openbossa.org>

        Reviewed by Ariya Hidayat.

        Fixed a possible crash @styleProperty when there is no embedded/external CSS set.

        * Api/qwebelement.cpp:
        (QWebElement::styleProperty):
        * tests/qwebelement/tst_qwebelement.cpp:
        (tst_QWebElement::style):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43621 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b65d4057
......@@ -908,17 +908,16 @@ QString QWebElement::styleProperty(const QString &name, const ResolveRule rule)
// declarations, as well as embedded and inline style declarations.
DOMWindow* domWindow = m_element->document()->frame()->domWindow();
RefPtr<CSSRuleList> rules = domWindow->getMatchedCSSRules(m_element, "");
if (RefPtr<CSSRuleList> rules = domWindow->getMatchedCSSRules(m_element, ""))
for (int i = rules->length(); i > 0; --i) {
CSSStyleRule* rule = static_cast<CSSStyleRule*>(rules->item(i - 1));
for (int i = rules->length(); i > 0; --i) {
CSSStyleRule* rule = static_cast<CSSStyleRule*>(rules->item(i - 1));
if (rule->style()->getPropertyPriority(propID))
return rule->style()->getPropertyValue(propID);
if (rule->style()->getPropertyPriority(propID))
return rule->style()->getPropertyValue(propID);
if (style->getPropertyValue(propID).isEmpty())
style = rule->style();
}
if (style->getPropertyValue(propID).isEmpty())
style = rule->style();
}
return style->getPropertyValue(propID);
}
......
2009-05-12 Antonio Gomes <antonio.gomes@openbossa.org>
Reviewed by Ariya Hidayat.
Fixed a possible crash @styleProperty when there is no embedded/external CSS set.
* Api/qwebelement.cpp:
(QWebElement::styleProperty):
* tests/qwebelement/tst_qwebelement.cpp:
(tst_QWebElement::style):
2009-05-12 Antonio Gomes <antonio.gomes@openbossa.org>
Reviewed by Ariya Hidayat.
......
......@@ -508,6 +508,14 @@ void tst_QWebElement::style()
p = m_mainFrame->documentElement().findAll("p").at(0);
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
QString html8 = "<body><p>some text</p></body>";
m_mainFrame->setHtml(html8);
p = m_mainFrame->documentElement().findAll("p").at(0);
QCOMPARE(p.styleProperty("color"), QLatin1String(""));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String(""));
}
void tst_QWebElement::computedStyle()
......
Markdown is supported
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