Diff
Modified: trunk/Source/WebCore/ChangeLog (130704 => 130705)
--- trunk/Source/WebCore/ChangeLog 2012-10-09 00:02:53 UTC (rev 130704)
+++ trunk/Source/WebCore/ChangeLog 2012-10-09 00:08:57 UTC (rev 130705)
@@ -1,3 +1,35 @@
+2012-10-08 Adam Barth <aba...@webkit.org>
+
+ Remove unused features of BlobBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=98331
+
+ Reviewed by Eric Seidel.
+
+ Now that we don't expose BlobBuilder as a web platform API, we can
+ strip down the class to handle only those cases that are needed by the
+ Blob constructor.
+
+ I've also renamed the class from WebKitBlobBuilder to BlobBuilder and
+ made it stack allocated rather than RefCounted. A future patch will
+ actually move the files around. (I didn't want to mix moving code
+ around with modifying the code.)
+
+ * bindings/js/JSBlobCustom.cpp:
+ (WebCore::JSBlobConstructor::constructJSBlob):
+ * bindings/v8/custom/V8BlobCustom.cpp:
+ (WebCore::V8Blob::constructorCallback):
+ * fileapi/WebKitBlobBuilder.cpp:
+ (WebCore):
+ (WebCore::BlobBuilder::BlobBuilder):
+ (WebCore::BlobBuilder::getBuffer):
+ (WebCore::BlobBuilder::append):
+ (WebCore::BlobBuilder::appendBytesData):
+ (WebCore::BlobBuilder::getBlob):
+ * fileapi/WebKitBlobBuilder.h:
+ (WebCore):
+ (BlobBuilder):
+ * page/FeatureObserver.h:
+
2012-10-08 Martin Robinson <mrobin...@igalia.com>
Try to fix the debug build after r130699
Modified: trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp (130704 => 130705)
--- trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp 2012-10-09 00:02:53 UTC (rev 130704)
+++ trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp 2012-10-09 00:08:57 UTC (rev 130705)
@@ -111,8 +111,7 @@
ASSERT(endings == "transparent" || endings == "native");
- // FIXME: this would be better if the WebKitBlobBuilder were a stack object to avoid the allocation.
- RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create();
+ BlobBuilder blobBuilder;
JSArray* array = asArray(firstArg);
unsigned length = array->length();
@@ -121,22 +120,22 @@
JSValue item = array->getIndex(exec, i);
#if ENABLE(BLOB)
if (item.inherits(&JSArrayBuffer::s_info))
- blobBuilder->append(context, toArrayBuffer(item));
+ blobBuilder.append(context, toArrayBuffer(item));
else if (item.inherits(&JSArrayBufferView::s_info))
- blobBuilder->append(toArrayBufferView(item));
+ blobBuilder.append(toArrayBufferView(item));
else
#endif
if (item.inherits(&JSBlob::s_info))
- blobBuilder->append(toBlob(item));
+ blobBuilder.append(toBlob(item));
else {
String string = item.toString(exec)->value(exec);
if (exec->hadException())
return JSValue::encode(jsUndefined());
- blobBuilder->append(string, endings, ASSERT_NO_EXCEPTION);
+ blobBuilder.append(string, endings);
}
}
- RefPtr<Blob> blob = blobBuilder->getBlob(type, BlobConstructedByConstructor);
+ RefPtr<Blob> blob = blobBuilder.getBlob(type);
return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), Blob, blob.get()));
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp (130704 => 130705)
--- trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-10-09 00:02:53 UTC (rev 130704)
+++ trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-10-09 00:08:57 UTC (rev 130705)
@@ -105,7 +105,7 @@
ASSERT(endings == "transparent" || endings == "native");
- RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create();
+ BlobBuilder blobBuilder;
EXCEPTION_BLOCK(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(firstArg));
uint32_t length = blobParts->Length();
@@ -117,24 +117,24 @@
if (V8ArrayBuffer::HasInstance(item)) {
ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item));
ASSERT(arrayBuffer);
- blobBuilder->append(context, arrayBuffer);
+ blobBuilder.append(context, arrayBuffer);
} else if (V8ArrayBufferView::HasInstance(item)) {
ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(item));
ASSERT(arrayBufferView);
- blobBuilder->append(arrayBufferView);
+ blobBuilder.append(arrayBufferView);
} else
#endif
if (V8Blob::HasInstance(item)) {
Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item));
ASSERT(blob);
- blobBuilder->append(blob);
+ blobBuilder.append(blob);
} else {
EXCEPTION_BLOCK(String, stringValue, toWebCoreString(item));
- blobBuilder->append(stringValue, endings, ASSERT_NO_EXCEPTION);
+ blobBuilder.append(stringValue, endings);
}
}
- RefPtr<Blob> blob = blobBuilder->getBlob(type, BlobConstructedByConstructor);
+ RefPtr<Blob> blob = blobBuilder.getBlob(type);
return toV8(blob.get(), args.Holder(), args.GetIsolate());
}
Modified: trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp (130704 => 130705)
--- trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp 2012-10-09 00:02:53 UTC (rev 130704)
+++ trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp 2012-10-09 00:08:57 UTC (rev 130705)
@@ -35,7 +35,6 @@
#include "Blob.h"
#include "Document.h"
#include "ExceptionCode.h"
-#include "FeatureObserver.h"
#include "File.h"
#include "HistogramSupport.h"
#include "LineEnding.h"
@@ -51,32 +50,20 @@
namespace WebCore {
+// FIXME: Move this file to BlobBuilder.cpp
+
enum BlobConstructorArrayBufferOrView {
BlobConstructorArrayBuffer,
BlobConstructorArrayBufferView,
BlobConstructorArrayBufferOrViewMax,
};
-// static
-PassRefPtr<WebKitBlobBuilder> WebKitBlobBuilder::create(ScriptExecutionContext* context)
-{
- String message("BlobBuilder is deprecated. Use \"Blob\" constructor instead.");
- context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, message);
-
- if (context->isDocument()) {
- Document* document = static_cast<Document*>(context);
- FeatureObserver::observe(document->domWindow(), FeatureObserver::LegacyBlobBuilder);
- }
-
- return adoptRef(new WebKitBlobBuilder());
-}
-
-WebKitBlobBuilder::WebKitBlobBuilder()
+BlobBuilder::BlobBuilder()
: m_size(0)
{
}
-Vector<char>& WebKitBlobBuilder::getBuffer()
+Vector<char>& BlobBuilder::getBuffer()
{
// If the last item is not a data item, create one. Otherwise, we simply append the new string to the last data item.
if (m_items.isEmpty() || m_items[m_items.size() - 1].type != BlobDataItem::Data)
@@ -85,34 +72,24 @@
return *m_items[m_items.size() - 1].data->mutableData();
}
-void WebKitBlobBuilder::append(const String& text, const String& endingType, ExceptionCode& ec)
+void BlobBuilder::append(const String& text, const String& endingType)
{
- bool isEndingTypeTransparent = endingType == "transparent";
- bool isEndingTypeNative = endingType == "native";
- if (!endingType.isEmpty() && !isEndingTypeTransparent && !isEndingTypeNative) {
- ec = SYNTAX_ERR;
- return;
- }
-
CString utf8Text = UTF8Encoding().encode(text.characters(), text.length(), EntitiesForUnencodables);
Vector<char>& buffer = getBuffer();
size_t oldSize = buffer.size();
- if (isEndingTypeNative)
+ if (endingType == "native")
normalizeLineEndingsToNative(utf8Text, buffer);
- else
+ else {
+ ASSERT(endingType == "transparent");
buffer.append(utf8Text.data(), utf8Text.length());
+ }
m_size += buffer.size() - oldSize;
}
-void WebKitBlobBuilder::append(const String& text, ExceptionCode& ec)
-{
- append(text, String(), ec);
-}
-
#if ENABLE(BLOB)
-void WebKitBlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer)
+void BlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer)
{
String consoleMessage("ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead.");
context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, consoleMessage);
@@ -125,7 +102,7 @@
appendBytesData(arrayBuffer->data(), arrayBuffer->byteLength());
}
-void WebKitBlobBuilder::append(ArrayBufferView* arrayBufferView)
+void BlobBuilder::append(ArrayBufferView* arrayBufferView)
{
HistogramSupport::histogramEnumeration("WebCore.Blob.constructor.ArrayBufferOrView", BlobConstructorArrayBufferView, BlobConstructorArrayBufferOrViewMax);
@@ -136,7 +113,7 @@
}
#endif
-void WebKitBlobBuilder::append(Blob* blob)
+void BlobBuilder::append(Blob* blob)
{
if (!blob)
return;
@@ -162,7 +139,7 @@
}
}
-void WebKitBlobBuilder::appendBytesData(const void* data, size_t length)
+void BlobBuilder::appendBytesData(const void* data, size_t length)
{
Vector<char>& buffer = getBuffer();
size_t oldSize = buffer.size();
@@ -170,10 +147,8 @@
m_size += buffer.size() - oldSize;
}
-PassRefPtr<Blob> WebKitBlobBuilder::getBlob(const String& contentType, BlobConstructionReason constructionReason)
+PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType)
{
- HistogramSupport::histogramEnumeration("WebCore.BlobBuilder.getBlob", constructionReason, BlobConstructionReasonMax);
-
OwnPtr<BlobData> blobData = BlobData::create();
blobData->setContentType(contentType);
blobData->swapItems(m_items);
Modified: trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h (130704 => 130705)
--- trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h 2012-10-09 00:02:53 UTC (rev 130704)
+++ trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h 2012-10-09 00:08:57 UTC (rev 130705)
@@ -37,39 +37,28 @@
namespace WebCore {
+// FIXME: Move this file to BlobBuilder.h
+
class Blob;
class ScriptExecutionContext;
class TextEncoding;
typedef int ExceptionCode;
-enum BlobConstructionReason {
- BlobConstructedByBlobBuilder,
- BlobConstructedByConstructor,
- BlobConstructionReasonMax,
-};
-
-class WebKitBlobBuilder : public RefCounted<WebKitBlobBuilder> {
+class BlobBuilder {
public:
- // Called when BlobBuilder is instantiated in JS API. We show deprecate warning message.
- static PassRefPtr<WebKitBlobBuilder> create(ScriptExecutionContext*);
+ BlobBuilder();
- // Called by Blob constructor.
- static PassRefPtr<WebKitBlobBuilder> create() { return adoptRef(new WebKitBlobBuilder()); }
-
void append(Blob*);
- void append(const String& text, ExceptionCode&);
- void append(const String& text, const String& ending, ExceptionCode&);
+ void append(const String& text, const String& ending);
#if ENABLE(BLOB)
void append(ScriptExecutionContext*, ArrayBuffer*);
void append(ArrayBufferView*);
#endif
- PassRefPtr<Blob> getBlob(const String& contentType = String(), BlobConstructionReason = BlobConstructedByBlobBuilder);
+ PassRefPtr<Blob> getBlob(const String& contentType);
private:
- WebKitBlobBuilder();
-
void appendBytesData(const void*, size_t);
Vector<char>& getBuffer();
Modified: trunk/Source/WebCore/page/FeatureObserver.h (130704 => 130705)
--- trunk/Source/WebCore/page/FeatureObserver.h 2012-10-09 00:02:53 UTC (rev 130704)
+++ trunk/Source/WebCore/page/FeatureObserver.h 2012-10-09 00:08:57 UTC (rev 130705)
@@ -41,7 +41,7 @@
enum Feature {
PageDestruction,
LegacyNotifications,
- LegacyBlobBuilder,
+ UnusedSlot01, // Prior to 10/2012, we used this slot for LegacyBlobBuilder.
PrefixedIndexedDB,
WorkerStart,
SharedWorkerStart,