Index: Source/bindings/v8/custom/V8FileCustom.cpp |
diff --git a/Source/core/html/HTMLDimension.h b/Source/bindings/v8/custom/V8FileCustom.cpp |
similarity index 52% |
copy from Source/core/html/HTMLDimension.h |
copy to Source/bindings/v8/custom/V8FileCustom.cpp |
index f0aa343f8835217bfe6340c7a564ba8693458eda..e121e82267cc1aa34701321dffcb205df8280ac3 100644 |
--- a/Source/core/html/HTMLDimension.h |
+++ b/Source/bindings/v8/custom/V8FileCustom.cpp |
@@ -28,55 +28,56 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef HTMLDimension_h |
-#define HTMLDimension_h |
+#include "config.h" |
+#include "V8File.h" |
-#include "wtf/Forward.h" |
-#include "wtf/Vector.h" |
+#include "RuntimeEnabledFeatures.h" |
+#include "bindings/v8/custom/V8BlobCustomHelpers.h" |
+#include "core/fileapi/BlobBuilder.h" |
+#include "wtf/RefPtr.h" |
namespace WebCore { |
-// This class corresponds to a dimension as described in HTML5 by the |
-// "rules for parsing a list of dimensions" (section 2.4.4.6). |
-class HTMLDimension { |
-public: |
- enum HTMLDimensionType { |
- Relative, Percentage, Absolute |
- }; |
+void V8File::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ if (!RuntimeEnabledFeatures::fileConstructorEnabled()) { |
+ throwTypeError("Illegal constructor", info.GetIsolate()); |
+ return; |
+ } |
- HTMLDimension() |
- : m_type(Absolute) |
- , m_value(0) |
- { |
+ if (info.Length() < 2) { |
+ throwTypeError("Constructor requires at least two arguments", info.GetIsolate()); |
+ return; |
} |
- HTMLDimension(double value, HTMLDimensionType type) |
- : m_type(type) |
- , m_value(value) |
- { |
+ // FIXME: handle WebIDL sequences, see http://crbug.com/314755 |
+ if (!info[0]->IsArray()) { |
+ throwTypeError("First argument of the constructor is not of type Array", info.GetIsolate()); |
+ return; |
} |
- HTMLDimensionType type() const { return m_type; } |
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, fileName, info[1]); |
- bool isRelative() const { return m_type == Relative; } |
- bool isPercentage() const { return m_type == Percentage; } |
- bool isAbsolute() const { return m_type == Absolute; } |
+ String contentType; |
+ String endings = "transparent"; |
- double value() const { return m_value; } |
+ if (info.Length() > 2) { |
+ if (!info[2]->IsObject()) { |
+ throwTypeError("Third argument of the constructor is not of type Object", info.GetIsolate()); |
+ return; |
+ } |
- bool operator==(const HTMLDimension& other) const |
- { |
- return m_type == other.m_type && m_value == other.m_value; |
+ if (!V8BlobCustomHelpers::processBlobPropertyBag(info[2], info.GetIsolate(), contentType, endings)) |
+ return; |
} |
- bool operator!=(const HTMLDimension& other) const { return !(*this == other); } |
+ ASSERT(endings == "transparent" || endings == "native"); |
-private: |
- HTMLDimensionType m_type; |
- double m_value; |
-}; |
+ BlobBuilder blobBuilder; |
+ if (!V8BlobCustomHelpers::processBlobParts(info[0], info.GetIsolate(), endings, blobBuilder)) |
+ return; |
-Vector<HTMLDimension> parseListOfDimensions(const String&); |
+ RefPtr<File> file = blobBuilder.createFile(contentType, fileName, currentTime()); |
+ info.GetReturnValue().Set(toV8(file.get(), info.Holder(), info.GetIsolate())); |
+} |
} // namespace WebCore |
- |
-#endif // HTMLDimension_h |