summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-23 04:08:09 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-23 04:08:09 +0000
commit1760972673ada52e7fae2827b16616451b5c6a2f (patch)
treefbbec09c587b16633206109f9d28798b17ff85e7 /webkit/port
parent3cc140ec828b5e7445cf78e07dcdb80e2a2c67d0 (diff)
downloadchromium_src-1760972673ada52e7fae2827b16616451b5c6a2f.zip
chromium_src-1760972673ada52e7fae2827b16616451b5c6a2f.tar.gz
chromium_src-1760972673ada52e7fae2827b16616451b5c6a2f.tar.bz2
Use platform/chromium from third_party/WebKit, etc.
R=dglazkov Review URL: http://codereview.chromium.org/16217 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/platform/GKURL.cpp939
-rw-r--r--webkit/port/platform/GoogleURLPrivate.h112
-rw-r--r--webkit/port/platform/chromium/ChromiumBridge.h177
-rw-r--r--webkit/port/platform/chromium/ChromiumDataObject.cpp53
-rw-r--r--webkit/port/platform/chromium/ChromiumDataObject.h70
-rw-r--r--webkit/port/platform/chromium/ChromiumUtilsWin.cpp54
-rw-r--r--webkit/port/platform/chromium/ChromiumUtilsWin.h38
-rw-r--r--webkit/port/platform/chromium/ClipboardChromium.cpp367
-rw-r--r--webkit/port/platform/chromium/ClipboardChromium.h84
-rw-r--r--webkit/port/platform/chromium/ClipboardUtilitiesChromium.cpp66
-rw-r--r--webkit/port/platform/chromium/ClipboardUtilitiesChromium.h40
-rw-r--r--webkit/port/platform/chromium/ContextMenuChromium.cpp87
-rw-r--r--webkit/port/platform/chromium/ContextMenuItemChromium.cpp106
-rw-r--r--webkit/port/platform/chromium/CursorChromium.cpp313
-rw-r--r--webkit/port/platform/chromium/DragDataChromium.cpp151
-rw-r--r--webkit/port/platform/chromium/DragDataRef.h41
-rw-r--r--webkit/port/platform/chromium/DragImageChromium.cpp91
-rw-r--r--webkit/port/platform/chromium/DragImageRef.h58
-rw-r--r--webkit/port/platform/chromium/EditorChromium.cpp40
-rw-r--r--webkit/port/platform/chromium/FileChooserChromium.cpp60
-rw-r--r--webkit/port/platform/chromium/FileSystemChromium.cpp82
-rw-r--r--webkit/port/platform/chromium/FileSystemChromiumLinux.cpp39
-rw-r--r--webkit/port/platform/chromium/FileSystemChromiumMac.mm42
-rw-r--r--webkit/port/platform/chromium/FileSystemChromiumWin.cpp42
-rw-r--r--webkit/port/platform/chromium/FramelessScrollView.cpp86
-rw-r--r--webkit/port/platform/chromium/FramelessScrollView.h59
-rw-r--r--webkit/port/platform/chromium/FramelessScrollViewClient.h17
-rw-r--r--webkit/port/platform/chromium/KeyCodeConversion.h30
-rw-r--r--webkit/port/platform/chromium/KeyCodeConversionGtk.cpp363
-rw-r--r--webkit/port/platform/chromium/KeyboardCodes.h41
-rw-r--r--webkit/port/platform/chromium/KeyboardCodesPosix.h547
-rw-r--r--webkit/port/platform/chromium/KeyboardCodesWin.h552
-rw-r--r--webkit/port/platform/chromium/Language.cpp46
-rw-r--r--webkit/port/platform/chromium/LinkHashChromium.cpp47
-rw-r--r--webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp147
-rw-r--r--webkit/port/platform/chromium/PasteboardChromium.cpp173
-rw-r--r--webkit/port/platform/chromium/PasteboardPrivate.h47
-rw-r--r--webkit/port/platform/chromium/PlatformCursor.h106
-rw-r--r--webkit/port/platform/chromium/PlatformKeyboardEventChromium.cpp82
-rw-r--r--webkit/port/platform/chromium/PlatformScreenChromium.cpp63
-rw-r--r--webkit/port/platform/chromium/PlatformWidget.h38
-rw-r--r--webkit/port/platform/chromium/PopupMenuChromium.cpp1120
-rw-r--r--webkit/port/platform/chromium/PopupMenuChromium.h102
-rw-r--r--webkit/port/platform/chromium/PopupMenuPrivate.h46
-rw-r--r--webkit/port/platform/chromium/RenderThemeGtk.cpp535
-rw-r--r--webkit/port/platform/chromium/RenderThemeGtk.h142
-rw-r--r--webkit/port/platform/chromium/SSLKeyGeneratorChromium.cpp51
-rw-r--r--webkit/port/platform/chromium/ScrollbarThemeChromium.cpp199
-rw-r--r--webkit/port/platform/chromium/ScrollbarThemeChromium.h79
-rw-r--r--webkit/port/platform/chromium/ScrollbarThemeChromiumLinux.cpp154
-rw-r--r--webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp210
-rw-r--r--webkit/port/platform/chromium/SearchPopupMenuChromium.cpp49
-rw-r--r--webkit/port/platform/chromium/SharedTimerChromium.cpp46
-rw-r--r--webkit/port/platform/chromium/SoundChromiumPosix.cpp41
-rw-r--r--webkit/port/platform/chromium/SoundChromiumWin.cpp35
-rw-r--r--webkit/port/platform/chromium/SystemTimeChromium.cpp47
-rw-r--r--webkit/port/platform/chromium/TemporaryLinkStubs.cpp58
-rw-r--r--webkit/port/platform/chromium/TextBoundariesChromium.cpp76
-rw-r--r--webkit/port/platform/chromium/TextBreakIteratorInternalICUChromium.cpp31
-rw-r--r--webkit/port/platform/chromium/WidgetChromium.cpp81
-rw-r--r--webkit/port/platform/chromium/gtk2drawing.c2815
-rw-r--r--webkit/port/platform/chromium/gtkdrawing.h390
-rw-r--r--webkit/port/platform/graphics/chromium/FontCacheChromiumWin.cpp635
-rw-r--r--webkit/port/platform/graphics/chromium/FontCacheLinux.cpp154
-rw-r--r--webkit/port/platform/graphics/chromium/FontChromiumWin.cpp290
-rw-r--r--webkit/port/platform/graphics/chromium/FontCustomPlatformData.cpp55
-rw-r--r--webkit/port/platform/graphics/chromium/FontCustomPlatformData.h63
-rw-r--r--webkit/port/platform/graphics/chromium/FontLinux.cpp84
-rw-r--r--webkit/port/platform/graphics/chromium/FontPlatformData.h22
-rw-r--r--webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp152
-rw-r--r--webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.h130
-rw-r--r--webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp109
-rw-r--r--webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h90
-rw-r--r--webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.cpp338
-rw-r--r--webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.h98
-rw-r--r--webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp242
-rw-r--r--webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp72
-rw-r--r--webkit/port/platform/graphics/chromium/IconChromiumLinux.cpp58
-rw-r--r--webkit/port/platform/graphics/chromium/IconChromiumMac.cpp59
-rw-r--r--webkit/port/platform/graphics/chromium/IconChromiumWin.cpp78
-rw-r--r--webkit/port/platform/graphics/chromium/ImageBufferData.h56
-rw-r--r--webkit/port/platform/graphics/chromium/ImageChromiumMac.mm33
-rw-r--r--webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h98
-rw-r--r--webkit/port/platform/graphics/chromium/PlatformIcon.h41
-rw-r--r--webkit/port/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp168
-rw-r--r--webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp136
-rw-r--r--webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp102
-rw-r--r--webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h93
-rw-r--r--webkit/port/platform/graphics/chromium/UniscribeHelper.cpp868
-rw-r--r--webkit/port/platform/graphics/chromium/UniscribeHelper.h404
-rw-r--r--webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.cpp135
-rw-r--r--webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.h99
-rw-r--r--webkit/port/platform/graphics/skia/AffineTransformSkia.cpp220
-rw-r--r--webkit/port/platform/graphics/skia/BitmapImageSingleFrameSkia.h62
-rw-r--r--webkit/port/platform/graphics/skia/ColorSkia.cpp43
-rw-r--r--webkit/port/platform/graphics/skia/FloatPointSkia.cpp47
-rw-r--r--webkit/port/platform/graphics/skia/FloatRectSkia.cpp46
-rw-r--r--webkit/port/platform/graphics/skia/GdkSkia.cc516
-rw-r--r--webkit/port/platform/graphics/skia/GdkSkia.h74
-rw-r--r--webkit/port/platform/graphics/skia/GradientSkia.cpp159
-rw-r--r--webkit/port/platform/graphics/skia/GraphicsContextPlatformPrivate.h53
-rw-r--r--webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp1109
-rw-r--r--webkit/port/platform/graphics/skia/ImageBufferSkia.cpp211
-rw-r--r--webkit/port/platform/graphics/skia/ImageSkia.cpp461
-rw-r--r--webkit/port/platform/graphics/skia/ImageSourceSkia.cpp244
-rw-r--r--webkit/port/platform/graphics/skia/ImageSourceSkia.h32
-rw-r--r--webkit/port/platform/graphics/skia/IntPointSkia.cpp50
-rw-r--r--webkit/port/platform/graphics/skia/IntRectSkia.cpp54
-rw-r--r--webkit/port/platform/graphics/skia/NativeImageSkia.cpp107
-rw-r--r--webkit/port/platform/graphics/skia/NativeImageSkia.h78
-rw-r--r--webkit/port/platform/graphics/skia/PathSkia.cpp287
-rw-r--r--webkit/port/platform/graphics/skia/PatternSkia.cpp57
-rw-r--r--webkit/port/platform/graphics/skia/PlatformContextSkia.cpp428
-rw-r--r--webkit/port/platform/graphics/skia/PlatformContextSkia.h174
-rw-r--r--webkit/port/platform/graphics/skia/PlatformGraphics.h13
-rw-r--r--webkit/port/platform/graphics/skia/SkiaFontWin.cpp273
-rw-r--r--webkit/port/platform/graphics/skia/SkiaFontWin.h63
-rw-r--r--webkit/port/platform/graphics/skia/SkiaUtils.cpp229
-rw-r--r--webkit/port/platform/graphics/skia/SkiaUtils.h59
-rw-r--r--webkit/port/platform/network/chromium/AuthenticationChallenge.h54
-rw-r--r--webkit/port/platform/network/chromium/AuthenticationChallengeChromium.cpp36
-rw-r--r--webkit/port/platform/network/chromium/CookieJarChromium.cpp52
-rw-r--r--webkit/port/platform/network/chromium/DNSChromium.cpp38
-rw-r--r--webkit/port/platform/network/chromium/NetworkStateNotifierChromium.cpp45
-rw-r--r--webkit/port/platform/network/chromium/NetworkStateNotifierPrivate.h39
-rw-r--r--webkit/port/platform/network/chromium/ResourceError.h52
-rw-r--r--webkit/port/platform/network/chromium/ResourceRequest.h128
-rw-r--r--webkit/port/platform/network/chromium/ResourceResponse.h81
128 files changed, 0 insertions, 22539 deletions
diff --git a/webkit/port/platform/GKURL.cpp b/webkit/port/platform/GKURL.cpp
deleted file mode 100644
index 1f215cb..0000000
--- a/webkit/port/platform/GKURL.cpp
+++ /dev/null
@@ -1,939 +0,0 @@
-// Copyright (c) 2008, 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 "KURL.h"
-#include "CString.h"
-#include "NotImplemented.h"
-#include "TextEncoding.h"
-#include "Vector.h"
-
-#if USE(GOOGLEURL)
-
-#undef LOG
-#include "googleurl/src/url_canon_internal.h"
-#include "googleurl/src/url_util.h"
-
-using namespace WTF;
-
-namespace WebCore {
-
-namespace {
-
-// Wraps WebKit's text encoding in a character set converter for the
-// canonicalizer.
-class WebCoreCharsetConverter : public url_canon::CharsetConverter {
-public:
- // The encoding parameter may be NULL, but in this case the object must not
- // be called.
- WebCoreCharsetConverter(const TextEncoding* encoding)
- : m_encoding(encoding) {
- }
-
- virtual void ConvertFromUTF16(const url_parse::UTF16Char* input,
- int input_len,
- url_canon::CanonOutput* output) {
- CString encoded = m_encoding->encode(input, input_len, URLEncodedEntitiesForUnencodables);
- output->Append(encoded.data(), static_cast<int>(encoded.length()));
- }
-
-private:
- const TextEncoding* m_encoding;
-};
-
-// Note that this function must be named differently than the one in KURL.cpp
-// since our unit tests evilly include both files, and their local definition
-// will be ambiguous.
-inline void assertProtocolIsGood(const char* protocol)
-{
-#ifndef NDEBUG
- const char* p = protocol;
- while (*p) {
- ASSERT(*p > ' ' && *p < 0x7F && !(*p >= 'A' && *p <= 'Z'));
- ++p;
- }
-#endif
-}
-
-// Returns the characters for the given string, or a pointer to a static empty
-// string if the input string is NULL. This will always ensure we have a non-
-// NULL character pointer since ReplaceComponents has special meaning for NULL.
-inline const url_parse::UTF16Char* CharactersOrEmpty(const String& str) {
- static const url_parse::UTF16Char zero = 0;
- return str.characters() ?
- reinterpret_cast<const url_parse::UTF16Char*>(str.characters()) :
- &zero;
-}
-
-inline bool isUnicodeEncoding(const TextEncoding* encoding)
-{
- return encoding->encodingForFormSubmission() == UTF8Encoding();
-}
-
-bool lowerCaseEqualsASCII(const char* begin, const char* end, const char* str)
-{
- while (begin != end && *str) {
- if (toASCIILower(*begin++) != *str++)
- return false;
- }
- return true;
-}
-
-} // namespace
-
-// GoogleURLPrivate ------------------------------------------------------------
-
-GoogleURLPrivate::GoogleURLPrivate()
- : m_isValid(false)
- , m_utf8IsASCII(true)
- , m_stringIsValid(false)
-{
-}
-
-GoogleURLPrivate::GoogleURLPrivate(const url_parse::Parsed& parsed, bool isValid)
- : m_isValid(isValid)
- , m_parsed(parsed)
- , m_utf8IsASCII(true)
- , m_stringIsValid(false)
-{
-}
-
-// Setters for the data. Using the ASCII version when you know the
-// data is ASCII will be slightly more efficient. The UTF-8 version
-// will always be correct if the caller is unsure.
-void GoogleURLPrivate::setUtf8(const char* data, int data_len)
-{
- // The m_utf8IsASCII must always be correct since the DeprecatedString
- // getter must create it with the proper constructor. This test can be
- // removed when DeprecatedString is gone, but it still might be a
- // performance win.
- m_utf8IsASCII = true;
- for (int i = 0; i < data_len; i++) {
- if (static_cast<unsigned char>(data[i]) >= 0x80) {
- m_utf8IsASCII = false;
- break;
- }
- }
-
- m_utf8 = CString(data, data_len);
- m_stringIsValid = false;
-}
-
-void GoogleURLPrivate::setAscii(const char* data, int data_len)
-{
- m_utf8 = CString(data, data_len);
- m_utf8IsASCII = true;
- m_stringIsValid = false;
-}
-
-void GoogleURLPrivate::init(const KURL& base,
- const String& relative,
- const TextEncoding* queryEncoding)
-{
- init(base, relative.characters(), relative.length(), queryEncoding);
-}
-
-// Note: code mostly duplicated below.
-void GoogleURLPrivate::init(const KURL& base, const char* rel, int rel_len,
- const TextEncoding* query_encoding)
-{
- // As a performance optimization, we do not use the charset converter if
- // encoding is UTF-8 or other Unicode encodings. Note that this is
- // per HTML5 2.5.3 (resolving URL). The URL canonicalizer will be
- // more efficient with no charset converter object because it
- // can do UTF-8 internally with no extra copies.
-
- // We feel free to make the charset converter object every time since it's
- // just a wrapper around a reference.
- WebCoreCharsetConverter charset_converter_object(query_encoding);
- WebCoreCharsetConverter* charset_converter =
- (!query_encoding || isUnicodeEncoding(query_encoding)) ? 0 :
- &charset_converter_object;
-
- url_canon::RawCanonOutputT<char> output;
- const CString& baseStr = base.m_url.utf8String();
- m_isValid = url_util::ResolveRelative(baseStr.data(), baseStr.length(),
- base.m_url.m_parsed, rel, rel_len,
- charset_converter,
- &output, &m_parsed);
-
- // See TODO in GoogleURLPrivate in the header. If canonicalization has not
- // changed the string, we can avoid an extra allocation by using assignment.
- //
- // When KURL encounters an error such that the URL is invalid and empty
- // (for example, resolving a relative URL on a non-hierarchical base), it
- // will produce an isNull URL, and calling setUtf8 will produce an empty
- // non-null URL. This is unlikely to affect anything, but we preserve this
- // just in case.
- if (m_isValid || output.length()) {
- // Without ref, the whole url is guaranteed to be ASCII-only.
- if (m_parsed.ref.is_nonempty())
- setUtf8(output.data(), output.length());
- else
- setAscii(output.data(), output.length());
- } else {
- // WebKit expects resolved URLs to be empty rather than NULL.
- setUtf8("", 0);
- }
-}
-
-// Note: code mostly duplicated above. See TODOs and comments there.
-void GoogleURLPrivate::init(const KURL& base, const UChar* rel, int rel_len,
- const TextEncoding* query_encoding)
-{
- WebCoreCharsetConverter charset_converter_object(query_encoding);
- WebCoreCharsetConverter* charset_converter =
- (!query_encoding || isUnicodeEncoding(query_encoding)) ? 0 :
- &charset_converter_object;
-
- url_canon::RawCanonOutputT<char> output;
- const CString& baseStr = base.m_url.utf8String();
- m_isValid = url_util::ResolveRelative(baseStr.data(), baseStr.length(),
- base.m_url.m_parsed, rel, rel_len,
- charset_converter,
- &output, &m_parsed);
-
- if (m_isValid || output.length()) {
- if (m_parsed.ref.is_nonempty())
- setUtf8(output.data(), output.length());
- else
- setAscii(output.data(), output.length());
- } else {
- setUtf8("", 0);
- }
-}
-
-void GoogleURLPrivate::copyTo(GoogleURLPrivate* dest) const
-{
- dest->m_isValid = m_isValid;
- dest->m_parsed = m_parsed;
-
- // Don't copy the 16-bit string since that will be regenerated as needed.
- dest->m_utf8 = CString(m_utf8.data(), m_utf8.length());
- dest->m_utf8IsASCII = m_utf8IsASCII;
- dest->m_stringIsValid = false;
-}
-
-String GoogleURLPrivate::componentString(const url_parse::Component& comp) const
-{
- if (!m_isValid || comp.len <= 0) {
- // KURL returns a NULL string if the URL is itself a NULL string, and an
- // empty string for other nonexistant entities.
- if (utf8String().isNull())
- return String();
- return String("", 0);
- }
- // begin and len are in terms of bytes which do not match
- // if string() is UTF-16 and input contains non-ASCII characters.
- // However, the only part in urlString that can contain non-ASCII
- // characters is 'ref' at the end of the string. In that case,
- // begin will always match the actual value and len (in terms of
- // byte) will be longer than what's needed by 'mid'. However, mid
- // truncates len to avoid go past the end of a string so that we can
- // get away withtout doing anything here.
- return string().substring(comp.begin, comp.len);
-}
-
-void GoogleURLPrivate::replaceComponents(const Replacements& replacements)
-{
- url_canon::RawCanonOutputT<char> output;
- url_parse::Parsed new_parsed;
-
- m_isValid = url_util::ReplaceComponents(utf8String().data(),
- utf8String().length(), m_parsed, replacements, NULL, &output, &new_parsed);
-
- m_parsed = new_parsed;
- if (m_parsed.ref.is_nonempty())
- setUtf8(output.data(), output.length());
- else
- setAscii(output.data(), output.length());
-}
-
-const String& GoogleURLPrivate::string() const
-{
- if (!m_stringIsValid) {
- // Must special case the NULL case, since constructing the
- // string like we do below will generate an empty rather than
- // a NULL string.
- if (m_utf8.isNull())
- m_string = String();
- else if (m_utf8IsASCII)
- m_string = String(m_utf8.data(), m_utf8.length());
- else
- m_string = String::fromUTF8(m_utf8.data(), m_utf8.length());
- m_stringIsValid = true;
- }
- return m_string;
-}
-
-// KURL ------------------------------------------------------------------------
-
-// Creates with NULL-terminated string input representing an absolute URL.
-// WebCore generally calls this only with hardcoded strings, so the input is
-// ASCII. We treat is as UTF-8 just in case.
-KURL::KURL(const char *url)
-{
- // FIXME(brettw) the Mac code checks for beginning with a slash and
- // converting to a file: URL. We will want to add this as well once we
- // can compile on a system like that.
- m_url.init(KURL(), url, strlen(url), NULL);
-
- // The one-argument constructors should never generate a NULL string.
- // This is a funny quirk of KURL (probably a bug) which we preserve.
- if (m_url.utf8String().isNull())
- m_url.setAscii("", 0);
-}
-
-// Initializes with a string representing an absolute URL. No encoding
-// information is specified. This generally happens when a KURL is converted
-// to a string and then converted back. In this case, the URL is already
-// canonical and in proper escaped form so needs no encoding. We treat it was
-// UTF-8 just in case.
-KURL::KURL(const String& url)
-{
- if (!url.isNull()) {
- m_url.init(KURL(), url, NULL);
- } else {
- // WebKit expects us to preserve the nullness of strings when this
- // constructor is used. In all other cases, it expects a non-null
- // empty string, which is what init() will create.
- m_url.m_isValid = false;
- }
-}
-
-// Constructs a new URL given a base URL and a possibly relative input URL.
-// This assumes UTF-8 encoding.
-KURL::KURL(const KURL& base, const String& relative)
-{
- m_url.init(base, relative, NULL);
-}
-
-// Constructs a new URL given a base URL and a possibly relative input URL.
-// Any query portion of the relative URL will be encoded in the given encoding.
-KURL::KURL(const KURL& base,
- const String& relative,
- const TextEncoding& encoding)
-{
- m_url.init(base, relative, &encoding.encodingForFormSubmission());
-}
-
-KURL::KURL(const char* canonicalSpec, int canonicalSpecLen,
- const url_parse::Parsed& parsed, bool isValid)
- : m_url(parsed, isValid)
-{
- // We know the reference fragment is the only part that can be UTF-8, so
- // we know it's ASCII when there is no ref.
- if (parsed.ref.is_nonempty())
- m_url.setUtf8(canonicalSpec, canonicalSpecLen);
- else
- m_url.setAscii(canonicalSpec, canonicalSpecLen);
-}
-
-#if PLATFORM(CF)
-KURL::KURL(CFURLRef)
-{
- notImplemented();
- invalidate();
-}
-
-CFURLRef KURL::createCFURL() const {
- notImplemented();
- return NULL;
-}
-#endif
-
-KURL KURL::copy() const
-{
- KURL result = *this;
- m_url.copyTo(&result.m_url);
- return result;
-}
-
-bool KURL::isNull() const
-{
- return m_url.utf8String().isNull();
-}
-
-bool KURL::isEmpty() const
-{
- return m_url.utf8String().length() == 0;
-}
-
-bool KURL::isValid() const
-{
- return m_url.m_isValid;
-}
-
-bool KURL::hasPath() const
-{
- // Note that http://www.google.com/" has a path, the path is "/". This can
- // return false only for invalid or nonstandard URLs.
- return m_url.m_parsed.path.len >= 0;
-}
-
-// We handle "parameters" separated be a semicolon, while the old KURL does
-// not, which can lead to different results in some cases.
-String KURL::lastPathComponent() const
-{
- // When the output ends in a slash, WebKit has different expectations than
- // our library. For "/foo/bar/" the library will return the empty string,
- // but WebKit wants "bar".
- url_parse::Component path = m_url.m_parsed.path;
- if (path.len > 0 && m_url.utf8String().data()[path.end() - 1] == '/')
- path.len--;
-
- url_parse::Component file;
- url_parse::ExtractFileName(m_url.utf8String().data(), path, &file);
-
- // Bug: https://bugs.webkit.org/show_bug.cgi?id=21015 this function returns
- // a null string when the path is empty, which we duplicate here.
- if (!file.is_nonempty())
- return String();
- return m_url.componentString(file);
-}
-
-String KURL::protocol() const
-{
- return m_url.componentString(m_url.m_parsed.scheme);
-}
-
-String KURL::host() const
-{
- // Note: WebKit decode_string()s here.
- return m_url.componentString(m_url.m_parsed.host);
-}
-
-// Returns 0 when there is no port or it is invalid.
-//
-// We define invalid port numbers to be invalid URLs, and they will be
-// rejected by the canonicalizer. WebKit's old one will allow them in
-// parsing, and return 0 from this port() function.
-unsigned short int KURL::port() const
-{
- if (!m_url.m_isValid || m_url.m_parsed.port.len <= 0)
- return 0;
- int port = url_parse::ParsePort(m_url.utf8String().data(), m_url.m_parsed.port);
- if (port == url_parse::PORT_UNSPECIFIED)
- return 0;
- return static_cast<unsigned short>(port);
-}
-
-// Returns the empty string if there is no password.
-String KURL::pass() const
-{
- // Bug: https://bugs.webkit.org/show_bug.cgi?id=21015 this function returns
- // a null string when the password is empty, which we duplicate here.
- if (!m_url.m_parsed.password.is_nonempty())
- return String();
-
- // Note: WebKit decode_string()s here.
- return m_url.componentString(m_url.m_parsed.password);
-}
-
-// Returns the empty string if there is no username.
-String KURL::user() const
-{
- // Note: WebKit decode_string()s here.
- return m_url.componentString(m_url.m_parsed.username);
-}
-
-String KURL::ref() const
-{
- // Empty but present refs ("foo.com/bar#") should result in the empty
- // string, which m_url.componentString will produce. Nonexistant refs should be
- // the NULL string.
- if (!m_url.m_parsed.ref.is_valid())
- return String();
-
- // Note: WebKit decode_string()s here.
- return m_url.componentString(m_url.m_parsed.ref);
-}
-
-bool KURL::hasRef() const
-{
- // Note: WebKit decode_string()s here.
- // FIXME(brettw) determine if they agree about an empty ref
- return m_url.m_parsed.ref.len >= 0;
-}
-
-String KURL::query() const
-{
- if (m_url.m_parsed.query.len >= 0) {
- // KURL's query() includes the question mark, even though the reference
- // doesn't. Move the query component backwards one to account for it
- // (our library doesn't count the question mark).
- url_parse::Component query_comp = m_url.m_parsed.query;
- query_comp.begin--;
- query_comp.len++;
- return m_url.componentString(query_comp);
- }
-
- // Bug: https://bugs.webkit.org/show_bug.cgi?id=21015 this function returns
- // an empty string when the query is empty rather than a null (not sure
- // which is right).
- return String("", 0);
-}
-
-String KURL::path() const
-{
- // Note: WebKit decode_string()s here.
- return m_url.componentString(m_url.m_parsed.path);
-}
-
-void KURL::setProtocol(const String& protocol)
-{
- GoogleURLPrivate::Replacements replacements;
- replacements.SetScheme(CharactersOrEmpty(protocol),
- url_parse::Component(0, protocol.length()));
- m_url.replaceComponents(replacements);
-}
-
-void KURL::setHost(const String& host)
-{
- GoogleURLPrivate::Replacements replacements;
- replacements.SetHost(CharactersOrEmpty(host),
- url_parse::Component(0, host.length()));
- m_url.replaceComponents(replacements);
-}
-
-// This function is used only in the JSC build.
-void KURL::setHostAndPort(const String& s) {
- String newhost = s.left(s.find(":"));
- String newport = s.substring(s.find(":") + 1);
-
- GoogleURLPrivate::Replacements replacements;
- // Host can't be removed, so we always set.
- replacements.SetHost(CharactersOrEmpty(newhost),
- url_parse::Component(0, newhost.length()));
-
- if (newport.isEmpty()) { // Port may be removed, so we support clearing.
- replacements.ClearPort();
- } else {
- replacements.SetPort(CharactersOrEmpty(newport),
- url_parse::Component(0, newport.length()));
- }
- m_url.replaceComponents(replacements);
-}
-
-void KURL::setPort(unsigned short i)
-{
- GoogleURLPrivate::Replacements replacements;
- String portStr;
- if (i > 0) {
- portStr = String::number(static_cast<int>(i));
- replacements.SetPort(
- reinterpret_cast<const url_parse::UTF16Char*>(portStr.characters()),
- url_parse::Component(0, portStr.length()));
-
- } else {
- // Clear any existing port when it is set to 0.
- replacements.ClearPort();
- }
- m_url.replaceComponents(replacements);
-}
-
-void KURL::setUser(const String& user)
-{
- // This function is commonly called to clear the username, which we
- // normally don't have, so we optimize this case.
- if (user.isEmpty() && !m_url.m_parsed.username.is_valid())
- return;
-
- // The canonicalizer will clear any usernames that are empty, so we
- // don't have to explicitly call ClearUsername() here.
- GoogleURLPrivate::Replacements replacements;
- replacements.SetUsername(CharactersOrEmpty(user),
- url_parse::Component(0, user.length()));
- m_url.replaceComponents(replacements);
-}
-
-void KURL::setPass(const String& pass)
-{
- // This function is commonly called to clear the password, which we
- // normally don't have, so we optimize this case.
- if (pass.isEmpty() && !m_url.m_parsed.password.is_valid())
- return;
-
- // The canonicalizer will clear any passwords that are empty, so we
- // don't have to explicitly call ClearUsername() here.
- GoogleURLPrivate::Replacements replacements;
- replacements.SetPassword(CharactersOrEmpty(pass),
- url_parse::Component(0, pass.length()));
- m_url.replaceComponents(replacements);
-}
-
-void KURL::setRef(const String& ref)
-{
- // This function is commonly called to clear the ref, which we
- // normally don't have, so we optimize this case.
- if (ref.isNull() && !m_url.m_parsed.ref.is_valid())
- return;
-
- GoogleURLPrivate::Replacements replacements;
- if (ref.isNull()) {
- replacements.ClearRef();
- } else {
- replacements.SetRef(CharactersOrEmpty(ref),
- url_parse::Component(0, ref.length()));
- }
- m_url.replaceComponents(replacements);
-}
-
-void KURL::removeRef()
-{
- GoogleURLPrivate::Replacements replacements;
- replacements.ClearRef();
- m_url.replaceComponents(replacements);
-}
-
-void KURL::setQuery(const String& query)
-{
- GoogleURLPrivate::Replacements replacements;
- if (query.isNull()) {
- // WebKit sets to NULL to clear any query.
- replacements.ClearQuery();
- } else if (query.length() > 0 && query[0] == '?') {
- // WebKit expects the query string to begin with a question mark, but
- // our library doesn't. So we trim off the question mark when setting.
- replacements.SetQuery(CharactersOrEmpty(query),
- url_parse::Component(1, query.length() - 1));
- } else {
- // When set with the empty string or something that doesn't begin with
- // a question mark, WebKit will add a question mark for you. The only
- // way this isn't compatible is if you call this function with an empty
- // string. Old KURL will leave a '?' with nothing following it in the
- // URL, whereas we'll clear it.
- replacements.SetQuery(CharactersOrEmpty(query),
- url_parse::Component(0, query.length()));
- }
- m_url.replaceComponents(replacements);
-}
-
-void KURL::setPath(const String& path)
-{
- // Empty paths will be canonicalized to "/", so we don't have to worry
- // about calling ClearPath().
- GoogleURLPrivate::Replacements replacements;
- replacements.SetPath(CharactersOrEmpty(path),
- url_parse::Component(0, path.length()));
- m_url.replaceComponents(replacements);
-}
-
-// On Mac, this just seems to return the same URL, but with "/foo/bar" for
-// file: URLs instead of file:///foo/bar. We don't bother with any of this,
-// at least for now.
-String KURL::prettyURL() const
-{
- if (!m_url.m_isValid)
- return String();
- return m_url.string();
-}
-
-// Copy the KURL version here on Sept 12, 2008 while doing the webkit merge.
-//
-// TODO(erg): Somehow share this with KURL? Like we'd theoretically merge
-// with decodeURLEscapeSequences below?
-#ifdef KURL_DECORATE_GLOBALS
-String KURL::mimeTypeFromDataURL(const String& url)
-#else
-String mimeTypeFromDataURL(const String& url)
-#endif
-{
- ASSERT(protocolIs(url, "data"));
- int index = url.find(';');
- if (index == -1)
- index = url.find(',');
- if (index != -1) {
- int len = index - 5;
- if (len > 0)
- return url.substring(5, len);
- return "text/plain"; // Data URLs with no MIME type are considered text/plain.
- }
- return "";
-}
-
-#ifdef KURL_DECORATE_GLOBALS
-String KURL::decodeURLEscapeSequences(const String& str)
-#else
-String decodeURLEscapeSequences(const String& str)
-#endif
-{
- return decodeURLEscapeSequences(str, UTF8Encoding());
-}
-
-// In WebKit's implementation, this is called by every component getter.
-// It will unescape every character, including NULL. This is scary, and may
-// cause security holes. We never call this function for components, and
-// just return the ASCII versions instead.
-//
-// However, this static function is called directly in some cases. It appears
-// that this only happens for javascript: URLs, so this is essentially the
-// JavaScript URL decoder. It assumes UTF-8 encoding.
-//
-// IE doesn't unescape %00, forcing you to use \x00 in JS strings, so we do
-// the same. This also eliminates NULL-related problems should a consumer
-// incorrectly call this function for non-JavaScript.
-//
-// TODO(brettw) these should be merged to the regular KURL implementation.
-#ifdef KURL_DECORATE_GLOBALS
-String KURL::decodeURLEscapeSequences(const String& str, const TextEncoding& encoding)
-#else
-String decodeURLEscapeSequences(const String& str, const TextEncoding& encoding)
-#endif
-{
- // TODO(brettw) We can probably use KURL's version of this function
- // without modification. However, I'm concerned about
- // https://bugs.webkit.org/show_bug.cgi?id=20559 so am keeping this old
- // custom code for now. Using their version will also fix the bug that
- // we ignore the encoding.
- //
- // TODO(brettw) bug 1350291: This does not get called very often. We just
- // convert first to 8-bit UTF-8, then unescape, then back to 16-bit. This
- // kind of sucks, and we don't use the encoding properly, which will make
- // some obscure anchor navigations fail.
- CString cstr = str.utf8();
-
- const char* input = cstr.data();
- int input_length = cstr.length();
- url_canon::RawCanonOutputT<char> unescaped;
- for (int i = 0; i < input_length; i++) {
- if (input[i] == '%') {
- unsigned char ch;
- if (url_canon::DecodeEscaped(input, &i, input_length, &ch)) {
- if (ch == 0) {
- // Never unescape NULLs.
- unescaped.push_back('%');
- unescaped.push_back('0');
- unescaped.push_back('0');
- } else {
- unescaped.push_back(ch);
- }
- } else {
- // Invalid escape sequence, copy the percent literal.
- unescaped.push_back('%');
- }
- } else {
- // Regular non-escaped 8-bit character.
- unescaped.push_back(input[i]);
- }
- }
-
- // Convert that 8-bit to UTF-16. It's not clear IE does this at all to
- // JavaScript URLs, but Firefox and Safari do.
- url_canon::RawCanonOutputT<url_parse::UTF16Char> utf16;
- for (int i = 0; i < unescaped.length(); i++) {
- unsigned char uch = static_cast<unsigned char>(unescaped.at(i));
- if (uch < 0x80) {
- // Non-UTF-8, just append directly
- utf16.push_back(uch);
- } else {
- // next_ch will point to the last character of the decoded
- // character.
- int next_ch = i;
- unsigned code_point;
- if (url_canon::ReadUTFChar(unescaped.data(), &next_ch,
- unescaped.length(), &code_point)) {
- // Valid UTF-8 character, convert to UTF-16.
- url_canon::AppendUTF16Value(code_point, &utf16);
- i = next_ch;
- } else {
- // WebKit strips any sequences that are not valid UTF-8. This
- // sounds scary. Instead, we just keep those invalid code
- // points and promote to UTF-16. We copy all characters from
- // the current position to the end of the identified sqeuqnce.
- while (i < next_ch) {
- utf16.push_back(static_cast<unsigned char>(unescaped.at(i)));
- i++;
- }
- utf16.push_back(static_cast<unsigned char>(unescaped.at(i)));
- }
- }
- }
-
- return String(reinterpret_cast<UChar*>(utf16.data()),
- utf16.length());
-}
-
-bool KURL::protocolIs(const char* protocol) const
-{
- assertProtocolIsGood(protocol);
- if (m_url.m_parsed.scheme.len <= 0)
- return protocol == NULL;
- return lowerCaseEqualsASCII(
- m_url.utf8String().data() + m_url.m_parsed.scheme.begin,
- m_url.utf8String().data() + m_url.m_parsed.scheme.end(),
- protocol);
-}
-
-bool KURL::isLocalFile() const
-{
- return protocolIs("file");
-}
-
-// This is called to escape a URL string. It is only used externally when
-// constructing mailto: links to set the query section. Since our query setter
-// will automatically do the correct escaping, this function does not have to
-// do any work.
-//
-// There is a possibility that a future called may use this function in other
-// ways, and may expect to get a valid URL string. The dangerous thing we want
-// to protect against here is accidentally getting NULLs in a string that is
-// not supposed to have NULLs. Therefore, we escape NULLs here to prevent this.
-#ifdef KURL_DECORATE_GLOBALS
-String KURL::encodeWithURLEscapeSequences(const String& notEncodedString)
-#else
-String encodeWithURLEscapeSequences(const String& notEncodedString)
-#endif
-{
- CString utf8 = UTF8Encoding().encode(
- reinterpret_cast<const UChar*>(notEncodedString.characters()),
- notEncodedString.length(),
- URLEncodedEntitiesForUnencodables);
- const char* input = utf8.data();
- int input_len = utf8.length();
-
- Vector<char, 2048> buffer;
- for (int i = 0; i < input_len; i++) {
- if (input[i] == 0)
- buffer.append("%00", 3);
- else
- buffer.append(input[i]);
- }
- return String(buffer.data(), buffer.size());
-}
-
-bool KURL::isHierarchical() const
-{
- if (!m_url.m_parsed.scheme.is_nonempty())
- return false;
- return url_util::IsStandard(
- &m_url.utf8String().data()[m_url.m_parsed.scheme.begin],
- m_url.utf8String().length(),
- m_url.m_parsed.scheme);
-}
-
-#ifndef NDEBUG
-void KURL::print() const
-{
- printf("%s\n", m_url.utf8String().data());
-}
-#endif
-
-void KURL::invalidate()
-{
- // This is only called from the constructor so resetting the (automatically
- // initialized) string and parsed structure would be a waste of time.
- m_url.m_isValid = false;
-}
-
-// Equal up to reference fragments, if any.
-bool equalIgnoringRef(const KURL& a, const KURL& b)
-{
- // Compute the length of each URL without its ref. Note that the reference
- // begin (if it exists) points to the character *after* the '#', so we need
- // to subtract one.
- int a_len = a.m_url.utf8String().length();
- if (a.m_url.m_parsed.ref.len >= 0)
- a_len = a.m_url.m_parsed.ref.begin - 1;
-
- int b_len = b.m_url.utf8String().length();
- if (b.m_url.m_parsed.ref.len >= 0)
- b_len = b.m_url.m_parsed.ref.begin - 1;
-
- return a_len == b_len &&
- strncmp(a.m_url.utf8String().data(), b.m_url.utf8String().data(), a_len) == 0;
-}
-
-unsigned KURL::hostStart() const
-{
- return m_url.m_parsed.CountCharactersBefore(url_parse::Parsed::HOST, false);
-}
-
-unsigned KURL::hostEnd() const
-{
- return m_url.m_parsed.CountCharactersBefore(url_parse::Parsed::PORT, true);
-}
-
-unsigned KURL::pathStart() const
-{
- return m_url.m_parsed.CountCharactersBefore(url_parse::Parsed::PATH, false);
-}
-
-unsigned KURL::pathEnd() const
-{
- return m_url.m_parsed.CountCharactersBefore(url_parse::Parsed::QUERY, true);
-}
-
-unsigned KURL::pathAfterLastSlash() const
-{
- // When there's no path, ask for what would be the beginning of it.
- if (!m_url.m_parsed.path.is_valid())
- return m_url.m_parsed.CountCharactersBefore(url_parse::Parsed::PATH, false);
-
- url_parse::Component filename;
- url_parse::ExtractFileName(m_url.utf8String().data(), m_url.m_parsed.path,
- &filename);
- return filename.begin;
-}
-
-#ifdef KURL_DECORATE_GLOBALS
-const KURL& KURL::blankURL()
-#else
-const KURL& blankURL()
-#endif
-{
- static KURL staticBlankURL("about:blank");
- return staticBlankURL;
-}
-
-#ifdef KURL_DECORATE_GLOBALS
-bool KURL::protocolIs(const String& url, const char* protocol)
-#else
-bool protocolIs(const String& url, const char* protocol)
-#endif
-{
- // Do the comparison without making a new string object.
- assertProtocolIsGood(protocol);
- for (int i = 0; ; ++i) {
- if (!protocol[i])
- return url[i] == ':';
- if (toASCIILower(url[i]) != protocol[i])
- return false;
- }
-}
-
-#ifndef KURL_DECORATE_GLOBALS
-inline bool KURL::protocolIs(const String& string, const char* protocol)
-{
- return WebCore::protocolIs(string, protocol);
-}
-#endif
-
-} // namespace WebCore
-
-#endif // USE(GOOGLEURL)
diff --git a/webkit/port/platform/GoogleURLPrivate.h b/webkit/port/platform/GoogleURLPrivate.h
deleted file mode 100644
index eb8e0601..0000000
--- a/webkit/port/platform/GoogleURLPrivate.h
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) 2008, 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 KURLGoogleURL_h
-#define KURLGoogleURL_h
-
-#include "CString.h"
-
-#include "googleurl/src/url_parse.h"
-#include "googleurl/src/url_canon.h"
-
-namespace WebCore {
-
-class KURL;
-class TextEncoding;
-
-// Wraps the internals related to using Google-URL as the bnackend for KURL.
-// This maintains the state and has auxiliary functions so that we don't need
-// to uglify KURL.h while allowing Google-URL to be evaluated.
-class GoogleURLPrivate {
-public:
- GoogleURLPrivate();
- GoogleURLPrivate(const url_parse::Parsed& parsed, bool isValid);
-
- // Initializes the object. This will call through to one of the backend
- // initializers below depending on whether the string's internal
- // representation is 8 or 16 bit.
- void init(const KURL& base, const String& relative,
- const TextEncoding* queryEncoding);
-
- // Backend initializers. The query encoding parameters are optional and can
- // be NULL (this implies UTF-8). These initializers require that the object
- // has just been created and the strings are NULL. Do not call on an
- // already-constructed object.
- void init(const KURL& base, const char* rel, int relLen,
- const TextEncoding* queryEncoding);
- void init(const KURL& base, const UChar* rel, int relLen,
- const TextEncoding* queryEncoding);
-
- // Does a deep copy to the given output object.
- void copyTo(GoogleURLPrivate* dest) const;
-
- // Returns the substring of the input identified by the given component.
- String componentString(const url_parse::Component& comp) const;
-
- // Replaces the given components, modifying the current URL. The current
- // URL must be valid.
- typedef url_canon::Replacements<url_parse::UTF16Char> Replacements;
- void replaceComponents(const Replacements& replacements);
-
- // Setters for the data. Using the ASCII version when you know the
- // data is ASCII will be slightly more efficient. The UTF-8 version
- // will always be correct if the caller is unsure.
- void setUtf8(const char* data, int dataLen);
- void setAscii(const char* data, int dataLen);
-
- // TODO(brettw) we can support an additional optimization. Make this
- // buffer support both optinal Strings and UTF-8 data. This way, we can use
- // the optimization from the original KURL which uses = with the original
- // string when canonicalization did not change it. This allows the strings
- // to share a buffer internally, and saves a malloc.
-
- // Getters for the data.
- const CString& utf8String() const { return m_utf8; }
- const String& string() const;
-
- bool m_isValid;
- url_parse::Parsed m_parsed; // Indexes into the UTF-8 version of the string.
-
-private:
- CString m_utf8;
-
- // Set to true when the caller set us using the ASCII setter. We can
- // be more efficient when we know there is no UTF-8 to worry about.
- // This flag is currently always correct, but should be changed to be a
- // hint (see setUtf8).
- bool m_utf8IsASCII;
-
- mutable bool m_stringIsValid;
- mutable String m_string;
-};
-
-} // namespace WebCore
-
-#endif // KURLGoogleURL_h
-
diff --git a/webkit/port/platform/chromium/ChromiumBridge.h b/webkit/port/platform/chromium/ChromiumBridge.h
deleted file mode 100644
index 15de72f..0000000
--- a/webkit/port/platform/chromium/ChromiumBridge.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright (c) 2008, 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 ChromiumBridge_h
-#define ChromiumBridge_h
-
-#include "config.h"
-
-#include "LinkHash.h"
-#include "PasteboardPrivate.h"
-#include "PassRefPtr.h"
-#include "PlatformString.h"
-
-class NativeImageSkia;
-
-typedef struct NPObject NPObject;
-typedef struct _NPP NPP_t;
-typedef NPP_t* NPP;
-
-#if PLATFORM(WIN_OS)
-typedef struct HFONT__* HFONT;
-#endif
-
-namespace WebCore {
- class Color;
- class Cursor;
- class Document;
- class Frame;
- class GraphicsContext;
- class Image;
- class IntRect;
- class KURL;
- class String;
- class Widget;
-
- struct PluginInfo;
-
- // An interface to the embedding layer, which has the ability to answer
- // questions about the system and so on...
-
- class ChromiumBridge {
- public:
- // Clipboard ----------------------------------------------------------
- static bool clipboardIsFormatAvailable(PasteboardPrivate::ClipboardFormat);
-
- static String clipboardReadPlainText();
- static void clipboardReadHTML(String*, KURL*);
-
- static void clipboardWriteSelection(const String&, const KURL&, const String&, bool);
- static void clipboardWriteURL(const KURL&, const String&);
- static void clipboardWriteImage(const NativeImageSkia* bitmap, const KURL&, const String&);
-
- // Cookies ------------------------------------------------------------
- static void setCookies(const KURL& url, const KURL& policyURL, const String& value);
- static String cookies(const KURL& url, const KURL& policyURL);
-
- // DNS ----------------------------------------------------------------
- static void prefetchDNS(const String& hostname);
-
- // Font ---------------------------------------------------------------
-#if PLATFORM(WIN_OS)
- static bool ensureFontLoaded(HFONT font);
-#endif
-
- // Forms --------------------------------------------------------------
- static void notifyFormStateChanged(const Document* doc);
-
- // JavaScript ---------------------------------------------------------
- static void notifyJSOutOfMemory(Frame* frame);
-
- // Language -----------------------------------------------------------
- static String computedDefaultLanguage();
-
- // LayoutTestMode -----------------------------------------------------
- static bool layoutTestMode();
-
- // MimeType -----------------------------------------------------------
- static bool isSupportedImageMIMEType(const char* mime_type);
- static bool isSupportedJavascriptMIMEType(const char* mime_type);
- static bool isSupportedNonImageMIMEType(const char* mime_type);
- static bool matchesMIMEType(const String& pattern, const String& type);
- static String mimeTypeForExtension(const String& ext);
- static String mimeTypeFromFile(const String& file_path);
- static String preferredExtensionForMIMEType(const String& mime_type);
-
- // Plugin -------------------------------------------------------------
- static bool plugins(bool refresh, Vector<PluginInfo*>* plugins);
- static NPObject* pluginScriptableObject(Widget* widget);
- static bool popupsAllowed(NPP npp);
-
- // Protocol -----------------------------------------------------------
- static String uiResourceProtocol();
-
- // Resources ----------------------------------------------------------
- static PassRefPtr<Image> loadPlatformImageResource(const char* name);
-
- // Screen -------------------------------------------------------------
- static int screenDepth(Widget*);
- static int screenDepthPerComponent(Widget*);
- static bool screenIsMonochrome(Widget*);
- static IntRect screenRect(Widget*);
- static IntRect screenAvailableRect(Widget*);
-
- // SharedTimers -------------------------------------------------------
- static void setSharedTimerFiredFunction(void (*func)());
- static void setSharedTimerFireTime(double fire_time);
- static void stopSharedTimer();
-
- // StatsCounters ------------------------------------------------------
- static void decrementStatsCounter(const char* name);
- static void incrementStatsCounter(const char* name);
- static void initV8CounterFunction();
-
- // SystemTime ---------------------------------------------------------
- static double currentTime();
-
- // Theming ------------------------------------------------------------
-#if PLATFORM(WIN_OS)
- static void paintButton(
- GraphicsContext*, int part, int state, int classicState, const IntRect& rect);
- static void paintMenuList(
- GraphicsContext*, int part, int state, int classicState, const IntRect& rect);
- static void paintScrollbarArrow(
- GraphicsContext*, int state, int classicState, const IntRect& rect);
- static void paintScrollbarThumb(
- GraphicsContext*, int part, int state, int classicState, const IntRect& rect);
- static void paintScrollbarTrack(
- GraphicsContext*, int part, int state, int classicState, const IntRect& rect, const IntRect& alignRect);
- static void paintTextField(
- GraphicsContext*, int part, int state, int classicState, const IntRect& rect, const Color& color, bool fillContentArea, bool drawEdges);
-#endif
-
- // Trace Event --------------------------------------------------------
- static void traceEventBegin(const char* name, void* id, const char* extra);
- static void traceEventEnd(const char* name, void* id, const char* extra);
-
- // URL ----------------------------------------------------------------
- static KURL inspectorURL();
-
- // Visited links ------------------------------------------------------
- static LinkHash visitedLinkHash(const UChar* url, unsigned length);
- static LinkHash visitedLinkHash(const KURL& base,
- const AtomicString& attributeURL);
- static bool isLinkVisited(LinkHash);
-
- // Widget -------------------------------------------------------------
- static void widgetSetCursor(Widget*, const Cursor&);
- static void widgetSetFocus(Widget*);
- };
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/ChromiumDataObject.cpp b/webkit/port/platform/chromium/ChromiumDataObject.cpp
deleted file mode 100644
index 54da838..0000000
--- a/webkit/port/platform/chromium/ChromiumDataObject.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2008, 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 "ChromiumDataObject.h"
-
-using namespace WebCore;
-
-void ChromiumDataObject::clear()
-{
- url = KURL();
- url_title = "";
- filenames.clear();
- plain_text = "";
- text_html = "";
- html_base_url = KURL();
- file_content_filename = "";
- if (file_content)
- file_content->clear();
-}
-
-bool ChromiumDataObject::hasData()
-{
- return !url.isEmpty() || !filenames.isEmpty() ||
- !plain_text.isEmpty() || !text_html.isEmpty() ||
- file_content;
-}
diff --git a/webkit/port/platform/chromium/ChromiumDataObject.h b/webkit/port/platform/chromium/ChromiumDataObject.h
deleted file mode 100644
index bdbb62c..0000000
--- a/webkit/port/platform/chromium/ChromiumDataObject.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2008, 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.
-
-// A data object for holding data that would be in a clipboard or moved
-// during a drag&drop operation. This is the data that webkit is aware
-// of and is not specific to a platform.
-
-#ifndef ChromiumDataObject_h
-#define ChromiumDataObject_h
-
-#include "KURL.h"
-#include "PlatformString.h"
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
- class ChromiumDataObject : public RefCounted<ChromiumDataObject> {
- public:
- static PassRefPtr<ChromiumDataObject> create() {
- return adoptRef(new ChromiumDataObject);
- }
-
- void clear();
- bool hasData();
-
- KURL url;
- String url_title;
-
- Vector<String> filenames;
-
- String plain_text;
-
- String text_html;
- KURL html_base_url;
-
- String file_content_filename;
- RefPtr<SharedBuffer> file_content;
- private:
- ChromiumDataObject() {}
-
- };
-}
-
-#endif // ChromiumDataObject_h
diff --git a/webkit/port/platform/chromium/ChromiumUtilsWin.cpp b/webkit/port/platform/chromium/ChromiumUtilsWin.cpp
deleted file mode 100644
index 8889eab..0000000
--- a/webkit/port/platform/chromium/ChromiumUtilsWin.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2008, 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 "ChromiumUtilsWin.h"
-
-#include <windows.h>
-
-namespace WebCore {
-namespace ChromiumUtils {
-
-bool isVistaOrGreater()
-{
- // Cache the result to avoid asking every time.
- static bool haveResult = false;
- static bool result = false;
- if (!haveResult) {
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- GetVersionEx(&versionInfo);
-
- haveResult = true;
- result = versionInfo.dwMajorVersion >= 6;
- }
- return result;
-}
-
-} // namespace ChromiumUtils
-} // namespace WebCore \ No newline at end of file
diff --git a/webkit/port/platform/chromium/ChromiumUtilsWin.h b/webkit/port/platform/chromium/ChromiumUtilsWin.h
deleted file mode 100644
index 9bc3fb6..0000000
--- a/webkit/port/platform/chromium/ChromiumUtilsWin.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2008, 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 ChromiumUtilsWin_h
-#define ChromiumUtilsWin_h
-
-namespace WebCore {
- namespace ChromiumUtils {
- bool isVistaOrGreater();
- }
-}
-
-#endif // ChromiumUtilsWin_h
diff --git a/webkit/port/platform/chromium/ClipboardChromium.cpp b/webkit/port/platform/chromium/ClipboardChromium.cpp
deleted file mode 100644
index ac701fe..0000000
--- a/webkit/port/platform/chromium/ClipboardChromium.cpp
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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"
-
-#if COMPILER(MSVC)
-__pragma(warning(push, 0))
-#endif
-#include "CachedImage.h"
-#include "ChromiumBridge.h"
-#include "ChromiumDataObject.h"
-#include "ClipboardChromium.h"
-#include "ClipboardUtilitiesChromium.h"
-#include "CSSHelper.h"
-#include "CString.h"
-#include "Document.h"
-#include "DragData.h"
-#include "Editor.h"
-#include "Element.h"
-#include "EventHandler.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameView.h"
-#include "HTMLNames.h"
-#include "Image.h"
-#include "MIMETypeRegistry.h"
-#include "markup.h"
-#include "Page.h"
-#include "Pasteboard.h"
-#include "PlatformString.h"
-#include "Range.h"
-#include "RenderImage.h"
-#include "StringBuilder.h"
-#include "StringHash.h"
-#include <wtf/RefPtr.h>
-#if COMPILER(MSVC)
-__pragma(warning(pop))
-#endif
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// We provide the IE clipboard types (URL and Text), and the clipboard types specified in the WHATWG Web Applications 1.0 draft
-// see http://www.whatwg.org/specs/web-apps/current-work/ Section 6.3.5.3
-
-enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText };
-
-static ClipboardDataType clipboardTypeFromMIMEType(const String& type)
-{
- String qType = type.stripWhiteSpace().lower();
-
- // two special cases for IE compatibility
- if (qType == "text" || qType == "text/plain" || qType.startsWith("text/plain;"))
- return ClipboardDataTypeText;
- if (qType == "url" || qType == "text/uri-list")
- return ClipboardDataTypeURL;
-
- return ClipboardDataTypeNone;
-}
-
-ClipboardChromium::ClipboardChromium(bool isForDragging,
- ChromiumDataObject* dataObject,
- ClipboardAccessPolicy policy)
- : Clipboard(policy, isForDragging)
- , m_dataObject(dataObject)
-{
-}
-
-PassRefPtr<ClipboardChromium> ClipboardChromium::create(bool isForDragging,
- ChromiumDataObject* dataObject, ClipboardAccessPolicy policy)
-{
- return adoptRef(new ClipboardChromium(isForDragging, dataObject, policy));
-}
-
-void ClipboardChromium::clearData(const String& type)
-{
- if (policy() != ClipboardWritable || !m_dataObject)
- return;
-
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
-
- if (dataType == ClipboardDataTypeURL) {
- m_dataObject->url = KURL();
- m_dataObject->url_title = "";
- }
- if (dataType == ClipboardDataTypeText) {
- m_dataObject->plain_text = "";
- }
-}
-
-void ClipboardChromium::clearAllData()
-{
- if (policy() != ClipboardWritable)
- return;
-
- m_dataObject->clear();
-}
-
-String ClipboardChromium::getData(const String& type, bool& success) const
-{
- success = false;
- if (policy() != ClipboardReadable || !m_dataObject) {
- return "";
- }
-
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
- String text;
- if (dataType == ClipboardDataTypeText) {
- if (!isForDragging()) {
- // If this isn't for a drag, it's for a cut/paste event handler.
- // In this case, we need to check the clipboard.
- text = ChromiumBridge::clipboardReadPlainText();
- success = !text.isEmpty();
- } else if (!m_dataObject->plain_text.isEmpty()) {
- success = true;
- text = m_dataObject->plain_text;
- }
- } else if (dataType == ClipboardDataTypeURL) {
- // TODO(tc): Handle the cut/paste event. This requires adding
- // a new IPC message to get the URL from the clipboard directly.
- if (!m_dataObject->url.isEmpty()) {
- success = true;
- text = m_dataObject->url.string();
- }
- }
-
- return text;
-}
-
-bool ClipboardChromium::setData(const String& type, const String& data)
-{
- if (policy() != ClipboardWritable)
- return false;
-
- ClipboardDataType winType = clipboardTypeFromMIMEType(type);
-
- if (winType == ClipboardDataTypeURL) {
- m_dataObject->url = KURL(data);
- return m_dataObject->url.isValid();
- }
-
- if (winType == ClipboardDataTypeText) {
- m_dataObject->plain_text = data;
- return true;
- }
- return false;
-}
-
-// extensions beyond IE's API
-HashSet<String> ClipboardChromium::types() const
-{
- HashSet<String> results;
- if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
- return results;
-
- if (!m_dataObject)
- return results;
-
- if (m_dataObject->url.isValid()) {
- results.add("URL");
- results.add("text/uri-list");
- }
-
- if (!m_dataObject->plain_text.isEmpty()) {
- results.add("Text");
- results.add("text/plain");
- }
-
- return results;
-}
-
-void ClipboardChromium::setDragImage(CachedImage* image, Node *node, const IntPoint &loc)
-{
- if (policy() != ClipboardImageWritable && policy() != ClipboardWritable)
- return;
-
- if (m_dragImage)
- m_dragImage->removeClient(this);
- m_dragImage = image;
- if (m_dragImage)
- m_dragImage->addClient(this);
-
- m_dragLoc = loc;
- m_dragImageElement = node;
-}
-
-void ClipboardChromium::setDragImage(CachedImage* img, const IntPoint &loc)
-{
- setDragImage(img, 0, loc);
-}
-
-void ClipboardChromium::setDragImageElement(Node *node, const IntPoint &loc)
-{
- setDragImage(0, node, loc);
-}
-
-DragImageRef ClipboardChromium::createDragImage(IntPoint& loc) const
-{
- DragImageRef result = 0;
- if (m_dragImage) {
- result = createDragImageFromImage(m_dragImage->image());
- loc = m_dragLoc;
- }
- return result;
-}
-
-static String imageToMarkup(const String& url, Element* element)
-{
- StringBuilder markup;
- markup.append("<img src=\"");
- markup.append(url);
- markup.append("\"");
- // Copy over attributes. If we are dragging an image, we expect things like
- // the id to be copied as well.
- NamedAttrMap* attrs = element->attributes();
- unsigned int length = attrs->length();
- for (unsigned int i = 0; i < length; ++i) {
- Attribute* attr = attrs->attributeItem(i);
- if (attr->localName() == "src")
- continue;
- markup.append(" ");
- markup.append(attr->localName());
- markup.append("=\"");
- String escapedAttr = attr->value();
- escapedAttr.replace("\"", "&quot;");
- markup.append(escapedAttr);
- markup.append("\"");
- }
-
- markup.append("/>");
- return markup.toString();
-}
-
-static CachedImage* getCachedImage(Element* element)
-{
- // Attempt to pull CachedImage from element
- ASSERT(element);
- RenderObject* renderer = element->renderer();
- if (!renderer || !renderer->isImage())
- return 0;
-
- RenderImage* image = static_cast<RenderImage*>(renderer);
- if (image->cachedImage() && !image->cachedImage()->errorOccurred())
- return image->cachedImage();
-
- return 0;
-}
-
-static void writeImageToDataObject(ChromiumDataObject* dataObject, Element* element,
- const KURL& url)
-{
- // Shove image data into a DataObject for use as a file
- CachedImage* cachedImage = getCachedImage(element);
- if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded())
- return;
-
- SharedBuffer* imageBuffer = cachedImage->image()->data();
- if (!imageBuffer || !imageBuffer->size())
- return;
-
- dataObject->file_content = imageBuffer;
-
- // Determine the filename for the file contents of the image. We try to
- // use the alt tag if one exists, otherwise we fall back on the suggested
- // filename in the http header, and finally we resort to using the filename
- // in the URL.
- String extension(".");
- extension += WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType(
- cachedImage->response().mimeType());
- String title = element->getAttribute(altAttr);
- if (title.isEmpty()) {
- title = cachedImage->response().suggestedFilename();
- if (title.isEmpty()) {
- // TODO(tc): Get the filename from the URL.
- }
- }
- dataObject->file_content_filename = title + extension;
-}
-
-void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
-{
- if (!m_dataObject)
- return;
-
- m_dataObject->url = url;
- m_dataObject->url_title = title;
-
- // Write the bytes in the image to the file format.
- writeImageToDataObject(m_dataObject.get(), element, url);
-
- AtomicString imageURL = element->getAttribute(srcAttr);
- if (imageURL.isEmpty())
- return;
-
- String fullURL = frame->document()->completeURL(parseURL(imageURL));
- if (fullURL.isEmpty())
- return;
-
- // Put img tag on the clipboard referencing the image
- m_dataObject->text_html = imageToMarkup(fullURL, element);
-}
-
-void ClipboardChromium::writeURL(const KURL& url, const String& title, Frame*)
-{
- if (!m_dataObject)
- return;
- m_dataObject->url = url;
- m_dataObject->url_title = title;
-
- // The URL can also be used as plain text.
- m_dataObject->plain_text = url.string();
-
- // The URL can also be used as an HTML fragment.
- m_dataObject->text_html = urlToMarkup(url, title);
- m_dataObject->html_base_url = url;
-}
-
-void ClipboardChromium::writeRange(Range* selectedRange, Frame* frame)
-{
- ASSERT(selectedRange);
- if (!m_dataObject)
- return;
-
- m_dataObject->text_html = createMarkup(selectedRange, 0,
- AnnotateForInterchange);
- m_dataObject->html_base_url = frame->document()->url();
-
- String str = frame->selectedText();
-#if PLATFORM(WIN_OS)
- replaceNewlinesWithWindowsStyleNewlines(str);
-#endif
- replaceNBSPWithSpace(str);
- m_dataObject->plain_text = str;
-}
-
-bool ClipboardChromium::hasData()
-{
- if (!m_dataObject)
- return false;
-
- return m_dataObject->hasData();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/ClipboardChromium.h b/webkit/port/platform/chromium/ClipboardChromium.h
deleted file mode 100644
index 81f2851..0000000
--- a/webkit/port/platform/chromium/ClipboardChromium.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2008, 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 ClipboardChromium_h
-#define ClipboardChromium_h
-
-#include "Clipboard.h"
-
-#include "CachedResourceClient.h"
-
-namespace WebCore {
-
- class CachedImage;
- class ChromiumDataObject;
- class IntPoint;
-
- class ClipboardChromium : public Clipboard, public CachedResourceClient {
- public:
- ~ClipboardChromium() {}
-
- static PassRefPtr<ClipboardChromium> create(bool, ChromiumDataObject*,
- ClipboardAccessPolicy);
-
- virtual void clearData(const String& type);
- void clearAllData();
- String getData(const String& type, bool& success) const;
- bool setData(const String& type, const String& data);
-
- // extensions beyond IE's API
- HashSet<String> types() const;
-
- void setDragImage(CachedImage*, const IntPoint&);
- void setDragImageElement(Node*, const IntPoint&);
-
- PassRefPtr<ChromiumDataObject> dataObject() {
- return m_dataObject;
- }
-
- virtual DragImageRef createDragImage(IntPoint& dragLoc) const;
- virtual void declareAndWriteDragImage(Element*, const KURL&,
- const String& title, Frame*);
- virtual void writeURL(const KURL&, const String&, Frame*);
- virtual void writeRange(Range*, Frame*);
-
- virtual bool hasData();
-
- private:
- ClipboardChromium(bool, ChromiumDataObject*, ClipboardAccessPolicy);
-
- void resetFromClipboard();
- void setDragImage(CachedImage*, Node*, const IntPoint&);
- RefPtr<ChromiumDataObject> m_dataObject;
- Frame* m_frame;
- };
-
-} // namespace WebCore
-
-#endif // ClipboardChromium_h
diff --git a/webkit/port/platform/chromium/ClipboardUtilitiesChromium.cpp b/webkit/port/platform/chromium/ClipboardUtilitiesChromium.cpp
deleted file mode 100644
index 37910c1..0000000
--- a/webkit/port/platform/chromium/ClipboardUtilitiesChromium.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2008, 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 "ClipboardUtilitiesChromium.h"
-
-#include "KURL.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-#if PLATFORM(WIN_OS)
-void replaceNewlinesWithWindowsStyleNewlines(String& str)
-{
- static const UChar Newline = '\n';
- static const char* const WindowsNewline("\r\n");
- str.replace(Newline, WindowsNewline);
-}
-#endif
-
-void replaceNBSPWithSpace(String& str)
-{
- static const UChar NonBreakingSpaceCharacter = 0xA0;
- static const UChar SpaceCharacter = ' ';
- str.replace(NonBreakingSpaceCharacter, SpaceCharacter);
-}
-
-String urlToMarkup(const KURL& url, const String& title)
-{
- String markup("<a href=\"");
- markup.append(url.string());
- markup.append("\">");
- // TODO(tc): HTML escape this, possibly by moving into the glue layer so we
- // can use net/base/escape.h.
- markup.append(title);
- markup.append("</a>");
- return markup;
-}
-
-}
diff --git a/webkit/port/platform/chromium/ClipboardUtilitiesChromium.h b/webkit/port/platform/chromium/ClipboardUtilitiesChromium.h
deleted file mode 100644
index 4bccc13..0000000
--- a/webkit/port/platform/chromium/ClipboardUtilitiesChromium.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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"
-
-namespace WebCore {
-
-class KURL;
-class String;
-
-#if PLATFORM(WIN_OS)
-void replaceNewlinesWithWindowsStyleNewlines(String&);
-#endif
-void replaceNBSPWithSpace(String&);
-
-String urlToMarkup(const KURL&, const String&);
-
-}
diff --git a/webkit/port/platform/chromium/ContextMenuChromium.cpp b/webkit/port/platform/chromium/ContextMenuChromium.cpp
deleted file mode 100644
index 81c318d..0000000
--- a/webkit/port/platform/chromium/ContextMenuChromium.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "ContextMenu.h"
-
-namespace WebCore {
-
-// This is a stub implementation of WebKit's ContextMenu class that does
-// nothing.
-
-ContextMenu::ContextMenu(const HitTestResult& result)
- : m_hitTestResult(result)
- , m_platformDescription(0)
-{
-}
-
-ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
- : m_hitTestResult(result)
- , m_platformDescription(0)
-{
-}
-
-ContextMenu::~ContextMenu()
-{
-}
-
-unsigned ContextMenu::itemCount() const
-{
- return 0;
-}
-
-void ContextMenu::insertItem(unsigned int position, ContextMenuItem& item)
-{
-}
-
-void ContextMenu::appendItem(ContextMenuItem& item)
-{
-}
-
-ContextMenuItem* ContextMenu::itemWithAction(unsigned action)
-{
- return 0;
-}
-
-ContextMenuItem* ContextMenu::itemAtIndex(unsigned index, const PlatformMenuDescription platformDescription)
-{
- return 0;
-}
-
-void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
-{
-}
-
-PlatformMenuDescription ContextMenu::platformDescription() const
-{
- return m_platformDescription;
-}
-
-PlatformMenuDescription ContextMenu::releasePlatformDescription()
-{
- return 0;
-}
-
-}
diff --git a/webkit/port/platform/chromium/ContextMenuItemChromium.cpp b/webkit/port/platform/chromium/ContextMenuItemChromium.cpp
deleted file mode 100644
index ebdc9c9..0000000
--- a/webkit/port/platform/chromium/ContextMenuItemChromium.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "ContextMenuItem.h"
-
-#include "ContextMenu.h"
-
-namespace WebCore {
-
-// This is a stub implementation of WebKit's ContextMenu class that does
-// nothing.
-
-ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription item)
-{
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenu* subMenu)
-{
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu)
-{
-}
-
-ContextMenuItem::~ContextMenuItem()
-{
-}
-
-PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
-{
- return PlatformMenuItemDescription();
-}
-
-ContextMenuItemType ContextMenuItem::type() const
-{
- return ContextMenuItemType();
-}
-
-ContextMenuAction ContextMenuItem::action() const
-{
- return ContextMenuAction();
-}
-
-String ContextMenuItem::title() const
-{
- return String();
-}
-
-PlatformMenuDescription ContextMenuItem::platformSubMenu() const
-{
- return PlatformMenuDescription();
-}
-
-void ContextMenuItem::setType(ContextMenuItemType type)
-{
-}
-
-void ContextMenuItem::setAction(ContextMenuAction action)
-{
-}
-
-void ContextMenuItem::setTitle(const String& title)
-{
-}
-
-void ContextMenuItem::setSubMenu(ContextMenu* subMenu)
-{
-}
-
-void ContextMenuItem::setChecked(bool checked)
-{
-}
-
-void ContextMenuItem::setEnabled(bool enabled)
-{
-}
-
-bool ContextMenuItem::enabled() const
-{
- return false;
-}
-
-}
diff --git a/webkit/port/platform/chromium/CursorChromium.cpp b/webkit/port/platform/chromium/CursorChromium.cpp
deleted file mode 100644
index fe9a893..0000000
--- a/webkit/port/platform/chromium/CursorChromium.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "Cursor.h"
-
-namespace WebCore {
-
-Cursor::Cursor(const Cursor& other)
- : m_impl(other.m_impl)
-{
-}
-
-Cursor::Cursor(Image* image, const IntPoint& hotSpot)
- : m_impl(image, hotSpot)
-{
-}
-
-Cursor::~Cursor()
-{
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- m_impl = other.m_impl;
- return *this;
-}
-
-Cursor::Cursor(PlatformCursor c)
- : m_impl(c)
-{
-}
-
-const Cursor& pointerCursor()
-{
- static const Cursor c(PlatformCursor::typePointer);
- return c;
-}
-
-const Cursor& crossCursor()
-{
- static const Cursor c(PlatformCursor::typeCross);
- return c;
-}
-
-const Cursor& handCursor()
-{
- static const Cursor c(PlatformCursor::typeHand);
- return c;
-}
-
-const Cursor& iBeamCursor()
-{
- static const Cursor c(PlatformCursor::typeIBeam);
- return c;
-}
-
-const Cursor& waitCursor()
-{
- static const Cursor c(PlatformCursor::typeWait);
- return c;
-}
-
-const Cursor& helpCursor()
-{
- static const Cursor c(PlatformCursor::typeHelp);
- return c;
-}
-
-const Cursor& eastResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeEastResize);
- return c;
-}
-
-const Cursor& northResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthResize);
- return c;
-}
-
-const Cursor& northEastResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthEastResize);
- return c;
-}
-
-const Cursor& northWestResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthWestResize);
- return c;
-}
-
-const Cursor& southResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeSouthResize);
- return c;
-}
-
-const Cursor& southEastResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeSouthEastResize);
- return c;
-}
-
-const Cursor& southWestResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeSouthWestResize);
- return c;
-}
-
-const Cursor& westResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeWestResize);
- return c;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthSouthResize);
- return c;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeEastWestResize);
- return c;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthEastSouthWestResize);
- return c;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthWestSouthEastResize);
- return c;
-}
-
-const Cursor& columnResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeColumnResize);
- return c;
-}
-
-const Cursor& rowResizeCursor()
-{
- static const Cursor c(PlatformCursor::typeRowResize);
- return c;
-}
-
-const Cursor& middlePanningCursor()
-{
- static const Cursor c(PlatformCursor::typeMiddlePanning);
- return c;
-}
-
-const Cursor& eastPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeEastPanning);
- return c;
-}
-
-const Cursor& northPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthPanning);
- return c;
-}
-
-const Cursor& northEastPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthEastPanning);
- return c;
-}
-
-const Cursor& northWestPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeNorthWestPanning);
- return c;
-}
-
-const Cursor& southPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeSouthPanning);
- return c;
-}
-
-const Cursor& southEastPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeSouthEastPanning);
- return c;
-}
-
-const Cursor& southWestPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeSouthWestPanning);
- return c;
-}
-
-const Cursor& westPanningCursor()
-{
- static const Cursor c(PlatformCursor::typeWestPanning);
- return c;
-}
-
-const Cursor& moveCursor()
-{
- static const Cursor c(PlatformCursor::typeMove);
- return c;
-}
-
-const Cursor& verticalTextCursor()
-{
- static const Cursor c(PlatformCursor::typeVerticalText);
- return c;
-}
-
-const Cursor& cellCursor()
-{
- static const Cursor c(PlatformCursor::typeCell);
- return c;
-}
-
-const Cursor& contextMenuCursor()
-{
- static const Cursor c(PlatformCursor::typeContextMenu);
- return c;
-}
-
-const Cursor& aliasCursor()
-{
- static const Cursor c(PlatformCursor::typeAlias);
- return c;
-}
-
-const Cursor& progressCursor()
-{
- static const Cursor c(PlatformCursor::typeProgress);
- return c;
-}
-
-const Cursor& noDropCursor()
-{
- static const Cursor c(PlatformCursor::typeNoDrop);
- return c;
-}
-
-const Cursor& copyCursor()
-{
- static const Cursor c(PlatformCursor::typeCopy);
- return c;
-}
-
-const Cursor& noneCursor()
-{
- static const Cursor c(PlatformCursor::typeNone);
- return c;
-}
-
-const Cursor& notAllowedCursor()
-{
- static const Cursor c(PlatformCursor::typeNotAllowed);
- return c;
-}
-
-const Cursor& zoomInCursor()
-{
- static const Cursor c(PlatformCursor::typeZoomIn);
- return c;
-}
-
-const Cursor& zoomOutCursor()
-{
- static const Cursor c(PlatformCursor::typeZoomOut);
- return c;
-}
-
-const Cursor& grabCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& grabbingCursor()
-{
- return pointerCursor();
-}
-
-}
diff --git a/webkit/port/platform/chromium/DragDataChromium.cpp b/webkit/port/platform/chromium/DragDataChromium.cpp
deleted file mode 100644
index d615559..0000000
--- a/webkit/port/platform/chromium/DragDataChromium.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
- */
-
-// Modified from Apple's version to not directly call any windows methods as
-// they may not be available to us in the multiprocess
-
-#include "config.h"
-#include "DragData.h"
-
-#include "ChromiumDataObject.h"
-#include "Clipboard.h"
-#include "ClipboardChromium.h"
-#include "DocumentFragment.h"
-#include "KURL.h"
-#include "PlatformString.h"
-#include "markup.h"
-
-namespace {
-
-bool containsHTML(const WebCore::ChromiumDataObject* drop_data) {
- return drop_data->text_html.length() > 0;
-}
-
-}
-
-namespace WebCore {
-
-PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const
-{
- RefPtr<ClipboardChromium> clipboard = ClipboardChromium::create(true,
- m_platformDragData, policy);
-
- return clipboard.release();
-}
-
-bool DragData::containsURL() const
-{
- return m_platformDragData->url.isValid();
-}
-
-String DragData::asURL(String* title) const
-{
- if (!m_platformDragData->url.isValid())
- return String();
-
- // |title| can be NULL
- if (title)
- *title = m_platformDragData->url_title;
- return m_platformDragData->url.string();
-}
-
-bool DragData::containsFiles() const
-{
- return !m_platformDragData->filenames.isEmpty();
-}
-
-void DragData::asFilenames(Vector<String>& result) const
-{
- for (size_t i = 0; i < m_platformDragData->filenames.size(); ++i)
- result.append(m_platformDragData->filenames[i]);
-}
-
-bool DragData::containsPlainText() const
-{
- return !m_platformDragData->plain_text.isEmpty();
-}
-
-String DragData::asPlainText() const
-{
- return m_platformDragData->plain_text;
-}
-
-bool DragData::containsColor() const
-{
- return false;
-}
-
-bool DragData::canSmartReplace() const
-{
- // Mimic the situations in which mac allows drag&drop to do a smart replace.
- // This is allowed whenever the drag data contains a 'range' (ie.,
- // ClipboardWin::writeRange is called). For example, dragging a link
- // should not result in a space being added.
- return !m_platformDragData->plain_text.isEmpty() &&
- !m_platformDragData->url.isValid();
-}
-
-bool DragData::containsCompatibleContent() const
-{
- return containsPlainText() || containsURL()
- || ::containsHTML(m_platformDragData)
- || containsColor();
-}
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
-{
- /*
- * Order is richest format first. On OSX this is:
- * * Web Archive
- * * Filenames
- * * HTML
- * * RTF
- * * TIFF
- * * PICT
- */
-
- if (containsFiles()) {
- // TODO(tc): Implement this. Should be pretty simple to make some HTML
- // and call createFragmentFromMarkup.
- //if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(doc,
- // ?, KURL()))
- // return fragment;
- }
-
- if (!m_platformDragData->text_html.isEmpty()) {
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(doc,
- m_platformDragData->text_html, m_platformDragData->html_base_url);
- return fragment.release();
- }
-
- return 0;
-}
-
-Color DragData::asColor() const
-{
- return Color();
-}
-
-}
diff --git a/webkit/port/platform/chromium/DragDataRef.h b/webkit/port/platform/chromium/DragDataRef.h
deleted file mode 100644
index 4ddc1ac..0000000
--- a/webkit/port/platform/chromium/DragDataRef.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2008, 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 DragDataRef_h
-#define DragDataRef_h
-
-#include "ChromiumDataObject.h"
-
-namespace WebCore {
-
-typedef ChromiumDataObject* DragDataRef;
-
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/DragImageChromium.cpp b/webkit/port/platform/chromium/DragImageChromium.cpp
deleted file mode 100644
index e74a204..0000000
--- a/webkit/port/platform/chromium/DragImageChromium.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "DragImage.h"
-
-#include "CachedImage.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-
-#if PLATFORM(WIN_OS)
-#include <windows.h>
-#else
-#include "NotImplemented.h"
-#endif
-
-namespace WebCore {
-
-IntSize dragImageSize(DragImageRef image)
-{
-// TODO(darin): DragImageRef should be changed to be a cross-platform
-// container. However, it may still make sense for its contents to be
-// platform-dependent.
-#if PLATFORM(WIN_OS)
- if (!image)
- return IntSize();
- BITMAP b;
- GetObject(image, sizeof(BITMAP), &b);
- return IntSize(b.bmWidth, b.bmHeight);
-#else
- return IntSize();
-#endif
-}
-
-void deleteDragImage(DragImageRef image)
-{
-#if PLATFORM(WIN_OS)
- if (image)
- ::DeleteObject(image);
-#else
- notImplemented();
-#endif
-}
-
-DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
-{
- // FIXME
- return 0;
-}
-
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
-{
- //We don't do this on windows as the dragimage is blended by the OS
- return image;
-}
-
-DragImageRef createDragImageFromImage(Image* img)
-{
- // FIXME
- return 0;
-}
-
-DragImageRef createDragImageIconForCachedImage(CachedImage*)
-{
- //FIXME: Provide icon for image type <rdar://problem/5015949>
- return 0;
-}
-
-}
diff --git a/webkit/port/platform/chromium/DragImageRef.h b/webkit/port/platform/chromium/DragImageRef.h
deleted file mode 100644
index 6b7dcaf..0000000
--- a/webkit/port/platform/chromium/DragImageRef.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2008, 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 DragImageRef_h__
-#define DragImageRef_h__
-
-#include "config.h"
-
-#if PLATFORM(WIN_OS)
-typedef struct HBITMAP__* HBITMAP;
-#elif PLATFORM(DARWIN)
-#if __OBJC__
-@class NSImage;
-#else
-class NSImage;
-#endif
-#endif
-
-namespace WebCore {
-
-#if PLATFORM(WIN_OS)
-typedef HBITMAP DragImageRef;
-#elif PLATFORM(DARWIN)
-typedef NSImage* DragImageRef;
-#else
-// TODO(port): remove null port.
-typedef void* DragImageRef;
-#endif
-
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/EditorChromium.cpp b/webkit/port/platform/chromium/EditorChromium.cpp
deleted file mode 100644
index 8636ed1..0000000
--- a/webkit/port/platform/chromium/EditorChromium.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "Editor.h"
-#include "ChromiumDataObject.h"
-#include "ClipboardChromium.h"
-
-namespace WebCore {
-
-PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
-{
- RefPtr<ChromiumDataObject> dataObject = ChromiumDataObject::create();
- return ClipboardChromium::create(false, dataObject.get(), policy);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/FileChooserChromium.cpp b/webkit/port/platform/chromium/FileChooserChromium.cpp
deleted file mode 100644
index 2a80744..0000000
--- a/webkit/port/platform/chromium/FileChooserChromium.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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"
-
-#if COMPILER(MSVC)
-__pragma(warning(push, 0))
-#endif
-#include "ChromeClientChromium.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FileChooser.h"
-#include "FileSystem.h"
-#include "LocalizedStrings.h"
-#include "NotImplemented.h"
-#include "Page.h"
-#include "StringTruncator.h"
-#if COMPILER(MSVC)
-__pragma(warning(pop))
-#endif
-
-namespace WebCore {
-
-String FileChooser::basenameForWidth(const Font& font, int width) const
-{
- if (width <= 0)
- return String();
-
- String string;
- if (!m_filenames.size())
- string = fileButtonNoFileSelectedLabel();
- else
- string = pathGetFileName(m_filenames[0]);
-
- return StringTruncator::centerTruncate(string, static_cast<float>(width), font, false);
-}
-
-}
diff --git a/webkit/port/platform/chromium/FileSystemChromium.cpp b/webkit/port/platform/chromium/FileSystemChromium.cpp
deleted file mode 100644
index 33b04cb..0000000
--- a/webkit/port/platform/chromium/FileSystemChromium.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "NotImplemented.h"
-#include "PlatformString.h"
-
-
-namespace WebCore {
-
-bool deleteFile(const String&)
-{
- notImplemented();
- return false;
-}
-
-bool deleteEmptyDirectory(const String&)
-{
- notImplemented();
- return false;
-}
-
-bool getFileSize(const String&, long long& result)
-{
- notImplemented();
- return false;
-}
-
-bool getFileModificationTime(const String&, time_t& result)
-{
- notImplemented();
- return false;
-}
-
-String directoryName(const String&)
-{
- notImplemented();
- return String();
-}
-
-String pathByAppendingComponent(const String& path, const String& component)
-{
- notImplemented();
- return String();
-}
-
-bool makeAllDirectories(const String& path)
-{
- notImplemented();
- return false;
-}
-
-bool fileExists(const String&)
-{
- notImplemented();
- return false;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/FileSystemChromiumLinux.cpp b/webkit/port/platform/chromium/FileSystemChromiumLinux.cpp
deleted file mode 100644
index e8635dc..0000000
--- a/webkit/port/platform/chromium/FileSystemChromiumLinux.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2008, 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 "FileSystem.h"
-
-namespace WebCore {
-
-String pathGetFileName(const String& path)
-{
- return path.substring(path.reverseFind('/') + 1);
-}
-
-}
diff --git a/webkit/port/platform/chromium/FileSystemChromiumMac.mm b/webkit/port/platform/chromium/FileSystemChromiumMac.mm
deleted file mode 100644
index 7733999..0000000
--- a/webkit/port/platform/chromium/FileSystemChromiumMac.mm
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2008, 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 "FileSystem.h"
-
-#import <Foundation/NSFileManager.h>
-#include "PlatformString.h"
-
-namespace WebCore {
-
-String pathGetFileName(const String& path)
-{
- return [[NSFileManager defaultManager] displayNameAtPath:path];
-}
-
-}
diff --git a/webkit/port/platform/chromium/FileSystemChromiumWin.cpp b/webkit/port/platform/chromium/FileSystemChromiumWin.cpp
deleted file mode 100644
index 91486e8..0000000
--- a/webkit/port/platform/chromium/FileSystemChromiumWin.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2008, 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 "FileSystem.h"
-
-#include <windows.h>
-#include <shlwapi.h>
-
-namespace WebCore {
-
-String pathGetFileName(const String& path)
-{
- return String(PathFindFileName(String(path).charactersWithNullTermination()));
-}
-
-}
diff --git a/webkit/port/platform/chromium/FramelessScrollView.cpp b/webkit/port/platform/chromium/FramelessScrollView.cpp
deleted file mode 100644
index 60d4375..0000000
--- a/webkit/port/platform/chromium/FramelessScrollView.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2008, 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 "FramelessScrollView.h"
-
-#include "FramelessScrollViewClient.h"
-
-namespace WebCore {
-
-FramelessScrollView::~FramelessScrollView()
-{
- // Remove native scrollbars now before we lose the connection to the HostWindow.
- setHasHorizontalScrollbar(false);
- setHasVerticalScrollbar(false);
-}
-
-void FramelessScrollView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
-{
- // Add in our offset within the ScrollView.
- IntRect dirtyRect = rect;
- dirtyRect.move(scrollbar->x(), scrollbar->y());
- invalidateRect(dirtyRect);
-}
-
-bool FramelessScrollView::isActive() const
-{
- // FIXME
- return true;
-}
-
-void FramelessScrollView::invalidateRect(const IntRect& rect)
-{
- if (HostWindow* h = hostWindow())
- h->repaint(contentsToWindow(rect), true);
-}
-
-HostWindow* FramelessScrollView::hostWindow() const
-{
- return const_cast<FramelessScrollViewClient*>(m_client);
-}
-
-IntRect FramelessScrollView::windowClipRect(bool clipToContents) const
-{
- return contentsToWindow(visibleContentRect(!clipToContents));
-}
-
-void FramelessScrollView::paintContents(GraphicsContext*, const IntRect& damageRect)
-{
-}
-
-void FramelessScrollView::contentsResized()
-{
-}
-
-void FramelessScrollView::visibleContentsResized()
-{
-}
-
-}
diff --git a/webkit/port/platform/chromium/FramelessScrollView.h b/webkit/port/platform/chromium/FramelessScrollView.h
deleted file mode 100644
index dd940a0..0000000
--- a/webkit/port/platform/chromium/FramelessScrollView.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef FramelessScrollView_h
-#define FramelessScrollView_h
-
-#include "ScrollView.h"
-
-namespace WebCore {
- class FramelessScrollViewClient;
- class PlatformKeyboardEvent;
- class PlatformMouseEvent;
- class PlatformWheelEvent;
-
- // A FramelessScrollView is a ScrollView that can be used to render custom
- // content, which does not have an associated Frame.
- //
- // TODO: It may be better to just develop a custom subclass of Widget that
- // can have scroll bars for this instead of trying to reuse ScrollView.
- //
- class FramelessScrollView : public ScrollView {
- public:
- FramelessScrollView() : m_client(0) {}
- ~FramelessScrollView();
-
- FramelessScrollViewClient* client() const { return m_client; }
- void setClient(FramelessScrollViewClient* client) { m_client = client; }
-
- // Event handlers that subclasses must implement.
- virtual bool handleMouseDownEvent(const PlatformMouseEvent&) = 0;
- virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) = 0;
- virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) = 0;
- virtual bool handleWheelEvent(const PlatformWheelEvent&) = 0;
- virtual bool handleKeyEvent(const PlatformKeyboardEvent&) = 0;
-
- // ScrollbarClient public methods:
- virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
- virtual bool isActive() const;
-
- // Widget public methods:
- virtual void invalidateRect(const IntRect&);
-
- // ScrollView public methods:
- virtual HostWindow* hostWindow() const;
- virtual IntRect windowClipRect(bool clipToContents = true) const;
-
- protected:
- // ScrollView protected methods:
- virtual void paintContents(GraphicsContext*, const IntRect& damageRect);
- virtual void contentsResized();
- virtual void visibleContentsResized();
-
- private:
- FramelessScrollViewClient* m_client;
- };
-}
-
-#endif // FramelessScrollView_h
diff --git a/webkit/port/platform/chromium/FramelessScrollViewClient.h b/webkit/port/platform/chromium/FramelessScrollViewClient.h
deleted file mode 100644
index a237bce..0000000
--- a/webkit/port/platform/chromium/FramelessScrollViewClient.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#ifndef FramelessScrollViewClient_h
-#define FramelessScrollViewClient_h
-
-#include "HostWindow.h"
-
-namespace WebCore {
- class FramelessScrollViewClient : public HostWindow {
- public:
- virtual void popupClosed(FramelessScrollView* popup_view) = 0;
- };
-}
-
-#endif // FramelessScrollViewClient_h
diff --git a/webkit/port/platform/chromium/KeyCodeConversion.h b/webkit/port/platform/chromium/KeyCodeConversion.h
deleted file mode 100644
index b7f96d9..0000000
--- a/webkit/port/platform/chromium/KeyCodeConversion.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
- */
-
-namespace WebCore {
-
-int windowsKeyCodeForKeyEvent(unsigned int keycode);
-
-}
diff --git a/webkit/port/platform/chromium/KeyCodeConversionGtk.cpp b/webkit/port/platform/chromium/KeyCodeConversionGtk.cpp
deleted file mode 100644
index 4808d7f..0000000
--- a/webkit/port/platform/chromium/KeyCodeConversionGtk.cpp
+++ /dev/null
@@ -1,363 +0,0 @@
-// WindowsKeyCodeForKeyEvent is taken from
-// WebKit/WebCore/platform/gtk/KeyEventGtk.cpp
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "KeyCodeConversion.h"
-#include "KeyboardCodes.h"
-
-#include <gdk/gdkkeysyms.h>
-
-namespace WebCore {
-
-int windowsKeyCodeForKeyEvent(unsigned int keycode)
-{
- switch (keycode) {
- case GDK_KP_0:
- return VKEY_NUMPAD0;// (60) Numeric keypad 0 key
- case GDK_KP_1:
- return VKEY_NUMPAD1;// (61) Numeric keypad 1 key
- case GDK_KP_2:
- return VKEY_NUMPAD2; // (62) Numeric keypad 2 key
- case GDK_KP_3:
- return VKEY_NUMPAD3; // (63) Numeric keypad 3 key
- case GDK_KP_4:
- return VKEY_NUMPAD4; // (64) Numeric keypad 4 key
- case GDK_KP_5:
- return VKEY_NUMPAD5; //(65) Numeric keypad 5 key
- case GDK_KP_6:
- return VKEY_NUMPAD6; // (66) Numeric keypad 6 key
- case GDK_KP_7:
- return VKEY_NUMPAD7; // (67) Numeric keypad 7 key
- case GDK_KP_8:
- return VKEY_NUMPAD8; // (68) Numeric keypad 8 key
- case GDK_KP_9:
- return VKEY_NUMPAD9; // (69) Numeric keypad 9 key
- case GDK_KP_Multiply:
- return VKEY_MULTIPLY; // (6A) Multiply key
- case GDK_KP_Add:
- return VKEY_ADD; // (6B) Add key
- case GDK_KP_Subtract:
- return VKEY_SUBTRACT; // (6D) Subtract key
- case GDK_KP_Decimal:
- return VKEY_DECIMAL; // (6E) Decimal key
- case GDK_KP_Divide:
- return VKEY_DIVIDE; // (6F) Divide key
-
- case GDK_BackSpace:
- return VKEY_BACK; // (08) BACKSPACE key
- case GDK_ISO_Left_Tab:
- case GDK_3270_BackTab:
- case GDK_Tab:
- return VKEY_TAB; // (09) TAB key
- case GDK_Clear:
- return VKEY_CLEAR; // (0C) CLEAR key
- case GDK_ISO_Enter:
- case GDK_KP_Enter:
- case GDK_Return:
- return VKEY_RETURN; //(0D) Return key
- case GDK_Shift_L:
- case GDK_Shift_R:
- return VKEY_SHIFT; // (10) SHIFT key
- case GDK_Control_L:
- case GDK_Control_R:
- return VKEY_CONTROL; // (11) CTRL key
- case GDK_Menu:
- case GDK_Alt_L:
- case GDK_Alt_R:
- return VKEY_MENU; // (12) ALT key
-
- case GDK_Pause:
- return VKEY_PAUSE; // (13) PAUSE key
- case GDK_Caps_Lock:
- return VKEY_CAPITAL; // (14) CAPS LOCK key
- case GDK_Kana_Lock:
- case GDK_Kana_Shift:
- return VKEY_KANA; // (15) Input Method Editor (IME) Kana mode
- case GDK_Hangul:
- return VKEY_HANGUL; // VKEY_HANGUL (15) IME Hangul mode
- // VKEY_JUNJA (17) IME Junja mode
- // VKEY_FINAL (18) IME final mode
- case GDK_Hangul_Hanja:
- return VKEY_HANJA; // (19) IME Hanja mode
- case GDK_Kanji:
- return VKEY_KANJI; // (19) IME Kanji mode
- case GDK_Escape:
- return VKEY_ESCAPE; // (1B) ESC key
- // VKEY_CONVERT (1C) IME convert
- // VKEY_NONCONVERT (1D) IME nonconvert
- // VKEY_ACCEPT (1E) IME accept
- // VKEY_MODECHANGE (1F) IME mode change request
- case GDK_space:
- return VKEY_SPACE; // (20) SPACEBAR
- case GDK_Page_Up:
- return VKEY_PRIOR; // (21) PAGE UP key
- case GDK_Page_Down:
- return VKEY_NEXT; // (22) PAGE DOWN key
- case GDK_End:
- return VKEY_END; // (23) END key
- case GDK_Home:
- return VKEY_HOME; // (24) HOME key
- case GDK_Left:
- return VKEY_LEFT; // (25) LEFT ARROW key
- case GDK_Up:
- return VKEY_UP; // (26) UP ARROW key
- case GDK_Right:
- return VKEY_RIGHT; // (27) RIGHT ARROW key
- case GDK_Down:
- return VKEY_DOWN; // (28) DOWN ARROW key
- case GDK_Select:
- return VKEY_SELECT; // (29) SELECT key
- case GDK_Print:
- return VKEY_PRINT; // (2A) PRINT key
- case GDK_Execute:
- return VKEY_EXECUTE;// (2B) EXECUTE key
- //dunno on this
- //case GDK_PrintScreen:
- // return VKEY_SNAPSHOT; // (2C) PRINT SCREEN key
- case GDK_Insert:
- return VKEY_INSERT; // (2D) INS key
- case GDK_Delete:
- return VKEY_DELETE; // (2E) DEL key
- case GDK_Help:
- return VKEY_HELP; // (2F) HELP key
- case GDK_0:
- case GDK_parenleft:
- return VKEY_0; // (30) 0) key
- case GDK_1:
- return VKEY_1; // (31) 1 ! key
- case GDK_2:
- case GDK_at:
- return VKEY_2; // (32) 2 & key
- case GDK_3:
- case GDK_numbersign:
- return VKEY_3; //case '3': case '#';
- case GDK_4:
- case GDK_dollar: // (34) 4 key '$';
- return VKEY_4;
- case GDK_5:
- case GDK_percent:
- return VKEY_5; // (35) 5 key '%'
- case GDK_6:
- case GDK_asciicircum:
- return VKEY_6; // (36) 6 key '^'
- case GDK_7:
- case GDK_ampersand:
- return VKEY_7; // (37) 7 key case '&'
- case GDK_8:
- case GDK_asterisk:
- return VKEY_8; // (38) 8 key '*'
- case GDK_9:
- case GDK_parenright:
- return VKEY_9; // (39) 9 key '('
- case GDK_a:
- case GDK_A:
- return VKEY_A; // (41) A key case 'a': case 'A': return 0x41;
- case GDK_b:
- case GDK_B:
- return VKEY_B; // (42) B key case 'b': case 'B': return 0x42;
- case GDK_c:
- case GDK_C:
- return VKEY_C; // (43) C key case 'c': case 'C': return 0x43;
- case GDK_d:
- case GDK_D:
- return VKEY_D; // (44) D key case 'd': case 'D': return 0x44;
- case GDK_e:
- case GDK_E:
- return VKEY_E; // (45) E key case 'e': case 'E': return 0x45;
- case GDK_f:
- case GDK_F:
- return VKEY_F; // (46) F key case 'f': case 'F': return 0x46;
- case GDK_g:
- case GDK_G:
- return VKEY_G; // (47) G key case 'g': case 'G': return 0x47;
- case GDK_h:
- case GDK_H:
- return VKEY_H; // (48) H key case 'h': case 'H': return 0x48;
- case GDK_i:
- case GDK_I:
- return VKEY_I; // (49) I key case 'i': case 'I': return 0x49;
- case GDK_j:
- case GDK_J:
- return VKEY_J; // (4A) J key case 'j': case 'J': return 0x4A;
- case GDK_k:
- case GDK_K:
- return VKEY_K; // (4B) K key case 'k': case 'K': return 0x4B;
- case GDK_l:
- case GDK_L:
- return VKEY_L; // (4C) L key case 'l': case 'L': return 0x4C;
- case GDK_m:
- case GDK_M:
- return VKEY_M; // (4D) M key case 'm': case 'M': return 0x4D;
- case GDK_n:
- case GDK_N:
- return VKEY_N; // (4E) N key case 'n': case 'N': return 0x4E;
- case GDK_o:
- case GDK_O:
- return VKEY_O; // (4F) O key case 'o': case 'O': return 0x4F;
- case GDK_p:
- case GDK_P:
- return VKEY_P; // (50) P key case 'p': case 'P': return 0x50;
- case GDK_q:
- case GDK_Q:
- return VKEY_Q; // (51) Q key case 'q': case 'Q': return 0x51;
- case GDK_r:
- case GDK_R:
- return VKEY_R; // (52) R key case 'r': case 'R': return 0x52;
- case GDK_s:
- case GDK_S:
- return VKEY_S; // (53) S key case 's': case 'S': return 0x53;
- case GDK_t:
- case GDK_T:
- return VKEY_T; // (54) T key case 't': case 'T': return 0x54;
- case GDK_u:
- case GDK_U:
- return VKEY_U; // (55) U key case 'u': case 'U': return 0x55;
- case GDK_v:
- case GDK_V:
- return VKEY_V; // (56) V key case 'v': case 'V': return 0x56;
- case GDK_w:
- case GDK_W:
- return VKEY_W; // (57) W key case 'w': case 'W': return 0x57;
- case GDK_x:
- case GDK_X:
- return VKEY_X; // (58) X key case 'x': case 'X': return 0x58;
- case GDK_y:
- case GDK_Y:
- return VKEY_Y; // (59) Y key case 'y': case 'Y': return 0x59;
- case GDK_z:
- case GDK_Z:
- return VKEY_Z; // (5A) Z key case 'z': case 'Z': return 0x5A;
- case GDK_Meta_L:
- return VKEY_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard)
- case GDK_Meta_R:
- return VKEY_RWIN; // (5C) Right Windows key (Natural keyboard)
- // VKEY_APPS (5D) Applications key (Natural keyboard)
- // VKEY_SLEEP (5F) Computer Sleep key
- // VKEY_SEPARATOR (6C) Separator key
- // VKEY_SUBTRACT (6D) Subtract key
- // VKEY_DECIMAL (6E) Decimal key
- // VKEY_DIVIDE (6F) Divide key
- // handled by key code above
-
- case GDK_Num_Lock:
- return VKEY_NUMLOCK; // (90) NUM LOCK key
-
- case GDK_Scroll_Lock:
- return VKEY_SCROLL; // (91) SCROLL LOCK key
-
- // VKEY_LSHIFT (A0) Left SHIFT key
- // VKEY_RSHIFT (A1) Right SHIFT key
- // VKEY_LCONTROL (A2) Left CONTROL key
- // VKEY_RCONTROL (A3) Right CONTROL key
- // VKEY_LMENU (A4) Left MENU key
- // VKEY_RMENU (A5) Right MENU key
- // VKEY_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
- // VKEY_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
- // VKEY_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
- // VKEY_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
- // VKEY_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
- // VKEY_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
- // VKEY_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
- // VKEY_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
- // VKEY_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
- // VKEY_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
- // VKEY_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
- // VKEY_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
- // VKEY_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
- // VKEY_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
- // VKEY_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
- // VKEY_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
- // VKEY_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
- // VKEY_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-
- // VKEY_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
- case GDK_semicolon:
- case GDK_colon:
- return VKEY_OEM_1; //case ';': case ':': return 0xBA;
- // VKEY_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
- case GDK_plus:
- case GDK_equal:
- return VKEY_OEM_PLUS; //case '=': case '+': return 0xBB;
- // VKEY_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
- case GDK_comma:
- case GDK_less:
- return VKEY_OEM_COMMA; //case ',': case '<': return 0xBC;
- // VKEY_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
- case GDK_minus:
- case GDK_underscore:
- return VKEY_OEM_MINUS; //case '-': case '_': return 0xBD;
- // VKEY_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
- case GDK_period:
- case GDK_greater:
- return VKEY_OEM_PERIOD; //case '.': case '>': return 0xBE;
- // VKEY_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
- case GDK_slash:
- case GDK_question:
- return VKEY_OEM_2; //case '/': case '?': return 0xBF;
- // VKEY_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
- case GDK_asciitilde:
- case GDK_quoteleft:
- return VKEY_OEM_3; //case '`': case '~': return 0xC0;
- // VKEY_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
- case GDK_bracketleft:
- case GDK_braceleft:
- return VKEY_OEM_4; //case '[': case '{': return 0xDB;
- // VKEY_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
- case GDK_backslash:
- case GDK_bar:
- return VKEY_OEM_5; //case '\\': case '|': return 0xDC;
- // VKEY_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
- case GDK_bracketright:
- case GDK_braceright:
- return VKEY_OEM_6; // case ']': case '}': return 0xDD;
- // VKEY_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
- case GDK_quoteright:
- case GDK_quotedbl:
- return VKEY_OEM_7; // case '\'': case '"': return 0xDE;
- // VKEY_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
- // VKEY_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
- // VKEY_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
- // VKEY_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VKEY_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
- // VKEY_ATTN (F6) Attn key
- // VKEY_CRSEL (F7) CrSel key
- // VKEY_EXSEL (F8) ExSel key
- // VKEY_EREOF (F9) Erase EOF key
- // VKEY_PLAY (FA) Play key
- // VKEY_ZOOM (FB) Zoom key
- // VKEY_NONAME (FC) Reserved for future use
- // VKEY_PA1 (FD) PA1 key
- // VKEY_OEM_CLEAR (FE) Clear key
- default:
- return 0;
- }
-
-}
-
-}
diff --git a/webkit/port/platform/chromium/KeyboardCodes.h b/webkit/port/platform/chromium/KeyboardCodes.h
deleted file mode 100644
index 3f4fa7d..0000000
--- a/webkit/port/platform/chromium/KeyboardCodes.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2008, 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 KeyboardCodes_h
-#define KeyboardCodes_h
-
-#include "config.h"
-
-#if PLATFORM(WIN_OS)
-#include "KeyboardCodesWin.h"
-#else
-#include "KeyboardCodesPosix.h"
-#endif
-
-#endif
diff --git a/webkit/port/platform/chromium/KeyboardCodesPosix.h b/webkit/port/platform/chromium/KeyboardCodesPosix.h
deleted file mode 100644
index 14344bf..0000000
--- a/webkit/port/platform/chromium/KeyboardCodesPosix.h
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 KeyboardCodesPosix_h
-#define KeyboardCodesPosix_h
-
-namespace WebCore {
-
-enum {
-
- // VKEY_LBUTTON (01) Left mouse button
- // VKEY_RBUTTON (02) Right mouse button
- // VKEY_CANCEL (03) Control-break processing
- // VKEY_MBUTTON (04) Middle mouse button (three-button mouse)
- // VKEY_XBUTTON1 (05)
- // VKEY_XBUTTON2 (06)
-
- // VKEY_BACK (08) BACKSPACE key
- VKEY_BACK = 0x08,
-
- // VKEY_TAB (09) TAB key
- VKEY_TAB = 0x09,
-
- // VKEY_CLEAR (0C) CLEAR key
- VKEY_CLEAR = 0x0C,
-
- // VKEY_RETURN (0D)
- VKEY_RETURN = 0x0D,
-
- // VKEY_SHIFT (10) SHIFT key
- VKEY_SHIFT = 0x10,
-
- // VKEY_CONTROL (11) CTRL key
- VKEY_CONTROL = 0x11,
-
- // VKEY_MENU (12) ALT key
- VKEY_MENU = 0x12,
-
- // VKEY_PAUSE (13) PAUSE key
- VKEY_PAUSE = 0x13,
-
- // VKEY_CAPITAL (14) CAPS LOCK key
- VKEY_CAPITAL = 0x14,
-
- // VKEY_KANA (15) Input Method Editor (IME) Kana mode
- VKEY_KANA = 0x15,
-
- // VKEY_HANGUEL (15) IME Hanguel mode (maintained for compatibility, use VKEY_HANGUL)
- // VKEY_HANGUL (15) IME Hangul mode
- VKEY_HANGUL = 0x15,
-
- // VKEY_JUNJA (17) IME Junja mode
- VKEY_JUNJA = 0x17,
-
- // VKEY_FINAL (18) IME final mode
- VKEY_FINAL = 0x18,
-
- // VKEY_HANJA (19) IME Hanja mode
- VKEY_HANJA = 0x19,
-
- // VKEY_KANJI (19) IME Kanji mode
- VKEY_KANJI = 0x19,
-
- // VKEY_ESCAPE (1B) ESC key
- VKEY_ESCAPE = 0x1B,
-
- // VKEY_CONVERT (1C) IME convert
- VKEY_CONVERT = 0x1C,
-
- // VKEY_NONCONVERT (1D) IME nonconvert
- VKEY_NONCONVERT = 0x1D,
-
- // VKEY_ACCEPT (1E) IME accept
- VKEY_ACCEPT = 0x1E,
-
- // VKEY_MODECHANGE (1F) IME mode change request
- VKEY_MODECHANGE = 0x1F,
-
- // VKEY_SPACE (20) SPACEBAR
- VKEY_SPACE = 0x20,
-
- // VKEY_PRIOR (21) PAGE UP key
- VKEY_PRIOR = 0x21,
-
- // VKEY_NEXT (22) PAGE DOWN key
- VKEY_NEXT = 0x22,
-
- // VKEY_END (23) END key
- VKEY_END = 0x23,
-
- // VKEY_HOME (24) HOME key
- VKEY_HOME = 0x24,
-
- // VKEY_LEFT (25) LEFT ARROW key
- VKEY_LEFT = 0x25,
-
- // VKEY_UP (26) UP ARROW key
- VKEY_UP = 0x26,
-
- // VKEY_RIGHT (27) RIGHT ARROW key
- VKEY_RIGHT = 0x27,
-
- // VKEY_DOWN (28) DOWN ARROW key
- VKEY_DOWN = 0x28,
-
- // VKEY_SELECT (29) SELECT key
- VKEY_SELECT = 0x29,
-
- // VKEY_PRINT (2A) PRINT key
- VKEY_PRINT = 0x2A,
-
- // VKEY_EXECUTE (2B) EXECUTE key
- VKEY_EXECUTE = 0x2B,
-
- // VKEY_SNAPSHOT (2C) PRINT SCREEN key
- VKEY_SNAPSHOT = 0x2C,
-
- // VKEY_INSERT (2D) INS key
- VKEY_INSERT = 0x2D,
-
- // VKEY_DELETE (2E) DEL key
- VKEY_DELETE = 0x2E,
-
- // VKEY_HELP (2F) HELP key
- VKEY_HELP = 0x2F,
-
- // (30) 0 key
- VKEY_0 = 0x30,
-
- // (31) 1 key
- VKEY_1 = 0x31,
-
- // (32) 2 key
- VKEY_2 = 0x32,
-
- // (33) 3 key
- VKEY_3 = 0x33,
-
- // (34) 4 key
- VKEY_4 = 0x34,
-
- // (35) 5 key,
-
- VKEY_5 = 0x35,
-
- // (36) 6 key
- VKEY_6 = 0x36,
-
- // (37) 7 key
- VKEY_7 = 0x37,
-
- // (38) 8 key
- VKEY_8 = 0x38,
-
- // (39) 9 key
- VKEY_9 = 0x39,
-
- // (41) A key
- VKEY_A = 0x41,
-
- // (42) B key
- VKEY_B = 0x42,
-
- // (43) C key
- VKEY_C = 0x43,
-
- // (44) D key
- VKEY_D = 0x44,
-
- // (45) E key
- VKEY_E = 0x45,
-
- // (46) F key
- VKEY_F = 0x46,
-
- // (47) G key
- VKEY_G = 0x47,
-
- // (48) H key
- VKEY_H = 0x48,
-
- // (49) I key
- VKEY_I = 0x49,
-
- // (4A) J key
- VKEY_J = 0x4A,
-
- // (4B) K key
- VKEY_K = 0x4B,
-
- // (4C) L key
- VKEY_L = 0x4C,
-
- // (4D) M key
- VKEY_M = 0x4D,
-
- // (4E) N key
- VKEY_N = 0x4E,
-
- // (4F) O key
- VKEY_O = 0x4F,
-
- // (50) P key
- VKEY_P = 0x50,
-
- // (51) Q key
- VKEY_Q = 0x51,
-
- // (52) R key
- VKEY_R = 0x52,
-
- // (53) S key
- VKEY_S = 0x53,
-
- // (54) T key
- VKEY_T = 0x54,
-
- // (55) U key
- VKEY_U = 0x55,
-
- // (56) V key
- VKEY_V = 0x56,
-
- // (57) W key
- VKEY_W = 0x57,
-
- // (58) X key
- VKEY_X = 0x58,
-
- // (59) Y key
- VKEY_Y = 0x59,
-
- // (5A) Z key
- VKEY_Z = 0x5A,
-
- // VKEY_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
- VKEY_LWIN = 0x5B,
-
- // VKEY_RWIN (5C) Right Windows key (Natural keyboard)
- VKEY_RWIN = 0x5C,
-
- // VKEY_APPS (5D) Applications key (Natural keyboard)
- VKEY_APPS = 0x5D,
-
- // VKEY_SLEEP (5F) Computer Sleep key
- VKEY_SLEEP = 0x5F,
-
- // VKEY_NUMPAD0 (60) Numeric keypad 0 key
- VKEY_NUMPAD0 = 0x60,
-
- // VKEY_NUMPAD1 (61) Numeric keypad 1 key
- VKEY_NUMPAD1 = 0x61,
-
- // VKEY_NUMPAD2 (62) Numeric keypad 2 key
- VKEY_NUMPAD2 = 0x62,
-
- // VKEY_NUMPAD3 (63) Numeric keypad 3 key
- VKEY_NUMPAD3 = 0x63,
-
- // VKEY_NUMPAD4 (64) Numeric keypad 4 key
- VKEY_NUMPAD4 = 0x64,
-
- // VKEY_NUMPAD5 (65) Numeric keypad 5 key
- VKEY_NUMPAD5 = 0x65,
-
- // VKEY_NUMPAD6 (66) Numeric keypad 6 key
- VKEY_NUMPAD6 = 0x66,
-
- // VKEY_NUMPAD7 (67) Numeric keypad 7 key
- VKEY_NUMPAD7 = 0x67,
-
- // VKEY_NUMPAD8 (68) Numeric keypad 8 key
- VKEY_NUMPAD8 = 0x68,
-
- // VKEY_NUMPAD9 (69) Numeric keypad 9 key
- VKEY_NUMPAD9 = 0x69,
-
- // VKEY_MULTIPLY (6A) Multiply key
- VKEY_MULTIPLY = 0x6A,
-
- // VKEY_ADD (6B) Add key
- VKEY_ADD = 0x6B,
-
- // VKEY_SEPARATOR (6C) Separator key
- VKEY_SEPARATOR = 0x6C,
-
- // VKEY_SUBTRACT (6D) Subtract key
- VKEY_SUBTRACT = 0x6D,
-
- // VKEY_DECIMAL (6E) Decimal key
- VKEY_DECIMAL = 0x6E,
-
- // VKEY_DIVIDE (6F) Divide key
- VKEY_DIVIDE = 0x6F,
-
- // VKEY_F1 (70) F1 key
- VKEY_F1 = 0x70,
-
- // VKEY_F2 (71) F2 key
- VKEY_F2 = 0x71,
-
- // VKEY_F3 (72) F3 key
- VKEY_F3 = 0x72,
-
- // VKEY_F4 (73) F4 key
- VKEY_F4 = 0x73,
-
- // VKEY_F5 (74) F5 key
- VKEY_F5 = 0x74,
-
- // VKEY_F6 (75) F6 key
- VKEY_F6 = 0x75,
-
- // VKEY_F7 (76) F7 key
- VKEY_F7 = 0x76,
-
- // VKEY_F8 (77) F8 key
- VKEY_F8 = 0x77,
-
- // VKEY_F9 (78) F9 key
- VKEY_F9 = 0x78,
-
- // VKEY_F10 (79) F10 key
- VKEY_F10 = 0x79,
-
- // VKEY_F11 (7A) F11 key
- VKEY_F11 = 0x7A,
-
- // VKEY_F12 (7B) F12 key
- VKEY_F12 = 0x7B,
-
- // VKEY_F13 (7C) F13 key
- VKEY_F13 = 0x7C,
-
- // VKEY_F14 (7D) F14 key
- VKEY_F14 = 0x7D,
-
- // VKEY_F15 (7E) F15 key
- VKEY_F15 = 0x7E,
-
- // VKEY_F16 (7F) F16 key
- VKEY_F16 = 0x7F,
-
- // VKEY_F17 (80H) F17 key
- VKEY_F17 = 0x80,
-
- // VKEY_F18 (81H) F18 key
- VKEY_F18 = 0x81,
-
- // VKEY_F19 (82H) F19 key
- VKEY_F19 = 0x82,
-
- // VKEY_F20 (83H) F20 key
- VKEY_F20 = 0x83,
-
- // VKEY_F21 (84H) F21 key
- VKEY_F21 = 0x84,
-
- // VKEY_F22 (85H) F22 key
- VKEY_F22 = 0x85,
-
- // VKEY_F23 (86H) F23 key
- VKEY_F23 = 0x86,
-
- // VKEY_F24 (87H) F24 key
- VKEY_F24 = 0x87,
-
- // VKEY_NUMLOCK (90) NUM LOCK key
- VKEY_NUMLOCK = 0x90,
-
- // VKEY_SCROLL (91) SCROLL LOCK key
- VKEY_SCROLL = 0x91,
-
- // VKEY_LSHIFT (A0) Left SHIFT key
- VKEY_LSHIFT = 0xA0,
-
- // VKEY_RSHIFT (A1) Right SHIFT key
- VKEY_RSHIFT = 0xA1,
-
- // VKEY_LCONTROL (A2) Left CONTROL key
- VKEY_LCONTROL = 0xA2,
-
- // VKEY_RCONTROL (A3) Right CONTROL key
- VKEY_RCONTROL = 0xA3,
-
- // VKEY_LMENU (A4) Left MENU key
- VKEY_LMENU = 0xA4,
-
- // VKEY_RMENU (A5) Right MENU key
- VKEY_RMENU = 0xA5,
-
- // VKEY_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
- VKEY_BROWSER_BACK = 0xA6,
-
- // VKEY_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
- VKEY_BROWSER_FORWARD = 0xA7,
-
- // VKEY_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
- VKEY_BROWSER_REFRESH = 0xA8,
-
- // VKEY_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
- VKEY_BROWSER_STOP = 0xA9,
-
- // VKEY_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
- VKEY_BROWSER_SEARCH = 0xAA,
-
- // VKEY_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
- VKEY_BROWSER_FAVORITES = 0xAB,
-
- // VKEY_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
- VKEY_BROWSER_HOME = 0xAC,
-
- // VKEY_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
- VKEY_VOLUME_MUTE = 0xAD,
-
- // VKEY_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
- VKEY_VOLUME_DOWN = 0xAE,
-
- // VKEY_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
- VKEY_VOLUME_UP = 0xAF,
-
- // VKEY_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
- VKEY_MEDIA_NEXT_TRACK = 0xB0,
-
- // VKEY_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
- VKEY_MEDIA_PREV_TRACK = 0xB1,
-
- // VKEY_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
- VKEY_MEDIA_STOP = 0xB2,
-
- // VKEY_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
- VKEY_MEDIA_PLAY_PAUSE = 0xB3,
-
- // VKEY_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
- VKEY_MEDIA_LAUNCH_MAIL = 0xB4,
-
- // VKEY_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
- VKEY_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5,
-
- // VKEY_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
- VKEY_MEDIA_LAUNCH_APP1 = 0xB6,
-
- // VKEY_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
- VKEY_MEDIA_LAUNCH_APP2 = 0xB7,
-
- // VKEY_OEM_1 (BA) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ',:' key
- VKEY_OEM_1 = 0xBA,
-
- // VKEY_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
- VKEY_OEM_PLUS = 0xBB,
-
- // VKEY_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
- VKEY_OEM_COMMA = 0xBC,
-
- // VKEY_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
- VKEY_OEM_MINUS = 0xBD,
-
- // VKEY_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
- VKEY_OEM_PERIOD = 0xBE,
-
- // VKEY_OEM_2 (BF) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
- VKEY_OEM_2 = 0xBF,
-
- // VKEY_OEM_3 (C0) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
- VKEY_OEM_3 = 0xC0,
-
- // VKEY_OEM_4 (DB) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
- VKEY_OEM_4 = 0xDB,
-
- // VKEY_OEM_5 (DC) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
- VKEY_OEM_5 = 0xDC,
-
- // VKEY_OEM_6 (DD) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
- VKEY_OEM_6 = 0xDD,
-
- // VKEY_OEM_7 (DE) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
- VKEY_OEM_7 = 0xDE,
-
- // VKEY_OEM_8 (DF) Used for miscellaneous characters, it can vary by keyboard.
- VKEY_OEM_8 = 0xDF,
-
- // VKEY_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
- VKEY_OEM_102 = 0xE2,
-
- // VKEY_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
- VKEY_PROCESSKEY = 0xE5,
-
- // VKEY_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VKEY_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
- VKEY_PACKET = 0xE7,
-
- // VKEY_ATTN (F6) Attn key
- VKEY_ATTN = 0xF6,
-
- // VKEY_CRSEL (F7) CrSel key
- VKEY_CRSEL = 0xF7,
-
- // VKEY_EXSEL (F8) ExSel key
- VKEY_EXSEL = 0xF8,
-
- // VKEY_EREOF (F9) Erase EOF key
- VKEY_EREOF = 0xF9,
-
- // VKEY_PLAY (FA) Play key
- VKEY_PLAY = 0xFA,
-
- // VKEY_ZOOM (FB) Zoom key
- VKEY_ZOOM = 0xFB,
-
- // VKEY_NONAME (FC) Reserved for future use
- VKEY_NONAME = 0xFC,
-
- // VKEY_PA1 (FD) PA1 key
- VKEY_PA1 = 0xFD,
-
- // VKEY_OEM_CLEAR (FE) Clear key
- VKEY_OEM_CLEAR = 0xFE,
-
- VKEY_UNKNOWN = 0
-
-};
-
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/KeyboardCodesWin.h b/webkit/port/platform/chromium/KeyboardCodesWin.h
deleted file mode 100644
index e23fadc..0000000
--- a/webkit/port/platform/chromium/KeyboardCodesWin.h
+++ /dev/null
@@ -1,552 +0,0 @@
-// Copyright (c) 2008, 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 KeyboardCodesWin_h
-#define KeyboardCodesWin_h
-
-#include <windows.h>
-
-namespace WebCore {
-
-enum {
-
- // VKEY_LBUTTON (01) Left mouse button
- // VKEY_RBUTTON (02) Right mouse button
- // VKEY_CANCEL (03) Control-break processing
- // VKEY_MBUTTON (04) Middle mouse button (three-button mouse)
- // VKEY_XBUTTON1 (05)
- // VKEY_XBUTTON2 (06)
-
- // VKEY_BACK (08) BACKSPACE key
- VKEY_BACK = VK_BACK,
-
- // VKEY_TAB (09) TAB key
- VKEY_TAB = VK_TAB,
-
- // VKEY_CLEAR (0C) CLEAR key
- VKEY_CLEAR = VK_CLEAR,
-
- // VKEY_RETURN (0D)
- VKEY_RETURN = VK_RETURN,
-
- // VKEY_SHIFT (10) SHIFT key
- VKEY_SHIFT = VK_SHIFT,
-
- // VKEY_CONTROL (11) CTRL key
- VKEY_CONTROL = VK_CONTROL,
-
- // VKEY_MENU (12) ALT key
- VKEY_MENU = VK_MENU,
-
- // VKEY_PAUSE (13) PAUSE key
- VKEY_PAUSE = VK_PAUSE,
-
- // VKEY_CAPITAL (14) CAPS LOCK key
- VKEY_CAPITAL = VK_CAPITAL,
-
- // VKEY_KANA (15) Input Method Editor (IME) Kana mode
- VKEY_KANA = VK_KANA,
-
- // VKEY_HANGUEL (15) IME Hanguel mode (maintained for compatibility, use VKEY_HANGUL)
- // VKEY_HANGUL (15) IME Hangul mode
- VKEY_HANGUL = VK_HANGUL,
-
- // VKEY_JUNJA (17) IME Junja mode
- VKEY_JUNJA = VK_JUNJA,
-
- // VKEY_FINAL (18) IME final mode
- VKEY_FINAL = VK_FINAL,
-
- // VKEY_HANJA (19) IME Hanja mode
- VKEY_HANJA = VK_HANJA,
-
- // VKEY_KANJI (19) IME Kanji mode
- VKEY_KANJI = VK_KANJI,
-
- // VKEY_ESCAPE (1B) ESC key
- VKEY_ESCAPE = VK_ESCAPE,
-
- // VKEY_CONVERT (1C) IME convert
- VKEY_CONVERT = VK_CONVERT,
-
- // VKEY_NONCONVERT (1D) IME nonconvert
- VKEY_NONCONVERT = VK_NONCONVERT,
-
- // VKEY_ACCEPT (1E) IME accept
- VKEY_ACCEPT = VK_ACCEPT,
-
- // VKEY_MODECHANGE (1F) IME mode change request
- VKEY_MODECHANGE = VK_MODECHANGE,
-
- // VKEY_SPACE (20) SPACEBAR
- VKEY_SPACE = VK_SPACE,
-
- // VKEY_PRIOR (21) PAGE UP key
- VKEY_PRIOR = VK_PRIOR,
-
- // VKEY_NEXT (22) PAGE DOWN key
- VKEY_NEXT = VK_NEXT,
-
- // VKEY_END (23) END key
- VKEY_END = VK_END,
-
- // VKEY_HOME (24) HOME key
- VKEY_HOME = VK_HOME,
-
- // VKEY_LEFT (25) LEFT ARROW key
- VKEY_LEFT = VK_LEFT,
-
- // VKEY_UP (26) UP ARROW key
- VKEY_UP = VK_UP,
-
- // VKEY_RIGHT (27) RIGHT ARROW key
- VKEY_RIGHT = VK_RIGHT,
-
- // VKEY_DOWN (28) DOWN ARROW key
- VKEY_DOWN = VK_DOWN,
-
- // VKEY_SELECT (29) SELECT key
- VKEY_SELECT = VK_SELECT,
-
- // VKEY_PRINT (2A) PRINT key
- VKEY_PRINT = VK_PRINT,
-
- // VKEY_EXECUTE (2B) EXECUTE key
- VKEY_EXECUTE = VK_EXECUTE,
-
- // VKEY_SNAPSHOT (2C) PRINT SCREEN key
- VKEY_SNAPSHOT = VK_SNAPSHOT,
-
- // VKEY_INSERT (2D) INS key
- VKEY_INSERT = VK_INSERT,
-
- // VKEY_DELETE (2E) DEL key
- VKEY_DELETE = VK_DELETE,
-
- // VKEY_HELP (2F) HELP key
- VKEY_HELP = VK_HELP,
-
- // (30) 0 key
- VKEY_0 = '0',
-
- // (31) 1 key
- VKEY_1 = '1',
-
- // (32) 2 key
- VKEY_2 = '2',
-
- // (33) 3 key
- VKEY_3 = '3',
-
- // (34) 4 key
- VKEY_4 = '4',
-
- // (35) 5 key,
-
- VKEY_5 = '5',
-
- // (36) 6 key
- VKEY_6 = '6',
-
- // (37) 7 key
- VKEY_7 = '7',
-
- // (38) 8 key
- VKEY_8 = '8',
-
- // (39) 9 key
- VKEY_9 = '9',
-
- // (41) A key
- VKEY_A = 'A',
-
- // (42) B key
- VKEY_B = 'B',
-
- // (43) C key
- VKEY_C = 'C',
-
- // (44) D key
- VKEY_D = 'D',
-
- // (45) E key
- VKEY_E = 'E',
-
- // (46) F key
- VKEY_F = 'F',
-
- // (47) G key
- VKEY_G = 'G',
-
- // (48) H key
- VKEY_H = 'H',
-
- // (49) I key
- VKEY_I = 'I',
-
- // (4A) J key
- VKEY_J = 'J',
-
- // (4B) K key
- VKEY_K = 'K',
-
- // (4C) L key
- VKEY_L = 'L',
-
- // (4D) M key
- VKEY_M = 'M',
-
- // (4E) N key
- VKEY_N = 'N',
-
- // (4F) O key
- VKEY_O = 'O',
-
- // (50) P key
- VKEY_P = 'P',
-
- // (51) Q key
- VKEY_Q = 'Q',
-
- // (52) R key
- VKEY_R = 'R',
-
- // (53) S key
- VKEY_S = 'S',
-
- // (54) T key
- VKEY_T = 'T',
-
- // (55) U key
- VKEY_U = 'U',
-
- // (56) V key
- VKEY_V = 'V',
-
- // (57) W key
- VKEY_W = 'W',
-
- // (58) X key
- VKEY_X = 'X',
-
- // (59) Y key
- VKEY_Y = 'Y',
-
- // (5A) Z key
- VKEY_Z = 'Z',
-
- // VKEY_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
- VKEY_LWIN = VK_LWIN,
-
- // VKEY_RWIN (5C) Right Windows key (Natural keyboard)
- VKEY_RWIN = VK_RWIN,
-
- // VKEY_APPS (5D) Applications key (Natural keyboard)
- VKEY_APPS = VK_APPS,
-
- // VKEY_SLEEP (5F) Computer Sleep key
- VKEY_SLEEP = VK_SLEEP,
-
- // VKEY_NUMPAD0 (60) Numeric keypad 0 key
- VKEY_NUMPAD0 = VK_NUMPAD0,
-
- // VKEY_NUMPAD1 (61) Numeric keypad 1 key
- VKEY_NUMPAD1 = VK_NUMPAD1,
-
- // VKEY_NUMPAD2 (62) Numeric keypad 2 key
- VKEY_NUMPAD2 = VK_NUMPAD2,
-
- // VKEY_NUMPAD3 (63) Numeric keypad 3 key
- VKEY_NUMPAD3 = VK_NUMPAD3,
-
- // VKEY_NUMPAD4 (64) Numeric keypad 4 key
- VKEY_NUMPAD4 = VK_NUMPAD4,
-
- // VKEY_NUMPAD5 (65) Numeric keypad 5 key
- VKEY_NUMPAD5 = VK_NUMPAD5,
-
- // VKEY_NUMPAD6 (66) Numeric keypad 6 key
- VKEY_NUMPAD6 = VK_NUMPAD6,
-
- // VKEY_NUMPAD7 (67) Numeric keypad 7 key
- VKEY_NUMPAD7 = VK_NUMPAD7,
-
- // VKEY_NUMPAD8 (68) Numeric keypad 8 key
- VKEY_NUMPAD8 = VK_NUMPAD8,
-
- // VKEY_NUMPAD9 (69) Numeric keypad 9 key
- VKEY_NUMPAD9 = VK_NUMPAD9,
-
- // VKEY_MULTIPLY (6A) Multiply key
- VKEY_MULTIPLY = VK_MULTIPLY,
-
- // VKEY_ADD (6B) Add key
- VKEY_ADD = VK_ADD,
-
- // VKEY_SEPARATOR (6C) Separator key
- VKEY_SEPARATOR = VK_SEPARATOR,
-
- // VKEY_SUBTRACT (6D) Subtract key
- VKEY_SUBTRACT = VK_SUBTRACT,
-
- // VKEY_DECIMAL (6E) Decimal key
- VKEY_DECIMAL = VK_DECIMAL,
-
- // VKEY_DIVIDE (6F) Divide key
- VKEY_DIVIDE = VK_DIVIDE,
-
- // VKEY_F1 (70) F1 key
- VKEY_F1 = VK_F1,
-
- // VKEY_F2 (71) F2 key
- VKEY_F2 = VK_F2,
-
- // VKEY_F3 (72) F3 key
- VKEY_F3 = VK_F3,
-
- // VKEY_F4 (73) F4 key
- VKEY_F4 = VK_F4,
-
- // VKEY_F5 (74) F5 key
- VKEY_F5 = VK_F5,
-
- // VKEY_F6 (75) F6 key
- VKEY_F6 = VK_F6,
-
- // VKEY_F7 (76) F7 key
- VKEY_F7 = VK_F7,
-
- // VKEY_F8 (77) F8 key
- VKEY_F8 = VK_F8,
-
- // VKEY_F9 (78) F9 key
- VKEY_F9 = VK_F9,
-
- // VKEY_F10 (79) F10 key
- VKEY_F10 = VK_F10,
-
- // VKEY_F11 (7A) F11 key
- VKEY_F11 = VK_F11,
-
- // VKEY_F12 (7B) F12 key
- VKEY_F12 = VK_F12,
-
- // VKEY_F13 (7C) F13 key
- VKEY_F13 = VK_F13,
-
- // VKEY_F14 (7D) F14 key
- VKEY_F14 = VK_F14,
-
- // VKEY_F15 (7E) F15 key
- VKEY_F15 = VK_F15,
-
- // VKEY_F16 (7F) F16 key
- VKEY_F16 = VK_F16,
-
- // VKEY_F17 (80H) F17 key
- VKEY_F17 = VK_F17,
-
- // VKEY_F18 (81H) F18 key
- VKEY_F18 = VK_F18,
-
- // VKEY_F19 (82H) F19 key
- VKEY_F19 = VK_F19,
-
- // VKEY_F20 (83H) F20 key
- VKEY_F20 = VK_F20,
-
- // VKEY_F21 (84H) F21 key
- VKEY_F21 = VK_F21,
-
- // VKEY_F22 (85H) F22 key
- VKEY_F22 = VK_F22,
-
- // VKEY_F23 (86H) F23 key
- VKEY_F23 = VK_F23,
-
- // VKEY_F24 (87H) F24 key
- VKEY_F24 = VK_F24,
-
- // VKEY_NUMLOCK (90) NUM LOCK key
- VKEY_NUMLOCK = VK_NUMLOCK,
-
- // VKEY_SCROLL (91) SCROLL LOCK key
- VKEY_SCROLL = VK_SCROLL,
-
- // VKEY_LSHIFT (A0) Left SHIFT key
- VKEY_LSHIFT = VK_LSHIFT,
-
- // VKEY_RSHIFT (A1) Right SHIFT key
- VKEY_RSHIFT = VK_RSHIFT,
-
- // VKEY_LCONTROL (A2) Left CONTROL key
- VKEY_LCONTROL = VK_LCONTROL,
-
- // VKEY_RCONTROL (A3) Right CONTROL key
- VKEY_RCONTROL = VK_RCONTROL,
-
- // VKEY_LMENU (A4) Left MENU key
- VKEY_LMENU = VK_LMENU,
-
- // VKEY_RMENU (A5) Right MENU key
- VKEY_RMENU = VK_RMENU,
-
- // VKEY_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
- VKEY_BROWSER_BACK = VK_BROWSER_BACK,
-
- // VKEY_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
- VKEY_BROWSER_FORWARD = VK_BROWSER_FORWARD,
-
- // VKEY_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
- VKEY_BROWSER_REFRESH = VK_BROWSER_REFRESH,
-
- // VKEY_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
- VKEY_BROWSER_STOP = VK_BROWSER_STOP,
-
- // VKEY_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
- VKEY_BROWSER_SEARCH = VK_BROWSER_SEARCH,
-
- // VKEY_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
- VKEY_BROWSER_FAVORITES = VK_BROWSER_FAVORITES,
-
- // VKEY_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
- VKEY_BROWSER_HOME = VK_BROWSER_HOME,
-
- // VKEY_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
- VKEY_VOLUME_MUTE = VK_VOLUME_MUTE,
-
- // VKEY_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
- VKEY_VOLUME_DOWN = VK_VOLUME_DOWN,
-
- // VKEY_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
- VKEY_VOLUME_UP = VK_VOLUME_UP,
-
- // VKEY_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
- VKEY_MEDIA_NEXT_TRACK = VK_MEDIA_NEXT_TRACK,
-
- // VKEY_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
- VKEY_MEDIA_PREV_TRACK = VK_MEDIA_PREV_TRACK,
-
- // VKEY_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
- VKEY_MEDIA_STOP = VK_MEDIA_STOP,
-
- // VKEY_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
- VKEY_MEDIA_PLAY_PAUSE = VK_MEDIA_PLAY_PAUSE,
-
- // VKEY_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
- VKEY_MEDIA_LAUNCH_MAIL = 0xB4,
-
- // VKEY_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
- VKEY_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5,
-
- // VKEY_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
- VKEY_MEDIA_LAUNCH_APP1 = 0xB6,
-
- // VKEY_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
- VKEY_MEDIA_LAUNCH_APP2 = 0xB7,
-
- // VKEY_OEM_1 (BA) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ',:' key
- VKEY_OEM_1 = VK_OEM_1,
-
- // VKEY_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
- VKEY_OEM_PLUS = VK_OEM_PLUS,
-
- // VKEY_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
- VKEY_OEM_COMMA = VK_OEM_COMMA,
-
- // VKEY_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
- VKEY_OEM_MINUS = VK_OEM_MINUS,
-
- // VKEY_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
- VKEY_OEM_PERIOD = VK_OEM_PERIOD,
-
- // VKEY_OEM_2 (BF) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
- VKEY_OEM_2 = VK_OEM_2,
-
- // VKEY_OEM_3 (C0) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
- VKEY_OEM_3 = VK_OEM_3,
-
- // VKEY_OEM_4 (DB) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
- VKEY_OEM_4 = VK_OEM_4,
-
- // VKEY_OEM_5 (DC) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
- VKEY_OEM_5 = VK_OEM_5,
-
- // VKEY_OEM_6 (DD) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
- VKEY_OEM_6 = VK_OEM_6,
-
- // VKEY_OEM_7 (DE) Used for miscellaneous characters, it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
- VKEY_OEM_7 = VK_OEM_7,
-
- // VKEY_OEM_8 (DF) Used for miscellaneous characters, it can vary by keyboard.
- VKEY_OEM_8 = VK_OEM_8,
-
- // VKEY_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
- VKEY_OEM_102 = VK_OEM_102,
-
- // VKEY_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
- VKEY_PROCESSKEY = VK_PROCESSKEY,
-
- // VKEY_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VKEY_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
- VKEY_PACKET = VK_PACKET,
-
- // VKEY_ATTN (F6) Attn key
- VKEY_ATTN = VK_ATTN,
-
- // VKEY_CRSEL (F7) CrSel key
- VKEY_CRSEL = VK_CRSEL,
-
- // VKEY_EXSEL (F8) ExSel key
- VKEY_EXSEL = VK_EXSEL,
-
- // VKEY_EREOF (F9) Erase EOF key
- VKEY_EREOF = VK_EREOF,
-
- // VKEY_PLAY (FA) Play key
- VKEY_PLAY = VK_PLAY,
-
- // VKEY_ZOOM (FB) Zoom key
- VKEY_ZOOM = VK_ZOOM,
-
- // VKEY_NONAME (FC) Reserved for future use
- VKEY_NONAME = VK_NONAME,
-
- // VKEY_PA1 (FD) PA1 key
- VKEY_PA1 = VK_PA1,
-
- // VKEY_OEM_CLEAR (FE) Clear key
- VKEY_OEM_CLEAR = VK_OEM_CLEAR,
-
- VKEY_UNKNOWN = 0
-
-};
-
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/Language.cpp b/webkit/port/platform/chromium/Language.cpp
deleted file mode 100644
index 343cac2..0000000
--- a/webkit/port/platform/chromium/Language.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2008, 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 "Language.h"
-
-#include "ChromiumBridge.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-String defaultLanguage()
-{
- static String computedDefaultLanguage;
- if (computedDefaultLanguage.isEmpty())
- computedDefaultLanguage = ChromiumBridge::computedDefaultLanguage();
- return computedDefaultLanguage;
-}
-
-}
diff --git a/webkit/port/platform/chromium/LinkHashChromium.cpp b/webkit/port/platform/chromium/LinkHashChromium.cpp
deleted file mode 100644
index 91a7195..0000000
--- a/webkit/port/platform/chromium/LinkHashChromium.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2008, 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 "LinkHash.h"
-
-#include "ChromiumBridge.h"
-
-namespace WebCore {
-
-LinkHash visitedLinkHash(const UChar* url, unsigned length)
-{
- return ChromiumBridge::visitedLinkHash(url, length);
-}
-
-LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL)
-{
- return ChromiumBridge::visitedLinkHash(base, attributeURL);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp b/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp
deleted file mode 100644
index 7f83d90..0000000
--- a/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) 2008, 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 "MIMETypeRegistry.h"
-
-#include "ChromiumBridge.h"
-#include "CString.h"
-#include "MediaPlayer.h"
-
-// NOTE: Unlike other ports, we don't use the shared implementation bits in
-// MIMETypeRegistry.cpp. Instead, we need to route most functions via the
-// ChromiumBridge to the embedder.
-
-namespace WebCore
-{
-
-// Checks if any of the plugins handle this extension, and if so returns the
-// plugin's mime type for this extension. Otherwise returns an empty string.
-// See PluginsChromium.cpp for the implementation of this function.
-String getPluginMimeTypeFromExtension(const String& extension);
-
-String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
-{
- return ChromiumBridge::mimeTypeForExtension(ext);
-}
-
-// Returns the file extension if one is found. Does not include the dot in the
-// filename. E.g., 'html'.
-String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
-{
- // Prune out any parameters in case they happen to have snuck in there...
- // TODO(darin): Is this really necessary??
- String mimeType = type.substring(0, static_cast<unsigned>(type.find(';')));
-
- String ext = ChromiumBridge::preferredExtensionForMIMEType(type);
- if (!ext.isEmpty() && ext[0] == L'.')
- ext = ext.substring(1);
-
- return ext;
-}
-
-String MIMETypeRegistry::getMIMETypeForPath(const String& path)
-{
- int pos = path.reverseFind('.');
- if (pos < 0)
- return "application/octet-stream";
- String extension = path.substring(pos + 1);
- String mimeType = getMIMETypeForExtension(extension);
- if (mimeType.isEmpty()) {
- // If there's no mimetype registered for the extension, check to see
- // if a plugin can handle the extension.
- mimeType = getPluginMimeTypeFromExtension(extension);
- }
- return mimeType;
-}
-
-bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType)
-{
- return !mimeType.isEmpty()
- && ChromiumBridge::isSupportedImageMIMEType(mimeType.latin1().data());
-}
-
-bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType)
-{
- return isSupportedImageMIMEType(mimeType);
-}
-
-bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeType)
-{
- // TODO(brettw) fill this out. See: http://trac.webkit.org/changeset/30888
- return isSupportedImageMIMEType(mimeType);
-}
-
-bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType)
-{
- return !mimeType.isEmpty()
- && ChromiumBridge::isSupportedJavascriptMIMEType(mimeType.latin1().data());
-}
-
-bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType)
-{
- return !mimeType.isEmpty()
- && ChromiumBridge::isSupportedNonImageMIMEType(mimeType.latin1().data());
-}
-
-bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType)
-{
- HashSet<String> supportedMediaMIMETypes;
-#if ENABLE(VIDEO)
- MediaPlayer::getSupportedTypes(supportedMediaMIMETypes);
-#endif
- return !mimeType.isEmpty() && supportedMediaMIMETypes.contains(mimeType);
-}
-
-bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType)
-{
- // Since this set is very limited and is likely to remain so we won't bother with the overhead
- // of using a hash set.
- // Any of the MIME types below may be followed by any number of specific versions of the JVM,
- // which is why we use startsWith()
- return mimeType.startsWith("application/x-java-applet", false)
- || mimeType.startsWith("application/x-java-bean", false)
- || mimeType.startsWith("application/x-java-vm", false);
-}
-
-static HashSet<String>& dummyHashSet()
-{
- ASSERT_NOT_REACHED();
- static HashSet<String> dummy;
- return dummy;
-}
-
-// NOTE: the following methods should never be reached
-HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypes() { return dummyHashSet(); }
-HashSet<String>& MIMETypeRegistry::getSupportedImageResourceMIMETypes() { return dummyHashSet(); }
-HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding() { return dummyHashSet(); }
-HashSet<String>& MIMETypeRegistry::getSupportedNonImageMIMETypes() { return dummyHashSet(); }
-HashSet<String>& MIMETypeRegistry::getSupportedMediaMIMETypes() { return dummyHashSet(); }
-
-}
diff --git a/webkit/port/platform/chromium/PasteboardChromium.cpp b/webkit/port/platform/chromium/PasteboardChromium.cpp
deleted file mode 100644
index 0ae7981b3..0000000
--- a/webkit/port/platform/chromium/PasteboardChromium.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "Pasteboard.h"
-
-#include "ChromiumBridge.h"
-#include "ClipboardUtilitiesChromium.h"
-#include "CString.h"
-#include "DocumentFragment.h"
-#include "Document.h"
-#include "Element.h"
-#include "Frame.h"
-#include "HitTestResult.h"
-#include "HTMLNames.h"
-#include "Image.h"
-#include "KURL.h"
-#include "NativeImageSkia.h"
-#include "NotImplemented.h"
-#include "Page.h"
-#include "Range.h"
-#include "RenderImage.h"
-#include "TextEncoding.h"
-#include "markup.h"
-
-#if ENABLE(SVG)
-#include "SVGNames.h"
-#include "XLinkNames.h"
-#endif
-
-namespace WebCore {
-
-Pasteboard* Pasteboard::generalPasteboard()
-{
- static Pasteboard* pasteboard = new Pasteboard;
- return pasteboard;
-}
-
-Pasteboard::Pasteboard()
-{
-}
-
-void Pasteboard::clear()
-{
- // The ScopedClipboardWriter class takes care of clearing the clipboard's
- // previous contents.
-}
-
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
-{
- String html = createMarkup(selectedRange, 0, AnnotateForInterchange);
- ExceptionCode ec = 0;
- KURL url = selectedRange->startContainer(ec)->document()->url();
- String plainText = frame->selectedText();
-#if PLATFORM(WIN_OS)
- replaceNewlinesWithWindowsStyleNewlines(plainText);
-#endif
- replaceNBSPWithSpace(plainText);
-
- ChromiumBridge::clipboardWriteSelection(html, url, plainText,
- canSmartCopyOrDelete);
-}
-
-void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame)
-{
- ASSERT(!url.isEmpty());
-
- String title(titleStr);
- if (title.isEmpty()) {
- title = url.lastPathComponent();
- if (title.isEmpty())
- title = url.host();
- }
-
- ChromiumBridge::clipboardWriteURL(url, title);
-}
-
-void Pasteboard::writeImage(Node* node, const KURL& link_url, const String& title)
-{
- // If the image is wrapped in a link, |url| points to the target of the
- // link. This isn't useful to us, so get the actual image URL.
- AtomicString urlString;
- if (node->hasTagName(HTMLNames::imgTag) || node->hasTagName(HTMLNames::inputTag))
- urlString = static_cast<Element*>(node)->getAttribute(HTMLNames::srcAttr);
-#if ENABLE(SVG)
- else if (node->hasTagName(SVGNames::imageTag))
- urlString = static_cast<Element*>(node)->getAttribute(XLinkNames::hrefAttr);
-#endif
- else if (node->hasTagName(HTMLNames::embedTag) || node->hasTagName(HTMLNames::objectTag)) {
- Element* element = static_cast<Element*>(node);
- urlString = element->getAttribute(element->imageSourceAttributeName());
- }
- KURL url = urlString.isEmpty() ? KURL() : node->document()->completeURL(parseURL(urlString));
-
- ASSERT(node && node->renderer() && node->renderer()->isImage());
- RenderImage* renderer = static_cast<RenderImage*>(node->renderer());
- CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
- ASSERT(cachedImage);
- Image* image = cachedImage->image();
- ASSERT(image);
-
- NativeImageSkia* bitmap = 0;
-#if !PLATFORM(CG)
- bitmap = image->nativeImageForCurrentFrame();
-#endif
- ChromiumBridge::clipboardWriteImage(bitmap, url, title);
-}
-
-bool Pasteboard::canSmartReplace()
-{
- return ChromiumBridge::clipboardIsFormatAvailable(
- PasteboardPrivate::WebSmartPasteFormat);
-}
-
-String Pasteboard::plainText(Frame* frame)
-{
- return ChromiumBridge::clipboardReadPlainText();
-}
-
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
-{
- chosePlainText = false;
-
- if (ChromiumBridge::clipboardIsFormatAvailable(
- PasteboardPrivate::HTMLFormat)) {
- String markup;
- KURL src_url;
- ChromiumBridge::clipboardReadHTML(&markup, &src_url);
-
- RefPtr<DocumentFragment> fragment =
- createFragmentFromMarkup(frame->document(), markup, src_url);
-
- if (fragment)
- return fragment.release();
- }
-
- if (allowPlainText) {
- String markup = ChromiumBridge::clipboardReadPlainText();
- if (!markup.isEmpty()) {
- chosePlainText = true;
- RefPtr<DocumentFragment> fragment =
- createFragmentFromText(context.get(), markup);
- if (fragment)
- return fragment.release();
- }
- }
-
- return 0;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/PasteboardPrivate.h b/webkit/port/platform/chromium/PasteboardPrivate.h
deleted file mode 100644
index 014e66f..0000000
--- a/webkit/port/platform/chromium/PasteboardPrivate.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2008, 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 PasteboardPrivate_h__
-#define PasteboardPrivate_h__
-
-namespace WebCore {
-
- class PasteboardPrivate
- {
- public:
- enum ClipboardFormat {
- HTMLFormat,
- BookmarkFormat,
- WebSmartPasteFormat,
- };
- };
-
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/PlatformCursor.h b/webkit/port/platform/chromium/PlatformCursor.h
deleted file mode 100644
index 8d5bd04..0000000
--- a/webkit/port/platform/chromium/PlatformCursor.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (c) 2008, 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 PlatformCursor_h
-#define PlatformCursor_h
-
-#include "Image.h"
-#include "IntPoint.h"
-#include "RefPtr.h"
-
-namespace WebCore {
- class PlatformCursor {
- public:
- enum Type {
- typePointer,
- typeCross,
- typeHand,
- typeIBeam,
- typeWait,
- typeHelp,
- typeEastResize,
- typeNorthResize,
- typeNorthEastResize,
- typeNorthWestResize,
- typeSouthResize,
- typeSouthEastResize,
- typeSouthWestResize,
- typeWestResize,
- typeNorthSouthResize,
- typeEastWestResize,
- typeNorthEastSouthWestResize,
- typeNorthWestSouthEastResize,
- typeColumnResize,
- typeRowResize,
- typeMiddlePanning,
- typeEastPanning,
- typeNorthPanning,
- typeNorthEastPanning,
- typeNorthWestPanning,
- typeSouthPanning,
- typeSouthEastPanning,
- typeSouthWestPanning,
- typeWestPanning,
- typeMove,
- typeVerticalText,
- typeCell,
- typeContextMenu,
- typeAlias,
- typeProgress,
- typeNoDrop,
- typeCopy,
- typeNone,
- typeNotAllowed,
- typeZoomIn,
- typeZoomOut,
- typeCustom
- };
-
- // Cursor.h assumes that it can initialize us to 0.
- explicit PlatformCursor(int type = 0) : m_type(typePointer) {}
-
- PlatformCursor(Type type) : m_type(type) {}
-
- PlatformCursor(Image* image, const IntPoint& hotSpot)
- : m_image(image)
- , m_hotSpot(hotSpot)
- , m_type(typeCustom) {}
-
- PassRefPtr<Image> customImage() const { return m_image; }
- const IntPoint& hotSpot() const { return m_hotSpot; }
- Type type() const { return m_type; }
-
- private:
- RefPtr<Image> m_image;
- IntPoint m_hotSpot;
- Type m_type;
- };
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/PlatformKeyboardEventChromium.cpp b/webkit/port/platform/chromium/PlatformKeyboardEventChromium.cpp
deleted file mode 100644
index 70dd4f4..0000000
--- a/webkit/port/platform/chromium/PlatformKeyboardEventChromium.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "PlatformKeyboardEvent.h"
-
-#if PLATFORM(WIN_OS)
-#include <windows.h>
-#elif PLATFORM(DARWIN)
-#import <Carbon/Carbon.h>
-#else
-#include "NotImplemented.h"
-#endif
-
-namespace WebCore {
-
-void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
-{
-#if PLATFORM(WIN_OS)
- // No KeyDown events on Windows to disambiguate.
- ASSERT_NOT_REACHED();
-#elif PLATFORM(DARWIN)
- // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
- ASSERT(m_type == KeyDown);
- ASSERT(type == RawKeyDown || type == Char);
- m_type = type;
- if (backwardCompatibilityMode)
- return;
-
- if (type == RawKeyDown) {
- m_text = String();
- m_unmodifiedText = String();
- } else {
- m_keyIdentifier = String();
- m_windowsVirtualKeyCode = 0;
- if (m_text.length() == 1 && (m_text[0U] >= 0xF700 && m_text[0U] <= 0xF7FF)) {
- // According to NSEvents.h, OpenStep reserves the range 0xF700-0xF8FF for function keys. However, some actual private use characters
- // happen to be in this range, e.g. the Apple logo (Option+Shift+K).
- // 0xF7FF is an arbitrary cut-off.
- m_text = String();
- m_unmodifiedText = String();
- }
- }
-#endif
-}
-
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
-#if PLATFORM(WIN_OS)
- // TODO(darin): does this even work inside the sandbox?
- return GetKeyState(VK_CAPITAL) & 1;
-#elif PLATFORM(DARWIN)
- return GetCurrentKeyModifiers() & alphaLock;
-#else
- notImplemented();
- return false;
-#endif
-}
-
-}
diff --git a/webkit/port/platform/chromium/PlatformScreenChromium.cpp b/webkit/port/platform/chromium/PlatformScreenChromium.cpp
deleted file mode 100644
index ad9eeb9..0000000
--- a/webkit/port/platform/chromium/PlatformScreenChromium.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2008, 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 "PlatformScreen.h"
-
-#include "ChromiumBridge.h"
-#include "IntRect.h"
-
-namespace WebCore {
-
-int screenDepth(Widget* widget)
-{
- return ChromiumBridge::screenDepth(widget);
-}
-
-int screenDepthPerComponent(Widget* widget)
-{
- return ChromiumBridge::screenDepthPerComponent(widget);
-}
-
-bool screenIsMonochrome(Widget* widget)
-{
- return ChromiumBridge::screenIsMonochrome(widget);
-}
-
-FloatRect screenRect(Widget* widget)
-{
- return ChromiumBridge::screenRect(widget);
-}
-
-FloatRect screenAvailableRect(Widget* widget)
-{
- return ChromiumBridge::screenAvailableRect(widget);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/PlatformWidget.h b/webkit/port/platform/chromium/PlatformWidget.h
deleted file mode 100644
index 661999f..0000000
--- a/webkit/port/platform/chromium/PlatformWidget.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2008, 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 PlatformWidget_h
-#define PlatformWidget_h
-
-// PlatformWidget is an opaque identifier corresponding to whatever native
-// view type the embedder may use. PlatformWidget CANNOT be assumed to be
-// a valid pointer. Some embedders may not use this identifier at all.
-
-typedef void* PlatformWidget;
-
-#endif
diff --git a/webkit/port/platform/chromium/PopupMenuChromium.cpp b/webkit/port/platform/chromium/PopupMenuChromium.cpp
deleted file mode 100644
index fb350e9..0000000
--- a/webkit/port/platform/chromium/PopupMenuChromium.cpp
+++ /dev/null
@@ -1,1120 +0,0 @@
-// Copyright (c) 2008, 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"
-
-#if COMPILER(MSVC)
-__pragma(warning(push, 0))
-#endif
-#include "PopupMenu.h"
-
-#include "CharacterNames.h"
-#include "ChromeClientChromium.h"
-#include "Document.h"
-#include "Font.h"
-#include "FrameView.h"
-#include "FontSelector.h"
-#include "Frame.h"
-#include "FramelessScrollView.h"
-#include "FramelessScrollViewClient.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "KeyboardCodes.h"
-#include "NotImplemented.h"
-#include "Page.h"
-#include "PlatformKeyboardEvent.h"
-#include "PlatformMouseEvent.h"
-#include "PlatformScreen.h"
-#include "PlatformWheelEvent.h"
-#include "RenderBlock.h"
-#include "RenderTheme.h"
-#include "ScrollbarTheme.h"
-#include "SystemTime.h"
-#include "Widget.h"
-#if COMPILER(MSVC)
-__pragma(warning(pop))
-#endif
-
-#include "webkit/port/platform/chromium/PopupMenuChromium.h"
-
-using namespace WTF;
-using namespace Unicode;
-
-using std::min;
-using std::max;
-
-namespace WebCore {
-
-typedef unsigned long long TimeStamp;
-
-static const int kMaxVisibleRows = 20;
-static const int kMaxHeight = 500;
-static const int kBorderSize = 1;
-static const TimeStamp kTypeAheadTimeoutMs = 1000;
-
-// This class uses WebCore code to paint and handle events for a drop-down list
-// box ("combobox" on Windows).
-class PopupListBox : public FramelessScrollView, public RefCounted<PopupListBox> {
-public:
- // FramelessScrollView
- virtual void paint(GraphicsContext* gc, const IntRect& rect);
- virtual bool handleMouseDownEvent(const PlatformMouseEvent& event);
- virtual bool handleMouseMoveEvent(const PlatformMouseEvent& event);
- virtual bool handleMouseReleaseEvent(const PlatformMouseEvent& event);
- virtual bool handleWheelEvent(const PlatformWheelEvent& event);
- virtual bool handleKeyEvent(const PlatformKeyboardEvent& event);
-
- // ScrollView
- virtual HostWindow* hostWindow() const;
-
- // PopupListBox methods
-
- // Show the popup
- void showPopup();
-
- // Hide the popup. Do not call this directly: use client->hidePopup().
- void hidePopup();
-
- // Update our internal list to match the client.
- void updateFromElement();
-
- // Free any allocated resources used in a particular popup session.
- void clear();
-
- // Set the index of the option that is displayed in the <select> widget in the page
- void setOriginalIndex(int index);
-
- // Get the index of the item that the user is currently moused over or has selected with
- // the keyboard. This is not the same as the original index, since the user has not yet
- // accepted this input.
- int selectedIndex() const { return m_selectedIndex; }
-
- // Move selection down/up the given number of items, scrolling if necessary.
- // Positive is down. The resulting index will be clamped to the range
- // [0, numItems), and non-option items will be skipped.
- void adjustSelectedIndex(int delta);
-
- // Returns the number of items in the list.
- int numItems() const { return static_cast<int>(m_items.size()); }
-
- void setBaseWidth(int width)
- {
- m_baseWidth = width;
- }
-
- // Compute size of widget and children.
- void layout();
-
- // Returns whether the popup wants to process events for the passed key.
- bool isInterestedInEventForKey(int key_code);
-
- // Sets whether the PopupMenuClient should be told to change its text when a
- // new item is selected (by using the arrow keys). Default is true.
- void setTextOnIndexChange(bool value) { m_setTextOnIndexChange = value; }
-
- // Sets whether we should accept the selected index when the popup is
- // abandonned.
- void setAcceptOnAbandon(bool value) { m_shouldAcceptOnAbandon = value; }
-
-private:
- friend class PopupContainer;
- friend class RefCounted<PopupListBox>;
-
- // A type of List Item
- enum ListItemType {
- TYPE_OPTION,
- TYPE_GROUP,
- TYPE_SEPARATOR
- };
-
- // A item (represented by <option> or <optgroup>) in the <select> widget.
- struct ListItem {
- ListItem(const String& label, ListItemType type)
- : label(label.copy()), type(type), y(0) {}
- String label;
- ListItemType type;
- int y; // y offset of this item, relative to the top of the popup.
- };
-
- PopupListBox(PopupMenuClient* client)
- : m_originalIndex(0)
- , m_selectedIndex(0)
- , m_shouldAcceptOnAbandon(true)
- , m_willAcceptOnAbandon(false)
- , m_visibleRows(0)
- , m_popupClient(client)
- , m_repeatingChar(0)
- , m_lastCharTime(0)
- , m_setTextOnIndexChange(true)
- {
- setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
- }
-
- ~PopupListBox()
- {
- clear();
- }
-
- void disconnectClient() { m_popupClient = 0; }
-
- // Closes the popup
- void abandon();
- // Select an index in the list, scrolling if necessary.
- void selectIndex(int index);
- // Accepts the selected index as the value to be displayed in the <select> widget on
- // the web page, and closes the popup.
- void acceptIndex(int index);
-
- // Returns true if the selection can be changed to index.
- // Disabled items, or labels cannot be selected.
- bool isSelectableItem(int index);
-
- // Scrolls to reveal the given index.
- void scrollToRevealRow(int index);
- void scrollToRevealSelection() { scrollToRevealRow(m_selectedIndex); }
-
- // Invalidates the row at the given index.
- void invalidateRow(int index);
-
- // Gets the height of a row.
- int getRowHeight(int index);
- // Get the bounds of a row.
- IntRect getRowBounds(int index);
-
- // Converts a point to an index of the row the point is over
- int pointToRowIndex(const IntPoint& point);
-
- // Paint an individual row
- void paintRow(GraphicsContext* gc, const IntRect& rect, int rowIndex);
-
- // Test if the given point is within the bounds of the popup window.
- bool isPointInBounds(const IntPoint& point);
-
- // Called when the user presses a text key. Does a prefix-search of the items.
- void typeAheadFind(const PlatformKeyboardEvent& event);
-
- // Returns the font to use for the given row
- Font getRowFont(int index);
-
- // This is the index of the item marked as "selected" - i.e. displayed in the widget on the
- // page.
- int m_originalIndex;
-
- // This is the index of the item that the user is hovered over or has selected using the
- // keyboard in the list. They have not confirmed this selection by clicking or pressing
- // enter yet however.
- int m_selectedIndex;
-
- // Whether we should accept the selectedIndex as chosen when the popup is
- // "abandoned". This value is set through its setter and is useful as
- // select popup menu and form autofill popup menu have different behaviors.
- bool m_shouldAcceptOnAbandon;
-
- // True if we should accept the selectedIndex as chosen, even if the popup
- // is "abandoned". This is used for keyboard navigation, where we want the
- // selection to change immediately, and is only used if
- // m_shouldAcceptOnAbandon is true.
- bool m_willAcceptOnAbandon;
-
- // This is the number of rows visible in the popup. The maximum number visible at a time is
- // defined as being kMaxVisibleRows. For a scrolled popup, this can be thought of as the
- // page size in data units.
- int m_visibleRows;
-
- // Our suggested width, not including scrollbar.
- int m_baseWidth;
-
- // A list of the options contained within the <select>
- Vector<ListItem*> m_items;
-
- // The <select> PopupMenuClient that opened us.
- PopupMenuClient* m_popupClient;
-
- // The scrollbar which has mouse capture. Mouse events go straight to this
- // if non-NULL.
- RefPtr<Scrollbar> m_capturingScrollbar;
-
- // The last scrollbar that the mouse was over. Used for mouseover highlights.
- RefPtr<Scrollbar> m_lastScrollbarUnderMouse;
-
- // The string the user has typed so far into the popup. Used for typeAheadFind.
- String m_typedString;
-
- // The char the user has hit repeatedly. Used for typeAheadFind.
- UChar m_repeatingChar;
-
- // The last time the user hit a key. Used for typeAheadFind.
- TimeStamp m_lastCharTime;
-
- bool m_setTextOnIndexChange;
-};
-
-static PlatformMouseEvent constructRelativeMouseEvent(const PlatformMouseEvent& e,
- FramelessScrollView* parent,
- FramelessScrollView* child)
-{
- IntPoint pos = parent->convertSelfToChild(child, e.pos());
-
- // FIXME(beng): This is a horrible hack since PlatformMouseEvent has no setters for x/y.
- // Need to add setters and get patch back upstream to webkit source.
- PlatformMouseEvent relativeEvent = e;
- IntPoint& relativePos = const_cast<IntPoint&>(relativeEvent.pos());
- relativePos.setX(pos.x());
- relativePos.setY(pos.y());
- return relativeEvent;
-}
-
-static PlatformWheelEvent constructRelativeWheelEvent(const PlatformWheelEvent& e,
- FramelessScrollView* parent,
- FramelessScrollView* child)
-{
- IntPoint pos = parent->convertSelfToChild(child, e.pos());
-
- // FIXME(beng): This is a horrible hack since PlatformWheelEvent has no setters for x/y.
- // Need to add setters and get patch back upstream to webkit source.
- PlatformWheelEvent relativeEvent = e;
- IntPoint& relativePos = const_cast<IntPoint&>(relativeEvent.pos());
- relativePos.setX(pos.x());
- relativePos.setY(pos.y());
- return relativeEvent;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PopupContainer implementation
-
-// static
-PassRefPtr<PopupContainer> PopupContainer::create(PopupMenuClient* client,
- bool focusOnShow)
-{
- return adoptRef(new PopupContainer(client, focusOnShow));
-}
-
-PopupContainer::PopupContainer(PopupMenuClient* client, bool focusOnShow)
- : m_listBox(new PopupListBox(client)),
- m_focusOnShow(focusOnShow)
-{
- // FrameViews are created with a refcount of 1 so it needs releasing after we
- // assign it to a RefPtr.
- m_listBox->deref();
-
- setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
-}
-
-PopupContainer::~PopupContainer()
-{
- if (m_listBox)
- removeChild(m_listBox.get());
-}
-
-void PopupContainer::showPopup(FrameView* view)
-{
- // Pre-layout, our size matches the <select> dropdown control.
- int selectHeight = frameRect().height();
-
- // Lay everything out to figure out our preferred size, then tell the view's
- // WidgetClient about it. It should assign us a client.
- layout();
-
- ChromeClientChromium* chromeClient = static_cast<ChromeClientChromium*>(
- view->frame()->page()->chrome()->client());
- if (chromeClient) {
- // If the popup would extend past the bottom of the screen, open upwards
- // instead.
- FloatRect screen = screenRect(view);
- IntRect widgetRect = chromeClient->windowToScreen(frameRect());
- if (widgetRect.bottom() > static_cast<int>(screen.bottom()))
- widgetRect.move(0, -(widgetRect.height() + selectHeight));
-
- chromeClient->popupOpened(this, widgetRect, m_focusOnShow);
- }
-
- // Must get called after we have a client and containingWindow.
- addChild(m_listBox.get());
-
- // Enable scrollbars after the listbox is inserted into the hierarchy, so
- // it has a proper WidgetClient.
- m_listBox->setVerticalScrollbarMode(ScrollbarAuto);
-
- m_listBox->scrollToRevealSelection();
-
- invalidate();
-}
-
-void PopupContainer::hidePopup()
-{
- invalidate();
-
- m_listBox->disconnectClient();
- removeChild(m_listBox.get());
- m_listBox = 0;
-
- if (client())
- client()->popupClosed(this);
-}
-
-void PopupContainer::layout()
-{
- m_listBox->layout();
-
- // Place the listbox within our border.
- m_listBox->move(kBorderSize, kBorderSize);
-
- // Size ourselves to contain listbox + border.
- resize(m_listBox->width() + kBorderSize*2, m_listBox->height() + kBorderSize*2);
-
- invalidate();
-}
-
-bool PopupContainer::handleMouseDownEvent(const PlatformMouseEvent& event)
-{
- return m_listBox->handleMouseDownEvent(
- constructRelativeMouseEvent(event, this, m_listBox.get()));
-}
-
-bool PopupContainer::handleMouseMoveEvent(const PlatformMouseEvent& event)
-{
- return m_listBox->handleMouseMoveEvent(
- constructRelativeMouseEvent(event, this, m_listBox.get()));
-}
-
-bool PopupContainer::handleMouseReleaseEvent(const PlatformMouseEvent& event)
-{
- return m_listBox->handleMouseReleaseEvent(
- constructRelativeMouseEvent(event, this, m_listBox.get()));
-}
-
-bool PopupContainer::handleWheelEvent(const PlatformWheelEvent& event)
-{
- return m_listBox->handleWheelEvent(
- constructRelativeWheelEvent(event, this, m_listBox.get()));
-}
-
-bool PopupContainer::handleKeyEvent(const PlatformKeyboardEvent& event)
-{
- return m_listBox->handleKeyEvent(event);
-}
-
-void PopupContainer::hide() {
- m_listBox->abandon();
-}
-
-void PopupContainer::paint(GraphicsContext* gc, const IntRect& rect)
-{
- // adjust coords for scrolled frame
- IntRect r = intersection(rect, frameRect());
- int tx = x();
- int ty = y();
-
- r.move(-tx, -ty);
-
- gc->translate(static_cast<float>(tx), static_cast<float>(ty));
- m_listBox->paint(gc, r);
- gc->translate(-static_cast<float>(tx), -static_cast<float>(ty));
-
- paintBorder(gc, rect);
-}
-
-void PopupContainer::paintBorder(GraphicsContext* gc, const IntRect& rect)
-{
- // FIXME(mpcomplete): where do we get the border color from?
- Color borderColor(127, 157, 185);
-
- gc->setStrokeStyle(NoStroke);
- gc->setFillColor(borderColor);
-
- int tx = x();
- int ty = y();
-
- // top, left, bottom, right
- gc->drawRect(IntRect(tx, ty, width(), kBorderSize));
- gc->drawRect(IntRect(tx, ty, kBorderSize, height()));
- gc->drawRect(IntRect(tx, ty + height() - kBorderSize, width(), kBorderSize));
- gc->drawRect(IntRect(tx + width() - kBorderSize, ty, kBorderSize, height()));
-}
-
-bool PopupContainer::isInterestedInEventForKey(int key_code) {
- return m_listBox->isInterestedInEventForKey(key_code);
-}
-
-void PopupContainer::show(const IntRect& r, FrameView* v, int index) {
- // The rect is the size of the select box. It's usually larger than we need.
- // subtract border size so that usually the container will be displayed
- // exactly the same width as the select box.
- listBox()->setBaseWidth(max(r.width() - kBorderSize * 2, 0));
-
- listBox()->updateFromElement();
-
- // We set the selected item in updateFromElement(), and disregard the
- // index passed into this function (same as Webkit's PopupMenuWin.cpp)
- // TODO(ericroman): make sure this is correct, and add an assertion.
- // DCHECK(popupWindow(popup)->listBox()->selectedIndex() == index);
-
- // Convert point to main window coords.
- IntPoint location = v->contentsToWindow(r.location());
-
- // Move it below the select widget.
- location.move(0, r.height());
-
- IntRect popupRect(location, r.size());
- setFrameRect(popupRect);
- showPopup(v);
-}
-
-void PopupContainer::setTextOnIndexChange(bool value) {
- listBox()->setTextOnIndexChange(value);
-}
-
-void PopupContainer::setAcceptOnAbandon(bool value) {
- listBox()->setAcceptOnAbandon(value);
-}
-
-void PopupContainer::refresh() {
- listBox()->updateFromElement();
- layout();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PopupListBox implementation
-
-bool PopupListBox::handleMouseDownEvent(const PlatformMouseEvent& event)
-{
- Scrollbar* scrollbar = scrollbarUnderMouse(event);
- if (scrollbar) {
- m_capturingScrollbar = scrollbar;
- m_capturingScrollbar->mouseDown(event);
- return true;
- }
-
- if (!isPointInBounds(event.pos()))
- abandon();
-
- return true;
-}
-
-bool PopupListBox::handleMouseMoveEvent(const PlatformMouseEvent& event)
-{
- if (m_capturingScrollbar) {
- m_capturingScrollbar->mouseMoved(event);
- return true;
- }
-
- Scrollbar* scrollbar = scrollbarUnderMouse(event);
- if (m_lastScrollbarUnderMouse != scrollbar) {
- // Send mouse exited to the old scrollbar.
- if (m_lastScrollbarUnderMouse)
- m_lastScrollbarUnderMouse->mouseExited();
- m_lastScrollbarUnderMouse = scrollbar;
- }
-
- if (scrollbar) {
- scrollbar->mouseMoved(event);
- return true;
- }
-
- if (!isPointInBounds(event.pos()))
- return false;
-
- selectIndex(pointToRowIndex(event.pos()));
- return true;
-}
-
-bool PopupListBox::handleMouseReleaseEvent(const PlatformMouseEvent& event)
-{
- if (m_capturingScrollbar) {
- m_capturingScrollbar->mouseUp();
- m_capturingScrollbar = 0;
- return true;
- }
-
- if (!isPointInBounds(event.pos()))
- return true;
-
- acceptIndex(pointToRowIndex(event.pos()));
- return true;
-}
-
-bool PopupListBox::handleWheelEvent(const PlatformWheelEvent& event)
-{
- if (!isPointInBounds(event.pos())) {
- abandon();
- return true;
- }
-
- // Pass it off to the scroll view.
- // Sadly, WebCore devs don't understand the whole "const" thing.
- wheelEvent(const_cast<PlatformWheelEvent&>(event));
- return true;
-}
-
-// Should be kept in sync with handleKeyEvent().
-bool PopupListBox::isInterestedInEventForKey(int key_code) {
- switch (key_code) {
- case VKEY_ESCAPE:
- case VKEY_RETURN:
- case VKEY_UP:
- case VKEY_DOWN:
- case VKEY_PRIOR:
- case VKEY_NEXT:
- case VKEY_HOME:
- case VKEY_END:
- case VKEY_TAB:
- return true;
- default:
- return false;
- }
-}
-
-bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event)
-{
- if (event.type() == PlatformKeyboardEvent::KeyUp)
- return true;
-
- if (numItems() == 0 && event.windowsVirtualKeyCode() != VKEY_ESCAPE)
- return true;
-
- switch (event.windowsVirtualKeyCode()) {
- case VKEY_ESCAPE:
- abandon(); // may delete this
- return true;
- case VKEY_RETURN:
- acceptIndex(m_selectedIndex); // may delete this
- return true;
- case VKEY_UP:
- adjustSelectedIndex(-1);
- break;
- case VKEY_DOWN:
- adjustSelectedIndex(1);
- break;
- case VKEY_PRIOR:
- adjustSelectedIndex(-m_visibleRows);
- break;
- case VKEY_NEXT:
- adjustSelectedIndex(m_visibleRows);
- break;
- case VKEY_HOME:
- adjustSelectedIndex(-m_selectedIndex);
- break;
- case VKEY_END:
- adjustSelectedIndex(m_items.size());
- break;
- default:
- if (!event.ctrlKey() && !event.altKey() && !event.metaKey() &&
- isPrintableChar(event.windowsVirtualKeyCode())) {
- typeAheadFind(event);
- }
- break;
- }
-
- if (m_originalIndex != m_selectedIndex) {
- // Keyboard events should update the selection immediately (but we don't
- // want to fire the onchange event until the popup is closed, to match
- // IE). We change the original index so we revert to that when the
- // popup is closed.
- if (m_shouldAcceptOnAbandon)
- m_willAcceptOnAbandon = true;
-
- setOriginalIndex(m_selectedIndex);
- if (m_setTextOnIndexChange)
- m_popupClient->setTextFromItem(m_selectedIndex);
- } else if (!m_setTextOnIndexChange &&
- event.windowsVirtualKeyCode() == VKEY_TAB) {
- // TAB is a special case as it should select the current item if any and
- // advance focus.
- if (m_selectedIndex >= 0)
- m_popupClient->setTextFromItem(m_selectedIndex);
- // Return false so the TAB key event is propagated to the page.
- return false;
- }
-
- return true;
-}
-
-HostWindow* PopupListBox::hostWindow() const
-{
- // Our parent is the root ScrollView, so it is the one that has a
- // HostWindow. FrameView::hostWindow() works similarly.
- return parent() ? parent()->hostWindow() : 0;
-}
-
-// From HTMLSelectElement.cpp
-static String stripLeadingWhiteSpace(const String& string)
-{
- int length = string.length();
- int i;
- for (i = 0; i < length; ++i)
- if (string[i] != noBreakSpace &&
- (string[i] <= 0x7F ? !isspace(string[i]) : (direction(string[i]) != WhiteSpaceNeutral)))
- break;
-
- return string.substring(i, length - i);
-}
-
-// From HTMLSelectElement.cpp, with modifications
-void PopupListBox::typeAheadFind(const PlatformKeyboardEvent& event)
-{
- TimeStamp now = static_cast<TimeStamp>(currentTime() * 1000.0f);
- TimeStamp delta = now - m_lastCharTime;
-
- m_lastCharTime = now;
-
- UChar c = event.windowsVirtualKeyCode();
-
- String prefix;
- int searchStartOffset = 1;
- if (delta > kTypeAheadTimeoutMs) {
- m_typedString = prefix = String(&c, 1);
- m_repeatingChar = c;
- } else {
- m_typedString.append(c);
-
- if (c == m_repeatingChar)
- // The user is likely trying to cycle through all the items starting with this character, so just search on the character
- prefix = String(&c, 1);
- else {
- m_repeatingChar = 0;
- prefix = m_typedString;
- searchStartOffset = 0;
- }
- }
-
- int itemCount = numItems();
- int index = (max(0, m_selectedIndex) + searchStartOffset) % itemCount;
- for (int i = 0; i < itemCount; i++, index = (index + 1) % itemCount) {
- if (!isSelectableItem(index))
- continue;
-
- if (stripLeadingWhiteSpace(m_items[index]->label).startsWith(prefix, false)) {
- selectIndex(index);
- return;
- }
- }
-}
-
-void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
-{
- // adjust coords for scrolled frame
- IntRect r = intersection(rect, frameRect());
- int tx = x() - scrollX();
- int ty = y() - scrollY();
-
- r.move(-tx, -ty);
-
- // set clip rect to match revised damage rect
- gc->save();
- gc->translate(static_cast<float>(tx), static_cast<float>(ty));
- gc->clip(r);
-
- // TODO(mpcomplete): Can we optimize scrolling to not require repainting the
- // entire window? Should we?
- for (int i = 0; i < numItems(); ++i)
- paintRow(gc, r, i);
-
- // Special case for an empty popup.
- if (numItems() == 0)
- gc->fillRect(r, Color::white);
-
- gc->restore();
-
- ScrollView::paint(gc, rect);
-}
-
-static const int separatorPadding = 4;
-static const int separatorHeight = 1;
-
-void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowIndex)
-{
- // This code is based largely on RenderListBox::paint* methods.
-
- IntRect rowRect = getRowBounds(rowIndex);
- if (!rowRect.intersects(rect))
- return;
-
- PopupMenuStyle style = m_popupClient->itemStyle(rowIndex);
-
- // Paint background
- Color backColor, textColor;
- if (rowIndex == m_selectedIndex) {
- backColor = theme()->activeListBoxSelectionBackgroundColor();
- textColor = theme()->activeListBoxSelectionForegroundColor();
- } else {
- backColor = style.backgroundColor();
- textColor = style.foregroundColor();
- }
-
- // If we have a transparent background, make sure it has a color to blend
- // against.
- if (backColor.hasAlpha())
- gc->fillRect(rowRect, Color::white);
-
- gc->fillRect(rowRect, backColor);
-
- if (m_popupClient->itemIsSeparator(rowIndex)) {
- IntRect separatorRect(
- rowRect.x() + separatorPadding,
- rowRect.y() + (rowRect.height() - separatorHeight) / 2,
- rowRect.width() - 2 * separatorPadding, separatorHeight);
- gc->fillRect(separatorRect, textColor);
- return;
- }
-
- gc->setFillColor(textColor);
-
- Font itemFont = getRowFont(rowIndex);
- gc->setFont(itemFont);
-
- // Bunch of shit to deal with RTL text...
- String itemText = m_popupClient->itemText(rowIndex);
- unsigned length = itemText.length();
- const UChar* str = itemText.characters();
-
- TextRun textRun(str, length, false, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
-
- // TODO(ojan): http://b/1210481 We should get the padding of individual
- // option elements. This probably implies changes to PopupMenuClient.
-
- // Draw the item text
- if (style.isVisible()) {
- int textX = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
- int textY = rowRect.y() + itemFont.ascent() + (rowRect.height() - itemFont.height()) / 2;
- gc->drawBidiText(textRun, IntPoint(textX, textY));
- }
-}
-
-Font PopupListBox::getRowFont(int rowIndex)
-{
- Font itemFont = m_popupClient->itemStyle(rowIndex).font();
- if (m_popupClient->itemIsLabel(rowIndex)) {
- // Bold-ify labels (ie, an <optgroup> heading).
- FontDescription d = itemFont.fontDescription();
- d.setWeight(FontWeightBold);
- Font font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
- font.update(0);
- return font;
- }
-
- return itemFont;
-}
-
-void PopupListBox::abandon()
-{
- RefPtr<PopupListBox> keepAlive(this);
-
- m_selectedIndex = m_originalIndex;
-
- if (m_willAcceptOnAbandon)
- m_popupClient->valueChanged(m_selectedIndex);
-
- // valueChanged may have torn down the popup!
- if (m_popupClient)
- m_popupClient->hidePopup();
-}
-
-int PopupListBox::pointToRowIndex(const IntPoint& point)
-{
- int y = scrollY() + point.y();
-
- // TODO(mpcomplete): binary search if perf matters.
- for (int i = 0; i < numItems(); ++i) {
- if (y < m_items[i]->y)
- return i-1;
- }
-
- // Last item?
- if (y < contentsHeight())
- return m_items.size()-1;
-
- return -1;
-}
-
-void PopupListBox::acceptIndex(int index)
-{
- ASSERT(index >= -1 && index < numItems());
- if (index == -1 && m_popupClient) {
- // Enter pressed with no selection, just close the popup.
- m_popupClient->hidePopup();
- return;
- }
-
- if (isSelectableItem(index)) {
- RefPtr<PopupListBox> keepAlive(this);
-
- // Tell the <select> PopupMenuClient what index was selected, and hide ourself.
- m_popupClient->valueChanged(index);
-
- // valueChanged may have torn down the popup!
- if (m_popupClient)
- m_popupClient->hidePopup();
- }
-}
-
-void PopupListBox::selectIndex(int index)
-{
- ASSERT(index >= 0 && index < numItems());
-
- if (index != m_selectedIndex && isSelectableItem(index)) {
- invalidateRow(m_selectedIndex);
- m_selectedIndex = index;
- invalidateRow(m_selectedIndex);
-
- scrollToRevealSelection();
- }
-}
-
-void PopupListBox::setOriginalIndex(int index)
-{
- m_originalIndex = m_selectedIndex = index;
-}
-
-int PopupListBox::getRowHeight(int index)
-{
- if (index >= 0) {
- return m_popupClient->itemStyle(index).font().height();
- } else {
- return 0;
- }
-}
-
-IntRect PopupListBox::getRowBounds(int index)
-{
- if (index >= 0) {
- return IntRect(0, m_items[index]->y, visibleWidth(), getRowHeight(index));
- } else {
- return IntRect(0, 0, visibleWidth(), getRowHeight(index));
- }
-}
-
-void PopupListBox::invalidateRow(int index)
-{
- if (index < 0)
- return;
-
- invalidateRect(getRowBounds(index));
-}
-
-void PopupListBox::scrollToRevealRow(int index)
-{
- if (index < 0)
- return;
-
- IntRect rowRect = getRowBounds(index);
-
- if (rowRect.y() < scrollY()) {
- // Row is above current scroll position, scroll up.
- ScrollView::setScrollPosition(IntPoint(0, rowRect.y()));
- } else if (rowRect.bottom() > scrollY() + visibleHeight()) {
- // Row is below current scroll position, scroll down.
- ScrollView::setScrollPosition(IntPoint(0, rowRect.bottom() - visibleHeight()));
- }
-}
-
-bool PopupListBox::isSelectableItem(int index) {
- return m_items[index]->type == TYPE_OPTION &&
- m_popupClient->itemIsEnabled(index);
-}
-
-void PopupListBox::adjustSelectedIndex(int delta)
-{
- int targetIndex = m_selectedIndex + delta;
- targetIndex = min(max(targetIndex, 0), numItems() - 1);
- if (!isSelectableItem(targetIndex)) {
- // We didn't land on an option. Try to find one.
- // We try to select the closest index to target, prioritizing any in
- // the range [current, target].
-
- int dir = delta > 0 ? 1 : -1;
- int testIndex = m_selectedIndex;
- int bestIndex = m_selectedIndex;
- bool passedTarget = false;
- while (testIndex >= 0 && testIndex < numItems()) {
- if (isSelectableItem(testIndex))
- bestIndex = testIndex;
- if (testIndex == targetIndex)
- passedTarget = true;
- if (passedTarget && bestIndex != m_selectedIndex)
- break;
-
- testIndex += dir;
- }
-
- // Pick the best index, which may mean we don't change.
- targetIndex = bestIndex;
- }
-
- // Select the new index, and ensure its visible. We do this regardless of
- // whether the selection changed to ensure keyboard events always bring the
- // selection into view.
- selectIndex(targetIndex);
- scrollToRevealSelection();
-}
-
-void PopupListBox::updateFromElement()
-{
- // It happens when pressing a key to jump to an item, then use tab or
- // mouse to get away from the select box. In that case, updateFromElement
- // is called before abandon, which causes discarding of the select result.
- if (m_willAcceptOnAbandon) {
- m_popupClient->valueChanged(m_selectedIndex);
- m_willAcceptOnAbandon = false;
- }
-
- clear();
-
- int size = m_popupClient->listSize();
- for (int i = 0; i < size; ++i) {
- ListItemType type;
- if (m_popupClient->itemIsSeparator(i))
- type = PopupListBox::TYPE_SEPARATOR;
- else if (m_popupClient->itemIsLabel(i))
- type = PopupListBox::TYPE_GROUP;
- else
- type = PopupListBox::TYPE_OPTION;
- m_items.append(new ListItem(m_popupClient->itemText(i), type));
- }
-
- m_selectedIndex = m_popupClient->selectedIndex();
- setOriginalIndex(m_selectedIndex);
-
- layout();
-}
-
-void PopupListBox::layout()
-{
- // Size our child items.
- int baseWidth = 0;
- int paddingWidth = 0;
- int y = 0;
- for (int i = 0; i < numItems(); ++i) {
- Font itemFont = getRowFont(i);
-
- // Place the item vertically.
- m_items[i]->y = y;
- y += itemFont.height();
-
- // Ensure the popup is wide enough to fit this item.
- String text = m_popupClient->itemText(i);
- if (!text.isEmpty()) {
- int width = itemFont.width(TextRun(text));
- baseWidth = max(baseWidth, width);
- }
- // TODO(ojan): http://b/1210481 We should get the padding of individual option elements.
- paddingWidth = max(paddingWidth,
- m_popupClient->clientPaddingLeft() + m_popupClient->clientPaddingRight());
- }
-
- int windowHeight = 0;
- m_visibleRows = min(numItems(), kMaxVisibleRows);
- for (int i = 0; i < m_visibleRows; ++i) {
- int rowHeight = getRowHeight(i);
- if (windowHeight + rowHeight > kMaxHeight) {
- m_visibleRows = i;
- break;
- }
-
- windowHeight += rowHeight;
- }
-
- // Set our widget and scrollable contents sizes.
- int scrollbarWidth = 0;
- if (m_visibleRows < numItems())
- scrollbarWidth = ScrollbarTheme::nativeTheme()->scrollbarThickness();
-
- int windowWidth = baseWidth + scrollbarWidth + paddingWidth;
- int contentWidth = baseWidth;
-
- if (windowWidth < m_baseWidth) {
- windowWidth = m_baseWidth;
- contentWidth = m_baseWidth - scrollbarWidth - paddingWidth;
- } else {
- m_baseWidth = baseWidth;
- }
-
- resize(windowWidth, windowHeight);
- setContentsSize(IntSize(contentWidth, getRowBounds(numItems() - 1).bottom()));
-
- if (hostWindow())
- scrollToRevealSelection();
-
- invalidate();
-}
-
-void PopupListBox::clear()
-{
- for (Vector<ListItem*>::iterator it = m_items.begin(); it != m_items.end(); ++it)
- delete *it;
- m_items.clear();
-}
-
-bool PopupListBox::isPointInBounds(const IntPoint& point)
-{
- return numItems() != 0 && IntRect(0, 0, width(), height()).contains(point);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// PopupMenu implementation
-//
-// Note: you cannot add methods to this class, since it is defined above the
-// portability layer. To access methods and properties on the
-// popup widgets, use |popupWindow| above.
-
-PopupMenu::PopupMenu(PopupMenuClient* client)
- : m_popupClient(client)
-{
-}
-
-PopupMenu::~PopupMenu()
-{
- hide();
-}
-
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
-{
- p.m_popup = PopupContainer::create(client(), true);
- p.m_popup->show(r, v, index);
-}
-
-void PopupMenu::hide()
-{
- if (p.m_popup) {
- p.m_popup->hidePopup();
- p.m_popup = 0;
- }
-}
-
-void PopupMenu::updateFromElement()
-{
- p.m_popup->listBox()->updateFromElement();
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return false;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/PopupMenuChromium.h b/webkit/port/platform/chromium/PopupMenuChromium.h
deleted file mode 100644
index c8c7098..0000000
--- a/webkit/port/platform/chromium/PopupMenuChromium.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PopupMenuChromium_h
-#define PopupMenuChromium_h
-
-#include "config.h"
-
-#if COMPILER(MSVC)
-__pragma(warning(push, 0))
-#endif
-#include "PopupMenuClient.h"
-
-#include "FramelessScrollView.h"
-#include "IntRect.h"
-#if COMPILER(MSVC)
-__pragma(warning(pop))
-#endif
-
-
-namespace WebCore {
-
-class PopupListBox;
-
-// TODO(darin): Our FramelessScrollView classes need to implement HostWindow!
-
-// This class holds a PopupListBox (see cpp file). Its sole purpose is to be
-// able to draw a border around its child. All its paint/event handling is just
-// forwarded to the child listBox (with the appropriate transforms).
-// NOTE: this class is exposed so it can be instantiated direcly for the
-// autofill popup. We cannot use the Popup class directly in that case as the
-// autofill popup should not be focused when shown and we want to forward the
-// key events to it (through handleKeyEvent).
-
-class PopupContainer : public FramelessScrollView, public RefCounted<PopupContainer> {
-public:
- static PassRefPtr<PopupContainer> create(PopupMenuClient* client,
- bool focusOnShow);
-
- // Whether a key event should be sent to this popup.
- virtual bool isInterestedInEventForKey(int key_code);
-
- // FramelessScrollView
- virtual void paint(GraphicsContext* gc, const IntRect& rect);
- virtual void hide();
- virtual bool handleMouseDownEvent(const PlatformMouseEvent& event);
- virtual bool handleMouseMoveEvent(const PlatformMouseEvent& event);
- virtual bool handleMouseReleaseEvent(const PlatformMouseEvent& event);
- virtual bool handleWheelEvent(const PlatformWheelEvent& event);
- virtual bool handleKeyEvent(const PlatformKeyboardEvent& event);
-
- // PopupContainer methods
-
- // Show the popup
- void showPopup(FrameView* view);
-
- // Show the popup in the specified rect for the specified frame.
- // Note: this code was somehow arbitrarily factored-out of the Popup class
- // so WebViewImpl can create a PopupContainer.
- void show(const IntRect& r, FrameView* v, int index);
-
- // Hide the popup. Do not call this directly: use client->hidePopup().
- void hidePopup();
-
- // Compute size of widget and children.
- void layout();
-
- // Sets whether the PopupMenuClient should be told to change its text when a
- // new item is selected (by using the arrow keys). Default is true.
- void setTextOnIndexChange(bool value);
-
- // Sets whether the selection should be accepted when the popup menu is
- // closed (through ESC being pressed or the focus going away).
- // Default is true.
- // Note that when TAB is pressed, the selection is always accepted
- // regardless of this setting.
- void setAcceptOnAbandon(bool value);
-
- PopupListBox* listBox() const { return m_listBox.get(); }
-
- // Refresh the popup values from the PopupMenuClient.
- void refresh();
-
-private:
- friend class WTF::RefCounted<PopupContainer>;
-
- PopupContainer(PopupMenuClient* client, bool focusOnShow);
- ~PopupContainer();
-
- // Paint the border.
- void paintBorder(GraphicsContext* gc, const IntRect& rect);
-
- RefPtr<PopupListBox> m_listBox;
-
- // Whether the window showing this popup should be focused when shown.
- bool m_focusOnShow;
-};
-
-}
-
-#endif // PopupMenuChromium_h
diff --git a/webkit/port/platform/chromium/PopupMenuPrivate.h b/webkit/port/platform/chromium/PopupMenuPrivate.h
deleted file mode 100644
index dfe7541..0000000
--- a/webkit/port/platform/chromium/PopupMenuPrivate.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2008, 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 PopupMenuPrivate_h__
-#define PopupMenuPrivate_h__
-
-#include "RefPtr.h"
-
-namespace WebCore {
-
-class PopupContainer;
-
-struct PopupMenuPrivate
-{
- RefPtr<PopupContainer> m_popup;
-};
-
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/RenderThemeGtk.cpp b/webkit/port/platform/chromium/RenderThemeGtk.cpp
deleted file mode 100644
index 4481770..0000000
--- a/webkit/port/platform/chromium/RenderThemeGtk.cpp
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "RenderThemeGtk.h"
-
-#include "AffineTransform.h"
-#include "ChromiumBridge.h"
-#include "CSSValueKeywords.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "RenderObject.h"
-#include "ScrollbarTheme.h"
-#include "gtkdrawing.h"
-#include "GdkSkia.h"
-#include "UserAgentStyleSheets.h"
-
-#include <gdk/gdk.h>
-
-namespace {
-
-enum PaddingType {
- TopPadding,
- RightPadding,
- BottomPadding,
- LeftPadding
-};
-
-const int kStyledMenuListInternalPadding[4] = { 1, 4, 1, 4 };
-
-// The default variable-width font size. We use this as the default font
-// size for the "system font", and as a base size (which we then shrink) for
-// form control fonts.
-float DefaultFontSize = 16.0;
-
-} // namespace
-
-namespace WebCore {
-
-static Color makeColor(const GdkColor& c)
-{
- return Color(makeRGB(c.red >> 8, c.green >> 8, c.blue >> 8));
-}
-
-// We aim to match IE here.
-// -IE uses a font based on the encoding as the default font for form controls.
-// -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT),
-// which returns MS Shell Dlg)
-// -Safari uses Lucida Grande.
-//
-// TODO(ojan): Fix this!
-// The only case where we know we don't match IE is for ANSI encodings. IE uses
-// MS Shell Dlg there, which we render incorrectly at certain pixel sizes
-// (e.g. 15px). So, for now we just use Arial.
-static const char* defaultGUIFont(Document* document)
-{
- return "Arial";
-}
-
-// Converts points to pixels. One point is 1/72 of an inch.
-static float pointsToPixels(float points)
-{
- static float pixelsPerInch = 0.0f;
- if (!pixelsPerInch) {
- GdkScreen* screen = gdk_screen_get_default();
- // TODO(deanm): I'm getting floating point values of ~75 and ~100,
- // and it's making my fonts look all wrong. Figure this out.
- if (0 && screen) {
- pixelsPerInch = gdk_screen_get_resolution(screen);
- } else {
- // Match the default we set on Windows.
- pixelsPerInch = 96.0f;
- }
- }
-
- static const float POINTS_PER_INCH = 72.0f;
- return points / POINTS_PER_INCH * pixelsPerInch;
-}
-
-static void setSizeIfAuto(RenderStyle* style, const IntSize& size)
-{
- if (style->width().isIntrinsicOrAuto())
- style->setWidth(Length(size.width(), Fixed));
- if (style->height().isAuto())
- style->setHeight(Length(size.height(), Fixed));
-}
-
-static bool supportsFocus(ControlPart appearance)
-{
- switch (appearance) {
- case PushButtonPart:
- case ButtonPart:
- case TextFieldPart:
- case TextAreaPart:
- case SearchFieldPart:
- case MenulistPart:
- case RadioPart:
- case CheckboxPart:
- return true;
- default:
- return false;
- }
-}
-
-static GtkTextDirection gtkTextDirection(TextDirection direction)
-{
- switch (direction) {
- case RTL:
- return GTK_TEXT_DIR_RTL;
- case LTR:
- return GTK_TEXT_DIR_LTR;
- default:
- return GTK_TEXT_DIR_NONE;
- }
-}
-static void setMozState(RenderTheme* theme, GtkWidgetState* state, RenderObject* o)
-{
- state->active = theme->isPressed(o);
- state->focused = theme->isFocused(o);
- state->inHover = theme->isHovered(o);
- // FIXME: Disabled does not always give the correct appearance for ReadOnly
- state->disabled = !theme->isEnabled(o) || theme->isReadOnlyControl(o);
- state->isDefault = false;
- state->canDefault = false;
- state->depressed = false;
-}
-
-static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- // Painting is disabled so just claim to have succeeded
- if (i.context->paintingDisabled())
- return false;
-
- GtkWidgetState mozState;
- setMozState(theme, &mozState, o);
-
- int flags;
-
- // We might want to make setting flags the caller's job at some point rather than doing it here.
- switch (type) {
- case MOZ_GTK_BUTTON:
- flags = GTK_RELIEF_NORMAL;
- break;
- case MOZ_GTK_CHECKBUTTON:
- case MOZ_GTK_RADIOBUTTON:
- flags = theme->isChecked(o);
- break;
- default:
- flags = 0;
- break;
- }
-
- PlatformContextSkia* pcs = i.context->platformContext();
- SkCanvas* canvas = pcs->canvas();
- if (!canvas)
- return false;
-
- GdkRectangle gdkRect;
- gdkRect.x = rect.x();
- gdkRect.y = rect.y();
- gdkRect.width = rect.width();
- gdkRect.height = rect.height();
-
- // getTotalClip returns the currently set clip region in device coordinates,
- // so we have to apply the current transform (actually we only support translations)
- // to get the page coordinates that our gtk widget rendering expects.
- // We invert it because we want to map from device coordinates to page coordinates.
- const SkIRect clip_region = canvas->getTotalClip().getBounds();
- AffineTransform ctm = i.context->getCTM().inverse();
- IntPoint pos = ctm.mapPoint(IntPoint(SkScalarRound(clip_region.fLeft), SkScalarRound(clip_region.fTop)));
- GdkRectangle gdkClipRect;
- gdkClipRect.x = pos.x();
- gdkClipRect.y = pos.y();
- gdkClipRect.width = clip_region.width();
- gdkClipRect.height = clip_region.height();
-
- // moz_gtk_widget_paint will paint outside the bounds of gdkRect unless we further restrict |gdkClipRect|.
- gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect);
-
- GtkTextDirection direction = gtkTextDirection(o->style()->direction());
-
- return moz_gtk_widget_paint(type, pcs->gdk_skia(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS;
-}
-
-static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, RenderTheme* renderTheme)
-{
- // FIXME: Make sure this function doesn't get called many times for a single GTK+ style change signal.
- renderTheme->platformColorsDidChange();
-}
-
-static double querySystemBlinkInterval(double defaultInterval)
-{
- GtkSettings* settings = gtk_settings_get_default();
-
- gboolean shouldBlink;
- gint time;
-
- g_object_get(settings, "gtk-cursor-blink", &shouldBlink, "gtk-cursor-blink-time", &time, NULL);
-
- if (!shouldBlink)
- return 0;
-
- return time / 1000.0;
-}
-
-// Implement WebCore::theme() for getting the global RenderTheme.
-RenderTheme* theme()
-{
- static RenderThemeGtk gtkTheme;
- return &gtkTheme;
-}
-
-RenderThemeGtk::RenderThemeGtk()
- : m_gtkWindow(0)
- , m_gtkContainer(0)
- , m_gtkEntry(0)
- , m_gtkTreeView(0)
-{
-}
-
-// Use the Windows style sheets to match their metrics.
-String RenderThemeGtk::extraDefaultStyleSheet()
-{
- return String(themeWinUserAgentStyleSheet, sizeof(themeWinUserAgentStyleSheet));
-}
-
-String RenderThemeGtk::extraQuirksStyleSheet()
-{
- return String(themeWinQuirksUserAgentStyleSheet, sizeof(themeWinQuirksUserAgentStyleSheet));
-}
-
-bool RenderThemeGtk::supportsFocusRing(const RenderStyle* style) const
-{
- return supportsFocus(style->appearance());
-}
-
-Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return makeColor(widget->style->base[GTK_STATE_SELECTED]);
-}
-
-Color RenderThemeGtk::platformInactiveSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return makeColor(widget->style->base[GTK_STATE_ACTIVE]);
-}
-
-Color RenderThemeGtk::platformActiveSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return makeColor(widget->style->text[GTK_STATE_SELECTED]);
-}
-
-Color RenderThemeGtk::platformInactiveSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return makeColor(widget->style->text[GTK_STATE_ACTIVE]);
-}
-
-Color RenderThemeGtk::platformTextSearchHighlightColor() const
-{
- return Color(255, 255, 150);
-}
-
-double RenderThemeGtk::caretBlinkInterval() const
-{
- // Disable the blinking caret in layout test mode, as it introduces
- // a race condition for the pixel tests. http://b/1198440
- if (ChromiumBridge::layoutTestMode())
- return 0;
-
- // We cache the interval so we don't have to repeatedly request it from gtk.
- static double blinkInterval = querySystemBlinkInterval(RenderTheme::caretBlinkInterval());
- return blinkInterval;
-}
-
-void RenderThemeGtk::systemFont(int propId, Document* document, FontDescription& fontDescription) const
-{
- const char* faceName = 0;
- float fontSize = 0;
- // TODO(mmoss) see also webkit/port/rendering/RenderThemeWin.cpp
- switch (propId) {
- case CSSValueMenu:
- case CSSValueStatusBar:
- case CSSValueSmallCaption:
- // triggered by LayoutTests/fast/css/css2-system-fonts.html
- notImplemented();
- break;
- case CSSValueWebkitMiniControl:
- case CSSValueWebkitSmallControl:
- case CSSValueWebkitControl:
- faceName = defaultGUIFont(document);
- // Why 2 points smaller? Because that's what Gecko does.
- fontSize = DefaultFontSize - pointsToPixels(2);
- break;
- default:
- faceName = defaultGUIFont(document);
- fontSize = DefaultFontSize;
- }
-
- // Only update if the size makes sense.
- if (fontSize > 0) {
- fontDescription.firstFamily().setFamily(faceName);
- fontDescription.setSpecifiedSize(fontSize);
- fontDescription.setIsAbsoluteSize(true);
- fontDescription.setGenericFamily(FontDescription::NoFamily);
- fontDescription.setWeight(FontWeightNormal);
- fontDescription.setItalic(false);
- }
-}
-
-int RenderThemeGtk::minimumMenuListSize(RenderStyle* style) const
-{
- return 0;
-}
-
-bool RenderThemeGtk::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_CHECKBUTTON, o, i, rect);
-}
-
-void RenderThemeGtk::setCheckboxSize(RenderStyle* style) const
-{
- // If the width and height are both specified, then we have nothing to do.
- if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
- return;
-
- // FIXME: A hard-coded size of 13 is used. This is wrong but necessary for now. It matches Firefox.
- // At different DPI settings on Windows, querying the theme gives you a larger size that accounts for
- // the higher DPI. Until our entire engine honors a DPI setting other than 96, we can't rely on the theme's
- // metrics.
- const IntSize size(13, 13);
- setSizeIfAuto(style, size);
-}
-
-bool RenderThemeGtk::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_RADIOBUTTON, o, i, rect);
-}
-
-void RenderThemeGtk::setRadioSize(RenderStyle* style) const
-{
- // Use same sizing for radio box as checkbox.
- setCheckboxSize(style);
-}
-
-bool RenderThemeGtk::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_BUTTON, o, i, rect);
-}
-
-bool RenderThemeGtk::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_ENTRY, o, i, rect);
-}
-
-bool RenderThemeGtk::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintTextField(o, i, rect);
-}
-
-bool RenderThemeGtk::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_CHECKMENUITEM, o, i, rect);
-}
-
-bool RenderThemeGtk::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_DROPDOWN_ARROW, o, i, rect);
-}
-
-bool RenderThemeGtk::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_CHECKMENUITEM, o, i, rect);
-}
-
-void RenderThemeGtk::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
-{
- // Height is locked to auto on all browsers.
- style->setLineHeight(RenderStyle::initialLineHeight());
-}
-
-bool RenderThemeGtk::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_DROPDOWN, o, i, rect);
-}
-
-void RenderThemeGtk::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- adjustMenuListStyle(selector, style, e);
-}
-
-// Used to paint styled menulists (i.e. with a non-default border)
-bool RenderThemeGtk::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- return paintMenuList(o, i, r);
-}
-
-int RenderThemeGtk::popupInternalPaddingLeft(RenderStyle* style) const
-{
- return menuListInternalPadding(style, LeftPadding);
-}
-
-int RenderThemeGtk::popupInternalPaddingRight(RenderStyle* style) const
-{
- return menuListInternalPadding(style, RightPadding);
-}
-
-int RenderThemeGtk::popupInternalPaddingTop(RenderStyle* style) const
-{
- return menuListInternalPadding(style, TopPadding);
-}
-
-int RenderThemeGtk::popupInternalPaddingBottom(RenderStyle* style) const
-{
- return menuListInternalPadding(style, BottomPadding);
-}
-
-void RenderThemeGtk::adjustButtonInnerStyle(RenderStyle* style) const
-{
- // This inner padding matches Firefox.
- style->setPaddingTop(Length(1, Fixed));
- style->setPaddingRight(Length(3, Fixed));
- style->setPaddingBottom(Length(1, Fixed));
- style->setPaddingLeft(Length(3, Fixed));
-}
-
-bool RenderThemeGtk::controlSupportsTints(const RenderObject* o) const
-{
- return isEnabled(o);
-}
-
-Color RenderThemeGtk::activeListBoxSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return makeColor(widget->style->base[GTK_STATE_SELECTED]);
-}
-
-Color RenderThemeGtk::activeListBoxSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return makeColor(widget->style->text[GTK_STATE_SELECTED]);
-}
-
-Color RenderThemeGtk::inactiveListBoxSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return makeColor(widget->style->base[GTK_STATE_ACTIVE]);
-}
-
-Color RenderThemeGtk::inactiveListBoxSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return makeColor(widget->style->text[GTK_STATE_ACTIVE]);
-}
-
-GtkWidget* RenderThemeGtk::gtkEntry() const
-{
- if (m_gtkEntry)
- return m_gtkEntry;
-
- m_gtkEntry = gtk_entry_new();
- g_signal_connect(m_gtkEntry, "style-set", G_CALLBACK(gtkStyleSetCallback), theme());
- gtk_container_add(gtkContainer(), m_gtkEntry);
- gtk_widget_realize(m_gtkEntry);
-
- return m_gtkEntry;
-}
-
-GtkWidget* RenderThemeGtk::gtkTreeView() const
-{
- if (m_gtkTreeView)
- return m_gtkTreeView;
-
- m_gtkTreeView = gtk_tree_view_new();
- g_signal_connect(m_gtkTreeView, "style-set", G_CALLBACK(gtkStyleSetCallback), theme());
- gtk_container_add(gtkContainer(), m_gtkTreeView);
- gtk_widget_realize(m_gtkTreeView);
-
- return m_gtkTreeView;
-}
-
-GtkContainer* RenderThemeGtk::gtkContainer() const
-{
- if (m_gtkContainer)
- return m_gtkContainer;
-
- m_gtkWindow = gtk_window_new(GTK_WINDOW_POPUP);
- m_gtkContainer = GTK_CONTAINER(gtk_fixed_new());
- gtk_container_add(GTK_CONTAINER(m_gtkWindow), GTK_WIDGET(m_gtkContainer));
- gtk_widget_realize(m_gtkWindow);
-
- return m_gtkContainer;
-}
-
-int RenderThemeGtk::menuListInternalPadding(RenderStyle* style, int paddingType) const
-{
- // This internal padding is in addition to the user-supplied padding.
- // Matches the FF behavior.
- int padding = kStyledMenuListInternalPadding[paddingType];
-
- // Reserve the space for right arrow here. The rest of the padding is
- // set by adjustMenuListStyle, since PopMenuWin.cpp uses the padding from
- // RenderMenuList to lay out the individual items in the popup.
- // If the MenuList actually has appearance "NoAppearance", then that means
- // we don't draw a button, so don't reserve space for it.
- const int bar_type = style->direction() == LTR ? RightPadding : LeftPadding;
- if (paddingType == bar_type && style->appearance() != NoControlPart)
- padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();
-
- return padding;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/RenderThemeGtk.h b/webkit/port/platform/chromium/RenderThemeGtk.h
deleted file mode 100644
index 90bc6f4..0000000
--- a/webkit/port/platform/chromium/RenderThemeGtk.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * This file is part of the WebKit project.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef RenderThemeGdk_h
-#define RenderThemeGdk_h
-
-#include "RenderTheme.h"
-#include "GraphicsContext.h"
-
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-class RenderThemeGtk : public RenderTheme {
-public:
- RenderThemeGtk();
- ~RenderThemeGtk() { }
-
- virtual String extraDefaultStyleSheet();
- virtual String extraQuirksStyleSheet();
-
- // A method asking if the theme's controls actually care about redrawing when hovered.
- virtual bool supportsHover(const RenderStyle*) const { return true; }
-
- // A method asking if the theme is able to draw the focus ring.
- virtual bool supportsFocusRing(const RenderStyle*) const;
-
- // The platform selection color.
- virtual Color platformActiveSelectionBackgroundColor() const;
- virtual Color platformInactiveSelectionBackgroundColor() const;
- virtual Color platformActiveSelectionForegroundColor() const;
- virtual Color platformInactiveSelectionForegroundColor() const;
- virtual Color platformTextSearchHighlightColor() const;
-
- virtual double caretBlinkInterval() const;
-
- // System fonts.
- virtual void systemFont(int propId, Document*, FontDescription&) const;
-
- virtual int minimumMenuListSize(RenderStyle*) const;
-
- virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setCheckboxSize(RenderStyle* style) const;
-
- virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setRadioSize(RenderStyle* style) const;
-
- virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
- { return paintTextField(o, i, r); }
-
- virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- // MenuList refers to an unstyled menulist (meaning a menulist without
- // background-color or border set) and MenuListButton refers to a styled
- // menulist (a menulist with background-color or border set). They have
- // this distinction to support showing aqua style themes whenever they
- // possibly can, which is something we don't want to replicate.
- //
- // In short, we either go down the MenuList code path or the MenuListButton
- // codepath. We never go down both. And in both cases, they render the
- // entire menulist.
- virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
- virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
- virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- // These methods define the padding for the MenuList's inner block.
- virtual int popupInternalPaddingLeft(RenderStyle*) const;
- virtual int popupInternalPaddingRight(RenderStyle*) const;
- virtual int popupInternalPaddingTop(RenderStyle*) const;
- virtual int popupInternalPaddingBottom(RenderStyle*) const;
-
- virtual void adjustButtonInnerStyle(RenderStyle* style) const;
-
- // A method asking if the control changes its tint when the window has focus or not.
- virtual bool controlSupportsTints(const RenderObject*) const;
-
- // A general method asking if any control tinting is supported at all.
- virtual bool supportsControlTints() const { return true; }
-
- // List Box selection color
- virtual Color activeListBoxSelectionBackgroundColor() const;
- virtual Color activeListBoxSelectionForegroundColor() const;
- virtual Color inactiveListBoxSelectionBackgroundColor() const;
- virtual Color inactiveListBoxSelectionForegroundColor() const;
-
-private:
- /*
- * hold the state
- */
- GtkWidget* gtkEntry() const;
- GtkWidget* gtkTreeView() const;
-
- /*
- * unmapped GdkWindow having a container. This is holding all
- * our fake widgets
- */
- GtkContainer* gtkContainer() const;
-
-private:
- int menuListInternalPadding(RenderStyle* style, int paddingType) const;
-
- mutable GtkWidget* m_gtkWindow;
- mutable GtkContainer* m_gtkContainer;
- mutable GtkWidget* m_gtkEntry;
- mutable GtkWidget* m_gtkTreeView;
-};
-
-}
-
-#endif
diff --git a/webkit/port/platform/chromium/SSLKeyGeneratorChromium.cpp b/webkit/port/platform/chromium/SSLKeyGeneratorChromium.cpp
deleted file mode 100644
index 0b6cb7c..0000000
--- a/webkit/port/platform/chromium/SSLKeyGeneratorChromium.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2008, 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 "SSLKeyGenerator.h"
-
-namespace WebCore {
-
-// These are defined in webkit/glue/localized_strings.cpp.
-String keygenMenuHighGradeKeySize();
-String keygenMenuMediumGradeKeySize();
-
-// Returns the key sizes supported by the HTML keygen tag. The first string
-// is displayed as the default key size in the keygen menu.
-Vector<String> supportedKeySizes()
-{
- Vector<String> sizes(2);
- sizes[0] = keygenMenuHighGradeKeySize();
- sizes[1] = keygenMenuMediumGradeKeySize();
- return sizes;
-}
-
-// TODO: implement signedPublicKeyAndChallengeString here.
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/ScrollbarThemeChromium.cpp b/webkit/port/platform/chromium/ScrollbarThemeChromium.cpp
deleted file mode 100644
index 4f167f9..0000000
--- a/webkit/port/platform/chromium/ScrollbarThemeChromium.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2008 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 "ScrollbarThemeChromium.h"
-
-#include "ChromiumBridge.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-#include "ScrollbarClient.h"
-#include "ScrollbarThemeComposite.h"
-
-// -----------------------------------------------------------------------------
-// This file contains scrollbar theme code that is cross platform. Additional
-// members of ScrollbarThemeChromium can be found in the platform specific files
-// -----------------------------------------------------------------------------
-
-namespace WebCore {
-
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- static ScrollbarThemeChromium theme;
- return &theme;
-}
-
-ScrollbarThemeChromium::ScrollbarThemeChromium()
-{
-}
-
-ScrollbarThemeChromium::~ScrollbarThemeChromium()
-{
-}
-
-void ScrollbarThemeChromium::themeChanged()
-{
-}
-
-bool ScrollbarThemeChromium::hasThumb(Scrollbar* scrollbar)
-{
- // This method is just called as a paint-time optimization to see if
- // painting the thumb can be skipped. We don't have to be exact here.
- return thumbLength(scrollbar) > 0;
-}
-
-IntRect ScrollbarThemeChromium::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
-{
- // Windows and Linux just have single arrows.
- if (part == BackButtonEndPart)
- return IntRect();
-
- IntSize size = buttonSize(scrollbar);
- return IntRect(scrollbar->x(), scrollbar->y(), size.width(), size.height());
-}
-
-IntRect ScrollbarThemeChromium::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
-{
- // Windows and Linux just have single arrows.
- if (part == ForwardButtonStartPart)
- return IntRect();
-
- IntSize size = buttonSize(scrollbar);
- int x, y;
- if (scrollbar->orientation() == HorizontalScrollbar) {
- x = scrollbar->x() + scrollbar->width() - size.width();
- y = scrollbar->y();
- } else {
- x = scrollbar->x();
- y = scrollbar->y() + scrollbar->height() - size.height();
- }
- return IntRect(x, y, size.width(), size.height());
-}
-
-IntRect ScrollbarThemeChromium::trackRect(Scrollbar* scrollbar, bool)
-{
- IntSize bs = buttonSize(scrollbar);
- int thickness = scrollbarThickness();
- if (scrollbar->orientation() == HorizontalScrollbar) {
- if (scrollbar->width() < 2 * thickness)
- return IntRect();
- return IntRect(scrollbar->x() + bs.width(), scrollbar->y(), scrollbar->width() - 2 * bs.width(), thickness);
- }
- if (scrollbar->height() < 2 * thickness)
- return IntRect();
- return IntRect(scrollbar->x(), scrollbar->y() + bs.height(), thickness, scrollbar->height() - 2 * bs.height());
-}
-
-void ScrollbarThemeChromium::paintTrackBackground(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
-{
- // Just assume a forward track part. We only paint the track as a single piece when there is no thumb.
- if (!hasThumb(scrollbar))
- paintTrackPiece(context, scrollbar, rect, ForwardTrackPart);
-}
-
-void ScrollbarThemeChromium::paintTickmarks(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
-{
- if (scrollbar->orientation() != VerticalScrollbar)
- return;
-
- if (rect.height() <= 0 || rect.width() <= 0)
- return; // nothing to draw on.
-
- // Get the tickmarks for the frameview.
- Vector<IntRect> tickmarks;
- scrollbar->client()->getTickmarks(tickmarks);
- if (!tickmarks.size())
- return;
-
- // Get the image for the tickmarks.
- static RefPtr<Image> dash = Image::loadPlatformResource("tickmarkDash");
- if (dash->isNull()) {
- ASSERT_NOT_REACHED();
- return;
- }
-
- context->save();
-
- for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.end(); ++i) {
- // Calculate how far down (in %) the tick-mark should appear.
- const float percent = static_cast<float>(i->y()) / scrollbar->totalSize();
-
- // Calculate how far down (in pixels) the tick-mark should appear.
- const int yPos = rect.topLeft().y() + (rect.height() * percent);
-
- IntPoint tick(scrollbar->x(), yPos);
- context->drawImage(dash.get(), tick);
- }
-
- context->restore();
-}
-
-void ScrollbarThemeChromium::paintScrollCorner(ScrollView* view, GraphicsContext* context, const IntRect& cornerRect)
-{
- // ScrollbarThemeComposite::paintScrollCorner incorrectly assumes that the
- // ScrollView is a FrameView (see FramelessScrollView), so we cannot let
- // that code run. For FrameView's this is correct since we don't do custom
- // scrollbar corner rendering, which ScrollbarThemeComposite supports.
- ScrollbarTheme::paintScrollCorner(view, context, cornerRect);
-}
-
-bool ScrollbarThemeChromium::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
-{
- return evt.shiftKey() && evt.button() == LeftButton;
-}
-
-IntSize ScrollbarThemeChromium::buttonSize(Scrollbar* scrollbar)
-{
- // Our desired rect is essentially thickness by thickness.
-
- // Our actual rect will shrink to half the available space when we have < 2
- // times thickness pixels left. This allows the scrollbar to scale down
- // and function even at tiny sizes.
-
- int thickness = scrollbarThickness();
-
-#if !defined(__linux__)
- // In layout test mode, we force the button "girth" (i.e., the length of
- // the button along the axis of the scrollbar) to be a fixed size.
- // FIXME: This is retarded! scrollbarThickness is already fixed in layout
- // test mode so that should be enough to result in repeatable results, but
- // preserving this hack avoids having to rebaseline pixel tests.
- const int kLayoutTestModeGirth = 17;
-
- int girth = ChromiumBridge::layoutTestMode() ? kLayoutTestModeGirth : thickness;
-#else
- int girth = thickness;
-#endif
-
- if (scrollbar->orientation() == HorizontalScrollbar) {
- int width = scrollbar->width() < 2 * girth ? scrollbar->width() / 2 : girth;
- return IntSize(width, thickness);
- }
-
- int height = scrollbar->height() < 2 * girth ? scrollbar->height() / 2 : girth;
- return IntSize(thickness, height);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/ScrollbarThemeChromium.h b/webkit/port/platform/chromium/ScrollbarThemeChromium.h
deleted file mode 100644
index c198222..0000000
--- a/webkit/port/platform/chromium/ScrollbarThemeChromium.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2008 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 ScrollbarThemeChromium_h
-#define ScrollbarThemeChromium_h
-
-#include "ScrollbarThemeComposite.h"
-
-namespace WebCore {
-
-class PlatformMouseEvent;
-
-// -----------------------------------------------------------------------------
-// This class contains the Chromium scrollbar implementations for Windows and
-// Linux. All of the symbols here in must be defined somewhere in the code and
-// we manage the platform specific parts by linking in different, platform
-// specific, files. Methods that we shared across platforms are implemented in
-// ScrollbarThemeChromium.cpp
-// -----------------------------------------------------------------------------
-class ScrollbarThemeChromium : public ScrollbarThemeComposite {
-public:
- ScrollbarThemeChromium();
- virtual ~ScrollbarThemeChromium();
-
- virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
-
- virtual void themeChanged();
-
- virtual bool invalidateOnMouseEnterExit();
-
-protected:
- virtual bool hasButtons(Scrollbar*) { return true; }
- virtual bool hasThumb(Scrollbar*);
-
- virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect trackRect(Scrollbar*, bool painting = false);
-
- virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect&);
- virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
-
- virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&);
- virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
- virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
- virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&);
- virtual void paintTickmarks(GraphicsContext*, Scrollbar*, const IntRect&);
-
-private:
- IntSize buttonSize(Scrollbar*);
-
- int getThemeState(Scrollbar*, ScrollbarPart) const;
- int getThemeArrowState(Scrollbar*, ScrollbarPart) const;
- int getClassicThemeState(Scrollbar*, ScrollbarPart) const;
-};
-
-}
-#endif
diff --git a/webkit/port/platform/chromium/ScrollbarThemeChromiumLinux.cpp b/webkit/port/platform/chromium/ScrollbarThemeChromiumLinux.cpp
deleted file mode 100644
index f052d92..0000000
--- a/webkit/port/platform/chromium/ScrollbarThemeChromiumLinux.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2008, 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 "ScrollbarThemeChromium.h"
-
-#include "AffineTransform.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-
-#include "gtkdrawing.h"
-#include "GdkSkia.h"
-#include <gtk/gtk.h>
-
-
-namespace WebCore {
-
-int ScrollbarThemeChromium::scrollbarThickness(ScrollbarControlSize controlSize)
-{
- static int size = 0;
- if (!size) {
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
- size = metrics.slider_width;
- }
- return size;
-}
-
-bool ScrollbarThemeChromium::invalidateOnMouseEnterExit()
-{
- notImplemented();
- return false;
-}
-
-// -----------------------------------------------------------------------------
-// Given an uninitialised widget state object, set the members such that it's
-// sane for drawing scrollbars
-// -----------------------------------------------------------------------------
-static void initMozState(GtkWidgetState* mozState)
-{
- mozState->active = true;
- mozState->focused = false;
- mozState->inHover = false;
- mozState->disabled = false;
- mozState->isDefault = false;
- mozState->canDefault = false;
- mozState->depressed = false;
- mozState->curpos = 0;
- mozState->maxpos = 0;
-}
-
-// -----------------------------------------------------------------------------
-// Paint a GTK widget
-// gc: context to draw onto
-// rect: the area of the widget
-// widget_type: the type of widget to draw
-// flags: widget dependent flags (e.g. direction of scrollbar arrows etc)
-//
-// See paintMozWiget in RenderThemeGtk.cpp for an explanation of the clipping.
-// -----------------------------------------------------------------------------
-static void paintScrollbarWidget(GraphicsContext* gc, const IntRect& rect,
- GtkThemeWidgetType widget_type, gint flags)
-{
- PlatformContextSkia* pcs = gc->platformContext();
-
- GdkRectangle gdkRect = { rect.x(), rect.y(), rect.width(), rect.height() };
-
- const SkIRect clip_region = pcs->canvas()->getTotalClip().getBounds();
- AffineTransform ctm = gc->getCTM().inverse();
- IntPoint pos = ctm.mapPoint(
- IntPoint(SkScalarRound(clip_region.fLeft), SkScalarRound(clip_region.fTop)));
- GdkRectangle gdkClipRect;
- gdkClipRect.x = pos.x();
- gdkClipRect.y = pos.y();
- gdkClipRect.width = clip_region.width();
- gdkClipRect.height = clip_region.height();
-
- gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect);
-
- GtkWidgetState mozState;
- initMozState(&mozState);
-
- moz_gtk_widget_paint(widget_type, pcs->gdk_skia(), &gdkRect, &gdkClipRect,
- &mozState, flags, GTK_TEXT_DIR_LTR);
-}
-
-void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar,
- const IntRect& rect, ScrollbarPart partType)
-{
- const bool horz = scrollbar->orientation() == HorizontalScrollbar;
- const GtkThemeWidgetType track_type =
- horz ? MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL : MOZ_GTK_SCROLLBAR_TRACK_VERTICAL;
- paintScrollbarWidget(gc, rect, track_type, 0);
-
- return;
-}
-
-void ScrollbarThemeChromium::paintButton(GraphicsContext* gc, Scrollbar* scrollbar,
- const IntRect& rect, ScrollbarPart part)
-{
- // TODO(port): It appears the either we're upsetting GTK by forcing WebKit
- // sizes on it, or the buttons expect the track to be drawn under them.
- // Either way, we end up with unpainted pixels which are upsetting the
- // pixel tests. Thus we paint green under the buttons to, at least, make
- // the pixel output the same between debug and opt builds.
- SkPaint paint;
- paint.setARGB(255, 0, 255, 128);
- SkRect skrect;
- skrect.set(rect.x(), rect.y(), rect.x() + rect.width() - 1, rect.y() + rect.height() - 1);
- gc->platformContext()->canvas()->drawRect(skrect, paint);
-
- const bool horz = scrollbar->orientation() == HorizontalScrollbar;
- gint flags = horz ? 0 : MOZ_GTK_STEPPER_VERTICAL;
- flags |= ForwardButtonEndPart == part ? MOZ_GTK_STEPPER_DOWN : 0;
- paintScrollbarWidget(gc, rect, MOZ_GTK_SCROLLBAR_BUTTON, flags);
-}
-
-void ScrollbarThemeChromium::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect)
-{
- const bool horz = scrollbar->orientation() == HorizontalScrollbar;
- const GtkThemeWidgetType thumb_type =
- horz ? MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL : MOZ_GTK_SCROLLBAR_THUMB_VERTICAL;
- paintScrollbarWidget(gc, rect, thumb_type, 0);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp b/webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp
deleted file mode 100644
index 90c5e21..0000000
--- a/webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2008 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 "ScrollbarThemeChromium.h"
-
-#include <windows.h>
-#include <vsstyle.h>
-
-#include "ChromiumBridge.h"
-#include "ChromiumUtilsWin.h"
-#include "GraphicsContext.h"
-#include "PlatformContextSkia.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-
-namespace WebCore {
-
-using ChromiumUtils::isVistaOrGreater;
-
-// The scrollbar size in DumpRenderTree on the Mac - so we can match their
-// layout results. Entries are for regular, small, and mini scrollbars.
-// Metrics obtained using [NSScroller scrollerWidthForControlSize:]
-static const int kMacScrollbarSize[3] = { 15, 11, 15 };
-
-int ScrollbarThemeChromium::scrollbarThickness(ScrollbarControlSize controlSize)
-{
- static int thickness;
- if (!thickness) {
- if (ChromiumBridge::layoutTestMode())
- return kMacScrollbarSize[controlSize];
- thickness = GetSystemMetrics(SM_CXVSCROLL);
- }
- return thickness;
-}
-
-bool ScrollbarThemeChromium::invalidateOnMouseEnterExit()
-{
- return isVistaOrGreater();
-}
-
-void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType)
-{
- bool horz = scrollbar->orientation() == HorizontalScrollbar;
-
- int partId;
- if (partType == BackTrackPart) {
- partId = horz ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
- } else {
- partId = horz ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
- }
-
- IntRect alignRect = trackRect(scrollbar, false);
-
- // Draw the track area before/after the thumb on the scroll bar.
- ChromiumBridge::paintScrollbarTrack(
- gc,
- partId,
- getThemeState(scrollbar, partType),
- getClassicThemeState(scrollbar, partType),
- rect,
- alignRect);
-}
-
-void ScrollbarThemeChromium::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
-{
- bool horz = scrollbar->orientation() == HorizontalScrollbar;
-
- int partId;
- if (part == BackButtonStartPart || part == ForwardButtonStartPart) {
- partId = horz ? DFCS_SCROLLLEFT : DFCS_SCROLLUP;
- } else {
- partId = horz ? DFCS_SCROLLRIGHT : DFCS_SCROLLDOWN;
- }
-
- // Draw the thumb (the box you drag in the scroll bar to scroll).
- ChromiumBridge::paintScrollbarArrow(
- gc,
- getThemeArrowState(scrollbar, part),
- partId | getClassicThemeState(scrollbar, part),
- rect);
-}
-
-void ScrollbarThemeChromium::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect)
-{
- bool horz = scrollbar->orientation() == HorizontalScrollbar;
-
- // Draw the thumb (the box you drag in the scroll bar to scroll).
- ChromiumBridge::paintScrollbarThumb(
- gc,
- horz ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT,
- getThemeState(scrollbar, ThumbPart),
- getClassicThemeState(scrollbar, ThumbPart),
- rect);
-
- // Draw the gripper (the three little lines on the thumb).
- ChromiumBridge::paintScrollbarThumb(
- gc,
- horz ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT,
- getThemeState(scrollbar, ThumbPart),
- getClassicThemeState(scrollbar, ThumbPart),
- rect);
-}
-
-int ScrollbarThemeChromium::getThemeState(Scrollbar* scrollbar, ScrollbarPart part) const
-{
- // When dragging the thumb, draw thumb pressed and other segments normal
- // regardless of where the cursor actually is. See also four places in
- // getThemeArrowState().
- if (scrollbar->pressedPart() == ThumbPart) {
- if (part == ThumbPart)
- return SCRBS_PRESSED;
- return isVistaOrGreater() ? SCRBS_HOVER : SCRBS_NORMAL;
- }
- if (!scrollbar->enabled())
- return SCRBS_DISABLED;
- if (scrollbar->hoveredPart() != part || part == BackTrackPart || part == ForwardTrackPart)
- return (scrollbar->hoveredPart() == NoPart || !isVistaOrGreater()) ? SCRBS_NORMAL : SCRBS_HOVER;
- if (scrollbar->pressedPart() == NoPart)
- return SCRBS_HOT;
- return (scrollbar->pressedPart() == part) ? SCRBS_PRESSED : SCRBS_NORMAL;
-}
-
-int ScrollbarThemeChromium::getThemeArrowState(Scrollbar* scrollbar, ScrollbarPart part) const
-{
- // We could take advantage of knowing the values in the state enum to write
- // some simpler code, but treating the state enum as a black box seems
- // clearer and more future-proof.
- if (part == BackButtonStartPart || part == ForwardButtonStartPart) {
- if (scrollbar->orientation() == HorizontalScrollbar) {
- if (scrollbar->pressedPart() == ThumbPart)
- return !isVistaOrGreater() ? ABS_LEFTNORMAL : ABS_LEFTHOVER;
- if (!scrollbar->enabled())
- return ABS_LEFTDISABLED;
- if (scrollbar->hoveredPart() != part)
- return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_LEFTNORMAL : ABS_LEFTHOVER;
- if (scrollbar->pressedPart() == NoPart)
- return ABS_LEFTHOT;
- return (scrollbar->pressedPart() == part) ?
- ABS_LEFTPRESSED : ABS_LEFTNORMAL;
- }
- if (scrollbar->pressedPart() == ThumbPart)
- return !isVistaOrGreater() ? ABS_UPNORMAL : ABS_UPHOVER;
- if (!scrollbar->enabled())
- return ABS_UPDISABLED;
- if (scrollbar->hoveredPart() != part)
- return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_UPNORMAL : ABS_UPHOVER;
- if (scrollbar->pressedPart() == NoPart)
- return ABS_UPHOT;
- return (scrollbar->pressedPart() == part) ? ABS_UPPRESSED : ABS_UPNORMAL;
- }
- if (scrollbar->orientation() == HorizontalScrollbar) {
- if (scrollbar->pressedPart() == ThumbPart)
- return !isVistaOrGreater() ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER;
- if (!scrollbar->enabled())
- return ABS_RIGHTDISABLED;
- if (scrollbar->hoveredPart() != part)
- return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER;
- if (scrollbar->pressedPart() == NoPart)
- return ABS_RIGHTHOT;
- return (scrollbar->pressedPart() == part) ? ABS_RIGHTPRESSED : ABS_RIGHTNORMAL;
- }
- if (scrollbar->pressedPart() == ThumbPart)
- return !isVistaOrGreater() ? ABS_DOWNNORMAL : ABS_DOWNHOVER;
- if (!scrollbar->enabled())
- return ABS_DOWNDISABLED;
- if (scrollbar->hoveredPart() != part)
- return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_DOWNNORMAL : ABS_DOWNHOVER;
- if (scrollbar->pressedPart() == NoPart)
- return ABS_DOWNHOT;
- return (scrollbar->pressedPart() == part) ? ABS_DOWNPRESSED : ABS_DOWNNORMAL;
-}
-
-int ScrollbarThemeChromium::getClassicThemeState(Scrollbar* scrollbar, ScrollbarPart part) const
-{
- // When dragging the thumb, draw the buttons normal even when hovered.
- if (scrollbar->pressedPart() == ThumbPart)
- return 0;
- if (!scrollbar->enabled())
- return DFCS_INACTIVE;
- if (scrollbar->hoveredPart() != part || part == BackTrackPart || part == ForwardTrackPart)
- return 0;
- if (scrollbar->pressedPart() == NoPart)
- return DFCS_HOT;
- return (scrollbar->pressedPart() == part) ? (DFCS_PUSHED | DFCS_FLAT) : 0;
-}
-
-}
diff --git a/webkit/port/platform/chromium/SearchPopupMenuChromium.cpp b/webkit/port/platform/chromium/SearchPopupMenuChromium.cpp
deleted file mode 100644
index d16ffa6..0000000
--- a/webkit/port/platform/chromium/SearchPopupMenuChromium.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-#include "SearchPopupMenu.h"
-
-#include "AtomicString.h"
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
-{
-}
-
-bool SearchPopupMenu::enabled()
-{
- // FIXME: <rdar://problem/5057218> Reenable "recent searches" search field menu when menu is fully implemented
- return false;
-}
-
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
-{
- notImplemented();
-}
-
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
-{
- notImplemented();
-}
-
-}
diff --git a/webkit/port/platform/chromium/SharedTimerChromium.cpp b/webkit/port/platform/chromium/SharedTimerChromium.cpp
deleted file mode 100644
index e942437..0000000
--- a/webkit/port/platform/chromium/SharedTimerChromium.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "ChromiumBridge.h"
-#include "SharedTimer.h"
-
-namespace WebCore {
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- ChromiumBridge::setSharedTimerFiredFunction(f);
-}
-
-void setSharedTimerFireTime(double fireTime)
-{
- ChromiumBridge::setSharedTimerFireTime(fireTime);
-}
-
-void stopSharedTimer()
-{
- ChromiumBridge::stopSharedTimer();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/SoundChromiumPosix.cpp b/webkit/port/platform/chromium/SoundChromiumPosix.cpp
deleted file mode 100644
index 4e3790a..0000000
--- a/webkit/port/platform/chromium/SoundChromiumPosix.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2008, 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 "Sound.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-void systemBeep()
-{
- notImplemented();
-}
-
-}
diff --git a/webkit/port/platform/chromium/SoundChromiumWin.cpp b/webkit/port/platform/chromium/SoundChromiumWin.cpp
deleted file mode 100644
index 38c5995..0000000
--- a/webkit/port/platform/chromium/SoundChromiumWin.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "Sound.h"
-
-#include <Windows.h>
-
-namespace WebCore {
-
-void systemBeep() { MessageBeep(static_cast<UINT>(-1)); }
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/SystemTimeChromium.cpp b/webkit/port/platform/chromium/SystemTimeChromium.cpp
deleted file mode 100644
index 857d767..0000000
--- a/webkit/port/platform/chromium/SystemTimeChromium.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "SystemTime.h"
-
-#include "NotImplemented.h"
-#include "ChromiumBridge.h"
-
-namespace WebCore {
-
-// Get the current time in seconds since epoch.
-double currentTime()
-{
- return ChromiumBridge::currentTime();
-}
-
-float userIdleTime()
-{
- // Needed for back/forward cache.
- notImplemented();
- return 0.0F;
-}
-
-}
diff --git a/webkit/port/platform/chromium/TemporaryLinkStubs.cpp b/webkit/port/platform/chromium/TemporaryLinkStubs.cpp
deleted file mode 100644
index 637c353..0000000
--- a/webkit/port/platform/chromium/TemporaryLinkStubs.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2008, 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 "KURL.h"
-#include "NotImplemented.h"
-#include "SharedBuffer.h"
-
-namespace WebCore {
-
-String signedPublicKeyAndChallengeString(unsigned, const String&, const KURL&) { notImplemented(); return String(); }
-void getSupportedKeySizes(Vector<String>&) { notImplemented(); }
-
-String KURL::fileSystemPath() const { notImplemented(); return String(); }
-
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) { notImplemented(); return 0; }
-
-} // namespace WebCore
-
-// Required to use notImplemented() outside of the WebCore namespace.
-using namespace WebCore;
-
-namespace WTF {
-
-#if !defined(__linux__)
-void scheduleDispatchFunctionsOnMainThread() { notImplemented(); }
-#endif
-
-} // namespace WTF
diff --git a/webkit/port/platform/chromium/TextBoundariesChromium.cpp b/webkit/port/platform/chromium/TextBoundariesChromium.cpp
deleted file mode 100644
index d226048..0000000
--- a/webkit/port/platform/chromium/TextBoundariesChromium.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "TextBoundaries.h"
-
-#include <unicode/ubrk.h>
-
-#include "StringImpl.h"
-#include "TextBreakIterator.h"
-
-namespace WebCore {
-
-int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
-{
- UBreakIterator* it = wordBreakIterator(chars, len);
-
- if (forward) {
- position = ubrk_following(it, position);
- while (position != UBRK_DONE) {
- // We stop searching when the character preceeding the break
- // is alphanumeric.
- if (position < len && u_isalnum(chars[position - 1]))
- return position;
-
- position = ubrk_following(it, position);
- }
-
- return len;
- } else {
- position = ubrk_preceding(it, position);
- while (position != UBRK_DONE) {
- // We stop searching when the character following the break
- // is alphanumeric.
- if (position > 0 && u_isalnum(chars[position]))
- return position;
-
- position = ubrk_preceding(it, position);
- }
-
- return 0;
- }
-}
-
-void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
-{
- UBreakIterator* it = wordBreakIterator(chars, len);
- *end = ubrk_following(it, position);
- if (*end < 0)
- *end = ubrk_last(it);
- *start = ubrk_previous(it);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/TextBreakIteratorInternalICUChromium.cpp b/webkit/port/platform/chromium/TextBreakIteratorInternalICUChromium.cpp
deleted file mode 100644
index 000ae9b..0000000
--- a/webkit/port/platform/chromium/TextBreakIteratorInternalICUChromium.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "config.h"
-#include "TextBreakIteratorInternalICU.h"
-
-namespace WebCore {
-
-const char* currentTextBreakLocaleID()
-{
- return "en_us";
-}
-
-}
diff --git a/webkit/port/platform/chromium/WidgetChromium.cpp b/webkit/port/platform/chromium/WidgetChromium.cpp
deleted file mode 100644
index e980370..0000000
--- a/webkit/port/platform/chromium/WidgetChromium.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "Widget.h"
-
-#include "ChromiumBridge.h"
-#include "Assertions.h"
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-Widget::Widget(PlatformWidget widget)
-{
- init(widget);
-}
-
-Widget::~Widget()
-{
- ASSERT(!parent());
-}
-
-void Widget::show()
-{
-}
-
-void Widget::hide()
-{
-}
-
-void Widget::setCursor(const Cursor& cursor)
-{
- ChromiumBridge::widgetSetCursor(this, cursor);
-}
-
-void Widget::paint(GraphicsContext*, const IntRect&)
-{
-}
-
-void Widget::setFocus()
-{
- ChromiumBridge::widgetSetFocus(this);
-}
-
-void Widget::setIsSelected(bool)
-{
-}
-
-IntRect Widget::frameRect() const
-{
- return m_frame;
-}
-
-void Widget::setFrameRect(const IntRect& rect)
-{
- m_frame = rect;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/chromium/gtk2drawing.c b/webkit/port/platform/chromium/gtk2drawing.c
deleted file mode 100644
index 475e9fd..0000000
--- a/webkit/port/platform/chromium/gtk2drawing.c
+++ /dev/null
@@ -1,2815 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Brian Ryner <bryner@brianryner.com> (Original Author)
- * Pierre Chanial <p_ch@verizon.net>
- * Michael Ventnor <m.ventnor@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * This file contains painting functions for each of the gtk2 widgets.
- * Adapted from the gtkdrawing.c, and gtk+2.0 source.
- */
-
-#include <gtk/gtk.h>
-#include <gdk/gdkprivate.h>
-#include <string.h>
-#include "gtkdrawing.h"
-
-#include <math.h>
-
-#define XTHICKNESS(style) (style->xthickness)
-#define YTHICKNESS(style) (style->ythickness)
-#define WINDOW_IS_MAPPED(window) ((window) && GDK_IS_WINDOW(window) && gdk_window_is_visible(window))
-
-static GtkWidget* gProtoWindow;
-static GtkWidget* gButtonWidget;
-static GtkWidget* gToggleButtonWidget;
-static GtkWidget* gCheckboxWidget;
-static GtkWidget* gRadiobuttonWidget;
-static GtkWidget* gHorizScrollbarWidget;
-static GtkWidget* gVertScrollbarWidget;
-static GtkWidget* gSpinWidget;
-static GtkWidget* gHScaleWidget;
-static GtkWidget* gVScaleWidget;
-static GtkWidget* gEntryWidget;
-static GtkWidget* gArrowWidget;
-static GtkWidget* gOptionMenuWidget;
-static GtkWidget* gComboBoxEntryWidget;
-static GtkWidget* gDropdownEntryWidget;
-static GtkWidget* gDropdownButtonWidget;
-static GtkWidget* gHandleBoxWidget;
-static GtkWidget* gToolbarWidget;
-static GtkWidget* gFrameWidget;
-static GtkWidget* gStatusbarWidget;
-static GtkWidget* gProgressWidget;
-static GtkWidget* gTabWidget;
-static GtkWidget* gTooltipWidget;
-static GtkWidget* gMenuBarWidget;
-static GtkWidget* gMenuBarItemWidget;
-static GtkWidget* gMenuPopupWidget;
-static GtkWidget* gMenuItemWidget;
-static GtkWidget* gCheckMenuItemWidget;
-static GtkWidget* gTreeViewWidget;
-static GtkWidget* gTreeHeaderCellWidget;
-static GtkWidget* gTreeHeaderSortArrowWidget;
-static GtkWidget* gExpanderWidget;
-static GtkWidget* gToolbarSeparatorWidget;
-static GtkWidget* gMenuSeparatorWidget;
-static GtkWidget* gHPanedWidget;
-static GtkWidget* gVPanedWidget;
-
-static GtkShadowType gMenuBarShadowType;
-static GtkShadowType gToolbarShadowType;
-
-static style_prop_t style_prop_func;
-static gboolean have_menu_shadow_type;
-static gboolean is_initialized;
-
-gint
-moz_gtk_enable_style_props(style_prop_t styleGetProp)
-{
- style_prop_func = styleGetProp;
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_window_widget()
-{
- if (!gProtoWindow) {
- gProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
- gtk_widget_realize(gProtoWindow);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-setup_widget_prototype(GtkWidget* widget)
-{
- static GtkWidget* protoLayout;
- ensure_window_widget();
- if (!protoLayout) {
- protoLayout = gtk_fixed_new();
- gtk_container_add(GTK_CONTAINER(gProtoWindow), protoLayout);
- }
-
- gtk_container_add(GTK_CONTAINER(protoLayout), widget);
- gtk_widget_realize(widget);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_button_widget()
-{
- if (!gButtonWidget) {
- gButtonWidget = gtk_button_new_with_label("M");
- setup_widget_prototype(gButtonWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_hpaned_widget()
-{
- if (!gHPanedWidget) {
- gHPanedWidget = gtk_hpaned_new();
- setup_widget_prototype(gHPanedWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_vpaned_widget()
-{
- if (!gVPanedWidget) {
- gVPanedWidget = gtk_vpaned_new();
- setup_widget_prototype(gVPanedWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_toggle_button_widget()
-{
- if (!gToggleButtonWidget) {
- gToggleButtonWidget = gtk_toggle_button_new();
- setup_widget_prototype(gToggleButtonWidget);
- /* toggle button must be set active to get the right style on hover. */
- GTK_TOGGLE_BUTTON(gToggleButtonWidget)->active = TRUE;
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_checkbox_widget()
-{
- if (!gCheckboxWidget) {
- gCheckboxWidget = gtk_check_button_new_with_label("M");
- setup_widget_prototype(gCheckboxWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_radiobutton_widget()
-{
- if (!gRadiobuttonWidget) {
- gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
- setup_widget_prototype(gRadiobuttonWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_scrollbar_widget()
-{
- if (!gVertScrollbarWidget) {
- gVertScrollbarWidget = gtk_vscrollbar_new(NULL);
- setup_widget_prototype(gVertScrollbarWidget);
- }
- if (!gHorizScrollbarWidget) {
- gHorizScrollbarWidget = gtk_hscrollbar_new(NULL);
- setup_widget_prototype(gHorizScrollbarWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_spin_widget()
-{
- if (!gSpinWidget) {
- gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
- setup_widget_prototype(gSpinWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_scale_widget()
-{
- if (!gHScaleWidget) {
- gHScaleWidget = gtk_hscale_new(NULL);
- setup_widget_prototype(gHScaleWidget);
- }
- if (!gVScaleWidget) {
- gVScaleWidget = gtk_vscale_new(NULL);
- setup_widget_prototype(gVScaleWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_entry_widget()
-{
- if (!gEntryWidget) {
- gEntryWidget = gtk_entry_new();
- setup_widget_prototype(gEntryWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_option_menu_widget()
-{
- if (!gOptionMenuWidget) {
- gOptionMenuWidget = gtk_option_menu_new();
- setup_widget_prototype(gOptionMenuWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_combo_box_entry_widget()
-{
- if (!gComboBoxEntryWidget) {
- gComboBoxEntryWidget = gtk_combo_box_entry_new();
- setup_widget_prototype(gComboBoxEntryWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_dropdown_entry_widget()
-{
- if (!gDropdownEntryWidget) {
- ensure_combo_box_entry_widget();
-
- gDropdownEntryWidget = GTK_BIN(gComboBoxEntryWidget)->child;
- gtk_widget_realize(gDropdownEntryWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static void
-moz_gtk_get_dropdown_button(GtkWidget *widget,
- gpointer client_data)
-{
- if (GTK_IS_TOGGLE_BUTTON(widget))
- gDropdownButtonWidget = widget;
-}
-
-static gint
-ensure_arrow_widget()
-{
- if (!gArrowWidget) {
- ensure_combo_box_entry_widget();
-
- gtk_container_forall(GTK_CONTAINER(gComboBoxEntryWidget),
- moz_gtk_get_dropdown_button,
- NULL);
-
- gArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
- gtk_container_add(GTK_CONTAINER(GTK_BIN(gDropdownButtonWidget)->child),
- gArrowWidget);
- gtk_widget_realize(gArrowWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_handlebox_widget()
-{
- if (!gHandleBoxWidget) {
- gHandleBoxWidget = gtk_handle_box_new();
- setup_widget_prototype(gHandleBoxWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_toolbar_widget()
-{
- if (!gToolbarWidget) {
- ensure_handlebox_widget();
- gToolbarWidget = gtk_toolbar_new();
- gtk_container_add(GTK_CONTAINER(gHandleBoxWidget), gToolbarWidget);
- gtk_widget_realize(gToolbarWidget);
- gtk_widget_style_get(gToolbarWidget, "shadow_type", &gToolbarShadowType,
- NULL);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_toolbar_separator_widget()
-{
- if (!gToolbarSeparatorWidget) {
- ensure_toolbar_widget();
- gToolbarSeparatorWidget = GTK_WIDGET(gtk_separator_tool_item_new());
- setup_widget_prototype(gToolbarSeparatorWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tooltip_widget()
-{
- if (!gTooltipWidget) {
- gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
- gtk_widget_realize(gTooltipWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tab_widget()
-{
- if (!gTabWidget) {
- gTabWidget = gtk_notebook_new();
- setup_widget_prototype(gTabWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_progress_widget()
-{
- if (!gProgressWidget) {
- gProgressWidget = gtk_progress_bar_new();
- setup_widget_prototype(gProgressWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_statusbar_widget()
-{
- if (!gStatusbarWidget) {
- gStatusbarWidget = gtk_statusbar_new();
- setup_widget_prototype(gStatusbarWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_frame_widget()
-{
- if (!gFrameWidget) {
- ensure_statusbar_widget();
- gFrameWidget = gtk_frame_new(NULL);
- gtk_container_add(GTK_CONTAINER(gStatusbarWidget), gFrameWidget);
- gtk_widget_realize(gFrameWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_bar_widget()
-{
- if (!gMenuBarWidget) {
- gMenuBarWidget = gtk_menu_bar_new();
- setup_widget_prototype(gMenuBarWidget);
- gtk_widget_style_get(gMenuBarWidget, "shadow_type", &gMenuBarShadowType,
- NULL);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_bar_item_widget()
-{
- if (!gMenuBarItemWidget) {
- ensure_menu_bar_widget();
- gMenuBarItemWidget = gtk_menu_item_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuBarWidget),
- gMenuBarItemWidget);
- gtk_widget_realize(gMenuBarItemWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_popup_widget()
-{
- if (!gMenuPopupWidget) {
- ensure_menu_bar_item_widget();
- gMenuPopupWidget = gtk_menu_new();
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(gMenuBarItemWidget),
- gMenuPopupWidget);
- gtk_widget_realize(gMenuPopupWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_item_widget()
-{
- if (!gMenuItemWidget) {
- ensure_menu_popup_widget();
- gMenuItemWidget = gtk_menu_item_new_with_label("M");
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
- gMenuItemWidget);
- gtk_widget_realize(gMenuItemWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_separator_widget()
-{
- if (!gMenuSeparatorWidget) {
- ensure_menu_popup_widget();
- gMenuSeparatorWidget = gtk_separator_menu_item_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
- gMenuSeparatorWidget);
- gtk_widget_realize(gMenuSeparatorWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_check_menu_item_widget()
-{
- if (!gCheckMenuItemWidget) {
- ensure_menu_popup_widget();
- gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
- gCheckMenuItemWidget);
- gtk_widget_realize(gCheckMenuItemWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tree_view_widget()
-{
- if (!gTreeViewWidget) {
- gTreeViewWidget = gtk_tree_view_new();
- setup_widget_prototype(gTreeViewWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tree_header_cell_widget()
-{
- if(!gTreeHeaderCellWidget) {
- GtkTreeViewColumn* treeViewColumn;
- ensure_tree_view_widget();
-
- treeViewColumn = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(treeViewColumn, "M");
-
- gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), treeViewColumn);
- gTreeHeaderCellWidget = treeViewColumn->button;
- gtk_tree_view_column_set_sort_indicator(treeViewColumn, TRUE);
- gTreeHeaderSortArrowWidget = treeViewColumn->arrow;
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_expander_widget()
-{
- if (!gExpanderWidget) {
- gExpanderWidget = gtk_expander_new("M");
- setup_widget_prototype(gExpanderWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static GtkStateType
-ConvertGtkState(GtkWidgetState* state)
-{
- if (state->disabled)
- return GTK_STATE_INSENSITIVE;
- else if (state->depressed)
- return (state->inHover ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
- else if (state->inHover)
- return (state->active ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT);
- else
- return GTK_STATE_NORMAL;
-}
-
-static gint
-TSOffsetStyleGCArray(GdkGC** gcs, gint xorigin, gint yorigin)
-{
- int i;
- /* there are 5 gc's in each array, for each of the widget states */
- for (i = 0; i < 5; ++i)
- gdk_gc_set_ts_origin(gcs[i], xorigin, yorigin);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-TSOffsetStyleGCs(GtkStyle* style, gint xorigin, gint yorigin)
-{
- TSOffsetStyleGCArray(style->fg_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->bg_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->light_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->dark_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->mid_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->text_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->base_gc, xorigin, yorigin);
- gdk_gc_set_ts_origin(style->black_gc, xorigin, yorigin);
- gdk_gc_set_ts_origin(style->white_gc, xorigin, yorigin);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkReliefStyle relief, GtkWidget* widget,
- GtkTextDirection direction)
-{
- GtkShadowType shadow_type;
- GtkStyle* style = widget->style;
- GtkStateType button_state = ConvertGtkState(state);
- gint x = rect->x, y=rect->y, width=rect->width, height=rect->height;
-
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width, &focus_pad);
-
- if (WINDOW_IS_MAPPED(drawable)) {
- gdk_window_set_back_pixmap(drawable, NULL, TRUE);
- gdk_window_clear_area(drawable, cliprect->x, cliprect->y,
- cliprect->width, cliprect->height);
- }
-
- gtk_widget_set_state(widget, button_state);
- gtk_widget_set_direction(widget, direction);
-
- if (state->isDefault)
- GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_DEFAULT);
-
- if (!interior_focus && state->focused) {
- x += focus_width + focus_pad;
- y += focus_width + focus_pad;
- width -= 2 * (focus_width + focus_pad);
- height -= 2 * (focus_width + focus_pad);
- }
-
- shadow_type = button_state == GTK_STATE_ACTIVE ||
- state->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
-
- if (state->isDefault && GTK_BUTTON(widget)->relief == GTK_RELIEF_NORMAL) {
- gtk_paint_box(style, drawable, button_state, shadow_type, cliprect,
- widget, "buttondefault", x, y, width, height);
- }
-
- if (relief != GTK_RELIEF_NONE || state->depressed ||
- (button_state != GTK_STATE_NORMAL &&
- button_state != GTK_STATE_INSENSITIVE)) {
- TSOffsetStyleGCs(style, x, y);
- /* the following line can trigger an assertion (Crux theme)
- file ../../gdk/gdkwindow.c: line 1846 (gdk_window_clear_area):
- assertion `GDK_IS_WINDOW (window)' failed */
- gtk_paint_box(style, drawable, button_state, shadow_type, cliprect,
- widget, "button", x, y, width, height);
- }
-
- if (state->focused) {
- if (interior_focus) {
- x += widget->style->xthickness + focus_pad;
- y += widget->style->ythickness + focus_pad;
- width -= 2 * (widget->style->xthickness + focus_pad);
- height -= 2 * (widget->style->ythickness + focus_pad);
- } else {
- x -= focus_width + focus_pad;
- y -= focus_width + focus_pad;
- width += 2 * (focus_width + focus_pad);
- height += 2 * (focus_width + focus_pad);
- }
-
- TSOffsetStyleGCs(style, x, y);
- gtk_paint_focus(style, drawable, button_state, cliprect,
- widget, "button", x, y, width, height);
- }
-
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_DEFAULT);
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_init()
-{
- is_initialized = TRUE;
- have_menu_shadow_type =
- (gtk_major_version > 2 ||
- (gtk_major_version == 2 && gtk_minor_version >= 1));
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing)
-{
- ensure_checkbox_widget();
-
- gtk_widget_style_get (gCheckboxWidget,
- "indicator_size", indicator_size,
- "indicator_spacing", indicator_spacing,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing)
-{
- ensure_radiobutton_widget();
-
- gtk_widget_style_get (gRadiobuttonWidget,
- "indicator_size", indicator_size,
- "indicator_spacing", indicator_spacing,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus,
- gint* focus_width, gint* focus_pad)
-{
- gtk_widget_style_get (widget,
- "interior-focus", interior_focus,
- "focus-line-width", focus_width,
- "focus-padding", focus_pad,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_option_menu_get_metrics(gboolean* interior_focus,
- GtkRequisition* indicator_size,
- GtkBorder* indicator_spacing,
- gint* focus_width,
- gint* focus_pad)
-{
- static const GtkRequisition default_indicator_size = { 7, 13 };
- static const GtkBorder default_indicator_spacing = { 7, 5, 2, 2 };
- /* these default values are not used in gtkoptionmenu.c
- static const gboolean default_interior_focus = TRUE;
- static const gint default_focus_width = 1;
- static const gint default_focus_pad = 0; */
- GtkRequisition *tmp_indicator_size;
- GtkBorder *tmp_indicator_spacing;
-
- gtk_widget_style_get(gOptionMenuWidget,
- "interior_focus", interior_focus,
- "indicator_size", &tmp_indicator_size,
- "indicator_spacing", &tmp_indicator_spacing,
- "focus_line_width", focus_width,
- "focus_padding", focus_pad,
- NULL);
-
- if (tmp_indicator_size)
- *indicator_size = *tmp_indicator_size;
- else
- *indicator_size = default_indicator_size;
- if (tmp_indicator_spacing)
- *indicator_spacing = *tmp_indicator_spacing;
- else
- *indicator_spacing = default_indicator_spacing;
-
- gtk_requisition_free(tmp_indicator_size);
- gtk_border_free(tmp_indicator_spacing);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_splitter_get_metrics(gint orientation, gint* size)
-{
- if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- ensure_hpaned_widget();
- gtk_widget_style_get(gHPanedWidget, "handle_size", size, NULL);
- } else {
- ensure_vpaned_widget();
- gtk_widget_style_get(gVPanedWidget, "handle_size", size, NULL);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean selected, gboolean isradio,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = (selected)?GTK_SHADOW_IN:GTK_SHADOW_OUT;
- gint indicator_size, indicator_spacing;
- gint x, y, width, height;
- GtkWidget *w;
- GtkStyle *style;
-
- if (isradio) {
- moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
- w = gRadiobuttonWidget;
- } else {
- moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
- w = gCheckboxWidget;
- }
-
- /* offset by indicator_spacing, and centered vertically within the rect */
- x = rect->x + indicator_spacing;
- y = rect->y + (rect->height - indicator_size) / 2;
- width = indicator_size;
- height = indicator_size;
-
- style = w->style;
- TSOffsetStyleGCs(style, x, y);
-
- gtk_widget_set_sensitive(w, !state->disabled);
- gtk_widget_set_direction(w, direction);
- GTK_TOGGLE_BUTTON(w)->active = selected;
-
- if (isradio) {
- gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
- gRadiobuttonWidget, "radiobutton", x, y,
- width, height);
- if (state->focused) {
- gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
- gRadiobuttonWidget, "radiobutton", rect->x, rect->y,
- rect->width, rect->height);
- }
- }
- else {
- gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
- gCheckboxWidget, "checkbutton", x, y, width, height);
- if (state->focused) {
- gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
- gCheckboxWidget, "checkbutton", rect->x, rect->y,
- rect->width, rect->height);
- }
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-calculate_arrow_dimensions(GdkRectangle* rect, GdkRectangle* arrow_rect)
-{
- GtkMisc* misc = GTK_MISC(gArrowWidget);
-
- gint extent = MIN(rect->width - misc->xpad * 2,
- rect->height - misc->ypad * 2);
-
- arrow_rect->x = ((rect->x + misc->xpad) * (1.0 - misc->xalign) +
- (rect->x + rect->width - extent - misc->xpad) *
- misc->xalign);
-
- arrow_rect->y = ((rect->y + misc->ypad) * (1.0 - misc->yalign) +
- (rect->y + rect->height - extent - misc->ypad) *
- misc->yalign);
-
- arrow_rect->width = arrow_rect->height = extent;
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkScrollbarButtonFlags flags,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = (state->active) ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GdkRectangle button_rect;
- GdkRectangle arrow_rect;
- GtkStyle* style;
- GtkWidget *scrollbar;
- GtkArrowType arrow_type;
- const char* detail = (flags & MOZ_GTK_STEPPER_VERTICAL) ?
- "vscrollbar" : "hscrollbar";
-
- ensure_scrollbar_widget();
-
- if (flags & MOZ_GTK_STEPPER_VERTICAL)
- scrollbar = gVertScrollbarWidget;
- else
- scrollbar = gHorizScrollbarWidget;
-
- gtk_widget_set_direction(scrollbar, direction);
-
- /* Some theme engines (i.e., ClearLooks) check the scrollbar's allocation
- to determine where it should paint rounded corners on the buttons.
- We need to trick them into drawing the buttons the way we want them. */
-
- scrollbar->allocation.x = rect->x;
- scrollbar->allocation.y = rect->y;
- scrollbar->allocation.width = rect->width;
- scrollbar->allocation.height = rect->height;
-
- if (flags & MOZ_GTK_STEPPER_VERTICAL) {
- scrollbar->allocation.height *= 5;
- if (flags & MOZ_GTK_STEPPER_DOWN) {
- arrow_type = GTK_ARROW_DOWN;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.y -= 4 * rect->height;
- else
- scrollbar->allocation.y -= rect->height;
-
- } else {
- arrow_type = GTK_ARROW_UP;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.y -= 3 * rect->height;
- }
- } else {
- scrollbar->allocation.width *= 5;
- if (flags & MOZ_GTK_STEPPER_DOWN) {
- arrow_type = GTK_ARROW_RIGHT;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.x -= 4 * rect->width;
- else
- scrollbar->allocation.x -= rect->width;
- } else {
- arrow_type = GTK_ARROW_LEFT;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.x -= 3 * rect->width;
- }
- }
-
- style = scrollbar->style;
-
- ensure_arrow_widget();
-
- calculate_arrow_dimensions(rect, &button_rect);
- TSOffsetStyleGCs(style, button_rect.x, button_rect.y);
-
- gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
- scrollbar, detail, button_rect.x, button_rect.y,
- button_rect.width, button_rect.height);
-
- arrow_rect.width = button_rect.width / 2;
- arrow_rect.height = button_rect.height / 2;
- arrow_rect.x = button_rect.x + (button_rect.width - arrow_rect.width) / 2;
- arrow_rect.y = button_rect.y +
- (button_rect.height - arrow_rect.height) / 2;
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- scrollbar, detail, arrow_type, TRUE, arrow_rect.x,
- arrow_rect.y, arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scrollbar_trough_paint(GtkThemeWidgetType widget,
- GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkScrollbar *scrollbar;
-
- ensure_scrollbar_widget();
-
- if (widget == MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL)
- scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
- else
- scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
-
- gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
-
- style = GTK_WIDGET(scrollbar)->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_ACTIVE,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
-
- gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
- GTK_WIDGET(scrollbar), "trough", rect->x, rect->y,
- rect->width, rect->height);
-
- if (state->focused) {
- gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
- GTK_WIDGET(scrollbar), "trough",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget,
- GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStateType state_type = (state->inHover || state->active) ?
- GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
- GtkStyle* style;
- GtkScrollbar *scrollbar;
- GtkAdjustment *adj;
-
- ensure_scrollbar_widget();
-
- if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
- scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
- else
- scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
-
- gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
-
- /* Make sure to set the scrollbar range before painting so that
- everything is drawn properly. At least the bluecurve (and
- maybe other) themes don't draw the top or bottom black line
- surrounding the scrollbar if the theme thinks that it's butted
- up against the scrollbar arrows. Note the increases of the
- clip rect below. */
- /* Changing the cliprect is pretty bogus. This lets themes draw
- outside the frame, which means we don't invalidate them
- correctly. See bug 297508. But some themes do seem to need
- it. So we modify the frame's overflow area to account for what
- we're doing here; see nsNativeThemeGTK::GetWidgetOverflow. */
- adj = gtk_range_get_adjustment(GTK_RANGE(scrollbar));
-
- if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) {
- cliprect->x -= 1;
- cliprect->width += 2;
- adj->page_size = rect->width;
- }
- else {
- cliprect->y -= 1;
- cliprect->height += 2;
- adj->page_size = rect->height;
- }
-
- adj->lower = 0;
- adj->value = state->curpos;
- adj->upper = state->maxpos;
- gtk_adjustment_changed(adj);
-
- style = GTK_WIDGET(scrollbar)->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
- GTK_WIDGET(scrollbar), "slider", rect->x, rect->y,
- rect->width, rect->height,
- (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
- GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_spin_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_spin_widget();
- gtk_widget_set_direction(gSpinWidget, direction);
- style = gSpinWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL,
- gSpinWidget, "spinbutton",
- rect->x, rect->y, rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_spin_updown_paint(GdkDrawable* drawable, GdkRectangle* rect,
- gboolean isDown, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GdkRectangle arrow_rect;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state_type == GTK_STATE_ACTIVE ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStyle* style;
-
- ensure_spin_widget();
- style = gSpinWidget->style;
- gtk_widget_set_direction(gSpinWidget, direction);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, state_type, shadow_type, NULL, gSpinWidget,
- isDown ? "spinbutton_down" : "spinbutton_up",
- rect->x, rect->y, rect->width, rect->height);
-
- /* hard code these values */
- arrow_rect.width = 6;
- arrow_rect.height = 6;
- arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
- arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
- arrow_rect.y += isDown ? -1 : 1;
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL,
- gSpinWidget, "spinbutton",
- isDown ? GTK_ARROW_DOWN : GTK_ARROW_UP, TRUE,
- arrow_rect.x, arrow_rect.y,
- arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkOrientation flags, GtkTextDirection direction)
-{
- gint x = 0, y = 0;
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkWidget* widget;
-
- ensure_scale_widget();
- widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
-
- if (flags == GTK_ORIENTATION_HORIZONTAL) {
- x = XTHICKNESS(style);
- y++;
- }
- else {
- x++;
- y = YTHICKNESS(style);
- }
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
-
- gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
- widget, "trough", rect->x + x, rect->y + y,
- rect->width - 2*x, rect->height - 2*y);
-
- if (state->focused)
- gtk_paint_focus(style, drawable, state_type, cliprect, widget, "trough",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkOrientation flags, GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkWidget* widget;
- gint thumb_width, thumb_height, x, y;
-
- ensure_scale_widget();
- widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
-
- /* determine the thumb size, and position the thumb in the center in the opposite axis */
- if (flags == GTK_ORIENTATION_HORIZONTAL) {
- moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height);
- x = rect->x;
- y = rect->y + (rect->height - thumb_height) / 2;
- }
- else {
- moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width);
- x = rect->x + (rect->width - thumb_width) / 2;
- y = rect->y;
- }
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
- widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale",
- x, y, thumb_width, thumb_height, flags);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_gripper_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type;
- GtkStyle* style;
-
- ensure_handlebox_widget();
- gtk_widget_set_direction(gHandleBoxWidget, direction);
-
- style = gHandleBoxWidget->style;
- shadow_type = GTK_HANDLE_BOX(gHandleBoxWidget)->shadow_type;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
- gHandleBoxWidget, "handlebox_bin", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_hpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state)
-{
- GtkStateType hpaned_state = ConvertGtkState(state);
-
- ensure_hpaned_widget();
- gtk_paint_handle(gHPanedWidget->style, drawable, hpaned_state,
- GTK_SHADOW_NONE, cliprect, gHPanedWidget, "paned",
- rect->x, rect->y, rect->width, rect->height,
- GTK_ORIENTATION_VERTICAL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_vpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state)
-{
- GtkStateType vpaned_state = ConvertGtkState(state);
-
- ensure_vpaned_widget();
- gtk_paint_handle(gVPanedWidget->style, drawable, vpaned_state,
- GTK_SHADOW_NONE, cliprect, gVPanedWidget, "paned",
- rect->x, rect->y, rect->width, rect->height,
- GTK_ORIENTATION_HORIZONTAL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkWidget* widget, GtkTextDirection direction)
-{
- gint x, y, width = rect->width, height = rect->height;
- GtkStyle* style;
- gboolean interior_focus;
- gint focus_width;
-
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
-
- /* paint the background first */
- x = XTHICKNESS(style);
- y = YTHICKNESS(style);
-
- /* This gets us a lovely greyish disabledish look */
- gtk_widget_set_sensitive(widget, !state->disabled);
-
- TSOffsetStyleGCs(style, rect->x + x, rect->y + y);
- gtk_paint_flat_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
- cliprect, widget, "entry_bg", rect->x + x,
- rect->y + y, rect->width - 2*x, rect->height - 2*y);
-
- gtk_widget_style_get(widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- NULL);
-
- /*
- * Now paint the shadow and focus border.
- *
- * gtk+ is able to draw over top of the entry when it gains focus,
- * so the non-focused text border is implicitly already drawn when
- * the entry is drawn in a focused state.
- *
- * Gecko doesn't quite work this way, so always draw the non-focused
- * shadow, then draw the shadow again, inset, if we're focused.
- */
-
- x = rect->x;
- y = rect->y;
-
- if (state->focused && !state->disabled) {
- /* This will get us the lit borders that focused textboxes enjoy on some themes. */
- GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
-
- if (!interior_focus) {
- /* Indent the border a little bit if we have exterior focus
- (this is what GTK does to draw native entries) */
- x += focus_width;
- y += focus_width;
- width -= 2 * focus_width;
- height -= 2 * focus_width;
- }
- }
-
- TSOffsetStyleGCs(style, x, y);
- gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- cliprect, widget, "entry", x, y, width, height);
-
- if (state->focused && !state->disabled) {
- if (!interior_focus) {
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_focus(style, drawable, GTK_STATE_NORMAL, cliprect,
- widget, "entry",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- /* Now unset the focus flag. We don't want other entries to look like they're focused too! */
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_treeview_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- gint xthickness, ythickness;
-
- GtkStyle *style;
- GtkStateType state_type;
-
- ensure_tree_view_widget();
- gtk_widget_set_direction(gTreeViewWidget, direction);
-
- /* only handle disabled and normal states, otherwise the whole background
- * area will be painted differently with other states */
- state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
-
- /* In GTK the treeview sets the background of the window
- * which contains the cells to the treeview base color.
- * If we don't set it here the background color will not be correct.*/
- gtk_widget_modify_bg(gTreeViewWidget, state_type,
- &gTreeViewWidget->style->base[state_type]);
-
- style = gTreeViewWidget->style;
- xthickness = XTHICKNESS(style);
- ythickness = YTHICKNESS(style);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_paint_flat_box(style, drawable, state_type, GTK_SHADOW_NONE,
- cliprect, gTreeViewWidget, "treeview",
- rect->x + xthickness, rect->y + ythickness,
- rect->width - 2 * xthickness,
- rect->height - 2 * ythickness);
-
- gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- cliprect, gTreeViewWidget, "scrolled_window",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tree_header_cell_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
- gTreeHeaderCellWidget, direction);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect,
- GtkWidgetState* state, GtkArrowType flags,
- GtkTextDirection direction)
-{
- GdkRectangle arrow_rect;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = GTK_SHADOW_IN;
- GtkArrowType arrow_type = flags;
- GtkStyle* style;
-
- ensure_tree_header_cell_widget();
- gtk_widget_set_direction(gTreeHeaderSortArrowWidget, direction);
-
- /* hard code these values */
- arrow_rect.width = 11;
- arrow_rect.height = 11;
- arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
- arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
-
- style = gTreeHeaderSortArrowWidget->style;
- TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- gTreeHeaderSortArrowWidget, "arrow", arrow_type, TRUE,
- arrow_rect.x, arrow_rect.y,
- arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_treeview_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkExpanderStyle expander_state,
- GtkTextDirection direction)
-{
- GtkStyle *style;
- GtkStateType state_type;
-
- ensure_tree_view_widget();
- gtk_widget_set_direction(gTreeViewWidget, direction);
-
- style = gTreeViewWidget->style;
-
- /* Because the frame we get is of the entire treeview, we can't get the precise
- * event state of one expander, thus rendering hover and active feedback useless. */
- state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_expander(style, drawable, state_type, cliprect, gTreeViewWidget, "treeview",
- rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkExpanderStyle expander_state,
- GtkTextDirection direction)
-{
- GtkStyle *style;
- GtkStateType state_type = ConvertGtkState(state);
-
- ensure_expander_widget();
- gtk_widget_set_direction(gExpanderWidget, direction);
-
- style = gExpanderWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_expander(style, drawable, state_type, cliprect, gExpanderWidget, "expander",
- rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_option_menu_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkStateType state_type = ConvertGtkState(state);
- gint x = rect->x, y=rect->y, width=rect->width, height=rect->height;
- gint tab_x, tab_y;
- gboolean interior_focus;
- GtkRequisition indicator_size;
- GtkBorder indicator_spacing;
- gint focus_width;
- gint focus_pad;
-
- ensure_option_menu_widget();
- gtk_widget_set_direction(gOptionMenuWidget, direction);
- moz_gtk_option_menu_get_metrics(&interior_focus, &indicator_size,
- &indicator_spacing, &focus_width,
- &focus_pad);
-
- style = gOptionMenuWidget->style;
-
- if (!interior_focus && state->focused) {
- x += focus_width + focus_pad;
- y += focus_width + focus_pad;
- width -= 2 * (focus_width + focus_pad);
- height -= 2 * (focus_width + focus_pad);
- }
-
- TSOffsetStyleGCs(style, x, y);
- gtk_paint_box(style, drawable, state_type, GTK_SHADOW_OUT,
- cliprect, gOptionMenuWidget, "optionmenu",
- x, y, width, height);
-
- if (direction == GTK_TEXT_DIR_RTL) {
- tab_x = x + indicator_spacing.right + XTHICKNESS(style);
- } else {
- tab_x = x + width - indicator_size.width - indicator_spacing.right -
- XTHICKNESS(style);
- }
- tab_y = y + (height - indicator_size.height) / 2;
-
- TSOffsetStyleGCs(style, tab_x, tab_y);
- gtk_paint_tab(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
- gOptionMenuWidget, "optionmenutab", tab_x, tab_y,
- indicator_size.width, indicator_size.height);
-
- if (state->focused) {
- if (interior_focus) {
- x += XTHICKNESS(style) + focus_pad;
- y += YTHICKNESS(style) + focus_pad;
- /* Standard GTK combos have their focus ring around the entire
- control, not just the text bit */
- width -= 2 * (XTHICKNESS(style) + focus_pad);
- height -= 2 * (YTHICKNESS(style) + focus_pad);
- } else {
- x -= focus_width + focus_pad;
- y -= focus_width + focus_pad;
- width += 2 * (focus_width + focus_pad);
- height += 2 * (focus_width + focus_pad);
- }
-
- TSOffsetStyleGCs(style, x, y);
- gtk_paint_focus (style, drawable, state_type, cliprect, gOptionMenuWidget,
- "button", x, y, width, height);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_downarrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state)
-{
- GtkStyle* style;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GdkRectangle arrow_rect;
-
- ensure_arrow_widget();
- style = gArrowWidget->style;
-
- arrow_rect.x = rect->x + 1 + XTHICKNESS(style);
- arrow_rect.y = rect->y + 1 + YTHICKNESS(style);
- arrow_rect.width = MAX(1, rect->width - (arrow_rect.x - rect->x) * 2);
- arrow_rect.height = MAX(1, rect->height - (arrow_rect.y - rect->y) * 2);
-
- TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- gArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE,
- arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_dropdown_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- static gfloat arrow_scaling = 0.7;
- gint real_arrow_padding;
- GdkRectangle arrow_rect, real_arrow_rect;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStyle* style;
-
- ensure_arrow_widget();
- gtk_widget_set_direction(gDropdownButtonWidget, direction);
-
- moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
- gDropdownButtonWidget, direction);
-
- /* This mirrors gtkbutton's child positioning */
- style = gDropdownButtonWidget->style;
- arrow_rect.x = rect->x + 1 + XTHICKNESS(style);
- arrow_rect.y = rect->y + 1 + YTHICKNESS(style);
- arrow_rect.width = MAX(1, rect->width - (arrow_rect.x - rect->x) * 2);
- arrow_rect.height = MAX(1, rect->height - (arrow_rect.y - rect->y) * 2);
-
- calculate_arrow_dimensions(&arrow_rect, &real_arrow_rect);
- style = gArrowWidget->style;
- TSOffsetStyleGCs(style, real_arrow_rect.x, real_arrow_rect.y);
-
- real_arrow_rect.width = real_arrow_rect.height =
- MIN (real_arrow_rect.width, real_arrow_rect.height) * arrow_scaling;
-
- real_arrow_padding = floor((arrow_rect.width - real_arrow_rect.width) / 2 + 0.5);
- real_arrow_rect.x = arrow_rect.x + real_arrow_padding;
- if (direction == GTK_TEXT_DIR_RTL)
- real_arrow_rect.x = arrow_rect.x + arrow_rect.width -
- real_arrow_rect.width - real_arrow_padding;
- real_arrow_rect.y = floor (arrow_rect.y + ((arrow_rect.height - real_arrow_rect.height) / 2) + 0.5);
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- gDropdownButtonWidget, "arrow", GTK_ARROW_DOWN, TRUE,
- real_arrow_rect.x, real_arrow_rect.y,
- real_arrow_rect.width, real_arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_container_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean isradio, GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkWidget *widget;
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- if (isradio) {
- ensure_radiobutton_widget();
- widget = gRadiobuttonWidget;
- } else {
- ensure_checkbox_widget();
- widget = gCheckboxWidget;
- }
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
- moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width,
- &focus_pad);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- /* The detail argument for the gtk_paint_* calls below are "checkbutton"
- even for radio buttons, to match what gtk does. */
-
- /* this is for drawing a prelight box */
- if (state_type == GTK_STATE_PRELIGHT || state_type == GTK_STATE_ACTIVE) {
- gtk_paint_flat_box(style, drawable, GTK_STATE_PRELIGHT,
- GTK_SHADOW_ETCHED_OUT, cliprect, widget,
- "checkbutton",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- if (state_type != GTK_STATE_NORMAL && state_type != GTK_STATE_PRELIGHT)
- state_type = GTK_STATE_NORMAL;
-
- if (state->focused && !interior_focus) {
- gtk_paint_focus(style, drawable, state_type, cliprect, widget,
- "checkbutton",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toggle_label_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean isradio, GtkTextDirection direction)
-{
- GtkStateType state_type;
- GtkStyle *style;
- GtkWidget *widget;
- gboolean interior_focus;
-
- if (!state->focused)
- return MOZ_GTK_SUCCESS;
-
- if (isradio) {
- ensure_radiobutton_widget();
- widget = gRadiobuttonWidget;
- } else {
- ensure_checkbox_widget();
- widget = gCheckboxWidget;
- }
- gtk_widget_set_direction(widget, direction);
-
- gtk_widget_style_get(widget, "interior-focus", &interior_focus, NULL);
- if (!interior_focus)
- return MOZ_GTK_SUCCESS;
-
- state_type = ConvertGtkState(state);
-
- style = widget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- /* Always "checkbutton" to match gtkcheckbutton.c */
- gtk_paint_focus(style, drawable, state_type, cliprect, widget,
- "checkbutton",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toolbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
-
- ensure_toolbar_widget();
- gtk_widget_set_direction(gToolbarWidget, direction);
-
- style = gToolbarWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
-
- gtk_paint_box (style, drawable, GTK_STATE_NORMAL, gToolbarShadowType,
- cliprect, gToolbarWidget, "toolbar",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toolbar_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- gint separator_width;
- gint paint_width;
- gboolean wide_separators;
-
- /* Defined as constants in GTK+ 2.10.14 */
- const double start_fraction = 0.2;
- const double end_fraction = 0.8;
-
- ensure_toolbar_separator_widget();
- gtk_widget_set_direction(gToolbarSeparatorWidget, direction);
-
- style = gToolbarSeparatorWidget->style;
-
- gtk_widget_style_get(gToolbarWidget,
- "wide-separators", &wide_separators,
- "separator-width", &separator_width,
- NULL);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if (wide_separators) {
- if (separator_width > rect->width)
- separator_width = rect->width;
-
- gtk_paint_box(style, drawable,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
- cliprect, gToolbarWidget, "vseparator",
- rect->x + (rect->width - separator_width) / 2,
- rect->y + rect->height * start_fraction,
- separator_width,
- rect->height * (end_fraction - start_fraction));
-
- } else {
- paint_width = style->xthickness;
-
- if (paint_width > rect->width)
- paint_width = rect->width;
-
- gtk_paint_vline(style, drawable,
- GTK_STATE_NORMAL, cliprect, gToolbarSeparatorWidget,
- "toolbar",
- rect->y + rect->height * start_fraction,
- rect->y + rect->height * end_fraction,
- rect->x + (rect->width - paint_width) / 2);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tooltip_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_tooltip_widget();
- gtk_widget_set_direction(gTooltipWidget, direction);
-
- style = gtk_rc_get_style_by_paths(gtk_settings_get_default(),
- "gtk-tooltips", "GtkWindow",
- GTK_TYPE_WINDOW);
-
- style = gtk_style_attach(style, gTooltipWidget->window);
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_flat_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTooltipWidget, "tooltip",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_resizer_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkStateType state_type = ConvertGtkState(state);
-
- ensure_window_widget();
- gtk_widget_set_direction(gProtoWindow, direction);
-
- style = gProtoWindow->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_paint_resize_grip(style, drawable, state_type, cliprect, gProtoWindow,
- NULL, (direction == GTK_TEXT_DIR_LTR) ?
- GDK_WINDOW_EDGE_SOUTH_EAST :
- GDK_WINDOW_EDGE_SOUTH_WEST,
- rect->x, rect->y, rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_frame_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
-
- ensure_frame_widget();
- gtk_widget_set_direction(gFrameWidget, direction);
-
- style = gFrameWidget->style;
-
- gtk_widget_style_get(gStatusbarWidget, "shadow-type", &shadow_type, NULL);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, shadow_type,
- cliprect, gFrameWidget, "frame", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_progressbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_progress_widget();
- gtk_widget_set_direction(gProgressWidget, direction);
-
- style = gProgressWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- cliprect, gProgressWidget, "trough", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_progress_widget();
- gtk_widget_set_direction(gProgressWidget, direction);
-
- style = gProgressWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
- cliprect, gProgressWidget, "bar", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_tab_thickness(void)
-{
- ensure_tab_widget();
- if (YTHICKNESS(gTabWidget->style) < 2)
- return 2; /* some themes don't set ythickness correctly */
-
- return YTHICKNESS(gTabWidget->style);
-}
-
-static gint
-moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTabFlags flags,
- GtkTextDirection direction)
-{
- /* When the tab isn't selected, we just draw a notebook extension.
- * When it is selected, we overwrite the adjacent border of the tabpanel
- * touching the tab with a pierced border (called "the gap") to make the
- * tab appear physically attached to the tabpanel; see details below. */
-
- GtkStyle* style;
-
- ensure_tab_widget();
- gtk_widget_set_direction(gTabWidget, direction);
-
- style = gTabWidget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if ((flags & MOZ_GTK_TAB_SELECTED) == 0) {
- /* Only draw the tab */
- gtk_paint_extension(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "tab",
- rect->x, rect->y, rect->width, rect->height,
- (flags & MOZ_GTK_TAB_BOTTOM) ?
- GTK_POS_TOP : GTK_POS_BOTTOM );
- } else {
- /* Draw the tab and the gap
- * We want the gap to be positionned exactly on the tabpanel top
- * border; since tabbox.css may set a negative margin so that the tab
- * frame rect already overlaps the tabpanel frame rect, we need to take
- * that into account when drawing. To that effect, nsNativeThemeGTK
- * passes us this negative margin (bmargin in the graphic below) in the
- * lowest bits of |flags|. We use it to set gap_voffset, the distance
- * between the top of the gap and the bottom of the tab (resp. the
- * bottom of the gap and the top of the tab when we draw a bottom tab),
- * while ensuring that the gap always touches the border of the tab,
- * i.e. 0 <= gap_voffset <= gap_height, to avoid surprinsing results
- * with big negative or positive margins.
- * Here is a graphical explanation in the case of top tabs:
- * ___________________________
- * / \
- * | T A B |
- * ----------|. . . . . . . . . . . . . . .|----- top of tabpanel
- * : ^ bmargin : ^
- * : | (-negative margin, : |
- * bottom : v passed in flags) : | gap_height
- * of -> :.............................: | (the size of the
- * the tab . part of the gap . | tabpanel top border)
- * . outside of the tab . v
- * ----------------------------------------------
- *
- * To draw the gap, we use gtk_paint_box_gap(), see comment in
- * moz_gtk_tabpanels_paint(). This box_gap is made 3 * gap_height tall,
- * which should suffice to ensure that the only visible border is the
- * pierced one. If the tab is in the middle, we make the box_gap begin
- * a bit to the left of the tab and end a bit to the right, adjusting
- * the gap position so it still is under the tab, because we want the
- * rendering of a gap in the middle of a tabpanel. This is the role of
- * the gints gap_{l,r}_offset. On the contrary, if the tab is the
- * first, we align the start border of the box_gap with the start
- * border of the tab (left if LTR, right if RTL), by setting the
- * appropriate offset to 0.*/
- gint gap_loffset, gap_roffset, gap_voffset, gap_height;
-
- /* Get height needed by the gap */
- gap_height = moz_gtk_get_tab_thickness();
-
- /* Extract gap_voffset from the first bits of flags */
- gap_voffset = flags & MOZ_GTK_TAB_MARGIN_MASK;
- if (gap_voffset > gap_height)
- gap_voffset = gap_height;
-
- /* Set gap_{l,r}_offset to appropriate values */
- gap_loffset = gap_roffset = 20; /* should be enough */
- if (flags & MOZ_GTK_TAB_FIRST) {
- if (direction == GTK_TEXT_DIR_RTL)
- gap_roffset = 0;
- else
- gap_loffset = 0;
- }
-
- if (flags & MOZ_GTK_TAB_BOTTOM) {
- /* Enlarge the cliprect to have room for the full gap height */
- cliprect->height += gap_height - gap_voffset;
- cliprect->y -= gap_height - gap_voffset;
-
- /* Draw the tab */
- gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
- rect->x, rect->y + gap_voffset, rect->width,
- rect->height - gap_voffset, GTK_POS_TOP);
-
- /* Draw the gap; erase with background color before painting in
- * case theme does not */
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL, cliprect,
- rect->x,
- rect->y + gap_voffset
- - gap_height,
- rect->width, gap_height);
- gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "notebook",
- rect->x - gap_loffset,
- rect->y + gap_voffset - 3 * gap_height,
- rect->width + gap_loffset + gap_roffset,
- 3 * gap_height, GTK_POS_BOTTOM,
- gap_loffset, rect->width);
- } else {
- /* Enlarge the cliprect to have room for the full gap height */
- cliprect->height += gap_height - gap_voffset;
-
- /* Draw the tab */
- gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
- rect->x, rect->y, rect->width,
- rect->height - gap_voffset, GTK_POS_BOTTOM);
-
- /* Draw the gap; erase with background color before painting in
- * case theme does not */
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL, cliprect,
- rect->x,
- rect->y + rect->height
- - gap_voffset,
- rect->width, gap_height);
- gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "notebook",
- rect->x - gap_loffset,
- rect->y + rect->height - gap_voffset,
- rect->width + gap_loffset + gap_roffset,
- 3 * gap_height, GTK_POS_TOP,
- gap_loffset, rect->width);
- }
-
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tabpanels_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- /* We use gtk_paint_box_gap() to draw the tabpanels widget. gtk_paint_box()
- * draws an all-purpose box, which a lot of themes render differently.
- * A zero-width gap is still visible in most themes, so we hide it to the
- * left (10px should be enough) */
- GtkStyle* style;
-
- ensure_tab_widget();
- gtk_widget_set_direction(gTabWidget, direction);
-
- style = gTabWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "notebook", rect->x, rect->y,
- rect->width, rect->height,
- GTK_POS_TOP, -10, 0);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_bar_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
- ensure_menu_bar_widget();
- gtk_widget_set_direction(gMenuBarWidget, direction);
-
- style = gMenuBarWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, gMenuBarShadowType,
- cliprect, gMenuBarWidget, "menubar", rect->x, rect->y,
- rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_popup_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- ensure_menu_popup_widget();
- gtk_widget_set_direction(gMenuPopupWidget, direction);
-
- style = gMenuPopupWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gMenuPopupWidget, "menu",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- gboolean wide_separators;
- gint separator_height;
- guint horizontal_padding;
- gint paint_height;
-
- ensure_menu_separator_widget();
- gtk_widget_set_direction(gMenuSeparatorWidget, direction);
-
- style = gMenuSeparatorWidget->style;
-
- gtk_widget_style_get(gMenuSeparatorWidget,
- "wide-separators", &wide_separators,
- "separator-height", &separator_height,
- "horizontal-padding", &horizontal_padding,
- NULL);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if (wide_separators) {
- if (separator_height > rect->height)
- separator_height = rect->height;
-
- gtk_paint_box(style, drawable,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
- cliprect, gMenuSeparatorWidget, "hseparator",
- rect->x + horizontal_padding + style->xthickness,
- rect->y + (rect->height - separator_height - style->ythickness) / 2,
- rect->width - 2 * (horizontal_padding + style->xthickness),
- separator_height);
- } else {
- paint_height = style->ythickness;
- if (paint_height > rect->height)
- paint_height = rect->height;
-
- gtk_paint_hline(style, drawable,
- GTK_STATE_NORMAL, cliprect, gMenuSeparatorWidget,
- "menuitem",
- rect->x + horizontal_padding + style->xthickness,
- rect->x + rect->width - horizontal_padding - style->xthickness - 1,
- rect->y + (rect->height - style->ythickness) / 2);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gint flags, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
- GtkWidget* item_widget;
-
- if (state->inHover && !state->disabled) {
- if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
- ensure_menu_bar_item_widget();
- item_widget = gMenuBarItemWidget;
- } else {
- ensure_menu_item_widget();
- item_widget = gMenuItemWidget;
- }
- gtk_widget_set_direction(item_widget, direction);
-
- style = item_widget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
- if (have_menu_shadow_type) {
- gtk_widget_style_get(item_widget, "selected_shadow_type",
- &shadow_type, NULL);
- } else {
- shadow_type = GTK_SHADOW_OUT;
- }
-
- gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, shadow_type,
- cliprect, item_widget, "menuitem", rect->x, rect->y,
- rect->width, rect->height);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkStateType state_type = ConvertGtkState(state);
-
- ensure_menu_item_widget();
- gtk_widget_set_direction(gMenuItemWidget, direction);
-
- style = gMenuItemWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_arrow(style, drawable, state_type,
- (state_type == GTK_STATE_PRELIGHT) ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
- cliprect, gMenuItemWidget, "menuitem",
- (direction == GTK_TEXT_DIR_LTR) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT,
- TRUE, rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_check_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean checked, gboolean isradio,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkShadowType shadow_type = (checked)?GTK_SHADOW_IN:GTK_SHADOW_OUT;
- gint offset;
- gint indicator_size;
- gint x, y;
-
- moz_gtk_menu_item_paint(drawable, rect, cliprect, state, FALSE, direction);
-
- ensure_check_menu_item_widget();
- gtk_widget_set_direction(gCheckMenuItemWidget, direction);
-
- gtk_widget_style_get (gCheckMenuItemWidget,
- "indicator-size", &indicator_size,
- NULL);
-
- if (checked || GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget)->always_show_toggle) {
- style = gCheckMenuItemWidget->style;
-
- offset = GTK_CONTAINER(gCheckMenuItemWidget)->border_width +
- gCheckMenuItemWidget->style->xthickness + 2;
-
- /* while normally this "3" would be the horizontal-padding style value, passing it to Gecko
- as the value of menuitem padding causes problems with dropdowns (bug 406129), so in the menu.css
- file this is hardcoded as 3px. Yes it sucks, but we don't really have a choice. */
- x = (direction == GTK_TEXT_DIR_RTL) ?
- rect->width - indicator_size - offset - 3: rect->x + offset + 3;
- y = rect->y + (rect->height - indicator_size) / 2;
-
- TSOffsetStyleGCs(style, x, y);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget),
- checked);
-
- if (isradio) {
- gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
- gCheckMenuItemWidget, "option",
- x, y, indicator_size, indicator_size);
- } else {
- gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
- gCheckMenuItemWidget, "check",
- x, y, indicator_size, indicator_size);
- }
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_window_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_window_widget();
- gtk_widget_set_direction(gProtoWindow, direction);
-
- style = gProtoWindow->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
- gint* right, gint* bottom, GtkTextDirection direction,
- gboolean inhtml)
-{
- GtkWidget* w;
-
- switch (widget) {
- case MOZ_GTK_BUTTON:
- {
- /* Constant in gtkbutton.c */
- static const gint child_spacing = 1;
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- ensure_button_widget();
- *left = *top = *right = *bottom = GTK_CONTAINER(gButtonWidget)->border_width;
-
- /* Don't add this padding in HTML, otherwise the buttons will
- become too big and stuff the layout. */
- if (!inhtml) {
- moz_gtk_widget_get_focus(gButtonWidget, &interior_focus, &focus_width, &focus_pad);
- *left += focus_width + focus_pad + child_spacing;
- *right += focus_width + focus_pad + child_spacing;
- *top += focus_width + focus_pad + child_spacing;
- *bottom += focus_width + focus_pad + child_spacing;
- }
-
- *left += gButtonWidget->style->xthickness;
- *right += gButtonWidget->style->xthickness;
- *top += gButtonWidget->style->ythickness;
- *bottom += gButtonWidget->style->ythickness;
- return MOZ_GTK_SUCCESS;
- }
-
- case MOZ_GTK_TOOLBAR:
- ensure_toolbar_widget();
- w = gToolbarWidget;
- break;
- case MOZ_GTK_ENTRY:
- ensure_entry_widget();
- w = gEntryWidget;
- break;
- case MOZ_GTK_TREEVIEW:
- ensure_tree_view_widget();
- w = gTreeViewWidget;
- break;
- case MOZ_GTK_TREE_HEADER_CELL:
- {
- /* A Tree Header in GTK is just a different styled button
- * It must be placed in a TreeView for getting the correct style
- * assigned.
- * That is why the following code is the same as for MOZ_GTK_BUTTON.
- * */
-
- /* Constant in gtkbutton.c */
- static const gint child_spacing = 1;
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- ensure_tree_header_cell_widget();
- *left = *top = *right = *bottom = GTK_CONTAINER(gTreeHeaderCellWidget)->border_width;
-
- moz_gtk_widget_get_focus(gTreeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad);
- *left += focus_width + focus_pad;
- *right += focus_width + focus_pad;
- *top += focus_width + focus_pad + child_spacing;
- *bottom += focus_width + focus_pad + child_spacing;
-
- *left += gTreeHeaderCellWidget->style->xthickness;
- *right += gTreeHeaderCellWidget->style->xthickness;
- *top += gTreeHeaderCellWidget->style->ythickness;
- *bottom += gTreeHeaderCellWidget->style->ythickness;
- return MOZ_GTK_SUCCESS;
- }
- case MOZ_GTK_TREE_HEADER_SORTARROW:
- ensure_tree_header_cell_widget();
- w = gTreeHeaderSortArrowWidget;
- break;
- case MOZ_GTK_DROPDOWN_ENTRY:
- ensure_dropdown_entry_widget();
- w = gDropdownEntryWidget;
- break;
- case MOZ_GTK_DROPDOWN_ARROW:
- ensure_arrow_widget();
- w = gDropdownButtonWidget;
- break;
- case MOZ_GTK_DROPDOWN:
- {
- /* We need to account for the arrow on the dropdown, so text doesn't
- come too close to the arrow, or in some cases spill into the arrow. */
- gboolean interior_focus;
- GtkRequisition indicator_size;
- GtkBorder indicator_spacing;
- gint focus_width, focus_pad;
-
- ensure_option_menu_widget();
- *right = *left = gOptionMenuWidget->style->xthickness;
- *bottom = *top = gOptionMenuWidget->style->ythickness;
- moz_gtk_option_menu_get_metrics(&interior_focus, &indicator_size,
- &indicator_spacing, &focus_width, &focus_pad);
-
- if (direction == GTK_TEXT_DIR_RTL)
- *left += indicator_spacing.left + indicator_size.width + indicator_spacing.right;
- else
- *right += indicator_spacing.left + indicator_size.width + indicator_spacing.right;
- return MOZ_GTK_SUCCESS;
- }
- case MOZ_GTK_TABPANELS:
- ensure_tab_widget();
- w = gTabWidget;
- break;
- case MOZ_GTK_PROGRESSBAR:
- ensure_progress_widget();
- w = gProgressWidget;
- break;
- case MOZ_GTK_SPINBUTTON_ENTRY:
- case MOZ_GTK_SPINBUTTON_UP:
- case MOZ_GTK_SPINBUTTON_DOWN:
- ensure_spin_widget();
- w = gSpinWidget;
- break;
- case MOZ_GTK_SCALE_HORIZONTAL:
- ensure_scale_widget();
- w = gHScaleWidget;
- break;
- case MOZ_GTK_SCALE_VERTICAL:
- ensure_scale_widget();
- w = gVScaleWidget;
- break;
- case MOZ_GTK_FRAME:
- ensure_frame_widget();
- w = gFrameWidget;
- break;
- case MOZ_GTK_CHECKBUTTON_LABEL:
- case MOZ_GTK_RADIOBUTTON_LABEL:
- {
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- /* If the focus is interior, then the label has a border of
- (focus_width + focus_pad). */
- if (widget == MOZ_GTK_CHECKBUTTON_LABEL) {
- ensure_checkbox_widget();
- moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
- &focus_width, &focus_pad);
- }
- else {
- ensure_radiobutton_widget();
- moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
- &focus_width, &focus_pad);
- }
-
- if (interior_focus)
- *left = *top = *right = *bottom = (focus_width + focus_pad);
- else
- *left = *top = *right = *bottom = 0;
-
- return MOZ_GTK_SUCCESS;
- }
-
- case MOZ_GTK_CHECKBUTTON_CONTAINER:
- case MOZ_GTK_RADIOBUTTON_CONTAINER:
- {
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- /* If the focus is _not_ interior, then the container has a border
- of (focus_width + focus_pad). */
- if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
- ensure_checkbox_widget();
- moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
- &focus_width, &focus_pad);
- w = gCheckboxWidget;
- } else {
- ensure_radiobutton_widget();
- moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
- &focus_width, &focus_pad);
- w = gRadiobuttonWidget;
- }
-
- *left = *top = *right = *bottom = GTK_CONTAINER(w)->border_width;
-
- if (!interior_focus) {
- *left += (focus_width + focus_pad);
- *right += (focus_width + focus_pad);
- *top += (focus_width + focus_pad);
- *bottom += (focus_width + focus_pad);
- }
-
- return MOZ_GTK_SUCCESS;
- }
- case MOZ_GTK_MENUBAR:
- ensure_menu_bar_widget();
- w = gMenuBarWidget;
- break;
- case MOZ_GTK_MENUPOPUP:
- ensure_menu_popup_widget();
- w = gMenuPopupWidget;
- break;
- case MOZ_GTK_MENUITEM:
- ensure_menu_item_widget();
- ensure_menu_bar_item_widget();
- w = gMenuItemWidget;
- break;
- case MOZ_GTK_CHECKMENUITEM:
- case MOZ_GTK_RADIOMENUITEM:
- ensure_check_menu_item_widget();
- w = gCheckMenuItemWidget;
- break;
- case MOZ_GTK_TAB:
- ensure_tab_widget();
- w = gTabWidget;
- break;
- /* These widgets have no borders, since they are not containers. */
- case MOZ_GTK_SPLITTER_HORIZONTAL:
- case MOZ_GTK_SPLITTER_VERTICAL:
- case MOZ_GTK_CHECKBUTTON:
- case MOZ_GTK_RADIOBUTTON:
- case MOZ_GTK_SCROLLBAR_BUTTON:
- case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
- case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
- case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
- case MOZ_GTK_SCALE_THUMB_VERTICAL:
- case MOZ_GTK_GRIPPER:
- case MOZ_GTK_PROGRESS_CHUNK:
- case MOZ_GTK_EXPANDER:
- case MOZ_GTK_TOOLBAR_SEPARATOR:
- case MOZ_GTK_MENUSEPARATOR:
- /* These widgets have no borders.*/
- case MOZ_GTK_SPINBUTTON:
- case MOZ_GTK_TOOLTIP:
- case MOZ_GTK_WINDOW:
- case MOZ_GTK_RESIZER:
- case MOZ_GTK_MENUARROW:
- case MOZ_GTK_TOOLBARBUTTON_ARROW:
- *left = *top = *right = *bottom = 0;
- return MOZ_GTK_SUCCESS;
- default:
- g_warning("Unsupported widget type: %d", widget);
- return MOZ_GTK_UNKNOWN_WIDGET;
- }
-
- *right = *left = XTHICKNESS(w->style);
- *bottom = *top = YTHICKNESS(w->style);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_dropdown_arrow_size(gint* width, gint* height)
-{
- const gint min_arrow_size = 15;
- ensure_arrow_widget();
-
- /*
- * First get the border of the dropdown arrow, then add in the requested
- * size of the arrow. Note that the minimum arrow size is fixed at
- * 15 pixels.
- */
-
- *width = 2 * (1 + XTHICKNESS(gDropdownButtonWidget->style));
- *width += min_arrow_size + GTK_MISC(gArrowWidget)->xpad * 2;
-
- *height = 2 * (1 + YTHICKNESS(gDropdownButtonWidget->style));
- *height += min_arrow_size + GTK_MISC(gArrowWidget)->ypad * 2;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_toolbar_separator_width(gint* size)
-{
- gboolean wide_separators;
- gint separator_width;
- GtkStyle* style;
-
- ensure_toolbar_widget();
-
- style = gToolbarWidget->style;
-
- gtk_widget_style_get(gToolbarWidget,
- "space-size", size,
- "wide-separators", &wide_separators,
- "separator-width", &separator_width,
- NULL);
-
- /* Just in case... */
- *size = MAX(*size, (wide_separators ? separator_width : style->xthickness));
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_expander_size(gint* size)
-{
- ensure_expander_widget();
- gtk_widget_style_get(gExpanderWidget,
- "expander-size", size,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_treeview_expander_size(gint* size)
-{
- ensure_tree_view_widget();
- gtk_widget_style_get(gTreeViewWidget,
- "expander-size", size,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_menu_separator_height(gint *size)
-{
- gboolean wide_separators;
- gint separator_height;
-
- ensure_menu_separator_widget();
-
- gtk_widget_style_get(gMenuSeparatorWidget,
- "wide-separators", &wide_separators,
- "separator-height", &separator_height,
- NULL);
-
- if (wide_separators)
- *size = separator_height + gMenuSeparatorWidget->style->ythickness;
- else
- *size = gMenuSeparatorWidget->style->ythickness * 2;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height)
-{
- GtkWidget* widget;
-
- ensure_scale_widget();
- widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
-
- gtk_widget_style_get (widget,
- "slider_length", thumb_length,
- "slider_width", thumb_height,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
-{
- ensure_scrollbar_widget();
-
- gtk_widget_style_get (gHorizScrollbarWidget,
- "slider_width", &metrics->slider_width,
- "trough_border", &metrics->trough_border,
- "stepper_size", &metrics->stepper_size,
- "stepper_spacing", &metrics->stepper_spacing,
- NULL);
-
- metrics->min_slider_size =
- GTK_RANGE(gHorizScrollbarWidget)->min_slider_size;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
- GdkRectangle* rect, GdkRectangle* cliprect,
- GtkWidgetState* state, gint flags,
- GtkTextDirection direction)
-{
- switch (widget) {
- case MOZ_GTK_BUTTON:
- if (state->depressed) {
- ensure_toggle_button_widget();
- return moz_gtk_button_paint(drawable, rect, cliprect, state,
- (GtkReliefStyle) flags,
- gToggleButtonWidget, direction);
- }
- ensure_button_widget();
- return moz_gtk_button_paint(drawable, rect, cliprect, state,
- (GtkReliefStyle) flags, gButtonWidget,
- direction);
- break;
- case MOZ_GTK_CHECKBUTTON:
- case MOZ_GTK_RADIOBUTTON:
- return moz_gtk_toggle_paint(drawable, rect, cliprect, state,
- (gboolean) flags,
- (widget == MOZ_GTK_RADIOBUTTON),
- direction);
- break;
- case MOZ_GTK_SCROLLBAR_BUTTON:
- return moz_gtk_scrollbar_button_paint(drawable, rect, cliprect, state,
- (GtkScrollbarButtonFlags) flags,
- direction);
- break;
- case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
- return moz_gtk_scrollbar_trough_paint(widget, drawable, rect,
- cliprect, state, direction);
- break;
- case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
- return moz_gtk_scrollbar_thumb_paint(widget, drawable, rect,
- cliprect, state, direction);
- break;
- case MOZ_GTK_SCALE_HORIZONTAL:
- case MOZ_GTK_SCALE_VERTICAL:
- return moz_gtk_scale_paint(drawable, rect, cliprect, state,
- (GtkOrientation) flags, direction);
- break;
- case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
- case MOZ_GTK_SCALE_THUMB_VERTICAL:
- return moz_gtk_scale_thumb_paint(drawable, rect, cliprect, state,
- (GtkOrientation) flags, direction);
- break;
- case MOZ_GTK_SPINBUTTON:
- return moz_gtk_spin_paint(drawable, rect, direction);
- break;
- case MOZ_GTK_SPINBUTTON_UP:
- case MOZ_GTK_SPINBUTTON_DOWN:
- return moz_gtk_spin_updown_paint(drawable, rect,
- (widget == MOZ_GTK_SPINBUTTON_DOWN),
- state, direction);
- break;
- case MOZ_GTK_SPINBUTTON_ENTRY:
- ensure_spin_widget();
- return moz_gtk_entry_paint(drawable, rect, cliprect, state,
- gSpinWidget, direction);
- break;
- case MOZ_GTK_GRIPPER:
- return moz_gtk_gripper_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_TREEVIEW:
- return moz_gtk_treeview_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_TREE_HEADER_CELL:
- return moz_gtk_tree_header_cell_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_TREE_HEADER_SORTARROW:
- return moz_gtk_tree_header_sort_arrow_paint(drawable, rect, cliprect,
- state,
- (GtkArrowType) flags,
- direction);
- break;
- case MOZ_GTK_TREEVIEW_EXPANDER:
- return moz_gtk_treeview_expander_paint(drawable, rect, cliprect, state,
- (GtkExpanderStyle) flags, direction);
- break;
- case MOZ_GTK_EXPANDER:
- return moz_gtk_expander_paint(drawable, rect, cliprect, state,
- (GtkExpanderStyle) flags, direction);
- break;
- case MOZ_GTK_ENTRY:
- ensure_entry_widget();
- return moz_gtk_entry_paint(drawable, rect, cliprect, state,
- gEntryWidget, direction);
- break;
- case MOZ_GTK_DROPDOWN:
- return moz_gtk_option_menu_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_DROPDOWN_ARROW:
- return moz_gtk_dropdown_arrow_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_DROPDOWN_ENTRY:
- ensure_dropdown_entry_widget();
- return moz_gtk_entry_paint(drawable, rect, cliprect, state,
- gDropdownEntryWidget, direction);
- break;
- case MOZ_GTK_CHECKBUTTON_CONTAINER:
- case MOZ_GTK_RADIOBUTTON_CONTAINER:
- return moz_gtk_container_paint(drawable, rect, cliprect, state,
- (widget == MOZ_GTK_RADIOBUTTON_CONTAINER),
- direction);
- break;
- case MOZ_GTK_CHECKBUTTON_LABEL:
- case MOZ_GTK_RADIOBUTTON_LABEL:
- return moz_gtk_toggle_label_paint(drawable, rect, cliprect, state,
- (widget == MOZ_GTK_RADIOBUTTON_LABEL),
- direction);
- break;
- case MOZ_GTK_TOOLBAR:
- return moz_gtk_toolbar_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_TOOLBAR_SEPARATOR:
- return moz_gtk_toolbar_separator_paint(drawable, rect, cliprect,
- direction);
- break;
- case MOZ_GTK_TOOLTIP:
- return moz_gtk_tooltip_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_FRAME:
- return moz_gtk_frame_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_RESIZER:
- return moz_gtk_resizer_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_PROGRESSBAR:
- return moz_gtk_progressbar_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_PROGRESS_CHUNK:
- return moz_gtk_progress_chunk_paint(drawable, rect, cliprect,
- direction);
- break;
- case MOZ_GTK_TAB:
- return moz_gtk_tab_paint(drawable, rect, cliprect,
- (GtkTabFlags) flags, direction);
- break;
- case MOZ_GTK_TABPANELS:
- return moz_gtk_tabpanels_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_MENUBAR:
- return moz_gtk_menu_bar_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_MENUPOPUP:
- return moz_gtk_menu_popup_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_MENUSEPARATOR:
- return moz_gtk_menu_separator_paint(drawable, rect, cliprect,
- direction);
- break;
- case MOZ_GTK_MENUITEM:
- return moz_gtk_menu_item_paint(drawable, rect, cliprect, state, flags,
- direction);
- break;
- case MOZ_GTK_MENUARROW:
- return moz_gtk_menu_arrow_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_TOOLBARBUTTON_ARROW:
- return moz_gtk_downarrow_paint(drawable, rect, cliprect, state);
- break;
- case MOZ_GTK_CHECKMENUITEM:
- case MOZ_GTK_RADIOMENUITEM:
- return moz_gtk_check_menu_item_paint(drawable, rect, cliprect, state,
- (gboolean) flags,
- (widget == MOZ_GTK_RADIOMENUITEM),
- direction);
- break;
- case MOZ_GTK_SPLITTER_HORIZONTAL:
- return moz_gtk_vpaned_paint(drawable, rect, cliprect, state);
- break;
- case MOZ_GTK_SPLITTER_VERTICAL:
- return moz_gtk_hpaned_paint(drawable, rect, cliprect, state);
- break;
- case MOZ_GTK_WINDOW:
- return moz_gtk_window_paint(drawable, rect, cliprect, direction);
- break;
- default:
- g_warning("Unknown widget type: %d", widget);
- }
-
- return MOZ_GTK_UNKNOWN_WIDGET;
-}
-
-GtkWidget* moz_gtk_get_scrollbar_widget(void)
-{
- if (!is_initialized)
- return NULL;
- ensure_scrollbar_widget();
- return gHorizScrollbarWidget;
-}
-
-gint
-moz_gtk_shutdown()
-{
- if (gTooltipWidget)
- gtk_widget_destroy(gTooltipWidget);
- /* This will destroy all of our widgets */
- if (gProtoWindow)
- gtk_widget_destroy(gProtoWindow);
-
- gProtoWindow = NULL;
- gButtonWidget = NULL;
- gToggleButtonWidget = NULL;
- gCheckboxWidget = NULL;
- gRadiobuttonWidget = NULL;
- gHorizScrollbarWidget = NULL;
- gVertScrollbarWidget = NULL;
- gSpinWidget = NULL;
- gHScaleWidget = NULL;
- gVScaleWidget = NULL;
- gEntryWidget = NULL;
- gArrowWidget = NULL;
- gOptionMenuWidget = NULL;
- gDropdownButtonWidget = NULL;
- gDropdownEntryWidget = NULL;
- gComboBoxEntryWidget = NULL;
- gHandleBoxWidget = NULL;
- gToolbarWidget = NULL;
- gStatusbarWidget = NULL;
- gFrameWidget = NULL;
- gProgressWidget = NULL;
- gTabWidget = NULL;
- gTooltipWidget = NULL;
- gMenuBarWidget = NULL;
- gMenuBarItemWidget = NULL;
- gMenuPopupWidget = NULL;
- gMenuItemWidget = NULL;
- gCheckMenuItemWidget = NULL;
- gTreeViewWidget = NULL;
- gTreeHeaderCellWidget = NULL;
- gTreeHeaderSortArrowWidget = NULL;
- gExpanderWidget = NULL;
- gToolbarSeparatorWidget = NULL;
- gMenuSeparatorWidget = NULL;
- gHPanedWidget = NULL;
- gVPanedWidget = NULL;
-
- is_initialized = FALSE;
-
- return MOZ_GTK_SUCCESS;
-}
diff --git a/webkit/port/platform/chromium/gtkdrawing.h b/webkit/port/platform/chromium/gtkdrawing.h
deleted file mode 100644
index ee79746..0000000
--- a/webkit/port/platform/chromium/gtkdrawing.h
+++ /dev/null
@@ -1,390 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Brian Ryner <bryner@brianryner.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/**
- * gtkdrawing.h: GTK widget rendering utilities
- *
- * gtkdrawing provides an API for rendering GTK widgets in the
- * current theme to a pixmap or window, without requiring an actual
- * widget instantiation, similar to the Macintosh Appearance Manager
- * or Windows XP's DrawThemeBackground() API.
- */
-
-#ifndef _GTK_DRAWING_H_
-#define _GTK_DRAWING_H_
-
-#include <gdk/gdk.h>
-#include <gtk/gtkstyle.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*** type definitions ***/
-typedef struct {
- guint8 active;
- guint8 focused;
- guint8 inHover;
- guint8 disabled;
- guint8 isDefault;
- guint8 canDefault;
- /* The depressed state is for buttons which remain active for a longer period:
- * activated toggle buttons or buttons showing a popup menu. */
- guint8 depressed;
- gint32 curpos; /* curpos and maxpos are used for scrollbars */
- gint32 maxpos;
-} GtkWidgetState;
-
-typedef struct {
- gint slider_width;
- gint trough_border;
- gint stepper_size;
- gint stepper_spacing;
- gint min_slider_size;
-} MozGtkScrollbarMetrics;
-
-typedef enum {
- MOZ_GTK_STEPPER_DOWN = 1 << 0,
- MOZ_GTK_STEPPER_BOTTOM = 1 << 1,
- MOZ_GTK_STEPPER_VERTICAL = 1 << 2
-} GtkScrollbarButtonFlags;
-
-/** flags for tab state **/
-typedef enum {
- /* first eight bits are used to pass a margin */
- MOZ_GTK_TAB_MARGIN_MASK = 0xFF,
- /* bottom tabs */
- MOZ_GTK_TAB_BOTTOM = 1 << 8,
- /* the first tab in the group */
- MOZ_GTK_TAB_FIRST = 1 << 9,
- /* the selected tab */
- MOZ_GTK_TAB_SELECTED = 1 << 10
-} GtkTabFlags;
-
-/** flags for menuitems **/
-typedef enum {
- /* menuitem is part of the menubar */
- MOZ_TOPLEVEL_MENU_ITEM = 1 << 0
-} GtkMenuItemFlags;
-
-/* function type for moz_gtk_enable_style_props */
-typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
-
-/*** result/error codes ***/
-#define MOZ_GTK_SUCCESS 0
-#define MOZ_GTK_UNKNOWN_WIDGET -1
-#define MOZ_GTK_UNSAFE_THEME -2
-
-/*** widget type constants ***/
-typedef enum {
- /* Paints a GtkButton. flags is a GtkReliefStyle. */
- MOZ_GTK_BUTTON,
- /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
- MOZ_GTK_CHECKBUTTON,
- /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
- MOZ_GTK_RADIOBUTTON,
- /**
- * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
- * the arrow direction.
- */
- MOZ_GTK_SCROLLBAR_BUTTON,
- /* Paints the trough (track) of a GtkScrollbar. */
- MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL,
- MOZ_GTK_SCROLLBAR_TRACK_VERTICAL,
- /* Paints the slider (thumb) of a GtkScrollbar. */
- MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
- MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
- /* Paints a GtkScale. */
- MOZ_GTK_SCALE_HORIZONTAL,
- MOZ_GTK_SCALE_VERTICAL,
- /* Paints a GtkScale thumb. */
- MOZ_GTK_SCALE_THUMB_HORIZONTAL,
- MOZ_GTK_SCALE_THUMB_VERTICAL,
- /* Paints a GtkSpinButton */
- MOZ_GTK_SPINBUTTON,
- MOZ_GTK_SPINBUTTON_UP,
- MOZ_GTK_SPINBUTTON_DOWN,
- MOZ_GTK_SPINBUTTON_ENTRY,
- /* Paints the gripper of a GtkHandleBox. */
- MOZ_GTK_GRIPPER,
- /* Paints a GtkEntry. */
- MOZ_GTK_ENTRY,
- /* Paints a GtkOptionMenu. */
- MOZ_GTK_DROPDOWN,
- /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
- MOZ_GTK_DROPDOWN_ARROW,
- /* Paints an entry in an editable option menu */
- MOZ_GTK_DROPDOWN_ENTRY,
- /* Paints the container part of a GtkCheckButton. */
- MOZ_GTK_CHECKBUTTON_CONTAINER,
- /* Paints the container part of a GtkRadioButton. */
- MOZ_GTK_RADIOBUTTON_CONTAINER,
- /* Paints the label of a GtkCheckButton (focus outline) */
- MOZ_GTK_CHECKBUTTON_LABEL,
- /* Paints the label of a GtkRadioButton (focus outline) */
- MOZ_GTK_RADIOBUTTON_LABEL,
- /* Paints the background of a GtkHandleBox. */
- MOZ_GTK_TOOLBAR,
- /* Paints a toolbar separator */
- MOZ_GTK_TOOLBAR_SEPARATOR,
- /* Paints a GtkToolTip */
- MOZ_GTK_TOOLTIP,
- /* Paints a GtkFrame (e.g. a status bar panel). */
- MOZ_GTK_FRAME,
- /* Paints a resize grip for a GtkWindow */
- MOZ_GTK_RESIZER,
- /* Paints a GtkProgressBar. */
- MOZ_GTK_PROGRESSBAR,
- /* Paints a progress chunk of a GtkProgressBar. */
- MOZ_GTK_PROGRESS_CHUNK,
- /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
- MOZ_GTK_TAB,
- /* Paints the background and border of a GtkNotebook. */
- MOZ_GTK_TABPANELS,
- /* Paints the background and border of a GtkTreeView */
- MOZ_GTK_TREEVIEW,
- /* Paints treeheader cells */
- MOZ_GTK_TREE_HEADER_CELL,
- /* Paints sort arrows in treeheader cells */
- MOZ_GTK_TREE_HEADER_SORTARROW,
- /* Paints an expander for a GtkTreeView */
- MOZ_GTK_TREEVIEW_EXPANDER,
- /* Paints a GtkExpander */
- MOZ_GTK_EXPANDER,
- /* Paints the background of the menu bar. */
- MOZ_GTK_MENUBAR,
- /* Paints the background of menus, context menus. */
- MOZ_GTK_MENUPOPUP,
- /* Paints the arrow of menuitems that contain submenus */
- MOZ_GTK_MENUARROW,
- /* Paints an arrow that points down */
- MOZ_GTK_TOOLBARBUTTON_ARROW,
- /* Paints items of menubar and popups. */
- MOZ_GTK_MENUITEM,
- MOZ_GTK_CHECKMENUITEM,
- MOZ_GTK_RADIOMENUITEM,
- MOZ_GTK_MENUSEPARATOR,
- /* Paints a GtkVPaned separator */
- MOZ_GTK_SPLITTER_HORIZONTAL,
- /* Paints a GtkHPaned separator */
- MOZ_GTK_SPLITTER_VERTICAL,
- /* Paints the background of a window, dialog or page. */
- MOZ_GTK_WINDOW
-} GtkThemeWidgetType;
-
-/*** General library functions ***/
-/**
- * Initializes the drawing library. You must call this function
- * prior to using any other functionality.
- * returns: MOZ_GTK_SUCCESS if there were no errors
- * MOZ_GTK_UNSAFE_THEME if the current theme engine is known
- * to crash with gtkdrawing.
- */
-gint moz_gtk_init();
-
-/**
- * Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer
- * to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental".
- * styleGetProp: pointer to gtk_style_get_prop_experimental
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
-
-/**
- * Perform cleanup of the drawing library. You should call this function
- * when your program exits, or you no longer need the library.
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_shutdown();
-
-
-/*** Widget drawing ***/
-/**
- * Paint a widget in the current theme.
- * widget: a constant giving the widget to paint
- * rect: the bounding rectangle for the widget
- * cliprect: a clipprect rectangle for this painting operation
- * state: the state of the widget. ignored for some widgets.
- * flags: widget-dependant flags; see the GtkThemeWidgetType definition.
- * direction: the text direction, to draw the widget correctly LTR and RTL.
- */
-gint
-moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
- GdkRectangle* rect, GdkRectangle* cliprect,
- GtkWidgetState* state, gint flags,
- GtkTextDirection direction);
-
-
-/*** Widget metrics ***/
-/**
- * Get the border size of a widget
- * left/right: [OUT] the widget's left/right border
- * top/bottom: [OUT] the widget's top/bottom border
- * direction: the text direction for the widget
- * inhtml: boolean indicating whether this widget will be drawn as a HTML form control,
- * in order to workaround a size issue (MOZ_GTK_BUTTON only, ignored otherwise)
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
- gint* right, gint* bottom, GtkTextDirection direction,
- gboolean inhtml);
-
-/**
- * Get the desired size of a GtkCheckButton
- * indicator_size: [OUT] the indicator size
- * indicator_spacing: [OUT] the spacing between the indicator and its
- * container
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing);
-
-/**
- * Get the desired size of a GtkRadioButton
- * indicator_size: [OUT] the indicator size
- * indicator_spacing: [OUT] the spacing between the indicator and its
- * container
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing);
-
-/** Get the focus metrics for a treeheadercell, button, checkbox, or radio button.
- * widget: [IN] the widget to get the focus metrics for
- * interior_focus: [OUT] whether the focus is drawn around the
- * label (TRUE) or around the whole container (FALSE)
- * focus_width: [OUT] the width of the focus line
- * focus_pad: [OUT] the padding between the focus line and children
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus,
- gint* focus_width, gint* focus_pad);
-
-/**
- * Get the desired size of a GtkScale thumb
- * orient: [IN] the scale orientation
- * thumb_length: [OUT] the length of the thumb
- * thumb_height: [OUT] the height of the thumb
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height);
-
-/**
- * Get the desired metrics for a GtkScrollbar
- * metrics: [IN] struct which will contain the metrics
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
-
-/**
- * Get the desired size of a dropdown arrow button
- * width: [OUT] the desired width
- * height: [OUT] the desired height
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_dropdown_arrow_size(gint* width, gint* height);
-
-/**
- * Get the desired size of a toolbar separator
- * size: [OUT] the desired width
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_toolbar_separator_width(gint* size);
-
-/**
- * Get the size of a regular GTK expander that shows/hides content
- * size: [OUT] the size of the GTK expander, size = width = height.
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_expander_size(gint* size);
-
-/**
- * Get the size of a treeview's expander (we call them twisties)
- * size: [OUT] the size of the GTK expander, size = width = height.
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_treeview_expander_size(gint* size);
-
-/**
- * Get the desired height of a menu separator
- * size: [OUT] the desired height
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_menu_separator_height(gint* size);
-
-/**
- * Get the desired size of a splitter
- * orientation: [IN] GTK_ORIENTATION_HORIZONTAL or GTK_ORIENTATION_VERTICAL
- * size: [OUT] width or height of the splitter handle
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_splitter_get_metrics(gint orientation, gint* size);
-
-/**
- * Retrieve an actual GTK scrollbar widget for style analysis. It will not
- * be modified.
- */
-GtkWidget* moz_gtk_get_scrollbar_widget(void);
-
-/**
- * Get the YTHICKNESS of a tab (notebook extension).
- */
-gint moz_gtk_get_tab_thickness(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif
diff --git a/webkit/port/platform/graphics/chromium/FontCacheChromiumWin.cpp b/webkit/port/platform/graphics/chromium/FontCacheChromiumWin.cpp
deleted file mode 100644
index ccbd8447..0000000
--- a/webkit/port/platform/graphics/chromium/FontCacheChromiumWin.cpp
+++ /dev/null
@@ -1,635 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "FontCache.h"
-
-#include "ChromiumBridge.h"
-#include "Font.h"
-#include "FontUtilsChromiumWin.h"
-#include "HashMap.h"
-#include "HashSet.h"
-#include "SimpleFontData.h"
-#include "StringHash.h"
-#include <unicode/uniset.h>
-
-#include <windows.h>
-#include <objidl.h>
-#include <mlang.h>
-
-using std::min;
-
-namespace WebCore
-{
-
-void FontCache::platformInit()
-{
- // Not needed on Windows.
-}
-
-// FIXME(jungshik) : consider adding to WebKit String class
-static bool isStringASCII(const String& s)
-{
- for (int i = 0; i < static_cast<int>(s.length()); ++i) {
- if (s[i] > 0x7f)
- return false;
- }
- return true;
-}
-
-// When asked for a CJK font with a native name under a non-CJK locale or
-// asked for a CJK font with a Romanized name under a CJK locale,
-// |GetTextFace| (after |CreateFont*|) returns a 'bogus' value (e.g. Arial).
-// This is not consistent with what MSDN says !!
-// Therefore, before we call |CreateFont*|, we have to map a Romanized name to
-// the corresponding native name under a CJK locale and vice versa
-// under a non-CJK locale.
-// See the corresponding gecko bugs at
-// https://bugzilla.mozilla.org/show_bug.cgi?id=373952
-// https://bugzilla.mozilla.org/show_bug.cgi?id=231426
-static bool LookupAltName(const String& name, String& altName)
-{
- struct FontCodepage {
- WCHAR *name;
- int codePage;
- };
-
- struct NamePair {
- WCHAR *name;
- FontCodepage altNameCp;
- };
-
- // FIXME(jungshik) : This list probably covers 99% of cases.
- // To cover the remaining 1% and cut down the file size,
- // consider accessing 'NAME' table of a truetype font
- // using |GetFontData| and caching the mapping.
- // 932 : Japanese, 936 : Simp. Chinese, 949 : Korean, 950 : Trad. Chinese
- // In the table below, the ASCII keys are all lower-cased for
- // case-insensitive matching.
- static const NamePair namePairs[] = {
- // MS Pゴシック, MS PGothic
- {L"\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF", {L"MS PGothic", 932}},
- {L"ms pgothic", {L"\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF", 932}},
- // MS P明朝, MS PMincho
- {L"\xFF2D\xFF33 \xFF30\x660E\x671D", {L"MS PMincho", 932}},
- {L"ms pmincho", {L"\xFF2D\xFF33 \xFF30\x660E\x671D", 932}},
- // MSゴシック, MS Gothic
- {L"\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF", {L"MS Gothic", 932}},
- {L"ms gothic", {L"\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF", 932}},
- // MS 明朝, MS Mincho
- {L"\xFF2D\xFF33 \x660E\x671D", {L"MS Mincho", 932}},
- {L"ms mincho", {L"\xFF2D\xFF33 \x660E\x671D", 932}},
- // メイリオ, Meiryo
- {L"\x30E1\x30A4\x30EA\x30AA", {L"Meiryo", 932}},
- {L"meiryo", {L"\x30E1\x30A4\x30EA\x30AA", 932}},
- // 바탕, Batang
- {L"\xBC14\xD0D5", {L"Batang", 949}},
- {L"batang", {L"\xBC14\xD0D5", 949}},
- // 바탕체, Batangche
- {L"\xBC14\xD0D5\xCCB4", {L"Batangche", 949}},
- {L"batangche", {L"\xBC14\xD0D5\xCCB4", 949}},
- // 굴림, Gulim
- {L"\xAD74\xB9BC", {L"Gulim", 949}},
- {L"gulim", {L"\xAD74\xB9BC", 949}},
- // 굴림체, Gulimche
- {L"\xAD74\xB9BC\xCCB4", {L"Gulimche", 949}},
- {L"gulimche", {L"\xAD74\xB9BC\xCCB4", 949}},
- // 돋움, Dotum
- {L"\xB3CB\xC6C0", {L"Dotum", 949}},
- {L"dotum", {L"\xB3CB\xC6C0", 949}},
- // 돋움체, Dotumche
- {L"\xB3CB\xC6C0\xCCB4", {L"Dotumche", 949}},
- {L"dotumche", {L"\xB3CB\xC6C0\xCCB4", 949}},
- // 궁서, Gungsuh
- {L"\xAD81\xC11C", {L"Gungsuh", 949}},
- {L"gungsuh", {L"\xAD81\xC11C", 949}},
- // 궁서체, Gungsuhche
- {L"\xAD81\xC11C\xCCB4", {L"Gungsuhche", 949}},
- {L"gungsuhche", {L"\xAD81\xC11C\xCCB4", 949}},
- // 맑은 고딕, Malgun Gothic
- {L"\xB9D1\xC740 \xACE0\xB515", {L"Malgun Gothic", 949}},
- {L"malgun gothic", {L"\xB9D1\xC740 \xACE0\xB515", 949}},
- // 宋体, SimSun
- {L"\x5B8B\x4F53", {L"SimSun", 936}},
- {L"simsun", {L"\x5B8B\x4F53", 936}},
- // 黑体, SimHei
- {L"\x9ED1\x4F53", {L"SimHei", 936}},
- {L"simhei", {L"\x9ED1\x4F53", 936}},
- // 新宋体, NSimSun
- {L"\x65B0\x5B8B\x4F53", {L"NSimSun", 936}},
- {L"nsimsun", {L"\x65B0\x5B8B\x4F53", 936}},
- // 微软雅黑, Microsoft Yahei
- {L"\x5FAE\x8F6F\x96C5\x9ED1", {L"Microsoft Yahei", 936}},
- {L"microsoft yahei", {L"\x5FAE\x8F6F\x96C5\x9ED1", 936}},
- // 仿宋, FangSong
- {L"\x4EFF\x5B8B", {L"FangSong", 936}},
- {L"fangsong", {L"\x4EFF\x5B8B", 936}},
- // 楷体, KaiTi
- {L"\x6977\x4F53", {L"KaiTi", 936}},
- {L"kaiti", {L"\x6977\x4F53", 936}},
- // 仿宋_GB2312, FangSong_GB2312
- {L"\x4EFF\x5B8B_GB2312", {L"FangSong_GB2312", 936}},
- {L"fangsong_gb2312", {L"\x4EFF\x5B8B_gb2312", 936}},
- // 楷体_GB2312, KaiTi_GB2312
- {L"\x6977\x4F53", {L"KaiTi_GB2312", 936}},
- {L"kaiti_gb2312", {L"\x6977\x4F53_gb2312", 936}},
- // 新細明體, PMingLiu
- {L"\x65B0\x7D30\x660E\x9AD4", {L"PMingLiu", 950}},
- {L"pmingliu", {L"\x65B0\x7D30\x660E\x9AD4", 950}},
- // 細明體, MingLiu
- {L"\x7D30\x660E\x9AD4", {L"MingLiu", 950}},
- {L"mingliu", {L"\x7D30\x660E\x9AD4", 950}},
- // 微軟正黑體, Microsoft JhengHei
- {L"\x5FAE\x8EDF\x6B63\x9ED1\x9AD4", {L"Microsoft JhengHei", 950}},
- {L"microsoft jhengHei", {L"\x5FAE\x8EDF\x6B63\x9ED1\x9AD4", 950}},
- // 標楷體, DFKai-SB
- {L"\x6A19\x6977\x9AD4", {L"DFKai-SB", 950}},
- {L"dfkai-sb", {L"\x6A19\x6977\x9AD4", 950}},
- // WenQuanYi Zen Hei
- {L"\x6587\x6cc9\x9a5b\x6b63\x9ed1", {L"WenQuanYi Zen Hei", 950}},
- {L"wenquanyi zen hei", {L"\x6587\x6cc9\x9a5b\x6b63\x9ed1", 950}},
- // WenQuanYi Zen Hei
- {L"\x6587\x6cc9\x9a7f\x6b63\x9ed1", {L"WenQuanYi Zen Hei", 936}},
- {L"wenquanyi zen hei", {L"\x6587\x6cc9\x9a7f\x6b63\x9ed1", 936}},
- // AR PL ShanHeiSun Uni,
- {L"\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069",
- {L"AR PL ShanHeiSun Uni", 950}},
- {L"ar pl shanheisun uni",
- {L"\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069", 950}},
- // AR PL ShanHeiSun Uni,
- {L"\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069",
- {L"AR PL ShanHeiSun Uni", 936}},
- {L"ar pl shanheisun uni",
- {L"\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069", 936}},
- // AR PL ZenKai Uni
- // Traditional Chinese (950) and Simplified Chinese (936) names are
- // identical.
- {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", {L"AR PL ZenKai Uni", 950}},
- {L"ar pl zenkai uni", {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", 950}},
- {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", {L"AR PL ZenKai Uni", 936}},
- {L"ar pl zenkai uni", {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", 936}},
- };
-
- typedef HashMap<String, const FontCodepage*> NameMap;
- static NameMap* fontNameMap = NULL;
-
- if (!fontNameMap) {
- size_t numElements = sizeof(namePairs) / sizeof(NamePair);
- fontNameMap = new NameMap;
- for (size_t i = 0; i < numElements; ++i)
- fontNameMap->set(String(namePairs[i].name), &(namePairs[i].altNameCp));
- }
-
- bool isAscii = false;
- String n;
- // use |lower| only for ASCII names
- // For non-ASCII names, we don't want to invoke an expensive
- // and unnecessary |lower|.
- if (isStringASCII(name)) {
- isAscii = true;
- n = name.lower();
- } else
- n = name;
-
- NameMap::iterator iter = fontNameMap->find(n);
- if (iter == fontNameMap->end())
- return false;
-
- static int systemCp = ::GetACP();
- int fontCp = iter->second->codePage;
-
- if ((isAscii && systemCp == fontCp) || (!isAscii && systemCp != fontCp)) {
- altName = String(iter->second->name);
- return true;
- }
-
- return false;
-}
-
-static HFONT createFontIndirectAndGetWinName(const String& family,
- LOGFONT* winfont, String* winName)
-{
- int len = min(static_cast<int>(family.length()), LF_FACESIZE - 1);
- memcpy(winfont->lfFaceName, family.characters(), len * sizeof(WORD));
- winfont->lfFaceName[len] = '\0';
-
- HFONT hfont = CreateFontIndirect(winfont);
- if (!hfont)
- return NULL;
-
- HDC dc = GetDC(0);
- HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
- WCHAR name[LF_FACESIZE];
- unsigned resultLength = GetTextFace(dc, LF_FACESIZE, name);
- if (resultLength > 0)
- resultLength--; // ignore the null terminator
-
- SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
- *winName = String(name, resultLength);
- return hfont;
-}
-
-// This maps font family names to their repertoires of supported Unicode
-// characters. Because it's family names rather than font faces we use
-// as keys, there might be edge cases where one face of a font family
-// has a different repertoire from another face of the same family.
-typedef HashMap<const wchar_t*, UnicodeSet*> FontCmapCache;
-
-static bool fontContainsCharacter(const FontPlatformData* font_data,
- const wchar_t* family, UChar32 character)
-{
- // TODO(jungshik) : For non-BMP characters, GetFontUnicodeRanges is of
- // no use. We have to read directly from the cmap table of a font.
- // Return true for now.
- if (character > 0xFFFF)
- return true;
-
- // This cache is just leaked on shutdown.
- static FontCmapCache* fontCmapCache = NULL;
- if (!fontCmapCache)
- fontCmapCache = new FontCmapCache;
-
- HashMap<const wchar_t*, UnicodeSet*>::iterator it =
- fontCmapCache->find(family);
- if (it != fontCmapCache->end())
- return it->second->contains(character);
-
- HFONT hfont = font_data->hfont();
- HDC hdc = GetDC(0);
- HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(hdc, hfont));
- int count = GetFontUnicodeRanges(hdc, 0);
- if (count == 0 && ChromiumBridge::ensureFontLoaded(hfont))
- count = GetFontUnicodeRanges(hdc, 0);
- if (count == 0) {
- ASSERT_NOT_REACHED();
- SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
- return true;
- }
-
- static Vector<char, 512> glyphsetBuffer;
- glyphsetBuffer.resize(GetFontUnicodeRanges(hdc, 0));
- GLYPHSET* glyphset = reinterpret_cast<GLYPHSET*>(glyphsetBuffer.data());
- // In addition, refering to the OS/2 table and converting the codepage list
- // to the coverage map might be faster.
- count = GetFontUnicodeRanges(hdc, glyphset);
- ASSERT(count > 0);
- SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
-
- // TODO(jungshik) : consider doing either of the following two:
- // 1) port back ICU 4.0's faster look-up code for UnicodeSet
- // 2) port Mozilla's CompressedCharMap or gfxSparseBitset
- unsigned i = 0;
- UnicodeSet* cmap = new UnicodeSet;
- while (i < glyphset->cRanges) {
- WCHAR start = glyphset->ranges[i].wcLow;
- cmap->add(start, start + glyphset->ranges[i].cGlyphs - 1);
- i++;
- }
- cmap->freeze();
- // We don't lowercase |family| because all of them are under our control
- // and they're already lowercased.
- fontCmapCache->set(family, cmap);
- return cmap->contains(character);
-}
-
-// Given the desired base font, this will create a SimpleFontData for a specific
-// font that can be used to render the given range of characters.
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font,
- const UChar* characters,
- int length)
-{
- // TODO(jungshik) : Consider passing fontDescription.dominantScript()
- // to GetFallbackFamily here.
- FontDescription fontDescription = font.fontDescription();
- UChar32 c;
- UScriptCode script;
- const wchar_t* family = getFallbackFamily(characters, length,
- fontDescription.genericFamily(), &c, &script);
- FontPlatformData* data = NULL;
- if (family) {
- data = getCachedFontPlatformData(font.fontDescription(),
- AtomicString(family, wcslen(family)),
- false);
- }
-
- // Last resort font list : PanUnicode. CJK fonts have a pretty
- // large repertoire. Eventually, we need to scan all the fonts
- // on the system to have a Firefox-like coverage.
- // Make sure that all of them are lowercased.
- const static wchar_t* const cjkFonts[] = {
- L"arial unicode ms",
- L"ms pgothic",
- L"simsun",
- L"gulim",
- L"pmingliu",
- L"wenquanyi zen hei", // partial CJK Ext. A coverage but more
- // widely known to Chinese users.
- L"ar pl shanheisun uni",
- L"ar pl zenkai uni",
- L"han nom a", // Complete CJK Ext. A coverage
- L"code2000", // Complete CJK Ext. A coverage
- // CJK Ext. B fonts are not listed here because it's of no use
- // with our current non-BMP character handling because we use
- // Uniscribe for it and that code path does not go through here.
- };
-
- const static wchar_t* const commonFonts[] = {
- L"tahoma",
- L"arial unicode ms",
- L"lucida sans unicode",
- L"microsoft sans serif",
- L"palatino linotype",
- // Four fonts below (and code2000 at the end) are not from MS, but
- // once installed, cover a very wide range of characters.
- L"freeserif",
- L"freesans",
- L"gentium",
- L"gentiumalt",
- L"ms pgothic",
- L"simsun",
- L"gulim",
- L"pmingliu",
- L"code2000",
- };
-
- const wchar_t* const* panUniFonts = NULL;
- int numFonts = 0;
- if (script == USCRIPT_HAN) {
- panUniFonts = cjkFonts;
- numFonts = ARRAYSIZE(cjkFonts);
- } else {
- panUniFonts = commonFonts;
- numFonts = ARRAYSIZE(commonFonts);
- }
- // Font returned from GetFallbackFamily may not cover |characters|
- // because it's based on script to font mapping. This problem is
- // critical enough for non-Latin scripts (especially Han) to
- // warrant an additional (real coverage) check with fontCotainsCharacter.
- int i;
- for (i = 0; (!data || !fontContainsCharacter(data, family, c))
- && i < numFonts; ++i) {
- family = panUniFonts[i];
- data = getCachedFontPlatformData(font.fontDescription(),
- AtomicString(family, wcslen(family)));
- }
- if (i < numFonts) // we found the font that covers this character !
- return getCachedFontData(data);
-
- return NULL;
-
-}
-
-const AtomicString& FontCache::alternateFamilyName(const AtomicString& familyName)
-{
- // Note that mapping to Courier is removed because
- // because it's a bitmap font on Windows.
- // Alias Courier -> Courier New
- static AtomicString courier("Courier"), courierNew("Courier New");
- if (equalIgnoringCase(familyName, courier))
- return courierNew;
-
- // Alias Times <-> Times New Roman.
- static AtomicString times("Times"), timesNewRoman("Times New Roman");
- if (equalIgnoringCase(familyName, times))
- return timesNewRoman;
- if (equalIgnoringCase(familyName, timesNewRoman))
- return times;
-
- // Alias Helvetica <-> Arial
- static AtomicString arial("Arial"), helvetica("Helvetica");
- if (equalIgnoringCase(familyName, helvetica))
- return arial;
- if (equalIgnoringCase(familyName, arial))
- return helvetica;
-
- // We block bitmap fonts altogether so that we have to
- // alias MS Sans Serif (bitmap font) -> Microsoft Sans Serif (truetype font)
- static AtomicString msSans("MS Sans Serif");
- static AtomicString microsoftSans("Microsoft Sans Serif");
- if (equalIgnoringCase(familyName, msSans))
- return microsoftSans;
-
- // Alias MS Serif (bitmap) -> Times New Roman (truetype font). There's no
- // 'Microsoft Sans Serif-equivalent' for Serif.
- static AtomicString msSerif("MS Serif");
- if (equalIgnoringCase(familyName, msSerif))
- return timesNewRoman;
-
- // TODO(jungshik) : should we map 'system' to something ('Tahoma') ?
- return emptyAtom;
-}
-
-FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(
- const FontDescription& description)
-{
- FontDescription::GenericFamilyType generic = description.genericFamily();
- // TODO(jungshik): Mapping webkit generic to GenericFamilyType needs to
- // be more intelligent.
- // This spot rarely gets reached. GetFontDataForCharacters() gets hit a lot
- // more often (see TODO comment there).
- const wchar_t* family = getFontFamilyForScript(description.dominantScript(),
- generic);
-
- if (family)
- return getCachedFontPlatformData(description, AtomicString(family, wcslen(family)));
-
- // FIXME: Would be even better to somehow get the user's default font here.
- // For now we'll pick the default that the user would get without changing
- // any prefs.
- static AtomicString timesStr("Times New Roman");
- static AtomicString courierStr("Courier New");
- static AtomicString arialStr("Arial");
-
- AtomicString& fontStr = timesStr;
- if (generic == FontDescription::SansSerifFamily)
- fontStr = arialStr;
- else if (generic == FontDescription::MonospaceFamily)
- fontStr = courierStr;
-
- return getCachedFontPlatformData(description, fontStr);
-}
-
-static LONG toGDIFontWeight(FontWeight fontWeight)
-{
- static LONG gdiFontWeights[] = {
- FW_THIN, // FontWeight100
- FW_EXTRALIGHT, // FontWeight200
- FW_LIGHT, // FontWeight300
- FW_NORMAL, // FontWeight400
- FW_MEDIUM, // FontWeight500
- FW_SEMIBOLD, // FontWeight600
- FW_BOLD, // FontWeight700
- FW_EXTRABOLD, // FontWeight800
- FW_HEAVY // FontWeight900
- };
- return gdiFontWeights[fontWeight];
-}
-
-// TODO(jungshik): This may not be the best place to put this function. See
-// TODO in pending/FontCache.h.
-AtomicString FontCache::getGenericFontForScript(UScriptCode script, const FontDescription& description)
-{
- const wchar_t* scriptFont = getFontFamilyForScript(
- script, description.genericFamily());
- return scriptFont ? AtomicString(scriptFont, wcslen(scriptFont)) : emptyAtom;
-}
-
-static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont)
-{
- // The size here looks unusual. The negative number is intentional.
- // Unlike WebKit trunk, we don't multiply the size by 32. That seems to be
- // some kind of artifact of their CG backend, or something.
- winfont->lfHeight = -fontDescription.computedPixelSize();
- winfont->lfWidth = 0;
- winfont->lfEscapement = 0;
- winfont->lfOrientation = 0;
- winfont->lfUnderline = false;
- winfont->lfStrikeOut = false;
- winfont->lfCharSet = DEFAULT_CHARSET;
- winfont->lfOutPrecision = OUT_TT_ONLY_PRECIS;
- winfont->lfQuality = ChromiumBridge::layoutTestMode() ? NONANTIALIASED_QUALITY
- : DEFAULT_QUALITY; // Honor user's desktop settings.
- winfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- winfont->lfItalic = fontDescription.italic();
- winfont->lfWeight = toGDIFontWeight(fontDescription.weight());
-}
-
-bool FontCache::fontExists(const FontDescription& fontDescription, const AtomicString& family)
-{
- LOGFONT winfont = {0};
- FillLogFont(fontDescription, &winfont);
- String winName;
- HFONT hfont = createFontIndirectAndGetWinName(family, &winfont, &winName);
- if (!hfont)
- return false;
-
- DeleteObject(hfont);
- if (equalIgnoringCase(family, winName))
- return true;
- // For CJK fonts with both English and native names,
- // GetTextFace returns a native name under the font's "locale"
- // and an English name under other locales regardless of
- // lfFaceName field of LOGFONT. As a result, we need to check
- // if a font has an alternate name. If there is, we need to
- // compare it with what's requested in the first place.
- String altName;
- return LookupAltName(family, altName) && equalIgnoringCase(altName, winName);
-}
-
-struct TraitsInFamilyProcData {
- TraitsInFamilyProcData(const AtomicString& familyName)
- : m_familyName(familyName)
- {
- }
-
- const AtomicString& m_familyName;
- HashSet<unsigned> m_traitsMasks;
-};
-
-static int CALLBACK traitsInFamilyEnumProc(CONST LOGFONT* logFont, CONST TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
-{
- TraitsInFamilyProcData* procData = reinterpret_cast<TraitsInFamilyProcData*>(lParam);
-
- unsigned traitsMask = 0;
- traitsMask |= logFont->lfItalic ? FontStyleItalicMask : FontStyleNormalMask;
- traitsMask |= FontVariantNormalMask;
- LONG weight = logFont->lfWeight;
- traitsMask |= weight == FW_THIN ? FontWeight100Mask :
- weight == FW_EXTRALIGHT ? FontWeight200Mask :
- weight == FW_LIGHT ? FontWeight300Mask :
- weight == FW_NORMAL ? FontWeight400Mask :
- weight == FW_MEDIUM ? FontWeight500Mask :
- weight == FW_SEMIBOLD ? FontWeight600Mask :
- weight == FW_BOLD ? FontWeight700Mask :
- weight == FW_EXTRABOLD ? FontWeight800Mask :
- FontWeight900Mask;
- procData->m_traitsMasks.add(traitsMask);
- return 1;
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- HDC hdc = GetDC(0);
-
- LOGFONT logFont;
- logFont.lfCharSet = DEFAULT_CHARSET;
- unsigned familyLength = min(familyName.length(), static_cast<unsigned>(LF_FACESIZE - 1));
- memcpy(logFont.lfFaceName, familyName.characters(), familyLength * sizeof(UChar));
- logFont.lfFaceName[familyLength] = 0;
- logFont.lfPitchAndFamily = 0;
-
- TraitsInFamilyProcData procData(familyName);
- EnumFontFamiliesEx(hdc, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0);
- copyToVector(procData.m_traitsMasks, traitsMasks);
-
- ReleaseDC(0, hdc);
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- LOGFONT winfont = {0};
- FillLogFont(fontDescription, &winfont);
-
- // Windows will always give us a valid pointer here, even if the face name
- // is non-existent. We have to double-check and see if the family name was
- // really used.
- String winName;
- HFONT hfont = createFontIndirectAndGetWinName(family, &winfont, &winName);
- if (!hfont)
- return 0;
-
- // TODO(pamg): Do we need to use predefined fonts "guaranteed" to exist
- // when we're running in layout-test mode?
- if (!equalIgnoringCase(family, winName)) {
- // For CJK fonts with both English and native names,
- // GetTextFace returns a native name under the font's "locale"
- // and an English name under other locales regardless of
- // lfFaceName field of LOGFONT. As a result, we need to check
- // if a font has an alternate name. If there is, we need to
- // compare it with what's requested in the first place.
- String altName;
- if (!LookupAltName(family, altName) ||
- !equalIgnoringCase(altName, winName)) {
- DeleteObject(hfont);
- return 0;
- }
- }
-
- return new FontPlatformData(hfont,
- fontDescription.computedPixelSize());
-}
-
-}
diff --git a/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp b/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp
deleted file mode 100644
index c8fb0f1..0000000
--- a/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "FontCache.h"
-
-#include <fontconfig/fontconfig.h>
-
-#include "AtomicString.h"
-#include "CString.h"
-#include "Font.h"
-#include "FontDescription.h"
-#include "FontPlatformData.h"
-#include "Logging.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-
-#include "SkPaint.h"
-#include "SkTypeface.h"
-#include "SkUtils.h"
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font,
- const UChar* characters,
- int length)
-{
- FcCharSet* cset = FcCharSetCreate();
- for (int i = 0; i < length; ++i)
- FcCharSetAddChar(cset, characters[i]);
-
- FcPattern* pattern = FcPatternCreate();
-
- FcValue fcvalue;
- fcvalue.type = FcTypeCharSet;
- fcvalue.u.c = cset;
- FcPatternAdd(pattern, FC_CHARSET, fcvalue, 0);
-
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
-
- FcResult result;
- FcPattern* match = FcFontMatch(0, pattern, &result);
- FcPatternDestroy(pattern);
-
- SimpleFontData* ret = NULL;
-
- if (match) {
- FcChar8* family;
- if (FcPatternGetString(match, FC_FAMILY, 0, &family) == FcResultMatch) {
- FontPlatformData* fpd =
- createFontPlatformData(font.fontDescription(),
- AtomicString((char *) family));
- ret = new SimpleFontData(*fpd);
- }
- FcPatternDestroy(match);
- }
-
- FcCharSetDestroy(cset);
-
- return ret;
-}
-
-const AtomicString& FontCache::alternateFamilyName(const AtomicString& familyName)
-{
- notImplemented();
-
- // This is just to stop GCC emitting a warning about returning a reference
- // to a temporary variable
- static AtomicString a;
- return a;
-}
-
-FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& description)
-{
- static AtomicString arialStr("Arial");
- return getCachedFontPlatformData(description, arialStr);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName,
- Vector<unsigned>& traitsMasks)
-{
- notImplemented();
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription,
- const AtomicString& family)
-{
- const char* name = 0;
- CString s;
-
- if (family.length() == 0) {
- static const struct {
- FontDescription::GenericFamilyType mType;
- const char* mName;
- } gNames[] = {
- { FontDescription::SerifFamily, "serif" },
- { FontDescription::SansSerifFamily, "sans-serif" },
- { FontDescription::MonospaceFamily, "monospace" },
- { FontDescription::CursiveFamily, "cursive" },
- { FontDescription::FantasyFamily, "fantasy" }
- };
-
- FontDescription::GenericFamilyType type = fontDescription.genericFamily();
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gNames); i++) {
- if (type == gNames[i].mType) {
- name = gNames[i].mName;
- break;
- }
- }
- // if we fall out of the loop, it's ok for name to still be 0
- }
- else { // convert the name to utf8
- s = family.string().utf8();
- name = s.data();
- }
-
- int style = SkTypeface::kNormal;
- if (fontDescription.weight() >= FontWeightBold)
- style |= SkTypeface::kBold;
- if (fontDescription.italic())
- style |= SkTypeface::kItalic;
-
- SkTypeface* tf = SkTypeface::Create(name, (SkTypeface::Style)style);
- if (!tf)
- return NULL;
-
- FontPlatformData* result =
- new FontPlatformData(tf,
- fontDescription.computedSize(),
- (style & SkTypeface::kBold) && !tf->isBold(),
- (style & SkTypeface::kItalic) && !tf->isItalic());
- tf->unref();
- return result;
-}
-
-AtomicString FontCache::getGenericFontForScript(UScriptCode script,
- const FontDescription& descript)
-{
- notImplemented();
- return AtomicString();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/FontChromiumWin.cpp b/webkit/port/platform/graphics/chromium/FontChromiumWin.cpp
deleted file mode 100644
index 5f85629..0000000
--- a/webkit/port/platform/graphics/chromium/FontChromiumWin.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 <windows.h>
-
-#include "AffineTransform.h"
-#include "ChromiumBridge.h"
-#include "Font.h"
-#include "FontFallbackList.h"
-#include "GlyphBuffer.h"
-#include "PlatformContextSkia.h"
-#include "SimpleFontData.h"
-#include "SkiaFontWin.h"
-#include "SkiaUtils.h"
-#include "UniscribeHelperTextRun.h"
-
-#include "skia/ext/platform_canvas_win.h"
-#include "skia/ext/skia_utils_win.h" // TODO(brettw) remove this dependency.
-
-namespace WebCore {
-
-static bool windowsCanHandleTextDrawing(GraphicsContext* context)
-{
- // Check for non-translation transforms. Sometimes zooms will look better in
- // Skia, and sometimes better in Windows. The main problem is that zooming
- // in using Skia will show you the hinted outlines for the smaller size,
- // which look weird. All else being equal, it's better to use Windows' text
- // drawing, so we don't check for zooms.
- const AffineTransform& xform = context->getCTM();
- if (xform.b() != 0 || // Y skew
- xform.c() != 0) // X skew
- return false;
-
- // Check for stroke effects.
- if (context->platformContext()->getTextDrawingMode() != cTextFill)
- return false;
-
- // Check for shadow effects.
- if (context->platformContext()->getDrawLooper())
- return false;
-
- return true;
-}
-
-static bool PaintSkiaText(PlatformContextSkia* platformContext,
- HFONT hfont,
- int numGlyphs,
- const WORD* glyphs,
- const int* advances,
- const SkPoint& origin)
-{
- int textMode = platformContext->getTextDrawingMode();
-
- // Filling (if necessary). This is the common case.
- SkPaint paint;
- platformContext->setupPaintForFilling(&paint);
- paint.setFlags(SkPaint::kAntiAlias_Flag);
- bool didFill = false;
- if ((textMode & cTextFill) && SkColorGetA(paint.getColor())) {
- if (!SkiaDrawText(hfont, platformContext->canvas(), origin, &paint,
- &glyphs[0], &advances[0], numGlyphs))
- return false;
- didFill = true;
- }
-
- // Stroking on top (if necessary).
- if ((textMode & WebCore::cTextStroke) &&
- platformContext->getStrokeStyle() != NoStroke &&
- platformContext->getStrokeThickness() > 0) {
-
- paint.reset();
- platformContext->setupPaintForStroking(&paint, NULL, 0);
- paint.setFlags(SkPaint::kAntiAlias_Flag);
- if (didFill) {
- // If there is a shadow and we filled above, there will already be
- // a shadow. We don't want to draw it again or it will be too dark
- // and it will go on top of the fill.
- //
- // Note that this isn't strictly correct, since the stroke could be
- // very thick and the shadow wouldn't account for this. The "right"
- // thing would be to draw to a new layer and then draw that layer
- // with a shadow. But this is a lot of extra work for something
- // that isn't normally an issue.
- paint.setLooper(NULL)->safeUnref();
- }
-
- if (!SkiaDrawText(hfont, platformContext->canvas(), origin,
- &paint, &glyphs[0], &advances[0], numGlyphs))
- return false;
- }
- return true;
-}
-
-void Font::drawGlyphs(GraphicsContext* graphicsContext,
- const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer,
- int from,
- int numGlyphs,
- const FloatPoint& point) const
-{
- PlatformGraphicsContext* context = graphicsContext->platformContext();
-
- // Max buffer length passed to the underlying windows API.
- const int kMaxBufferLength = 1024;
- // Default size for the buffer. It should be enough for most of cases.
- const int kDefaultBufferLength = 256;
-
- SkColor color = context->fillColor();
- unsigned char alpha = SkColorGetA(color);
- // Skip 100% transparent text; no need to draw anything.
- if (!alpha && context->getStrokeStyle() == NoStroke)
- return;
-
- // Set up our graphics context.
- HDC hdc = context->canvas()->beginPlatformPaint();
- HGDIOBJ oldFont = SelectObject(hdc, font->platformData().hfont());
-
- // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency.
- // Enforce non-transparent color.
- color = SkColorSetRGB(SkColorGetR(color),
- SkColorGetG(color),
- SkColorGetB(color));
- SetTextColor(hdc, skia::SkColorToCOLORREF(color));
- SetBkMode(hdc, TRANSPARENT);
-
- // Windows needs the characters and the advances in nice contiguous
- // buffers, which we build here.
- Vector<WORD, kDefaultBufferLength> glyphs;
- Vector<int, kDefaultBufferLength> advances;
-
- // Compute the coordinate. The 'origin' represents the baseline, so we need
- // to move it up to the top of the bounding square.
- int x = static_cast<int>(point.x());
- int lineTop = static_cast<int>(point.y()) - font->ascent();
-
- bool canUseGDI = windowsCanHandleTextDrawing(graphicsContext);
-
- // We draw the glyphs in chunks to avoid having to do a heap allocation for
- // the arrays of characters and advances. Since ExtTextOut is the
- // lowest-level text output function on Windows, there should be little
- // penalty for splitting up the text. On the other hand, the buffer cannot
- // be bigger than 4094 or the function will fail.
- int glyphIndex = 0;
- while (glyphIndex < numGlyphs) {
- // how many chars will be in this chunk?
- int curLen = std::min(kMaxBufferLength, numGlyphs - glyphIndex);
-
- glyphs.resize(curLen);
- advances.resize(curLen);
-
- int curWidth = 0;
- for (int i = 0; i < curLen; ++i, ++glyphIndex) {
- glyphs[i] = glyphBuffer.glyphAt(from + glyphIndex);
- advances[i] =
- static_cast<int>(glyphBuffer.advanceAt(from + glyphIndex));
- curWidth += advances[i];
- }
-
- bool success = false;
- for (int executions = 0; executions < 2; ++executions) {
- if (canUseGDI) {
- success = !!ExtTextOut(hdc, x, lineTop, ETO_GLYPH_INDEX, NULL,
- reinterpret_cast<const wchar_t*>(&glyphs[0]),
- curLen, &advances[0]);
- } else {
- // Skia's text draing origin is the baseline, like WebKit, not
- // the top, like Windows.
- SkPoint origin = { x, point.y() };
- success = PaintSkiaText(context,
- font->platformData().hfont(), numGlyphs,
- reinterpret_cast<const WORD*>(&glyphs[0]),
- &advances[0], origin);
- }
-
- if (!success && executions == 0) {
- // Ask the browser to load the font for us and retry.
- ChromiumBridge::ensureFontLoaded(font->platformData().hfont());
- continue;
- }
- break;
- }
-
- ASSERT(success);
-
- x += curWidth;
- }
-
- SelectObject(hdc, oldFont);
- context->canvas()->endPlatformPaint();
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run,
- const IntPoint& point,
- int h,
- int from,
- int to) const
-{
- UniscribeHelperTextRun state(run, *this);
- float left = static_cast<float>(point.x() + state.CharacterToX(from));
- float right = static_cast<float>(point.x() + state.CharacterToX(to));
-
- // If the text is RTL, left will actually be after right.
- if (left < right) {
- return FloatRect(left, static_cast<float>(point.y()),
- right - left, static_cast<float>(h));
- }
- return FloatRect(right, static_cast<float>(point.y()),
- left - right, static_cast<float>(h));
-}
-
-void Font::drawComplexText(GraphicsContext* graphicsContext,
- const TextRun& run,
- const FloatPoint& point,
- int from,
- int to) const
-{
- PlatformGraphicsContext* context = graphicsContext->platformContext();
- UniscribeHelperTextRun state(run, *this);
-
- SkColor color = context->fillColor();
- unsigned char alpha = SkColorGetA(color);
- // Skip 100% transparent text; no need to draw anything.
- if (!alpha)
- return;
-
- HDC hdc = context->canvas()->beginPlatformPaint();
-
- // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency.
- // Enforce non-transparent color.
- color = SkColorSetRGB(SkColorGetR(color),
- SkColorGetG(color),
- SkColorGetB(color));
- SetTextColor(hdc, skia::SkColorToCOLORREF(color));
- SetBkMode(hdc, TRANSPARENT);
-
- // Uniscribe counts the coordinates from the upper left, while WebKit uses
- // the baseline, so we have to subtract off the ascent.
- state.Draw(hdc,
- static_cast<int>(point.x()),
- static_cast<int>(point.y() - ascent()),
- from,
- to);
- context->canvas()->endPlatformPaint();
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- UniscribeHelperTextRun state(run, *this);
- return static_cast<float>(state.Width());
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x,
- bool includePartialGlyphs) const
-{
- // Mac code ignores includePartialGlyphs, and they don't know what it's
- // supposed to do, so we just ignore it as well.
- UniscribeHelperTextRun state(run, *this);
- int char_index = state.XToCharacter(x);
-
- // XToCharacter will return -1 if the position is before the first
- // character (we get called like this sometimes).
- if (char_index < 0)
- char_index = 0;
- return char_index;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/FontCustomPlatformData.cpp b/webkit/port/platform/graphics/chromium/FontCustomPlatformData.cpp
deleted file mode 100644
index 9105a8c..0000000
--- a/webkit/port/platform/graphics/chromium/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
- // FIXME: Release the HFONT ref?
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic)
-{
- return FontPlatformData(m_font, size);
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
-
-#if PLATFORM(WIN_OS)
- HFONT font = 0;
- // FIXME: Figure out some way to get Windows to give us back a font object.
- if (!font)
- return 0;
- return new FontCustomPlatformData(font);
-#else
- notImplemented();
-#endif
-}
-
-}
diff --git a/webkit/port/platform/graphics/chromium/FontCustomPlatformData.h b/webkit/port/platform/graphics/chromium/FontCustomPlatformData.h
deleted file mode 100644
index 8aa0fea..0000000
--- a/webkit/port/platform/graphics/chromium/FontCustomPlatformData.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontCustomPlatformData_h
-#define FontCustomPlatformData_h
-
-#if PLATFORM(DARWIN)
-// TODO(port): This #include isn't strictly kosher, but we're currently using
-// the Mac font code from upstream WebKit, and we need to pick up their header.
-#undef FontCustomPlatformData_h
-#include "third_party/WebKit/WebCore/platform/graphics/mac/FontCustomPlatformData.h"
-#else
-
-#include <wtf/Noncopyable.h>
-
-#if PLATFORM(WIN_OS)
-#include <windows.h>
-#endif
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformData : Noncopyable {
-#if PLATFORM(WIN_OS)
- FontCustomPlatformData(HFONT font)
- : m_font(font)
- {}
-#endif
-
- ~FontCustomPlatformData();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic);
-
-#if PLATFORM(WIN_OS)
- HFONT m_font;
-#endif
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
-
-}
-
-#endif
-#endif
diff --git a/webkit/port/platform/graphics/chromium/FontLinux.cpp b/webkit/port/platform/graphics/chromium/FontLinux.cpp
deleted file mode 100644
index 7e2ebac..0000000
--- a/webkit/port/platform/graphics/chromium/FontLinux.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "Font.h"
-
-#include "FloatRect.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "SimpleFontData.h"
-
-#include "SkCanvas.h"
-#include "SkPaint.h"
-#include "SkTemplates.h"
-#include "SkTypeface.h"
-#include "SkUtils.h"
-
-namespace WebCore {
-
-void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer, int from, int numGlyphs,
- const FloatPoint& point) const {
- SkCanvas* canvas = gc->platformContext()->canvas();
- SkPaint paint;
-
- font->platformData().setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- paint.setColor(gc->fillColor().rgb());
-
- SkASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t)); // compile-time assert
-
- const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
- SkScalar x = SkFloatToScalar(point.x());
- SkScalar y = SkFloatToScalar(point.y());
-
- // TODO(port): text rendering speed:
- // Android has code in their WebCore fork to special case when the
- // GlyphBuffer has no advances other than the defaults. In that case the
- // text drawing can proceed faster. However, it's unclear when those
- // patches may be upstreamed to WebKit so we always use the slower path
- // here.
- const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
- SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
- SkPoint* pos = storage.get();
-
- for (int i = 0; i < numGlyphs; i++) {
- pos[i].set(x, y);
- x += SkFloatToScalar(adv[i].width());
- y += SkFloatToScalar(adv[i].height());
- }
- canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
-}
-
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run,
- const FloatPoint& point, int from, int to) const
-{
- notImplemented();
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- notImplemented();
- return 0;
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x,
- bool includePartialGlyphs) const
-{
- notImplemented();
- return 0;
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run,
- const IntPoint& point, int h,
- int from, int to) const
-{
- notImplemented();
- return FloatRect();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/FontPlatformData.h b/webkit/port/platform/graphics/chromium/FontPlatformData.h
deleted file mode 100644
index ea3dba5..0000000
--- a/webkit/port/platform/graphics/chromium/FontPlatformData.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef FontPlatformData_h
-#define FontPlatformData_h
-
-#include "config.h"
-#include "build/build_config.h"
-
-#if defined(OS_WIN)
-#include "FontPlatformDataChromiumWin.h"
-#elif defined(OS_LINUX)
-#include "FontPlatformDataLinux.h"
-#elif defined(OS_MACOSX)
-// TODO(port): This #include isn't strictly kosher, but we're currently using
-// the Mac font code from upstream WebKit, and we need to pick up their header.
-#undef FontPlatformData_h
-#include "third_party/WebKit/WebCore/platform/graphics/mac/FontPlatformData.h"
-#endif
-
-#endif // ifndef FontPlatformData_h
diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp b/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
deleted file mode 100644
index 3a11c1c..0000000
--- a/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006, 2007 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include <windows.h>
-#include <objidl.h>
-#include <mlang.h>
-
-#include "ChromiumBridge.h"
-#include "SkiaFontWin.h"
-
-namespace WebCore {
-
-FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
- : m_font(hashTableDeletedFontValue())
- , m_size(-1)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
-{
-}
-
-FontPlatformData::FontPlatformData()
- : m_font(0)
- , m_size(0)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
-{
-}
-
-FontPlatformData::FontPlatformData(HFONT font, float size)
- : m_font(RefCountedHFONT::create(font))
- , m_size(size)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
-{
-}
-
-// TODO(jhaas): this ctor is needed for SVG fonts but doesn't seem
-// to do much
-FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
- : m_font(0)
- , m_size(size)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
-{
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& data)
- : m_font(data.m_font)
- , m_size(data.m_size)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
-{
-}
-
-FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
-{
- if (this != &data) {
- m_font = data.m_font;
- m_size = data.m_size;
-
- // The following fields will get re-computed if necessary.
-
- ScriptFreeCache(&m_scriptCache);
- m_scriptCache = 0;
-
- delete m_scriptFontProperties;
- m_scriptFontProperties = 0;
- }
- return *this;
-}
-
-FontPlatformData::~FontPlatformData()
-{
- ScriptFreeCache(&m_scriptCache);
- m_scriptCache = 0;
-
- delete m_scriptFontProperties;
- m_scriptFontProperties = 0;
-}
-
-FontPlatformData::RefCountedHFONT::~RefCountedHFONT()
-{
- if (m_hfont != reinterpret_cast<HFONT>(-1)) {
- RemoveFontFromSkiaFontWinCache(m_hfont);
- DeleteObject(m_hfont);
- }
-}
-
-FontPlatformData::RefCountedHFONT* FontPlatformData::hashTableDeletedFontValue()
-{
- static RefPtr<RefCountedHFONT> deletedValue =
- RefCountedHFONT::create(reinterpret_cast<HFONT>(-1));
- return deletedValue.get();
-}
-
-SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const
-{
- if (!m_scriptFontProperties) {
- m_scriptFontProperties = new SCRIPT_FONTPROPERTIES;
- memset(m_scriptFontProperties, 0, sizeof(SCRIPT_FONTPROPERTIES));
- m_scriptFontProperties->cBytes = sizeof(SCRIPT_FONTPROPERTIES);
- HRESULT result = ScriptGetFontProperties(0, scriptCache(),
- m_scriptFontProperties);
- if (result == E_PENDING) {
- HDC dc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(dc, hfont());
- HRESULT hr = ScriptGetFontProperties(dc, scriptCache(),
- m_scriptFontProperties);
- if (S_OK != hr) {
- if (ChromiumBridge::ensureFontLoaded(hfont())) {
- // Retry ScriptGetFontProperties.
- // TODO(nsylvain): Handle gracefully the error if this call
- // also fails. See bug 1136944.
- hr = ScriptGetFontProperties(dc, scriptCache(),
- m_scriptFontProperties);
- if (S_OK != hr) {
- ASSERT_NOT_REACHED();
- }
- }
- }
-
- SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
- }
- }
- return m_scriptFontProperties;
-}
-
-}
diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.h b/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.h
deleted file mode 100644
index 80f9df3..0000000
--- a/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006, 2007 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef FontPlatformDataWin_H
-#define FontPlatformDataWin_H
-
-#include "config.h"
-
-#include "StringImpl.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-// TODO(tc): Once this file is only included by the ChromiumWin build, we can
-// remove the PLATFORM #ifs.
-#if PLATFORM(WIN_OS)
-#include <usp10.h>
-#endif
-
-typedef struct HFONT__ *HFONT;
-
-namespace WebCore {
-
-class FontDescription;
-
-class FontPlatformData
-{
-public:
- // Used for deleted values in the font cache's hash tables. The hash table
- // will create us with this structure, and it will compare other values
- // to this "Deleted" one. It expects the Deleted one to be differentiable
- // from the NULL one (created with the empty constructor), so we can't just
- // set everything to NULL.
- FontPlatformData(WTF::HashTableDeletedValueType);
- FontPlatformData();
- FontPlatformData(HFONT hfont, float size);
- FontPlatformData(float size, bool bold, bool oblique);
- FontPlatformData(const FontPlatformData& data);
-
- FontPlatformData& operator=(const FontPlatformData& data);
-
- bool isHashTableDeletedValue() const { return m_font == hashTableDeletedFontValue(); }
-
- ~FontPlatformData();
-
- HFONT hfont() const { return m_font ? m_font->hfont() : 0; }
- float size() const { return m_size; }
-
- unsigned hash() const
- {
- return m_font ? m_font->hash() : NULL;
- }
-
- bool operator==(const FontPlatformData& other) const
- {
- return m_font == other.m_font && m_size == other.m_size;
- }
-
-#if PLATFORM(WIN_OS)
- SCRIPT_FONTPROPERTIES* scriptFontProperties() const;
- SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; }
-#endif
-
-private:
- // We refcount the internal HFONT so that FontPlatformData can be
- // efficiently copied. WebKit depends on being able to copy it, and we
- // don't really want to re-create the HFONT.
- class RefCountedHFONT : public RefCounted<RefCountedHFONT> {
- public:
- static PassRefPtr<RefCountedHFONT> create(HFONT hfont)
- {
- return adoptRef(new RefCountedHFONT(hfont));
- }
-
- ~RefCountedHFONT();
-
- HFONT hfont() const { return m_hfont; }
- unsigned hash() const
- {
- return StringImpl::computeHash(reinterpret_cast<const UChar*>(&m_hfont), sizeof(HFONT) / sizeof(UChar));
- }
-
- bool operator==(const RefCountedHFONT& other) const
- {
- return m_hfont == other.m_hfont;
- }
-
- private:
- // The create() function assumes there is already a refcount of one
- // so it can do adoptRef.
- RefCountedHFONT(HFONT hfont) : m_hfont(hfont)
- {
- }
-
- HFONT m_hfont;
- };
-
- static RefCountedHFONT* hashTableDeletedFontValue();
-
- RefPtr<RefCountedHFONT> m_font;
- float m_size; // Point size of the font in pixels.
-
-#if PLATFORM(WIN_OS)
- mutable SCRIPT_CACHE m_scriptCache;
- mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
-#endif
-};
-
-}
-
-#endif
diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp
deleted file mode 100644
index 01167da..0000000
--- a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "SkPaint.h"
-#include "SkTypeface.h"
-
-namespace WebCore {
-
-FontPlatformData::FontPlatformData(const FontPlatformData& src)
-{
- src.m_typeface->safeRef();
- m_typeface = src.m_typeface;
-
- m_textSize = src.m_textSize;
- m_fakeBold = src.m_fakeBold;
- m_fakeItalic = src.m_fakeItalic;
-}
-
-FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic)
- : m_typeface(tf)
- , m_textSize(textSize)
- , m_fakeBold(fakeBold)
- , m_fakeItalic(fakeItalic)
-{
- m_typeface->safeRef();
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
- : m_typeface(src.m_typeface)
- , m_textSize(textSize)
- , m_fakeBold(src.m_fakeBold)
- , m_fakeItalic(src.m_fakeItalic)
-{
- m_typeface->safeRef();
-}
-
-FontPlatformData::~FontPlatformData()
-{
- m_typeface->safeUnref();
-}
-
-FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
-{
- SkRefCnt_SafeAssign(m_typeface, src.m_typeface);
-
- m_textSize = src.m_textSize;
- m_fakeBold = src.m_fakeBold;
- m_fakeItalic = src.m_fakeItalic;
-
- return *this;
-}
-
-void FontPlatformData::setupPaint(SkPaint* paint) const
-{
- const float ts = m_textSize > 0 ? m_textSize : 12;
-
- paint->setAntiAlias(false);
- paint->setSubpixelText(false);
- paint->setTextSize(SkFloatToScalar(ts));
- paint->setTypeface(m_typeface);
- paint->setFakeBoldText(m_fakeBold);
- paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1/4 : 0);
- paint->setTextEncoding(SkPaint::kUTF16_TextEncoding);
-}
-
-bool FontPlatformData::operator==(const FontPlatformData& a) const
-{
- // If either of the typeface pointers are invalid (either NULL or the
- // special deleted value) then we test for pointer equality. Otherwise, we
- // call SkTypeface::Equal on the valid pointers.
- const bool typefaces_equal =
- (m_typeface == hashTableDeletedFontValue() ||
- a.m_typeface == hashTableDeletedFontValue() ||
- !m_typeface || !a.m_typeface) ?
- (m_typeface == a.m_typeface) :
- SkTypeface::Equal(m_typeface, a.m_typeface);
- return typefaces_equal &&
- m_textSize == a.m_textSize &&
- m_fakeBold == a.m_fakeBold &&
- m_fakeItalic == a.m_fakeItalic;
-}
-
-unsigned FontPlatformData::hash() const
-{
- // This hash is taken from Android code. It is not our fault.
- unsigned h = SkTypeface::UniqueID(m_typeface);
- h ^= 0x01010101 * (((int)m_fakeBold << 1) | (int)m_fakeItalic);
-
- // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
- // rules. Memcpy is generally optimized enough so that performance doesn't
- // matter here.
- uint32_t textsize_bytes;
- memcpy(&textsize_bytes, &m_textSize, sizeof(uint32_t));
- h ^= textsize_bytes;
-
- return h;
-}
-
-bool FontPlatformData::isFixedPitch() const
-{
- notImplemented();
- return false;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h
deleted file mode 100644
index 0d67b24..0000000
--- a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef FontPlatformDataLinux_h
-#define FontPlatformDataLinux_h
-
-#include "config.h"
-#include "build/build_config.h"
-
-#include "StringImpl.h"
-#include "NotImplemented.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-class SkPaint;
-class SkTypeface;
-
-namespace WebCore {
-
-class FontDescription;
-
-// -----------------------------------------------------------------------------
-// FontPlatformData is the handle which WebKit has on a specific face. A face
-// is the tuple of (font, size, ...etc). Here we are just wrapping a Skia
-// SkTypeface pointer and dealing with the reference counting etc.
-// -----------------------------------------------------------------------------
-class FontPlatformData {
-public:
- // Used for deleted values in the font cache's hash tables. The hash table
- // will create us with this structure, and it will compare other values
- // to this "Deleted" one. It expects the Deleted one to be differentiable
- // from the NULL one (created with the empty constructor), so we can't just
- // set everything to NULL.
- FontPlatformData(WTF::HashTableDeletedValueType)
- : m_typeface(hashTableDeletedFontValue())
- , m_textSize(0)
- , m_fakeBold(false)
- , m_fakeItalic(false)
- { }
-
- FontPlatformData()
- : m_typeface(0)
- , m_textSize(0)
- , m_fakeBold(false)
- , m_fakeItalic(false)
- { }
-
- FontPlatformData(float textSize, bool fakeBold, bool fakeItalic)
- : m_typeface(0)
- , m_textSize(textSize)
- , m_fakeBold(fakeBold)
- , m_fakeItalic(fakeItalic)
- { }
-
- FontPlatformData(const FontPlatformData&);
- FontPlatformData(SkTypeface *, float textSize, bool fakeBold, bool fakeItalic);
- FontPlatformData(const FontPlatformData& src, float textSize);
- ~FontPlatformData();
-
- // -------------------------------------------------------------------------
- // Return true iff this font is monospaced (i.e. every glyph has an equal x
- // advance)
- // -------------------------------------------------------------------------
- bool isFixedPitch() const;
-
- // -------------------------------------------------------------------------
- // Setup a Skia painting context to use this font.
- // -------------------------------------------------------------------------
- void setupPaint(SkPaint*) const;
-
- unsigned hash() const;
- float size() const { return m_textSize; }
-
- bool operator==(const FontPlatformData& other) const;
- FontPlatformData& operator=(const FontPlatformData& src);
- bool isHashTableDeletedValue() const { return m_typeface == hashTableDeletedFontValue(); }
-
-private:
- SkTypeface* m_typeface;
- float m_textSize;
- bool m_fakeBold;
- bool m_fakeItalic;
-
- SkTypeface* hashTableDeletedFontValue() const { return reinterpret_cast<SkTypeface*>(-1); }
-};
-
-} // namespace WebCore
-
-#endif // ifdef FontPlatformData_h
diff --git a/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.cpp b/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.cpp
deleted file mode 100644
index 3128259..0000000
--- a/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.cpp
+++ /dev/null
@@ -1,338 +0,0 @@
-// Copyright (c) 2006-2008, 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 "FontUtilsChromiumWin.h"
-
-#include <limits>
-
-#include "PlatformString.h"
-#include "StringHash.h"
-#include "UniscribeHelper.h"
-#include <unicode/locid.h>
-#include <unicode/uchar.h>
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-namespace {
-
-// A simple mapping from UScriptCode to family name. This is a sparse array,
-// which works well since the range of UScriptCode values is small.
-typedef const UChar* ScriptToFontMap[USCRIPT_CODE_LIMIT];
-
-void initializeScriptFontMap(ScriptToFontMap& scriptFontMap)
-{
- struct FontMap {
- UScriptCode script;
- const UChar* family;
- };
-
- const static FontMap fontMap[] = {
- {USCRIPT_LATIN, L"times new roman"},
- {USCRIPT_GREEK, L"times new roman"},
- {USCRIPT_CYRILLIC, L"times new roman"},
- {USCRIPT_SIMPLIFIED_HAN, L"simsun"},
- //{USCRIPT_TRADITIONAL_HAN, L"pmingliu"},
- {USCRIPT_HIRAGANA, L"ms pgothic"},
- {USCRIPT_KATAKANA, L"ms pgothic"},
- {USCRIPT_KATAKANA_OR_HIRAGANA, L"ms pgothic"},
- {USCRIPT_HANGUL, L"gulim"},
- {USCRIPT_THAI, L"tahoma"},
- {USCRIPT_HEBREW, L"david"},
- {USCRIPT_ARABIC, L"tahoma"},
- {USCRIPT_DEVANAGARI, L"mangal"},
- {USCRIPT_BENGALI, L"vrinda"},
- {USCRIPT_GURMUKHI, L"raavi"},
- {USCRIPT_GUJARATI, L"shruti"},
- {USCRIPT_ORIYA, L"kalinga"},
- {USCRIPT_TAMIL, L"latha"},
- {USCRIPT_TELUGU, L"gautami"},
- {USCRIPT_KANNADA, L"tunga"},
- {USCRIPT_MALAYALAM, L"kartika"},
- {USCRIPT_LAO, L"dokchampa"},
- {USCRIPT_TIBETAN, L"microsoft himalaya"},
- {USCRIPT_GEORGIAN, L"sylfaen"},
- {USCRIPT_ARMENIAN, L"sylfaen"},
- {USCRIPT_ETHIOPIC, L"nyala"},
- {USCRIPT_CANADIAN_ABORIGINAL, L"euphemia"},
- {USCRIPT_CHEROKEE, L"plantagenet cherokee"},
- {USCRIPT_YI, L"microsoft yi balti"},
- {USCRIPT_SINHALA, L"iskoola pota"},
- {USCRIPT_SYRIAC, L"estrangelo edessa"},
- {USCRIPT_KHMER, L"daunpenh"},
- {USCRIPT_THAANA, L"mv boli"},
- {USCRIPT_MONGOLIAN, L"mongolian balti"},
- {USCRIPT_MYANMAR, L"padauk"},
- // For USCRIPT_COMMON, we map blocks to scripts when
- // that makes sense.
- };
-
- for (int i = 0; i < sizeof(fontMap) / sizeof(fontMap[0]); ++i)
- scriptFontMap[fontMap[i].script] = fontMap[i].family;
-
- // Initialize the locale-dependent mapping.
- // Since Chrome synchronizes the ICU default locale with its UI locale,
- // this ICU locale tells the current UI locale of Chrome.
- Locale locale = Locale::getDefault();
- const UChar* localeFamily = NULL;
- if (locale == Locale::getJapanese()) {
- localeFamily = scriptFontMap[USCRIPT_HIRAGANA];
- } else if (locale == Locale::getKorean()) {
- localeFamily = scriptFontMap[USCRIPT_HANGUL];
- } else {
- // Use Simplified Chinese font for all other locales including
- // Traditional Chinese because Simsun (SC font) has a wider
- // coverage (covering both SC and TC) than PMingLiu (TC font).
- // This also speeds up the TC version of Chrome when rendering SC
- // pages.
- localeFamily = scriptFontMap[USCRIPT_SIMPLIFIED_HAN];
- }
- if (localeFamily)
- scriptFontMap[USCRIPT_HAN] = localeFamily;
-}
-
-const int kUndefinedAscent = std::numeric_limits<int>::min();
-
-// Given an HFONT, return the ascent. If GetTextMetrics fails,
-// kUndefinedAscent is returned, instead.
-int getAscent(HFONT hfont)
-{
- HDC dc = GetDC(NULL);
- HGDIOBJ oldFont = SelectObject(dc, hfont);
- TEXTMETRIC tm;
- BOOL gotMetrics = GetTextMetrics(dc, &tm);
- SelectObject(dc, oldFont);
- ReleaseDC(NULL, dc);
- return gotMetrics ? tm.tmAscent : kUndefinedAscent;
-}
-
-struct FontData {
- FontData() : hfont(NULL), ascent(kUndefinedAscent), scriptCache(NULL) {}
- HFONT hfont;
- int ascent;
- mutable SCRIPT_CACHE scriptCache;
-};
-
-// Again, using hash_map does not earn us much here. page_cycler_test intl2
-// gave us a 'better' result with map than with hash_map even though they're
-// well-within 1-sigma of each other so that the difference is not significant.
-// On the other hand, some pages in intl2 seem to take longer to load with map
-// in the 1st pass. Need to experiment further.
-typedef HashMap<String, FontData> FontDataCache;
-
-} // namespace
-
-// TODO(jungshik) : this is font fallback code version 0.1
-// - Cover all the scripts
-// - Get the default font for each script/generic family from the
-// preference instead of hardcoding in the source.
-// (at least, read values from the registry for IE font settings).
-// - Support generic families (from FontDescription)
-// - If the default font for a script is not available,
-// try some more fonts known to support it. Finally, we can
-// use EnumFontFamilies or similar APIs to come up with a list of
-// fonts supporting the script and cache the result.
-// - Consider using UnicodeSet (or UnicodeMap) converted from
-// GLYPHSET (BMP) or directly read from truetype cmap tables to
-// keep track of which character is supported by which font
-// - Update script_font_cache in response to WM_FONTCHANGE
-
-const UChar* getFontFamilyForScript(UScriptCode script,
- FontDescription::GenericFamilyType generic)
-{
- static ScriptToFontMap scriptFontMap;
- static bool initialized = false;
- if (!initialized) {
- initializeScriptFontMap(scriptFontMap);
- initialized = true;
- }
- if (script == USCRIPT_INVALID_CODE)
- return NULL;
- ASSERT(script < USCRIPT_CODE_LIMIT);
- return scriptFontMap[script];
-}
-
-// TODO(jungshik)
-// - Handle 'Inherited', 'Common' and 'Unknown'
-// (see http://www.unicode.org/reports/tr24/#Usage_Model )
-// For 'Inherited' and 'Common', perhaps we need to
-// accept another parameter indicating the previous family
-// and just return it.
-// - All the characters (or characters up to the point a single
-// font can cover) need to be taken into account
-const UChar* getFallbackFamily(const UChar *characters,
- int length,
- FontDescription::GenericFamilyType generic,
- UChar32 *charChecked,
- UScriptCode *scriptChecked)
-{
- ASSERT(characters && characters[0] && length > 0);
- UScriptCode script = USCRIPT_COMMON;
-
- // Sometimes characters common to script (e.g. space) is at
- // the beginning of a string so that we need to skip them
- // to get a font required to render the string.
- int i = 0;
- UChar32 ucs4 = 0;
- while (i < length && script == USCRIPT_COMMON ||
- script == USCRIPT_INVALID_CODE) {
- U16_NEXT(characters, i, length, ucs4);
- UErrorCode err = U_ZERO_ERROR;
- script = uscript_getScript(ucs4, &err);
- // silently ignore the error
- }
-
- // hack for full width ASCII. For the full-width ASCII, use the font
- // for Han (which is locale-dependent).
- if (0xFF00 < ucs4 && ucs4 < 0xFF5F)
- script = USCRIPT_HAN;
-
- // There are a lot of characters in USCRIPT_COMMON that can be covered
- // by fonts for scripts closely related to them. See
- // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:Script=Common:]
- // TODO(jungshik): make this more efficient with a wider coverage
- if (script == USCRIPT_COMMON || script == USCRIPT_INHERITED) {
- UBlockCode block = ublock_getCode(ucs4);
- switch (block) {
- case UBLOCK_BASIC_LATIN:
- script = USCRIPT_LATIN;
- break;
- case UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION:
- script = USCRIPT_HAN;
- break;
- case UBLOCK_HIRAGANA:
- case UBLOCK_KATAKANA:
- script = USCRIPT_HIRAGANA;
- break;
- case UBLOCK_ARABIC:
- script = USCRIPT_ARABIC;
- break;
- case UBLOCK_GREEK:
- script = USCRIPT_GREEK;
- break;
- case UBLOCK_DEVANAGARI:
- // For Danda and Double Danda (U+0964, U+0965), use a Devanagari
- // font for now although they're used by other scripts as well.
- // Without a context, we can't do any better.
- script = USCRIPT_DEVANAGARI;
- break;
- case UBLOCK_ARMENIAN:
- script = USCRIPT_ARMENIAN;
- break;
- case UBLOCK_GEORGIAN:
- script = USCRIPT_GEORGIAN;
- break;
- case UBLOCK_KANNADA:
- script = USCRIPT_KANNADA;
- break;
- }
- }
-
- // Another lame work-around to cover non-BMP characters.
- const UChar* family = getFontFamilyForScript(script, generic);
- if (!family) {
- int plane = ucs4 >> 16;
- switch (plane) {
- case 1:
- family = L"code2001";
- break;
- case 2:
- family = L"simsun-extb";
- break;
- default:
- family = L"lucida sans unicode";
- }
- }
-
- if (charChecked)
- *charChecked = ucs4;
- if (scriptChecked)
- *scriptChecked = script;
- return family;
-}
-
-// Be aware that this is not thread-safe.
-bool getDerivedFontData(const UChar *family,
- int style,
- LOGFONT *logfont,
- int *ascent,
- HFONT *hfont,
- SCRIPT_CACHE **scriptCache) {
- ASSERT(logfont && family && *family);
-
- // It does not matter that we leak font data when we exit.
- static FontDataCache fontDataCache;
-
- // TODO(jungshik) : This comes up pretty high in the profile so that
- // we need to measure whether using SHA256 (after coercing all the
- // fields to char*) is faster than String::format.
- String fontKey = String::format("%1d:%d:%ls", style, logfont->lfHeight, family);
- FontDataCache::iterator iter = fontDataCache.find(fontKey);
- FontData *derived;
- if (iter == fontDataCache.end()) {
- ASSERT(wcslen(family) < LF_FACESIZE);
- wcscpy_s(logfont->lfFaceName, LF_FACESIZE, family);
- // TODO(jungshik): CreateFontIndirect always comes up with
- // a font even if there's no font matching the name. Need to
- // check it against what we actually want (as is done in
- // FontCacheWin.cpp)
- pair<FontDataCache::iterator, bool> entry = fontDataCache.add(fontKey, FontData());
- derived = &entry.first->second;
- derived->hfont = CreateFontIndirect(logfont);
- // GetAscent may return kUndefinedAscent, but we still want to
- // cache it so that we won't have to call CreateFontIndirect once
- // more for HFONT next time.
- derived->ascent = getAscent(derived->hfont);
- } else {
- derived = &iter->second;
- // Last time, GetAscent failed so that only HFONT was
- // cached. Try once more assuming that TryPreloadFont
- // was called by a caller between calls.
- if (kUndefinedAscent == derived->ascent)
- derived->ascent = getAscent(derived->hfont);
- }
- *hfont = derived->hfont;
- *ascent = derived->ascent;
- *scriptCache = &(derived->scriptCache);
- return *ascent != kUndefinedAscent;
-}
-
-int getStyleFromLogfont(const LOGFONT* logfont) {
- // TODO(jungshik) : consider defining UNDEFINED or INVALID for style and
- // returning it when logfont is NULL
- if (!logfont) {
- ASSERT_NOT_REACHED();
- return FontStyleNormal;
- }
- return (logfont->lfItalic ? FontStyleItalic : FontStyleNormal) |
- (logfont->lfUnderline ? FontStyleUnderlined : FontStyleNormal) |
- (logfont->lfWeight >= 700 ? FontStyleBold : FontStyleNormal);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.h b/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.h
deleted file mode 100644
index 82162f4..0000000
--- a/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2006-2008, 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.
-
-// A collection of utilities for font handling.
-
-#ifndef FontUtilsWin_h
-#define FontUtilsWin_h
-
-#include <usp10.h>
-#include <wchar.h>
-#include <windows.h>
-
-#include "FontDescription.h"
-#include <unicode/uscript.h>
-
-namespace WebCore {
-
-// Return a font family that supports a script and belongs to |generic| font
-// family. It can return NULL and a caller has to implement its own fallback.
-const UChar* getFontFamilyForScript(UScriptCode script,
- FontDescription::GenericFamilyType generic);
-
-// Return a font family that can render |characters| based on
-// what script characters belong to. When char_checked is non-NULL,
-// it's filled with the character used to determine the script.
-// When script_checked is non-NULL, the script used to determine
-// the family is returned.
-// TODO(jungshik) : This function needs a total overhaul.
-const UChar* getFallbackFamily(const UChar* characters,
- int length,
- FontDescription::GenericFamilyType generic,
- UChar32 *charChecked,
- UScriptCode *scriptChecked);
-
-// Derive a new HFONT by replacing lfFaceName of LOGFONT with |family|,
-// calculate the ascent for the derived HFONT, and initialize SCRIPT_CACHE
-// in FontData.
-// |style| is only used for cache key generation. |style| is
-// bit-wise OR of BOLD(1), UNDERLINED(2) and ITALIC(4) and
-// should match what's contained in LOGFONT. It should be calculated
-// by calling GetStyleFromLogFont.
-// Returns false if the font is not accessible, in which case |ascent| field
-// of |fontdata| is set to kUndefinedAscent.
-// Be aware that this is not thread-safe.
-// TODO(jungshik): Instead of having three out params, we'd better have one
-// (|*FontData|), but somehow it mysteriously messes up the layout for
-// certain complex script pages (e.g. hi.wikipedia.org) and also crashes
-// at the start-up if recently visited page list includes pages with complex
-// scripts in their title. Moreover, somehow the very first-pass of
-// intl2 page-cycler test is noticeably slower with one out param than
-// the current version although the subsequent 9 passes take about the
-// same time.
-bool getDerivedFontData(const UChar *family,
- int style,
- LOGFONT *logfont,
- int *ascent,
- HFONT *hfont,
- SCRIPT_CACHE **scriptCache);
-
-enum {
- FontStyleNormal = 0,
- FontStyleBold = 1,
- FontStyleItalic = 2,
- FontStyleUnderlined = 4
-};
-
-// Derive style (bit-wise OR of FONT_STYLE_BOLD, FONT_STYLE_UNDERLINED, and
-// FONT_STYLE_ITALIC) from LOGFONT. Returns 0 if |*logfont| is NULL.
-int getStyleFromLogfont(const LOGFONT *logfont);
-
-} // namespace WebCore
-
-#endif // FontUtilsWin_h
diff --git a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp
deleted file mode 100644
index 1f29c88..0000000
--- a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright (c) 2008, 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 <windows.h>
-#include <vector>
-
-#include "ChromiumBridge.h"
-#include "ChromiumUtilsWin.h"
-#include "Font.h"
-#include "GlyphPageTreeNode.h"
-#include "SimpleFontData.h"
-#include "UniscribeHelperTextRun.h"
-
-namespace WebCore
-{
-
-// Fills one page of font data pointers with NULL to indicate that there
-// are no glyphs for the characters.
-static void fillEmptyGlyphs(GlyphPage* page)
-{
- for (int i = 0; i < GlyphPage::size; ++i)
- page->setGlyphDataForIndex(i, NULL, NULL);
-}
-
-// Lazily initializes space glyph
-static Glyph initSpaceGlyph(HDC dc, Glyph* space_glyph)
-{
- if (*space_glyph)
- return *space_glyph;
- static wchar_t space = ' ';
- GetGlyphIndices(dc, &space, 1, space_glyph, 0);
- return *space_glyph;
-}
-
-// Fills a page of glyphs in the Basic Multilingual Plane (<= U+FFFF). We
-// can use the standard Windows GDI functions here. The input buffer size is
-// assumed to be GlyphPage::size. Returns true if any glyphs were found.
-static bool fillBMPGlyphs(UChar* buffer,
- GlyphPage* page,
- const SimpleFontData* fontData,
- bool recurse)
-{
- HDC dc = GetDC((HWND)0);
- HGDIOBJ old_font = SelectObject(dc, fontData->m_font.hfont());
-
- TEXTMETRIC tm = {0};
- if (!GetTextMetrics(dc, &tm)) {
- SelectObject(dc, old_font);
- ReleaseDC(0, dc);
-
- if (recurse) {
- if (ChromiumBridge::ensureFontLoaded(fontData->m_font.hfont())) {
- return fillBMPGlyphs(buffer, page, fontData, false);
- } else {
- fillEmptyGlyphs(page);
- return false;
- }
- } else {
- // TODO(nsylvain): This should never happen. We want to crash the
- // process and receive a crash dump. We should revisit this code later.
- // See bug 1136944.
- ASSERT_NOT_REACHED();
- fillEmptyGlyphs(page);
- return false;
- }
- }
-
- // NOTE(hbono): GetGlyphIndices() sets each item of localGlyphBuffer[]
- // with the one of the values listed below.
- // * With the GGI_MARK_NONEXISTING_GLYPHS flag
- // + If the font has a glyph available for the character,
- // localGlyphBuffer[i] > 0x0.
- // + If the font does not have glyphs available for the character,
- // localGlyphBuffer[i] = 0x1F (TrueType Collection?) or
- // 0xFFFF (OpenType?).
- // * Without the GGI_MARK_NONEXISTING_GLYPHS flag
- // + If the font has a glyph available for the character,
- // localGlyphBuffer[i] > 0x0.
- // + If the font does not have glyphs available for the character,
- // localGlyphBuffer[i] = 0x80.
- // (Windows automatically assigns the glyph for a box character to
- // prevent ExtTextOut() from returning errors.)
- // To avoid from hurting the rendering performance, this code just
- // tells WebKit whether or not the all glyph indices for the given
- // characters are 0x80 (i.e. a possibly-invalid glyph) and let it
- // use alternative fonts for the characters.
- // Although this may cause a problem, it seems to work fine as far as I
- // have tested. (Obviously, I need more tests.)
- WORD localGlyphBuffer[GlyphPage::size];
-
- // NOTE(jnd). I find some Chinese characters can not be correctly displayed
- // when call GetGlyphIndices without flag GGI_MARK_NONEXISTING_GLYPHS,
- // because the corresponding glyph index is set as 0x20 when current font
- // does not have glyphs available for the character. According a blog post
- // http://blogs.msdn.com/michkap/archive/2006/06/28/649791.aspx
- // I think we should switch to the way about calling GetGlyphIndices with
- // flag GGI_MARK_NONEXISTING_GLYPHS, it should be OK according the
- // description of MSDN.
- // Also according to Jungshik and Hironori's suggestion and modification
- // we treat turetype and raster Font as different way when windows version
- // is less than Vista.
- GetGlyphIndices(dc, buffer, GlyphPage::size, localGlyphBuffer,
- GGI_MARK_NONEXISTING_GLYPHS);
-
- // Copy the output to the GlyphPage
- bool have_glyphs = false;
- int invalid_glyph = 0xFFFF;
- if (!ChromiumUtils::isVistaOrGreater() && !(tm.tmPitchAndFamily & TMPF_TRUETYPE))
- invalid_glyph = 0x1F;
-
- Glyph space_glyph = 0; // Glyph for a space. Lazily filled.
-
- for (unsigned i = 0; i < GlyphPage::size; i++) {
- UChar c = buffer[i];
- Glyph glyph = localGlyphBuffer[i];
- const SimpleFontData* glyphFontData = fontData;
- // When this character should be a space, we ignore whatever the font
- // says and use a space. Otherwise, if fonts don't map one of these
- // space or zero width glyphs, we will get a box.
- if (Font::treatAsSpace(c)) {
- // Hard code the glyph indices for characters that should be
- // treated like spaces.
- glyph = initSpaceGlyph(dc, &space_glyph);
- // TODO(dglazkov): change Font::treatAsZeroWidthSpace to use
- // u_hasBinaryProperty, per jungshik's comment here:
- // https://bugs.webkit.org/show_bug.cgi?id=20237#c6.
- // Then the additional OR won't be necessary.
- } else if (Font::treatAsZeroWidthSpace(c) || c == 0x200B) {
- glyph = initSpaceGlyph(dc, &space_glyph);
- glyphFontData = fontData->zeroWidthFontData();
- } else if (glyph == invalid_glyph) {
- // WebKit expects both the glyph index and FontData
- // pointer to be NULL if the glyph is not present
- glyph = 0;
- glyphFontData = 0;
- } else {
- if (SimpleFontData::isCJKCodePoint(c))
- glyphFontData = fontData->cjkWidthFontData();
- have_glyphs = true;
- }
- page->setGlyphDataForCharacter(i, glyph, glyphFontData);
- }
-
- SelectObject(dc, old_font);
- ReleaseDC(0, dc);
- return have_glyphs;
-}
-
-// For non-BMP characters, each is two words (UTF-16) and the input buffer size
-// is (GlyphPage::size * 1). Since GDI doesn't know how to handle non-BMP
-// characters, we must use Uniscribe to tell us the glyph indices.
-//
-// We don't want to call this in the case of "regular" characters since some
-// fonts may not have the correct combining rules for accents. See the notes
-// at the bottom of ScriptGetCMap. We can't use ScriptGetCMap, though, since
-// it doesn't seem to support UTF-16, despite what this blog post says:
-// http://blogs.msdn.com/michkap/archive/2006/06/29/650680.aspx
-//
-// So we fire up the full Uniscribe doohicky, give it our string, and it will
-// correctly handle the UTF-16 for us. The hard part is taking this and getting
-// the glyph indices back out that correspond to the correct input characters,
-// since they may be missing.
-//
-// Returns true if any glyphs were found.
-static bool fillNonBMPGlyphs(UChar* buffer,
- GlyphPage* page,
- const SimpleFontData* fontData)
-{
- bool haveGlyphs = false;
-
- UniscribeHelperTextRun state(buffer, GlyphPage::size * 2, false,
- fontData->m_font.hfont(),
- fontData->m_font.scriptCache(),
- fontData->m_font.scriptFontProperties());
- state.setInhibitLigate(true);
- state.Init();
-
- for (unsigned i = 0; i < GlyphPage::size; i++) {
- // Each character in this input buffer is a surrogate pair, which
- // consists of two UChars. So, the offset for its i-th character is
- // (i * 2).
- WORD glyph = state.FirstGlyphForCharacter(i * 2);
- if (glyph) {
- haveGlyphs = true;
- page->setGlyphDataForIndex(i, glyph, fontData);
- } else {
- // Clear both glyph and fontData fields.
- page->setGlyphDataForIndex(i, 0, 0);
- }
- }
- return haveGlyphs;
-}
-
-// We're supposed to return true if there are any glyphs in this page in our
-// font, false if there are none.
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* characterBuffer,
- unsigned bufferLength, const SimpleFontData* fontData)
-{
- // This function's parameters are kind of stupid. We always fill this page,
- // which is a fixed size. The source character indices are in the given
- // input buffer. For non-BMP characters each character will be represented
- // by a surrogate pair (two characters), so the input bufferLength will be
- // twice as big, even though the output size is the same.
- //
- // We have to handle BMP and non-BMP characters differently anyway...
- if (bufferLength == GlyphPage::size) {
- return fillBMPGlyphs(characterBuffer, this, fontData, true);
- } else if (bufferLength == GlyphPage::size * 2) {
- return fillNonBMPGlyphs(characterBuffer, this, fontData);
- } else {
- // TODO: http://b/1007391 make use of offset and length
- return false;
- }
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp
deleted file mode 100644
index 65b02c7..0000000
--- a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2008, 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 "GlyphPageTreeNode.h"
-
-#include "Font.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-
-#include "SkTemplates.h"
-#include "SkPaint.h"
-#include "SkUtils.h"
-
-namespace WebCore
-{
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
- SkDebugf("%s last char is high-surrogate", __FUNCTION__);
- return false;
- }
-
- SkPaint paint;
- fontData->platformData().setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- SkAutoSTMalloc <GlyphPage::size, uint16_t> glyphStorage(length);
- uint16_t* glyphs = glyphStorage.get();
- // textToGlyphs takes a byte count, not a glyph count so we multiply by two.
- unsigned count = paint.textToGlyphs(buffer, bufferLength * 2, glyphs);
- if (count != length) {
- SkDebugf("%s count != length\n", __FUNCTION__);
- return false;
- }
-
- unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero
- for (unsigned i = 0; i < length; i++) {
- setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? fontData : NULL);
- allGlyphs |= glyphs[i];
- }
- return allGlyphs != 0;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/IconChromiumLinux.cpp b/webkit/port/platform/graphics/chromium/IconChromiumLinux.cpp
deleted file mode 100644
index 9c38d84..0000000
--- a/webkit/port/platform/graphics/chromium/IconChromiumLinux.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* Copyright (C) 2006, 2007 Apple Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Library General Public
-* License as published by the Free Software Foundation; either
-* version 2 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Library General Public License for more details.
-*
-* You should have received a copy of the GNU Library General Public License
-* along with this library; see the file COPYING.LIB. If not, write to
-* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-* Boston, MA 02111-1307, USA.
-*
-*/
-
-#include "config.h"
-
-#include "Icon.h"
-
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-Icon::Icon(const PlatformIcon& icon)
- : m_icon(icon)
-{
-}
-
-Icon::~Icon()
-{
-}
-
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
- notImplemented();
- return NULL;
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- notImplemented();
- return NULL;
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& r)
-{
- notImplemented();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/IconChromiumMac.cpp b/webkit/port/platform/graphics/chromium/IconChromiumMac.cpp
deleted file mode 100644
index 6514d71..0000000
--- a/webkit/port/platform/graphics/chromium/IconChromiumMac.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2008, 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 "Icon.h"
-#include "PassRefPtr.h"
-
-// TODO(port): These are temporary stubs, we need real implementations which
-// may come in the form of IconChromium.cpp. The Windows Chromium
-// implementation is currently in IconWin.cpp.
-
-namespace WebCore {
-
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
- return NULL;
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- return NULL;
-}
-
-Icon::~Icon()
-{
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
-}
-
-}
diff --git a/webkit/port/platform/graphics/chromium/IconChromiumWin.cpp b/webkit/port/platform/graphics/chromium/IconChromiumWin.cpp
deleted file mode 100644
index 4d640cc..0000000
--- a/webkit/port/platform/graphics/chromium/IconChromiumWin.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-* Copyright (C) 2006, 2007 Apple Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Library General Public
-* License as published by the Free Software Foundation; either
-* version 2 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Library General Public License for more details.
-*
-* You should have received a copy of the GNU Library General Public License
-* along with this library; see the file COPYING.LIB. If not, write to
-* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-* Boston, MA 02111-1307, USA.
-*
-*/
-
-#include "config.h"
-
-#include <windows.h>
-#include <shellapi.h>
-
-#include "GraphicsContext.h"
-#include "Icon.h"
-#include "PlatformContextSkia.h"
-#include "PlatformString.h"
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-Icon::Icon(const PlatformIcon& icon)
- : m_icon(icon)
-{
-}
-
-Icon::~Icon()
-{
- if (m_icon)
- DestroyIcon(m_icon);
-}
-
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
- SHFILEINFO sfi;
- memset(&sfi, 0, sizeof(sfi));
-
- String tmpFilename = filename;
- if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
- return 0;
-
- return adoptRef(new Icon(sfi.hIcon));
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- // TODO: support multiple files.
- // http://code.google.com/p/chromium/issues/detail?id=4092
- if (!filenames.size())
- return 0;
-
- return createIconForFile(filenames[0]);
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
- if (context->paintingDisabled())
- return;
-
- HDC hdc = context->platformContext()->canvas()->beginPlatformPaint();
- DrawIconEx(hdc, rect.x(), rect.y(), m_icon, rect.width(), rect.height(),
- 0, 0, DI_NORMAL);
- context->platformContext()->canvas()->endPlatformPaint();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/ImageBufferData.h b/webkit/port/platform/graphics/chromium/ImageBufferData.h
deleted file mode 100644
index f8d3fd3..0000000
--- a/webkit/port/platform/graphics/chromium/ImageBufferData.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 ImageBufferData_h
-#define ImageBufferData_h
-
-#if PLATFORM(DARWIN)
-// TODO(port): This #include isn't strictly kosher, but we're currently using
-// the Mac font code from upstream WebKit, and we need to pick up their header.
-#undef ImageBufferData_h
-#include "third_party/WebKit/WebCore/platform/graphics/cg/ImageBufferData.h"
-#else
-
-#include "PlatformContextSkia.h"
-
-#include "skia/ext/platform_canvas.h"
-
-namespace WebCore {
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
-
- skia::PlatformCanvas m_canvas;
-
- // Must be second since this will refer to m_canvas.
- PlatformContextSkia m_platformContext;
-};
-
-} // namespace WebCore
-
-#endif
-
-#endif // ImageBufferData_h
diff --git a/webkit/port/platform/graphics/chromium/ImageChromiumMac.mm b/webkit/port/platform/graphics/chromium/ImageChromiumMac.mm
deleted file mode 100644
index c2a3555..0000000
--- a/webkit/port/platform/graphics/chromium/ImageChromiumMac.mm
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// A wrapper around Uniscribe that provides a reasonable API.
-
-#include "config.h"
-
-#include "BitmapImage.h"
-#include "ChromiumBridge.h"
-#include "Image.h"
-
-
-namespace WebCore {
-
-PassRefPtr<Image> Image::loadPlatformResource(const char* name)
-{
- return ChromiumBridge::loadPlatformImageResource(name);
-}
-
-// TODO(port): These are temporary stubs, we need real implementations which
-// may come in the form of ImageChromium.cpp. The Windows Chromium
-// implementation is currently in ImageSkia.cpp.
-
-void BitmapImage::initPlatformData()
-{
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-}
-
-}
diff --git a/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h b/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
deleted file mode 100644
index 082b6ab..0000000
--- a/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2008, 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 MediaPlayerPrivateChromium_h
-#define MediaPlayerPrivateChromium_h
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayer.h"
-
-namespace WebCore {
-
- class MediaPlayerPrivate : public Noncopyable {
- public:
- MediaPlayerPrivate(MediaPlayer*);
- ~MediaPlayerPrivate();
-
- IntSize naturalSize() const;
- bool hasVideo() const;
-
- void load(const String& url);
- void cancelLoad();
-
- void play();
- void pause();
-
- bool paused() const;
- bool seeking() const;
-
- float duration() const;
- float currentTime() const;
- void seek(float time);
- void setEndTime(float);
-
- void setRate(float);
- void setVolume(float);
-
- int dataRate() const;
-
- MediaPlayer::NetworkState networkState() const;
- MediaPlayer::ReadyState readyState() const;
-
- float maxTimeBuffered() const;
- float maxTimeSeekable() const;
- unsigned bytesLoaded() const;
- bool totalBytesKnown() const;
- unsigned totalBytes() const;
-
- void setVisible(bool);
- void setRect(const IntRect&);
-
- void paint(GraphicsContext*, const IntRect&);
-
- static void getSupportedTypes(HashSet<String>& types);
- static bool isAvailable();
-
- // Public methods to be called by WebMediaPlayer
- FrameView* frameView();
- void networkStateChanged();
- void readyStateChanged();
- void timeChanged();
- void volumeChanged();
- void repaint();
-
- private:
- MediaPlayer* m_player;
- void* m_data;
- };
-}
-
-#endif
-
-#endif // MediaPlayerPrivateChromium_h
diff --git a/webkit/port/platform/graphics/chromium/PlatformIcon.h b/webkit/port/platform/graphics/chromium/PlatformIcon.h
deleted file mode 100644
index 9bbd548..0000000
--- a/webkit/port/platform/graphics/chromium/PlatformIcon.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2008, 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 PlatformIcon_h
-#define PlatformIcon_h
-
-typedef struct HICON__* HICON;
-
-namespace WebCore {
-
-typedef HICON PlatformIcon;
-
-}
-
-#endif
diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
deleted file mode 100644
index 6be0a1e..0000000
--- a/webkit/port/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "ChromiumBridge.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "SimpleFontData.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-#include <wtf/MathExtras.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-#include <objidl.h>
-#include <mlang.h>
-
-namespace WebCore {
-
-static inline float scaleEmToUnits(float x, int unitsPerEm)
-{
- return unitsPerEm ? x / (float)unitsPerEm : x;
-}
-
-void SimpleFontData::platformInit()
-{
- HDC dc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(dc, m_font.hfont());
-
- TEXTMETRIC tm = {0};
- if (!GetTextMetrics(dc, &tm)) {
- if (ChromiumBridge::ensureFontLoaded(m_font.hfont())) {
- // Retry GetTextMetrics.
- // TODO(nsylvain): Handle gracefully the error if this call also
- // fails.
- // See bug 1136944.
- if (!GetTextMetrics(dc, &tm)) {
- ASSERT_NOT_REACHED();
- }
- }
- }
-
- m_avgCharWidth = tm.tmAveCharWidth;
- m_maxCharWidth = tm.tmMaxCharWidth;
-
- m_ascent = tm.tmAscent;
- m_descent = tm.tmDescent;
- m_lineGap = tm.tmExternalLeading;
- m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts.
-
- OUTLINETEXTMETRIC otm;
- if (GetOutlineTextMetrics(dc, sizeof(otm), &otm) > 0) {
- // This is a TrueType font. We might be able to get an accurate xHeight.
- GLYPHMETRICS gm = {0};
- MAT2 mat = {{0, 1}, {0, 0}, {0, 0}, {0, 1}}; // The identity matrix.
- DWORD len = GetGlyphOutlineW(dc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
- if (len != GDI_ERROR && gm.gmBlackBoxY > 0)
- m_xHeight = static_cast<float>(gm.gmBlackBoxY);
- }
-
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
-
- SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
-}
-
-void SimpleFontData::platformDestroy()
-{
- // We don't hash this on Win32, so it's effectively owned by us.
- delete m_smallCapsFontData;
- m_smallCapsFontData = NULL;
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- LOGFONT winfont;
- GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont);
- float smallCapsSize = 0.70f * fontDescription.computedSize();
- // Unlike WebKit trunk, we don't multiply the size by 32. That seems
- // to be some kind of artifact of their CG backend, or something.
- winfont.lfHeight = -lroundf(smallCapsSize);
- HFONT hfont = CreateFontIndirect(&winfont);
- m_smallCapsFontData =
- new SimpleFontData(FontPlatformData(hfont, smallCapsSize));
- }
- return m_smallCapsFontData;
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- // This used to be implemented with IMLangFontLink2, but since that code has
- // been disabled, this would always return false anyway.
- return false;
-}
-
-void SimpleFontData::determinePitch()
-{
- // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that.
- HDC dc = GetDC((HWND)0);
- HGDIOBJ oldFont = SelectObject(dc, m_font.hfont());
-
- // Yes, this looks backwards, but the fixed pitch bit is actually set if the font
- // is *not* fixed pitch. Unbelievable but true.
- TEXTMETRIC tm = {0};
- if (!GetTextMetrics(dc, &tm)) {
- if (ChromiumBridge::ensureFontLoaded(m_font.hfont())) {
- // Retry GetTextMetrics.
- // TODO(nsylvain): Handle gracefully the error if this call also fails.
- // See bug 1136944.
- if (!GetTextMetrics(dc, &tm)) {
- ASSERT_NOT_REACHED();
- }
- }
- }
-
- m_treatAsFixedPitch = ((tm.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0);
-
- SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- HDC dc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(dc, m_font.hfont());
-
- int width = 0;
- if (!GetCharWidthI(dc, glyph, 1, 0, &width)) {
- // Ask the browser to preload the font and retry.
- if (ChromiumBridge::ensureFontLoaded(m_font.hfont())) {
- if (!GetCharWidthI(dc, glyph, 1, 0, &width)) {
- ASSERT_NOT_REACHED();
- }
- }
- }
-
- SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
-
- return static_cast<float>(width);
-}
-
-}
diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp
deleted file mode 100644
index 150e7c5..0000000
--- a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "Font.h"
-#include "FontCache.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-#include "Logging.h"
-#include "NotImplemented.h"
-
-#include "SkPaint.h"
-#include "SkTypeface.h"
-#include "SkTime.h"
-
-namespace WebCore {
-
-// Smallcaps versions of fonts are 70% the size of the normal font.
-static const float kSmallCapsFraction = 0.7f;
-
-void SimpleFontData::platformInit()
-{
- SkPaint paint;
- SkPaint::FontMetrics metrics;
-
- m_font.setupPaint(&paint);
- paint.getFontMetrics(&metrics);
-
- // Beware those who step here: This code is designed to match Win32 font
- // metrics *exactly*.
- if (metrics.fVDMXMetricsValid) {
- m_ascent = metrics.fVDMXAscent;
- m_descent = metrics.fVDMXDescent;
- } else {
- m_ascent = SkScalarRound(-metrics.fAscent);
- m_descent = SkScalarRound(metrics.fHeight) - m_ascent;
- }
-
- if (metrics.fXHeight) {
- m_xHeight = metrics.fXHeight;
- } else {
- // hack taken from the Windows port
- m_xHeight = static_cast<float>(m_ascent) * 0.56;
- }
-
- m_lineGap = SkScalarRound(metrics.fLeading);
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
-
- // In WebKit/WebCore/platform/graphics/SimpleFontData.cpp, m_spaceWidth is
- // calculated for us, but we need to calculate m_maxCharWidth and
- // m_avgCharWidth in order for text entry widgets to be sized correctly.
-
- m_maxCharWidth = SkScalarRound(metrics.fXRange * SkScalarRound(m_font.size()));
-
- if (metrics.fAvgCharWidth) {
- m_avgCharWidth = SkScalarRound(metrics.fAvgCharWidth);
- } else {
- m_avgCharWidth = m_xHeight;
-
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
-
- if (glyphPageZero) {
- static const UChar32 x_char = 'x';
- const Glyph x_glyph = glyphPageZero->glyphDataForCharacter(x_char).glyph;
-
- if (x_glyph) {
- m_avgCharWidth = widthForGlyph(x_glyph);
- }
- }
- }
-}
-
-void SimpleFontData::platformDestroy()
-{
- delete m_smallCapsFontData;
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- const float smallCapsSize = lroundf(fontDescription.computedSize() * kSmallCapsFraction);
- m_smallCapsFontData =
- new SimpleFontData(FontPlatformData(m_font, smallCapsSize));
- }
- return m_smallCapsFontData;
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- SkPaint paint;
- static const unsigned kMaxBufferCount = 64;
- uint16_t glyphs[kMaxBufferCount];
-
- m_font.setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- while (length > 0) {
- int n = SkMin32(length, SK_ARRAY_COUNT(glyphs));
-
- // textToGlyphs takes a byte count so we double the character count.
- int count = paint.textToGlyphs(characters, n * 2, glyphs);
- for (int i = 0; i < count; i++) {
- if (0 == glyphs[i]) {
- return false; // missing glyph
- }
- }
-
- characters += n;
- length -= n;
- }
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- m_treatAsFixedPitch = platformData().isFixedPitch();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- SkASSERT(sizeof(glyph) == 2); // compile-time assert
-
- SkPaint paint;
-
- m_font.setupPaint(&paint);
-
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- SkScalar width = paint.measureText(&glyph, 2);
-
- return SkScalarToFloat(width);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp
deleted file mode 100644
index 4461d3c..0000000
--- a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "ThemeHelperChromiumWin.h"
-
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-
-namespace WebCore {
-
-ThemeHelperWin::ThemeHelperWin(GraphicsContext* context,
- const IntRect& rect)
- : m_orgContext(context)
- , m_orgMatrix(context->getCTM())
- , m_orgRect(rect)
-{
- if (m_orgMatrix.b() != 0 || // Y skew
- m_orgMatrix.c() != 0) { // X skew
- // Complicated effects, make a copy and draw the bitmap there.
- m_type = COPY;
- m_rect.setSize(rect.size());
-
- m_newBuffer.set(ImageBuffer::create(rect.size(), false).release());
-
- // Theme drawing messes with the transparency.
- // TODO(brettw) Ideally, we would leave this transparent, but I was
- // having problems with button drawing, so we fill with white. Buttons
- // looked good with transparent here and no fixing up of the alpha
- // later, but text areas didn't. This makes text areas look good but
- // gives buttons a white halo. Is there a way to fix this? I think
- // buttons actually have antialised edges which is just not possible
- // to handle on a transparent background given that it messes with the
- // alpha channel.
- FloatRect newContextRect(0, 0, rect.width(), rect.height());
- GraphicsContext* newContext = m_newBuffer->context();
- newContext->setFillColor(Color::white);
- newContext->fillRect(newContextRect);
-
- return;
- }
-
- if (m_orgMatrix.a() != 1.0 || // X scale
- m_orgMatrix.d() != 1.0) { // Y scale
- // Only a scaling is applied.
- m_type = SCALE;
-
- // Save the transformed coordinates to draw.
- m_rect = m_orgMatrix.mapRect(rect);
-
- m_orgContext->save();
- m_orgContext->concatCTM(m_orgContext->getCTM().inverse());
- return;
- }
-
- // Nothing interesting.
- m_rect = rect;
- m_type = ORIGINAL;
-}
-
-ThemeHelperWin::~ThemeHelperWin()
-{
- switch (m_type) {
- case SCALE:
- m_orgContext->restore();
- break;
- case COPY: {
- // Copy the duplicate bitmap with our control to the original canvas.
- FloatRect destRect(m_orgRect);
- m_newBuffer->context()->platformContext()->canvas()->
- getTopPlatformDevice().fixupAlphaBeforeCompositing();
- m_orgContext->drawImage(m_newBuffer->image(), destRect);
- break;
- }
- case ORIGINAL:
- break;
- }
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h
deleted file mode 100644
index 6141824..0000000
--- a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 ThemeHelperWin_h
-#define ThemeHelperWin_h
-
-#include "AffineTransform.h"
-#include "ImageBuffer.h"
-#include "IntRect.h"
-#include "WTF/OwnPtr.h"
-
-namespace WebCore {
-
-class GraphicsContext;
-class IntRect;
-
-// Helps drawing theme elements like buttons and scroll bars. This will handle
-// translations and scalings that Windows might not, by either making Windows
-// draw the appropriate sized control, or by rendering it into an off-screen
-// context and transforming it ourselves.
-class ThemeHelperWin {
- enum Type {
- // Use the original canvas with no changes. This is the normal mode.
- ORIGINAL,
-
- // Use the original canvas but scale the rectangle of the control so
- // that it will be the correct size, undoing any scale already on the
- // canvas. This will have the effect of just drawing the control bigger
- // or smaller and not actually expanding or contracting the pixels in
- // it. This usually looks better.
- SCALE,
-
- // Make a copy of the control and then transform it ourselves after
- // Windows draws it. This allows us to get complex effects.
- COPY,
- };
-
-public:
- // Prepares drawing a control with the given rect to the given context.
- ThemeHelperWin(GraphicsContext* context, const IntRect& rect);
- ~ThemeHelperWin();
-
- // Returns the context to draw the control into, which may be the original
- // or the copy, depending on the mode.
- GraphicsContext* context()
- {
- return m_newBuffer.get() ? m_newBuffer->context() : m_orgContext;
- }
-
- // Returns the rectangle in which to draw into the canvas() by Windows.
- const IntRect& rect() { return m_rect; }
-
-private:
- Type m_type;
-
- // The original canvas to wrote to. Not owned by this class.
- GraphicsContext* m_orgContext;
- AffineTransform m_orgMatrix;
- IntRect m_orgRect;
-
- // When m_type == COPY, this will be a new surface owned by this class that
- // represents the copy.
- OwnPtr<ImageBuffer> m_newBuffer;
-
- // The control rectangle in the coordinate space of canvas().
- IntRect m_rect;
-};
-
-} // namespace WebCore
-
-#endif // ThemeHelperWin_h
diff --git a/webkit/port/platform/graphics/chromium/UniscribeHelper.cpp b/webkit/port/platform/graphics/chromium/UniscribeHelper.cpp
deleted file mode 100644
index 1ace87a..0000000
--- a/webkit/port/platform/graphics/chromium/UniscribeHelper.cpp
+++ /dev/null
@@ -1,868 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "UniscribeHelper.h"
-
-#include <windows.h>
-
-#include "FontUtilsChromiumWin.h"
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-// This function is used to see where word spacing should be applied inside
-// runs. Note that this must match Font::treatAsSpace so we all agree where
-// and how much space this is, so we don't want to do more general Unicode
-// "is this a word break" thing.
-static bool TreatAsSpace(UChar c)
-{
- return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0;
-}
-
-// SCRIPT_FONTPROPERTIES contains glyph indices for default, invalid
-// and blank glyphs. Just because ScriptShape succeeds does not mean
-// that a text run is rendered correctly. Some characters may be rendered
-// with default/invalid/blank glyphs. Therefore, we need to check if the glyph
-// array returned by ScriptShape contains any of those glyphs to make
-// sure that the text run is rendered successfully.
-static bool ContainsMissingGlyphs(WORD *glyphs,
- int length,
- SCRIPT_FONTPROPERTIES* properties)
-{
- for (int i = 0; i < length; ++i) {
- if (glyphs[i] == properties->wgDefault ||
- (glyphs[i] == properties->wgInvalid &&
- glyphs[i] != properties->wgBlank))
- return true;
- }
-
- return false;
-}
-
-// HFONT is the 'incarnation' of 'everything' about font, but it's an opaque
-// handle and we can't directly query it to make a new HFONT sharing
-// its characteristics (height, style, etc) except for family name.
-// This function uses GetObject to convert HFONT back to LOGFONT,
-// resets the fields of LOGFONT and calculates style to use later
-// for the creation of a font identical to HFONT other than family name.
-static void SetLogFontAndStyle(HFONT hfont, LOGFONT *logfont, int *style)
-{
- ASSERT(hfont && logfont);
- if (!hfont || !logfont)
- return;
-
- GetObject(hfont, sizeof(LOGFONT), logfont);
- // We reset these fields to values appropriate for CreateFontIndirect.
- // while keeping lfHeight, which is the most important value in creating
- // a new font similar to hfont.
- logfont->lfWidth = 0;
- logfont->lfEscapement = 0;
- logfont->lfOrientation = 0;
- logfont->lfCharSet = DEFAULT_CHARSET;
- logfont->lfOutPrecision = OUT_TT_ONLY_PRECIS;
- logfont->lfQuality = DEFAULT_QUALITY; // Honor user's desktop settings.
- logfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- if (style)
- *style = getStyleFromLogfont(logfont);
-}
-
-UniscribeHelper::UniscribeHelper(const UChar* input,
- int inputLength,
- bool isRtl,
- HFONT hfont,
- SCRIPT_CACHE* scriptCache,
- SCRIPT_FONTPROPERTIES* fontProperties)
- : m_input(input)
- , m_inputLength(inputLength)
- , m_isRtl(isRtl)
- , m_hfont(hfont)
- , m_scriptCache(scriptCache)
- , m_fontProperties(fontProperties)
- , m_directionalOverride(false)
- , m_inhibitLigate(false)
- , m_letterSpacing(0)
- , m_spaceWidth(0)
- , m_wordSpacing(0)
- , m_ascent(0)
-{
- m_logfont.lfFaceName[0] = 0;
-}
-
-UniscribeHelper::~UniscribeHelper()
-{
-}
-
-void UniscribeHelper::InitWithOptionalLengthProtection(bool lengthProtection)
-{
- // We cap the input length and just don't do anything. We'll allocate a lot
- // of things of the size of the number of characters, so the allocated
- // memory will be several times the input length. Plus shaping such a large
- // buffer may be a form of denial of service. No legitimate text should be
- // this long. It also appears that Uniscribe flatly rejects very long
- // strings, so we don't lose anything by doing this.
- //
- // The input length protection may be disabled by the unit tests to cause
- // an error condition.
- static const int kMaxInputLength = 65535;
- if (m_inputLength == 0 ||
- (lengthProtection && m_inputLength > kMaxInputLength))
- return;
-
- FillRuns();
- FillShapes();
- FillScreenOrder();
-}
-
-int UniscribeHelper::Width() const
-{
- int width = 0;
- for (int item_index = 0; item_index < static_cast<int>(m_runs.size());
- item_index++) {
- width += AdvanceForItem(item_index);
- }
- return width;
-}
-
-void UniscribeHelper::Justify(int additionalSpace)
-{
- // Count the total number of glyphs we have so we know how big to make the
- // buffers below.
- int totalGlyphs = 0;
- for (size_t run = 0; run < m_runs.size(); run++) {
- int run_idx = m_screenOrder[run];
- totalGlyphs += static_cast<int>(m_shapes[run_idx].glyphLength());
- }
- if (totalGlyphs == 0)
- return; // Nothing to do.
-
- // We make one big buffer in screen order of all the glyphs we are drawing
- // across runs so that the justification function will adjust evenly across
- // all glyphs.
- Vector<SCRIPT_VISATTR, 64> visattr;
- visattr.resize(totalGlyphs);
- Vector<int, 64> advances;
- advances.resize(totalGlyphs);
- Vector<int, 64> justify;
- justify.resize(totalGlyphs);
-
- // Build the packed input.
- int dest_index = 0;
- for (size_t run = 0; run < m_runs.size(); run++) {
- int run_idx = m_screenOrder[run];
- const Shaping& shaping = m_shapes[run_idx];
-
- for (int i = 0; i < shaping.glyphLength(); i++, dest_index++) {
- memcpy(&visattr[dest_index], &shaping.m_visattr[i],
- sizeof(SCRIPT_VISATTR));
- advances[dest_index] = shaping.m_advance[i];
- }
- }
-
- // The documentation for ScriptJustify is wrong, the parameter is the space
- // to add and not the width of the column you want.
- const int minKashida = 1; // How do we decide what this should be?
- ScriptJustify(&visattr[0], &advances[0], totalGlyphs, additionalSpace,
- minKashida, &justify[0]);
-
- // Now we have to unpack the justification amounts back into the runs so
- // the glyph indices match.
- int globalGlyphIndex = 0;
- for (size_t run = 0; run < m_runs.size(); run++) {
- int run_idx = m_screenOrder[run];
- Shaping& shaping = m_shapes[run_idx];
-
- shaping.m_justify.resize(shaping.glyphLength());
- for (int i = 0; i < shaping.glyphLength(); i++, globalGlyphIndex++)
- shaping.m_justify[i] = justify[globalGlyphIndex];
- }
-}
-
-int UniscribeHelper::CharacterToX(int offset) const
-{
- HRESULT hr;
- ASSERT(offset <= m_inputLength);
-
- // Our algorithm is to traverse the items in screen order from left to
- // right, adding in each item's screen width until we find the item with
- // the requested character in it.
- int width = 0;
- for (size_t screen_idx = 0; screen_idx < m_runs.size(); screen_idx++) {
- // Compute the length of this run.
- int itemIdx = m_screenOrder[screen_idx];
- const SCRIPT_ITEM& item = m_runs[itemIdx];
- const Shaping& shaping = m_shapes[itemIdx];
- int itemLength = shaping.charLength();
-
- if (offset >= item.iCharPos && offset <= item.iCharPos + itemLength) {
- // Character offset is in this run.
- int char_len = offset - item.iCharPos;
-
- int curX = 0;
- hr = ScriptCPtoX(char_len, FALSE, itemLength,
- shaping.glyphLength(),
- &shaping.m_logs[0], &shaping.m_visattr[0],
- shaping.effectiveAdvances(), &item.a, &curX);
- if (FAILED(hr))
- return 0;
-
- width += curX + shaping.m_prePadding;
- ASSERT(width >= 0);
- return width;
- }
-
- // Move to the next item.
- width += AdvanceForItem(itemIdx);
- }
- ASSERT(width >= 0);
- return width;
-}
-
-int UniscribeHelper::XToCharacter(int x) const
-{
- // We iterate in screen order until we find the item with the given pixel
- // position in it. When we find that guy, we ask Uniscribe for the
- // character index.
- HRESULT hr;
- for (size_t screen_idx = 0; screen_idx < m_runs.size(); screen_idx++) {
- int itemIdx = m_screenOrder[screen_idx];
- int advance_for_item = AdvanceForItem(itemIdx);
-
- // Note that the run may be empty if shaping failed, so we want to skip
- // over it.
- const Shaping& shaping = m_shapes[itemIdx];
- int itemLength = shaping.charLength();
- if (x <= advance_for_item && itemLength > 0) {
- // The requested offset is within this item.
- const SCRIPT_ITEM& item = m_runs[itemIdx];
-
- // Account for the leading space we've added to this run that
- // Uniscribe doesn't know about.
- x -= shaping.m_prePadding;
-
- int char_x = 0;
- int trailing;
- hr = ScriptXtoCP(x, itemLength, shaping.glyphLength(),
- &shaping.m_logs[0], &shaping.m_visattr[0],
- shaping.effectiveAdvances(), &item.a, &char_x,
- &trailing);
-
- // The character offset is within the item. We need to add the
- // item's offset to transform it into the space of the TextRun
- return char_x + item.iCharPos;
- }
-
- // The offset is beyond this item, account for its length and move on.
- x -= advance_for_item;
- }
-
- // Error condition, we don't know what to do if we don't have that X
- // position in any of our items.
- return 0;
-}
-
-void UniscribeHelper::Draw(HDC dc, int x, int y, int from, int to)
-{
- HGDIOBJ oldFont = 0;
- int curX = x;
- bool firstRun = true;
-
- for (size_t screen_idx = 0; screen_idx < m_runs.size(); screen_idx++) {
- int itemIdx = m_screenOrder[screen_idx];
- const SCRIPT_ITEM& item = m_runs[itemIdx];
- const Shaping& shaping = m_shapes[itemIdx];
-
- // Character offsets within this run. THESE MAY NOT BE IN RANGE and may
- // be negative, etc. The code below handles this.
- int fromChar = from - item.iCharPos;
- int to_char = to - item.iCharPos;
-
- // See if we need to draw any characters in this item.
- if (shaping.charLength() == 0 ||
- fromChar >= shaping.charLength() || to_char <= 0) {
- // No chars in this item to display.
- curX += AdvanceForItem(itemIdx);
- continue;
- }
-
- // Compute the starting glyph within this span. |from| and |to| are
- // global offsets that may intersect arbitrarily with our local run.
- int fromGlyph, afterGlyph;
- if (item.a.fRTL) {
- // To compute the first glyph when going RTL, we use |to|.
- if (to_char >= shaping.charLength()) {
- // The end of the text is after (to the left) of us.
- fromGlyph = 0;
- } else {
- // Since |to| is exclusive, the first character we draw on the
- // left is actually the one right before (to the right) of
- // |to|.
- fromGlyph = shaping.m_logs[to_char - 1];
- }
-
- // The last glyph is actually the first character in the range.
- if (fromChar <= 0) {
- // The first character to draw is before (to the right) of this
- // span, so draw all the way to the end.
- afterGlyph = shaping.glyphLength();
- } else {
- // We want to draw everything up until the character to the
- // right of |from|. To the right is - 1, so we look that up
- // (remember our character could be more than one glyph, so we
- // can't look up our glyph and add one).
- afterGlyph = shaping.m_logs[fromChar - 1];
- }
- } else {
- // Easy case, everybody agrees about directions. We only need to
- // handle boundary conditions to get a range inclusive at the
- // beginning, and exclusive at the ending. We have to do some
- // computation to see the glyph one past the end.
- fromGlyph = shaping.m_logs[fromChar < 0 ? 0 : fromChar];
- if (to_char >= shaping.charLength())
- afterGlyph = shaping.glyphLength();
- else
- afterGlyph = shaping.m_logs[to_char];
- }
-
- // Account for the characters that were skipped in this run. When
- // WebKit asks us to draw a subset of the run, it actually tells us
- // to draw at the X offset of the beginning of the run, since it
- // doesn't know the internal position of any of our characters.
- const int* effectiveAdvances = shaping.effectiveAdvances();
- int innerOffset = 0;
- for (int i = 0; i < fromGlyph; i++)
- innerOffset += effectiveAdvances[i];
-
- // Actually draw the glyphs we found.
- int glyphCount = afterGlyph - fromGlyph;
- if (fromGlyph >= 0 && glyphCount > 0) {
- // Account for the preceeding space we need to add to this run. We
- // don't need to count for the following space because that will be
- // counted in AdvanceForItem below when we move to the next run.
- innerOffset += shaping.m_prePadding;
-
- // Pass NULL in when there is no justification.
- const int* justify = shaping.m_justify.size() == 0 ?
- NULL : &shaping.m_justify[fromGlyph];
-
- if (firstRun) {
- oldFont = SelectObject(dc, shaping.m_hfont);
- firstRun = false;
- } else {
- SelectObject(dc, shaping.m_hfont);
- }
-
- // TODO(brettw) bug 698452: if a half a character is selected,
- // we should set up a clip rect so we draw the half of the glyph
- // correctly.
- // Fonts with different ascents can be used to render different
- // runs. 'Across-runs' y-coordinate correction needs to be
- // adjusted for each font.
- HRESULT hr = S_FALSE;
- for (int executions = 0; executions < 2; ++executions) {
- hr = ScriptTextOut(dc, shaping.m_scriptCache,
- curX + innerOffset,
- y - shaping.m_ascentOffset,
- 0, NULL, &item.a, NULL, 0,
- &shaping.m_glyphs[fromGlyph],
- glyphCount,
- &shaping.m_advance[fromGlyph],
- justify,
- &shaping.m_offsets[fromGlyph]);
- if (S_OK != hr && 0 == executions) {
- // If this ScriptTextOut is called from the renderer it
- // might fail because the sandbox is preventing it from
- // opening the font files. If we are running in the
- // renderer, TryToPreloadFont is overridden to ask the
- // browser to preload the font for us so we can access it.
- TryToPreloadFont(shaping.m_hfont);
- continue;
- }
- break;
- }
-
- ASSERT(S_OK == hr);
- }
-
- curX += AdvanceForItem(itemIdx);
- }
-
- if (oldFont)
- SelectObject(dc, oldFont);
-}
-
-WORD UniscribeHelper::FirstGlyphForCharacter(int charOffset) const
-{
- // Find the run for the given character.
- for (int i = 0; i < static_cast<int>(m_runs.size()); i++) {
- int firstChar = m_runs[i].iCharPos;
- const Shaping& shaping = m_shapes[i];
- int localOffset = charOffset - firstChar;
- if (localOffset >= 0 && localOffset < shaping.charLength()) {
- // The character is in this run, return the first glyph for it
- // (should generally be the only glyph). It seems Uniscribe gives
- // glyph 0 for empty, which is what we want to return in the
- // "missing" case.
- size_t glyphIndex = shaping.m_logs[localOffset];
- if (glyphIndex >= shaping.m_glyphs.size()) {
- // The glyph should be in this run, but the run has too few
- // actual characters. This can happen when shaping the run
- // fails, in which case, we should have no data in the logs at
- // all.
- ASSERT(shaping.m_glyphs.size() == 0);
- return 0;
- }
- return shaping.m_glyphs[glyphIndex];
- }
- }
- return 0;
-}
-
-void UniscribeHelper::FillRuns()
-{
- HRESULT hr;
- m_runs.resize(UNISCRIBE_HELPER_STACK_RUNS);
-
- SCRIPT_STATE inputState;
- inputState.uBidiLevel = m_isRtl;
- inputState.fOverrideDirection = m_directionalOverride;
- inputState.fInhibitSymSwap = false;
- inputState.fCharShape = false; // Not implemented in Uniscribe
- inputState.fDigitSubstitute = false; // Do we want this for Arabic?
- inputState.fInhibitLigate = m_inhibitLigate;
- inputState.fDisplayZWG = false; // Don't draw control characters.
- inputState.fArabicNumContext = m_isRtl; // Do we want this for Arabic?
- inputState.fGcpClusters = false;
- inputState.fReserved = 0;
- inputState.fEngineReserved = 0;
- // The psControl argument to ScriptItemize should be non-NULL for RTL text,
- // per http://msdn.microsoft.com/en-us/library/ms776532.aspx . So use a
- // SCRIPT_CONTROL that is set to all zeros. Zero as a locale ID means the
- // neutral locale per http://msdn.microsoft.com/en-us/library/ms776294.aspx
- static SCRIPT_CONTROL inputControl = {0, // uDefaultLanguage :16;
- 0, // fContextDigits :1;
- 0, // fInvertPreBoundDir :1;
- 0, // fInvertPostBoundDir :1;
- 0, // fLinkStringBefore :1;
- 0, // fLinkStringAfter :1;
- 0, // fNeutralOverride :1;
- 0, // fNumericOverride :1;
- 0, // fLegacyBidiClass :1;
- 0, // fMergeNeutralItems :1;
- 0};// fReserved :7;
- // Calling ScriptApplyDigitSubstitution( NULL, &inputControl, &inputState)
- // here would be appropriate if we wanted to set the language ID, and get
- // local digit substitution behavior. For now, don't do it.
-
- while (true) {
- int num_items = 0;
-
- // Ideally, we would have a way to know the runs before and after this
- // one, and put them into the control parameter of ScriptItemize. This
- // would allow us to shape characters properly that cross style
- // boundaries (WebKit bug 6148).
- //
- // We tell ScriptItemize that the output list of items is one smaller
- // than it actually is. According to Mozilla bug 366643, if there is
- // not enough room in the array on pre-SP2 systems, ScriptItemize will
- // write one past the end of the buffer.
- //
- // ScriptItemize is very strange. It will often require a much larger
- // ITEM buffer internally than it will give us as output. For example,
- // it will say a 16-item buffer is not big enough, and will write
- // interesting numbers into all those items. But when we give it a 32
- // item buffer and it succeeds, it only has one item output.
- //
- // It seems to be doing at least two passes, the first where it puts a
- // lot of intermediate data into our items, and the second where it
- // collates them.
- hr = ScriptItemize(m_input, m_inputLength,
- static_cast<int>(m_runs.size()) - 1, &inputControl,
- &inputState,
- &m_runs[0], &num_items);
- if (SUCCEEDED(hr)) {
- m_runs.resize(num_items);
- break;
- }
- if (hr != E_OUTOFMEMORY) {
- // Some kind of unexpected error.
- m_runs.resize(0);
- break;
- }
- // There was not enough items for it to write into, expand.
- m_runs.resize(m_runs.size() * 2);
- }
-}
-
-bool UniscribeHelper::Shape(const UChar* input,
- int itemLength,
- int numGlyphs,
- SCRIPT_ITEM& run,
- Shaping& shaping)
-{
- HFONT hfont = m_hfont;
- SCRIPT_CACHE* scriptCache = m_scriptCache;
- SCRIPT_FONTPROPERTIES* fontProperties = m_fontProperties;
- int ascent = m_ascent;
- HDC tempDC = NULL;
- HGDIOBJ oldFont = 0;
- HRESULT hr;
- bool lastFallbackTried = false;
- bool result;
-
- int generatedGlyphs = 0;
-
- // In case HFONT passed in ctor cannot render this run, we have to scan
- // other fonts from the beginning of the font list.
- ResetFontIndex();
-
- // Compute shapes.
- while (true) {
- shaping.m_logs.resize(itemLength);
- shaping.m_glyphs.resize(numGlyphs);
- shaping.m_visattr.resize(numGlyphs);
-
- // Firefox sets SCRIPT_ANALYSIS.SCRIPT_STATE.fDisplayZWG to true
- // here. Is that what we want? It will display control characters.
- hr = ScriptShape(tempDC, scriptCache, input, itemLength,
- numGlyphs, &run.a,
- &shaping.m_glyphs[0], &shaping.m_logs[0],
- &shaping.m_visattr[0], &generatedGlyphs);
- if (hr == E_PENDING) {
- // Allocate the DC.
- tempDC = GetDC(NULL);
- oldFont = SelectObject(tempDC, hfont);
- continue;
- } else if (hr == E_OUTOFMEMORY) {
- numGlyphs *= 2;
- continue;
- } else if (SUCCEEDED(hr) &&
- (lastFallbackTried ||
- !ContainsMissingGlyphs(&shaping.m_glyphs[0],
- generatedGlyphs, fontProperties))) {
- break;
- }
-
- // The current font can't render this run. clear DC and try
- // next font.
- if (tempDC) {
- SelectObject(tempDC, oldFont);
- ReleaseDC(NULL, tempDC);
- tempDC = NULL;
- }
-
- if (NextWinFontData(&hfont, &scriptCache, &fontProperties, &ascent)) {
- // The primary font does not support this run. Try next font.
- // In case of web page rendering, they come from fonts specified in
- // CSS stylesheets.
- continue;
- } else if (!lastFallbackTried) {
- lastFallbackTried = true;
-
- // Generate a last fallback font based on the script of
- // a character to draw while inheriting size and styles
- // from the primary font
- if (!m_logfont.lfFaceName[0])
- SetLogFontAndStyle(m_hfont, &m_logfont, &m_style);
-
- // TODO(jungshik): generic type should come from webkit for
- // UniscribeHelperTextRun (a derived class used in webkit).
- const UChar *family = getFallbackFamily(input, itemLength,
- FontDescription::StandardFamily, NULL, NULL);
- bool font_ok = getDerivedFontData(family, m_style, &m_logfont,
- &ascent, &hfont, &scriptCache);
-
- if (!font_ok) {
- // If this GetDerivedFontData is called from the renderer it
- // might fail because the sandbox is preventing it from opening
- // the font files. If we are running in the renderer,
- // TryToPreloadFont is overridden to ask the browser to preload
- // the font for us so we can access it.
- TryToPreloadFont(hfont);
-
- // Try again.
- font_ok = getDerivedFontData(family, m_style, &m_logfont,
- &ascent, &hfont, &scriptCache);
- ASSERT(font_ok);
- }
-
- // TODO(jungshik) : Currently GetDerivedHFont always returns a
- // a valid HFONT, but in the future, I may change it to return 0.
- ASSERT(hfont);
-
- // We don't need a font_properties for the last resort fallback font
- // because we don't have anything more to try and are forced to
- // accept empty glyph boxes. If we tried a series of fonts as
- // 'last-resort fallback', we'd need it, but currently, we don't.
- continue;
- } else if (hr == USP_E_SCRIPT_NOT_IN_FONT) {
- run.a.eScript = SCRIPT_UNDEFINED;
- continue;
- } else if (FAILED(hr)) {
- // Error shaping.
- generatedGlyphs = 0;
- result = false;
- goto cleanup;
- }
- }
-
- // Sets Windows font data for this run to those corresponding to
- // a font supporting this run. we don't need to store font_properties
- // because it's not used elsewhere.
- shaping.m_hfont = hfont;
- shaping.m_scriptCache = scriptCache;
-
- // The ascent of a font for this run can be different from
- // that of the primary font so that we need to keep track of
- // the difference per run and take that into account when calling
- // ScriptTextOut in |Draw|. Otherwise, different runs rendered by
- // different fonts would not be aligned vertically.
- shaping.m_ascentOffset = m_ascent ? ascent - m_ascent : 0;
- result = true;
-
- cleanup:
- shaping.m_glyphs.resize(generatedGlyphs);
- shaping.m_visattr.resize(generatedGlyphs);
- shaping.m_advance.resize(generatedGlyphs);
- shaping.m_offsets.resize(generatedGlyphs);
- if (tempDC) {
- SelectObject(tempDC, oldFont);
- ReleaseDC(NULL, tempDC);
- }
- // On failure, our logs don't mean anything, so zero those out.
- if (!result)
- shaping.m_logs.clear();
-
- return result;
-}
-
-void UniscribeHelper::FillShapes()
-{
- m_shapes.resize(m_runs.size());
- for (size_t i = 0; i < m_runs.size(); i++) {
- int startItem = m_runs[i].iCharPos;
- int itemLength = m_inputLength - startItem;
- if (i < m_runs.size() - 1)
- itemLength = m_runs[i + 1].iCharPos - startItem;
-
- int numGlyphs;
- if (itemLength < UNISCRIBE_HELPER_STACK_CHARS) {
- // We'll start our buffer sizes with the current stack space
- // available in our buffers if the current input fits. As long as
- // it doesn't expand past that we'll save a lot of time mallocing.
- numGlyphs = UNISCRIBE_HELPER_STACK_CHARS;
- } else {
- // When the input doesn't fit, give up with the stack since it will
- // almost surely not be enough room (unless the input actually
- // shrinks, which is unlikely) and just start with the length
- // recommended by the Uniscribe documentation as a "usually fits"
- // size.
- numGlyphs = itemLength * 3 / 2 + 16;
- }
-
- // Convert a string to a glyph string trying the primary font, fonts in
- // the fallback list and then script-specific last resort font.
- Shaping& shaping = m_shapes[i];
- if (!Shape(&m_input[startItem], itemLength, numGlyphs, m_runs[i],
- shaping))
- continue;
-
- // Compute placements. Note that offsets is documented incorrectly
- // and is actually an array.
-
- // DC that we lazily create if Uniscribe commands us to.
- // (this does not happen often because scriptCache is already
- // updated when calling ScriptShape).
- HDC tempDC = NULL;
- HGDIOBJ oldFont = NULL;
- HRESULT hr;
- while (true) {
- shaping.m_prePadding = 0;
- hr = ScriptPlace(tempDC, shaping.m_scriptCache,
- &shaping.m_glyphs[0],
- static_cast<int>(shaping.m_glyphs.size()),
- &shaping.m_visattr[0], &m_runs[i].a,
- &shaping.m_advance[0], &shaping.m_offsets[0],
- &shaping.m_abc);
- if (hr != E_PENDING)
- break;
-
- // Allocate the DC and run the loop again.
- tempDC = GetDC(NULL);
- oldFont = SelectObject(tempDC, shaping.m_hfont);
- }
-
- if (FAILED(hr)) {
- // Some error we don't know how to handle. Nuke all of our data
- // since we can't deal with partially valid data later.
- m_runs.clear();
- m_shapes.clear();
- m_screenOrder.clear();
- }
-
- if (tempDC) {
- SelectObject(tempDC, oldFont);
- ReleaseDC(NULL, tempDC);
- }
- }
-
- AdjustSpaceAdvances();
-
- if (m_letterSpacing != 0 || m_wordSpacing != 0)
- ApplySpacing();
-}
-
-void UniscribeHelper::FillScreenOrder()
-{
- m_screenOrder.resize(m_runs.size());
-
- // We assume that the input has only one text direction in it.
- // TODO(brettw) are we sure we want to keep this restriction?
- if (m_isRtl) {
- for (int i = 0; i < static_cast<int>(m_screenOrder.size()); i++)
- m_screenOrder[static_cast<int>(m_screenOrder.size()) - i - 1] = i;
- } else {
- for (int i = 0; i < static_cast<int>(m_screenOrder.size()); i++)
- m_screenOrder[i] = i;
- }
-}
-
-void UniscribeHelper::AdjustSpaceAdvances()
-{
- if (m_spaceWidth == 0)
- return;
-
- int spaceWidthWithoutLetterSpacing = m_spaceWidth - m_letterSpacing;
-
- // This mostly matches what WebKit's UniscribeController::shapeAndPlaceItem.
- for (size_t run = 0; run < m_runs.size(); run++) {
- Shaping& shaping = m_shapes[run];
-
- for (int i = 0; i < shaping.charLength(); i++) {
- if (!TreatAsSpace(m_input[m_runs[run].iCharPos + i]))
- continue;
-
- int glyphIndex = shaping.m_logs[i];
- int currentAdvance = shaping.m_advance[glyphIndex];
- // Don't give zero-width spaces a width.
- if (!currentAdvance)
- continue;
-
- // currentAdvance does not include additional letter-spacing, but
- // space_width does. Here we find out how off we are from the
- // correct width for the space not including letter-spacing, then
- // just subtract that diff.
- int diff = currentAdvance - spaceWidthWithoutLetterSpacing;
- // The shaping can consist of a run of text, so only subtract the
- // difference in the width of the glyph.
- shaping.m_advance[glyphIndex] -= diff;
- shaping.m_abc.abcB -= diff;
- }
- }
-}
-
-void UniscribeHelper::ApplySpacing()
-{
- for (size_t run = 0; run < m_runs.size(); run++) {
- Shaping& shaping = m_shapes[run];
- bool isRtl = m_runs[run].a.fRTL;
-
- if (m_letterSpacing != 0) {
- // RTL text gets padded to the left of each character. We increment
- // the run's advance to make this happen. This will be balanced out
- // by NOT adding additional advance to the last glyph in the run.
- if (isRtl)
- shaping.m_prePadding += m_letterSpacing;
-
- // Go through all the glyphs in this run and increase the "advance"
- // to account for letter spacing. We adjust letter spacing only on
- // cluster boundaries.
- //
- // This works for most scripts, but may have problems with some
- // indic scripts. This behavior is better than Firefox or IE for
- // Hebrew.
- for (int i = 0; i < shaping.glyphLength(); i++) {
- if (shaping.m_visattr[i].fClusterStart) {
- // Ick, we need to assign the extra space so that the glyph
- // comes first, then is followed by the space. This is
- // opposite for RTL.
- if (isRtl) {
- if (i != shaping.glyphLength() - 1) {
- // All but the last character just get the spacing
- // applied to their advance. The last character
- // doesn't get anything,
- shaping.m_advance[i] += m_letterSpacing;
- shaping.m_abc.abcB += m_letterSpacing;
- }
- } else {
- // LTR case is easier, we just add to the advance.
- shaping.m_advance[i] += m_letterSpacing;
- shaping.m_abc.abcB += m_letterSpacing;
- }
- }
- }
- }
-
- // Go through all the characters to find whitespace and insert the
- // extra wordspacing amount for the glyphs they correspond to.
- if (m_wordSpacing != 0) {
- for (int i = 0; i < shaping.charLength(); i++) {
- if (!TreatAsSpace(m_input[m_runs[run].iCharPos + i]))
- continue;
-
- // The char in question is a word separator...
- int glyphIndex = shaping.m_logs[i];
-
- // Spaces will not have a glyph in Uniscribe, it will just add
- // additional advance to the character to the left of the
- // space. The space's corresponding glyph will be the character
- // following it in reading order.
- if (isRtl) {
- // In RTL, the glyph to the left of the space is the same
- // as the first glyph of the following character, so we can
- // just increment it.
- shaping.m_advance[glyphIndex] += m_wordSpacing;
- shaping.m_abc.abcB += m_wordSpacing;
- } else {
- // LTR is actually more complex here, we apply it to the
- // previous character if there is one, otherwise we have to
- // apply it to the leading space of the run.
- if (glyphIndex == 0) {
- shaping.m_prePadding += m_wordSpacing;
- } else {
- shaping.m_advance[glyphIndex - 1] += m_wordSpacing;
- shaping.m_abc.abcB += m_wordSpacing;
- }
- }
- }
- } // m_wordSpacing != 0
-
- // Loop for next run...
- }
-}
-
-// The advance is the ABC width of the run
-int UniscribeHelper::AdvanceForItem(int item_index) const
-{
- int accum = 0;
- const Shaping& shaping = m_shapes[item_index];
-
- if (shaping.m_justify.size() == 0) {
- // Easy case with no justification, the width is just the ABC width of
- // the run. (The ABC width is the sum of the advances).
- return shaping.m_abc.abcA + shaping.m_abc.abcB +
- shaping.m_abc.abcC + shaping.m_prePadding;
- }
-
- // With justification, we use the justified amounts instead. The
- // justification array contains both the advance and the extra space
- // added for justification, so is the width we want.
- int justification = 0;
- for (size_t i = 0; i < shaping.m_justify.size(); i++)
- justification += shaping.m_justify[i];
-
- return shaping.m_prePadding + justification;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/UniscribeHelper.h b/webkit/port/platform/graphics/chromium/UniscribeHelper.h
deleted file mode 100644
index 1079e74..0000000
--- a/webkit/port/platform/graphics/chromium/UniscribeHelper.h
+++ /dev/null
@@ -1,404 +0,0 @@
-// Copyright (c) 2006-2008, 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.
-
-// A wrapper around Uniscribe that provides a reasonable API.
-
-#ifndef UniscribeHelper_h
-#define UniscribeHelper_h
-
-#include <windows.h>
-#include <usp10.h>
-#include <map>
-
-#include <unicode/uchar.h>
-#include <wtf/Vector.h>
-
-class UniscribeTest_TooBig_Test; // A gunit test for UniscribeHelper.
-
-namespace WebCore {
-
-#define UNISCRIBE_HELPER_STACK_RUNS 8
-#define UNISCRIBE_HELPER_STACK_CHARS 32
-
-// This object should be safe to create & destroy frequently, as long as the
-// caller preserves the script_cache when possible (this data may be slow to
-// compute).
-//
-// This object is "kind of large" (~1K) because it reserves a lot of space for
-// working with to avoid expensive heap operations. Therefore, not only should
-// you not worry about creating and destroying it, you should try to not keep
-// them around.
-class UniscribeHelper {
-public:
- // Initializes this Uniscribe run with the text pointed to by |run| with
- // |length|. The input is NOT null terminated.
- //
- // The is_rtl flag should be set if the input script is RTL. It is assumed
- // that the caller has already divided up the input text (using ICU, for
- // example) into runs of the same direction of script. This avoids
- // disagreements between the caller and Uniscribe later (see FillItems).
- //
- // A script cache should be provided by the caller that is initialized to
- // NULL. When the caller is done with the cache (it may be stored between
- // runs as long as it is used consistently with the same HFONT), it should
- // call ScriptFreeCache().
- UniscribeHelper(const UChar* input,
- int inputLength,
- bool isRtl,
- HFONT hfont,
- SCRIPT_CACHE* scriptCache,
- SCRIPT_FONTPROPERTIES* fontProperties);
-
- virtual ~UniscribeHelper();
-
- // Sets Uniscribe's directional override flag. False by default.
- bool directionalOverride() const
- {
- return m_directionalOverride;
- }
- void setDirectionalOverride(bool override)
- {
- m_directionalOverride = override;
- }
-
- // Set's Uniscribe's no-ligate override flag. False by default.
- bool inhibitLigate() const
- {
- return m_inhibitLigate;
- }
- void setInhibitLigate(bool inhibit)
- {
- m_inhibitLigate = inhibit;
- }
-
- // Set letter spacing. We will try to insert this much space between
- // graphemes (one or more glyphs perceived as a single unit by ordinary
- // users of a script). Positive values increase letter spacing, negative
- // values decrease it. 0 by default.
- int letterSpacing() const
- {
- return m_letterSpacing;
- }
- void setLetterSpacing(int letterSpacing)
- {
- m_letterSpacing = letterSpacing;
- }
-
- // Set the width of a standard space character. We use this to normalize
- // space widths. Windows will make spaces after Hindi characters larger than
- // other spaces. A space_width of 0 means to use the default space width.
- //
- // Must be set before Init() is called.
- int spaceWidth() const
- {
- return m_spaceWidth;
- }
- void setSpaceWidth(int spaceWidth)
- {
- m_spaceWidth = spaceWidth;
- }
-
- // Set word spacing. We will try to insert this much extra space between
- // each word in the input (beyond whatever whitespace character separates
- // words). Positive values lead to increased letter spacing, negative values
- // decrease it. 0 by default.
- //
- // Must be set before Init() is called.
- int wordSpacing() const
- {
- return m_wordSpacing;
- }
- void setWordSpacing(int wordSpacing)
- {
- m_wordSpacing = wordSpacing;
- }
-
- void setAscent(int ascent)
- {
- m_ascent = ascent;
- }
-
- // You must call this after setting any options but before doing any
- // other calls like asking for widths or drawing.
- void Init()
- {
- InitWithOptionalLengthProtection(true);
- }
-
- // Returns the total width in pixels of the text run.
- int Width() const;
-
- // Call to justify the text, with the amount of space that should be ADDED
- // to get the desired width that the column should be justified to.
- // Normally, spaces are inserted, but for Arabic there will be kashidas
- // (extra strokes) inserted instead.
- //
- // This function MUST be called AFTER Init().
- void Justify(int additionalSpace);
-
- // Computes the given character offset into a pixel offset of the beginning
- // of that character.
- int CharacterToX(int offset) const;
-
- // Converts the given pixel X position into a logical character offset into
- // the run. For positions appearing before the first character, this will
- // return -1.
- int XToCharacter(int x) const;
-
- // Draws the given characters to (x, y) in the given DC. The font will be
- // handled by this function, but the font color and other attributes should
- // be pre-set.
- //
- // The y position is the upper left corner, NOT the baseline.
- void Draw(HDC dc, int x, int y, int from, int to);
-
- // Returns the first glyph assigned to the character at the given offset.
- // This function is used to retrieve glyph information when Uniscribe is
- // being used to generate glyphs for non-complex, non-BMP (above U+FFFF)
- // characters. These characters are not otherwise special and have no
- // complex shaping rules, so we don't otherwise need Uniscribe, except
- // Uniscribe is the only way to get glyphs for non-BMP characters.
- //
- // Returns 0 if there is no glyph for the given character.
- WORD FirstGlyphForCharacter(int charOffset) const;
-
-protected:
- // Backend for init. The flag allows the unit test to specify whether we
- // should fail early for very long strings like normal, or try to pass the
- // long string to Uniscribe. The latter provides a way to force failure of
- // shaping.
- void InitWithOptionalLengthProtection(bool lengthProtection);
-
- // Tries to preload the font when the it is not accessible.
- // This is the default implementation and it does not do anything.
- virtual void TryToPreloadFont(HFONT font) {}
-
-private:
- friend class UniscribeTest_TooBig_Test;
-
- // An array corresponding to each item in runs_ containing information
- // on each of the glyphs that were generated. Like runs_, this is in
- // reading order. However, for rtl text, the characters within each
- // item will be reversed.
- struct Shaping {
- Shaping()
- : m_prePadding(0)
- , m_hfont(NULL)
- , m_scriptCache(NULL)
- , m_ascentOffset(0) {
- m_abc.abcA = 0;
- m_abc.abcB = 0;
- m_abc.abcC = 0;
- }
-
- // Returns the number of glyphs (which will be drawn to the screen)
- // in this run.
- int glyphLength() const
- {
- return static_cast<int>(m_glyphs.size());
- }
-
- // Returns the number of characters (that we started with) in this run.
- int charLength() const
- {
- return static_cast<int>(m_logs.size());
- }
-
- // Returns the advance array that should be used when measuring glyphs.
- // The returned pointer will indicate an array with glyph_length()
- // elements and the advance that should be used for each one. This is
- // either the real advance, or the justified advances if there is one,
- // and is the array we want to use for measurement.
- const int* effectiveAdvances() const
- {
- if (m_advance.size() == 0)
- return 0;
- if (m_justify.size() == 0)
- return &m_advance[0];
- return &m_justify[0];
- }
-
- // This is the advance amount of space that we have added to the
- // beginning of the run. It is like the ABC's |A| advance but one that
- // we create and must handle internally whenever computing with pixel
- // offsets.
- int m_prePadding;
-
- // Glyph indices in the font used to display this item. These indices
- // are in screen order.
- Vector<WORD, UNISCRIBE_HELPER_STACK_CHARS> m_glyphs;
-
- // For each input character, this tells us the first glyph index it
- // generated. This is the only array with size of the input chars.
- //
- // All offsets are from the beginning of this run. Multiple characters
- // can generate one glyph, in which case there will be adjacent
- // duplicates in this list. One character can also generate multiple
- // glyphs, in which case there will be skipped indices in this list.
- Vector<WORD, UNISCRIBE_HELPER_STACK_CHARS> m_logs;
-
- // Flags and such for each glyph.
- Vector<SCRIPT_VISATTR, UNISCRIBE_HELPER_STACK_CHARS> m_visattr;
-
- // Horizontal advances for each glyph listed above, this is basically
- // how wide each glyph is.
- Vector<int, UNISCRIBE_HELPER_STACK_CHARS> m_advance;
-
- // This contains glyph offsets, from the nominal position of a glyph.
- // It is used to adjust the positions of multiple combining characters
- // around/above/below base characters in a context-sensitive manner so
- // that they don't bump against each other and the base character.
- Vector<GOFFSET, UNISCRIBE_HELPER_STACK_CHARS> m_offsets;
-
- // Filled by a call to Justify, this is empty for nonjustified text.
- // If nonempty, this contains the array of justify characters for each
- // character as returned by ScriptJustify.
- //
- // This is the same as the advance array, but with extra space added
- // for some characters. The difference between a glyph's |justify|
- // width and it's |advance| width is the extra space added.
- Vector<int, UNISCRIBE_HELPER_STACK_CHARS> m_justify;
-
- // Sizing information for this run. This treats the entire run as a
- // character with a preceeding advance, width, and ending advance. The
- // B width is the sum of the |advance| array, and the A and C widths
- // are any extra spacing applied to each end.
- //
- // It is unclear from the documentation what this actually means. From
- // experimentation, it seems that the sum of the character advances is
- // always the sum of the ABC values, and I'm not sure what you're
- // supposed to do with the ABC values.
- ABC m_abc;
-
- // Pointers to windows font data used to render this run.
- HFONT m_hfont;
- SCRIPT_CACHE* m_scriptCache;
-
- // Ascent offset between the ascent of the primary font
- // and that of the fallback font. The offset needs to be applied,
- // when drawing a string, to align multiple runs rendered with
- // different fonts.
- int m_ascentOffset;
- };
-
- // Computes the runs_ array from the text run.
- void FillRuns();
-
- // Computes the shapes_ array given an runs_ array already filled in.
- void FillShapes();
-
- // Fills in the screen_order_ array (see below).
- void FillScreenOrder();
-
- // Called to update the glyph positions based on the current spacing
- // options that are set.
- void ApplySpacing();
-
- // Normalizes all advances for spaces to the same width. This keeps windows
- // from making spaces after Hindi characters larger, which is then
- // inconsistent with our meaure of the width since WebKit doesn't include
- // spaces in text-runs sent to uniscribe unless white-space:pre.
- void AdjustSpaceAdvances();
-
- // Returns the total width of a single item.
- int AdvanceForItem(int item_index) const;
-
- // Shapes a run (pointed to by |input|) using |hfont| first.
- // Tries a series of fonts specified retrieved with NextWinFontData
- // and finally a font covering characters in |*input|. A string pointed
- // by |input| comes from ScriptItemize and is supposed to contain
- // characters belonging to a single script aside from characters common to
- // all scripts (e.g. space).
- bool Shape(const UChar* input,
- int item_length,
- int num_glyphs,
- SCRIPT_ITEM& run,
- Shaping& shaping);
-
- // Gets Windows font data for the next best font to try in the list
- // of fonts. When there's no more font available, returns false
- // without touching any of out params. Need to call ResetFontIndex
- // to start scanning of the font list from the beginning.
- virtual bool NextWinFontData(HFONT* hfont,
- SCRIPT_CACHE** script_cache,
- SCRIPT_FONTPROPERTIES** font_properties,
- int* ascent) {
- return false;
- }
-
- // Resets the font index to the first in the list of fonts to try after the
- // primaryFont turns out not to work. With fontIndex reset,
- // NextWinFontData scans fallback fonts from the beginning.
- virtual void ResetFontIndex() {}
-
- // The input data for this run of Uniscribe. See the constructor.
- const UChar* m_input;
- const int m_inputLength;
- const bool m_isRtl;
-
- // Windows font data for the primary font. In a sense, m_logfont and m_style
- // are redundant because m_hfont contains all the information. However,
- // invoking GetObject, everytime we need the height and the style, is rather
- // expensive so that we cache them. Would it be better to add getter and
- // (virtual) setter for the height and the style of the primary font,
- // instead of m_logfont? Then, a derived class ctor can set m_ascent,
- // m_height and m_style if they're known. Getters for them would have to
- // 'infer' their values from m_hfont ONLY when they're not set.
- HFONT m_hfont;
- SCRIPT_CACHE* m_scriptCache;
- SCRIPT_FONTPROPERTIES* m_fontProperties;
- int m_ascent;
- LOGFONT m_logfont;
- int m_style;
-
- // Options, see the getters/setters above.
- bool m_directionalOverride;
- bool m_inhibitLigate;
- int m_letterSpacing;
- int m_spaceWidth;
- int m_wordSpacing;
-
- // Uniscribe breaks the text into Runs. These are one length of text that is
- // in one script and one direction. This array is in reading order.
- Vector<SCRIPT_ITEM, UNISCRIBE_HELPER_STACK_RUNS> m_runs;
-
- Vector<Shaping, UNISCRIBE_HELPER_STACK_RUNS> m_shapes;
-
- // This is a mapping between reading order and screen order for the items.
- // Uniscribe's items array are in reading order. For right-to-left text,
- // or mixed (although WebKit's |TextRun| should really be only one
- // direction), this makes it very difficult to compute character offsets
- // and positions. This list is in screen order from left to right, and
- // gives the index into the |m_runs| and |m_shapes| arrays of each
- // subsequent item.
- Vector<int, UNISCRIBE_HELPER_STACK_RUNS> m_screenOrder;
-};
-
-} // namespace WebCore
-
-#endif // UniscribeHelper_h
diff --git a/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.cpp b/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.cpp
deleted file mode 100644
index 93d23e9..0000000
--- a/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "UniscribeHelperTextRun.h"
-
-#include "ChromiumBridge.h"
-#include "Font.h"
-#include "SimpleFontData.h"
-
-namespace WebCore {
-
-UniscribeHelperTextRun::UniscribeHelperTextRun(const WebCore::TextRun& run,
- const WebCore::Font& font)
- : UniscribeHelper(run.characters(), run.length(), run.rtl(),
- font.primaryFont()->platformData().hfont(),
- font.primaryFont()->platformData().scriptCache(),
- font.primaryFont()->platformData().scriptFontProperties())
- , m_font(&font)
- , m_fontIndex(0)
-{
- setDirectionalOverride(run.directionalOverride());
- setLetterSpacing(font.letterSpacing());
- setSpaceWidth(font.spaceWidth());
- setWordSpacing(font.wordSpacing());
- setAscent(font.primaryFont()->ascent());
-
- Init();
-
- // Padding is the amount to add to make justification happen. This
- // should be done after Init() so all the runs are already measured.
- if (run.padding() > 0)
- Justify(run.padding());
-}
-
-UniscribeHelperTextRun::UniscribeHelperTextRun(
- const wchar_t* input,
- int inputLength,
- bool isRtl,
- HFONT hfont,
- SCRIPT_CACHE* scriptCache,
- SCRIPT_FONTPROPERTIES* fontProperties)
- : UniscribeHelper(input, inputLength, isRtl, hfont,
- scriptCache, fontProperties)
- , m_font(NULL)
- , m_fontIndex(-1)
-{
-}
-
-void UniscribeHelperTextRun::TryToPreloadFont(HFONT font)
-{
- // Ask the browser to get the font metrics for this font.
- // That will preload the font and it should now be accessible
- // from the renderer.
- WebCore::ChromiumBridge::ensureFontLoaded(font);
-}
-
-bool UniscribeHelperTextRun::NextWinFontData(
- HFONT* hfont,
- SCRIPT_CACHE** scriptCache,
- SCRIPT_FONTPROPERTIES** fontProperties,
- int* ascent)
-{
- // This check is necessary because NextWinFontData can be called again
- // after we already ran out of fonts. fontDataAt behaves in a strange
- // manner when the difference between param passed and # of fonts stored in
- // WebKit::Font is larger than one. We can avoid this check by setting
- // font_index_ to # of elements in hfonts_ when we run out of font. In that
- // case, we'd have to go through a couple of more checks before returning
- // false.
- if (m_fontIndex == -1 || !m_font)
- return false;
-
- // If the font data for a fallback font requested is not yet retrieved, add
- // them to our vectors. Note that '>' rather than '>=' is used to test that
- // condition. primaryFont is not stored in hfonts_, and friends so that
- // indices for fontDataAt and our vectors for font data are 1 off from each
- // other. That is, when fully populated, hfonts_ and friends have one font
- // fewer than what's contained in font_.
- if (static_cast<size_t>(++m_fontIndex) > m_hfonts.size()) {
- const WebCore::FontData *fontData = m_font->fontDataAt(m_fontIndex);
- if (!fontData) {
- // Ran out of fonts.
- m_fontIndex = -1;
- return false;
- }
-
- // TODO(ericroman): this won't work for SegmentedFontData
- // http://b/issue?id=1007335
- const WebCore::SimpleFontData* simpleFontData =
- fontData->fontDataForCharacter(' ');
-
- m_hfonts.append(simpleFontData->platformData().hfont());
- m_scriptCaches.append(
- simpleFontData->platformData().scriptCache());
- m_fontProperties.append(
- simpleFontData->platformData().scriptFontProperties());
- m_ascents.append(simpleFontData->ascent());
- }
-
- *hfont = m_hfonts[m_fontIndex - 1];
- *scriptCache = m_scriptCaches[m_fontIndex - 1];
- *fontProperties = m_fontProperties[m_fontIndex - 1];
- *ascent = m_ascents[m_fontIndex - 1];
- return true;
-}
-
-void UniscribeHelperTextRun::ResetFontIndex()
-{
- m_fontIndex = 0;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.h b/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.h
deleted file mode 100644
index 281e6d9..0000000
--- a/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/*
- * Copyright (C) 2006, 2007 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 UniscribeHelperTextRun_h
-#define UniscribeHelperTextRun_h
-
-#include "UniscribeHelper.h"
-
-namespace WebCore {
-
-class Font;
-class TextRun;
-
-// Wrapper around the Uniscribe helper that automatically sets it up with the
-// WebKit types we supply.
-class UniscribeHelperTextRun : public UniscribeHelper {
-public:
- // Regular constructor used for WebCore text run processing.
- UniscribeHelperTextRun(const WebCore::TextRun& run,
- const WebCore::Font& font);
-
- // Constructor with the same interface as the gfx::UniscribeState. Using
- // this constructor will not give you font fallback, but it will provide
- // the ability to load fonts that may not be in the OS cache
- // ("TryToPreloadFont") if the caller does not have a TextRun/Font.
- UniscribeHelperTextRun(const wchar_t* input,
- int inputLength,
- bool isRtl,
- HFONT hfont,
- SCRIPT_CACHE* scriptCache,
- SCRIPT_FONTPROPERTIES* fontProperties);
-
-protected:
- virtual void TryToPreloadFont(HFONT font);
-
-private:
- // This function retrieves the Windows font data (HFONT, etc) for the next
- // WebKit font in the list. If the font data corresponding to font_index_
- // has been obtained before, returns the values stored in our internal
- // vectors (hfonts_, etc). Otherwise, it gets next SimpleFontData from
- // WebKit and adds them to in hfonts_ and friends so that font data can be
- // returned quickly next time they're requested.
- virtual bool NextWinFontData(HFONT* hfont,
- SCRIPT_CACHE** scriptCache,
- SCRIPT_FONTPROPERTIES** fontProperties,
- int* ascent);
- virtual void ResetFontIndex();
-
- // Reference to WebKit::Font that contains all the information about fonts
- // we can use to render this input run of text. It is used in
- // NextWinFontData to retrieve Windows font data for a series of
- // non-primary fonts.
- //
- // This pointer can be NULL for no font fallback handling.
- const Font* m_font;
-
- // It's rare that many fonts are listed in stylesheets.
- // Four would be large enough in most cases.
- const static size_t kNumberOfFonts = 4;
-
- // These vectors are used to store Windows font data for non-primary fonts.
- Vector<HFONT, kNumberOfFonts> m_hfonts;
- Vector<SCRIPT_CACHE*, kNumberOfFonts> m_scriptCaches;
- Vector<SCRIPT_FONTPROPERTIES*, kNumberOfFonts> m_fontProperties;
- Vector<int, kNumberOfFonts> m_ascents;
-
- // Index of the fallback font we're currently using for NextWinFontData.
- int m_fontIndex;
-};
-
-} // namespace WebCore
-
-#endif // UniscribeHelperTextRun_h
diff --git a/webkit/port/platform/graphics/skia/AffineTransformSkia.cpp b/webkit/port/platform/graphics/skia/AffineTransformSkia.cpp
deleted file mode 100644
index 30d87d3..0000000
--- a/webkit/port/platform/graphics/skia/AffineTransformSkia.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-// Copyright (c) 2008, 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 "AffineTransform.h"
-
-#include "FloatRect.h"
-#include "IntRect.h"
-
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-static const double deg2rad = 0.017453292519943295769; // pi/180
-
-AffineTransform::AffineTransform()
-{
- m_transform.reset();
-}
-
-AffineTransform::AffineTransform(double a, double b, double c, double d,
- double e, double f)
-{
- setMatrix(a, b, c, d, e, f);
-}
-
-AffineTransform::AffineTransform(const SkMatrix& matrix) : m_transform(matrix)
-{
-}
-
-void AffineTransform::setMatrix(double a, double b, double c, double d,
- double e, double f)
-{
- m_transform.reset();
-
- m_transform.setScaleX(WebCoreDoubleToSkScalar(a));
- m_transform.setSkewX(WebCoreDoubleToSkScalar(c));
- m_transform.setTranslateX(WebCoreDoubleToSkScalar(e));
-
- m_transform.setScaleY(WebCoreDoubleToSkScalar(d));
- m_transform.setSkewY(WebCoreDoubleToSkScalar(b));
- m_transform.setTranslateY(WebCoreDoubleToSkScalar(f));
-}
-
-void AffineTransform::map(double x, double y, double *x2, double *y2) const
-{
- SkPoint src, dst;
- src.set(WebCoreDoubleToSkScalar(x), WebCoreDoubleToSkScalar(y));
- m_transform.mapPoints(&dst, &src, 1);
-
- *x2 = SkScalarToDouble(dst.fX);
- *y2 = SkScalarToDouble(dst.fY);
-}
-
-IntRect AffineTransform::mapRect(const IntRect& src) const
-{
- SkRect dst;
- m_transform.mapRect(&dst, src);
- return enclosingIntRect(dst);
-}
-
-FloatRect AffineTransform::mapRect(const FloatRect& src) const
-{
- SkRect dst;
- m_transform.mapRect(&dst, src);
- return dst;
-}
-
-bool AffineTransform::isIdentity() const
-{
- return m_transform.isIdentity();
-}
-
-void AffineTransform::reset()
-{
- m_transform.reset();
-}
-
-AffineTransform &AffineTransform::scale(double sx, double sy)
-{
- m_transform.preScale(WebCoreDoubleToSkScalar(sx), WebCoreDoubleToSkScalar(sy), 0, 0);
- return *this;
-}
-
-AffineTransform &AffineTransform::rotate(double d)
-{
- m_transform.preRotate(WebCoreDoubleToSkScalar(d), 0, 0);
- return *this;
-}
-
-AffineTransform &AffineTransform::translate(double tx, double ty)
-{
- m_transform.preTranslate(WebCoreDoubleToSkScalar(tx), WebCoreDoubleToSkScalar(ty));
- return *this;
-}
-
-AffineTransform &AffineTransform::shear(double sx, double sy)
-{
- m_transform.preSkew(WebCoreDoubleToSkScalar(sx), WebCoreDoubleToSkScalar(sy), 0, 0);
- return *this;
-}
-
-double AffineTransform::det() const
-{
- return SkScalarToDouble(m_transform.getScaleX()) * SkScalarToDouble(m_transform.getScaleY()) -
- SkScalarToDouble(m_transform.getSkewY()) * SkScalarToDouble(m_transform.getSkewX());
-}
-
-AffineTransform AffineTransform::inverse() const
-{
- AffineTransform inverse;
- m_transform.invert(&inverse.m_transform);
- return inverse;
-}
-
-AffineTransform::operator SkMatrix() const
-{
- return m_transform;
-}
-
-bool AffineTransform::operator==(const AffineTransform& m2) const
-{
- return m_transform == m2.m_transform;
-}
-
-AffineTransform &AffineTransform::operator*=(const AffineTransform& m2)
-{
- m_transform.setConcat(m2.m_transform, m_transform);
- return *this;
-}
-
-AffineTransform AffineTransform::operator*(const AffineTransform& m2)
-{
- AffineTransform cat;
-
- cat.m_transform.setConcat(m2.m_transform, m_transform);
- return cat;
-}
-
-double AffineTransform::a() const
-{
- return SkScalarToDouble(m_transform.getScaleX());
-}
-void AffineTransform::setA(double a)
-{
- m_transform.setScaleX(WebCoreDoubleToSkScalar(a));
-}
-
-double AffineTransform::b() const
-{
- return SkScalarToDouble(m_transform.getSkewY());
-}
-void AffineTransform::setB(double b)
-{
- m_transform.setSkewY(WebCoreDoubleToSkScalar(b));
-}
-
-double AffineTransform::c() const
-{
- return SkScalarToDouble(m_transform.getSkewX());
-}
-void AffineTransform::setC(double c)
-{
- m_transform.setSkewX(WebCoreDoubleToSkScalar(c));
-}
-
-double AffineTransform::d() const
-{
- return SkScalarToDouble(m_transform.getScaleY());
-}
-void AffineTransform::setD(double d)
-{
- m_transform.setScaleY(WebCoreDoubleToSkScalar(d));
-}
-
-double AffineTransform::e() const
-{
- return SkScalarToDouble(m_transform.getTranslateX());
-}
-void AffineTransform::setE(double e)
-{
- m_transform.setTranslateX(WebCoreDoubleToSkScalar(e));
-}
-
-double AffineTransform::f() const
-{
- return SkScalarToDouble(m_transform.getTranslateY());
-}
-void AffineTransform::setF(double f)
-{
- m_transform.setTranslateY(WebCoreDoubleToSkScalar(f));
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/BitmapImageSingleFrameSkia.h b/webkit/port/platform/graphics/skia/BitmapImageSingleFrameSkia.h
deleted file mode 100644
index 74ac230..0000000
--- a/webkit/port/platform/graphics/skia/BitmapImageSingleFrameSkia.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BitmapImageSingleFrameSkia_h
-#define BitmapImageSingleFrameSkia_h
-
-#include "Image.h"
-#include "NativeImageSkia.h"
-
-namespace WebCore {
-
-// This image class can be used in places which need an Image, but have
-// raw pixel data rather than undecoded image data.
-// The Image is simpler than a BitmapImage, as it does not have image
-// observers, animation, multiple frames, or non-decoded data.
-// Therefore trimming the decoded data (destroyDecodedData()) has no effect.
-//
-// The difficulty with putting this in BitmapImage::create(NativeImagePtr)
-// is that NativeImagePtr = NativeImageSkia, yet callers have SkBitmap.
-class BitmapImageSingleFrameSkia : public Image {
-public:
- // Creates a new Image, by copying the pixel values out of |bitmap|.
- // If creation failed, returns null.
- static PassRefPtr<BitmapImageSingleFrameSkia> create(
- const SkBitmap& bitmap);
-
- virtual bool isBitmapImage() const { return true; }
-
- virtual IntSize size() const
- {
- return IntSize(m_nativeImage.width(), m_nativeImage.height());
- }
-
- // Do nothing, as we only have the one representation of data (decoded).
- virtual void destroyDecodedData(bool destroyAll = true) { }
-
- virtual unsigned decodedSize() const
- {
- return m_nativeImage.decodedSize();
- }
-
- // We only have a single frame.
- virtual NativeImagePtr nativeImageForCurrentFrame()
- {
- return &m_nativeImage;
- }
-
-protected:
- virtual void draw(GraphicsContext* ctxt, const FloatRect& dstRect,
- const FloatRect& srcRect, CompositeOperator compositeOp);
-
-private:
- NativeImageSkia m_nativeImage;
-
- // Use create().
- BitmapImageSingleFrameSkia() { }
-};
-
-} // namespace WebCore
-
-#endif // BitmapImageSingleFrameSkia_h
diff --git a/webkit/port/platform/graphics/skia/ColorSkia.cpp b/webkit/port/platform/graphics/skia/ColorSkia.cpp
deleted file mode 100644
index 383527e..0000000
--- a/webkit/port/platform/graphics/skia/ColorSkia.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "Color.h"
-
-#include "SkColor.h"
-
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-COMPILE_ASSERT(SK_ColorBLACK == Color::black, SkColorAndColorAreLaidOutTheSame);
-
-Color focusRingColor()
-{
- static Color focusRingColor(229, 151, 0, 255);
- return focusRingColor;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/FloatPointSkia.cpp b/webkit/port/platform/graphics/skia/FloatPointSkia.cpp
deleted file mode 100644
index 01c94ef..0000000
--- a/webkit/port/platform/graphics/skia/FloatPointSkia.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "FloatPoint.h"
-
-#include "SkPoint.h"
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-FloatPoint::FloatPoint(const SkPoint& p)
- : m_x(p.fX)
- , m_y(p.fY)
-{
-}
-
-FloatPoint::operator SkPoint() const
-{
- SkPoint p = { WebCoreFloatToSkScalar(m_x), WebCoreFloatToSkScalar(m_y) };
- return p;
-}
-
-} // namespace WebCore
-
diff --git a/webkit/port/platform/graphics/skia/FloatRectSkia.cpp b/webkit/port/platform/graphics/skia/FloatRectSkia.cpp
deleted file mode 100644
index 4676983..0000000
--- a/webkit/port/platform/graphics/skia/FloatRectSkia.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "FloatRect.h"
-
-#include "SkRect.h"
-
-namespace WebCore {
-
-FloatRect::FloatRect(const SkRect& r)
- : m_location(r.fLeft, r.fTop)
- , m_size(r.width(), r.height())
-{
-}
-
-FloatRect::operator SkRect() const
-{
- SkRect rect = { x(), y(), right(), bottom() };
- return rect;
-}
-
-} // namespace WebCore
-
diff --git a/webkit/port/platform/graphics/skia/GdkSkia.cc b/webkit/port/platform/graphics/skia/GdkSkia.cc
deleted file mode 100644
index b4c8ce5..0000000
--- a/webkit/port/platform/graphics/skia/GdkSkia.cc
+++ /dev/null
@@ -1,516 +0,0 @@
-/* Based on GTK code by the Chromium Authors. The original header for that code
- * continues below */
-
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include <stdio.h>
-
-#include <gdk/gdk.h>
-#include <SkCanvas.h>
-#include <SkBitmap.h>
-#include <SkDevice.h>
-
-#include "GdkSkia.h"
-
-static GdkGC *gdk_skia_create_gc (GdkDrawable *drawable,
- GdkGCValues *values,
- GdkGCValuesMask mask);
-static void gdk_skia_draw_rectangle (GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height);
-static void gdk_skia_draw_arc (GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height,
- gint angle1,
- gint angle2);
-static void gdk_skia_draw_polygon (GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- GdkPoint *points,
- gint npoints);
-static void gdk_skia_draw_text (GdkDrawable *drawable,
- GdkFont *font,
- GdkGC *gc,
- gint x,
- gint y,
- const gchar *text,
- gint text_length);
-static void gdk_skia_draw_text_wc (GdkDrawable *drawable,
- GdkFont *font,
- GdkGC *gc,
- gint x,
- gint y,
- const GdkWChar *text,
- gint text_length);
-static void gdk_skia_draw_drawable (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixmap *src,
- gint xsrc,
- gint ysrc,
- gint xdest,
- gint ydest,
- gint width,
- gint height);
-static void gdk_skia_draw_points (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPoint *points,
- gint npoints);
-static void gdk_skia_draw_segments (GdkDrawable *drawable,
- GdkGC *gc,
- GdkSegment *segs,
- gint nsegs);
-static void gdk_skia_draw_lines (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPoint *points,
- gint npoints);
-
-static void gdk_skia_draw_glyphs (GdkDrawable *drawable,
- GdkGC *gc,
- PangoFont *font,
- gint x,
- gint y,
- PangoGlyphString *glyphs);
-static void gdk_skia_draw_glyphs_transformed (GdkDrawable *drawable,
- GdkGC *gc,
- PangoMatrix *matrix,
- PangoFont *font,
- gint x,
- gint y,
- PangoGlyphString *glyphs);
-
-static void gdk_skia_draw_image (GdkDrawable *drawable,
- GdkGC *gc,
- GdkImage *image,
- gint xsrc,
- gint ysrc,
- gint xdest,
- gint ydest,
- gint width,
- gint height);
-static void gdk_skia_draw_pixbuf (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixbuf *pixbuf,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height,
- GdkRgbDither dither,
- gint x_dither,
- gint y_dither);
-static void gdk_skia_draw_trapezoids (GdkDrawable *drawable,
- GdkGC *gc,
- GdkTrapezoid *trapezoids,
- gint n_trapezoids);
-
-static void gdk_skia_real_get_size (GdkDrawable *drawable,
- gint *width,
- gint *height);
-
-static GdkImage* gdk_skia_copy_to_image (GdkDrawable *drawable,
- GdkImage *image,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height);
-
-static cairo_surface_t *gdk_skia_ref_cairo_surface (GdkDrawable *drawable);
-
-static GdkVisual* gdk_skia_real_get_visual (GdkDrawable *drawable);
-static gint gdk_skia_real_get_depth (GdkDrawable *drawable);
-static void gdk_skia_real_set_colormap (GdkDrawable *drawable,
- GdkColormap *cmap);
-static GdkColormap* gdk_skia_real_get_colormap (GdkDrawable *drawable);
-static GdkScreen* gdk_skia_real_get_screen (GdkDrawable *drawable);
-static void gdk_skia_init (GdkSkiaObject *skia);
-static void gdk_skia_class_init (GdkSkiaObjectClass *klass);
-static void gdk_skia_finalize (GObject *object);
-
-static gpointer parent_class = NULL;
-
-// -----------------------------------------------------------------------------
-// Usually GDK code is C code. However, since we are interfacing to a C++
-// library, we must compile in C++ mode to parse its headers etc. Thankfully,
-// these are the only non-static symbol in the file so we can just wrap them in
-// an extern decl to disable name mangling and everything should be happy.
-// -----------------------------------------------------------------------------
-extern "C" {
-GType
-gdk_skia_get_type (void)
-{
- static GType object_type = 0;
-
- if (!object_type)
- object_type = g_type_register_static_simple (GDK_TYPE_DRAWABLE,
- "GdkSkia",
- sizeof (GdkSkiaObjectClass),
- (GClassInitFunc) gdk_skia_class_init,
- sizeof (GdkSkiaObject),
- (GInstanceInitFunc) gdk_skia_init,
- (GTypeFlags) 0);
-
- return object_type;
-}
-
-GdkSkia*
-gdk_skia_new(SkCanvas *canvas)
-{
- GdkSkia *skia = GDK_SKIA(g_object_new (GDK_TYPE_SKIA, NULL));
- reinterpret_cast<GdkSkiaObject*>(skia)->canvas = canvas;
- return skia;
-}
-
-} // extern "C"
-
-static void
-gdk_skia_init (GdkSkiaObject *skia)
-{
- /* 0 initialization is fine for us */
-}
-
-static void
-gdk_skia_class_init (GdkSkiaObjectClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = gdk_skia_finalize;
-
- drawable_class->create_gc = gdk_skia_create_gc;
- drawable_class->draw_rectangle = gdk_skia_draw_rectangle;
- drawable_class->draw_arc = gdk_skia_draw_arc;
- drawable_class->draw_polygon = gdk_skia_draw_polygon;
- drawable_class->draw_text = gdk_skia_draw_text;
- drawable_class->draw_text_wc = gdk_skia_draw_text_wc;
- drawable_class->draw_drawable = gdk_skia_draw_drawable;
- drawable_class->draw_points = gdk_skia_draw_points;
- drawable_class->draw_segments = gdk_skia_draw_segments;
- drawable_class->draw_lines = gdk_skia_draw_lines;
- drawable_class->draw_glyphs = gdk_skia_draw_glyphs;
- drawable_class->draw_glyphs_transformed = gdk_skia_draw_glyphs_transformed;
- drawable_class->draw_image = gdk_skia_draw_image;
- drawable_class->draw_pixbuf = gdk_skia_draw_pixbuf;
- drawable_class->draw_trapezoids = gdk_skia_draw_trapezoids;
- drawable_class->get_depth = gdk_skia_real_get_depth;
- drawable_class->get_screen = gdk_skia_real_get_screen;
- drawable_class->get_size = gdk_skia_real_get_size;
- drawable_class->set_colormap = gdk_skia_real_set_colormap;
- drawable_class->get_colormap = gdk_skia_real_get_colormap;
- drawable_class->get_visual = gdk_skia_real_get_visual;
- drawable_class->_copy_to_image = gdk_skia_copy_to_image;
- drawable_class->ref_cairo_surface = gdk_skia_ref_cairo_surface;
-}
-
-static void
-gdk_skia_finalize (GObject *object)
-{
- GdkSkiaObject *const skia = (GdkSkiaObject *) object;
- if (skia->surface)
- cairo_surface_destroy(skia->surface);
- G_OBJECT_CLASS (parent_class)->finalize(object);
-}
-
-#define NOTIMPLEMENTED fprintf(stderr, "GDK Skia not implemented: %s\n", __PRETTY_FUNCTION__)
-
-static GdkGC *
-gdk_skia_create_gc(GdkDrawable *drawable,
- GdkGCValues *values,
- GdkGCValuesMask mask) {
- NOTIMPLEMENTED;
- return NULL;
-}
-
-static void
-gc_set_paint(GdkGC *gc, SkPaint *paint) {
- GdkGCValues values;
- gdk_gc_get_values(gc, &values);
-
- paint->setARGB(255,
- values.foreground.pixel >> 16,
- values.foreground.pixel >> 8,
- values.foreground.pixel);
- paint->setStrokeWidth(values.line_width);
-}
-
-static void
-gdk_skia_draw_rectangle(GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height) {
- GdkSkiaObject *skia = (GdkSkiaObject *) drawable;
- SkPaint paint;
- gc_set_paint(gc, &paint);
-
- if (filled) {
- paint.setStyle(SkPaint::kFill_Style);
- } else {
- paint.setStyle(SkPaint::kStroke_Style);
- }
-
- SkRect rect;
- rect.set(x, y, x + width, y + height);
-
- skia->canvas->drawRect(rect, paint);
-}
-
-static void
-gdk_skia_draw_arc(GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height,
- gint angle1,
- gint angle2) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_polygon(GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- GdkPoint *points,
- gint npoints) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_text(GdkDrawable *drawable,
- GdkFont *font,
- GdkGC *gc,
- gint x,
- gint y,
- const gchar *text,
- gint text_length) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_text_wc(GdkDrawable *drawable,
- GdkFont *font,
- GdkGC *gc,
- gint x,
- gint y,
- const GdkWChar *text,
- gint text_length) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_drawable(GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixmap *src,
- gint xsrc,
- gint ysrc,
- gint xdest,
- gint ydest,
- gint width,
- gint height) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_points(GdkDrawable *drawable,
- GdkGC *gc,
- GdkPoint *points,
- gint npoints) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_segments(GdkDrawable *drawable,
- GdkGC *gc,
- GdkSegment *segs,
- gint nsegs) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_lines(GdkDrawable *drawable,
- GdkGC *gc,
- GdkPoint *points,
- gint npoints) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_glyphs(GdkDrawable *drawable,
- GdkGC *gc,
- PangoFont *font,
- gint x,
- gint y,
- PangoGlyphString *glyphs) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_glyphs_transformed(GdkDrawable *drawable,
- GdkGC *gc,
- PangoMatrix *matrix,
- PangoFont *font,
- gint x,
- gint y,
- PangoGlyphString *glyphs) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_image(GdkDrawable *drawable,
- GdkGC *gc,
- GdkImage *image,
- gint xsrc,
- gint ysrc,
- gint xdest,
- gint ydest,
- gint width,
- gint height) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_pixbuf(GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixbuf *pixbuf,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height,
- GdkRgbDither dither,
- gint x_dither,
- gint y_dither) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_draw_trapezoids(GdkDrawable *drawable,
- GdkGC *gc,
- GdkTrapezoid *trapezoids,
- gint n_trapezoids) {
- NOTIMPLEMENTED;
-}
-
-static void
-gdk_skia_real_get_size(GdkDrawable *drawable,
- gint *width,
- gint *height) {
- GdkSkiaObject *const skia = (GdkSkiaObject *) drawable;
- SkDevice *const dev = skia->canvas->getDevice();
- *width = dev->width();
- *height = dev->height();
-}
-
-static GdkImage*
-gdk_skia_copy_to_image(GdkDrawable *drawable,
- GdkImage *image,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height) {
- NOTIMPLEMENTED;
- return NULL;
-}
-
-static cairo_surface_t *
-gdk_skia_ref_cairo_surface(GdkDrawable *drawable) {
- GdkSkiaObject *const skia = (GdkSkiaObject *) drawable;
-
- if (!skia->surface) {
- SkDevice *const dev = skia->canvas->getDevice();
- const SkBitmap *const bm = &dev->accessBitmap(true);
-
- skia->surface = cairo_image_surface_create_for_data
- ((unsigned char *) bm->getPixels(),
- CAIRO_FORMAT_ARGB32, dev->width(), dev->height(), bm->rowBytes());
- }
-
- SkMatrix matrix = skia->canvas->getTotalMatrix();
- int x_shift = SkScalarRound(matrix.getTranslateX());
- int y_shift = SkScalarRound(matrix.getTranslateY());
- cairo_surface_set_device_offset(skia->surface, x_shift, y_shift);
-
- return cairo_surface_reference(skia->surface);
-}
-
-static GdkVisual*
-gdk_skia_real_get_visual(GdkDrawable *drawable) {
- NOTIMPLEMENTED;
- return NULL;
-}
-
-static gint
-gdk_skia_real_get_depth(GdkDrawable *drawable) {
- GdkSkiaObject *skia = (GdkSkiaObject *) drawable;
- const SkBitmap::Config config = skia->canvas->getDevice()->config();
-
- switch (config) {
- case SkBitmap::kARGB_8888_Config:
- return 24;
- default:
- // NOTREACHED
- *reinterpret_cast<char*>(NULL) = 0;
- return 0;
- }
-}
-
-static void
-gdk_skia_real_set_colormap(GdkDrawable *drawable,
- GdkColormap *cmap) {
- NOTIMPLEMENTED;
-}
-
-static GdkColormap*
-gdk_skia_real_get_colormap(GdkDrawable *drawable) {
- NOTIMPLEMENTED;
- return NULL;
-}
-
-static GdkScreen*
-gdk_skia_real_get_screen(GdkDrawable *drawable) {
- NOTIMPLEMENTED;
- return NULL;
-}
diff --git a/webkit/port/platform/graphics/skia/GdkSkia.h b/webkit/port/platform/graphics/skia/GdkSkia.h
deleted file mode 100644
index 6e6b76a..0000000
--- a/webkit/port/platform/graphics/skia/GdkSkia.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Based on GTK code by the Chromium Authors. The original header for that code
- * continues below */
-
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GDK_SKIA_H__
-#define __GDK_SKIA_H__
-
-#include <gdk/gdk.h>
-#include <cairo/cairo.h>
-
-class SkCanvas;
-
-G_BEGIN_DECLS
-
-typedef struct _GdkSkiaObject GdkSkiaObject;
-typedef struct _GdkSkiaObjectClass GdkSkiaObjectClass;
-
-typedef struct _GdkDrawable GdkSkia;
-
-#define GDK_TYPE_SKIA (gdk_skia_get_type ())
-#define GDK_SKIA(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SKIA, GdkSkia))
-#define GDK_SKIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SKIA, GdkSkiaObjectClass))
-#define GDK_IS_SKIA(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SKIA))
-#define GDK_IS_SKIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_SKIA))
-#define GDK_SKIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SKIA, GdkSkiaObjectClass))
-#define GDK_SKIA_OBJECT(object) ((GdkSkiaObject *) GDK_SKIA (object))
-
-struct _GdkSkiaObject
-{
- GdkDrawable parent_instance;
- SkCanvas *canvas;
- cairo_surface_t *surface;
-};
-
-struct _GdkSkiaObjectClass
-{
- GdkDrawableClass parent_class;
-};
-
-GType gdk_skia_get_type();
-
-// -----------------------------------------------------------------------------
-// Return a new GdkSkia for the given canvas.
-// -----------------------------------------------------------------------------
-GdkSkia* gdk_skia_new(SkCanvas* canvas);
-
-G_END_DECLS
-
-#endif /* __GDK_SKIA_H__ */
diff --git a/webkit/port/platform/graphics/skia/GradientSkia.cpp b/webkit/port/platform/graphics/skia/GradientSkia.cpp
deleted file mode 100644
index 1c33164..0000000
--- a/webkit/port/platform/graphics/skia/GradientSkia.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "Gradient.h"
-
-#include "CSSParser.h"
-#include "GraphicsContext.h"
-
-#include "SkGradientShader.h"
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- if (m_gradient)
- m_gradient->safeUnref();
- m_gradient = 0;
-}
-
-static inline U8CPU F2B(float x)
-{
- return static_cast<int>(x * 255);
-}
-
-static SkColor makeSkColor(float a, float r, float g, float b)
-{
- return SkColorSetARGB(F2B(a), F2B(r), F2B(g), F2B(b));
-}
-
-// Determine the total number of stops needed, including pseudo-stops at the
-// ends as necessary.
-static size_t total_stops_needed(const Gradient::ColorStop* stopData, size_t count)
-{
- const Gradient::ColorStop* stop = stopData;
- size_t count_used = count;
- if (count < 1 || stop->stop > 0.0)
- count_used++;
- stop += count - 1;
- if (count < 2 || stop->stop < 1.0)
- count_used++;
- return count_used;
-}
-
-// Collect sorted stop position and color information into the pos and colors
-// buffers, ensuring stops at both 0.0 and 1.0. The buffers must be large
-// enough to hold information for all stops, including the new endpoints if
-// stops at 0.0 and 1.0 aren't already included.
-static void fill_stops(const Gradient::ColorStop* stopData,
- size_t count, SkScalar* pos, SkColor* colors)
-{
- const Gradient::ColorStop* stop = stopData;
- size_t start = 0;
- if (count < 1) {
- // A gradient with no stops must be transparent black.
- pos[0] = WebCoreFloatToSkScalar(0.0);
- colors[0] = makeSkColor(0.0, 0.0, 0.0, 0.0);
- start = 1;
- } else if (stop->stop > 0.0) {
- // Copy the first stop to 0.0. The first stop position may have a slight
- // rounding error, but we don't care in this float comparison, since
- // 0.0 comes through cleanly and people aren't likely to want a gradient
- // with a stop at (0 + epsilon).
- pos[0] = WebCoreFloatToSkScalar(0.0);
- colors[0] = makeSkColor(stop->alpha, stop->red, stop->green, stop->blue);
- start = 1;
- }
-
- for (size_t i = start; i < start + count; i++) {
- pos[i] = WebCoreFloatToSkScalar(stop->stop);
- colors[i] = makeSkColor(stop->alpha, stop->red, stop->green, stop->blue);
- ++stop;
- }
-
- // Copy the last stop to 1.0 if needed. See comment above about this float
- // comparison.
- if (count < 1 || (--stop)->stop < 1.0) {
- pos[start + count] = WebCoreFloatToSkScalar(1.0);
- colors[start + count] = colors[start + count - 1];
- }
-}
-
-static inline bool compareStops(const Gradient::ColorStop& a, const Gradient::ColorStop& b)
-{
- return a.stop < b.stop;
-}
-
-SkShader* Gradient::platformGradient()
-{
- if (m_gradient)
- return m_gradient;
-
- // TODO: This and compareStops() are also in Gradient.cpp and
- // CSSGradientValue.cpp; probably should refactor in WebKit.
- if (!m_stopsSorted) {
- if (m_stops.size())
- std::stable_sort(m_stops.begin(), m_stops.end(), compareStops);
- m_stopsSorted = true;
- }
- size_t count_used = total_stops_needed(m_stops.data(), m_stops.size());
- ASSERT(count_used >= 2);
- ASSERT(count_used >= m_stops.size());
-
- // FIXME: Why is all this manual pointer math needed?!
- SkAutoMalloc storage(count_used * (sizeof(SkColor) + sizeof(SkScalar)));
- SkColor* colors = (SkColor*)storage.get();
- SkScalar* pos = (SkScalar*)(colors + count_used);
-
- fill_stops(m_stops.data(), m_stops.size(), pos, colors);
-
- if (m_radial) {
- // TODO(mmoss) CSS radial Gradients allow an offset focal point (the
- // "start circle"), but skia doesn't seem to support that, so this just
- // ignores m_p0/m_r0 and draws the gradient centered in the "end
- // circle" (m_p1/m_r1).
- // See http://webkit.org/blog/175/introducing-css-gradients/ for a
- // description of the expected behavior.
- m_gradient = SkGradientShader::CreateRadial(m_p1,
- WebCoreFloatToSkScalar(m_r1), colors, pos,
- static_cast<int>(count_used), SkShader::kClamp_TileMode);
- } else {
- SkPoint pts[2] = { m_p0, m_p1 };
- m_gradient = SkGradientShader::CreateLinear(pts, colors, pos,
- static_cast<int>(count_used), SkShader::kClamp_TileMode);
- }
-
- return m_gradient;
-}
-
-void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
-{
- context->setFillGradient(this);
- context->fillRect(rect);
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/GraphicsContextPlatformPrivate.h b/webkit/port/platform/graphics/skia/GraphicsContextPlatformPrivate.h
deleted file mode 100644
index fdd37b9..0000000
--- a/webkit/port/platform/graphics/skia/GraphicsContextPlatformPrivate.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2006 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 GraphicsContextPlatformPrivate_h
-#define GraphicsContextPlatformPrivate_h
-
-class PlatformContextSkia;
-
-namespace WebCore {
-
-// This class just holds onto a PlatformContextSkia for GraphicsContext.
-class GraphicsContextPlatformPrivate {
-public:
- GraphicsContextPlatformPrivate(PlatformContextSkia* platformContext)
- : m_context(platformContext) { }
-
- PlatformContextSkia* context() { return m_context; }
-
-private:
- // Non-owning pointer to the PlatformContext.
- PlatformContextSkia* m_context;
-
- // We don't support copy or assign.
- GraphicsContextPlatformPrivate(const GraphicsContextPlatformPrivate& other);
- GraphicsContextPlatformPrivate& operator=(
- const GraphicsContextPlatformPrivate& other);
-};
-
-} // namespace WebCore
-
-#endif // GraphicsContextPlatformPrivate_h
diff --git a/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp b/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp
deleted file mode 100644
index 6237990..0000000
--- a/webkit/port/platform/graphics/skia/GraphicsContextSkia.cpp
+++ /dev/null
@@ -1,1109 +0,0 @@
-/*
-** Copyright 2006, Google Inc.
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-#include "config.h"
-#include <math.h>
-
-#include "GraphicsContext.h"
-#include "GraphicsContextPlatformPrivate.h"
-#include "GraphicsContextPrivate.h"
-
-#include "Assertions.h"
-#include "AffineTransform.h"
-#include "Color.h"
-#include "FloatRect.h"
-#include "Gradient.h"
-#include "IntRect.h"
-#include "NativeImageSkia.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "SkBitmap.h"
-#include "SkBlurDrawLooper.h"
-#include "SkCornerPathEffect.h"
-#include "skia/ext/platform_canvas.h"
-#include "SkiaUtils.h"
-#include "SkShader.h"
-#include "wtf/MathExtras.h"
-
-using namespace std;
-
-namespace WebCore {
-
-namespace {
-
-// "Reasonable" functions ------------------------------------------------------
-//
-// These functions check certain graphics primitives for being "reasonable".
-// We don't like to send crazy data to the graphics layer that might overflow,
-// and this helps us avoid some of those cases.
-//
-// THESE ARE NOT PERFECT. We can't guarantee what the graphics layer is doing.
-// Ideally, all of these would be fixed in the graphics layer and we would not
-// have to do any checking. You can uncomment the CHECK_REASONABLE flag to
-// check the graphics layer.
-#define CHECK_REASONABLE
-
-static bool IsCoordinateReasonable(float coord)
-{
-#ifdef CHECK_REASONABLE
- // First check for valid floats.
-#if defined(_MSC_VER)
- if (!_finite(coord))
-#else
- if (!finite(coord))
-#endif
- return false;
-
- // Skia uses 16.16 fixed point and 26.6 fixed point in various places. If
- // the transformed point exceeds 15 bits, we just declare that it's
- // unreasonable to catch both of these cases.
- static const int maxPointMagnitude = 32767;
- if (coord > maxPointMagnitude || coord < -maxPointMagnitude)
- return false;
-
- return true;
-#else
- return true;
-#endif
-}
-
-static bool IsPointReasonable(const SkMatrix& transform, const SkPoint& pt)
-{
-#ifdef CHECK_REASONABLE
- // Now check for points that will overflow. We check the *transformed*
- // points since this is what will be rasterized.
- SkPoint xPt;
- transform.mapPoints(&xPt, &pt, 1);
- return IsCoordinateReasonable(xPt.fX) && IsCoordinateReasonable(xPt.fY);
-#else
- return true;
-#endif
-}
-
-static bool IsRectReasonable(const SkMatrix& transform, const SkRect& rc)
-{
-#ifdef CHECK_REASONABLE
- SkPoint topleft = {rc.fLeft, rc.fTop};
- SkPoint bottomright = {rc.fRight, rc.fBottom};
- return IsPointReasonable(transform, topleft) &&
- IsPointReasonable(transform, bottomright);
-#else
- return true;
-#endif
-}
-
-bool IsPathReasonable(const SkMatrix& transform, const SkPath& path)
-{
-#ifdef CHECK_REASONABLE
- SkPoint current_points[4];
- SkPath::Iter iter(path, false);
- for (SkPath::Verb verb = iter.next(current_points);
- verb != SkPath::kDone_Verb;
- verb = iter.next(current_points)) {
- switch (verb) {
- case SkPath::kMove_Verb:
- // This move will be duplicated in the next verb, so we can ignore.
- break;
- case SkPath::kLine_Verb:
- // iter.next returns 2 points.
- if (!IsPointReasonable(transform, current_points[0]) ||
- !IsPointReasonable(transform, current_points[1]))
- return false;
- break;
- case SkPath::kQuad_Verb:
- // iter.next returns 3 points.
- if (!IsPointReasonable(transform, current_points[0]) ||
- !IsPointReasonable(transform, current_points[1]) ||
- !IsPointReasonable(transform, current_points[2]))
- return false;
- break;
- case SkPath::kCubic_Verb:
- // iter.next returns 4 points.
- if (!IsPointReasonable(transform, current_points[0]) ||
- !IsPointReasonable(transform, current_points[1]) ||
- !IsPointReasonable(transform, current_points[2]) ||
- !IsPointReasonable(transform, current_points[3]))
- return false;
- break;
- case SkPath::kClose_Verb:
- case SkPath::kDone_Verb:
- default:
- break;
- }
- }
- return true;
-#else
- return true;
-#endif
-}
-
-// Local helper functions ------------------------------------------------------
-
-void addCornerArc(SkPath* path,
- const SkRect& rect,
- const IntSize& size,
- int startAngle)
-{
- SkIRect ir;
- int rx = SkMin32(SkScalarRound(rect.width()), size.width());
- int ry = SkMin32(SkScalarRound(rect.height()), size.height());
-
- ir.set(-rx, -ry, rx, ry);
- switch (startAngle) {
- case 0:
- ir.offset(rect.fRight - ir.fRight, rect.fBottom - ir.fBottom);
- break;
- case 90:
- ir.offset(rect.fLeft - ir.fLeft, rect.fBottom - ir.fBottom);
- break;
- case 180:
- ir.offset(rect.fLeft - ir.fLeft, rect.fTop - ir.fTop);
- break;
- case 270:
- ir.offset(rect.fRight - ir.fRight, rect.fTop - ir.fTop);
- break;
- default:
- ASSERT(0);
- }
-
- SkRect r;
- r.set(ir);
- path->arcTo(r, SkIntToScalar(startAngle), SkIntToScalar(90), false);
-}
-
-inline int fastMod(int value, int max)
-{
- int sign = SkExtractSign(value);
-
- value = SkApplySign(value, sign);
- if (value >= max)
- value %= max;
- return SkApplySign(value, sign);
-}
-
-inline float square(float n)
-{
- return n * n;
-}
-
-} // namespace
-
-// -----------------------------------------------------------------------------
-
-// This may be called with a NULL pointer to create a graphics context that has
-// no painting.
-GraphicsContext::GraphicsContext(PlatformGraphicsContext *gc)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(gc))
-{
- setPaintingDisabled(!gc || !platformContext()->canvas());
-}
-
-GraphicsContext::~GraphicsContext()
-{
- delete m_data;
- this->destroyGraphicsContextPrivate(m_common);
-}
-
-PlatformGraphicsContext* GraphicsContext::platformContext() const
-{
- ASSERT(!paintingDisabled());
- return m_data->context();
-}
-
-// State saving ----------------------------------------------------------------
-
-void GraphicsContext::savePlatformState()
-{
- if (paintingDisabled())
- return;
-
- // Save our private State.
- platformContext()->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- if (paintingDisabled())
- return;
-
- // Restore our private State.
- platformContext()->restore();
-}
-
-void GraphicsContext::beginTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
-
- // We need the "alpha" layer flag here because the base layer is opaque
- // (the surface of the page) but layers on top may have transparent parts.
- // Without explicitly setting the alpha flag, the layer will inherit the
- // opaque setting of the base and some things won't work properly.
- platformContext()->canvas()->saveLayerAlpha(
- 0,
- static_cast<unsigned char>(opacity * 255),
- static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag |
- SkCanvas::kFullColorLayer_SaveFlag));
-}
-
-void GraphicsContext::endTransparencyLayer()
-{
- if (paintingDisabled())
- return;
-
-#if PLATFORM(WIN_OS)
- platformContext()->canvas()->getTopPlatformDevice().
- fixupAlphaBeforeCompositing();
-#endif
- platformContext()->canvas()->restore();
-}
-
-// Graphics primitives ---------------------------------------------------------
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
- SkRect r(rect);
- if (!IsRectReasonable(getCTM(), r))
- return;
-
- SkPath path;
- path.addOval(r, SkPath::kCW_Direction);
- // only perform the inset if we won't invert r
- if (2 * thickness < rect.width() && 2 * thickness < rect.height()) {
- r.inset(SkIntToScalar(thickness) ,SkIntToScalar(thickness));
- path.addOval(r, SkPath::kCCW_Direction);
- }
- platformContext()->canvas()->clipPath(path);
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- if (paintingDisabled())
- return;
- platformContext()->addPath(*path.platformPath());
-}
-
-void GraphicsContext::beginPath()
-{
- if (paintingDisabled())
- return;
- platformContext()->beginPath();
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- if (paintingDisabled())
- return;
- platformContext()->setDrawLooper(0);
-}
-
-void GraphicsContext::clearRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r = rect;
- if (!IsRectReasonable(getCTM(), r))
- ClipRectToCanvas(*platformContext()->canvas(), r, &r);
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- paint.setPorterDuffXfermode(SkPorterDuff::kClear_Mode);
- platformContext()->canvas()->drawRect(r, paint);
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r(rect);
- if (!IsRectReasonable(getCTM(), r))
- return;
-
- platformContext()->canvas()->clipRect(r);
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- const SkPath& p = *path.platformPath();
- if (!IsPathReasonable(getCTM(), p))
- return;
-
- platformContext()->canvas()->clipPath(p);
-}
-
-void GraphicsContext::clipOut(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r(rect);
- if (!IsRectReasonable(getCTM(), r))
- return;
-
- platformContext()->canvas()->clipRect(r, SkRegion::kDifference_Op);
-}
-
-void GraphicsContext::clipOut(const Path& p)
-{
- if (paintingDisabled())
- return;
-
- const SkPath& path = *p.platformPath();
- if (!IsPathReasonable(getCTM(), path))
- return;
-
- platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op);
-}
-
-void GraphicsContext::clipOutEllipseInRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect oval(rect);
- if (!IsRectReasonable(getCTM(), oval))
- return;
-
- SkPath path;
- path.addOval(oval, SkPath::kCCW_Direction);
- platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op);
-}
-
-void GraphicsContext::clipPath(WindRule clipRule)
-{
- if (paintingDisabled())
- return;
-
- const SkPath* oldPath = platformContext()->currentPath();
- SkPath path(*oldPath);
- path.setFillType(clipRule == RULE_EVENODD ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
- platformContext()->canvas()->clipPath(path);
-}
-
-void GraphicsContext::clipToImageBuffer(const FloatRect& rect,
- const ImageBuffer* imageBuffer)
-{
- if (paintingDisabled())
- return;
-
- // TODO(eseidel): This is needed for image masking and complex text fills.
- notImplemented();
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& xform)
-{
- if (paintingDisabled())
- return;
- platformContext()->canvas()->concat(xform);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t numPoints,
- const FloatPoint* points,
- bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- if (numPoints <= 1)
- return;
-
- SkPath path;
-
- path.incReserve(numPoints);
- path.moveTo(WebCoreFloatToSkScalar(points[0].x()),
- WebCoreFloatToSkScalar(points[0].y()));
- for (size_t i = 1; i < numPoints; i++) {
- path.lineTo(WebCoreFloatToSkScalar(points[i].x()),
- WebCoreFloatToSkScalar(points[i].y()));
- }
-
- if (!IsPathReasonable(getCTM(), path))
- return;
-
- SkPaint paint;
- if (fillColor().rgb() & 0xFF000000) {
- platformContext()->setupPaintForFilling(&paint);
- platformContext()->canvas()->drawPath(path, paint);
- }
-
- if (strokeStyle() != NoStroke) {
- paint.reset();
- platformContext()->setupPaintForStroking(&paint, 0, 0);
- platformContext()->canvas()->drawPath(path, paint);
- }
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& elipseRect)
-{
- if (paintingDisabled())
- return;
-
- SkRect rect = elipseRect;
- if (!IsRectReasonable(getCTM(), rect))
- return;
-
- SkPaint paint;
- if (fillColor().rgb() & 0xFF000000) {
- platformContext()->setupPaintForFilling(&paint);
- platformContext()->canvas()->drawOval(rect, paint);
- }
- if (strokeStyle() != NoStroke) {
- paint.reset();
- platformContext()->setupPaintForStroking(&paint, &rect, 0);
- platformContext()->canvas()->drawOval(rect, paint);
- }
-}
-
-void GraphicsContext::drawFocusRing(const Color& color)
-{
- if (paintingDisabled())
- return;
- const Vector<IntRect>& rects = focusRingRects();
- unsigned rectCount = rects.size();
- if (0 == rectCount)
- return;
-
- SkRegion exterior_region;
- const SkScalar exterior_offset = WebCoreFloatToSkScalar(0.5);
- for (unsigned i = 0; i < rectCount; i++) {
- SkIRect r = rects[i];
- r.inset(-exterior_offset, -exterior_offset);
- exterior_region.op(r, SkRegion::kUnion_Op);
- }
-
- SkPath path;
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
-
- paint.setColor(focusRingColor().rgb());
- paint.setStrokeWidth(exterior_offset * 2);
- paint.setPathEffect(new SkCornerPathEffect(exterior_offset * 2))->unref();
- exterior_region.getBoundaryPath(&path);
- platformContext()->canvas()->drawPath(path, paint);
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- StrokeStyle penStyle = strokeStyle();
- if (penStyle == NoStroke)
- return;
-
- SkPaint paint;
- SkPoint pts[2] = { (SkPoint)point1, (SkPoint)point2 };
- if (!IsPointReasonable(getCTM(), pts[0]) ||
- !IsPointReasonable(getCTM(), pts[1]))
- return;
-
- // We know these are vertical or horizontal lines, so the length will just
- // be the sum of the displacement component vectors give or take 1 -
- // probably worth the speed up of no square root, which also won't be exact.
- SkPoint disp = pts[1] - pts[0];
- int length = SkScalarRound(disp.fX + disp.fY);
- int width = roundf(
- platformContext()->setupPaintForStroking(&paint, 0, length));
-
- // "Borrowed" this comment and idea from GraphicsContextCG.cpp
- // For odd widths, we add in 0.5 to the appropriate x/y so that the float
- // arithmetic works out. For example, with a border width of 3, KHTML will
- // pass us (y1+y2)/2, e.g., (50+53)/2 = 103/2 = 51 when we want 51.5. It is
- // always true that an even width gave us a perfect position, but an odd
- // width gave us a position that is off by exactly 0.5.
- bool isVerticalLine = pts[0].fX == pts[1].fX;
-
- if (width & 1) { // Odd.
- if (isVerticalLine) {
- pts[0].fX = pts[0].fX + SK_ScalarHalf;
- pts[1].fX = pts[0].fX;
- } else { // Horizontal line
- pts[0].fY = pts[0].fY + SK_ScalarHalf;
- pts[1].fY = pts[0].fY;
- }
- }
- platformContext()->canvas()->drawPoints(
- SkCanvas::kLines_PointMode, 2, pts, paint);
-}
-
-void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& pt,
- int width,
- bool grammar)
-{
- if (paintingDisabled())
- return;
-
- // Create the pattern we'll use to draw the underline.
- static SkBitmap* misspell_bitmap = 0;
- if (!misspell_bitmap) {
- // We use a 2-pixel-high misspelling indicator because that seems to be
- // what WebKit is designed for, and how much room there is in a typical
- // page for it.
- const int row_pixels = 32; // Must be multiple of 4 for pattern below.
- const int col_pixels = 2;
- misspell_bitmap = new SkBitmap;
- misspell_bitmap->setConfig(SkBitmap::kARGB_8888_Config,
- row_pixels, col_pixels);
- misspell_bitmap->allocPixels();
-
- misspell_bitmap->eraseARGB(0, 0, 0, 0);
- const uint32_t line_color = 0xFFFF0000; // Opaque red.
- const uint32_t anti_color = 0x60600000; // Semitransparent red.
-
- // Pattern: X o o X o o X
- // o X o o X o
- uint32_t* row1 = misspell_bitmap->getAddr32(0, 0);
- uint32_t* row2 = misspell_bitmap->getAddr32(0, 1);
- for (int x = 0; x < row_pixels; x ++) {
- switch (x % 4) {
- case 0:
- row1[x] = line_color;
- break;
- case 1:
- row1[x] = anti_color;
- row2[x] = anti_color;
- break;
- case 2:
- row2[x] = line_color;
- break;
- case 3:
- row1[x] = anti_color;
- row2[x] = anti_color;
- break;
- }
- }
- }
-
- // Offset it vertically by 1 so that there's some space under the text.
- SkScalar origin_x = SkIntToScalar(pt.x());
- SkScalar origin_y = SkIntToScalar(pt.y()) + 1;
-
- // Make a shader for the bitmap with an origin of the box we'll draw. This
- // shader is refcounted and will have an initial refcount of 1.
- SkShader* shader = SkShader::CreateBitmapShader(
- *misspell_bitmap, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
- SkMatrix matrix;
- matrix.reset();
- matrix.postTranslate(origin_x, origin_y);
- shader->setLocalMatrix(matrix);
-
- // Assign the shader to the paint & release our reference. The paint will
- // now own the shader and the shader will be destroyed when the paint goes
- // out of scope.
- SkPaint paint;
- paint.setShader(shader);
- shader->unref();
-
- SkRect rect;
- rect.set(origin_x,
- origin_y,
- origin_x + SkIntToScalar(width),
- origin_y + SkIntToScalar(misspell_bitmap->height()));
- platformContext()->canvas()->drawRect(rect, paint);
-}
-
-void GraphicsContext::drawLineForText(const IntPoint& pt,
- int width,
- bool printing)
-{
- if (paintingDisabled())
- return;
-
- int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
- SkRect r;
- r.fLeft = SkIntToScalar(pt.x());
- r.fTop = SkIntToScalar(pt.y());
- r.fRight = r.fLeft + SkIntToScalar(width);
- r.fBottom = r.fTop + SkIntToScalar(thickness);
-
- SkPaint paint;
- paint.setColor(this->strokeColor().rgb());
- platformContext()->canvas()->drawRect(r, paint);
-}
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r = rect;
- if (!IsRectReasonable(getCTM(), r)) {
- // See the fillRect below.
- ClipRectToCanvas(*platformContext()->canvas(), r, &r);
- }
-
- platformContext()->drawRect(r);
-}
-
-void GraphicsContext::fillPath()
-{
- if (paintingDisabled())
- return;
- const SkPath& path = *platformContext()->currentPath();
- if (!IsPathReasonable(getCTM(), path))
- return;
-
- const GraphicsContextState& state = m_common->state;
- ColorSpace colorSpace = state.fillColorSpace;
-
- if (colorSpace == SolidColorSpace && !fillColor().alpha())
- return;
-
- platformContext()->setFillRule(state.fillRule == RULE_EVENODD ?
- SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
-
- if (colorSpace == PatternColorSpace) {
- SkShader* pat = state.fillPattern->createPlatformPattern(getCTM());
- paint.setShader(pat);
- pat->unref();
- } else if (colorSpace == GradientColorSpace)
- paint.setShader(state.fillGradient->platformGradient());
-
- platformContext()->canvas()->drawPath(path, paint);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r = rect;
- if (!IsRectReasonable(getCTM(), r)) {
- // See the other version of fillRect below.
- ClipRectToCanvas(*platformContext()->canvas(), r, &r);
- }
-
- const GraphicsContextState& state = m_common->state;
- ColorSpace colorSpace = state.fillColorSpace;
-
- if (colorSpace == SolidColorSpace && !fillColor().alpha())
- return;
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
-
- if (colorSpace == PatternColorSpace) {
- SkShader* pat = state.fillPattern->createPlatformPattern(getCTM());
- paint.setShader(pat);
- pat->unref();
- } else if (colorSpace == GradientColorSpace)
- paint.setShader(state.fillGradient->platformGradient());
-
- platformContext()->canvas()->drawRect(r, paint);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- if (color.rgb() & 0xFF000000) {
- SkRect r = rect;
- if (!IsRectReasonable(getCTM(), r)) {
- // Special case when the rectangle overflows fixed point. This is a
- // workaround to fix bug 1212844. When the input rectangle is very
- // large, it can overflow Skia's internal fixed point rect. This
- // should be fixable in Skia (since the output bitmap isn't that
- // large), but until that is fixed, we try to handle it ourselves.
- //
- // We manually clip the rectangle to the current clip rect. This
- // will prevent overflow. The rectangle will be transformed to the
- // canvas' coordinate space before it is converted to fixed point
- // so we are guaranteed not to overflow after doing this.
- ClipRectToCanvas(*platformContext()->canvas(), r, &r);
- }
-
- SkPaint paint;
- platformContext()->setupPaintCommon(&paint);
- paint.setColor(color.rgb());
- platformContext()->canvas()->drawRect(r, paint);
- }
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect,
- const IntSize& topLeft,
- const IntSize& topRight,
- const IntSize& bottomLeft,
- const IntSize& bottomRight,
- const Color& color)
-{
- if (paintingDisabled())
- return;
-
- SkRect r = rect;
- if (!IsRectReasonable(getCTM(), r)) {
- // See fillRect().
- ClipRectToCanvas(*platformContext()->canvas(), r, &r);
- }
-
- SkPath path;
- addCornerArc(&path, r, topRight, 270);
- addCornerArc(&path, r, bottomRight, 0);
- addCornerArc(&path, r, bottomLeft, 90);
- addCornerArc(&path, r, topLeft, 180);
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- platformContext()->canvas()->drawPath(path, paint);
- return fillRect(rect, color);
-}
-
-AffineTransform GraphicsContext::getCTM() const
-{
- return platformContext()->canvas()->getTotalMatrix();
-}
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
-{
- // This logic is copied from GraphicsContextCG, eseidel 5/05/08
-
- // It is not enough just to round to pixels in device space. The rotation
- // part of the affine transform matrix to device space can mess with this
- // conversion if we have a rotating image like the hands of the world clock
- // widget. We just need the scale, so we get the affine transform matrix and
- // extract the scale.
-
- const SkMatrix& deviceMatrix =
- platformContext()->canvas()->getTotalMatrix();
- if (deviceMatrix.isIdentity())
- return rect;
-
- float deviceScaleX = sqrtf(square(deviceMatrix.getScaleX())
- + square(deviceMatrix.getSkewY()));
- float deviceScaleY = sqrtf(square(deviceMatrix.getSkewX())
- + square(deviceMatrix.getScaleY()));
-
- FloatPoint deviceOrigin(rect.x() * deviceScaleX, rect.y() * deviceScaleY);
- FloatPoint deviceLowerRight((rect.x() + rect.width()) * deviceScaleX,
- (rect.y() + rect.height()) * deviceScaleY);
-
- deviceOrigin.setX(roundf(deviceOrigin.x()));
- deviceOrigin.setY(roundf(deviceOrigin.y()));
- deviceLowerRight.setX(roundf(deviceLowerRight.x()));
- deviceLowerRight.setY(roundf(deviceLowerRight.y()));
-
- // Don't let the height or width round to 0 unless either was originally 0
- if (deviceOrigin.y() == deviceLowerRight.y() && rect.height() != 0)
- deviceLowerRight.move(0, 1);
- if (deviceOrigin.x() == deviceLowerRight.x() && rect.width() != 0)
- deviceLowerRight.move(1, 0);
-
- FloatPoint roundedOrigin(deviceOrigin.x() / deviceScaleX,
- deviceOrigin.y() / deviceScaleY);
- FloatPoint roundedLowerRight(deviceLowerRight.x() / deviceScaleX,
- deviceLowerRight.y() / deviceScaleY);
- return FloatRect(roundedOrigin, roundedLowerRight - roundedOrigin);
-}
-
-void GraphicsContext::scale(const FloatSize& size)
-{
- if (paintingDisabled())
- return;
- platformContext()->canvas()->scale(WebCoreFloatToSkScalar(size.width()),
- WebCoreFloatToSkScalar(size.height()));
-}
-
-void GraphicsContext::setAlpha(float alpha)
-{
- if (paintingDisabled())
- return;
- platformContext()->setAlpha(alpha);
-}
-
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
-{
- if (paintingDisabled())
- return;
- platformContext()->setPorterDuffMode(WebCoreCompositeToSkiaComposite(op));
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
-{
- notImplemented();
-}
-
-void GraphicsContext::setLineCap(LineCap cap)
-{
- if (paintingDisabled())
- return;
- switch (cap) {
- case ButtCap:
- platformContext()->setLineCap(SkPaint::kButt_Cap);
- break;
- case RoundCap:
- platformContext()->setLineCap(SkPaint::kRound_Cap);
- break;
- case SquareCap:
- platformContext()->setLineCap(SkPaint::kSquare_Cap);
- break;
- default:
- ASSERT(0);
- break;
- }
-}
-
-void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
-{
- if (paintingDisabled())
- return;
- // TODO(dglazkov): This is lifted directly off SkiaSupport, lines 49-74
- // so it is not guaranteed to work correctly. I made some minor cosmetic
- // refactoring, but not much else. Please fix this?
- size_t dashLength = dashes.size();
- if (!dashLength)
- return;
-
- size_t count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
- SkScalar* intervals = new SkScalar[count];
-
- for (unsigned int i = 0; i < count; i++)
- intervals[i] = dashes[i % dashLength];
-
- platformContext()->setDashPathEffect(new SkDashPathEffect(intervals,
- count, dashOffset));
-
- delete[] intervals;
-}
-
-void GraphicsContext::setLineJoin(LineJoin join)
-{
- if (paintingDisabled())
- return;
- switch (join) {
- case MiterJoin:
- platformContext()->setLineJoin(SkPaint::kMiter_Join);
- break;
- case RoundJoin:
- platformContext()->setLineJoin(SkPaint::kRound_Join);
- break;
- case BevelJoin:
- platformContext()->setLineJoin(SkPaint::kBevel_Join);
- break;
- default:
- ASSERT(0);
- break;
- }
-}
-
-void GraphicsContext::setMiterLimit(float limit)
-{
- if (paintingDisabled())
- return;
- platformContext()->setMiterLimit(limit);
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& color)
-{
- if (paintingDisabled())
- return;
- platformContext()->setFillColor(color.rgb());
-}
-
-void GraphicsContext::setPlatformShadow(const IntSize& size,
- int blur_int,
- const Color& color)
-{
- if (paintingDisabled())
- return;
-
- double width = size.width();
- double height = size.height();
- double blur = blur_int;
-
- if (!m_common->state.shadowsIgnoreTransforms) {
- AffineTransform transform = getCTM();
- transform.map(width, height, &width, &height);
-
- // Transform for the blur
- double a = transform.a() * transform.a() + transform.b() * transform.b();
- double b = transform.a() * transform.c() + transform.b() * transform.d();
- double c = b;
- double d = transform.c() * transform.c() + transform.d() * transform.d();
- double eigenvalue = sqrt(0.5 * ((a + d) - sqrt(4 * b * c + (a - d) * (a - d))));
- blur *= eigenvalue;
- } else {
- // This is weird, but shadows get dropped in the wrong direction for
- // canvas elements without this.
- height = -height;
- }
-
- SkColor c;
- if (color.isValid())
- c = color.rgb();
- else
- c = SkColorSetARGB(0xFF/3, 0, 0, 0); // "std" apple shadow color.
-
- // TODO(tc): Should we have a max value for the blur? CG clamps at 1000.0
- // for perf reasons.
- SkDrawLooper* dl = new SkBlurDrawLooper(blur / 2, width, height, c);
- platformContext()->setDrawLooper(dl);
- dl->unref();
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& strokecolor)
-{
- if (paintingDisabled())
- return;
- platformContext()->setStrokeColor(strokecolor.rgb());
-}
-
-void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle& stroke)
-{
- if (paintingDisabled())
- return;
- platformContext()->setStrokeStyle(stroke);
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float thickness)
-{
- if (paintingDisabled())
- return;
- platformContext()->setStrokeThickness(thickness);
-}
-
-void GraphicsContext::setPlatformTextDrawingMode(int mode)
-{
- if (paintingDisabled())
- return;
- platformContext()->setTextDrawingMode(mode);
-}
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
-}
-
-void GraphicsContext::setUseAntialiasing(bool enable)
-{
- if (paintingDisabled())
- return;
- platformContext()->setUseAntialiasing(enable);
-}
-
-void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- SkRect oval = r;
- if (strokeStyle() == NoStroke) {
- // Stroke using the fill color.
- // TODO(brettw) is this really correct? It seems unreasonable.
- platformContext()->setupPaintForFilling(&paint);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(WebCoreFloatToSkScalar(strokeThickness()));
- } else
- platformContext()->setupPaintForStroking(&paint, 0, 0);
-
- // We do this before converting to scalar, so we don't overflow SkFixed.
- startAngle = fastMod(startAngle, 360);
- angleSpan = fastMod(angleSpan, 360);
-
- SkPath path;
- path.addArc(oval, SkIntToScalar(-startAngle), SkIntToScalar(-angleSpan));
- if (!IsPathReasonable(getCTM(), path))
- return;
- platformContext()->canvas()->drawPath(path, paint);
-}
-
-void GraphicsContext::strokePath()
-{
- if (paintingDisabled())
- return;
- const SkPath& path = *platformContext()->currentPath();
- if (!IsPathReasonable(getCTM(), path))
- return;
-
- const GraphicsContextState& state = m_common->state;
- ColorSpace colorSpace = state.strokeColorSpace;
-
- if (colorSpace == SolidColorSpace && !strokeColor().alpha())
- return;
-
- SkPaint paint;
- platformContext()->setupPaintForStroking(&paint, 0, 0);
-
- if (colorSpace == PatternColorSpace) {
- SkShader* pat = state.strokePattern->createPlatformPattern(getCTM());
- paint.setShader(pat);
- pat->unref();
- } else if (colorSpace == GradientColorSpace)
- paint.setShader(state.strokeGradient->platformGradient());
-
- platformContext()->canvas()->drawPath(path, paint);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
-{
- if (paintingDisabled())
- return;
- if (!IsRectReasonable(getCTM(), rect))
- return;
-
- const GraphicsContextState& state = m_common->state;
- ColorSpace colorSpace = state.strokeColorSpace;
-
- if (colorSpace == SolidColorSpace && !strokeColor().alpha())
- return;
-
- SkPaint paint;
- platformContext()->setupPaintForStroking(&paint, 0, 0);
- paint.setStrokeWidth(WebCoreFloatToSkScalar(lineWidth));
-
- if (colorSpace == PatternColorSpace) {
- SkShader* pat = state.strokePattern->createPlatformPattern(getCTM());
- paint.setShader(pat);
- pat->unref();
- } else if (colorSpace == GradientColorSpace)
- paint.setShader(state.strokeGradient->platformGradient());
-
- platformContext()->canvas()->drawRect(rect, paint);
-}
-
-void GraphicsContext::rotate(float angleInRadians)
-{
- if (paintingDisabled())
- return;
- platformContext()->canvas()->rotate(WebCoreFloatToSkScalar(
- angleInRadians * (180.0f / 3.14159265f)));
-}
-
-void GraphicsContext::translate(float w, float h)
-{
- if (paintingDisabled())
- return;
- platformContext()->canvas()->translate(WebCoreFloatToSkScalar(w),
- WebCoreFloatToSkScalar(h));
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/ImageBufferSkia.cpp b/webkit/port/platform/graphics/skia/ImageBufferSkia.cpp
deleted file mode 100644
index 42e9a9f..0000000
--- a/webkit/port/platform/graphics/skia/ImageBufferSkia.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright (c) 2008, 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 "ImageBuffer.h"
-
-#include "BitmapImage.h"
-#include "BitmapImageSingleFrameSkia.h"
-#include "GraphicsContext.h"
-#include "ImageData.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "SkiaUtils.h"
-
-using namespace std;
-
-namespace WebCore {
-
-// We pass a technically-uninitialized canvas to the platform context here since
-// the canvas initialization completes in ImageBuffer::ImageBuffer. But
-// PlatformContext doesn't actually need to use the object, and this makes all
-// the ownership easier to manage.
-ImageBufferData::ImageBufferData(const IntSize& size)
- : m_canvas()
- , m_platformContext(NULL) // Canvas is set in ImageBuffer constructor.
-{
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
- : m_data(size)
- , m_size(size)
-{
- if (!m_data.m_canvas.initialize(size.width(), size.height(), false)) {
- success = false;
- return;
- }
-
- m_data.m_platformContext.setCanvas(&m_data.m_canvas);
- m_context.set(new GraphicsContext(&m_data.m_platformContext));
-
- // Make the background transparent. It would be nice if this wasn't
- // required, but the canvas is currently filled with the magic transparency
- // color. Can we have another way to manage this?
- m_data.m_canvas.drawARGB(0, 0, 0, 0, SkPorterDuff::kClear_Mode);
- success = true;
-}
-
-ImageBuffer::~ImageBuffer()
-{
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- return m_context.get();
-}
-
-Image* ImageBuffer::image() const
-{
- if (!m_image) {
- // This creates a COPY of the image and will cache that copy. This means
- // that if subsequent operations take place on the context, neither the
- // currently-returned image, nor the results of future image() calls,
- // will contain that operation.
- //
- // This seems silly, but is the way the CG port works: image() is
- // intended to be used only when rendering is "complete."
- m_image = BitmapImageSingleFrameSkia::create(
- *m_data.m_platformContext.bitmap());
- }
- return m_image.get();
-}
-
-PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect& rect) const
-{
- ASSERT(context());
-
- RefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
- unsigned char* data = result->data()->data().data();
-
- if (rect.x() < 0 || rect.y() < 0 ||
- (rect.x() + rect.width()) > m_size.width() ||
- (rect.y() + rect.height()) > m_size.height())
- memset(data, 0, result->data()->length());
-
- int originx = rect.x();
- int destx = 0;
- if (originx < 0) {
- destx = -originx;
- originx = 0;
- }
- int endx = rect.x() + rect.width();
- if (endx > m_size.width())
- endx = m_size.width();
- int numColumns = endx - originx;
-
- int originy = rect.y();
- int desty = 0;
- if (originy < 0) {
- desty = -originy;
- originy = 0;
- }
- int endy = rect.y() + rect.height();
- if (endy > m_size.height())
- endy = m_size.height();
- int numRows = endy - originy;
-
- const SkBitmap& bitmap = *context()->platformContext()->bitmap();
- ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config);
- SkAutoLockPixels bitmapLock(bitmap);
-
- unsigned destBytesPerRow = 4 * rect.width();
- unsigned char* destRow = data + desty * destBytesPerRow + destx * 4;
-
- for (int y = 0; y < numRows; ++y) {
- uint32_t* srcRow = bitmap.getAddr32(originx, originy + y);
- for (int x = 0; x < numColumns; ++x) {
- SkColor color = SkPMColorToColor(srcRow[x]);
- unsigned char* destPixel = &destRow[x * 4];
- destPixel[0] = SkColorGetR(color);
- destPixel[1] = SkColorGetG(color);
- destPixel[2] = SkColorGetB(color);
- destPixel[3] = SkColorGetA(color);
- }
- destRow += destBytesPerRow;
- }
-
- return result;
-}
-
-void ImageBuffer::putImageData(ImageData* source, const IntRect& sourceRect,
- const IntPoint& destPoint)
-{
- ASSERT(sourceRect.width() > 0);
- ASSERT(sourceRect.height() > 0);
-
- int originx = sourceRect.x();
- int destx = destPoint.x() + sourceRect.x();
- ASSERT(destx >= 0);
- ASSERT(destx < m_size.width());
- ASSERT(originx >= 0);
- ASSERT(originx < sourceRect.right());
-
- int endx = destPoint.x() + sourceRect.right();
- ASSERT(endx <= m_size.width());
-
- int numColumns = endx - destx;
-
- int originy = sourceRect.y();
- int desty = destPoint.y() + sourceRect.y();
- ASSERT(desty >= 0);
- ASSERT(desty < m_size.height());
- ASSERT(originy >= 0);
- ASSERT(originy < sourceRect.bottom());
-
- int endy = destPoint.y() + sourceRect.bottom();
- ASSERT(endy <= m_size.height());
- int numRows = endy - desty;
-
- const SkBitmap& bitmap = *context()->platformContext()->bitmap();
- ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config);
- SkAutoLockPixels bitmapLock(bitmap);
-
- unsigned srcBytesPerRow = 4 * source->width();
-
- const unsigned char* srcRow = source->data()->data().data() +
- originy * srcBytesPerRow + originx * 4;
-
- for (int y = 0; y < numRows; ++y) {
- uint32_t* destRow = bitmap.getAddr32(destx, desty + y);
- for (int x = 0; x < numColumns; ++x) {
- const unsigned char* srcPixel = &srcRow[x * 4];
- destRow[x] = SkPreMultiplyARGB(srcPixel[3], srcPixel[0],
- srcPixel[1], srcPixel[2]);
- }
- srcRow += srcBytesPerRow;
- }
-}
-
-String ImageBuffer::toDataURL(const String&) const
-{
- notImplemented();
- return String();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/ImageSkia.cpp b/webkit/port/platform/graphics/skia/ImageSkia.cpp
deleted file mode 100644
index 972ca0d..0000000
--- a/webkit/port/platform/graphics/skia/ImageSkia.cpp
+++ /dev/null
@@ -1,461 +0,0 @@
-// Copyright (c) 2008, 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 "AffineTransform.h"
-#include "BitmapImage.h"
-#include "BitmapImageSingleFrameSkia.h"
-#include "ChromiumBridge.h"
-#include "FloatConversion.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "Logging.h"
-#include "NativeImageSkia.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "PlatformString.h"
-#include "SkiaUtils.h"
-#include "SkShader.h"
-
-#include "skia/ext/image_operations.h"
-#include "skia/ext/platform_canvas.h"
-
-namespace WebCore {
-
-namespace {
-
-// Used by computeResamplingMode to tell how bitmaps should be resampled.
-enum ResamplingMode {
- // Nearest neighbor resampling. Used when we detect that the page is
- // trying to make a pattern by stretching a small bitmap very large.
- RESAMPLE_NONE,
-
- // Default skia resampling. Used for large growing of images where high
- // quality resampling doesn't get us very much except a slowdown.
- RESAMPLE_LINEAR,
-
- // High quality resampling.
- RESAMPLE_AWESOME,
-};
-
-// static
-ResamplingMode computeResamplingMode(const NativeImageSkia& bitmap,
- int srcWidth, int srcHeight,
- float destWidth, float destHeight)
-{
- int destIWidth = static_cast<int>(destWidth);
- int destIHeight = static_cast<int>(destHeight);
-
- // The percent change below which we will not resample. This usually means
- // an off-by-one error on the web page, and just doing nearest neighbor
- // sampling is usually good enough.
- const float kFractionalChangeThreshold = 0.025f;
-
- // Images smaller than this in either direction are considered "small" and
- // are not resampled ever (see below).
- const int kSmallImageSizeThreshold = 8;
-
- // The amount an image can be stretched in a single direction before we
- // say that it is being stretched so much that it must be a line or
- // background that doesn't need resampling.
- const float kLargeStretch = 3.0f;
-
- // Figure out if we should resample this image. We try to prune out some
- // common cases where resampling won't give us anything, since it is much
- // slower than drawing stretched.
- if (srcWidth == destIWidth && srcHeight == destIHeight) {
- // We don't need to resample if the source and destination are the same.
- return RESAMPLE_NONE;
- }
-
- if (srcWidth <= kSmallImageSizeThreshold ||
- srcHeight <= kSmallImageSizeThreshold ||
- destWidth <= kSmallImageSizeThreshold ||
- destHeight <= kSmallImageSizeThreshold) {
- // Never resample small images. These are often used for borders and
- // rules (think 1x1 images used to make lines).
- return RESAMPLE_NONE;
- }
-
- if (srcHeight * kLargeStretch <= destHeight ||
- srcWidth * kLargeStretch <= destWidth) {
- // Large image detected.
-
- // Don't resample if it is being stretched a lot in only one direction.
- // This is trying to catch cases where somebody has created a border
- // (which might be large) and then is stretching it to fill some part
- // of the page.
- if (srcWidth == destWidth || srcHeight == destHeight)
- return RESAMPLE_NONE;
-
- // The image is growing a lot and in more than one direction. Resampling
- // is slow and doesn't give us very much when growing a lot.
- return RESAMPLE_LINEAR;
- }
-
- if ((fabs(destWidth - srcWidth) / srcWidth <
- kFractionalChangeThreshold) &&
- (fabs(destHeight - srcHeight) / srcHeight <
- kFractionalChangeThreshold)) {
- // It is disappointingly common on the web for image sizes to be off by
- // one or two pixels. We don't bother resampling if the size difference
- // is a small fraction of the original size.
- return RESAMPLE_NONE;
- }
-
- // When the image is not yet done loading, use linear. We don't cache the
- // partially resampled images, and as they come in incrementally, it causes
- // us to have to resample the whole thing every time.
- if (!bitmap.isDataComplete())
- return RESAMPLE_LINEAR;
-
- // Everything else gets resampled.
- return RESAMPLE_AWESOME;
-}
-
-// Draws the given bitmap to the given canvas. The subset of the source bitmap
-// identified by src_rect is drawn to the given destination rect. The bitmap
-// will be resampled to resample_width * resample_height (this is the size of
-// the whole image, not the subset). See shouldResampleBitmap for more.
-//
-// This does a lot of computation to resample only the portion of the bitmap
-// that will only be drawn. This is critical for performance since when we are
-// scrolling, for example, we are only drawing a small strip of the image.
-// Resampling the whole image every time is very slow, so this speeds up things
-// dramatically.
-void drawResampledBitmap(SkCanvas& canvas,
- SkPaint& paint,
- const NativeImageSkia& bitmap,
- const SkIRect& srcIRect,
- const SkRect& destRect)
-{
- // First get the subset we need. This is efficient and does not copy pixels.
- SkBitmap subset;
- bitmap.extractSubset(&subset, srcIRect);
- SkRect srcRect;
- srcRect.set(srcIRect);
-
- // Whether we're doing a subset or using the full source image.
- bool srcIsFull = srcIRect.fLeft == 0 && srcIRect.fTop == 0 &&
- srcIRect.width() == bitmap.width() &&
- srcIRect.height() == bitmap.height();
-
- // We will always draw in integer sizes, so round the destination rect.
- SkIRect destRectRounded;
- destRect.round(&destRectRounded);
- SkIRect resizedImageRect; // Represents the size of the resized image.
- resizedImageRect.set(0, 0,
- destRectRounded.width(), destRectRounded.height());
-
- if (srcIsFull &&
- bitmap.hasResizedBitmap(destRectRounded.width(),
- destRectRounded.height())) {
- // Yay, this bitmap frame already has a resized version.
- SkBitmap resampled = bitmap.resizedBitmap(destRectRounded.width(),
- destRectRounded.height());
- canvas.drawBitmapRect(resampled, 0, destRect, &paint);
- return;
- }
-
- // Compute the visible portion of our rect.
- SkRect destBitmapSubsetSk;
- ClipRectToCanvas(canvas, destRect, &destBitmapSubsetSk);
- destBitmapSubsetSk.offset(-destRect.fLeft, -destRect.fTop);
-
- // The matrix inverting, etc. could have introduced rounding error which
- // causes the bounds to be outside of the resized bitmap. We round outward
- // so we always lean toward it being larger rather than smaller than we
- // need, and then clamp to the bitmap bounds so we don't get any invalid
- // data.
- SkIRect destBitmapSubsetSkI;
- destBitmapSubsetSk.roundOut(&destBitmapSubsetSkI);
- if (!destBitmapSubsetSkI.intersect(resizedImageRect))
- return; // Resized image does not intersect.
-
- if (srcIsFull && bitmap.shouldCacheResampling(
- resizedImageRect.width(),
- resizedImageRect.height(),
- destBitmapSubsetSkI.width(),
- destBitmapSubsetSkI.height())) {
- // We're supposed to resize the entire image and cache it, even though
- // we don't need all of it.
- SkBitmap resampled = bitmap.resizedBitmap(destRectRounded.width(),
- destRectRounded.height());
- canvas.drawBitmapRect(resampled, 0, destRect, &paint);
- } else {
- // We should only resize the exposed part of the bitmap to do the
- // minimal possible work.
- gfx::Rect destBitmapSubset(destBitmapSubsetSkI.fLeft,
- destBitmapSubsetSkI.fTop,
- destBitmapSubsetSkI.width(),
- destBitmapSubsetSkI.height());
-
- // Resample the needed part of the image.
- SkBitmap resampled = skia::ImageOperations::Resize(subset,
- skia::ImageOperations::RESIZE_LANCZOS3,
- destRectRounded.width(), destRectRounded.height(),
- destBitmapSubset);
-
- // Compute where the new bitmap should be drawn. Since our new bitmap
- // may be smaller than the original, we have to shift it over by the
- // same amount that we cut off the top and left.
- SkRect offsetDestRect = {
- destBitmapSubset.x() + destRect.fLeft,
- destBitmapSubset.y() + destRect.fTop,
- destBitmapSubset.right() + destRect.fLeft,
- destBitmapSubset.bottom() + destRect.fTop };
-
- canvas.drawBitmapRect(resampled, 0, offsetDestRect, &paint);
- }
-}
-
-void paintSkBitmap(PlatformContextSkia* platformContext,
- const NativeImageSkia& bitmap,
- const SkIRect& srcRect,
- const SkRect& destRect,
- const SkPorterDuff::Mode& compOp)
-{
- SkPaint paint;
- paint.setPorterDuffXfermode(compOp);
-
- skia::PlatformCanvas* canvas = platformContext->canvas();
-
- ResamplingMode resampling = platformContext->IsPrinting() ? RESAMPLE_NONE :
- computeResamplingMode(bitmap, srcRect.width(), srcRect.height(),
- SkScalarToFloat(destRect.width()),
- SkScalarToFloat(destRect.height()));
- if (resampling == RESAMPLE_AWESOME) {
- paint.setFilterBitmap(false);
- drawResampledBitmap(*canvas, paint, bitmap, srcRect, destRect);
- } else {
- // No resampling necessary, we can just draw the bitmap. We want to
- // filter it if we decided to do linear interpolation above, or if there
- // is something interesting going on with the matrix (like a rotation).
- // Note: for serialization, we will want to subset the bitmap first so
- // we don't send extra pixels.
- paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
- canvas->drawBitmapRect(bitmap, &srcRect, destRect, &paint);
- }
-}
-
-// Transforms the given dimensions with the given matrix. Used to see how big
-// images will be once transformed.
-void TransformDimensions(const SkMatrix& matrix,
- float src_width,
- float src_height,
- float* dest_width,
- float* dest_height) {
- // Transform 3 points to see how long each side of the bitmap will be.
- SkPoint src_points[3]; // (0, 0), (width, 0), (0, height).
- src_points[0].set(0, 0);
- src_points[1].set(SkFloatToScalar(src_width), 0);
- src_points[2].set(0, SkFloatToScalar(src_height));
-
- // Now measure the length of the two transformed vectors relative to the
- // transformed origin to see how big the bitmap will be. Note: for skews,
- // this isn't the best thing, but we don't have skews.
- SkPoint dest_points[3];
- matrix.mapPoints(dest_points, src_points, 3);
- *dest_width = SkScalarToFloat((dest_points[1] - dest_points[0]).length());
- *dest_height = SkScalarToFloat((dest_points[2] - dest_points[0]).length());
-}
-
-} // namespace
-
-void FrameData::clear()
-{
- // ImageSource::createFrameAtIndex() allocated |m_frame| and passed
- // ownership to BitmapImage; we must delete it here.
- delete m_frame;
- m_frame = 0;
- // NOTE: We purposefully don't reset metadata here, so that even if we
- // throw away previously-decoded data, animation loops can still access
- // properties like frame durations without re-decoding.
-}
-
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- return ChromiumBridge::loadPlatformImageResource(name);
-}
-
-void Image::drawPattern(GraphicsContext* context,
- const FloatRect& floatSrcRect,
- const AffineTransform& patternTransform,
- const FloatPoint& phase,
- CompositeOperator compositeOp,
- const FloatRect& destRect)
-{
- if (destRect.isEmpty() || floatSrcRect.isEmpty())
- return; // nothing to draw
-
- NativeImageSkia* bitmap = nativeImageForCurrentFrame();
- if (!bitmap)
- return;
-
- // This is a very inexpensive operation. It will generate a new bitmap but
- // it will internally reference the old bitmap's pixels, adjusting the row
- // stride so the extra pixels appear as padding to the subsetted bitmap.
- SkBitmap src_subset;
- SkIRect srcRect = enclosingIntRect(floatSrcRect);
- bitmap->extractSubset(&src_subset, srcRect);
-
- SkBitmap resampled;
- SkShader* shader;
-
- // Figure out what size the bitmap will be in the destination. The
- // destination rect is the bounds of the pattern, we need to use the
- // matrix to see how bit it will be.
- float dest_bitmap_width, dest_bitmap_height;
- TransformDimensions(patternTransform, srcRect.width(), srcRect.height(),
- &dest_bitmap_width, &dest_bitmap_height);
-
- // Compute the resampling mode.
- ResamplingMode resampling;
- if (context->platformContext()->IsPrinting())
- resampling = RESAMPLE_LINEAR;
- else {
- resampling = computeResamplingMode(*bitmap,
- srcRect.width(), srcRect.height(),
- dest_bitmap_width, dest_bitmap_height);
- }
-
- // Load the transform WebKit requested.
- SkMatrix matrix(patternTransform);
-
- if (resampling == RESAMPLE_AWESOME) {
- // Do nice resampling.
- SkBitmap resampled = skia::ImageOperations::Resize(src_subset,
- skia::ImageOperations::RESIZE_LANCZOS3,
- static_cast<int>(dest_bitmap_width),
- static_cast<int>(dest_bitmap_height));
- shader = SkShader::CreateBitmapShader(
- resampled, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
-
- // Since we just resized the bitmap, we need to undo the scale set in
- // the image transform.
- matrix.setScaleX(SkIntToScalar(1));
- matrix.setScaleY(SkIntToScalar(1));
- } else {
- // No need to do nice resampling.
- shader = SkShader::CreateBitmapShader(
- src_subset, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
- }
-
- // We also need to translate it such that the origin of the pattern is the
- // origin of the destination rect, which is what WebKit expects. Skia uses
- // the coordinate system origin as the base for the patter. If WebKit wants
- // a shifted image, it will shift it from there using the patternTransform.
- float adjustedX = phase.x() + floatSrcRect.x() *
- narrowPrecisionToFloat(patternTransform.a());
- float adjustedY = phase.y() + floatSrcRect.y() *
- narrowPrecisionToFloat(patternTransform.d());
- matrix.postTranslate(SkFloatToScalar(adjustedX),
- SkFloatToScalar(adjustedY));
- shader->setLocalMatrix(matrix);
-
- SkPaint paint;
- paint.setShader(shader)->unref();
- paint.setPorterDuffXfermode(WebCoreCompositeToSkiaComposite(compositeOp));
- paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
-
- context->platformContext()->paintSkPaint(destRect, paint);
-}
-
-// ================================================
-// BitmapImage Class
-// ================================================
-
-void BitmapImage::initPlatformData()
-{
- // This is not used. On Mac, the "platform" data is a cache of some OS
- // specific versions of the image that are created is some cases. These
- // aren't normally used, it is equivalent to getHBITMAP on Windows, and
- // the platform data is the cache.
-}
-
-void BitmapImage::invalidatePlatformData()
-{
- // See initPlatformData above.
-}
-
-void BitmapImage::checkForSolidColor()
-{
-}
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
- const FloatRect& srcRect, CompositeOperator compositeOp)
-{
- if (!m_source.initialized())
- return;
-
- // Spin the animation to the correct frame before we try to draw it, so we
- // don't draw an old frame and then immediately need to draw a newer one,
- // causing flicker and wasting CPU.
- startAnimation();
-
- const NativeImageSkia* bm = nativeImageForCurrentFrame();
- if (!bm)
- return; // It's too early and we don't have an image yet.
-
- if (srcRect.isEmpty() || dstRect.isEmpty())
- return; // Nothing to draw.
-
- paintSkBitmap(ctxt->platformContext(),
- *bm,
- enclosingIntRect(srcRect),
- enclosingIntRect(dstRect),
- WebCoreCompositeToSkiaComposite(compositeOp));
-}
-
-void BitmapImageSingleFrameSkia::draw(GraphicsContext* ctxt,
- const FloatRect& dstRect,
- const FloatRect& srcRect,
- CompositeOperator compositeOp)
-{
- if (srcRect.isEmpty() || dstRect.isEmpty())
- return; // Nothing to draw.
-
- paintSkBitmap(ctxt->platformContext(),
- m_nativeImage,
- enclosingIntRect(srcRect),
- enclosingIntRect(dstRect),
- WebCoreCompositeToSkiaComposite(compositeOp));
-}
-
-PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create(
- const SkBitmap& bitmap)
-{
- RefPtr<BitmapImageSingleFrameSkia> image(new BitmapImageSingleFrameSkia());
- if (!bitmap.copyTo(&image->m_nativeImage, bitmap.config()))
- return 0;
- return image.release();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/ImageSourceSkia.cpp b/webkit/port/platform/graphics/skia/ImageSourceSkia.cpp
deleted file mode 100644
index af5bb82..0000000
--- a/webkit/port/platform/graphics/skia/ImageSourceSkia.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2006 Google Inc. All Rights Reserved.
- *
- * Portions Copyright (C) 2006 Apple Computer, 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "ImageSourceSkia.h"
-#include "SharedBuffer.h"
-
-#include "GIFImageDecoder.h"
-#include "JPEGImageDecoder.h"
-#include "PNGImageDecoder.h"
-#include "BMPImageDecoder.h"
-#include "XBMImageDecoder.h"
-#include "ICOImageDecoder.h"
-
-#include "SkBitmap.h"
-
-namespace WebCore {
-
-ImageDecoder* createDecoder(const Vector<char>& data,
- const IntSize& preferredIconSize)
-{
- // We need at least 4 bytes to figure out what kind of image we're dealing with.
- int length = data.size();
- if (length < 4)
- return 0;
-
- const unsigned char* uContents = (const unsigned char*)data.data();
- const char* contents = data.data();
-
- // GIFs begin with GIF8(7 or 9).
- if (strncmp(contents, "GIF8", 4) == 0)
- return new GIFImageDecoder();
-
- // Test for PNG.
- if (uContents[0]==0x89 &&
- uContents[1]==0x50 &&
- uContents[2]==0x4E &&
- uContents[3]==0x47)
- return new PNGImageDecoder();
-
- // JPEG
- if (uContents[0]==0xFF &&
- uContents[1]==0xD8 &&
- uContents[2]==0xFF)
- return new JPEGImageDecoder();
-
- // BMP
- if (strncmp(contents, "BM", 2) == 0)
- return new BMPImageDecoder();
-
- // ICOs always begin with a 2-byte 0 followed by a 2-byte 1.
- // CURs begin with 2-byte 0 followed by 2-byte 2.
- if (!memcmp(contents, "\000\000\001\000", 4) ||
- !memcmp(contents, "\000\000\002\000", 4))
- return new ICOImageDecoder(preferredIconSize);
-
- // XBMs require 8 bytes of info.
- if (length >= 8 && strncmp(contents, "#define ", 8) == 0)
- return new XBMImageDecoder();
-
- // Give up. We don't know what the heck this is.
- return 0;
-}
-
-ImageSource::ImageSource()
- : m_decoder(0)
-{}
-
-ImageSource::~ImageSource()
-{
- clear(true);
-}
-
-void ImageSource::clear(bool destroyAll, size_t clearBeforeFrame)
-{
- if (destroyAll) {
- delete m_decoder;
- m_decoder = 0;
- return;
- }
-
- if (m_decoder)
- m_decoder->clearFrameBufferCache(clearBeforeFrame);
-}
-
-bool ImageSource::initialized() const
-{
- return m_decoder;
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
- // Make the decoder by sniffing the bytes.
- // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
- // If insufficient bytes are available to determine the image type, no decoder plugin will be
- // made.
- if (!m_decoder)
- m_decoder = createDecoder(data->buffer(), IntSize());
-
- // CreateDecoder will return NULL if the decoder could not be created. Plus,
- // we should not send more data to a decoder which has already decided it
- // has failed.
- if (!m_decoder || m_decoder->failed())
- return;
- m_decoder->setData(data, allDataReceived);
-}
-
-bool ImageSource::isSizeAvailable()
-{
- if (!m_decoder)
- return false;
-
- return m_decoder->isSizeAvailable();
-}
-
-IntSize ImageSource::size() const
-{
- if (!m_decoder)
- return IntSize();
-
- return m_decoder->size();
-}
-
-IntSize ImageSource::frameSizeAtIndex(size_t) const
-{
- // TODO(brettw) do we need anything here?
- return size();
-}
-
-int ImageSource::repetitionCount()
-{
- if (!m_decoder)
- return cAnimationNone;
-
- return m_decoder->repetitionCount();
-}
-
-size_t ImageSource::frameCount() const
-{
- if (!m_decoder)
- return 0;
- return m_decoder->failed() ? 0 : m_decoder->frameCount();
-}
-
-NativeImagePtr ImageSource::createFrameAtIndex(size_t index)
-{
- if (!m_decoder)
- return 0;
-
- // Note that the buffer can have NULL bytes even when it is marked as
- // non-empty. It seems "FrameEmpty" is only set before the frame has been
- // initialized. If it is decoded and it happens to be empty, it will be
- // marked as "FrameComplete" but will still have NULL bytes.
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return 0;
-
- // Copy the bitmap. The pixel data is refcounted internally by SkBitmap, so
- // this doesn't cost much. This pointer will be owned by the BitmapImage
- // and freed in FrameData::clear().
- return new NativeImageSkia(buffer->bitmap());
-}
-
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
-{
- if (!m_decoder)
- return false;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- return buffer && buffer->status() == RGBA32Buffer::FrameComplete;
-}
-
-float ImageSource::frameDurationAtIndex(size_t index)
-{
- if (!m_decoder)
- return 0;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return 0;
-
- // Many annoying ads specify a 0 duration to make an image flash as quickly
- // as possible. We follow WinIE's behavior and use a duration of 100 ms
- // for any frames that specify a duration of <= 50 ms. See
- // <http://bugs.webkit.org/show_bug.cgi?id=14413> or Radar 4051389 for
- // more.
- const float duration = buffer->duration() / 1000.0f;
- return (duration < 0.051f) ? 0.100f : duration;
-
-}
-
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
-{
- if (!m_decoder || !m_decoder->supportsAlpha())
- return false;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return false;
-
- return buffer->hasAlpha();
-}
-
-void ImageSourceSkia::setData(SharedBuffer* data,
- bool allDataReceived,
- const IntSize& preferredIconSize)
-{
- if (!m_decoder)
- m_decoder = createDecoder(data->buffer(), preferredIconSize);
-
- ImageSource::setData(data, allDataReceived);
-}
-
-String ImageSource::filenameExtension() const
-{
- // TODO(pkasting): Implement me!
- return String();
-}
-
-}
diff --git a/webkit/port/platform/graphics/skia/ImageSourceSkia.h b/webkit/port/platform/graphics/skia/ImageSourceSkia.h
deleted file mode 100644
index 4385f16..0000000
--- a/webkit/port/platform/graphics/skia/ImageSourceSkia.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-
-// We need access to the private member of ImageSource. Hack it locally
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-#define private protected
-#include "ImageSource.h"
-#undef private
-
-namespace WebCore {
-
-class ImageSourceSkia : public ImageSource {
-public:
- // This is a special-purpose routine for the favicon decoder, which is used
- // to specify a particular icon size for the ICOImageDecoder to prefer
- // decoding. Note that not all favicons are ICOs, so this won't
- // necessarily do anything differently than ImageSource::setData().
- //
- // Passing an empty IntSize for |preferredIconSize| here is exactly
- // equivalent to just calling ImageSource::setData(). See also comments in
- // ICOImageDecoder.cpp.
- void setData(SharedBuffer* data,
- bool allDataReceived,
- const IntSize& preferredIconSize);
-};
-
-}
-
diff --git a/webkit/port/platform/graphics/skia/IntPointSkia.cpp b/webkit/port/platform/graphics/skia/IntPointSkia.cpp
deleted file mode 100644
index 21e110e..0000000
--- a/webkit/port/platform/graphics/skia/IntPointSkia.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "IntPoint.h"
-#include "SkPoint.h"
-
-namespace WebCore {
-
-IntPoint::IntPoint(const SkIPoint& p)
- : m_x(p.fX)
- , m_y(p.fY)
-{
-}
-
-IntPoint::operator SkIPoint() const
-{
- SkIPoint p = { m_x, m_y };
- return p;
-}
-
-IntPoint::operator SkPoint() const
-{
- SkPoint p = { SkIntToScalar(m_x), SkIntToScalar(m_y) };
- return p;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/IntRectSkia.cpp b/webkit/port/platform/graphics/skia/IntRectSkia.cpp
deleted file mode 100644
index e3186e2..0000000
--- a/webkit/port/platform/graphics/skia/IntRectSkia.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "IntRect.h"
-
-#include "SkRect.h"
-
-namespace WebCore {
-
-IntRect::operator SkIRect() const
-{
- SkIRect rect = { x(), y(), right(), bottom() };
- return rect;
-}
-
-IntRect::operator SkRect() const
-{
- SkRect rect;
- rect.set(SkIntToScalar(x()), SkIntToScalar(y()),
- SkIntToScalar(right()), SkIntToScalar(bottom()));
- return rect;
-}
-
-IntRect::IntRect(const SkIRect& r)
- : m_location(r.fLeft, r.fTop)
- , m_size(r.width(), r.height())
-{
-}
-
-}
-
diff --git a/webkit/port/platform/graphics/skia/NativeImageSkia.cpp b/webkit/port/platform/graphics/skia/NativeImageSkia.cpp
deleted file mode 100644
index fa4ce86..0000000
--- a/webkit/port/platform/graphics/skia/NativeImageSkia.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2008, 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 "skia/ext/image_operations.h"
-
-#include "NativeImageSkia.h"
-#include "SkiaUtils.h"
-
-NativeImageSkia::NativeImageSkia()
- : SkBitmap(),
- m_isDataComplete(false),
- m_resizedImage(),
- m_lastRequestSize(0, 0),
- m_resizeRequests(0) {
-}
-
-int NativeImageSkia::decodedSize() const {
- return getSize() + m_resizedImage.getSize();
-}
-
-bool NativeImageSkia::hasResizedBitmap(int w, int h) const {
- if (m_lastRequestSize.width() == w && m_lastRequestSize.height() == h) {
- m_resizeRequests++;
- } else {
- m_lastRequestSize = WebCore::IntSize(w, h);
- m_resizeRequests = 0;
- }
-
- return m_resizedImage.width() == w && m_resizedImage.height() == h;
-}
-
-// FIXME(brettw) don't cache when image is in-progress.
-
-SkBitmap NativeImageSkia::resizedBitmap(int w, int h) const {
- if (m_resizedImage.width() != w || m_resizedImage.height() != h) {
- m_resizedImage = skia::ImageOperations::Resize(*this,
- skia::ImageOperations::RESIZE_LANCZOS3, w, h);
- }
- return m_resizedImage;
-}
-
-// static
-bool NativeImageSkia::shouldCacheResampling(int dest_width,
- int dest_height,
- int dest_subset_width,
- int dest_subset_height) const {
- // We can not cache incomplete frames. This might be a good optimization in
- // the future, were we know how much of the frame has been decoded, so when
- // we incrementally draw more of the image, we only have to resample the
- // parts that are changed.
- if (!m_isDataComplete)
- return false;
-
- // If the destination bitmap is small, we'll always allow caching, since
- // there is not very much penalty for computing it and it may come in handy.
- static const int kSmallBitmapSize = 4096;
- if (dest_width * dest_height <= kSmallBitmapSize)
- return true;
-
- // If "too many" requests have been made for this bitmap, we assume that
- // many more will be made as well, and we'll go ahead and cache it.
- static const int kManyRequestThreshold = 4;
- if (m_lastRequestSize.width() == dest_width &&
- m_lastRequestSize.height() == dest_height) {
- if (m_resizeRequests >= kManyRequestThreshold)
- return true;
- } else {
- // When a different size is being requested, count this as a query
- // (hasResizedBitmap) and reset the counter.
- m_lastRequestSize = WebCore::IntSize(dest_width, dest_height);
- m_resizeRequests = 0;
- }
-
- // Otherwise, use the heuristic that if more than 1/4 of the image is
- // requested, it's worth caching.
- int dest_size = dest_width * dest_height;
- int dest_subset_size = dest_subset_width * dest_subset_height;
- return dest_size / 4 < dest_subset_size;
-}
diff --git a/webkit/port/platform/graphics/skia/NativeImageSkia.h b/webkit/port/platform/graphics/skia/NativeImageSkia.h
deleted file mode 100644
index d256725..0000000
--- a/webkit/port/platform/graphics/skia/NativeImageSkia.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NativeImageSkia_h
-#define NativeImageSkia_h
-
-#include "SkBitmap.h"
-#include "IntSize.h"
-
-// This object is used as the "native image" in our port. When WebKit uses
-// "NativeImagePtr", it is a pointer to this type. It is an SkBitmap, but also
-// stores a cached resized image.
-class NativeImageSkia : public SkBitmap {
-public:
- NativeImageSkia();
-
- // Returns the number of bytes of image data. This includes the cached
- // resized version if there is one.
- int decodedSize() const;
-
- // Sets the data complete flag. This is called by the image decoder when
- // all data is complete, and used by us to know whether we can cache
- // resized images.
- void setDataComplete() { m_isDataComplete = true; }
-
- // Returns true if the entire image has been decoded.
- bool isDataComplete() const { return m_isDataComplete; }
-
- // We can keep a resized version of the bitmap cached on this object.
- // This function will return true if there is a cached version of the
- // given image subset with the given dimensions.
- bool hasResizedBitmap(int width, int height) const;
-
- // This will return an existing resized image, or generate a new one of
- // the specified size and store it in the cache. Subsetted images can not
- // be cached unless the subset is the entire bitmap.
- SkBitmap resizedBitmap(int width, int height) const;
-
- // Returns true if the given resize operation should either resize the whole
- // image and cache it, or resize just the part it needs and throw the result
- // away.
- //
- // On the one hand, if only a small subset is desired, then we will waste a
- // lot of time resampling the entire thing, so we only want to do exactly
- // what's required. On the other hand, resampling the entire bitmap is
- // better if we're going to be using it more than once (like a bitmap
- // scrolling on and off the screen. Since we only cache when doing the
- // entire thing, it's best to just do it up front.
- bool shouldCacheResampling(int dest_width,
- int dest_height,
- int dest_subset_width,
- int dest_subset_height) const;
-
-private:
- // Set to true when the data is complete. Before the entire image has
- // loaded, we do not want to cache a resize.
- bool m_isDataComplete;
-
- // The cached bitmap. This will be empty() if there is no cached image.
- mutable SkBitmap m_resizedImage;
-
- // References how many times that the image size has been requested for
- // the last size.
- //
- // Every time we get a request, if it matches the m_lastRequestSize, we'll
- // increment the counter, and if not, we'll reset the counter and save the
- // size.
- //
- // This allows us to see if many requests have been made for the same
- // resized image, we know that we should probably cache it, even if all of
- // those requests individually are small and would not otherwise be cached.
- mutable WebCore::IntSize m_lastRequestSize;
- mutable int m_resizeRequests;
-};
-
-#endif // NativeImageSkia_h
-
diff --git a/webkit/port/platform/graphics/skia/PathSkia.cpp b/webkit/port/platform/graphics/skia/PathSkia.cpp
deleted file mode 100644
index 3d3430c..0000000
--- a/webkit/port/platform/graphics/skia/PathSkia.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright (c) 2008, 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 "Path.h"
-#include "FloatRect.h"
-#include "AffineTransform.h"
-
-#include "SkPath.h"
-#include "SkRegion.h"
-
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-Path::Path()
-{
- m_path = new SkPath;
-}
-
-Path::Path(const Path& other)
-{
- m_path = new SkPath(*other.m_path);
-}
-
-Path::~Path()
-{
- delete m_path;
-}
-
-Path& Path::operator=(const Path& other)
-{
- *m_path = *other.m_path;
- return *this;
-}
-
-bool Path::isEmpty() const
-{
- return m_path->isEmpty();
-}
-
-bool Path::contains(const FloatPoint& point, WindRule rule) const
-{
- return SkPathContainsPoint(
- m_path,
- point,
- rule == RULE_NONZERO ? SkPath::kWinding_FillType : SkPath::kEvenOdd_FillType);
-}
-
-void Path::translate(const FloatSize& size)
-{
- m_path->offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(size.height()));
-}
-
-FloatRect Path::boundingRect() const
-{
- SkRect r;
-
- m_path->computeBounds(&r, SkPath::kExact_BoundsType);
- return FloatRect( SkScalarToFloat(r.fLeft),
- SkScalarToFloat(r.fTop),
- SkScalarToFloat(r.width()),
- SkScalarToFloat(r.height()));
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
- m_path->moveTo(WebCoreFloatToSkScalar(point.x()), WebCoreFloatToSkScalar(point.y()));
-}
-
-void Path::addLineTo(const FloatPoint& p)
-{
- m_path->lineTo(WebCoreFloatToSkScalar(p.x()), WebCoreFloatToSkScalar(p.y()));
-}
-
-void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& ep)
-{
- m_path->quadTo(WebCoreFloatToSkScalar(cp.x()), WebCoreFloatToSkScalar(cp.y()),
- WebCoreFloatToSkScalar(ep.x()), WebCoreFloatToSkScalar(ep.y()));
-}
-
-void Path::addBezierCurveTo(const FloatPoint& p1, const FloatPoint& p2, const FloatPoint& ep)
-{
- m_path->cubicTo(WebCoreFloatToSkScalar(p1.x()), WebCoreFloatToSkScalar(p1.y()),
- WebCoreFloatToSkScalar(p2.x()), WebCoreFloatToSkScalar(p2.y()),
- WebCoreFloatToSkScalar(ep.x()), WebCoreFloatToSkScalar(ep.y()));
-}
-
-void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
-{
- m_path->arcTo(WebCoreFloatToSkScalar(p1.x()), WebCoreFloatToSkScalar(p1.y()),
- WebCoreFloatToSkScalar(p2.x()), WebCoreFloatToSkScalar(p2.y()),
- WebCoreFloatToSkScalar(radius));
-}
-
-void Path::closeSubpath()
-{
- m_path->close();
-}
-
-static const float gPI = 3.1415926f;
-
-void Path::addArc(const FloatPoint& p, float r, float sa, float ea,
- bool anticlockwise) {
- SkScalar cx = WebCoreFloatToSkScalar(p.x());
- SkScalar cy = WebCoreFloatToSkScalar(p.y());
- SkScalar radius = WebCoreFloatToSkScalar(r);
-
- SkRect oval;
- oval.set(cx - radius, cy - radius, cx + radius, cy + radius);
-
- float sweep = ea - sa;
- // check for a circle
- if (sweep >= 2*gPI || sweep <= -2*gPI) {
- m_path->addOval(oval);
- } else {
- SkScalar startDegrees = WebCoreFloatToSkScalar(sa * 180 / gPI);
- SkScalar sweepDegrees = WebCoreFloatToSkScalar(sweep * 180 / gPI);
-
- // Counterclockwise arcs should be drawn with negative sweeps, while
- // clockwise arcs should be drawn with positive sweeps. Check to see
- // if the situation is reversed and correct it by adding or subtracting
- // a full circle
- if (anticlockwise && sweepDegrees > 0) {
- sweepDegrees -= SkIntToScalar(360);
- } else if (!anticlockwise && sweepDegrees < 0) {
- sweepDegrees += SkIntToScalar(360);
- }
-
-// SkDebugf("addArc sa=%g ea=%g cw=%d start=%g sweep=%g\n", sa, ea, clockwise,
-// SkScalarToFloat(startDegrees), SkScalarToFloat(sweepDegrees));
-
- m_path->arcTo(oval, startDegrees, sweepDegrees, false);
- }
-}
-
-void Path::addRect(const FloatRect& rect)
-{
- m_path->addRect(rect);
-}
-
-void Path::addEllipse(const FloatRect& rect)
-{
- m_path->addOval(rect);
-}
-
-void Path::clear()
-{
- m_path->reset();
-}
-
-static FloatPoint* setfpts(FloatPoint dst[], const SkPoint src[], int count)
-{
- for (int i = 0; i < count; i++)
- {
- dst[i].setX(SkScalarToFloat(src[i].fX));
- dst[i].setY(SkScalarToFloat(src[i].fY));
- }
- return dst;
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- SkPath::Iter iter(*m_path, false);
- SkPoint pts[4];
-
- PathElement elem;
- FloatPoint fpts[3];
-
- for (;;)
- {
- switch (iter.next(pts)) {
- case SkPath::kMove_Verb:
- elem.type = PathElementMoveToPoint;
- elem.points = setfpts(fpts, &pts[0], 1);
- break;
- case SkPath::kLine_Verb:
- elem.type = PathElementAddLineToPoint;
- elem.points = setfpts(fpts, &pts[1], 1);
- break;
- case SkPath::kQuad_Verb:
- elem.type = PathElementAddQuadCurveToPoint;
- elem.points = setfpts(fpts, &pts[1], 2);
- break;
- case SkPath::kCubic_Verb:
- elem.type = PathElementAddCurveToPoint;
- elem.points = setfpts(fpts, &pts[1], 3);
- break;
- case SkPath::kClose_Verb:
- elem.type = PathElementCloseSubpath;
- elem.points = setfpts(fpts, NULL, 0);
- break;
- case SkPath::kDone_Verb:
- return;
- }
- function(info, &elem);
- }
-}
-
-void Path::transform(const AffineTransform& xform)
-{
- m_path->transform(xform);
-}
-
-String Path::debugString() const
-{
- String result;
-
- SkPath::Iter iter(*m_path, false);
- SkPoint pts[4];
-
- int numPoints = m_path->getPoints(NULL, 0);
- SkPath::Verb verb;
-
- do {
- verb = iter.next(pts);
- switch (verb) {
- case SkPath::kMove_Verb:
- result += String::format("M%.2f,%.2f ", pts[0].fX, pts[0].fY);
- numPoints -= 1;
- break;
- case SkPath::kLine_Verb:
- if (!iter.isCloseLine()) {
- result += String::format("L%.2f,%.2f ", pts[1].fX, pts[1].fY);
- numPoints -= 1;
- }
- break;
- case SkPath::kQuad_Verb:
- result += String::format("Q%.2f,%.2f,%.2f,%.2f ",
- pts[1].fX, pts[1].fY,
- pts[2].fX, pts[2].fY);
- numPoints -= 2;
- break;
- case SkPath::kCubic_Verb:
- result += String::format("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f ",
- pts[1].fX, pts[1].fY,
- pts[2].fX, pts[2].fY,
- pts[3].fX, pts[3].fY);
- numPoints -= 3;
- break;
- case SkPath::kClose_Verb:
- result += "Z ";
- break;
- case SkPath::kDone_Verb:
- break;
- }
- } while (verb != SkPath::kDone_Verb);
-
- // If you have a path that ends with an M, Skia will not iterate the
- // trailing M. That's nice of it, but Apple's paths output the trailing M
- // and we want out layout dumps to look like theirs
- if (numPoints) {
- ASSERT(numPoints==1);
- m_path->getLastPt(pts);
- result += String::format("M%.2f,%.2f ", pts[0].fX, pts[0].fY);
- }
-
- return result.stripWhiteSpace();
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/PatternSkia.cpp b/webkit/port/platform/graphics/skia/PatternSkia.cpp
deleted file mode 100644
index d80d3ec..0000000
--- a/webkit/port/platform/graphics/skia/PatternSkia.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2008 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "Pattern.h"
-
-#include "AffineTransform.h"
-#include "Image.h"
-#include "NativeImageSkia.h"
-
-#include "SkShader.h"
-
-namespace WebCore {
-
-static inline SkShader::TileMode shaderRule(bool shouldRepeat)
-{
- // FIXME: Skia does not have a "draw the tile only once" option
- // Clamp draws the last line of the image after stopping repeating
- return shouldRepeat ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
-}
-
-PlatformPatternPtr Pattern::createPlatformPattern(const AffineTransform& patternTransform) const
-{
- SkBitmap* bm = m_tileImage->nativeImageForCurrentFrame();
- SkShader* shader = SkShader::CreateBitmapShader(*bm,
- shaderRule(m_repeatX),
- shaderRule(m_repeatY));
- shader->setLocalMatrix(patternTransform);
- return shader;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/PlatformContextSkia.cpp b/webkit/port/platform/graphics/skia/PlatformContextSkia.cpp
deleted file mode 100644
index 7822bd6..0000000
--- a/webkit/port/platform/graphics/skia/PlatformContextSkia.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-// Copyright (c) 2008, 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 "GraphicsContext.h"
-#include "NativeImageSkia.h"
-#include "PlatformContextSkia.h"
-#undef LOG
-#include "SkiaUtils.h"
-#include "wtf/MathExtras.h"
-
-#include "skia/ext/image_operations.h"
-#include "skia/ext/platform_canvas.h"
-
-#include "SkBitmap.h"
-#include "SkColorPriv.h"
-#include "SkShader.h"
-#include "SkDashPathEffect.h"
-
-#if defined(OS_LINUX)
-#include "GdkSkia.h"
-#endif
-
-// State -----------------------------------------------------------------------
-
-// Encapsulates the additional painting state information we store for each
-// pushed graphics state.
-struct PlatformContextSkia::State {
- State();
- State(const State&);
- ~State();
-
- // Common shader state.
- float m_alpha;
- SkPorterDuff::Mode m_porterDuffMode;
- SkShader* m_gradient;
- SkShader* m_pattern;
- bool m_useAntialiasing;
- SkDrawLooper* m_looper;
-
- // Fill.
- SkColor m_fillColor;
-
- // Stroke.
- WebCore::StrokeStyle m_strokeStyle;
- SkColor m_strokeColor;
- float m_strokeThickness;
- int m_dashRatio; // Ratio of the length of a dash to its width.
- float m_miterLimit;
- SkPaint::Cap m_lineCap;
- SkPaint::Join m_lineJoin;
- SkDashPathEffect* m_dash;
-
- // Text. (See cTextFill & friends in GraphicsContext.h.)
- int m_textDrawingMode;
-
- // Helper function for applying the state's alpha value to the given input
- // color to produce a new output color.
- SkColor applyAlpha(SkColor c) const;
-
-private:
- // Not supported.
- void operator=(const State&);
-};
-
-// Note: Keep theses default values in sync with GraphicsContextState.
-PlatformContextSkia::State::State()
- : m_alpha(1)
- , m_porterDuffMode(SkPorterDuff::kSrcOver_Mode)
- , m_gradient(0)
- , m_pattern(0)
- , m_useAntialiasing(true)
- , m_looper(0)
- , m_fillColor(0xFF000000)
- , m_strokeStyle(WebCore::SolidStroke)
- , m_strokeColor(0x0FF000000)
- , m_strokeThickness(0)
- , m_dashRatio(3)
- , m_miterLimit(4)
- , m_lineCap(SkPaint::kDefault_Cap)
- , m_lineJoin(SkPaint::kDefault_Join)
- , m_dash(0)
- , m_textDrawingMode(WebCore::cTextFill)
-{
-}
-
-PlatformContextSkia::State::State(const State& other)
-{
- memcpy(this, &other, sizeof(State));
-
- m_looper->safeRef();
- m_dash->safeRef();
- m_gradient->safeRef();
- m_pattern->safeRef();
-}
-
-PlatformContextSkia::State::~State()
-{
- m_looper->safeUnref();
- m_dash->safeUnref();
- m_gradient->safeUnref();
- m_pattern->safeUnref();
-}
-
-SkColor PlatformContextSkia::State::applyAlpha(SkColor c) const
-{
- int s = roundf(m_alpha * 256);
- if (s >= 256)
- return c;
- if (s < 0)
- return 0;
-
- int a = SkAlphaMul(SkColorGetA(c), s);
- return (c & 0x00FFFFFF) | (a << 24);
-}
-
-// PlatformContextSkia ---------------------------------------------------------
-
-// Danger: canvas can be NULL.
-PlatformContextSkia::PlatformContextSkia(skia::PlatformCanvas* canvas)
- : m_canvas(canvas)
- , m_stateStack(sizeof(State))
-{
- m_stateStack.append(State());
- m_state = &m_stateStack.last();
-#if defined(OS_LINUX)
- m_gdkskia = m_canvas ? gdk_skia_new(m_canvas) : NULL;
-#endif
-}
-
-PlatformContextSkia::~PlatformContextSkia()
-{
-#if defined(OS_LINUX)
- if (m_gdkskia) {
- g_object_unref(m_gdkskia);
- m_gdkskia = NULL;
- }
-#endif
-}
-
-void PlatformContextSkia::setCanvas(skia::PlatformCanvas* canvas)
-{
- m_canvas = canvas;
-}
-
-void PlatformContextSkia::save()
-{
- m_stateStack.append(*m_state);
- m_state = &m_stateStack.last();
-
- // Save our native canvas.
- canvas()->save();
-}
-
-void PlatformContextSkia::restore()
-{
- m_stateStack.removeLast();
- m_state = &m_stateStack.last();
-
- // Restore our native canvas.
- canvas()->restore();
-}
-
-void PlatformContextSkia::drawRect(SkRect rect)
-{
- SkPaint paint;
- int fillcolorNotTransparent = m_state->m_fillColor & 0xFF000000;
- if (fillcolorNotTransparent) {
- setupPaintForFilling(&paint);
- canvas()->drawRect(rect, paint);
- }
-
- if (m_state->m_strokeStyle != WebCore::NoStroke &&
- (m_state->m_strokeColor & 0xFF000000)) {
- if (fillcolorNotTransparent) {
- // This call is expensive so don't call it unnecessarily.
- paint.reset();
- }
- setupPaintForStroking(&paint, &rect, 0);
- canvas()->drawRect(rect, paint);
- }
-}
-
-void PlatformContextSkia::setupPaintCommon(SkPaint* paint) const
-{
-#ifdef SK_DEBUGx
- {
- SkPaint defaultPaint;
- SkASSERT(*paint == defaultPaint);
- }
-#endif
-
- paint->setAntiAlias(m_state->m_useAntialiasing);
- paint->setPorterDuffXfermode(m_state->m_porterDuffMode);
- paint->setLooper(m_state->m_looper);
-
- if (m_state->m_gradient)
- paint->setShader(m_state->m_gradient);
- else if (m_state->m_pattern)
- paint->setShader(m_state->m_pattern);
-}
-
-void PlatformContextSkia::setupPaintForFilling(SkPaint* paint) const
-{
- setupPaintCommon(paint);
- paint->setColor(m_state->applyAlpha(m_state->m_fillColor));
-}
-
-float PlatformContextSkia::setupPaintForStroking(SkPaint* paint,
- SkRect* rect,
- int length) const
-{
- setupPaintCommon(paint);
- float width = m_state->m_strokeThickness;
-
- // This allows dashing and dotting to work properly for hairline strokes.
- if (width == 0)
- width = 1;
-
- paint->setColor(m_state->applyAlpha(m_state->m_strokeColor));
- paint->setStyle(SkPaint::kStroke_Style);
- paint->setStrokeWidth(SkFloatToScalar(width));
- paint->setStrokeCap(m_state->m_lineCap);
- paint->setStrokeJoin(m_state->m_lineJoin);
- paint->setStrokeMiter(SkFloatToScalar(m_state->m_miterLimit));
-
- if (rect != 0 && (static_cast<int>(roundf(width)) & 1))
- rect->inset(-SK_ScalarHalf, -SK_ScalarHalf);
-
- if (m_state->m_dash) {
- paint->setPathEffect(m_state->m_dash);
- } else {
- switch (m_state->m_strokeStyle) {
- case WebCore::NoStroke:
- case WebCore::SolidStroke:
- break;
- case WebCore::DashedStroke:
- width = m_state->m_dashRatio * width;
- // Fall through.
- case WebCore::DottedStroke:
- SkScalar dashLength;
- if (length) {
- // Determine about how many dashes or dots we should have.
- int numDashes = length / roundf(width);
- if (!(numDashes & 1))
- numDashes++; // Make it odd so we end on a dash/dot.
- // Use the number of dashes to determine the length of a
- // dash/dot, which will be approximately width
- dashLength = SkScalarDiv(SkIntToScalar(length),
- SkIntToScalar(numDashes));
- } else {
- dashLength = SkFloatToScalar(width);
- }
- SkScalar intervals[2] = { dashLength, dashLength };
- paint->setPathEffect(
- new SkDashPathEffect(intervals, 2, 0))->unref();
- }
- }
- return width;
-}
-
-void PlatformContextSkia::setDrawLooper(SkDrawLooper* dl)
-{
- SkRefCnt_SafeAssign(m_state->m_looper, dl);
-}
-
-void PlatformContextSkia::setMiterLimit(float ml)
-{
- m_state->m_miterLimit = ml;
-}
-
-void PlatformContextSkia::setAlpha(float alpha)
-{
- m_state->m_alpha = alpha;
-}
-
-void PlatformContextSkia::setLineCap(SkPaint::Cap lc)
-{
- m_state->m_lineCap = lc;
-}
-
-void PlatformContextSkia::setLineJoin(SkPaint::Join lj)
-{
- m_state->m_lineJoin = lj;
-}
-
-void PlatformContextSkia::setPorterDuffMode(SkPorterDuff::Mode pdm)
-{
- m_state->m_porterDuffMode = pdm;
-}
-
-void PlatformContextSkia::setFillColor(SkColor color)
-{
- m_state->m_fillColor = color;
-}
-
-SkDrawLooper* PlatformContextSkia::getDrawLooper() const
-{
- return m_state->m_looper;
-}
-
-WebCore::StrokeStyle PlatformContextSkia::getStrokeStyle() const
-{
- return m_state->m_strokeStyle;
-}
-
-void PlatformContextSkia::setStrokeStyle(WebCore::StrokeStyle strokestyle)
-{
- m_state->m_strokeStyle = strokestyle;
-}
-
-void PlatformContextSkia::setStrokeColor(SkColor strokecolor)
-{
- m_state->m_strokeColor = strokecolor;
-}
-
-float PlatformContextSkia::getStrokeThickness() const
-{
- return m_state->m_strokeThickness;
-}
-
-void PlatformContextSkia::setStrokeThickness(float thickness)
-{
- m_state->m_strokeThickness = thickness;
-}
-
-int PlatformContextSkia::getTextDrawingMode() const
-{
- return m_state->m_textDrawingMode;
-}
-
-void PlatformContextSkia::setTextDrawingMode(int mode)
-{
- // cTextClip is never used, so we assert that it isn't set:
- // https://bugs.webkit.org/show_bug.cgi?id=21898
- ASSERT((mode & WebCore::cTextClip) == 0);
- m_state->m_textDrawingMode = mode;
-}
-
-void PlatformContextSkia::setUseAntialiasing(bool enable)
-{
- m_state->m_useAntialiasing = enable;
-}
-
-SkColor PlatformContextSkia::fillColor() const
-{
- return m_state->m_fillColor;
-}
-
-void PlatformContextSkia::beginPath()
-{
- m_path.reset();
-}
-
-void PlatformContextSkia::addPath(const SkPath& path)
-{
- m_path.addPath(path);
-}
-
-void PlatformContextSkia::setFillRule(SkPath::FillType fr)
-{
- m_path.setFillType(fr);
-}
-
-void PlatformContextSkia::setGradient(SkShader* gradient)
-{
- if (gradient != m_state->m_gradient) {
- m_state->m_gradient->safeUnref();
- m_state->m_gradient = gradient;
- }
-}
-
-void PlatformContextSkia::setPattern(SkShader* pattern)
-{
- if (pattern != m_state->m_pattern) {
- m_state->m_pattern->safeUnref();
- m_state->m_pattern = pattern;
- }
-}
-
-void PlatformContextSkia::setDashPathEffect(SkDashPathEffect* dash)
-{
- if (dash != m_state->m_dash) {
- m_state->m_dash->safeUnref();
- m_state->m_dash = dash;
- }
-}
-
-void PlatformContextSkia::paintSkPaint(const SkRect& rect,
- const SkPaint& paint)
-{
- m_canvas->drawRect(rect, paint);
-}
-
-const SkBitmap* PlatformContextSkia::bitmap() const
-{
- return &m_canvas->getDevice()->accessBitmap(false);
-}
-
-bool PlatformContextSkia::IsPrinting()
-{
- return m_canvas->getTopPlatformDevice().IsVectorial();
-}
diff --git a/webkit/port/platform/graphics/skia/PlatformContextSkia.h b/webkit/port/platform/graphics/skia/PlatformContextSkia.h
deleted file mode 100644
index b9755b4..0000000
--- a/webkit/port/platform/graphics/skia/PlatformContextSkia.h
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2008, 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 PlatformContextSkia_h
-#define PlatformContextSkia_h
-
-
-#include "SkDashPathEffect.h"
-#include "SkDrawLooper.h"
-#include "SkDeque.h"
-#include "skia/ext/platform_canvas.h"
-#include "SkPaint.h"
-#include "SkPath.h"
-
-#include "GraphicsContext.h"
-#include "wtf/Vector.h"
-
-typedef struct _GdkDrawable GdkSkia;
-
-// This class holds the platform-specific state for GraphicsContext. We put
-// most of our Skia wrappers on this class. In theory, a lot of this stuff could
-// be moved to GraphicsContext directly, except that some code external to this
-// would like to poke at our graphics layer as well (like the Image and Font
-// stuff, which needs some amount of our wrappers and state around SkCanvas).
-//
-// So in general, this class uses just Skia types except when there's no easy
-// conversion. GraphicsContext is responsible for converting the WebKit types to
-// Skia types and setting up the eventual call to the Skia functions.
-//
-// This class then keeps track of all the current Skia state. WebKit expects
-// that the graphics state that is pushed and popped by save() and restore()
-// includes things like colors and pen styles. Skia does this differently, where
-// push and pop only includes transforms and bitmaps, and the application is
-// responsible for managing the painting state which is store in separate
-// SkPaint objects. This class provides the adaptor that allows the painting
-// state to be pushed and popped along with the bitmap.
-class PlatformContextSkia {
-public:
- // For printing, there shouldn't be any canvas. canvas can be NULL. If you
- // supply a NULL canvas, you can also call setCanvas later.
- PlatformContextSkia(skia::PlatformCanvas* canvas);
- ~PlatformContextSkia();
-
- // Sets the canvas associated with this context. Use when supplying NULL
- // to the constructor.
- void setCanvas(skia::PlatformCanvas* canvas);
-
- void save();
- void restore();
-
- // Sets up the common flags on a paint for antialiasing, effects, etc.
- // This is implicitly called by setupPaintFill and setupPaintStroke, but
- // you may wish to call it directly sometimes if you don't want that other
- // behavior.
- void setupPaintCommon(SkPaint* paint) const;
-
- // Sets up the paint for the current fill style.
- void setupPaintForFilling(SkPaint* paint) const;
-
- // Sets up the paint for stroking. Returns an int representing the width of
- // the pen, or 1 if the pen's width is 0 if a non-zero length is provided,
- // the number of dashes/dots on a dashed/dotted line will be adjusted to
- // start and end that length with a dash/dot.
- float setupPaintForStroking(SkPaint* paint, SkRect* rect, int length) const;
-
- // State setting functions.
- void setDrawLooper(SkDrawLooper* dl); // Note: takes an additional ref.
- void setMiterLimit(float ml);
- void setAlpha(float alpha);
- void setLineCap(SkPaint::Cap lc);
- void setLineJoin(SkPaint::Join lj);
- void setFillRule(SkPath::FillType fr);
- void setPorterDuffMode(SkPorterDuff::Mode pdm);
- void setFillColor(SkColor color);
- void setStrokeStyle(WebCore::StrokeStyle strokestyle);
- void setStrokeColor(SkColor strokecolor);
- void setStrokeThickness(float thickness);
- void setTextDrawingMode(int mode);
- void setUseAntialiasing(bool enable);
- void setGradient(SkShader*);
- void setPattern(SkShader*);
- void setDashPathEffect(SkDashPathEffect*);
-
- SkDrawLooper* getDrawLooper() const;
- WebCore::StrokeStyle getStrokeStyle() const;
- float getStrokeThickness() const;
- int getTextDrawingMode() const;
-
- // Paths.
- void beginPath();
- void addPath(const SkPath& path);
- const SkPath* currentPath() const { return &m_path; }
-
- SkColor fillColor() const;
-
- skia::PlatformCanvas* canvas() { return m_canvas; }
-
- // TODO(brettw) why is this in this class?
- void drawRect(SkRect rect);
-
- // TODO(maruel): I'm still unsure how I will serialize this call.
- void paintSkPaint(const SkRect& rect, const SkPaint& paint);
-
- const SkBitmap* bitmap() const;
-
- // Returns the canvas used for painting, NOT guaranteed to be non-NULL.
- //
- // Warning: This function is deprecated so the users are reminded that they
- // should use this layer of indirection instead of using the canvas
- // directly. This is to help with the eventual serialization.
- skia::PlatformCanvas* canvas() const;
-
- // Returns if the context is a printing context instead of a display
- // context. Bitmap shouldn't be resampled when printing to keep the best
- // possible quality.
- bool IsPrinting();
-
-#if defined(__linux__)
- GdkSkia* gdk_skia() const { return m_gdkskia; }
-#endif
-
-private:
- // Defines drawing style.
- struct State;
-
- // NULL indicates painting is disabled. Never delete this object.
- skia::PlatformCanvas* m_canvas;
-
- // States stack. Enables local drawing state change with save()/restore()
- // calls.
- WTF::Vector<State> m_stateStack;
- // Pointer to the current drawing state. This is a cached value of
- // mStateStack.back().
- State* m_state;
-
- // Current path.
- SkPath m_path;
-
- // Disallow these.
- PlatformContextSkia(const PlatformContextSkia&);
- void operator=(const PlatformContextSkia&);
-
-#if defined(__linux__)
- // A pointer to a GDK Drawable wrapping of this Skia canvas
- GdkSkia* m_gdkskia;
-#endif
-};
-
-#endif // PlatformContextSkia_h
diff --git a/webkit/port/platform/graphics/skia/PlatformGraphics.h b/webkit/port/platform/graphics/skia/PlatformGraphics.h
deleted file mode 100644
index 6669dae..0000000
--- a/webkit/port/platform/graphics/skia/PlatformGraphics.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PlatformGraphics_d
-#define PlatformGraphics_d
-
-typedef class SkShader* PlatformGradient;
-typedef class SkShader* PlatformPattern;
-
-#endif
-
-
diff --git a/webkit/port/platform/graphics/skia/SkiaFontWin.cpp b/webkit/port/platform/graphics/skia/SkiaFontWin.cpp
deleted file mode 100644
index 28ac5ab..0000000
--- a/webkit/port/platform/graphics/skia/SkiaFontWin.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <windows.h>
-
-#include "WTF/ListHashSet.h"
-#include "WTF/Vector.h"
-
-#include "SkiaFontWin.h"
-
-#include "SkCanvas.h"
-#include "SkPaint.h"
-
-namespace WebCore {
-
-namespace {
-
-struct CachedOutlineKey {
- CachedOutlineKey() : font(NULL), glyph(0), path(NULL) {}
- CachedOutlineKey(HFONT f, WORD g) : font(f), glyph(g), path(NULL) {}
-
- HFONT font;
- WORD glyph;
-
- // The lifetime of this pointer is managed externally to this class. Be sure
- // to call DeleteOutline to remove items.
- SkPath* path;
-};
-
-const bool operator==(const CachedOutlineKey& a, const CachedOutlineKey& b)
-{
- return a.font == b.font && a.glyph == b.glyph;
-}
-
-struct CachedOutlineKeyHash {
- static unsigned hash(const CachedOutlineKey& key)
- {
- unsigned keyBytes;
- memcpy(&keyBytes, &key.font, sizeof(unsigned));
- return keyBytes + key.glyph;
- }
-
- static unsigned equal(const CachedOutlineKey& a,
- const CachedOutlineKey& b)
- {
- return a.font == b.font && a.glyph == b.glyph;
- }
-
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-typedef ListHashSet<CachedOutlineKey, CachedOutlineKeyHash> OutlineCache;
-OutlineCache outlineCache;
-
-// The global number of glyph outlines we'll cache.
-const int outlineCacheSize = 256;
-
-inline FIXED SkScalarToFIXED(SkScalar x)
-{
- FIXED fixed;
- SkFixed skFixed = SkScalarToFixed(x);
- memcpy(&fixed, &skFixed, sizeof(FIXED));
- return fixed;
-}
-
-inline SkScalar FIXEDToSkScalar(FIXED fixed)
-{
- SkFixed skFixed;
- memcpy(&skFixed, &fixed, sizeof(SkFixed));
- return SkFixedToScalar(skFixed);
-}
-
-// Removes the given key from the cached outlines, also deleting the path.
-void DeleteOutline(OutlineCache::iterator deleteMe)
-{
- delete deleteMe->path;
- outlineCache.remove(deleteMe);
-}
-
-void AddPolyCurveToPath(const TTPOLYCURVE* polyCurve, SkPath* path)
-{
- switch (polyCurve->wType) {
- case TT_PRIM_LINE:
- for (WORD i = 0; i < polyCurve->cpfx; i++) {
- path->lineTo(FIXEDToSkScalar(polyCurve->apfx[i].x),
- -FIXEDToSkScalar(polyCurve->apfx[i].y));
- }
- break;
-
- case TT_PRIM_QSPLINE:
- // FIXME(brettw) doesn't this duplicate points if we do the loop > once?
- for (WORD i = 0; i < polyCurve->cpfx - 1; i++) {
- SkScalar bx = FIXEDToSkScalar(polyCurve->apfx[i].x);
- SkScalar by = FIXEDToSkScalar(polyCurve->apfx[i].y);
-
- SkScalar cx = FIXEDToSkScalar(polyCurve->apfx[i + 1].x);
- SkScalar cy = FIXEDToSkScalar(polyCurve->apfx[i + 1].y);
- if (i < polyCurve->cpfx - 2) {
- // We're not the last point, compute C.
- cx = SkScalarAve(bx, cx);
- cy = SkScalarAve(by, cy);
- }
-
- // Need to flip the y coordinates since the font's coordinate system is
- // flipped from ours vertically.
- path->quadTo(bx, -by, cx, -cy);
- }
- break;
-
- case TT_PRIM_CSPLINE:
- // FIXME
- break;
- }
-}
-
-// The size of the glyph outline buffer.
-const int glyphPathBufferSize = 4096;
-
-// Fills the given SkPath with the outline for the given glyph index. The font
-// currently selected into the given DC is used. Returns true on success.
-bool GetPathForGlyph(HDC dc, WORD glyph, SkPath* path)
-{
- char buffer[glyphPathBufferSize];
- GLYPHMETRICS gm;
- MAT2 mat = {{0, 1}, {0, 0}, {0, 0}, {0, 1}}; // Each one is (fract,value).
-
- DWORD totalSize = GetGlyphOutlineW(dc, glyph, GGO_GLYPH_INDEX | GGO_NATIVE,
- &gm, glyphPathBufferSize, buffer, &mat);
- if (totalSize == GDI_ERROR)
- return false;
-
- const char* curGlyph = buffer;
- const char* endGlyph = &buffer[totalSize];
- while (curGlyph < endGlyph) {
- const TTPOLYGONHEADER* polyHeader =
- reinterpret_cast<const TTPOLYGONHEADER*>(curGlyph);
- path->moveTo(FIXEDToSkScalar(polyHeader->pfxStart.x),
- -FIXEDToSkScalar(polyHeader->pfxStart.y));
-
- const char* curPoly = curGlyph + sizeof(TTPOLYGONHEADER);
- const char* endPoly = curGlyph + polyHeader->cb;
- while (curPoly < endPoly) {
- const TTPOLYCURVE* polyCurve =
- reinterpret_cast<const TTPOLYCURVE*>(curPoly);
- AddPolyCurveToPath(polyCurve, path);
- curPoly += sizeof(WORD) * 2 + sizeof(POINTFX) * polyCurve->cpfx;
- }
- curGlyph += polyHeader->cb;
- }
-
- path->close();
- return true;
-}
-
-// Returns a SkPath corresponding to the give glyph in the given font. The font
-// should be selected into the given DC. The returned path is owned by the
-// hashtable. Returns NULL on error.
-const SkPath* GetCachedPathForGlyph(HDC hdc, HFONT font, WORD glyph)
-{
- CachedOutlineKey key(font, glyph);
- OutlineCache::iterator found = outlineCache.find(key);
- if (found != outlineCache.end()) {
- // Keep in MRU order by removing & reinserting the value.
- key = *found;
- outlineCache.remove(found);
- outlineCache.add(key);
- return key.path;
- }
-
- key.path = new SkPath;
- if (!GetPathForGlyph(hdc, glyph, key.path))
- return NULL;
-
- if (outlineCache.size() > outlineCacheSize) {
- // The cache is too big, find the oldest value (first in the list).
- DeleteOutline(outlineCache.begin());
- }
-
- outlineCache.add(key);
- return key.path;
-}
-
-} // namespace
-
-bool SkiaDrawText(HFONT hfont,
- SkCanvas* canvas,
- const SkPoint& point,
- SkPaint* paint,
- const WORD* glyphs,
- const int* advances,
- int num_glyphs)
-{
- HDC dc = GetDC(0);
- HGDIOBJ old_font = SelectObject(dc, hfont);
-
- canvas->save();
- canvas->translate(point.fX, point.fY);
-
- for (int i = 0; i < num_glyphs; i++) {
- const SkPath* path = GetCachedPathForGlyph(dc, hfont, glyphs[i]);
- if (!path)
- return false;
- canvas->drawPath(*path, *paint);
- canvas->translate(advances[i], 0);
- }
-
- canvas->restore();
-
- SelectObject(dc, old_font);
- ReleaseDC(0, dc);
- return true;
-}
-
-/* TODO(brettw) finish this implementation
-bool SkiaDrawComplexText(HFONT font,
- SkCanvas* canvas,
- const SkPoint& point,
- SkPaint* paint
- UINT fuOptions,
- const SCRIPT_ANALYSIS* psa,
- const WORD* pwGlyphs,
- int cGlyphs,
- const int* advances,
- const int* justifies,
- const GOFFSET* glyph_offsets)
-{
- HDC dc = GetDC(0);
- HGDIOBJ old_font = SelectObject(dc, hfont);
-
- canvas->save();
- canvas->translate(point.fX, point.fY);
-
- for (int i = 0; i < cGlyphs; i++) {
- canvas->translate(glyph_offsets[i].du, glyph_offsets[i].dv);
-
-
-
-
- // Undo the offset for this glyph.
- canvas->translate(-glyph_offsets[i].du, -glyph_offsets[i].dv);
-
- // And advance to where we're drawing the next one. We use the justifies
- // run since that is the justified advances for each character, rather than
- // the adnvaces one.
- canvas->translate(justifies[i], 0);
- }
-
- canvas->restore();
-
- SelectObject(dc, old_font);
- ReleaseDC(0, dc);
-}*/
-
-void RemoveFontFromSkiaFontWinCache(HFONT hfont)
-{
- // ListHashSet isn't the greatest structure for deleting stuff out of, but
- // removing entries will be relatively rare (we don't remove fonts much, nor
- // do we draw out own glyphs using these routines much either).
- //
- // We keep a list of all glyphs we're removing which we do in a separate
- // pass.
- Vector<CachedOutlineKey> outlinesToDelete;
- for (OutlineCache::iterator i = outlineCache.begin();
- i != outlineCache.end(); ++i)
- outlinesToDelete.append(*i);
-
- for (Vector<CachedOutlineKey>::iterator i = outlinesToDelete.begin();
- i != outlinesToDelete.end(); ++i)
- DeleteOutline(outlineCache.find(*i));
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/SkiaFontWin.h b/webkit/port/platform/graphics/skia/SkiaFontWin.h
deleted file mode 100644
index 9e950bd0..0000000
--- a/webkit/port/platform/graphics/skia/SkiaFontWin.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SkiaFont_Win_h
-#define SkiaFont_Win_h
-
-#include <windows.h>
-#include <usp10.h>
-
-class SkCanvas;
-class SkPaint;
-struct SkPoint;
-
-// This file provices Skia equivalents to Windows text drawing functions. They
-// will get the outlines from Windows and draw then using Skia using the given
-// parameters in the paint arguments. This allows more complex effects and
-// transforms to be drawn than Windows allows.
-//
-// These functions will be significantly slower than Windows GDI, and the text
-// will look different (no ClearType), so use only when necessary.
-//
-// When you call a Skia* text drawing function, various glyph outlines will be
-// cached. As a result, you should call RemoveFontFromSkiaFontWinCache when
-// the font is destroyed so that the cache does not outlive the font (since the
-// HFONTs are recycled).
-namespace WebCore {
-
-// Analog of the Windows GDI function DrawText, except using the given SkPaint
-// attributes for the text. See above for more.
-//
-// Returns true of the text was drawn successfully. False indicates an error
-// from Windows.
-bool SkiaDrawText(HFONT hfont,
- SkCanvas* canvas,
- const SkPoint& point,
- SkPaint* paint,
- const WORD* glyphs,
- const int* advances,
- int num_glyphs);
-
-// This mirrors the features of ScriptTextOut.
-/* TODO(brettw) finish this implementation.
-bool SkiaDrawComplexText(HFONT font,
- SkCanvas* canvas,
- const SkPoint& point,
- SkPaint* paint,
- UINT fuOptions,
- const SCRIPT_ANALYSIS* psa,
- const WORD* pwGlyphs,
- int cGlyphs,
- const int* advances,
- const int* justifies,
- const GOFFSET* glyph_offsets);
-*/
-
-// Removes any cached glyphs from the outline cache corresponding to the given
-// font handle.
-void RemoveFontFromSkiaFontWinCache(HFONT hfont);
-
-} // namespace WebCore
-
-#endif // SkiaFont_Win_h
diff --git a/webkit/port/platform/graphics/skia/SkiaUtils.cpp b/webkit/port/platform/graphics/skia/SkiaUtils.cpp
deleted file mode 100644
index 56e2b04..0000000
--- a/webkit/port/platform/graphics/skia/SkiaUtils.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright (c) 2008, 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 "SkiaUtils.h"
-
-#include "SharedBuffer.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-#include "SkMatrix.h"
-#include "SkRegion.h"
-
-namespace WebCore {
-
-void WebCorePointToSkiaPoint(const WebCore::FloatPoint& src, SkPoint* dst)
-{
- dst->set(WebCoreFloatToSkScalar(src.x()), WebCoreFloatToSkScalar(src.y()));
-}
-
-void WebCoreRectToSkiaRect(const WebCore::IntRect& src, SkRect* dst)
-{
- dst->set(SkIntToScalar(src.x()),
- SkIntToScalar(src.y()),
- SkIntToScalar(src.x() + src.width()),
- SkIntToScalar(src.y() + src.height()));
-}
-
-void WebCoreRectToSkiaRect(const WebCore::IntRect& src, SkIRect* dst)
-{
- dst->set(src.x(),
- src.y(),
- src.x() + src.width(),
- src.y() + src.height());
-}
-
-void WebCoreRectToSkiaRect(const WebCore::FloatRect& src, SkRect* dst)
-{
- dst->set(WebCoreFloatToSkScalar(src.x()),
- WebCoreFloatToSkScalar(src.y()),
- WebCoreFloatToSkScalar(src.x() + src.width()),
- WebCoreFloatToSkScalar(src.y() + src.height()));
-}
-
-void WebCoreRectToSkiaRect(const WebCore::FloatRect& src, SkIRect* dst)
-{
- dst->set(SkScalarRound(WebCoreFloatToSkScalar(src.x())),
- SkScalarRound(WebCoreFloatToSkScalar(src.y())),
- SkScalarRound(WebCoreFloatToSkScalar(src.x() + src.width())),
- SkScalarRound(WebCoreFloatToSkScalar(src.y() + src.height())));
-}
-
-static const struct CompositOpToPorterDuffMode {
- uint8_t mCompositOp;
- uint8_t mPorterDuffMode;
-} gMapCompositOpsToPorterDuffModes[] = {
- { WebCore::CompositeClear, SkPorterDuff::kClear_Mode },
- { WebCore::CompositeCopy, SkPorterDuff::kSrcOver_Mode }, // TODO
- { WebCore::CompositeSourceOver, SkPorterDuff::kSrcOver_Mode },
- { WebCore::CompositeSourceIn, SkPorterDuff::kSrcIn_Mode },
- { WebCore::CompositeSourceOut, SkPorterDuff::kSrcOut_Mode },
- { WebCore::CompositeSourceAtop, SkPorterDuff::kSrcATop_Mode },
- { WebCore::CompositeDestinationOver, SkPorterDuff::kDstOver_Mode },
- { WebCore::CompositeDestinationIn, SkPorterDuff::kDstIn_Mode },
- { WebCore::CompositeDestinationOut, SkPorterDuff::kDstOut_Mode },
- { WebCore::CompositeDestinationAtop, SkPorterDuff::kDstATop_Mode },
- { WebCore::CompositeXOR, SkPorterDuff::kXor_Mode },
- { WebCore::CompositePlusDarker, SkPorterDuff::kDarken_Mode },
- { WebCore::CompositeHighlight, SkPorterDuff::kSrcOver_Mode }, // TODO
- { WebCore::CompositePlusLighter, SkPorterDuff::kLighten_Mode }
-};
-
-SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(WebCore::CompositeOperator op)
-{
- const CompositOpToPorterDuffMode* table = gMapCompositOpsToPorterDuffModes;
-
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToPorterDuffModes); i++) {
- if (table[i].mCompositOp == op) {
- return (SkPorterDuff::Mode)table[i].mPorterDuffMode;
- }
- }
-
- SkDEBUGF(("GraphicsContext::setCompositeOperation uknown CompositOperator %d\n", op));
- return SkPorterDuff::kSrcOver_Mode; // fall-back
-}
-
-static U8CPU InvScaleByte(U8CPU component, uint32_t scale)
-{
- SkASSERT(component == (uint8_t)component);
- return (component * scale + 0x8000) >> 16;
-}
-
-SkColor SkPMColorToColor(SkPMColor pm)
-{
- if (0 == pm)
- return 0;
-
- unsigned a = SkGetPackedA32(pm);
- uint32_t scale = (255 << 16) / a;
-
- return SkColorSetARGB(a,
- InvScaleByte(SkGetPackedR32(pm), scale),
- InvScaleByte(SkGetPackedG32(pm), scale),
- InvScaleByte(SkGetPackedB32(pm), scale));
-}
-
-WebCore::Color SkPMColorToWebCoreColor(SkPMColor pm)
-{
- return SkPMColorToColor(pm);
-}
-
-void IntersectRectAndRegion(const SkRegion& region, const SkRect& src_rect,
- SkRect* dest_rect) {
- // The cliperator requires an int rect, so we round out.
- SkIRect src_rect_rounded;
- src_rect.roundOut(&src_rect_rounded);
-
- // The Cliperator will iterate over a bunch of rects where our transformed
- // rect and the clipping region (which may be non-square) overlap.
- SkRegion::Cliperator cliperator(region, src_rect_rounded);
- if (cliperator.done()) {
- dest_rect->setEmpty();
- return;
- }
-
- // Get the union of all visible rects in the clip that overlap our bitmap.
- SkIRect cur_visible_rect = cliperator.rect();
- cliperator.next();
- while (!cliperator.done()) {
- cur_visible_rect.join(cliperator.rect());
- cliperator.next();
- }
-
- dest_rect->set(cur_visible_rect);
-}
-
-void ClipRectToCanvas(const SkCanvas& canvas, const SkRect& src_rect,
- SkRect* dest_rect) {
- // Translate into the canvas' coordinate space. This is where the clipping
- // region applies.
- SkRect transformed_src;
- canvas.getTotalMatrix().mapRect(&transformed_src, src_rect);
-
- // Do the intersection.
- SkRect transformed_dest;
- IntersectRectAndRegion(canvas.getTotalClip(), transformed_src,
- &transformed_dest);
-
- // Now transform it back into world space.
- SkMatrix inverse_transform;
- canvas.getTotalMatrix().invert(&inverse_transform);
- inverse_transform.mapRect(dest_rect, transformed_dest);
-}
-
-bool SkPathContainsPoint(SkPath* orig_path, WebCore::FloatPoint point, SkPath::FillType ft)
-{
- SkRegion rgn, clip;
-
- SkPath::FillType orig_ft = orig_path->getFillType(); // save
-
- const SkPath* path = orig_path;
- SkPath scaled_path;
- int scale = 1;
-
- SkRect bounds;
- orig_path->computeBounds(&bounds, SkPath::kFast_BoundsType);
-
- // We can immediately return false if the point is outside the bounding rect
- if (!bounds.contains(SkFloatToScalar(point.x()), SkFloatToScalar(point.y())))
- return false;
-
- orig_path->setFillType(ft);
-
- // Skia has trouble with coordinates close to the max signed 16-bit values
- // If we have those, we need to scale.
- //
- // TODO: remove this code once Skia is patched to work properly with large
- // values
- const SkScalar kMaxCoordinate = SkIntToScalar(1<<15);
- SkScalar biggest_coord = std::max(std::max(std::max(
- bounds.fRight, bounds.fBottom), -bounds.fLeft), -bounds.fTop);
-
- if (biggest_coord > kMaxCoordinate) {
- scale = SkScalarCeil(SkScalarDiv(biggest_coord, kMaxCoordinate));
-
- SkMatrix m;
- m.setScale(SkScalarInvert(SkIntToScalar(scale)),
- SkScalarInvert(SkIntToScalar(scale)));
- orig_path->transform(m, &scaled_path);
- path = &scaled_path;
- }
-
- int x = (int)floorf(point.x() / scale);
- int y = (int)floorf(point.y() / scale);
- clip.setRect(x, y, x + 1, y + 1);
-
- bool contains = rgn.setPath(*path, clip);
-
- orig_path->setFillType(orig_ft); // restore
- return contains;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/graphics/skia/SkiaUtils.h b/webkit/port/platform/graphics/skia/SkiaUtils.h
deleted file mode 100644
index 4373e7e..0000000
--- a/webkit/port/platform/graphics/skia/SkiaUtils.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file declares helper routines for using Skia in WebKit.
-
-#ifndef SkiaUtils_h
-#define SkiaUtils_h
-
-#include <wtf/MathExtras.h>
-#include "GraphicsContext.h"
-#include "SkPath.h"
-#include "SkPorterDuff.h"
-
-class SkCanvas;
-class SkRegion;
-
-namespace WebCore {
-
-// Converts a WebCore composit operation (WebCore::Composite*) to the
-// corresponding Skia type.
-SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(WebCore::CompositeOperator);
-
-// move this guy into SkColor.h
-SkColor SkPMColorToColor(SkPMColor pm);
-
-// Converts Android colors to WebKit ones.
-WebCore::Color SkPMColorToWebCoreColor(SkPMColor pm);
-
-// Skia has problems when passed infinite, etc floats, filter them to 0.
-inline SkScalar WebCoreFloatToSkScalar(const float& f) {
- return SkFloatToScalar(isfinite(f) ? f : 0);
-}
-
-inline SkScalar WebCoreDoubleToSkScalar(const double& d) {
- return SkDoubleToScalar(isfinite(d) ? d : 0);
-}
-
-// Intersects the given source rect with the region, returning the smallest
-// rectangular region that encompases the result.
-//
-// src_rect and dest_rect can be the same.
-void IntersectRectAndRegion(const SkRegion& region, const SkRect& src_rect,
- SkRect* dest_rect);
-
-// Computes the smallest rectangle that, which when drawn to the given canvas,
-// will cover the same area as the source rectangle. It will clip to the canvas'
-// clip, doing the necessary coordinate transforms.
-//
-// src_rect and dest_rect can be the same.
-void ClipRectToCanvas(const SkCanvas& canvas, const SkRect& src_rect,
- SkRect* dest_rect);
-
-// Determine if a given WebKit point is contained in a path
-bool SkPathContainsPoint(SkPath* orig_path, WebCore::FloatPoint point, SkPath::FillType ft);
-
-} // namespace WebCore
-
-#endif // SkiaUtils_h
diff --git a/webkit/port/platform/network/chromium/AuthenticationChallenge.h b/webkit/port/platform/network/chromium/AuthenticationChallenge.h
deleted file mode 100644
index b1db6cf..0000000
--- a/webkit/port/platform/network/chromium/AuthenticationChallenge.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Google, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 AuthenticationChallenge_h
-#define AuthenticationChallenge_h
-
-#include "AuthenticationChallengeBase.h"
-#include "ResourceHandle.h"
-
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class ResourceHandle;
-
-class AuthenticationChallenge : public AuthenticationChallengeBase {
-public:
- AuthenticationChallenge() {}
- AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error);
-
- ResourceHandle* sourceHandle() const { return m_sourceHandle.get(); }
-
-private:
- friend class AuthenticationChallengeBase;
- static bool platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b);
-
- RefPtr<ResourceHandle> m_sourceHandle;
-};
-
-}
-
-#endif
diff --git a/webkit/port/platform/network/chromium/AuthenticationChallengeChromium.cpp b/webkit/port/platform/network/chromium/AuthenticationChallengeChromium.cpp
deleted file mode 100644
index fb3c5a4..0000000
--- a/webkit/port/platform/network/chromium/AuthenticationChallengeChromium.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2008 Google, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "AuthenticationChallenge.h"
-
-namespace WebCore {
-
-bool AuthenticationChallenge::platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b)
-{
- return true;
-}
-
-} // namespace WebCore
diff --git a/webkit/port/platform/network/chromium/CookieJarChromium.cpp b/webkit/port/platform/network/chromium/CookieJarChromium.cpp
deleted file mode 100644
index ac5b622..0000000
--- a/webkit/port/platform/network/chromium/CookieJarChromium.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2008 Google, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "CookieJar.h"
-
-#include "ChromiumBridge.h"
-#include "Document.h"
-
-namespace WebCore {
-
-void setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value)
-{
- // We ignore the policyURL and compute it directly ourselves to ensure
- // consistency with the cookies() method below.
- ChromiumBridge::setCookies(url, document->policyBaseURL(), value);
-}
-
-String cookies(const Document* document, const KURL& url)
-{
- return ChromiumBridge::cookies(url, document->policyBaseURL());
-}
-
-bool cookiesEnabled(const Document*)
-{
- // FIXME: For now just assume cookies are always on.
- return true;
-}
-
-}
diff --git a/webkit/port/platform/network/chromium/DNSChromium.cpp b/webkit/port/platform/network/chromium/DNSChromium.cpp
deleted file mode 100644
index d28a155..0000000
--- a/webkit/port/platform/network/chromium/DNSChromium.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2008 Collin Jackson <collinj@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE COMPUTER, INC. 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 "DNS.h"
-
-#include "ChromiumBridge.h"
-
-namespace WebCore {
-
-void prefetchDNS(const String& hostname)
-{
- ChromiumBridge::prefetchDNS(hostname);
-}
-
-}
diff --git a/webkit/port/platform/network/chromium/NetworkStateNotifierChromium.cpp b/webkit/port/platform/network/chromium/NetworkStateNotifierChromium.cpp
deleted file mode 100644
index f486ab5..0000000
--- a/webkit/port/platform/network/chromium/NetworkStateNotifierChromium.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2008 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 "NetworkStateNotifier.h"
-
-namespace WebCore {
-
-// Chromium doesn't currently support network state notifications. This causes
-// an extra DLL to get loaded into the renderer which can slow things down a
-// bit. We may want an alternate design.
-
-void NetworkStateNotifier::updateState()
-{
-}
-
-NetworkStateNotifier::NetworkStateNotifier()
- : m_isOnLine(true)
- , m_networkStateChangedFunction(0)
-{
-}
-
-}
diff --git a/webkit/port/platform/network/chromium/NetworkStateNotifierPrivate.h b/webkit/port/platform/network/chromium/NetworkStateNotifierPrivate.h
deleted file mode 100644
index 5234f40..0000000
--- a/webkit/port/platform/network/chromium/NetworkStateNotifierPrivate.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2008, 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 NetworkStateNotifierPrivate_h__
-#define NetworkStateNotifierPrivate_h__
-
-namespace WebCore {
-
-struct NetworkStateNotifierPrivate {};
-
-}
-
-#endif
diff --git a/webkit/port/platform/network/chromium/ResourceError.h b/webkit/port/platform/network/chromium/ResourceError.h
deleted file mode 100644
index a71b302..0000000
--- a/webkit/port/platform/network/chromium/ResourceError.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Google, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 ResourceError_h
-#define ResourceError_h
-
-#include "ResourceErrorBase.h"
-
-namespace WebCore {
-
-class ResourceError : public ResourceErrorBase {
-public:
- ResourceError()
- {
- }
-
- ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
- {
- }
-
-private:
- friend class ResourceErrorBase;
-};
-
-} // namespace WebCore
-
-#endif // ResourceError_h_
diff --git a/webkit/port/platform/network/chromium/ResourceRequest.h b/webkit/port/platform/network/chromium/ResourceRequest.h
deleted file mode 100644
index 8e142c68..0000000
--- a/webkit/port/platform/network/chromium/ResourceRequest.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 ResourceRequest_h
-#define ResourceRequest_h
-
-#include "CString.h"
-#include "ResourceRequestBase.h"
-
-namespace WebCore {
-
- class Frame;
-
- class ResourceRequest : public ResourceRequestBase {
- public:
- enum TargetType {
- TargetIsMainFrame,
- TargetIsSubFrame,
- TargetIsSubResource,
- TargetIsObject,
- TargetIsMedia
- };
-
- ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
- , m_frame(0)
- , m_originPid(0)
- , m_targetType(TargetIsSubResource)
- {
- }
-
- ResourceRequest(const KURL& url, const CString& securityInfo)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- , m_frame(0)
- , m_originPid(0)
- , m_targetType(TargetIsSubResource)
- , m_securityInfo(securityInfo)
- {
- }
-
- ResourceRequest(const KURL& url)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- , m_frame(0)
- , m_originPid(0)
- , m_targetType(TargetIsSubResource)
- {
- }
-
- ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy)
- , m_frame(0)
- , m_originPid(0)
- , m_targetType(TargetIsSubResource)
- {
- setHTTPReferrer(referrer);
- }
-
- ResourceRequest()
- : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
- , m_frame(0)
- , m_originPid(0)
- , m_targetType(TargetIsSubResource)
- {
- }
-
- // Provides context for the resource request.
- Frame* frame() const { return m_frame; }
- void setFrame(Frame* frame) { m_frame = frame; }
-
- // What this request is for.
- void setTargetType(TargetType type) { m_targetType = type; }
- TargetType targetType() const { return m_targetType; }
-
- // The origin pid is the process id of the process from which this
- // request originated. In the case of out-of-process plugins, this
- // allows to link back the request to the plugin process (as it is
- // processed through a render view process).
- int originPid() const { return m_originPid; }
- void setOriginPid(int originPid) { m_originPid = originPid; }
-
- // Opaque buffer that describes the security state (including SSL
- // connection state) for the resource that should be reported when the
- // resource has been loaded. This is used to simulate secure
- // connection for request (typically when showing error page, so the
- // error page has the errors of the page that actually failed). Empty
- // string if not a secure connection.
- CString securityInfo() const { return m_securityInfo; }
- void setSecurityInfo(const CString& value) { m_securityInfo = value; }
-
- private:
- friend class ResourceRequestBase;
-
- void doUpdatePlatformRequest() {}
- void doUpdateResourceRequest() {}
-
- Frame* m_frame;
- int m_originPid;
- TargetType m_targetType;
- CString m_securityInfo;
- };
-
-} // namespace WebCore
-
-#endif // ResourceRequest_h
diff --git a/webkit/port/platform/network/chromium/ResourceResponse.h b/webkit/port/platform/network/chromium/ResourceResponse.h
deleted file mode 100644
index c35e048..0000000
--- a/webkit/port/platform/network/chromium/ResourceResponse.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
-/*
- * Copyright (C) 2006 Apple Computer, 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 ResourceResponse_h
-#define ResourceResponse_h
-
-#include "CString.h"
-#include "ResourceResponseBase.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-class ResourceResponse : public ResourceResponseBase {
-public:
- ResourceResponse()
- : ResourceResponseBase(),
- m_isContentFiltered(false)
- {
- }
-
- ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename),
- m_isContentFiltered(false)
- {
- }
-
- const CString& getSecurityInfo() const { return m_securityInfo; }
- void setSecurityInfo(CString securityInfo) {
- m_securityInfo = securityInfo;
- }
-
- bool isContentFiltered() const { return m_isContentFiltered; }
- void setIsContentFiltered(bool isContentFiltered) {
- m_isContentFiltered = isContentFiltered;
- }
-
-private:
- friend class ResourceResponseBase;
-
- // An opaque value that contains some information regarding the security of
- // the connection for this request, such as SSL connection info (empty
- // string if not over HTTPS).
- CString m_securityInfo;
-
- void doUpdateResourceResponse()
- {
- notImplemented();
- }
-
- // Whether the contents for this response has been altered/blocked (usually
- // for security reasons.
- bool m_isContentFiltered;
-};
-
-} // namespace WebCore
-
-#endif // ResourceResponse_h