Diff
Modified: trunk/Source/WebCore/ChangeLog (126158 => 126159)
--- trunk/Source/WebCore/ChangeLog 2012-08-21 15:15:32 UTC (rev 126158)
+++ trunk/Source/WebCore/ChangeLog 2012-08-21 15:25:47 UTC (rev 126159)
@@ -1,3 +1,34 @@
+2012-08-21 Sheriff Bot <[email protected]>
+
+ Unreviewed, rolling out r126150.
+ http://trac.webkit.org/changeset/126150
+ https://bugs.webkit.org/show_bug.cgi?id=94605
+
+ Breaks 73 layout tests on chromium.webkit builder (Requested
+ by pfeldman on #webkit).
+
+ * UseV8.cmake:
+ * WebCore.gypi:
+ * bindings/v8/V8Binding.cpp:
+ (StringTraits):
+ (WebCore):
+ (WebCore::v8StringToWebCoreString):
+ (WebCore::int32ToWebCoreStringFast):
+ (WebCore::int32ToWebCoreString):
+ * bindings/v8/V8Binding.h:
+ (WebCore):
+ (V8ParameterBase):
+ (WebCore::V8ParameterBase::operator String):
+ (WebCore::V8ParameterBase::operator AtomicString):
+ (WebCore::V8ParameterBase::V8ParameterBase):
+ (WebCore::V8ParameterBase::prepareBase):
+ (WebCore::V8ParameterBase::object):
+ (WebCore::V8ParameterBase::setString):
+ (WebCore::V8ParameterBase::toString):
+ (WebCore::::prepare):
+ * bindings/v8/V8StringResource.cpp: Removed.
+ * bindings/v8/V8StringResource.h: Removed.
+
2012-08-21 Philippe Normand <[email protected]>
Early returns in MediaPlayer setters
Modified: trunk/Source/WebCore/UseV8.cmake (126158 => 126159)
--- trunk/Source/WebCore/UseV8.cmake 2012-08-21 15:15:32 UTC (rev 126158)
+++ trunk/Source/WebCore/UseV8.cmake 2012-08-21 15:25:47 UTC (rev 126159)
@@ -145,7 +145,6 @@
bindings/v8/custom/V8SQLTransactionCustom.cpp
bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
bindings/v8/custom/V8StorageCustom.cpp
- bindings/v8/custom/V8StringResource.cpp
bindings/v8/custom/V8StyleSheetCustom.cpp
bindings/v8/custom/V8StyleSheetListCustom.cpp
bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
Modified: trunk/Source/WebCore/WebCore.gypi (126158 => 126159)
--- trunk/Source/WebCore/WebCore.gypi 2012-08-21 15:15:32 UTC (rev 126158)
+++ trunk/Source/WebCore/WebCore.gypi 2012-08-21 15:25:47 UTC (rev 126159)
@@ -2288,8 +2288,6 @@
'bindings/v8/V8Proxy.h',
'bindings/v8/V8RecursionScope.cpp',
'bindings/v8/V8RecursionScope.h',
- 'bindings/v8/V8StringResource.cpp',
- 'bindings/v8/V8StringResource.h',
'bindings/v8/V8ThrowException.cpp',
'bindings/v8/V8ThrowException.h',
'bindings/v8/V8Utilities.cpp',
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (126158 => 126159)
--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-08-21 15:15:32 UTC (rev 126158)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-08-21 15:25:47 UTC (rev 126159)
@@ -204,6 +204,118 @@
return uintValue->Value();
}
+template <class S> struct StringTraits
+{
+ static S fromStringResource(WebCoreStringResource* resource);
+
+ static S fromV8String(v8::Handle<v8::String> v8String, int length);
+};
+
+template<>
+struct StringTraits<String>
+{
+ static String fromStringResource(WebCoreStringResource* resource)
+ {
+ return resource->webcoreString();
+ }
+
+ static String fromV8String(v8::Handle<v8::String> v8String, int length)
+ {
+ ASSERT(v8String->Length() == length);
+ // NOTE: as of now, String(const UChar*, int) performs String::createUninitialized
+ // anyway, so no need to optimize like we do for AtomicString below.
+ UChar* buffer;
+ String result = String::createUninitialized(length, buffer);
+ v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
+ return result;
+ }
+};
+
+template<>
+struct StringTraits<AtomicString>
+{
+ static AtomicString fromStringResource(WebCoreStringResource* resource)
+ {
+ return resource->atomicString();
+ }
+
+ static AtomicString fromV8String(v8::Handle<v8::String> v8String, int length)
+ {
+ ASSERT(v8String->Length() == length);
+ static const int inlineBufferSize = 16;
+ if (length <= inlineBufferSize) {
+ UChar inlineBuffer[inlineBufferSize];
+ v8String->Write(reinterpret_cast<uint16_t*>(inlineBuffer), 0, length);
+ return AtomicString(inlineBuffer, length);
+ }
+ UChar* buffer;
+ String tmp = String::createUninitialized(length, buffer);
+ v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
+ return AtomicString(tmp);
+ }
+};
+
+template <typename StringType>
+StringType v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external)
+{
+ WebCoreStringResource* stringResource = WebCoreStringResource::toStringResource(v8String);
+ if (stringResource)
+ return StringTraits<StringType>::fromStringResource(stringResource);
+
+ int length = v8String->Length();
+ if (!length) {
+ // Avoid trying to morph empty strings, as they do not have enough room to contain the external reference.
+ return StringImpl::empty();
+ }
+
+ StringType result(StringTraits<StringType>::fromV8String(v8String, length));
+
+ if (external == Externalize && v8String->CanMakeExternal()) {
+ stringResource = new WebCoreStringResource(result);
+ if (!v8String->MakeExternal(stringResource)) {
+ // In case of a failure delete the external resource as it was not used.
+ delete stringResource;
+ }
+ }
+ return result;
+}
+
+// Explicitly instantiate the above template with the expected parameterizations,
+// to ensure the compiler generates the code; otherwise link errors can result in GCC 4.4.
+template String v8StringToWebCoreString<String>(v8::Handle<v8::String>, ExternalMode);
+template AtomicString v8StringToWebCoreString<AtomicString>(v8::Handle<v8::String>, ExternalMode);
+
+// Fast but non thread-safe version.
+String int32ToWebCoreStringFast(int value)
+{
+ // Caching of small strings below is not thread safe: newly constructed AtomicString
+ // are not safely published.
+ ASSERT(isMainThread());
+
+ // Most numbers used are <= 100. Even if they aren't used there's very little cost in using the space.
+ const int kLowNumbers = 100;
+ DEFINE_STATIC_LOCAL(Vector<AtomicString>, lowNumbers, (kLowNumbers + 1));
+ String webCoreString;
+ if (0 <= value && value <= kLowNumbers) {
+ webCoreString = lowNumbers[value];
+ if (!webCoreString) {
+ AtomicString valueString = AtomicString(String::number(value));
+ lowNumbers[value] = valueString;
+ webCoreString = valueString;
+ }
+ } else
+ webCoreString = String::number(value);
+ return webCoreString;
+}
+
+String int32ToWebCoreString(int value)
+{
+ // If we are on the main thread (this should always true for non-workers), call the faster one.
+ if (isMainThread())
+ return int32ToWebCoreStringFast(value);
+ return String::number(value);
+}
+
v8::Persistent<v8::FunctionTemplate> createRawTemplate()
{
v8::HandleScope scope;
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (126158 => 126159)
--- trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-08-21 15:15:32 UTC (rev 126158)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-08-21 15:25:47 UTC (rev 126159)
@@ -41,7 +41,6 @@
#include "V8ObjectConstructor.h"
#include "V8PerIsolateData.h"
#include "V8Proxy.h"
-#include "V8StringResource.h"
#include "V8ThrowException.h"
#include "V8ValueCache.h"
#include <wtf/Noncopyable.h>
@@ -77,6 +76,14 @@
return isolate ? v8::Null(isolate) : v8::Null();
}
+ enum ExternalMode {
+ Externalize,
+ DoNotExternalize
+ };
+
+ template <typename StringType>
+ StringType v8StringToWebCoreString(v8::Handle<v8::String>, ExternalMode);
+
// Convert v8 types to a WTF::String. If the V8 string is not already
// an external string then it is transformed into an external string at this
// point to avoid repeated conversions.
@@ -357,6 +364,8 @@
v8::Persistent<v8::String> getToStringName();
v8::Persistent<v8::FunctionTemplate> getToStringTemplate();
+ String int32ToWebCoreString(int value);
+
PassRefPtr<DOMStringList> toDOMStringList(v8::Handle<v8::Value>);
// Returns the window object associated with a context.
@@ -375,6 +384,102 @@
void crashIfV8IsDead();
+ class V8ParameterBase {
+ public:
+ operator String() { return toString<String>(); }
+ operator AtomicString() { return toString<AtomicString>(); }
+
+ protected:
+ V8ParameterBase(v8::Local<v8::Value> object) : m_v8Object(object), m_mode(Externalize), m_string() { }
+
+ bool prepareBase()
+ {
+ if (m_v8Object.IsEmpty())
+ return true;
+
+ if (LIKELY(m_v8Object->IsString()))
+ return true;
+
+ if (LIKELY(m_v8Object->IsInt32())) {
+ setString(int32ToWebCoreString(m_v8Object->Int32Value()));
+ return true;
+ }
+
+ m_mode = DoNotExternalize;
+ v8::TryCatch block;
+ m_v8Object = m_v8Object->ToString();
+ // Handle the case where an exception is thrown as part of invoking toString on the object.
+ if (block.HasCaught()) {
+ block.ReThrow();
+ return false;
+ }
+ return true;
+ }
+
+ v8::Local<v8::Value> object() { return m_v8Object; }
+
+ void setString(const String& string)
+ {
+ m_string = string;
+ m_v8Object.Clear(); // To signal that String is ready.
+ }
+
+ private:
+ v8::Local<v8::Value> m_v8Object;
+ ExternalMode m_mode;
+ String m_string;
+
+ template <class StringType>
+ StringType toString()
+ {
+ if (LIKELY(!m_v8Object.IsEmpty()))
+ return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode);
+
+ return StringType(m_string);
+ }
+ };
+
+ // V8Parameter is an adapter class that converts V8 values to Strings
+ // or AtomicStrings as appropriate, using multiple typecast operators.
+ enum V8ParameterMode {
+ DefaultMode,
+ WithNullCheck,
+ WithUndefinedOrNullCheck
+ };
+ template <V8ParameterMode MODE = DefaultMode>
+ class V8Parameter: public V8ParameterBase {
+ public:
+ V8Parameter(v8::Local<v8::Value> object) : V8ParameterBase(object) { }
+ V8Parameter(v8::Local<v8::Value> object, bool) : V8ParameterBase(object) { prepare(); }
+
+ bool prepare();
+ };
+
+ template<> inline bool V8Parameter<DefaultMode>::prepare()
+ {
+ return V8ParameterBase::prepareBase();
+ }
+
+ template<> inline bool V8Parameter<WithNullCheck>::prepare()
+ {
+ if (object().IsEmpty() || object()->IsNull()) {
+ setString(String());
+ return true;
+ }
+
+ return V8ParameterBase::prepareBase();
+ }
+
+ template<> inline bool V8Parameter<WithUndefinedOrNullCheck>::prepare()
+ {
+ if (object().IsEmpty() || object()->IsNull() || object()->IsUndefined()) {
+ setString(String());
+ return true;
+ }
+
+ return V8ParameterBase::prepareBase();
+ }
+
} // namespace WebCore
#endif // V8Binding_h
Deleted: trunk/Source/WebCore/bindings/v8/V8StringResource.cpp (126158 => 126159)
--- trunk/Source/WebCore/bindings/v8/V8StringResource.cpp 2012-08-21 15:15:32 UTC (rev 126158)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.cpp 2012-08-21 15:25:47 UTC (rev 126159)
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "V8StringResource.h"
-
-#include "V8Binding.h"
-
-namespace WebCore {
-
-template <class S> struct StringTraits {
- static S fromStringResource(WebCoreStringResource*);
- static S fromV8String(v8::Handle<v8::String>, int);
-};
-
-template<>
-struct StringTraits<String> {
- static String fromStringResource(WebCoreStringResource* resource)
- {
- return resource->webcoreString();
- }
-
- static String fromV8String(v8::Handle<v8::String> v8String, int length)
- {
- ASSERT(v8String->Length() == length);
- // NOTE: as of now, String(const UChar*, int) performs String::createUninitialized
- // anyway, so no need to optimize like we do for AtomicString below.
- UChar* buffer;
- String result = String::createUninitialized(length, buffer);
- v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
- return result;
- }
-};
-
-template<>
-struct StringTraits<AtomicString> {
- static AtomicString fromStringResource(WebCoreStringResource* resource)
- {
- return resource->atomicString();
- }
-
- static AtomicString fromV8String(v8::Handle<v8::String> v8String, int length)
- {
- ASSERT(v8String->Length() == length);
- static const int inlineBufferSize = 16;
- if (length <= inlineBufferSize) {
- UChar inlineBuffer[inlineBufferSize];
- v8String->Write(reinterpret_cast<uint16_t*>(inlineBuffer), 0, length);
- return AtomicString(inlineBuffer, length);
- }
- UChar* buffer;
- String string = String::createUninitialized(length, buffer);
- v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
- return AtomicString(string);
- }
-};
-
-template <typename StringType>
-StringType v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external)
-{
- WebCoreStringResource* stringResource = WebCoreStringResource::toStringResource(v8String);
- if (stringResource)
- return StringTraits<StringType>::fromStringResource(stringResource);
-
- int length = v8String->Length();
- if (!length) {
- // Avoid trying to morph empty strings, as they do not have enough room to contain the external reference.
- return String();
- }
-
- StringType result(StringTraits<StringType>::fromV8String(v8String, length));
-
- if (external == Externalize && v8String->CanMakeExternal()) {
- stringResource = new WebCoreStringResource(result);
- if (!v8String->MakeExternal(stringResource)) {
- // In case of a failure delete the external resource as it was not used.
- delete stringResource;
- }
- }
- return result;
-}
-
-// Explicitly instantiate the above template with the expected parameterizations,
-// to ensure the compiler generates the code; otherwise link errors can result in GCC 4.4.
-template String v8StringToWebCoreString<String>(v8::Handle<v8::String>, ExternalMode);
-template AtomicString v8StringToWebCoreString<AtomicString>(v8::Handle<v8::String>, ExternalMode);
-
-// Fast but non thread-safe version.
-String int32ToWebCoreStringFast(int value)
-{
- // Caching of small strings below is not thread safe: newly constructed AtomicString
- // are not safely published.
- ASSERT(isMainThread());
-
- // Most numbers used are <= 100. Even if they aren't used there's very little cost in using the space.
- const int kLowNumbers = 100;
- DEFINE_STATIC_LOCAL(Vector<AtomicString>, lowNumbers, (kLowNumbers + 1));
- String webCoreString;
- if (0 <= value && value <= kLowNumbers) {
- webCoreString = lowNumbers[value];
- if (!webCoreString) {
- AtomicString valueString = AtomicString(String::number(value));
- lowNumbers[value] = valueString;
- webCoreString = valueString;
- }
- } else
- webCoreString = String::number(value);
- return webCoreString;
-}
-
-String int32ToWebCoreString(int value)
-{
- // If we are on the main thread (this should always true for non-workers), call the faster one.
- if (isMainThread())
- return int32ToWebCoreStringFast(value);
- return String::number(value);
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/bindings/v8/V8StringResource.h (126158 => 126159)
--- trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-08-21 15:15:32 UTC (rev 126158)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-08-21 15:25:47 UTC (rev 126159)
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef V8StringResource_h
-#define V8StringResource_h
-
-#include <v8.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-enum ExternalMode {
- Externalize,
- DoNotExternalize
-};
-
-template <typename StringType>
-StringType v8StringToWebCoreString(v8::Handle<v8::String>, ExternalMode);
-String int32ToWebCoreString(int value);
-
-class V8ParameterBase {
-public:
- operator String() { return toString<String>(); }
- operator AtomicString() { return toString<AtomicString>(); }
-
-protected:
- V8ParameterBase(v8::Local<v8::Value> object) : m_v8Object(object), m_mode(Externalize), m_string() { }
-
- bool prepareBase()
- {
- if (m_v8Object.IsEmpty())
- return true;
-
- if (LIKELY(m_v8Object->IsString()))
- return true;
-
- if (LIKELY(m_v8Object->IsInt32())) {
- setString(int32ToWebCoreString(m_v8Object->Int32Value()));
- return true;
- }
-
- m_mode = DoNotExternalize;
- v8::TryCatch block;
- m_v8Object = m_v8Object->ToString();
- // Handle the case where an exception is thrown as part of invoking toString on the object.
- if (block.HasCaught()) {
- block.ReThrow();
- return false;
- }
- return true;
- }
-
- v8::Local<v8::Value> object() { return m_v8Object; }
-
- void setString(const String& string)
- {
- m_string = string;
- m_v8Object.Clear(); // To signal that String is ready.
- }
-
-private:
- v8::Local<v8::Value> m_v8Object;
- ExternalMode m_mode;
- String m_string;
-
- template <class StringType>
- StringType toString()
- {
- if (LIKELY(!m_v8Object.IsEmpty()))
- return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode);
-
- return StringType(m_string);
- }
-};
-
-// V8Parameter is an adapter class that converts V8 values to Strings
-// or AtomicStrings as appropriate, using multiple typecast operators.
-enum V8ParameterMode {
- DefaultMode,
- WithNullCheck,
- WithUndefinedOrNullCheck
-};
-
-template <V8ParameterMode MODE = DefaultMode>
-class V8Parameter: public V8ParameterBase {
-public:
- V8Parameter(v8::Local<v8::Value> object) : V8ParameterBase(object) { }
- V8Parameter(v8::Local<v8::Value> object, bool) : V8ParameterBase(object) { prepare(); }
-
- bool prepare();
-};
-
-template<> inline bool V8Parameter<DefaultMode>::prepare()
-{
- return V8ParameterBase::prepareBase();
-}
-
-template<> inline bool V8Parameter<WithNullCheck>::prepare()
-{
- if (object().IsEmpty() || object()->IsNull()) {
- setString(String());
- return true;
- }
-
- return V8ParameterBase::prepareBase();
-}
-
-template<> inline bool V8Parameter<WithUndefinedOrNullCheck>::prepare()
-{
- if (object().IsEmpty() || object()->IsNull() || object()->IsUndefined()) {
- setString(String());
- return true;
- }
-
- return V8ParameterBase::prepareBase();
-}
-
-} // namespace WebCore
-
-#endif // V8StringResource_h