Changeset 130705 in webkit
- Timestamp:
- Oct 8, 2012, 5:08:57 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
bindings/js/JSBlobCustom.cpp (modified) (2 diffs)
-
bindings/v8/custom/V8BlobCustom.cpp (modified) (3 diffs)
-
fileapi/WebKitBlobBuilder.cpp (modified) (9 diffs)
-
fileapi/WebKitBlobBuilder.h (modified) (3 diffs)
-
page/FeatureObserver.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r130704 r130705 1 2012-10-08 Adam Barth <abarth@webkit.org> 2 3 Remove unused features of BlobBuilder 4 https://bugs.webkit.org/show_bug.cgi?id=98331 5 6 Reviewed by Eric Seidel. 7 8 Now that we don't expose BlobBuilder as a web platform API, we can 9 strip down the class to handle only those cases that are needed by the 10 Blob constructor. 11 12 I've also renamed the class from WebKitBlobBuilder to BlobBuilder and 13 made it stack allocated rather than RefCounted. A future patch will 14 actually move the files around. (I didn't want to mix moving code 15 around with modifying the code.) 16 17 * bindings/js/JSBlobCustom.cpp: 18 (WebCore::JSBlobConstructor::constructJSBlob): 19 * bindings/v8/custom/V8BlobCustom.cpp: 20 (WebCore::V8Blob::constructorCallback): 21 * fileapi/WebKitBlobBuilder.cpp: 22 (WebCore): 23 (WebCore::BlobBuilder::BlobBuilder): 24 (WebCore::BlobBuilder::getBuffer): 25 (WebCore::BlobBuilder::append): 26 (WebCore::BlobBuilder::appendBytesData): 27 (WebCore::BlobBuilder::getBlob): 28 * fileapi/WebKitBlobBuilder.h: 29 (WebCore): 30 (BlobBuilder): 31 * page/FeatureObserver.h: 32 1 33 2012-10-08 Martin Robinson <mrobinson@igalia.com> 2 34 -
trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp
r129574 r130705 112 112 ASSERT(endings == "transparent" || endings == "native"); 113 113 114 // FIXME: this would be better if the WebKitBlobBuilder were a stack object to avoid the allocation. 115 RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create(); 114 BlobBuilder blobBuilder; 116 115 117 116 JSArray* array = asArray(firstArg); … … 122 121 #if ENABLE(BLOB) 123 122 if (item.inherits(&JSArrayBuffer::s_info)) 124 blobBuilder ->append(context, toArrayBuffer(item));123 blobBuilder.append(context, toArrayBuffer(item)); 125 124 else if (item.inherits(&JSArrayBufferView::s_info)) 126 blobBuilder ->append(toArrayBufferView(item));125 blobBuilder.append(toArrayBufferView(item)); 127 126 else 128 127 #endif 129 128 if (item.inherits(&JSBlob::s_info)) 130 blobBuilder ->append(toBlob(item));129 blobBuilder.append(toBlob(item)); 131 130 else { 132 131 String string = item.toString(exec)->value(exec); 133 132 if (exec->hadException()) 134 133 return JSValue::encode(jsUndefined()); 135 blobBuilder ->append(string, endings, ASSERT_NO_EXCEPTION);134 blobBuilder.append(string, endings); 136 135 } 137 136 } 138 137 139 RefPtr<Blob> blob = blobBuilder ->getBlob(type, BlobConstructedByConstructor);138 RefPtr<Blob> blob = blobBuilder.getBlob(type); 140 139 return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), Blob, blob.get())); 141 140 } -
trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp
r128139 r130705 106 106 ASSERT(endings == "transparent" || endings == "native"); 107 107 108 RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create();108 BlobBuilder blobBuilder; 109 109 110 110 EXCEPTION_BLOCK(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(firstArg)); … … 118 118 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item)); 119 119 ASSERT(arrayBuffer); 120 blobBuilder ->append(context, arrayBuffer);120 blobBuilder.append(context, arrayBuffer); 121 121 } else if (V8ArrayBufferView::HasInstance(item)) { 122 122 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(item)); 123 123 ASSERT(arrayBufferView); 124 blobBuilder ->append(arrayBufferView);124 blobBuilder.append(arrayBufferView); 125 125 } else 126 126 #endif … … 128 128 Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); 129 129 ASSERT(blob); 130 blobBuilder ->append(blob);130 blobBuilder.append(blob); 131 131 } else { 132 132 EXCEPTION_BLOCK(String, stringValue, toWebCoreString(item)); 133 blobBuilder ->append(stringValue, endings, ASSERT_NO_EXCEPTION);133 blobBuilder.append(stringValue, endings); 134 134 } 135 135 } 136 136 137 RefPtr<Blob> blob = blobBuilder ->getBlob(type, BlobConstructedByConstructor);137 RefPtr<Blob> blob = blobBuilder.getBlob(type); 138 138 return toV8(blob.get(), args.Holder(), args.GetIsolate()); 139 139 } -
trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp
r128797 r130705 36 36 #include "Document.h" 37 37 #include "ExceptionCode.h" 38 #include "FeatureObserver.h"39 38 #include "File.h" 40 39 #include "HistogramSupport.h" … … 52 51 namespace WebCore { 53 52 53 // FIXME: Move this file to BlobBuilder.cpp 54 54 55 enum BlobConstructorArrayBufferOrView { 55 56 BlobConstructorArrayBuffer, … … 58 59 }; 59 60 60 // static 61 PassRefPtr<WebKitBlobBuilder> WebKitBlobBuilder::create(ScriptExecutionContext* context) 62 { 63 String message("BlobBuilder is deprecated. Use \"Blob\" constructor instead."); 64 context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, message); 65 66 if (context->isDocument()) { 67 Document* document = static_cast<Document*>(context); 68 FeatureObserver::observe(document->domWindow(), FeatureObserver::LegacyBlobBuilder); 69 } 70 71 return adoptRef(new WebKitBlobBuilder()); 72 } 73 74 WebKitBlobBuilder::WebKitBlobBuilder() 61 BlobBuilder::BlobBuilder() 75 62 : m_size(0) 76 63 { 77 64 } 78 65 79 Vector<char>& WebKitBlobBuilder::getBuffer()66 Vector<char>& BlobBuilder::getBuffer() 80 67 { 81 68 // If the last item is not a data item, create one. Otherwise, we simply append the new string to the last data item. … … 86 73 } 87 74 88 void WebKitBlobBuilder::append(const String& text, const String& endingType, ExceptionCode& ec)75 void BlobBuilder::append(const String& text, const String& endingType) 89 76 { 90 bool isEndingTypeTransparent = endingType == "transparent";91 bool isEndingTypeNative = endingType == "native";92 if (!endingType.isEmpty() && !isEndingTypeTransparent && !isEndingTypeNative) {93 ec = SYNTAX_ERR;94 return;95 }96 97 77 CString utf8Text = UTF8Encoding().encode(text.characters(), text.length(), EntitiesForUnencodables); 98 78 … … 100 80 size_t oldSize = buffer.size(); 101 81 102 if ( isEndingTypeNative)82 if (endingType == "native") 103 83 normalizeLineEndingsToNative(utf8Text, buffer); 104 else 84 else { 85 ASSERT(endingType == "transparent"); 105 86 buffer.append(utf8Text.data(), utf8Text.length()); 87 } 106 88 m_size += buffer.size() - oldSize; 107 89 } 108 90 109 void WebKitBlobBuilder::append(const String& text, ExceptionCode& ec)110 {111 append(text, String(), ec);112 }113 114 91 #if ENABLE(BLOB) 115 void WebKitBlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer)92 void BlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer) 116 93 { 117 94 String consoleMessage("ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead."); … … 126 103 } 127 104 128 void WebKitBlobBuilder::append(ArrayBufferView* arrayBufferView)105 void BlobBuilder::append(ArrayBufferView* arrayBufferView) 129 106 { 130 107 HistogramSupport::histogramEnumeration("WebCore.Blob.constructor.ArrayBufferOrView", BlobConstructorArrayBufferView, BlobConstructorArrayBufferOrViewMax); … … 137 114 #endif 138 115 139 void WebKitBlobBuilder::append(Blob* blob)116 void BlobBuilder::append(Blob* blob) 140 117 { 141 118 if (!blob) … … 163 140 } 164 141 165 void WebKitBlobBuilder::appendBytesData(const void* data, size_t length)142 void BlobBuilder::appendBytesData(const void* data, size_t length) 166 143 { 167 144 Vector<char>& buffer = getBuffer(); … … 171 148 } 172 149 173 PassRefPtr<Blob> WebKitBlobBuilder::getBlob(const String& contentType, BlobConstructionReason constructionReason)150 PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType) 174 151 { 175 HistogramSupport::histogramEnumeration("WebCore.BlobBuilder.getBlob", constructionReason, BlobConstructionReasonMax);176 177 152 OwnPtr<BlobData> blobData = BlobData::create(); 178 153 blobData->setContentType(contentType); -
trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h
r125386 r130705 38 38 namespace WebCore { 39 39 40 // FIXME: Move this file to BlobBuilder.h 41 40 42 class Blob; 41 43 class ScriptExecutionContext; … … 44 46 typedef int ExceptionCode; 45 47 46 enum BlobConstructionReason { 47 BlobConstructedByBlobBuilder, 48 BlobConstructedByConstructor, 49 BlobConstructionReasonMax, 50 }; 51 52 class WebKitBlobBuilder : public RefCounted<WebKitBlobBuilder> { 48 class BlobBuilder { 53 49 public: 54 // Called when BlobBuilder is instantiated in JS API. We show deprecate warning message. 55 static PassRefPtr<WebKitBlobBuilder> create(ScriptExecutionContext*); 56 57 // Called by Blob constructor. 58 static PassRefPtr<WebKitBlobBuilder> create() { return adoptRef(new WebKitBlobBuilder()); } 50 BlobBuilder(); 59 51 60 52 void append(Blob*); 61 void append(const String& text, ExceptionCode&); 62 void append(const String& text, const String& ending, ExceptionCode&); 53 void append(const String& text, const String& ending); 63 54 #if ENABLE(BLOB) 64 55 void append(ScriptExecutionContext*, ArrayBuffer*); … … 66 57 #endif 67 58 68 PassRefPtr<Blob> getBlob(const String& contentType = String(), BlobConstructionReason = BlobConstructedByBlobBuilder);59 PassRefPtr<Blob> getBlob(const String& contentType); 69 60 70 61 private: 71 WebKitBlobBuilder();72 73 62 void appendBytesData(const void*, size_t); 74 63 -
trunk/Source/WebCore/page/FeatureObserver.h
r130463 r130705 42 42 PageDestruction, 43 43 LegacyNotifications, 44 LegacyBlobBuilder,44 UnusedSlot01, // Prior to 10/2012, we used this slot for LegacyBlobBuilder. 45 45 PrefixedIndexedDB, 46 46 WorkerStart,
Note:
See TracChangeset
for help on using the changeset viewer.