Chromium Code Reviews| Index: Source/wtf/text/TextCodecBase64.cpp |
| diff --git a/Source/platform/geometry/FloatSize.cpp b/Source/wtf/text/TextCodecBase64.cpp |
| similarity index 51% |
| copy from Source/platform/geometry/FloatSize.cpp |
| copy to Source/wtf/text/TextCodecBase64.cpp |
| index e3da8beff0df58d452d8d53b5d73e76b1bcb1524..26348d26751711fe802dabd1dc1692ebc89100c1 100644 |
| --- a/Source/platform/geometry/FloatSize.cpp |
| +++ b/Source/wtf/text/TextCodecBase64.cpp |
| @@ -1,6 +1,5 @@ |
| /* |
| - * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. |
| - * Copyright (C) 2005 Nokia. All rights reserved. |
| + * Copyright (C) 2004, 2006, 2008, 2011 Apple Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| @@ -25,44 +24,51 @@ |
| */ |
| #include "config.h" |
| -#include "platform/geometry/FloatSize.h" |
| +#include "wtf/text/TextCodecBase64.h" |
| -#include "platform/FloatConversion.h" |
| -#include "platform/geometry/IntSize.h" |
| -#include "platform/geometry/LayoutSize.h" |
| -#include <limits> |
| -#include <math.h> |
| +#include "wtf/text/Base64.h" |
| +#include "wtf/text/CString.h" |
| +#include "wtf/text/StringBuffer.h" |
|
jsbell
2014/01/24 22:15:05
Is this include needed?
|
| +#include "wtf/unicode/CharacterNames.h" |
|
jsbell
2014/01/24 22:15:05
Is this include needed?
|
| +using namespace WTF; |
| using namespace std; |
| -namespace WebCore { |
| +namespace WTF { |
| -FloatSize::FloatSize(const IntSize& size) : m_width(size.width()), m_height(size.height()) |
| +PassOwnPtr<TextCodec> TextCodecBase64::create(const TextEncoding&, const void*) |
| { |
| + return adoptPtr(new TextCodecBase64); |
| } |
| -FloatSize::FloatSize(const LayoutSize& size) : m_width(size.width()), m_height(size.height()) |
| +void TextCodecBase64::registerEncodingNames(EncodingNameRegistrar registrar) |
|
jsbell
2014/01/24 22:15:05
Does this registration cause base64 to show up in
|
| { |
| + registrar("Base64", "Base64"); |
| + registrar("base64", "Base64"); |
| } |
| -float FloatSize::diagonalLength() const |
| +void TextCodecBase64::registerCodecs(TextCodecRegistrar registrar) |
| { |
| - return sqrtf(diagonalLengthSquared()); |
| + registrar("Base64", create, 0); |
| } |
| -bool FloatSize::isZero() const |
| +String TextCodecBase64::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError) |
|
jsbell
2014/01/24 22:15:05
Is streaming handled here? It looks like flush is
|
| { |
| - return fabs(m_width) < numeric_limits<float>::epsilon() && fabs(m_height) < numeric_limits<float>::epsilon(); |
| + return base64Encode(bytes, length); |
| } |
| -bool FloatSize::isExpressibleAsIntSize() const |
| +CString TextCodecBase64::encode(const UChar* characters, size_t length, UnencodableHandling) |
|
jsbell
2014/01/24 22:15:05
It doesn't look like the Codec API handles flushin
|
| { |
| - return isWithinIntRange(m_width) && isWithinIntRange(m_height); |
| + Vector<char> output; |
| + base64Decode(characters, length, output); |
| + return CString(output.data(), output.size()); |
| } |
| -FloatSize FloatSize::narrowPrecision(double width, double height) |
| +CString TextCodecBase64::encode(const LChar* characters, size_t length, UnencodableHandling) |
| { |
| - return FloatSize(narrowPrecisionToFloat(width), narrowPrecisionToFloat(height)); |
| + Vector<char> output; |
| + base64Decode(reinterpret_cast<const char*>(characters), length, output); |
| + return CString(output.data(), output.size()); |
| } |
| -} |
| +} // namespace WTF |