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

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

        Reviewed by Ariya Hidayat.

        QWebElementSelection renamed to QWebElementCollection.

        * Api/qwebelement.cpp:
        (QWebElement::findAll):
        (QWebElementCollectionPrivate::QWebElementCollectionPrivate):
        (QWebElementCollectionPrivate::create):
        (QWebElementCollection::QWebElementCollection):
        (QWebElementCollection::operator=):
        (QWebElementCollection::~QWebElementCollection):
        (QWebElementCollection::operator+):
        (QWebElementCollection::append):
        (QWebElementCollection::count):
        (QWebElementCollection::at):
        (QWebElementCollection::toList):
        * Api/qwebelement.h:
        * Api/qwebframe.cpp:
        (QWebFrame::findAllElements):
        * Api/qwebframe.h:
        * QtLauncher/main.cpp:
        (MainWindow::selectElements):
        * tests/qwebelement/tst_qwebelement.cpp:
        (tst_QWebElement::simpleCollection):
        (tst_QWebElement::iteration):
        (tst_QWebElement::emptyCollection):
        (tst_QWebElement::appendCollection):
        (tst_QWebElement::nullSelect):

git-svn-id: svn://svn.chromium.org/blink/trunk@42710 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cd80ce0f
......@@ -31,7 +31,7 @@ namespace WebCore {
}
class QWebFrame;
class QWebElementSelection;
class QWebElementCollection;
class QWebElementPrivate;
class QWEBKIT_EXPORT QWebElement
......@@ -47,7 +47,7 @@ public:
bool isNull() const;
QWebElementSelection findAll(const QString &query) const;
QWebElementCollection findAll(const QString &query) const;
QWebElement findFirst(const QString &query) const;
void setPlainText(const QString &text);
......@@ -93,7 +93,7 @@ public:
QWebElement document() const;
QWebFrame *webFrame() const;
// TODO: Add QWebElementSelection overloads
// TODO: Add QWebElementCollection overloads
void append(const QString &html);
void append(QWebElement element);
......@@ -130,31 +130,31 @@ private:
QWebElement(WebCore::Element *domElement);
friend class QWebFrame;
friend class QWebElementSelection;
friend class QWebElementCollection;
friend class QWebHitTestResult;
QWebElementPrivate *d;
WebCore::Element *m_element;
};
class QWebElementSelectionPrivate;
class QWebElementCollectionPrivate;
class QWEBKIT_EXPORT QWebElementSelection
class QWEBKIT_EXPORT QWebElementCollection
{
public:
QWebElementSelection();
QWebElementSelection(const QWebElement &contextElement, const QString &query);
QWebElementSelection(const QWebElementSelection &);
QWebElementSelection &operator=(const QWebElementSelection &);
~QWebElementSelection();
QWebElementSelection operator+(const QWebElementSelection &other) const;
inline QWebElementSelection &operator+=(const QWebElementSelection &other)
QWebElementCollection();
QWebElementCollection(const QWebElement &contextElement, const QString &query);
QWebElementCollection(const QWebElementCollection &);
QWebElementCollection &operator=(const QWebElementCollection &);
~QWebElementCollection();
QWebElementCollection operator+(const QWebElementCollection &other) const;
inline QWebElementCollection &operator+=(const QWebElementCollection &other)
{
append(other); return *this;
}
void append(const QWebElementSelection &selection);
void append(const QWebElementCollection &collection);
int count() const;
QWebElement at(int i) const;
......@@ -167,9 +167,9 @@ public:
class const_iterator {
public:
int i;
const QWebElementSelection *s;
const QWebElementCollection *s;
inline const_iterator(const QWebElementSelection *selection, int index) : i(index), s(selection) {}
inline const_iterator(const QWebElementCollection *collection, int index) : i(index), s(collection) {}
inline const_iterator(const const_iterator &o) : i(o.i), s(o.s) {}
inline const QWebElement operator*() const { return s->at(i); }
......@@ -200,7 +200,7 @@ public:
inline const QWebElement operator[](int i) const { return at(i); }
private:
QExplicitlySharedDataPointer<QWebElementSelectionPrivate> d;
QExplicitlySharedDataPointer<QWebElementCollectionPrivate> d;
};
#endif // QWEBELEMENT_H
......@@ -982,10 +982,10 @@ QWebElement QWebFrame::documentElement() const
/*!
\since 4.6
Returns a new selection of elements that are children of the frame's
Returns a new collection of elements that are children of the frame's
document element and that match the given CSS selector \a query.
*/
QWebElementSelection QWebFrame::findAllElements(const QString &query) const
QWebElementCollection QWebFrame::findAllElements(const QString &query) const
{
return documentElement().findAll(query);
}
......
......@@ -50,7 +50,7 @@ class QWebHitTestResult;
class QWebHistoryItem;
class QWebSecurityOrigin;
class QWebElement;
class QWebElementSelection;
class QWebElementCollection;
namespace WebCore {
class WidgetPrivate;
......@@ -179,7 +179,7 @@ public:
QSize contentsSize() const;
QWebElement documentElement() const;
QWebElementSelection findAllElements(const QString &query) const;
QWebElementCollection findAllElements(const QString &query) const;
QWebElement findFirstElement(const QString &query) const;
QWebHitTestResult hitTestContent(const QPoint &pos) const;
......
2009-04-21 Antonio Gomes <antonio.gomes@openbossa.org>
Reviewed by Ariya Hidayat.
QWebElementSelection renamed to QWebElementCollection.
* Api/qwebelement.cpp:
(QWebElement::findAll):
(QWebElementCollectionPrivate::QWebElementCollectionPrivate):
(QWebElementCollectionPrivate::create):
(QWebElementCollection::QWebElementCollection):
(QWebElementCollection::operator=):
(QWebElementCollection::~QWebElementCollection):
(QWebElementCollection::operator+):
(QWebElementCollection::append):
(QWebElementCollection::count):
(QWebElementCollection::at):
(QWebElementCollection::toList):
* Api/qwebelement.h:
* Api/qwebframe.cpp:
(QWebFrame::findAllElements):
* Api/qwebframe.h:
* QtLauncher/main.cpp:
(MainWindow::selectElements):
* tests/qwebelement/tst_qwebelement.cpp:
(tst_QWebElement::simpleCollection):
(tst_QWebElement::iteration):
(tst_QWebElement::emptyCollection):
(tst_QWebElement::appendCollection):
(tst_QWebElement::nullSelect):
2009-04-17 Laszlo Gombos <laszlo.1.gombos@nokia.com>
Reviewed by Simon Hausmann.
......
......@@ -188,7 +188,7 @@ protected slots:
QString str = QInputDialog::getText(this, "Select elements", "Choose elements",
QLineEdit::Normal, "a", &ok);
if (ok && !str.isEmpty()) {
QWebElementSelection result = view->page()->mainFrame()->findAllElements(str);
QWebElementCollection result = view->page()->mainFrame()->findAllElements(str);
foreach (QWebElement e, result)
e.setStyleProperty("background-color", "yellow");
statusBar()->showMessage(QString("%1 element(s) selected").arg(result.count()), 5000);
......
......@@ -65,7 +65,7 @@ public slots:
private slots:
void textHtml();
void simpleSelection();
void simpleCollection();
void attributes();
void attributesNS();
void classes();
......@@ -77,9 +77,9 @@ private slots:
void functionNames();
void documentElement();
void frame();
void emptySelection();
void emptyCollection();
void style();
void appendSelection();
void appendCollection();
void properties();
void appendAndPrepend();
void insertBeforeAndAfter();
......@@ -132,13 +132,13 @@ void tst_QWebElement::textHtml()
QCOMPARE(body.toXml(QWebElement::InnerXml), html);
}
void tst_QWebElement::simpleSelection()
void tst_QWebElement::simpleCollection()
{
QString html = "<body><p>first para</p><p>second para</p></body>";
m_mainFrame->setHtml(html);
QWebElement body = m_mainFrame->documentElement();
QWebElementSelection paras = body.findAll("p");
QWebElementCollection paras = body.findAll("p");
QCOMPARE(paras.count(), 2);
QList<QWebElement> list = paras.toList();
......@@ -294,7 +294,7 @@ void tst_QWebElement::iteration()
m_mainFrame->setHtml(html);
QWebElement body = m_mainFrame->documentElement();
QWebElementSelection paras = body.findAll("p");
QWebElementCollection paras = body.findAll("p");
QList<QWebElement> referenceList = paras.toList();
QList<QWebElement> foreachList;
......@@ -410,10 +410,10 @@ void tst_QWebElement::frame()
QVERIFY(secondPara.webFrame() == secondFrame);
}
void tst_QWebElement::emptySelection()
void tst_QWebElement::emptyCollection()
{
QWebElementSelection emptySelection;
QCOMPARE(emptySelection.count(), 0);
QWebElementCollection emptyCollection;
QCOMPARE(emptyCollection.count(), 0);
}
void tst_QWebElement::style()
......@@ -432,34 +432,34 @@ void tst_QWebElement::style()
QCOMPARE(p.styleProperty("cursor"), QLatin1String("auto"));
}
void tst_QWebElement::appendSelection()
void tst_QWebElement::appendCollection()
{
QString html = "<body><span class='a'>aaa</span><p>first para</p><div>foo</div>"
"<span class='b'>bbb</span><p>second para</p><div>bar</div></body>";
m_mainFrame->setHtml(html);
QWebElement body = m_mainFrame->documentElement();
QWebElementSelection selection = body.findAll("p");
QCOMPARE(selection.count(), 2);
QWebElementCollection collection = body.findAll("p");
QCOMPARE(collection.count(), 2);
selection.append(body.findAll("div"));
QCOMPARE(selection.count(), 4);
collection.append(body.findAll("div"));
QCOMPARE(collection.count(), 4);
selection += body.findAll("span.a");
QCOMPARE(selection.count(), 5);
collection += body.findAll("span.a");
QCOMPARE(collection.count(), 5);
QWebElementSelection all = selection + body.findAll("span.b");
QWebElementCollection all = collection + body.findAll("span.b");
QCOMPARE(all.count(), 6);
QCOMPARE(selection.count(), 5);
QCOMPARE(collection.count(), 5);
all += selection;
all += collection;
QCOMPARE(all.count(), 11);
QCOMPARE(selection.count(), 5);
QWebElementSelection test;
test.append(selection);
QCOMPARE(collection.count(), 5);
QWebElementCollection test;
test.append(collection);
QCOMPARE(test.count(), 5);
test.append(QWebElementSelection());
test.append(QWebElementCollection());
QCOMPARE(test.count(), 5);
}
......@@ -696,8 +696,8 @@ void tst_QWebElement::nullSelect()
{
m_mainFrame->setHtml("<body><p>Test");
QWebElementSelection selection = m_mainFrame->findAllElements("invalid{syn(tax;;%#$f223e>>");
QVERIFY(selection.count() == 0);
QWebElementCollection collection = m_mainFrame->findAllElements("invalid{syn(tax;;%#$f223e>>");
QVERIFY(collection.count() == 0);
}
void tst_QWebElement::firstChildNextSibling()
......
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