Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: third_party/WebKit/WebCore/bridge/qt/qt_runtime.cpp

Issue 20076: WebKit merge 40500:40539 [WebKit side] (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public 5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details. 12 * Lesser General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Lesser General Public 14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software 15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U SA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U SA
17 * 17 *
18 */ 18 */
19 19
20 #include "config.h" 20 #include "config.h"
21 #include "qt_runtime.h" 21 #include "qt_runtime.h"
22 22
23 #include "DateInstance.h" 23 #include "DateInstance.h"
24 #include "DateMath.h" 24 #include "DateMath.h"
25 #include "DatePrototype.h" 25 #include "DatePrototype.h"
26 #include "FunctionPrototype.h" 26 #include "FunctionPrototype.h"
27 #include "Interpreter.h"
27 #include "JSArray.h" 28 #include "JSArray.h"
29 #include "JSByteArray.h"
28 #include "JSDOMBinding.h" 30 #include "JSDOMBinding.h"
29 #include "JSGlobalObject.h" 31 #include "JSGlobalObject.h"
30 #include "JSLock.h" 32 #include "JSLock.h"
31 #include "JSObject.h" 33 #include "JSObject.h"
32 #include "ObjectPrototype.h" 34 #include "ObjectPrototype.h"
33 #include "PropertyNameArray.h" 35 #include "PropertyNameArray.h"
34 #include "RegExpConstructor.h" 36 #include "RegExpConstructor.h"
35 #include "RegExpObject.h" 37 #include "RegExpObject.h"
36 #include "qdatetime.h" 38 #include "qdatetime.h"
37 #include "qdebug.h" 39 #include "qdebug.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 Variant = 0, 90 Variant = 0,
89 Number, 91 Number,
90 Boolean, 92 Boolean,
91 String, 93 String,
92 Date, 94 Date,
93 RegExp, 95 RegExp,
94 Array, 96 Array,
95 QObj, 97 QObj,
96 Object, 98 Object,
97 Null, 99 Null,
98 RTArray 100 RTArray,
101 JSByteArray
99 } JSRealType; 102 } JSRealType;
100 103
101 #if defined(QTWK_RUNTIME_CONVERSION_DEBUG) || defined(QTWK_RUNTIME_MATCH_DEBUG) 104 #if defined(QTWK_RUNTIME_CONVERSION_DEBUG) || defined(QTWK_RUNTIME_MATCH_DEBUG)
102 QDebug operator<<(QDebug dbg, const JSRealType &c) 105 QDebug operator<<(QDebug dbg, const JSRealType &c)
103 { 106 {
104 const char *map[] = { "Variant", "Number", "Boolean", "String", "Date", 107 const char *map[] = { "Variant", "Number", "Boolean", "String", "Date",
105 "RegExp", "Array", "RTObject", "Object", "Null", "RTArray"}; 108 "RegExp", "Array", "RTObject", "Object", "Null", "RTArray"};
106 109
107 dbg.nospace() << "JSType(" << ((int)c) << ", " << map[c] << ")"; 110 dbg.nospace() << "JSType(" << ((int)c) << ", " << map[c] << ")";
108 111
109 return dbg.space(); 112 return dbg.space();
110 } 113 }
111 #endif 114 #endif
112 115
113 static JSRealType valueRealType(ExecState* exec, JSValuePtr val) 116 static JSRealType valueRealType(ExecState* exec, JSValuePtr val)
114 { 117 {
115 if (val.isNumber()) 118 if (val.isNumber())
116 return Number; 119 return Number;
117 else if (val.isString()) 120 else if (val.isString())
118 return String; 121 return String;
119 else if (val.isBoolean()) 122 else if (val.isBoolean())
120 return Boolean; 123 return Boolean;
121 else if (val.isNull()) 124 else if (val.isNull())
122 return Null; 125 return Null;
126 else if (exec->interpreter()->isJSByteArray(val))
127 return JSByteArray;
123 else if (val.isObject()) { 128 else if (val.isObject()) {
124 JSObject *object = val.toObject(exec); 129 JSObject *object = val.toObject(exec);
125 if (object->inherits(&RuntimeArray::s_info)) // RuntimeArray 'inherits' from Array, but not in C++ 130 if (object->inherits(&RuntimeArray::s_info)) // RuntimeArray 'inherits' from Array, but not in C++
126 return RTArray; 131 return RTArray;
127 else if (object->inherits(&JSArray::info)) 132 else if (object->inherits(&JSArray::info))
128 return Array; 133 return Array;
129 else if (object->inherits(&DateInstance::info)) 134 else if (object->inherits(&DateInstance::info))
130 return Date; 135 return Date;
131 else if (object->inherits(&RegExpObject::info)) 136 else if (object->inherits(&RegExpObject::info))
132 return RegExp; 137 return RegExp;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (object->inherits(&NumberObject::info)) 188 if (object->inherits(&NumberObject::info))
184 hint = QMetaType::Double; 189 hint = QMetaType::Double;
185 else if (object->inherits(&BooleanObject::info)) 190 else if (object->inherits(&BooleanObject::info))
186 hint = QMetaType::Bool; 191 hint = QMetaType::Bool;
187 else 192 else
188 hint = QMetaType::QVariantMap; 193 hint = QMetaType::QVariantMap;
189 break; 194 break;
190 case QObj: 195 case QObj:
191 hint = QMetaType::QObjectStar; 196 hint = QMetaType::QObjectStar;
192 break; 197 break;
198 case JSByteArray:
199 hint = QMetaType::QByteArray;
200 break;
193 case Array: 201 case Array:
194 case RTArray: 202 case RTArray:
195 hint = QMetaType::QVariantList; 203 hint = QMetaType::QVariantList;
196 break; 204 break;
197 } 205 }
198 } 206 }
199 207
200 qConvDebug() << "convertValueToQVariant: jstype is " << type << ", hint is" << hint; 208 qConvDebug() << "convertValueToQVariant: jstype is " << type << ", hint is" << hint;
201 209
202 if (value == jsNull() 210 if (value == jsNull()
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 QString qstring = QString::fromUtf16((const ushort*)ustring.rep( )->data(),ustring.size()); 426 QString qstring = QString::fromUtf16((const ushort*)ustring.rep( )->data(),ustring.size());
419 QStringList result; 427 QStringList result;
420 result.append(qstring); 428 result.append(qstring);
421 ret = QVariant(result); 429 ret = QVariant(result);
422 dist = 10; 430 dist = 10;
423 } 431 }
424 break; 432 break;
425 } 433 }
426 434
427 case QMetaType::QByteArray: { 435 case QMetaType::QByteArray: {
428 UString ustring = value.toString(exec); 436 if (type == JSByteArray) {
429 ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data (),ustring.size()).toLatin1()); 437 WTF::ByteArray* arr = asByteArray(value)->storage();
430 if (type == String) 438 ret = QVariant(QByteArray(reinterpret_cast<const char*>(arr->dat a()), arr->length()));
431 dist = 5; 439 dist = 0;
432 else 440 } else {
433 dist = 10; 441 UString ustring = value.toString(exec);
442 ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()-> data(),ustring.size()).toLatin1());
443 if (type == String)
444 dist = 5;
445 else
446 dist = 10;
447 }
434 break; 448 break;
435 } 449 }
436 450
437 case QMetaType::QDateTime: 451 case QMetaType::QDateTime:
438 case QMetaType::QDate: 452 case QMetaType::QDate:
439 case QMetaType::QTime: 453 case QMetaType::QTime:
440 if (type == Date) { 454 if (type == Date) {
441 DateInstance* date = static_cast<DateInstance*>(object); 455 DateInstance* date = static_cast<DateInstance*>(object);
442 GregorianDateTime gdt; 456 GregorianDateTime gdt;
443 date->getUTCTime(gdt); 457 date->getUTCTime(gdt);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 dt.second = time.second(); 829 dt.second = time.second();
816 dt.isDST = -1; 830 dt.isDST = -1;
817 double ms = JSC::gregorianDateTimeToMS(dt, time.msec(), /*inputIsUTC*/ f alse); 831 double ms = JSC::gregorianDateTimeToMS(dt, time.msec(), /*inputIsUTC*/ f alse);
818 832
819 DateInstance* instance = new (exec) DateInstance(exec->lexicalGlobalObje ct()->dateStructure()); 833 DateInstance* instance = new (exec) DateInstance(exec->lexicalGlobalObje ct()->dateStructure());
820 instance->setInternalValue(jsNumber(exec, trunc(ms))); 834 instance->setInternalValue(jsNumber(exec, trunc(ms)));
821 return instance; 835 return instance;
822 } 836 }
823 837
824 if (type == QMetaType::QByteArray) { 838 if (type == QMetaType::QByteArray) {
825 QByteArray ba = variant.value<QByteArray>(); 839 QByteArray qtByteArray = variant.value<QByteArray>();
826 UString ustring(ba.constData()); 840 WTF::RefPtr<WTF::ByteArray> wtfByteArray = WTF::ByteArray::create(qtByte Array.length());
827 return jsString(exec, ustring); 841 qMemCopy(wtfByteArray->data(), qtByteArray.constData(), qtByteArray.leng th());
842 return new (exec) JSC::JSByteArray(exec, JSC::JSByteArray::createStructu re(jsNull()), wtfByteArray.get());
828 } 843 }
829 844
830 if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) { 845 if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) {
831 QObject* obj = variant.value<QObject*>(); 846 QObject* obj = variant.value<QObject*>();
832 return QtInstance::getQtInstance(obj, root)->createRuntimeObject(exec); 847 return QtInstance::getQtInstance(obj, root)->createRuntimeObject(exec);
833 } 848 }
834 849
835 if (type == QMetaType::QVariantMap) { 850 if (type == QMetaType::QVariantMap) {
836 // create a new object, and stuff properties into it 851 // create a new object, and stuff properties into it
837 JSObject* ret = constructEmptyObject(exec); 852 JSObject* ret = constructEmptyObject(exec);
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 return convertQVariantToValue(exec, rootObject(), QVariant::fromValue(va l)); 1764 return convertQVariantToValue(exec, rootObject(), QVariant::fromValue(va l));
1750 } 1765 }
1751 1766
1752 return jsUndefined(); 1767 return jsUndefined();
1753 } 1768 }
1754 1769
1755 // =============== 1770 // ===============
1756 1771
1757 } } 1772 } }
1758 1773
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698