Changeset 120165 in webkit


Ignore:
Timestamp:
Jun 12, 2012 11:50:19 PM (12 years ago)
Author:
kinuko@chromium.org
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:
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120163 r120165  
     12012-06-11  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Unprefix Blob.webkitSlice
     4        https://bugs.webkit.org/show_bug.cgi?id=78111
     5
     6        Reviewed by Adam Barth.
     7
     8        Converted existing tests that are calling Blob.webkitSlice() to call slice().
     9
     10        * fast/files/blob-slice-overflow.html:
     11        * fast/files/blob-slice-test.html:
     12        * fast/files/resources/read-blob-test-cases.js:
     13        (testReadingSlicedFileBlob):
     14        (testReadingSlicedTextBlob):
     15        (testReadingSlicedArrayBufferBlob):
     16        (testReadingSlicedHybridBlob):
     17        (testReadingTripleSlicedHybridBlob):
     18        * fast/filesystem/resources/file-writer-utils.js:
     19        (verifyByteRangeIsZeroesHelper):
     20        * http/tests/local/blob/script-tests/send-hybrid-blob.js:
     21        (runHybridBlobTest):
     22        * http/tests/local/blob/script-tests/send-sliced-data-blob.js:
     23        (runSliceTest):
     24        * http/tests/local/fileapi/script-tests/send-sliced-dragged-file.js:
     25        (onStableFileDrop):
     26        (onUnstableFileDrop):
     27        * http/tests/local/formdata/resources/send-form-data-common.js:
     28        (testSendingFormData):
     29        * inspector/profiler/heap-snapshot-loader.html:
     30
    1312012-06-12  Csaba Osztrogonác  <ossy@webkit.org>
    232
  • trunk/LayoutTests/fast/files/blob-slice-overflow.html

    r115582 r120165  
    1515
    1616blob = new Blob([text]);
    17 slicedBlob = blob.webkitSlice(1999, 9223372036854775000);
     17slicedBlob = blob.slice(1999, 9223372036854775000);
    1818
    1919document.getElementById('console').appendChild(document.createTextNode('Blob slice length: ' + slicedBlob.size));
  • trunk/LayoutTests/fast/files/blob-slice-test.html

    r115582 r120165  
    4747    if (start == undefined && end == undefined) {
    4848        message += "without parameters";
    49         subBlob = blob.webkitSlice();
     49        subBlob = blob.slice();
    5050    } else if (end == undefined) {
    5151        message += "from " + start;
    52         subBlob = blob.webkitSlice(start);
     52        subBlob = blob.slice(start);
    5353    } else {
    5454        message += "from " + start + " to " + end;
    55         subBlob = blob.webkitSlice(start, end);
     55        subBlob = blob.slice(start, end);
    5656    }
    5757    message += ": ";
  • trunk/LayoutTests/fast/files/resources/read-blob-test-cases.js

    r119805 r120165  
    106106{
    107107    log("Test reading a blob containing sliced file");
    108     var blob = buildBlob([testFiles['file2'].webkitSlice(1, 6)]);
     108    var blob = buildBlob([testFiles['file2'].slice(1, 6)]);
    109109    readBlobAsBinaryString(testFiles, blob);
    110110}
     
    114114    log("Test reading a blob containing sliced text");
    115115    var blob = buildBlob(['First'])
    116     blob = blob.webkitSlice(1, 11);
     116    blob = blob.slice(1, 11);
    117117    readBlobAsBinaryString(testFiles, blob);
    118118}
     
    123123    var array = new Uint8Array([0, 1, 2, 128, 129, 130, 253, 254, 255]);
    124124    var blob = buildBlob([array])
    125     blob = blob.webkitSlice(1, 11);
     125    blob = blob.slice(1, 11);
    126126    readBlobAsBinaryString(testFiles, blob);
    127127}
     
    164164    var array = new Uint8Array([48, 49, 50]);
    165165    var blob = buildBlob(['First', testFiles['file1'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array]);
    166     var blob = blob.webkitSlice(7, 19);
     166    var blob = blob.slice(7, 19);
    167167    readBlobAsBinaryString(testFiles, blob);
    168168}
     
    172172    log("Test reading a triple-sliced hybrid blob");
    173173    var array = new Uint8Array([48, 49, 50]);
    174     var items = ['First', testFiles['file1'].webkitSlice(1, 11), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array];
     174    var items = ['First', testFiles['file1'].slice(1, 11), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array];
    175175    var blob = buildBlob(items);
    176     var blob = blob.webkitSlice(7, 19);
     176    var blob = blob.slice(7, 19);
    177177    var blob2 = buildBlob(items.concat(['Foo', blob, 'Bar']));
    178     var blob2 = blob2.webkitSlice(12, 42);
     178    var blob2 = blob2.slice(12, 42);
    179179    readBlobAsBinaryString(testFiles, blob2);
    180180}
  • trunk/LayoutTests/fast/filesystem/resources/file-writer-utils.js

    r115582 r120165  
    7373            onSuccess();
    7474        };
    75     fileReader.readAsBinaryString(file.webkitSlice(start, start + length));
     75    fileReader.readAsBinaryString(file.slice(start, start + length));
    7676}
    7777
     
    9292            onSuccess();
    9393        };
    94     fileReader.readAsText(file.webkitSlice(start, start + data.length));
     94    fileReader.readAsText(file.slice(start, start + data.length));
    9595}
    9696
  • trunk/LayoutTests/http/tests/local/blob/script-tests/send-hybrid-blob.js

    r83873 r120165  
    1818    var urlParameter = util.createUrlParameter(fileIndexOrStrings, opt_range);
    1919    if (opt_range)
    20         blob = blob.webkitSlice(opt_range.start, opt_range.start + opt_range.length);
     20        blob = blob.slice(opt_range.start, opt_range.start + opt_range.length);
    2121    util.uploadBlob(blob, urlParameter);
    2222}
  • trunk/LayoutTests/http/tests/local/blob/script-tests/send-sliced-data-blob.js

    r83873 r120165  
    88    var range = {'start':0, 'length':-1};
    99    for (var i = 0; i < ranges.length; ++i) {
    10         blob = blob.webkitSlice(ranges[i].start, ranges[i].start + ranges[i].length);
     10        blob = blob.slice(ranges[i].start, ranges[i].start + ranges[i].length);
    1111        range.start += ranges[i].start;
    1212    }
  • trunk/LayoutTests/http/tests/local/fileapi/script-tests/send-sliced-dragged-file.js

    r118920 r120165  
    5757{
    5858    // Slice the file.
    59     subfile = file.webkitSlice(start, start + length, contentType);
     59    subfile = file.slice(start, start + length, contentType);
    6060    shouldEvaluateTo("subfile.size", computeExpectedLength(fileLength, start, length));
    6161    shouldBe("subfile.type", (contentType != undefined && contentType != null) ? '"' + contentType + '"' : '""');
     
    7676{
    7777    // Slice the file.
    78     subfile = file.webkitSlice(start, start + length, contentType);
     78    subfile = file.slice(start, start + length, contentType);
    7979    shouldEvaluateTo("subfile.size", computeExpectedLength(fileLength, start, length));
    8080    shouldBe("subfile.type", (contentType != undefined && contentType != null) ? '"' + contentType + '"' : '""');
  • trunk/LayoutTests/http/tests/local/formdata/resources/send-form-data-common.js

    r97274 r120165  
    7171                    if (dataList[i]['start'] && dataList[i]['length']) {
    7272                        fileSliced = true;
    73                         file = file.webkitSlice(dataList[i]['start'], dataList[i]['start'] + dataList[i]['length']);
     73                        file = file.slice(dataList[i]['start'], dataList[i]['start'] + dataList[i]['length']);
    7474                    }
    7575                    formDataList.push({'name': dataList[i]['name'], 'value': file, 'filename': dataList[i]['filename']});
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html

    r118778 r120165  
    9090                name: "mock.heapsnapshot",
    9191                size: sourceStringified.length,
    92                 webkitSlice: function(begin, end) {
    93                     return this;
    94                 }
     92                slice: function(begin, end) { return this; },
     93                webkitSlice: function(begin, end) { return this; }
    9594            };
    9695
  • trunk/Source/WebCore/ChangeLog

    r120164 r120165  
     12012-06-11  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Unprefix Blob.webkitSlice
     4        https://bugs.webkit.org/show_bug.cgi?id=78111
     5
     6        Reviewed by Adam Barth.
     7
     8        Add unprefixed Blob.slice and start showing a deprecation message when webkitSlice is called.
     9
     10        No new tests: existing tests that call webkitSlice() are converted to slice(). They should keep running.
     11
     12        * bindings/gobject/WebKitDOMCustom.cpp:
     13        (webkit_dom_blob_slice): Removed.
     14        (webkit_dom_blob_webkit_slice): Added.
     15        * fileapi/Blob.cpp:
     16        (WebCore::Blob::slice):
     17        (WebCore):
     18        (WebCore::Blob::webkitSlice):
     19        (WebCore::Blob::sliceInternal): Added.
     20        * fileapi/Blob.h:
     21        (WebCore):
     22        (Blob):
     23        * fileapi/Blob.idl:
     24
    1252012-06-12  Sheriff Bot  <webkit.review.bot@gmail.com>
    226
  • trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.cpp

    r96093 r120165  
    4545/* Compatibility */
    4646WebKitDOMBlob*
    47 webkit_dom_blob_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type)
     47webkit_dom_blob_webkit_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type)
    4848{
    49     return webkit_dom_blob_webkit_slice(self, start, end, content_type);
     49    return webkit_dom_blob_slice(self, start, end, content_type);
    5050}
    5151
     
    6161    g_warning("The onforminput functionality has been removed from the DOM spec, this function does nothing.");
    6262}
    63 
    64 
  • trunk/Source/WebCore/bindings/gobject/WebKitDOMCustom.h

    r96093 r120165  
    3030
    3131/* Compatibility */
    32 WEBKIT_API WebKitDOMBlob* webkit_dom_blob_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type);
     32WEBKIT_API WebKitDOMBlob* webkit_dom_blob_webkit_slice(WebKitDOMBlob* self, gint64 start, gint64 end, const gchar* content_type);
    3333WEBKIT_API void webkit_dom_html_form_element_dispatch_form_change(WebKitDOMHTMLFormElement* self);
    3434WEBKIT_API void webkit_dom_html_form_element_dispatch_form_input(WebKitDOMHTMLFormElement* self);
  • trunk/Source/WebCore/fileapi/Blob.cpp

    r118394 r120165  
    3434#include "BlobURL.h"
    3535#include "File.h"
     36#include "HistogramSupport.h"
     37#include "ScriptExecutionContext.h"
    3638#include "ThreadableBlobRegistry.h"
    3739
    3840namespace WebCore {
     41
     42namespace {
     43
     44// Used in histograms to see when we can actually deprecate the prefixed slice.
     45enum SliceHistogramEnum {
     46    SliceWithoutPrefix,
     47    SliceWithPrefix,
     48    SliceHistogramEnumMax,
     49};
     50
     51} // namespace
    3952
    4053Blob::Blob()
     
    7487
    7588#if ENABLE(BLOB)
    76 PassRefPtr<Blob> Blob::webkitSlice(long long start, long long end, const String& contentType) const
     89PassRefPtr<Blob> Blob::slice(long long start, long long end, const String& contentType) const
     90{
     91    HistogramSupport::histogramEnumeration("WebCore.Blob.slice", SliceWithoutPrefix, SliceHistogramEnumMax);
     92    return sliceInternal(start, end, contentType);
     93}
     94
     95PassRefPtr<Blob> Blob::webkitSlice(ScriptExecutionContext* context, long long start, long long end, const String& contentType) const
     96{
     97    String message("Blob.webkitSlice() is deprecated. Use Blob.slice() instead .");
     98    context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, message);
     99
     100    HistogramSupport::histogramEnumeration("WebCore.Blob.slice", SliceWithPrefix, SliceHistogramEnumMax);
     101    return sliceInternal(start, end, contentType);
     102}
     103
     104PassRefPtr<Blob> Blob::sliceInternal(long long start, long long end, const String& contentType) const
    77105{
    78106    // When we slice a file for the first time, we obtain a snapshot of the file by capturing its current size and modification time.
  • trunk/Source/WebCore/fileapi/Blob.h

    r118394 r120165  
    4242namespace WebCore {
    4343
     44class ScriptExecutionContext;
     45
    4446class Blob : public RefCounted<Blob> {
    4547public:
     
    6971
    7072#if ENABLE(BLOB)
    71     PassRefPtr<Blob> webkitSlice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const;
     73    PassRefPtr<Blob> slice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const;
     74
     75    // Prefixed version is going to be deprecated. This internally calls sliceInternal() (as slice() does) after showing a deprecation message.
     76    PassRefPtr<Blob> webkitSlice(ScriptExecutionContext*, long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const;
     77
    7278#endif
    7379
     
    7884    // For deserialization.
    7985    Blob(const KURL& srcURL, const String& type, long long size);
     86
     87#if ENABLE(BLOB)
     88    PassRefPtr<Blob> sliceInternal(long long start, long long end, const String& contentType) const;
     89#endif
    8090
    8191    // This is an internal URL referring to the blob data associated with this object. It serves
  • trunk/Source/WebCore/fileapi/Blob.idl

    r115582 r120165  
    4343#if !defined(LANGUAGE_OBJECTIVE_C)
    4444#if defined(ENABLE_BLOB) && ENABLE_BLOB
    45         Blob webkitSlice(in [Optional] long long start, in [Optional] long long end, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString contentType);
     45        Blob slice(in [Optional] long long start, in [Optional] long long end, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString contentType);
     46#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT
     47        // Prefixed version is going to be deprecated.
     48        [CallWith=ScriptExecutionContext] Blob webkitSlice(in [Optional] long long start, in [Optional] long long end, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString contentType);
     49#endif
    4650#endif
    4751#endif
  • trunk/Source/WebCore/fileapi/File.h

    r119824 r120165  
    5757    // 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.
    5858    //
    59     // Otherwise calling size(), lastModifiedTime() and webkitSlice() will synchronously query the file metadata.
     59    // Otherwise calling size(), lastModifiedTime() and slice() will synchronously query the file metadata.
    6060    static PassRefPtr<File> createForFileSystemFile(const String& name, const FileMetadata& metadata)
    6161    {
Note: See TracChangeset for help on using the changeset viewer.