Title: [120165] trunk
Revision
120165
Author
[email protected]
Date
2012-06-12 23:50:19 -0700 (Tue, 12 Jun 2012)

Log Message

Unprefix Blob.webkitSlice
https://bugs.webkit.org/show_bug.cgi?id=78111

Reviewed by Adam Barth.

Source/WebCore:

Add unprefixed Blob.slice and start showing a deprecation message when webkitSlice is called.

No new tests: existing tests that call webkitSlice() are converted to slice(). They should keep running.

* bindings/gobject/WebKitDOMCustom.cpp:
(webkit_dom_blob_slice): Removed.
(webkit_dom_blob_webkit_slice): Added.
* fileapi/Blob.cpp:
(WebCore::Blob::slice):
(WebCore):
(WebCore::Blob::webkitSlice):
(WebCore::Blob::sliceInternal): Added.
* fileapi/Blob.h:
(WebCore):
(Blob):
* fileapi/Blob.idl:

LayoutTests:

Converted existing tests that are calling Blob.webkitSlice() to call slice().

* fast/files/blob-slice-overflow.html:
* fast/files/blob-slice-test.html:
* fast/files/resources/read-blob-test-cases.js:
(testReadingSlicedFileBlob):
(testReadingSlicedTextBlob):
(testReadingSlicedArrayBufferBlob):
(testReadingSlicedHybridBlob):
(testReadingTripleSlicedHybridBlob):
* fast/filesystem/resources/file-writer-utils.js:
(verifyByteRangeIsZeroesHelper):
* http/tests/local/blob/script-tests/send-hybrid-blob.js:
(runHybridBlobTest):
* http/tests/local/blob/script-tests/send-sliced-data-blob.js:
(runSliceTest):
* http/tests/local/fileapi/script-tests/send-sliced-dragged-file.js:
(onStableFileDrop):
(onUnstableFileDrop):
* http/tests/local/formdata/resources/send-form-data-common.js:
(testSendingFormData):
* inspector/profiler/heap-snapshot-loader.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120164 => 120165)


--- trunk/LayoutTests/ChangeLog	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/ChangeLog	2012-06-13 06:50:19 UTC (rev 120165)
@@ -1,3 +1,33 @@
+2012-06-11  Kinuko Yasuda  <[email protected]>
+
+        Unprefix Blob.webkitSlice
+        https://bugs.webkit.org/show_bug.cgi?id=78111
+
+        Reviewed by Adam Barth.
+
+        Converted existing tests that are calling Blob.webkitSlice() to call slice().
+
+        * fast/files/blob-slice-overflow.html:
+        * fast/files/blob-slice-test.html:
+        * fast/files/resources/read-blob-test-cases.js:
+        (testReadingSlicedFileBlob):
+        (testReadingSlicedTextBlob):
+        (testReadingSlicedArrayBufferBlob):
+        (testReadingSlicedHybridBlob):
+        (testReadingTripleSlicedHybridBlob):
+        * fast/filesystem/resources/file-writer-utils.js:
+        (verifyByteRangeIsZeroesHelper):
+        * http/tests/local/blob/script-tests/send-hybrid-blob.js:
+        (runHybridBlobTest):
+        * http/tests/local/blob/script-tests/send-sliced-data-blob.js:
+        (runSliceTest):
+        * http/tests/local/fileapi/script-tests/send-sliced-dragged-file.js:
+        (onStableFileDrop):
+        (onUnstableFileDrop):
+        * http/tests/local/formdata/resources/send-form-data-common.js:
+        (testSendingFormData):
+        * inspector/profiler/heap-snapshot-loader.html:
+
 2012-06-12  Csaba Osztrogonác  <[email protected]>
 
         [Qt] Unreviewed morning gardening, skip new failing tests.

Modified: trunk/LayoutTests/fast/files/blob-slice-overflow.html (120164 => 120165)


--- trunk/LayoutTests/fast/files/blob-slice-overflow.html	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/fast/files/blob-slice-overflow.html	2012-06-13 06:50:19 UTC (rev 120165)
@@ -14,7 +14,7 @@
     text += 'A';
 
 blob = new Blob([text]);
-slicedBlob = blob.webkitSlice(1999, 9223372036854775000);
+slicedBlob = blob.slice(1999, 9223372036854775000);
 
 document.getElementById('console').appendChild(document.createTextNode('Blob slice length: ' + slicedBlob.size));
 if (slicedBlob.size != 1) {

Modified: trunk/LayoutTests/fast/files/blob-slice-test.html (120164 => 120165)


--- trunk/LayoutTests/fast/files/blob-slice-test.html	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/fast/files/blob-slice-test.html	2012-06-13 06:50:19 UTC (rev 120165)
@@ -46,13 +46,13 @@
     var message = "Slicing ";
     if (start == undefined && end == undefined) {
         message += "without parameters";
-        subBlob = blob.webkitSlice();
+        subBlob = blob.slice();
     } else if (end == undefined) {
         message += "from " + start;
-        subBlob = blob.webkitSlice(start);
+        subBlob = blob.slice(start);
     } else {
         message += "from " + start + " to " + end;
-        subBlob = blob.webkitSlice(start, end);
+        subBlob = blob.slice(start, end);
     }
     message += ": ";
     reader._onload_ = function(event) {

Modified: trunk/LayoutTests/fast/files/resources/read-blob-test-cases.js (120164 => 120165)


--- trunk/LayoutTests/fast/files/resources/read-blob-test-cases.js	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/fast/files/resources/read-blob-test-cases.js	2012-06-13 06:50:19 UTC (rev 120165)
@@ -105,7 +105,7 @@
 function testReadingSlicedFileBlob(testFiles)
 {
     log("Test reading a blob containing sliced file");
-    var blob = buildBlob([testFiles['file2'].webkitSlice(1, 6)]);
+    var blob = buildBlob([testFiles['file2'].slice(1, 6)]);
     readBlobAsBinaryString(testFiles, blob);
 }
 
@@ -113,7 +113,7 @@
 {
     log("Test reading a blob containing sliced text");
     var blob = buildBlob(['First'])
-    blob = blob.webkitSlice(1, 11);
+    blob = blob.slice(1, 11);
     readBlobAsBinaryString(testFiles, blob);
 }
 
@@ -122,7 +122,7 @@
     log("Test reading a blob containing sliced ArrayBuffer");
     var array = new Uint8Array([0, 1, 2, 128, 129, 130, 253, 254, 255]);
     var blob = buildBlob([array])
-    blob = blob.webkitSlice(1, 11);
+    blob = blob.slice(1, 11);
     readBlobAsBinaryString(testFiles, blob);
 }
 
@@ -163,7 +163,7 @@
     log("Test reading a sliced hybrid blob");
     var array = new Uint8Array([48, 49, 50]);
     var blob = buildBlob(['First', testFiles['file1'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array]);
-    var blob = blob.webkitSlice(7, 19);
+    var blob = blob.slice(7, 19);
     readBlobAsBinaryString(testFiles, blob);
 }
 
@@ -171,11 +171,11 @@
 {
     log("Test reading a triple-sliced hybrid blob");
     var array = new Uint8Array([48, 49, 50]);
-    var items = ['First', testFiles['file1'].webkitSlice(1, 11), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array];
+    var items = ['First', testFiles['file1'].slice(1, 11), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array];
     var blob = buildBlob(items);
-    var blob = blob.webkitSlice(7, 19);
+    var blob = blob.slice(7, 19);
     var blob2 = buildBlob(items.concat(['Foo', blob, 'Bar']));
-    var blob2 = blob2.webkitSlice(12, 42);
+    var blob2 = blob2.slice(12, 42);
     readBlobAsBinaryString(testFiles, blob2);
 }
 

Modified: trunk/LayoutTests/fast/filesystem/resources/file-writer-utils.js (120164 => 120165)


--- trunk/LayoutTests/fast/filesystem/resources/file-writer-utils.js	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/fast/filesystem/resources/file-writer-utils.js	2012-06-13 06:50:19 UTC (rev 120165)
@@ -72,7 +72,7 @@
                 assert(result.charCodeAt(i) == 0);
             onSuccess();
         };
-    fileReader.readAsBinaryString(file.webkitSlice(start, start + length));
+    fileReader.readAsBinaryString(file.slice(start, start + length));
 }
 
 // Verifies that fileEntry, at offset, is all zeroes for length bytes.
@@ -91,7 +91,7 @@
             assert(fileReader.result == data);
             onSuccess();
         };
-    fileReader.readAsText(file.webkitSlice(start, start + data.length));
+    fileReader.readAsText(file.slice(start, start + data.length));
 }
 
 // Verifies that the contents of fileEntry, at offset, match contents [a string].

Modified: trunk/LayoutTests/http/tests/local/blob/script-tests/send-hybrid-blob.js (120164 => 120165)


--- trunk/LayoutTests/http/tests/local/blob/script-tests/send-hybrid-blob.js	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/http/tests/local/blob/script-tests/send-hybrid-blob.js	2012-06-13 06:50:19 UTC (rev 120165)
@@ -17,7 +17,7 @@
     var blob = util.appendAndCreateBlob(fileIndexOrStrings);
     var urlParameter = util.createUrlParameter(fileIndexOrStrings, opt_range);
     if (opt_range)
-        blob = blob.webkitSlice(opt_range.start, opt_range.start + opt_range.length);
+        blob = blob.slice(opt_range.start, opt_range.start + opt_range.length);
     util.uploadBlob(blob, urlParameter);
 }
 

Modified: trunk/LayoutTests/http/tests/local/blob/script-tests/send-sliced-data-blob.js (120164 => 120165)


--- trunk/LayoutTests/http/tests/local/blob/script-tests/send-sliced-data-blob.js	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/http/tests/local/blob/script-tests/send-sliced-data-blob.js	2012-06-13 06:50:19 UTC (rev 120165)
@@ -7,7 +7,7 @@
     var blob = util.appendAndCreateBlob(appendItems);
     var range = {'start':0, 'length':-1};
     for (var i = 0; i < ranges.length; ++i) {
-        blob = blob.webkitSlice(ranges[i].start, ranges[i].start + ranges[i].length);
+        blob = blob.slice(ranges[i].start, ranges[i].start + ranges[i].length);
         range.start += ranges[i].start;
     }
     range.length = ranges[ranges.length - 1].length;

Modified: trunk/LayoutTests/http/tests/local/fileapi/script-tests/send-sliced-dragged-file.js (120164 => 120165)


--- trunk/LayoutTests/http/tests/local/fileapi/script-tests/send-sliced-dragged-file.js	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/http/tests/local/fileapi/script-tests/send-sliced-dragged-file.js	2012-06-13 06:50:19 UTC (rev 120165)
@@ -56,7 +56,7 @@
 function onStableFileDrop(file, filePath, fileLength, start, length, contentType)
 {
     // Slice the file.
-    subfile = file.webkitSlice(start, start + length, contentType);
+    subfile = file.slice(start, start + length, contentType);
     shouldEvaluateTo("subfile.size", computeExpectedLength(fileLength, start, length));
     shouldBe("subfile.type", (contentType != undefined && contentType != null) ? '"' + contentType + '"' : '""');
 
@@ -75,7 +75,7 @@
 function onUnstableFileDrop(file, filePath, fileLength, start, length, contentType)
 {
     // Slice the file.
-    subfile = file.webkitSlice(start, start + length, contentType);
+    subfile = file.slice(start, start + length, contentType);
     shouldEvaluateTo("subfile.size", computeExpectedLength(fileLength, start, length));
     shouldBe("subfile.type", (contentType != undefined && contentType != null) ? '"' + contentType + '"' : '""');
   

Modified: trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js (120164 => 120165)


--- trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js	2012-06-13 06:50:19 UTC (rev 120165)
@@ -70,7 +70,7 @@
                     var file = files[j];
                     if (dataList[i]['start'] && dataList[i]['length']) {
                         fileSliced = true;
-                        file = file.webkitSlice(dataList[i]['start'], dataList[i]['start'] + dataList[i]['length']);
+                        file = file.slice(dataList[i]['start'], dataList[i]['start'] + dataList[i]['length']);
                     }
                     formDataList.push({'name': dataList[i]['name'], 'value': file, 'filename': dataList[i]['filename']});
                     break;

Modified: trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html (120164 => 120165)


--- trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html	2012-06-13 06:50:19 UTC (rev 120165)
@@ -89,9 +89,8 @@
             var fileMock = {
                 name: "mock.heapsnapshot",
                 size: sourceStringified.length,
-                webkitSlice: function(begin, end) {
-                    return this;
-                }
+                slice: function(begin, end) { return this; },
+                webkitSlice: function(begin, end) { return this; }
             };
 
             WebInspector.HeapProfileHeader.prototype._createFileReader = function() {

Modified: trunk/Source/WebCore/ChangeLog (120164 => 120165)


--- trunk/Source/WebCore/ChangeLog	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/Source/WebCore/ChangeLog	2012-06-13 06:50:19 UTC (rev 120165)
@@ -1,3 +1,27 @@
+2012-06-11  Kinuko Yasuda  <[email protected]>
+
+        Unprefix Blob.webkitSlice
+        https://bugs.webkit.org/show_bug.cgi?id=78111
+
+        Reviewed by Adam Barth.
+
+        Add unprefixed Blob.slice and start showing a deprecation message when webkitSlice is called.
+
+        No new tests: existing tests that call webkitSlice() are converted to slice(). They should keep running.
+
+        * bindings/gobject/WebKitDOMCustom.cpp:
+        (webkit_dom_blob_slice): Removed.
+        (webkit_dom_blob_webkit_slice): Added.
+        * fileapi/Blob.cpp:
+        (WebCore::Blob::slice):
+        (WebCore):
+        (WebCore::Blob::webkitSlice):
+        (WebCore::Blob::sliceInternal): Added.
+        * fileapi/Blob.h:
+        (WebCore):
+        (Blob):
+        * fileapi/Blob.idl:
+
 2012-06-12  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r120036.

Modified: trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.cpp (120164 => 120165)


--- trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.cpp	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.cpp	2012-06-13 06:50:19 UTC (rev 120165)
@@ -44,9 +44,9 @@
 
 /* Compatibility */
 WebKitDOMBlob*
-webkit_dom_blob_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type)
+webkit_dom_blob_webkit_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type)
 {
-    return webkit_dom_blob_webkit_slice(self, start, end, content_type);
+    return webkit_dom_blob_slice(self, start, end, content_type);
 }
 
 void
@@ -60,5 +60,3 @@
 {
     g_warning("The onforminput functionality has been removed from the DOM spec, this function does nothing.");
 }
-
-

Modified: trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.h (120164 => 120165)


--- trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.h	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.h	2012-06-13 06:50:19 UTC (rev 120165)
@@ -29,7 +29,7 @@
 WEBKIT_API gboolean webkit_dom_html_input_element_is_edited(WebKitDOMHTMLInputElement*);
 
 /* Compatibility */
-WEBKIT_API WebKitDOMBlob* webkit_dom_blob_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type);
+WEBKIT_API WebKitDOMBlob* webkit_dom_blob_webkit_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type);
 WEBKIT_API void webkit_dom_html_form_element_dispatch_form_change(WebKitDOMHTMLFormElement* self);
 WEBKIT_API void webkit_dom_html_form_element_dispatch_form_input(WebKitDOMHTMLFormElement* self);
 

Modified: trunk/Source/WebCore/fileapi/Blob.cpp (120164 => 120165)


--- trunk/Source/WebCore/fileapi/Blob.cpp	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/Source/WebCore/fileapi/Blob.cpp	2012-06-13 06:50:19 UTC (rev 120165)
@@ -33,10 +33,23 @@
 
 #include "BlobURL.h"
 #include "File.h"
+#include "HistogramSupport.h"
+#include "ScriptExecutionContext.h"
 #include "ThreadableBlobRegistry.h"
 
 namespace WebCore {
 
+namespace {
+
+// Used in histograms to see when we can actually deprecate the prefixed slice.
+enum SliceHistogramEnum {
+    SliceWithoutPrefix,
+    SliceWithPrefix,
+    SliceHistogramEnumMax,
+};
+
+} // namespace
+
 Blob::Blob()
     : m_size(0)
 {
@@ -73,8 +86,23 @@
 }
 
 #if ENABLE(BLOB)
-PassRefPtr<Blob> Blob::webkitSlice(long long start, long long end, const String& contentType) const
+PassRefPtr<Blob> Blob::slice(long long start, long long end, const String& contentType) const
 {
+    HistogramSupport::histogramEnumeration("WebCore.Blob.slice", SliceWithoutPrefix, SliceHistogramEnumMax);
+    return sliceInternal(start, end, contentType);
+}
+
+PassRefPtr<Blob> Blob::webkitSlice(ScriptExecutionContext* context, long long start, long long end, const String& contentType) const
+{
+    String message("Blob.webkitSlice() is deprecated. Use Blob.slice() instead .");
+    context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, message);
+
+    HistogramSupport::histogramEnumeration("WebCore.Blob.slice", SliceWithPrefix, SliceHistogramEnumMax);
+    return sliceInternal(start, end, contentType);
+}
+
+PassRefPtr<Blob> Blob::sliceInternal(long long start, long long end, const String& contentType) const
+{
     // When we slice a file for the first time, we obtain a snapshot of the file by capturing its current size and modification time.
     // The modification time will be used to verify if the file has been changed or not, when the underlying data are accessed.
     long long size;

Modified: trunk/Source/WebCore/fileapi/Blob.h (120164 => 120165)


--- trunk/Source/WebCore/fileapi/Blob.h	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/Source/WebCore/fileapi/Blob.h	2012-06-13 06:50:19 UTC (rev 120165)
@@ -41,6 +41,8 @@
 
 namespace WebCore {
 
+class ScriptExecutionContext;
+
 class Blob : public RefCounted<Blob> {
 public:
     static PassRefPtr<Blob> create()
@@ -68,7 +70,11 @@
     virtual bool isFile() const { return false; }
 
 #if ENABLE(BLOB)
-    PassRefPtr<Blob> webkitSlice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const;
+    PassRefPtr<Blob> slice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const;
+
+    // Prefixed version is going to be deprecated. This internally calls sliceInternal() (as slice() does) after showing a deprecation message.
+    PassRefPtr<Blob> webkitSlice(ScriptExecutionContext*, long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const;
+
 #endif
 
 protected:
@@ -78,6 +84,10 @@
     // For deserialization.
     Blob(const KURL& srcURL, const String& type, long long size);
 
+#if ENABLE(BLOB)
+    PassRefPtr<Blob> sliceInternal(long long start, long long end, const String& contentType) const;
+#endif
+
     // This is an internal URL referring to the blob data associated with this object. It serves
     // as an identifier for this blob. The internal URL is never used to source the blob's content
     // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.

Modified: trunk/Source/WebCore/fileapi/Blob.idl (120164 => 120165)


--- trunk/Source/WebCore/fileapi/Blob.idl	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/Source/WebCore/fileapi/Blob.idl	2012-06-13 06:50:19 UTC (rev 120165)
@@ -42,9 +42,13 @@
 
 #if !defined(LANGUAGE_OBJECTIVE_C)
 #if defined(ENABLE_BLOB) && ENABLE_BLOB
-        Blob webkitSlice(in [Optional] long long start, in [Optional] long long end, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString contentType);
+        Blob slice(in [Optional] long long start, in [Optional] long long end, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString contentType);
+#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT
+        // Prefixed version is going to be deprecated.
+        [CallWith=ScriptExecutionContext] Blob webkitSlice(in [Optional] long long start, in [Optional] long long end, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString contentType);
 #endif
 #endif
+#endif
     };
 
 }

Modified: trunk/Source/WebCore/fileapi/File.h (120164 => 120165)


--- trunk/Source/WebCore/fileapi/File.h	2012-06-13 06:33:22 UTC (rev 120164)
+++ trunk/Source/WebCore/fileapi/File.h	2012-06-13 06:50:19 UTC (rev 120165)
@@ -56,7 +56,7 @@
 #if ENABLE(FILE_SYSTEM)
     // If filesystem files live in the remote filesystem, the port might pass the valid metadata (whose length field is non-negative) and cache in the File object.
     //
-    // Otherwise calling size(), lastModifiedTime() and webkitSlice() will synchronously query the file metadata.
+    // Otherwise calling size(), lastModifiedTime() and slice() will synchronously query the file metadata.
     static PassRefPtr<File> createForFileSystemFile(const String& name, const FileMetadata& metadata)
     {
         return adoptRef(new File(name, metadata));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to