Changeset 54775 in webkit
- Timestamp:
- Feb 15, 2010, 7:36:00 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/bridge/qt/qt_runtime.cpp (modified) (5 diffs)
-
WebKit/qt/Api/qwebelement.h (modified) (3 diffs)
-
WebKit/qt/ChangeLog (modified) (1 diff)
-
WebKit/qt/tests/qwebframe/tst_qwebframe.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54774 r54775 1 2010-02-15 Noam Rosenthal <noam.rosenthal@nokia.com> 2 3 Reviewed by Simon Hausmann. 4 5 [Qt] QtWebkit bridge: enable passing a QWebElement to a signal/slot/property 6 https://bugs.webkit.org/show_bug.cgi?id=34901 7 8 When a signal/slot/property is of type QWebElement, it can seamlessly 9 connect with JS objects that hold a WebCore element. 10 11 New tests, see WebKit/qt/ChangeLog 12 13 * bridge/qt/qt_runtime.cpp: 14 (JSC::Bindings::QtWebElementRuntime::create): A proxy to QWebElement 15 constructor 16 (JSC::Bindings::QtWebElementRuntime::get): A proxy to 17 QWebElement::element 18 (JSC::Bindings::convertValueToQVariant): handle QWebElement 19 (JSC::Bindings::convertQVariantToValue): handle QWebElement 20 1 21 2010-02-15 Pavel Feldman <pfeldman@chromium.org> 2 22 -
trunk/WebCore/bridge/qt/qt_runtime.cpp
r54060 r54775 30 30 #include "JSByteArray.h" 31 31 #include "JSDOMBinding.h" 32 #include "JSDOMWindow.h" 33 #include <JSFunction.h> 32 34 #include "JSGlobalObject.h" 35 #include "JSHTMLElement.h" 33 36 #include "JSLock.h" 34 37 #include "JSObject.h" … … 46 49 #include "qt_pixmapruntime.h" 47 50 #include "qvarlengtharray.h" 48 #include <JSFunction.h>51 #include "qwebelement.h" 49 52 #include <limits.h> 50 53 #include <runtime/Error.h> … … 114 117 } 115 118 #endif 119 120 // this is here as a proxy, so we'd have a class to friend in QWebElement, 121 // as getting/setting a WebCore in QWebElement is private 122 class QtWebElementRuntime { 123 public: 124 static QWebElement create(Element* element) 125 { 126 return QWebElement(element); 127 } 128 129 static Element* get(const QWebElement& element) 130 { 131 return element.m_element; 132 } 133 }; 116 134 117 135 static JSRealType valueRealType(ExecState* exec, JSValue val) … … 723 741 } else if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(hint))) { 724 742 ret = QtPixmapInstance::variantFromObject(object, static_cast<QMetaType::Type>(hint)); 743 } else if (hint == (QMetaType::Type) qMetaTypeId<QWebElement>()) { 744 if (object && object->inherits(&JSHTMLElement::s_info)) 745 ret = QVariant::fromValue<QWebElement>(QtWebElementRuntime::create((static_cast<JSHTMLElement*>(object))->impl())); 746 else 747 ret = QVariant::fromValue<QWebElement>(QWebElement()); 725 748 } else if (hint == (QMetaType::Type) qMetaTypeId<QVariant>()) { 726 749 if (value.isUndefinedOrNull()) { … … 854 877 if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(variant.type()))) 855 878 return QtPixmapInstance::createRuntimeObject(exec, root, variant); 879 880 if (type == qMetaTypeId<QWebElement>()) { 881 if (!root->globalObject()->inherits(&JSDOMWindow::s_info)) 882 return jsUndefined(); 883 884 Document* document = (static_cast<JSDOMWindow*>(root->globalObject()))->impl()->document(); 885 if (!document) 886 return jsUndefined(); 887 888 return toJS(exec, toJSDOMGlobalObject(document, exec), QtWebElementRuntime::get(variant.value<QWebElement>())); 889 } 856 890 857 891 if (type == QMetaType::QVariantMap) { -
trunk/WebKit/qt/Api/qwebelement.h
r50676 r54775 31 31 class Element; 32 32 class Node; 33 } 34 35 namespace JSC { 36 namespace Bindings { 37 class QtWebElementRuntime; 38 } 33 39 } 34 40 … … 154 160 friend class QWebHitTestResultPrivate; 155 161 friend class QWebPage; 162 friend class JSC::Bindings::QtWebElementRuntime; 156 163 157 164 QWebElementPrivate* d; … … 256 263 }; 257 264 265 Q_DECLARE_METATYPE(QWebElement) 266 258 267 #endif // QWEBELEMENT_H -
trunk/WebKit/qt/ChangeLog
r54772 r54775 1 2010-02-15 Noam Rosenthal <noam.rosenthal@nokia.com> 2 3 Reviewed by Simon Hausmann. 4 5 [Qt] QtWebkit bridge: enable passing a QWebElement to a signal/slot/property 6 Add Q_DECLARE_METATYPE to QWebElement, add relevant tests to 7 tst_qwebframe 8 https://bugs.webkit.org/show_bug.cgi?id=34901 9 10 * Api/qwebelement.h: declare metatype 11 * tests/qwebframe/tst_qwebframe.cpp: 12 (MyQObject::webElementProperty): new test for QWebElement 13 (MyQObject::setWebElementProperty): new test for QWebElement 14 (MyQObject::myOverloadedSlot): new test for QWebElement 15 1 16 2010-02-15 Robert Hogan <robert@roberthogan.net>, Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 17 -
trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
r53930 r54775 67 67 Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) 68 68 Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType) 69 Q_PROPERTY(QWebElement webElementProperty READ webElementProperty WRITE setWebElementProperty) 69 70 Q_ENUMS(Policy Strategy) 70 71 Q_FLAGS(Ability) … … 182 183 } 183 184 185 QWebElement webElementProperty() const { 186 return m_webElement; 187 } 188 189 void setWebElementProperty(const QWebElement& element) { 190 m_webElement = element; 191 } 192 184 193 CustomType propWithCustomType() const { 185 194 return m_customType; … … 433 442 m_qtFunctionInvoked = 35; 434 443 m_actuals << arg; 444 } 445 void myOverloadedSlot(const QWebElement &arg) { 446 m_qtFunctionInvoked = 36; 447 m_actuals << QVariant::fromValue<QWebElement>(arg); 435 448 } 436 449 … … 468 481 int m_readOnlyValue; 469 482 QKeySequence m_shortcut; 483 QWebElement m_webElement; 470 484 CustomType m_customType; 471 485 int m_qtFunctionInvoked; … … 686 700 void tst_QWebFrame::getSetStaticProperty() 687 701 { 702 m_page->mainFrame()->setHtml("<html><head><body></body></html>"); 688 703 QCOMPARE(evalJS("typeof myObject.noSuchProperty"), sUndefined); 689 704 … … 825 840 QCOMPARE(evalJS("typeof myObject.stringListProperty[2]"), sString); 826 841 QCOMPARE(evalJS("myObject.stringListProperty[2]"), QLatin1String("true")); 842 evalJS("myObject.webElementProperty=document.body;"); 843 QCOMPARE(evalJS("myObject.webElementProperty.tagName"), QLatin1String("BODY")); 827 844 828 845 // try to delete … … 1887 1904 QCOMPARE(m_myObject->qtFunctionInvoked(), 35); 1888 1905 */ 1906 1907 // should pick myOverloadedSlot(QRegExp) 1908 m_myObject->resetQtFunctionInvoked(); 1909 evalJS("myObject.myOverloadedSlot(document.body)"); 1910 QCOMPARE(m_myObject->qtFunctionInvoked(), 36); 1911 1889 1912 // should pick myOverloadedSlot(QObject*) 1890 1913 m_myObject->resetQtFunctionInvoked();
Note:
See TracChangeset
for help on using the changeset viewer.