Title: [125275] trunk/Source
Revision
125275
Author
[email protected]
Date
2012-08-10 06:37:46 -0700 (Fri, 10 Aug 2012)

Log Message

[Qt] Remove QRegExp <> JS RegExp conversion
https://bugs.webkit.org/show_bug.cgi?id=93716

Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Removed automatic conversion between QRegExp and JS regular expressions. The semantics
between the expressions are totally different, which can cause data loss and unexpected
behaviour. QJSEngine/Value doesn't have this conversion anymore neither.

* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::operator<<):
(JSC::Bindings::valueRealType):
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):

Source/WebKit/qt:

Removed tests that cover the automatic QRegExp <> JS RegExp conversion. See WebCore
ChangeLog for details.

* tests/qobjectbridge/tst_qobjectbridge.cpp:
(MyQObject::emitMySignalWithDateTimeArg):
(MyQObject):
(tst_QObjectBridge::overloadedSlots):
(tst_QObjectBridge::typeConversion):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125274 => 125275)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 13:35:48 UTC (rev 125274)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 13:37:46 UTC (rev 125275)
@@ -1,3 +1,20 @@
+2012-08-10  Simon Hausmann  <[email protected]>
+
+        [Qt] Remove QRegExp <> JS RegExp conversion
+        https://bugs.webkit.org/show_bug.cgi?id=93716
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Removed automatic conversion between QRegExp and JS regular expressions. The semantics
+        between the expressions are totally different, which can cause data loss and unexpected
+        behaviour. QJSEngine/Value doesn't have this conversion anymore neither.
+
+        * bridge/qt/qt_runtime.cpp:
+        (JSC::Bindings::operator<<):
+        (JSC::Bindings::valueRealType):
+        (JSC::Bindings::convertValueToQVariant):
+        (JSC::Bindings::convertQVariantToValue):
+
 2012-08-10  Andrey Kosyakov  <[email protected]>
 
         Web Inspector: console.timeStamp() marked are not shown in Timeline overview

Modified: trunk/Source/WebCore/bridge/qt/qt_runtime.cpp (125274 => 125275)


--- trunk/Source/WebCore/bridge/qt/qt_runtime.cpp	2012-08-10 13:35:48 UTC (rev 125274)
+++ trunk/Source/WebCore/bridge/qt/qt_runtime.cpp	2012-08-10 13:37:46 UTC (rev 125275)
@@ -40,8 +40,6 @@
 #include "JSUint8ClampedArray.h"
 #include "ObjectPrototype.h"
 #include "PropertyNameArray.h"
-#include "RegExpConstructor.h"
-#include "RegExpObject.h"
 #include "qdatetime.h"
 #include "qdebug.h"
 #include "qmetaobject.h"
@@ -101,7 +99,6 @@
     Boolean,
     String,
     Date,
-    RegExp,
     Array,
     QObj,
     Object,
@@ -114,7 +111,7 @@
 QDebug operator<<(QDebug dbg, const JSRealType &c)
 {
      const char *map[] = { "Variant", "Number", "Boolean", "String", "Date",
-         "RegExp", "Array", "RTObject", "Object", "Null", "RTArray"};
+         "Array", "RTObject", "Object", "Null", "RTArray"};
 
      dbg.nospace() << "JSType(" << ((int)c) << ", " <<  map[c] << ")";
 
@@ -174,8 +171,6 @@
             return Array;
         else if (object->inherits(&DateInstance::s_info))
             return Date;
-        else if (object->inherits(&RegExpObject::s_info))
-            return RegExp;
         else if (object->inherits(&RuntimeObject::s_info))
             return QObj;
         return Object;
@@ -258,9 +253,6 @@
             case Date:
                 hint = QMetaType::QDateTime;
                 break;
-            case RegExp:
-                hint = QMetaType::QRegExp;
-                break;
             case Object:
                 if (object->inherits(&NumberObject::s_info))
                     hint = QMetaType::Double;
@@ -584,43 +576,6 @@
             }
             break;
 
-        case QMetaType::QRegExp:
-            if (type == RegExp) {
-/*
-                RegExpObject *re = static_cast<RegExpObject*>(object);
-*/
-                // Attempt to convert.. a bit risky
-                UString ustring = value.toString(exec)->value(exec);
-                QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
-
-                // this is of the form '/xxxxxx/i'
-                int firstSlash = qstring.indexOf(QLatin1Char('/'));
-                int lastSlash = qstring.lastIndexOf(QLatin1Char('/'));
-                if (firstSlash >=0 && lastSlash > firstSlash) {
-                    QRegExp realRe;
-
-                    realRe.setPattern(qstring.mid(firstSlash + 1, lastSlash - firstSlash - 1));
-
-                    if (qstring.mid(lastSlash + 1).contains(QLatin1Char('i')))
-                        realRe.setCaseSensitivity(Qt::CaseInsensitive);
-
-                    ret = QVariant::fromValue(realRe);
-                    dist = 0;
-                } else {
-                    qConvDebug() << "couldn't parse a JS regexp";
-                }
-            } else if (type == String) {
-                UString ustring = value.toString(exec)->value(exec);
-                QString qstring = QString((const QChar*)ustring.impl()->characters(), ustring.length());
-
-                QRegExp re(qstring);
-                if (re.isValid()) {
-                    ret = QVariant::fromValue(re);
-                    dist = 10;
-                }
-            }
-            break;
-
         case QMetaType::QObjectStar:
             if (type == QObj) {
                 QtInstance* qtinst = QtInstance::getInstance(object);
@@ -852,20 +807,6 @@
         type == QMetaType::Double)
         return jsNumber(variant.toDouble());
 
-    if (type == QMetaType::QRegExp) {
-        QRegExp re = variant.value<QRegExp>();
-
-        if (re.isValid()) {
-            UString pattern((UChar*)re.pattern().utf16(), re.pattern().length());
-            RegExpFlags flags = (re.caseSensitivity() == Qt::CaseInsensitive) ? FlagIgnoreCase : NoFlags;
-
-            JSC::RegExp* regExp = JSC::RegExp::create(exec->globalData(), pattern, flags);
-            if (regExp->isValid())
-                return RegExpObject::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp);
-            return jsNull();
-        }
-    }
-
     if (type == QMetaType::QDateTime ||
         type == QMetaType::QDate ||
         type == QMetaType::QTime) {

Modified: trunk/Source/WebKit/qt/ChangeLog (125274 => 125275)


--- trunk/Source/WebKit/qt/ChangeLog	2012-08-10 13:35:48 UTC (rev 125274)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-08-10 13:37:46 UTC (rev 125275)
@@ -1,3 +1,19 @@
+2012-08-10  Simon Hausmann  <[email protected]>
+
+        [Qt] Remove QRegExp <> JS RegExp conversion
+        https://bugs.webkit.org/show_bug.cgi?id=93716
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Removed tests that cover the automatic QRegExp <> JS RegExp conversion. See WebCore
+        ChangeLog for details.
+
+        * tests/qobjectbridge/tst_qobjectbridge.cpp:
+        (MyQObject::emitMySignalWithDateTimeArg):
+        (MyQObject):
+        (tst_QObjectBridge::overloadedSlots):
+        (tst_QObjectBridge::typeConversion):
+
 2012-08-09  Simon Hausmann  <[email protected]>
 
         [Qt] Remove support for __qt_sender__ in QObject bridge

Modified: trunk/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp (125274 => 125275)


--- trunk/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp	2012-08-10 13:35:48 UTC (rev 125274)
+++ trunk/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp	2012-08-10 13:37:46 UTC (rev 125275)
@@ -442,10 +442,6 @@
     {
         emit mySignalWithDateTimeArg(dt);
     }
-    void emitMySignalWithRegexArg(QRegExp r)
-    {
-        emit mySignalWithRegexArg(r);
-    }
 
 public Q_SLOTS:
     void mySlot()
@@ -542,12 +538,6 @@
         m_actuals << arg;
     }
 
-    void myOverloadedSlot(const QRegExp &arg)
-    {
-        m_qtFunctionInvoked = 34;
-        m_actuals << arg;
-    }
-
     void myOverloadedSlot(const QVariant &arg)
     {
         m_qtFunctionInvoked = 35;
@@ -575,7 +565,6 @@
     void mySignalWithDoubleArg(double);
     void mySignal2(bool arg = false);
     void mySignalWithDateTimeArg(QDateTime);
-    void mySignalWithRegexArg(QRegExp);
 
 private:
     int m_intValue;
@@ -1747,11 +1736,6 @@
     evalJS("myObject.myOverloadedSlot(new Date())");
     QCOMPARE(m_myObject->qtFunctionInvoked(), 32);
 
-    // should pick myOverloadedSlot(QRegExp)
-    m_myObject->resetQtFunctionInvoked();
-    evalJS("myObject.myOverloadedSlot(new RegExp())");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 34);
-
     // should pick myOverloadedSlot(QVariant)
     /* XFAIL
     m_myObject->resetQtFunctionInvoked();
@@ -1971,8 +1955,6 @@
     QCOMPARE(evalJS("window.__date_equals"), sTrue);
     evalJS("delete window.__date_equals");
     evalJS("myObject.mySignalWithDateTimeArg.disconnect(checkDate); delete checkDate;");
-
-    // ### RegExps
 }
 
 class StringListTestObject : public QObject {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to