Changeset 42238 in webkit


Ignore:
Timestamp:
Apr 6, 2009 4:25:37 AM (11 years ago)
Author:
Simon Hausmann
Message:

WebCore:

2009-04-06 Simon Hausmann <simon.hausmann@nokia.com>

Reviewed by Tor Arne Vestbø.

Add new files to the Qt build.
Export helper function from the Qt JSC binding, needed in WebKit/qt.

WebKit/qt:

2009-04-06 Simon Hausmann <simon.hausmann@nokia.com>

Ariya Hidayat <ariya.hidayat@nokia.com>
Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Genevieve Mak <gen@staikos.net>

Reviewed by Tor Arne Vestbø, Simon Hausmann

First revision of new API in the Qt port to access the DOM.

Location:
trunk
Files:
5 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r42237 r42238  
     12009-04-06  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        Reviewed by Tor Arne Vestbø.
     4
     5        Add new files to the Qt build.
     6        Export helper function from the Qt JSC binding, needed in WebKit/qt.
     7
     8        * WebCore.pro: Add new files.
     9        * bridge/qt/qt_runtime.h: Declare convertQVariantToValue.
     10
    1112009-04-06  Simon Hausmann  <simon.hausmann@nokia.com>
    212
  • trunk/WebCore/WebCore.pro

    r42167 r42238  
    11931193    ../WebKit/qt/Api/qwebpage.cpp \
    11941194    ../WebKit/qt/Api/qwebview.cpp \
     1195    ../WebKit/qt/Api/qwebelement.cpp \
    11951196    ../WebKit/qt/Api/qwebhistory.cpp \
    11961197    ../WebKit/qt/Api/qwebsettings.cpp \
  • trunk/WebCore/bridge/qt/qt_runtime.h

    r42233 r42238  
    225225
    226226QVariant convertValueToQVariant(ExecState* exec, JSValuePtr value, QMetaType::Type hint, int *distance);
     227JSValuePtr convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, const QVariant& variant);
    227228
    228229} // namespace Bindings
  • trunk/WebKit/qt/Api/headers.pri

    r39744 r42238  
    66                     $$PWD/qwebhistoryinterface.h \
    77                     $$PWD/qwebdatabase.h \
    8                      $$PWD/qwebsecurityorigin.h
     8                     $$PWD/qwebsecurityorigin.h \
     9                     $$PWD/qwebelement.h
  • trunk/WebKit/qt/Api/qwebframe.cpp

    r42099 r42238  
    2626#include "qwebsecurityorigin.h"
    2727#include "qwebsecurityorigin_p.h"
     28#include "qwebelement.h"
    2829
    2930#include "DocumentLoader.h"
     
    962963        return QSize();
    963964    return QSize(view->contentsWidth(), view->contentsHeight());
     965}
     966
     967/*!
     968    \since 4.6
     969
     970    Returns the document element of this frame.
     971
     972    The document element provides access to the entire structured
     973    content of the frame.
     974*/
     975QWebElement QWebFrame::documentElement() const
     976{
     977    WebCore::Document *doc = d->frame->document();
     978    if (!doc)
     979        return QWebElement();
     980    return QWebElement(doc->documentElement());
     981}
     982
     983/*!
     984    \since 4.6
     985    Returns a new selection of elements that are children of the frame's
     986    document element and that match the given CSS selector \a query.
     987*/
     988QWebElementSelection QWebFrame::selectElements(const QString &query) const
     989{
     990    return documentElement().select(query);
     991}
     992
     993/*!
     994    \since 4.6
     995    Returns the first element in the frame's document that matches the
     996    given CSS selector \a query. Returns a null element if there is no
     997    match.
     998*/
     999QWebElement QWebFrame::selectElement(const QString &query) const
     1000{
     1001    return documentElement().selectFirst(query);
    9641002}
    9651003
     
    14481486
    14491487/*!
     1488    \since 4.6
     1489    Returns the underlying DOM element as QWebElement.
     1490*/
     1491QWebElement QWebHitTestResult::element() const
     1492{
     1493    if (!d || !d->innerNonSharedNode || !d->innerNonSharedNode->isElementNode())
     1494        return QWebElement();
     1495
     1496    return QWebElement(static_cast<WebCore::Element*>(d->innerNonSharedNode.get()));
     1497}
     1498
     1499/*!
    14501500    Returns the frame the hit test was executed in.
    14511501*/
  • trunk/WebKit/qt/Api/qwebframe.h

    r40973 r42238  
    11/*
    2     Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     2    Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies)
    33    Copyright (C) 2007 Staikos Computing Services Inc.
    44
     
    5050class QWebHistoryItem;
    5151class QWebSecurityOrigin;
     52class QWebElement;
     53class QWebElementSelection;
    5254
    5355namespace WebCore {
     
    8890    bool isContentEditable() const;
    8991    bool isContentSelected() const;
     92
     93    QWebElement element() const;
    9094
    9195    QWebFrame *frame() const;
     
    175179    QSize contentsSize() const;
    176180
     181    QWebElement documentElement() const;
     182    QWebElementSelection selectElements(const QString &query) const;
     183    QWebElement selectElement(const QString &query) const;
     184
    177185    QWebHitTestResult hitTestContent(const QPoint &pos) const;
    178186
  • trunk/WebKit/qt/ChangeLog

    r42166 r42238  
     12009-04-06  Simon Hausmann  <simon.hausmann@nokia.com>
     2            Ariya Hidayat <ariya.hidayat@nokia.com>
     3            Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
     4            Genevieve Mak <gen@staikos.net>
     5
     6        Reviewed by Tor Arne Vestbø, Simon Hausmann
     7
     8        First revision of new API in the Qt port to access the DOM.
     9
     10        * Api/headers.pri: Added qwebelement.h to the API headers.
     11        * Api/qwebelement.cpp: Added.
     12        * Api/qwebelement.h: Added.
     13        * Api/qwebframe.cpp:
     14        (QWebFrame::documentElement): Added accessor for the document element.
     15        (QWebFrame::selectElements): Added convenienc query method.
     16        (QWebFrame::selectElement): Ditto.
     17        (QWebHitTestResult::element): Added accessor for underlying DOM element.
     18        * Api/qwebframe.h:
     19        * QtLauncher/main.cpp: Simple test gui for element selections.
     20        * tests/qwebelement/qwebelement.pro: Added.
     21        * tests/qwebelement/tst_qwebelement.cpp: Added.
     22        * tests/tests.pro: Added QWebElement & QWebElementSelection unit tests.
     23
    1242009-04-02  Simon Hausmann  <simon.hausmann@nokia.com>
    225
  • trunk/WebKit/qt/QtLauncher/main.cpp

    r39173 r42238  
    11/*
    2  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
    33 * Copyright (C) 2006 George Staikos <staikos@kde.org>
    44 * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
     
    3434#include <qwebframe.h>
    3535#include <qwebsettings.h>
     36#include <qwebelement.h>
    3637
    3738#include <QtGui>
     
    182183        qDebug() << "HTML: " << view->page()->mainFrame()->toHtml();
    183184    }
     185
     186    void selectElements() {
     187        bool ok;
     188        QString str = QInputDialog::getText(this, "Select elements", "Choose elements",
     189                                            QLineEdit::Normal, "a", &ok);
     190        if (ok && !str.isEmpty()) {
     191            QWebElementSelection result =  view->page()->mainFrame()->selectElements(str);
     192            foreach (QWebElement e, result)
     193                e.setStyleProperty("background-color", "yellow");
     194            statusBar()->showMessage(QString("%1 element(s) selected").arg(result.count()), 5000);
     195        }
     196    }
     197
    184198private:
    185199
     
    273287        view->pageAction(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I));
    274288        view->pageAction(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U));
     289
     290        QMenu *toolsMenu = menuBar()->addMenu("&Tools");
     291        toolsMenu->addAction("Select elements...", this, SLOT(selectElements()));
     292
    275293    }
    276294
  • trunk/WebKit/qt/tests/tests.pro

    r35621 r42238  
    11
    22TEMPLATE = subdirs
    3 SUBDIRS = qwebframe qwebpage
     3SUBDIRS = qwebframe qwebpage qwebelement
Note: See TracChangeset for help on using the changeset viewer.