Commit 3ccb9561 authored by ariya@webkit.org's avatar ariya@webkit.org

2009-04-23 Antonio Gomes <antonio.gomes@openbossa.org>

        Reviewed by Ariya Hidayat.

        [Qt] Added QWebElement::computedStyleProperty method.

        * Api/qwebelement.cpp:
        (QWebElement::computedStyleProperty):
        * Api/qwebelement.h:
        * tests/qwebelement/tst_qwebelement.cpp:
        (tst_QWebElement::computedStyle):

git-svn-id: svn://svn.chromium.org/blink/trunk@42777 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent dcad4f60
......@@ -773,8 +773,6 @@ QString QWebElement::styleProperty(const QString &name) const
if (!propID || !style)
return QString();
// TODO: use computed style for fallback
return style->getPropertyValue(propID);
}
......@@ -791,12 +789,27 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value)
if (!propID || !style)
return;
// TODO: what about computed style?
ExceptionCode exception = 0;
style->setProperty(name, value, exception);
}
/*!
Returns the computed value for style named \a name or an empty string if the style has no such name.
*/
QString QWebElement::computedStyleProperty(const QString &name) const
{
if (!m_element || !m_element->isStyledElement())
return QString();
int propID = cssPropertyID(name);
RefPtr<CSSComputedStyleDeclaration> style = computedStyle(m_element);
if (!propID || !style)
return QString();
return style->getPropertyValue(propID);
}
/*!
Returns the list of classes of this element.
*/
......
......@@ -126,6 +126,8 @@ public:
QString styleProperty(const QString &name) const;
void setStyleProperty(const QString &name, const QString &value);
QString computedStyleProperty(const QString &name) const;
private:
QWebElement(WebCore::Element *domElement);
......
2009-04-23 Antonio Gomes <antonio.gomes@openbossa.org>
Reviewed by Ariya Hidayat.
[Qt] Added QWebElement::computedStyleProperty method.
* Api/qwebelement.cpp:
(QWebElement::computedStyleProperty):
* Api/qwebelement.h:
* tests/qwebelement/tst_qwebelement.cpp:
(tst_QWebElement::computedStyle):
2009-04-23 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Rubber-stamped by Ariya Hidayat.
......
......@@ -79,6 +79,7 @@ private slots:
void frame();
void emptyCollection();
void style();
void computedStyle();
void appendCollection();
void properties();
void appendAndPrepend();
......@@ -432,6 +433,24 @@ void tst_QWebElement::style()
QCOMPARE(p.styleProperty("cursor"), QLatin1String("auto"));
}
void tst_QWebElement::computedStyle()
{
QString html = "<body><p>some text</p></body>";
m_mainFrame->setHtml(html);
QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("auto"));
QVERIFY(!p.computedStyleProperty("cursor").isEmpty());
QVERIFY(p.styleProperty("cursor").isEmpty());
p.setStyleProperty("cursor", "text");
p.setStyleProperty("color", "red");
QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("text"));
QCOMPARE(p.computedStyleProperty("color"), QLatin1String("rgb(255, 0, 0)"));
QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
}
void tst_QWebElement::appendCollection()
{
QString html = "<body><span class='a'>aaa</span><p>first para</p><div>foo</div>"
......
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