[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

hausmann at webkit.org hausmann at webkit.org
Thu Oct 29 20:34:11 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 89d5e74c7df8c175092e413c10125fb7b8e5501c
Author: hausmann at webkit.org <hausmann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 25 08:53:30 2009 +0000

    [Qt] Update QWebElement API to remove script related methods.
    QWebElement::evaluateScript is the only one kept, these are
    removed to postpone most of the QtWebKit<->JavaScript API design
    after 4.6.
    https://bugs.webkit.org/show_bug.cgi?id=29708
    
    Patch by Jocelyn Turcotte <jocelyn.turcotte at nokia.com> on 2009-09-24
    Reviewed by Simon Hausmann.
    
    * Api/qwebelement.cpp:
    * Api/qwebelement.h:
    Methods removed:
    - QWebElement::callFunction
    - QWebElement::functions
    - QWebElement::scriptableProperty
    - QWebElement::setScriptableProperty
    - QWebElement::scriptableProperties
    * tests/qwebelement/tst_qwebelement.cpp:
    (tst_QWebElement::evaluateScript):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48751 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp
index c656bde..fcf61b4 100644
--- a/WebKit/qt/Api/qwebelement.cpp
+++ b/WebKit/qt/Api/qwebelement.cpp
@@ -95,16 +95,6 @@ public:
     It is possible to replace the contents of child elements using
     setPlainText() and setInnerXml(). To replace the element itself and its
     contents, use setOuterXml().
-
-    In the JavaScript DOM interfaces, elements can have additional functions
-    depending on their type. For example, an HTML form element can be triggered
-    to submit the entire form to the web server using the submit() function. A
-    list of these special functions can be obtained in QWebElement using
-    functions(); they can be invoked using callFunction().
-
-    Similarly, element specific properties can be obtained using
-    scriptableProperties() and read or written using scriptableProperty() or
-    setScriptableProperty().
 */
 
 /*!
@@ -673,39 +663,8 @@ static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValu
 }
 
 
-static bool setupScriptObject(WebCore::Element* element, ScriptObject& object, ScriptState*& state, ScriptController*& scriptController)
-{
-    if (!element)
-        return false;
-
-    Document* document = element->document();
-    if (!document)
-        return false;
-
-    Frame* frame = document->frame();
-    if (!frame)
-        return false;
-
-    scriptController = frame->script();
-
-    state = scriptController->globalObject()->globalExec();
-
-    JSC::JSValue thisValue = toJS(state, element);
-    if (!thisValue)
-        return false;
-
-    JSC::JSObject* thisObject = thisValue.toObject(state);
-    if (!thisObject)
-        return false;
-
-    object = ScriptObject(state, thisObject);
-    return true;
-}
-
 /*!
     Executes \a scriptSource with this element as \c this object.
-
-    \sa callFunction()
 */
 QVariant QWebElement::evaluateJavaScript(const QString& scriptSource)
 {
@@ -734,218 +693,6 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource)
 }
 
 /*!
-    Calls the function with the given \a name and \a arguments.
-
-    The underlying DOM element that QWebElement wraps may have dedicated
-    functions, depending on its type. For example, a form element can have the
-    \c submit function, that would submit the form to the destination specified
-    in the HTML.
-
-    \sa functions()
-*/
-QVariant QWebElement::callFunction(const QString &name, const QVariantList &arguments)
-{
-    ScriptState* state = 0;
-    ScriptObject thisObject;
-    ScriptController* scriptController = 0;
-
-    if (!setupScriptObject(m_element, thisObject, state, scriptController))
-        return QVariant();
-
-    ScriptFunctionCall functionCall(state, thisObject, name);
-
-    for (QVariantList::ConstIterator it = arguments.constBegin(), end = arguments.constEnd();
-         it != end; ++it)
-        functionCall.appendArgument(JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), *it));
-
-    bool hadException = false;
-    ScriptValue result = functionCall.call(hadException);
-    if (hadException)
-        return QVariant();
-
-    int distance = 0;
-    return JSC::Bindings::convertValueToQVariant(state, result.jsValue(), QMetaType::Void, &distance);
-}
-
-/*!
-    Returns a list of function names this element supports.
-
-    The function names returned are the same functions callable from the DOM
-    element's JavaScript binding.
-
-    \sa callFunction()
-*/
-QStringList QWebElement::functions() const
-{
-    ScriptState* state = 0;
-    ScriptObject thisObject;
-    ScriptController* scriptController = 0;
-
-    if (!setupScriptObject(m_element, thisObject, state, scriptController))
-        return QStringList();
-
-    JSC::JSObject* object = thisObject.jsObject();
-    if (!object)
-        return QStringList();
-
-    QStringList names;
-
-    // Enumerate the contents of the object
-    JSC::PropertyNameArray properties(state);
-    object->getPropertyNames(state, properties);
-    for (JSC::PropertyNameArray::const_iterator it = properties.begin();
-         it != properties.end(); ++it) {
-
-        JSC::JSValue property = object->get(state, *it);
-        if (!property)
-            continue;
-
-        JSC::JSObject* function = property.toObject(state);
-        if (!function)
-            continue;
-
-        JSC::CallData callData;
-        JSC::CallType callType = function->getCallData(callData);
-        if (callType == JSC::CallTypeNone)
-            continue;
-
-        JSC::UString ustring = (*it).ustring();
-        names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size());
-    }
-
-    if (state->hadException())
-        state->clearException();
-
-    return names;
-}
-
-/*!
-    Returns the value of the element's \a name property. If no such property
-    exists, an invalid QVariant is returned.
-
-    The return value's property has the same value as the corresponding
-    property in the element's JavaScript binding with the same name.
-
-    Information about all available properties is provided through
-    scriptProperties().
-
-    \sa setScriptableProperty(), scriptableProperties()
-*/
-QVariant QWebElement::scriptableProperty(const QString &name) const
-{
-    ScriptState* state = 0;
-    ScriptObject thisObject;
-    ScriptController *scriptController = 0;
-
-    if (!setupScriptObject(m_element, thisObject, state, scriptController))
-        return QVariant();
-
-    String wcName(name);
-    JSC::JSValue property = thisObject.jsObject()->get(state, JSC::Identifier(state, wcName));
-
-    // ###
-    if (state->hadException())
-        state->clearException();
-
-    int distance = 0;
-    return JSC::Bindings::convertValueToQVariant(state, property, QMetaType::Void, &distance);
-}
-
-/*!
-    Sets the value of the element's \a name property to \a value.
-
-    Information about all available properties is provided through
-    scriptProperties().
-
-    Setting the property will affect the corresponding property in the
-    element's JavaScript binding with the same name.
-
-    \sa scriptableProperty(), scriptableProperties()
-*/
-void QWebElement::setScriptableProperty(const QString &name, const QVariant &value)
-{
-    ScriptState* state = 0;
-    ScriptObject thisObject;
-    ScriptController* scriptController = 0;
-
-    if (!setupScriptObject(m_element, thisObject, state, scriptController))
-        return;
-
-    JSC::JSValue jsValue = JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), value);
-    if (!jsValue)
-        return;
-
-    String wcName(name);
-    JSC::PutPropertySlot slot;
-    thisObject.jsObject()->put(state, JSC::Identifier(state, wcName), jsValue, slot);
-    if (state->hadException())
-        state->clearException();
-}
-
-/*!
-    Returns a list of property names this element supports.
-
-    The function names returned are the same properties that are accessible
-    from the DOM element's JavaScript binding.
-
-    \sa setScriptableProperty(), scriptableProperty()
-*/
-QStringList QWebElement::scriptableProperties() const
-{
-    if (!m_element)
-        return QStringList();
-
-    Document* document = m_element->document();
-    if (!document)
-        return QStringList();
-
-    Frame* frame = document->frame();
-    if (!frame)
-        return QStringList();
-
-    ScriptController* script = frame->script();
-    JSC::ExecState* exec = script->globalObject()->globalExec();
-
-    JSC::JSValue thisValue = toJS(exec, m_element);
-    if (!thisValue)
-        return QStringList();
-
-    JSC::JSObject* object = thisValue.toObject(exec);
-    if (!object)
-        return QStringList();
-
-    QStringList names;
-
-    // Enumerate the contents of the object
-    JSC::PropertyNameArray properties(exec);
-    object->getPropertyNames(exec, properties);
-    for (JSC::PropertyNameArray::const_iterator it = properties.begin();
-         it != properties.end(); ++it) {
-
-        JSC::JSValue property = object->get(exec, *it);
-        if (!property)
-            continue;
-
-        JSC::JSObject* function = property.toObject(exec);
-        if (!function)
-            continue;
-
-        JSC::CallData callData;
-        JSC::CallType callType = function->getCallData(callData);
-        if (callType != JSC::CallTypeNone)
-            continue;
-
-        JSC::UString ustring = (*it).ustring();
-        names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size());
-    }
-
-    if (exec->hadException())
-        exec->clearException();
-
-    return names;
-}
-
-/*!
     \enum QWebElement::StyleResolveStrategy
 
     This enum describes how QWebElement's styleProperty resolves the given
diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h
index 132de09..c00e30f 100644
--- a/WebKit/qt/Api/qwebelement.h
+++ b/WebKit/qt/Api/qwebelement.h
@@ -122,13 +122,6 @@ public:
 
     QVariant evaluateJavaScript(const QString& scriptSource);
 
-    QVariant callFunction(const QString& functionName, const QVariantList& arguments = QVariantList());
-    QStringList functions() const;
-
-    QVariant scriptableProperty(const QString& name) const;
-    void setScriptableProperty(const QString& name, const QVariant& value);
-    QStringList scriptableProperties() const;
-
     enum StyleResolveStrategy {
          InlineStyle,
          CascadedStyle,
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 0340859..9467cb9 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,24 @@
+2009-09-24  Jocelyn Turcotte  <jocelyn.turcotte at nokia.com>
+
+        Reviewed by Simon Hausmann.
+
+        [Qt] Update QWebElement API to remove script related methods.
+        QWebElement::evaluateScript is the only one kept, these are
+        removed to postpone most of the QtWebKit<->JavaScript API design
+        after 4.6.
+        https://bugs.webkit.org/show_bug.cgi?id=29708
+
+        * Api/qwebelement.cpp:
+        * Api/qwebelement.h:
+        Methods removed:
+        - QWebElement::callFunction
+        - QWebElement::functions
+        - QWebElement::scriptableProperty
+        - QWebElement::setScriptableProperty
+        - QWebElement::scriptableProperties
+        * tests/qwebelement/tst_qwebelement.cpp:
+        (tst_QWebElement::evaluateScript):
+
 2009-09-25  Jocelyn Turcotte  <jocelyn.turcotte at nokia.com>
 
         Reviewed by Simon Hausmann.
diff --git a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
index ecf3837..778c35b 100644
--- a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
+++ b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
@@ -72,14 +72,10 @@ private slots:
     void namespaceURI();
     void foreachManipulation();
     void evaluateJavaScript();
-    void callFunction();
-    void callFunctionSubmitForm();
-    void functionNames();
     void documentElement();
     void frame();
     void style();
     void computedStyle();
-    void properties();
     void appendAndPrepend();
     void insertBeforeAndAfter();
     void remove();
@@ -293,7 +289,6 @@ void tst_QWebElement::evaluateJavaScript()
     QVERIFY(result.type() == QVariant::String);
     QCOMPARE(result.toString(), QLatin1String("P"));
 
-    QVERIFY(para.functions().contains("hasAttributes"));
     result = para.evaluateJavaScript("this.hasAttributes()");
     QVERIFY(result.isValid());
     QVERIFY(result.type() == QVariant::Bool);
@@ -308,43 +303,6 @@ void tst_QWebElement::evaluateJavaScript()
     QVERIFY(result.toBool());
 }
 
-void tst_QWebElement::callFunction()
-{
-    m_mainFrame->setHtml("<body><p>test");
-    QWebElement body = m_mainFrame->documentElement();
-    QVERIFY(body.functions().contains("hasChildNodes"));
-    QVariant result = body.callFunction("hasChildNodes");
-    QVERIFY(result.isValid());
-    QVERIFY(result.type() == QVariant::Bool);
-    QVERIFY(result.toBool());
-
-    body.callFunction("setAttribute", QVariantList() << "foo" << "bar");
-    QCOMPARE(body.attribute("foo"), QString("bar"));
-}
-
-void tst_QWebElement::callFunctionSubmitForm()
-{
-    m_mainFrame->setHtml(QString("<html><body><form name='tstform' action='data:text/html,foo'method='get'>"
-                                 "<input type='text'><input type='submit'></form></body></html>"), QUrl());
-
-    QWebElement form = m_mainFrame->documentElement().findAll("form").at(0);
-    QVERIFY(form.functions().contains("submit"));
-    QVERIFY(!form.isNull());
-    form.callFunction("submit");
-
-    waitForSignal(m_page, SIGNAL(loadFinished(bool)));
-    QCOMPARE(m_mainFrame->url().toString(), QString("data:text/html,foo?"));
-}
-
-void tst_QWebElement::functionNames()
-{
-    m_mainFrame->setHtml("<body><p>Test");
-
-    QWebElement body = m_mainFrame->documentElement();
-
-    QVERIFY(body.functions().contains("setAttribute"));
-}
-
 void tst_QWebElement::documentElement()
 {
     m_mainFrame->setHtml("<body><p>Test");
@@ -536,37 +494,6 @@ void tst_QWebElement::computedStyle()
     QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red"));
 }
 
-void tst_QWebElement::properties()
-{
-    m_mainFrame->setHtml("<body><form><input type=checkbox id=ourcheckbox checked=true>");
-
-    QWebElement checkBox = m_mainFrame->findFirstElement("#ourcheckbox");
-    QVERIFY(!checkBox.isNull());
-
-    QVERIFY(checkBox.scriptableProperties().contains("checked"));
-
-    QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(true));
-    checkBox.setScriptableProperty("checked", false);
-    QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(false));
-
-    QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
-    QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
-
-    checkBox.setScriptableProperty("non_existant", "test");
-
-    QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant("test"));
-    QVERIFY(checkBox.scriptableProperties().contains("non_existant"));
-
-    // removing scriptableProperties is currently not supported. We should look into this
-    // and consider the option of just allowing through the QtScript API only.
-#if 0
-    checkBox.setScriptableProperty("non_existant", QVariant());
-
-    QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
-    QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
-#endif
-}
-
 void tst_QWebElement::appendAndPrepend()
 {
     QString html = "<body>"

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list