From: jianli@chromium.org Date: Tue, 1 Sep 2009 20:16:57 +0000 (+0000) Subject: [V8] FileList cannot be accessed via index in Chromium. X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=858f36c7a668190c0646a95d7d41e0cb69110b80 [V8] FileList cannot be accessed via index in Chromium. https://bugs.webkit.org/show_bug.cgi?id=28883 Reviewed by Dimitri Glazkov. Tested by clipboard-file-access.html. * WebCore.gypi: * bindings/v8/V8DOMWrapper.cpp: (WebCore::V8DOMWrapper::getTemplate): * bindings/v8/custom/V8CustomBinding.h: * bindings/v8/custom/V8FileListCustom.cpp: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@47947 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 3bb8b59..eb365f4 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2009-09-01 Jian Li + + Reviewed by Dimitri Glazkov. + + [V8] FileList cannot be accessed via index in Chromium. + https://bugs.webkit.org/show_bug.cgi?id=28883 + + Tested by clipboard-file-access.html. + + * WebCore.gypi: + * bindings/v8/V8DOMWrapper.cpp: + (WebCore::V8DOMWrapper::getTemplate): + * bindings/v8/custom/V8CustomBinding.h: + * bindings/v8/custom/V8FileListCustom.cpp: Added. + 2009-08-31 Jon Honeycutt Remove the workaround added in r47316. diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi index f0bdd58..a935c33 100644 --- a/WebCore/WebCore.gypi +++ b/WebCore/WebCore.gypi @@ -637,6 +637,7 @@ 'bindings/v8/custom/V8DocumentCustom.cpp', 'bindings/v8/custom/V8ElementCustom.cpp', 'bindings/v8/custom/V8EventCustom.cpp', + 'bindings/v8/custom/V8FileListCustom.cpp', 'bindings/v8/custom/V8HTMLAudioElementConstructor.cpp', 'bindings/v8/custom/V8HTMLCanvasElementCustom.cpp', 'bindings/v8/custom/V8HTMLCollectionCustom.cpp', diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp index eb1ad77..c6e0cad 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -491,6 +491,9 @@ v8::Persistent V8DOMWrapper::getTemplate(V8ClassIndex::V8W case V8ClassIndex::CLIENTRECTLIST: descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(ClientRectList)); break; + case V8ClassIndex::FILELIST: + descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(FileList)); + break; #if ENABLE(DATAGRID) case V8ClassIndex::DATAGRIDCOLUMNLIST: descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(DataGridColumnList)); diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h index 1075bf8..ae9f9ce 100644 --- a/WebCore/bindings/v8/custom/V8CustomBinding.h +++ b/WebCore/bindings/v8/custom/V8CustomBinding.h @@ -477,6 +477,7 @@ namespace WebCore { DECLARE_CALLBACK(SQLResultSetRowListItem); DECLARE_INDEXED_PROPERTY_GETTER(ClientRectList); + DECLARE_INDEXED_PROPERTY_GETTER(FileList); #if ENABLE(DATAGRID) DECLARE_PROPERTY_ACCESSOR(HTMLDataGridElementDataSource); diff --git a/WebCore/bindings/v8/custom/V8FileListCustom.cpp b/WebCore/bindings/v8/custom/V8FileListCustom.cpp new file mode 100644 index 0000000..bc533cf --- /dev/null +++ b/WebCore/bindings/v8/custom/V8FileListCustom.cpp @@ -0,0 +1,54 @@ +/* + * 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 "FileList.h" + +#include "File.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8Proxy.h" + +#include + +namespace WebCore { + +INDEXED_PROPERTY_GETTER(FileList) +{ + INC_STATS("DOM.FileList.IndexedPropertyGetter"); + FileList* fileList = V8DOMWrapper::convertToNativeObject(V8ClassIndex::FILELIST, info.Holder()); + RefPtr file = fileList->item(index); + if (!file) + return notHandledByInterceptor(); + + return V8DOMWrapper::convertToV8Object(V8ClassIndex::FILE, file.release()); +} + +} // namespace WebCore