Commit a5d23a13 authored by jamesr@google.com's avatar jamesr@google.com

[chromium] Move WebMimeRegistry and dependencies to Source/Platform

https://bugs.webkit.org/show_bug.cgi?id=74583

Reviewed by Darin Fisher.

.:

Update .gitignore for Source/Platform/Platform.gyp/ generated project files.

* .gitignore:

Source/Platform:

This creates a skeleton directory structure for the chromium WebKit platform API and moves WebMimeRegistry.h
along with its dependencies (WebString and WebCString) to their final location.

* Platform.gyp/Platform.gyp: Added.
* Platform.gypi: Added.
* chromium/platform/WebCString.h: Copied from Source/WebKit/chromium/public/platform/WebCString.h.
(WebKit::WebCString::~WebCString):
(WebKit::WebCString::WebCString):
(WebKit::WebCString::operator=):
(WebKit::WebCString::isEmpty):
(WebKit::WebCString::isNull):
(WebKit::WebCString::operator std::string):
(WebKit::WebCString::fromUTF16):
(WebKit::operator<):
* chromium/platform/WebCommon.h: Copied from Source/WebKit/chromium/public/platform/WebCommon.h.
* chromium/platform/WebMimeRegistry.h: Copied from Source/WebKit/chromium/public/platform/WebMimeRegistry.h.
(WebKit::WebMimeRegistry::~WebMimeRegistry):
* chromium/platform/WebString.h: Copied from Source/WebKit/chromium/public/platform/WebString.h.
(WebKit::WebString::~WebString):
(WebKit::WebString::WebString):
(WebKit::WebString::operator=):
(WebKit::WebString::isEmpty):
(WebKit::WebString::isNull):
(WebKit::WebString::operator string16):
(WebKit::WebString::operator NullableString16):
(WebKit::WebString::fromUTF8):
(WebKit::operator==):
(WebKit::operator!=):
* chromium/src/WebCString.cpp: Renamed from Source/WebKit/chromium/src/WebCString.cpp.
(WebKit::WebCString::compare):
(WebKit::WebCString::reset):
(WebKit::WebCString::assign):
(WebKit::WebCString::length):
(WebKit::WebCString::data):
(WebKit::WebCString::utf16):
(WebKit::WebCString::fromUTF16):
(WebKit::WebCString::WebCString):
(WebKit::WebCString::operator=):
(WebKit::WebCString::operator WTF::CString):
* chromium/src/WebString.cpp: Renamed from Source/WebKit/chromium/src/WebString.cpp.
(WebKit::WebString::reset):
(WebKit::WebString::assign):
(WebKit::WebString::length):
(WebKit::WebString::data):
(WebKit::WebString::utf8):
(WebKit::WebString::fromUTF8):
(WebKit::WebString::equals):
(WebKit::WebString::WebString):
(WebKit::WebString::operator=):
(WebKit::WebString::operator WTF::String):
(WebKit::WebString::operator WTF::AtomicString):

Source/WebKit/chromium:

public/platform/WebMimeRegistry.h is a temporary forwarding header to ease the transition. Once downstream
callers are updated to the new location this header can be removed.

WebString, WebCString, and WebCommon.h will remain in place as forwarding headers for users of the WebKit client
API.

* WebKit.gyp:
* public/platform/WebCString.h:
* public/platform/WebCommon.h:
* public/platform/WebMimeRegistry.h:
* public/platform/WebString.h:

Tools:

Teaches the WEBKIT_EXPORT check about the chromium WebKit platform API header location.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_function_definition):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104048 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aa134a21
......@@ -54,6 +54,10 @@ Source/WebKit/chromium/*.vcproj*
Source/WebKit/chromium/All.xcodeproj
Source/WebKit/chromium/WebKit.xcodeproj
Source/WebKit/chromium/WebKitUnitTests.xcodeproj
Source/Platform/Platform.gyp/*.Makefile
Source/Platform/Platform.gyp/*.mk
Source/Platform/Platform.gyp/*.sln
Source/Platform/Platform.gyp/*.vcproj*
Tools/Tools.xcodeproj
Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.xcodeproj
......
2012-01-04 James Robinson <jamesr@chromium.org>
[chromium] Move WebMimeRegistry and dependencies to Source/Platform
https://bugs.webkit.org/show_bug.cgi?id=74583
Reviewed by Darin Fisher.
Update .gitignore for Source/Platform/Platform.gyp/ generated project files.
* .gitignore:
2012-01-04 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
[Qt] Introduce new qmake variable 'WEBKIT' for signaling dependencies
......
2012-01-04 James Robinson <jamesr@chromium.org>
[chromium] Move WebMimeRegistry and dependencies to Source/Platform
https://bugs.webkit.org/show_bug.cgi?id=74583
Reviewed by Darin Fisher.
This creates a skeleton directory structure for the chromium WebKit platform API and moves WebMimeRegistry.h
along with its dependencies (WebString and WebCString) to their final location.
* Platform.gyp/Platform.gyp: Added.
* Platform.gypi: Added.
* chromium/platform/WebCString.h: Copied from Source/WebKit/chromium/public/platform/WebCString.h.
(WebKit::WebCString::~WebCString):
(WebKit::WebCString::WebCString):
(WebKit::WebCString::operator=):
(WebKit::WebCString::isEmpty):
(WebKit::WebCString::isNull):
(WebKit::WebCString::operator std::string):
(WebKit::WebCString::fromUTF16):
(WebKit::operator<):
* chromium/platform/WebCommon.h: Copied from Source/WebKit/chromium/public/platform/WebCommon.h.
* chromium/platform/WebMimeRegistry.h: Copied from Source/WebKit/chromium/public/platform/WebMimeRegistry.h.
(WebKit::WebMimeRegistry::~WebMimeRegistry):
* chromium/platform/WebString.h: Copied from Source/WebKit/chromium/public/platform/WebString.h.
(WebKit::WebString::~WebString):
(WebKit::WebString::WebString):
(WebKit::WebString::operator=):
(WebKit::WebString::isEmpty):
(WebKit::WebString::isNull):
(WebKit::WebString::operator string16):
(WebKit::WebString::operator NullableString16):
(WebKit::WebString::fromUTF8):
(WebKit::operator==):
(WebKit::operator!=):
* chromium/src/WebCString.cpp: Renamed from Source/WebKit/chromium/src/WebCString.cpp.
(WebKit::WebCString::compare):
(WebKit::WebCString::reset):
(WebKit::WebCString::assign):
(WebKit::WebCString::length):
(WebKit::WebCString::data):
(WebKit::WebCString::utf16):
(WebKit::WebCString::fromUTF16):
(WebKit::WebCString::WebCString):
(WebKit::WebCString::operator=):
(WebKit::WebCString::operator WTF::CString):
* chromium/src/WebString.cpp: Renamed from Source/WebKit/chromium/src/WebString.cpp.
(WebKit::WebString::reset):
(WebKit::WebString::assign):
(WebKit::WebString::length):
(WebKit::WebString::data):
(WebKit::WebString::utf8):
(WebKit::WebString::fromUTF8):
(WebKit::WebString::equals):
(WebKit::WebString::WebString):
(WebKit::WebString::operator=):
(WebKit::WebString::operator WTF::String):
(WebKit::WebString::operator WTF::AtomicString):
2011-11-02 Adam Barth <abarth@webkit.org>
Add stubs for WTF and Platform
......
#
# Copyright (C) 2011 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.
#
{
'includes': [
'../Platform.gypi',
],
'targets': [
{
'target_name': 'platform',
'type': 'static_library',
'dependencies': [
'../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf',
'../../WTF/WTF.gyp/WTF.gyp:newwtf',
],
'include_dirs': [
'../chromium',
],
'defines': [
'WEBKIT_IMPLEMENTATION=1',
],
'sources': [
'<@(platform_files)',
],
'direct_dependent_settings': {
'include_dirs': [
'../chromium',
],
},
'conditions': [
['inside_chromium_build==1', {
'conditions': [
['component=="shared_library"', {
'defines': [
'WEBKIT_DLL',
],
}],
],
}],
]
}
]
}
#
# Copyright (C) 2011 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.
#
{
'variables': {
'platform_files': [
'chromium/public/WebCString.h',
'chromium/public/WebCommon.h',
'chromium/public/WebString.h',
'chromium/public/WebMimeRegistry.h',
'chromium/src/WebCString.cpp',
'chromium/src/WebString.cpp',
]
}
}
/*
* 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.
*/
#ifndef WebCString_h
#define WebCString_h
#include "WebCommon.h"
#if WEBKIT_IMPLEMENTATION
#include <wtf/Forward.h>
#else
#include <string>
#endif
namespace WTF {
class CString;
}
namespace WebKit {
class WebCStringPrivate;
class WebString;
// A single-byte string container with unspecified encoding. It is
// inexpensive to copy a WebCString object.
//
// WARNING: It is not safe to pass a WebCString across threads!!!
//
class WebCString {
public:
~WebCString() { reset(); }
WebCString() : m_private(0) { }
WebCString(const char* data, size_t len) : m_private(0)
{
assign(data, len);
}
WebCString(const WebCString& s) : m_private(0) { assign(s); }
WebCString& operator=(const WebCString& s)
{
assign(s);
return *this;
}
// Returns 0 if both strings are equals, a value greater than zero if the
// first character that does not match has a greater value in this string
// than in |other|, or a value less than zero to indicate the opposite.
WEBKIT_EXPORT int compare(const WebCString& other) const;
WEBKIT_EXPORT void reset();
WEBKIT_EXPORT void assign(const WebCString&);
WEBKIT_EXPORT void assign(const char* data, size_t len);
WEBKIT_EXPORT size_t length() const;
WEBKIT_EXPORT const char* data() const;
bool isEmpty() const { return !length(); }
bool isNull() const { return !m_private; }
WEBKIT_EXPORT WebString utf16() const;
#if WEBKIT_IMPLEMENTATION
WebCString(const WTF::CString&);
WebCString& operator=(const WTF::CString&);
operator WTF::CString() const;
#else
WebCString(const std::string& s) : m_private(0)
{
assign(s.data(), s.length());
}
WebCString& operator=(const std::string& s)
{
assign(s.data(), s.length());
return *this;
}
operator std::string() const
{
size_t len = length();
return len ? std::string(data(), len) : std::string();
}
template <class UTF16String>
static WebCString fromUTF16(const UTF16String& s)
{
return fromUTF16(s.data(), s.length());
}
#endif
private:
void assign(WebCStringPrivate*);
WebCStringPrivate* m_private;
};
inline bool operator<(const WebCString& a, const WebCString& b)
{
return a.compare(b) < 0;
}
} // namespace WebKit
#endif
/*
* Copyright (C) 2010 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.
*/
#ifndef WebCommon_h
#define WebCommon_h
// -----------------------------------------------------------------------------
// Default configuration
#if !defined(WEBKIT_IMPLEMENTATION)
#define WEBKIT_IMPLEMENTATION 0
#endif
#if !defined(WEBKIT_USING_SKIA)
#if !defined(__APPLE__) || defined(USE_SKIA)
#define WEBKIT_USING_SKIA 1
#else
#define WEBKIT_USING_SKIA 0
#endif
#endif
#if !defined(WEBKIT_USING_CG)
#if defined(__APPLE__) && !WEBKIT_USING_SKIA
#define WEBKIT_USING_CG 1
#else
#define WEBKIT_USING_CG 0
#endif
#endif
#if !defined(WEBKIT_USING_V8)
#define WEBKIT_USING_V8 1
#endif
#if !defined(WEBKIT_USING_JSC)
#define WEBKIT_USING_JSC 0
#endif
// -----------------------------------------------------------------------------
// Exported symbols need to be annotated with WEBKIT_EXPORT
#if defined(WEBKIT_DLL)
#if defined(WIN32)
#if WEBKIT_IMPLEMENTATION
#define WEBKIT_EXPORT __declspec(dllexport)
#else
#define WEBKIT_EXPORT __declspec(dllimport)
#endif
#else
#define WEBKIT_EXPORT __attribute__((visibility("default")))
#endif
#else
#define WEBKIT_EXPORT
#endif
// -----------------------------------------------------------------------------
// Basic types
#include <stddef.h> // For size_t
#if defined(WIN32)
// Visual Studio doesn't have stdint.h.
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
#endif
namespace WebKit {
// UTF-16 character type
#if defined(WIN32)
typedef wchar_t WebUChar;
#else
typedef unsigned short WebUChar;
#endif
// -----------------------------------------------------------------------------
// Assertions
WEBKIT_EXPORT void failedAssertion(const char* file, int line, const char* function, const char* assertion);
} // namespace WebKit
// Ideally, only use inside the public directory but outside of WEBKIT_IMPLEMENTATION blocks. (Otherwise use WTF's ASSERT.)
#if defined(NDEBUG)
#define WEBKIT_ASSERT(assertion) ((void)0)
#else
#define WEBKIT_ASSERT(assertion) do { \
if (!(assertion)) \
failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \
} while (0)
#endif
#define WEBKIT_ASSERT_NOT_REACHED() WEBKIT_ASSERT(0)
#endif
/*
* 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.
*/
#ifndef WebMimeRegistry_h
#define WebMimeRegistry_h
#include "WebCommon.h"
namespace WebKit {
class WebString;
class WebMimeRegistry {
public:
enum SupportsType { IsNotSupported, IsSupported, MayBeSupported };
virtual SupportsType supportsMIMEType(const WebKit::WebString& mimeType) = 0;
virtual SupportsType supportsImageMIMEType(const WebKit::WebString& mimeType) = 0;
virtual SupportsType supportsJavaScriptMIMEType(const WebKit::WebString& mimeType) = 0;
virtual SupportsType supportsMediaMIMEType(const WebKit::WebString& mimeType,
const WebKit::WebString& codecs) = 0;
virtual SupportsType supportsNonImageMIMEType(const WebKit::WebString& mimeType) = 0;
virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString& fileExtension) = 0;
virtual WebKit::WebString wellKnownMimeTypeForExtension(const WebKit::WebString& fileExtension) = 0;
virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString& filePath) = 0;
virtual WebKit::WebString preferredExtensionForMIMEType(const WebKit::WebString& mimeType) = 0;
protected:
~WebMimeRegistry() { }
};
} // namespace WebKit
#endif
/*
* 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.
*/
#ifndef WebString_h
#define WebString_h
#include "WebCommon.h"
#if WEBKIT_IMPLEMENTATION
#include <wtf/Forward.h>
#else
#include <base/nullable_string16.h>
#include <base/string16.h>
#endif
namespace WebKit {
class WebCString;
class WebStringPrivate;
// A UTF-16 string container. It is inexpensive to copy a WebString
// object.
//
// WARNING: It is not safe to pass a WebString across threads!!!
//
class WebString {
public:
~WebString() { reset(); }
WebString() : m_private(0) { }
WebString(const WebUChar* data, size_t len) : m_private(0)
{
assign(data, len);
}
WebString(const WebString& s) : m_private(0) { assign(s); }
WebString& operator=(const WebString& s)
{
assign(s);
return *this;
}
WEBKIT_EXPORT void reset();
WEBKIT_EXPORT void assign(const WebString&);
WEBKIT_EXPORT void assign(const WebUChar* data, size_t len);
WEBKIT_EXPORT bool equals(const WebString& s) const;
WEBKIT_EXPORT size_t length() const;
WEBKIT_EXPORT const WebUChar* data() const;
bool isEmpty() const { return !length(); }
bool isNull() const { return !m_private; }
WEBKIT_EXPORT WebCString utf8() const;
WEBKIT_EXPORT static WebString fromUTF8(const char* data, size_t length);
WEBKIT_EXPORT static WebString fromUTF8(const char* data);
template <int N> WebString(const char (&data)[N])
: m_private(0)
{
assign(fromUTF8(data, N - 1));
}
template <int N> WebString& operator=(const char (&data)[N])
{
assign(fromUTF8(data, N - 1));
return *this;
}
#if WEBKIT_IMPLEMENTATION
WebString(const WTF::String&);
WebString& operator=(const WTF::String&);
operator WTF::String() const;
WebString(const WTF::AtomicString&);
WebString& operator=(const WTF::AtomicString&);
operator WTF::AtomicString() const;
#else
WebString(const string16& s) : m_private(0)
{
assign(s.data(), s.length());
}
WebString& operator=(const string16& s)
{