2010-09-07 Mihai Parparita <mihaip@chromium.org>
Reviewed by Oliver Hunt.
pushState and replaceState do not clone RegExp objects correctly
https://bugs.webkit.org/show_bug.cgi?id=44718
Move internal representation of JSC::RegExp (which depends on wether
YARR and YARR_JIT is enabled) into RegExpRepresentation which can live
in the implementation only. This makes it feasible to use RegExp in
WebCore without bringing in all of YARR.
* JavaScriptCore.exp: Export RegExp and RegExpObject functions that are
needed inside WebCore's JSC bindings.
* runtime/RegExp.cpp:
(JSC::RegExpRepresentation::~RegExpRepresentation):
(JSC::RegExp::RegExp):
(JSC::RegExp::~RegExp):
(JSC::RegExp::compile):
(JSC::RegExp::match):
* runtime/RegExp.h:
2010-09-07 Mihai Parparita <mihaip@chromium.org>
Reviewed by Oliver Hunt.
pushState and replaceState do not clone RegExp objects correctly
https://bugs.webkit.org/show_bug.cgi?id=44718
Make RegExp test of pushstate-object-types.html actually test a RegExp
value with flags.
Also adds ImageData since it can be serialized as of r54646.
* fast/loader/stateobjects/pushstate-object-types-expected.txt:
* fast/loader/stateobjects/pushstate-object-types.html:
2010-09-07 Mihai Parparita <mihaip@chromium.org>
Reviewed by Oliver Hunt.
pushState and replaceState do not clone RegExp objects correctly
https://bugs.webkit.org/show_bug.cgi?id=44718
Add RegExp support to the JSC implementation of SerializedScriptValue
(it stores the pattern and flags read from a RegExpObject, and creates
a new one on deserialization).
Tests: fast/loader/stateobjects/pushstate-object-types.html
* ForwardingHeaders/runtime/RegExp.h: Added.
* ForwardingHeaders/runtime/RegExpObject.h: Added.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneDeserializer::readTerminal):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/bindings/js/SerializedScriptValue.cpp b/WebCore/bindings/js/SerializedScriptValue.cpp
index 92c8936..f2290888 100644
--- a/WebCore/bindings/js/SerializedScriptValue.cpp
+++ b/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -44,6 +44,8 @@
#include <runtime/ExceptionHelpers.h>
#include <runtime/JSLock.h>
#include <runtime/PropertyNameArray.h>
+#include <runtime/RegExp.h>
+#include <runtime/RegExpObject.h>
#include <wtf/ByteArray.h>
#include <wtf/HashTraits.h>
#include <wtf/Vector.h>
@@ -83,6 +85,7 @@
BlobTag = 15,
StringTag = 16,
EmptyStringTag = 17,
+ RegExpTag = 18,
ErrorTag = 255
};
@@ -145,6 +148,8 @@
* Blob :-
* BlobTag <url:StringData><type:StringData><size:long long>
*
+ * RegExp :-
+ * RegExpTag <pattern:StringData><flags:StringData>
*/
class CloneBase {
@@ -389,6 +394,21 @@
write(data->data()->data()->data(), data->data()->length());
return true;
}
+ if (obj->inherits(&RegExpObject::info)) {
+ RegExpObject* regExp = asRegExpObject(obj);
+ char flags[3];
+ int flagCount = 0;
+ if (regExp->regExp()->global())
+ flags[flagCount++] = 'g';
+ if (regExp->regExp()->ignoreCase())
+ flags[flagCount++] = 'i';
+ if (regExp->regExp()->multiline())
+ flags[flagCount++] = 'm';
+ write(RegExpTag);
+ write(regExp->regExp()->pattern());
+ write(UString(flags, flagCount));
+ return true;
+ }
CallData unusedData;
if (getCallData(value, unusedData) == CallTypeNone)
@@ -1066,6 +1086,16 @@
}
case EmptyStringTag:
return jsEmptyString(&m_exec->globalData());
+ case RegExpTag: {
+ Identifier pattern;
+ if (!readStringData(pattern))
+ return JSValue();
+ Identifier flags;
+ if (!readStringData(flags))
+ return JSValue();
+ RefPtr<RegExp> regExp = RegExp::create(&m_exec->globalData(), pattern.ustring(), flags.ustring());
+ return new (m_exec) RegExpObject(m_exec->lexicalGlobalObject(), m_globalObject->regExpStructure(), regExp);
+ }
default:
m_ptr--; // Push the tag back
return JSValue();