[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
paroga at webkit.org
paroga at webkit.org
Wed Dec 22 13:31:57 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit b418ba2a12d3e12e16076b277244cee9ce7bd441
Author: paroga at webkit.org <paroga at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Sep 18 20:41:03 2010 +0000
2010-09-18 Patrick Gansterer <paroga at paroga.com>
Reviewed by Darin Adler.
Rename Wince files to WinCE
https://bugs.webkit.org/show_bug.cgi?id=37287
* wtf/unicode/Unicode.h:
* wtf/unicode/wince/UnicodeWinCE.cpp: Copied from JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp.
* wtf/unicode/wince/UnicodeWinCE.h: Copied from JavaScriptCore/wtf/unicode/wince/UnicodeWince.h.
* wtf/unicode/wince/UnicodeWince.cpp: Removed.
* wtf/unicode/wince/UnicodeWince.h: Removed.
* wtf/wince/FastMallocWinCE.h: Copied from JavaScriptCore/wtf/wince/FastMallocWince.h.
* wtf/wince/FastMallocWince.h: Removed.
2010-09-18 Ademar de Souza Reis Jr <ademar.reis at openbossa.org>
Reviewed by Kenneth Rohde Christiansen.
Enable Platform Strategies on Qt
[Qt] Turn on PLATFORM_STRATEGIES
https://bugs.webkit.org/show_bug.cgi?id=45831
* WebCore.pro: Adding/removing implementation files
* platform/qt/Language.cpp: Added, WebCore::defaultLanguage() was
moved from platform/qt/Localizations.cpp
(WebCore::defaultLanguage): Moved from Localizations.cpp
* platform/qt/Localizations.cpp: Removed (code is now inside
WebCoreSupport/WebPlatformStrategies.cpp)
* plugins/qt/PluginDataQt.cpp: Removed (idem)
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67788 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 8ded00c..eb8cf82 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,18 @@
+2010-09-18 Patrick Gansterer <paroga at paroga.com>
+
+ Reviewed by Darin Adler.
+
+ Rename Wince files to WinCE
+ https://bugs.webkit.org/show_bug.cgi?id=37287
+
+ * wtf/unicode/Unicode.h:
+ * wtf/unicode/wince/UnicodeWinCE.cpp: Copied from JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp.
+ * wtf/unicode/wince/UnicodeWinCE.h: Copied from JavaScriptCore/wtf/unicode/wince/UnicodeWince.h.
+ * wtf/unicode/wince/UnicodeWince.cpp: Removed.
+ * wtf/unicode/wince/UnicodeWince.h: Removed.
+ * wtf/wince/FastMallocWinCE.h: Copied from JavaScriptCore/wtf/wince/FastMallocWince.h.
+ * wtf/wince/FastMallocWince.h: Removed.
+
2010-09-18 Ademar de Souza Reis Jr <ademar.reis at openbossa.org>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/JavaScriptCore/wtf/unicode/Unicode.h b/JavaScriptCore/wtf/unicode/Unicode.h
index d59439d..c755c6c 100644
--- a/JavaScriptCore/wtf/unicode/Unicode.h
+++ b/JavaScriptCore/wtf/unicode/Unicode.h
@@ -32,7 +32,7 @@
#elif USE(GLIB_UNICODE)
#include <wtf/unicode/glib/UnicodeGLib.h>
#elif USE(WINCE_UNICODE)
-#include <wtf/unicode/wince/UnicodeWince.h>
+#include <wtf/unicode/wince/UnicodeWinCE.h>
#else
#error "Unknown Unicode implementation"
#endif
diff --git a/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.cpp b/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.cpp
new file mode 100644
index 0000000..b52b05c
--- /dev/null
+++ b/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2006 George Staikos <staikos at kde.org>
+ * Copyright (C) 2006 Alexey Proskuryakov <ap at nypop.com>
+ * Copyright (C) 2007-2009 Torch Mobile, 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 "UnicodeWinCE.h"
+
+#include <wchar.h>
+
+namespace WTF {
+namespace Unicode {
+
+wchar_t toLower(wchar_t c)
+{
+ return towlower(c);
+}
+
+wchar_t toUpper(wchar_t c)
+{
+ return towupper(c);
+}
+
+wchar_t foldCase(wchar_t c)
+{
+ return towlower(c);
+}
+
+bool isPrintableChar(wchar_t c)
+{
+ return !!iswprint(c);
+}
+
+bool isSpace(wchar_t c)
+{
+ return !!iswspace(c);
+}
+
+bool isLetter(wchar_t c)
+{
+ return !!iswalpha(c);
+}
+
+bool isUpper(wchar_t c)
+{
+ return !!iswupper(c);
+}
+
+bool isLower(wchar_t c)
+{
+ return !!iswlower(c);
+}
+
+bool isDigit(wchar_t c)
+{
+ return !!iswdigit(c);
+}
+
+bool isPunct(wchar_t c)
+{
+ return !!iswpunct(c);
+}
+
+bool isAlphanumeric(wchar_t c)
+{
+ return !!iswalnum(c);
+}
+
+int toLower(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError)
+{
+ const UChar* sourceIterator = source;
+ const UChar* sourceEnd = source + sourceLength;
+ UChar* resultIterator = result;
+ UChar* resultEnd = result + resultLength;
+
+ int remainingCharacters = 0;
+ if (sourceLength <= resultLength)
+ while (sourceIterator < sourceEnd)
+ *resultIterator++ = towlower(*sourceIterator++);
+ else
+ while (resultIterator < resultEnd)
+ *resultIterator++ = towlower(*sourceIterator++);
+
+ if (sourceIterator < sourceEnd)
+ remainingCharacters += sourceEnd - sourceIterator;
+ *isError = (remainingCharacters != 0);
+ if (resultIterator < resultEnd)
+ *resultIterator = 0;
+
+ return (resultIterator - result) + remainingCharacters;
+}
+
+int toUpper(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError)
+{
+ const UChar* sourceIterator = source;
+ const UChar* sourceEnd = source + sourceLength;
+ UChar* resultIterator = result;
+ UChar* resultEnd = result + resultLength;
+
+ int remainingCharacters = 0;
+ if (sourceLength <= resultLength)
+ while (sourceIterator < sourceEnd)
+ *resultIterator++ = towupper(*sourceIterator++);
+ else
+ while (resultIterator < resultEnd)
+ *resultIterator++ = towupper(*sourceIterator++);
+
+ if (sourceIterator < sourceEnd)
+ remainingCharacters += sourceEnd - sourceIterator;
+ *isError = (remainingCharacters != 0);
+ if (resultIterator < resultEnd)
+ *resultIterator = 0;
+
+ return (resultIterator - result) + remainingCharacters;
+}
+
+int foldCase(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError)
+{
+ *isError = false;
+ if (resultLength < sourceLength) {
+ *isError = true;
+ return sourceLength;
+ }
+ for (int i = 0; i < sourceLength; ++i)
+ result[i] = foldCase(source[i]);
+ return sourceLength;
+}
+
+wchar_t toTitleCase(wchar_t c)
+{
+ return towupper(c);
+}
+
+Direction direction(UChar32 c)
+{
+ return static_cast<Direction>(UnicodeCE::direction(c));
+}
+
+CharCategory category(unsigned int c)
+{
+ return static_cast<CharCategory>(TO_MASK((__int8) UnicodeCE::category(c)));
+}
+
+DecompositionType decompositionType(UChar32 c)
+{
+ return static_cast<DecompositionType>(UnicodeCE::decompositionType(c));
+}
+
+unsigned char combiningClass(UChar32 c)
+{
+ return UnicodeCE::combiningClass(c);
+}
+
+wchar_t mirroredChar(UChar32 c)
+{
+ return UnicodeCE::mirroredChar(c);
+}
+
+int digitValue(wchar_t c)
+{
+ return UnicodeCE::digitValue(c);
+}
+
+} // namespace Unicode
+} // namespace WTF
diff --git a/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h b/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h
new file mode 100644
index 0000000..8cc9580
--- /dev/null
+++ b/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2006 George Staikos <staikos at kde.org>
+ * Copyright (C) 2006 Alexey Proskuryakov <ap at nypop.com>
+ * Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, 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 WTF_UnicodeWinCE_h
+#define WTF_UnicodeWinCE_h
+
+#include "UnicodeMacrosFromICU.h"
+
+#include "ce_unicode.h"
+
+#define TO_MASK(x) (1 << (x))
+
+namespace WTF {
+
+ namespace Unicode {
+
+ enum Direction {
+ LeftToRight = UnicodeCE::U_LEFT_TO_RIGHT,
+ RightToLeft = UnicodeCE::U_RIGHT_TO_LEFT,
+ EuropeanNumber = UnicodeCE::U_EUROPEAN_NUMBER,
+ EuropeanNumberSeparator = UnicodeCE::U_EUROPEAN_NUMBER_SEPARATOR,
+ EuropeanNumberTerminator = UnicodeCE::U_EUROPEAN_NUMBER_TERMINATOR,
+ ArabicNumber = UnicodeCE::U_ARABIC_NUMBER,
+ CommonNumberSeparator = UnicodeCE::U_COMMON_NUMBER_SEPARATOR,
+ BlockSeparator = UnicodeCE::U_BLOCK_SEPARATOR,
+ SegmentSeparator = UnicodeCE::U_SEGMENT_SEPARATOR,
+ WhiteSpaceNeutral = UnicodeCE::U_WHITE_SPACE_NEUTRAL,
+ OtherNeutral = UnicodeCE::U_OTHER_NEUTRAL,
+ LeftToRightEmbedding = UnicodeCE::U_LEFT_TO_RIGHT_EMBEDDING,
+ LeftToRightOverride = UnicodeCE::U_LEFT_TO_RIGHT_OVERRIDE,
+ RightToLeftArabic = UnicodeCE::U_RIGHT_TO_LEFT_ARABIC,
+ RightToLeftEmbedding = UnicodeCE::U_RIGHT_TO_LEFT_EMBEDDING,
+ RightToLeftOverride = UnicodeCE::U_RIGHT_TO_LEFT_OVERRIDE,
+ PopDirectionalFormat = UnicodeCE::U_POP_DIRECTIONAL_FORMAT,
+ NonSpacingMark = UnicodeCE::U_DIR_NON_SPACING_MARK,
+ BoundaryNeutral = UnicodeCE::U_BOUNDARY_NEUTRAL
+ };
+
+ enum DecompositionType {
+ DecompositionNone = UnicodeCE::U_DT_NONE,
+ DecompositionCanonical = UnicodeCE::U_DT_CANONICAL,
+ DecompositionCompat = UnicodeCE::U_DT_COMPAT,
+ DecompositionCircle = UnicodeCE::U_DT_CIRCLE,
+ DecompositionFinal = UnicodeCE::U_DT_FINAL,
+ DecompositionFont = UnicodeCE::U_DT_FONT,
+ DecompositionFraction = UnicodeCE::U_DT_FRACTION,
+ DecompositionInitial = UnicodeCE::U_DT_INITIAL,
+ DecompositionIsolated = UnicodeCE::U_DT_ISOLATED,
+ DecompositionMedial = UnicodeCE::U_DT_MEDIAL,
+ DecompositionNarrow = UnicodeCE::U_DT_NARROW,
+ DecompositionNoBreak = UnicodeCE::U_DT_NOBREAK,
+ DecompositionSmall = UnicodeCE::U_DT_SMALL,
+ DecompositionSquare = UnicodeCE::U_DT_SQUARE,
+ DecompositionSub = UnicodeCE::U_DT_SUB,
+ DecompositionSuper = UnicodeCE::U_DT_SUPER,
+ DecompositionVertical = UnicodeCE::U_DT_VERTICAL,
+ DecompositionWide = UnicodeCE::U_DT_WIDE,
+ };
+
+ enum CharCategory {
+ NoCategory = 0,
+ Other_NotAssigned = TO_MASK(UnicodeCE::U_GENERAL_OTHER_TYPES),
+ Letter_Uppercase = TO_MASK(UnicodeCE::U_UPPERCASE_LETTER),
+ Letter_Lowercase = TO_MASK(UnicodeCE::U_LOWERCASE_LETTER),
+ Letter_Titlecase = TO_MASK(UnicodeCE::U_TITLECASE_LETTER),
+ Letter_Modifier = TO_MASK(UnicodeCE::U_MODIFIER_LETTER),
+ Letter_Other = TO_MASK(UnicodeCE::U_OTHER_LETTER),
+
+ Mark_NonSpacing = TO_MASK(UnicodeCE::U_NON_SPACING_MARK),
+ Mark_Enclosing = TO_MASK(UnicodeCE::U_ENCLOSING_MARK),
+ Mark_SpacingCombining = TO_MASK(UnicodeCE::U_COMBINING_SPACING_MARK),
+
+ Number_DecimalDigit = TO_MASK(UnicodeCE::U_DECIMAL_DIGIT_NUMBER),
+ Number_Letter = TO_MASK(UnicodeCE::U_LETTER_NUMBER),
+ Number_Other = TO_MASK(UnicodeCE::U_OTHER_NUMBER),
+
+ Separator_Space = TO_MASK(UnicodeCE::U_SPACE_SEPARATOR),
+ Separator_Line = TO_MASK(UnicodeCE::U_LINE_SEPARATOR),
+ Separator_Paragraph = TO_MASK(UnicodeCE::U_PARAGRAPH_SEPARATOR),
+
+ Other_Control = TO_MASK(UnicodeCE::U_CONTROL_CHAR),
+ Other_Format = TO_MASK(UnicodeCE::U_FORMAT_CHAR),
+ Other_PrivateUse = TO_MASK(UnicodeCE::U_PRIVATE_USE_CHAR),
+ Other_Surrogate = TO_MASK(UnicodeCE::U_SURROGATE),
+
+ Punctuation_Dash = TO_MASK(UnicodeCE::U_DASH_PUNCTUATION),
+ Punctuation_Open = TO_MASK(UnicodeCE::U_START_PUNCTUATION),
+ Punctuation_Close = TO_MASK(UnicodeCE::U_END_PUNCTUATION),
+ Punctuation_Connector = TO_MASK(UnicodeCE::U_CONNECTOR_PUNCTUATION),
+ Punctuation_Other = TO_MASK(UnicodeCE::U_OTHER_PUNCTUATION),
+
+ Symbol_Math = TO_MASK(UnicodeCE::U_MATH_SYMBOL),
+ Symbol_Currency = TO_MASK(UnicodeCE::U_CURRENCY_SYMBOL),
+ Symbol_Modifier = TO_MASK(UnicodeCE::U_MODIFIER_SYMBOL),
+ Symbol_Other = TO_MASK(UnicodeCE::U_OTHER_SYMBOL),
+
+ Punctuation_InitialQuote = TO_MASK(UnicodeCE::U_INITIAL_PUNCTUATION),
+ Punctuation_FinalQuote = TO_MASK(UnicodeCE::U_FINAL_PUNCTUATION)
+ };
+
+ CharCategory category(unsigned int);
+
+ bool isSpace(wchar_t);
+ bool isLetter(wchar_t);
+ bool isPrintableChar(wchar_t);
+ bool isUpper(wchar_t);
+ bool isLower(wchar_t);
+ bool isPunct(wchar_t);
+ bool isDigit(wchar_t);
+ bool isAlphanumeric(wchar_t);
+ inline bool isSeparatorSpace(wchar_t c) { return category(c) == Separator_Space; }
+ inline bool isHighSurrogate(wchar_t c) { return (c & 0xfc00) == 0xd800; }
+ inline bool isLowSurrogate(wchar_t c) { return (c & 0xfc00) == 0xdc00; }
+
+ wchar_t toLower(wchar_t);
+ wchar_t toUpper(wchar_t);
+ wchar_t foldCase(wchar_t);
+ wchar_t toTitleCase(wchar_t);
+ int toLower(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError);
+ int toUpper(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError);
+ int foldCase(UChar* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError);
+
+ int digitValue(wchar_t);
+
+ wchar_t mirroredChar(UChar32);
+ unsigned char combiningClass(UChar32);
+ DecompositionType decompositionType(UChar32);
+ Direction direction(UChar32);
+ inline bool isArabicChar(UChar32 c)
+ {
+ return c >= 0x0600 && c <= 0x06FF;
+ }
+
+ inline bool hasLineBreakingPropertyComplexContext(UChar32)
+ {
+ return false; // FIXME: implement!
+ }
+
+ inline int umemcasecmp(const wchar_t* a, const wchar_t* b, int len)
+ {
+ for (int i = 0; i < len; ++i) {
+ wchar_t c1 = foldCase(a[i]);
+ wchar_t c2 = foldCase(b[i]);
+ if (c1 != c2)
+ return c1 - c2;
+ }
+ return 0;
+ }
+
+ inline UChar32 surrogateToUcs4(wchar_t high, wchar_t low)
+ {
+ return (UChar32(high) << 10) + low - 0x35fdc00;
+ }
+
+ } // namespace Unicode
+
+} // namespace WTF
+
+#endif // WTF_UnicodeWinCE_h
diff --git a/JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp b/JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp
deleted file mode 100644
index 42f0ff8..0000000
--- a/JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2006 George Staikos <staikos at kde.org>
- * Copyright (C) 2006 Alexey Proskuryakov <ap at nypop.com>
- * Copyright (C) 2007-2009 Torch Mobile, 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 "UnicodeWince.h"
-
-#include <wchar.h>
-
-namespace WTF {
-namespace Unicode {
-
-wchar_t toLower(wchar_t c)
-{
- return towlower(c);
-}
-
-wchar_t toUpper(wchar_t c)
-{
- return towupper(c);
-}
-
-wchar_t foldCase(wchar_t c)
-{
- return towlower(c);
-}
-
-bool isPrintableChar(wchar_t c)
-{
- return !!iswprint(c);
-}
-
-bool isSpace(wchar_t c)
-{
- return !!iswspace(c);
-}
-
-bool isLetter(wchar_t c)
-{
- return !!iswalpha(c);
-}
-
-bool isUpper(wchar_t c)
-{
- return !!iswupper(c);
-}
-
-bool isLower(wchar_t c)
-{
- return !!iswlower(c);
-}
-
-bool isDigit(wchar_t c)
-{
- return !!iswdigit(c);
-}
-
-bool isPunct(wchar_t c)
-{
- return !!iswpunct(c);
-}
-
-bool isAlphanumeric(wchar_t c)
-{
- return !!iswalnum(c);
-}
-
-int toLower(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError)
-{
- const UChar* sourceIterator = source;
- const UChar* sourceEnd = source + sourceLength;
- UChar* resultIterator = result;
- UChar* resultEnd = result + resultLength;
-
- int remainingCharacters = 0;
- if (sourceLength <= resultLength)
- while (sourceIterator < sourceEnd)
- *resultIterator++ = towlower(*sourceIterator++);
- else
- while (resultIterator < resultEnd)
- *resultIterator++ = towlower(*sourceIterator++);
-
- if (sourceIterator < sourceEnd)
- remainingCharacters += sourceEnd - sourceIterator;
- *isError = (remainingCharacters != 0);
- if (resultIterator < resultEnd)
- *resultIterator = 0;
-
- return (resultIterator - result) + remainingCharacters;
-}
-
-int toUpper(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError)
-{
- const UChar* sourceIterator = source;
- const UChar* sourceEnd = source + sourceLength;
- UChar* resultIterator = result;
- UChar* resultEnd = result + resultLength;
-
- int remainingCharacters = 0;
- if (sourceLength <= resultLength)
- while (sourceIterator < sourceEnd)
- *resultIterator++ = towupper(*sourceIterator++);
- else
- while (resultIterator < resultEnd)
- *resultIterator++ = towupper(*sourceIterator++);
-
- if (sourceIterator < sourceEnd)
- remainingCharacters += sourceEnd - sourceIterator;
- *isError = (remainingCharacters != 0);
- if (resultIterator < resultEnd)
- *resultIterator = 0;
-
- return (resultIterator - result) + remainingCharacters;
-}
-
-int foldCase(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError)
-{
- *isError = false;
- if (resultLength < sourceLength) {
- *isError = true;
- return sourceLength;
- }
- for (int i = 0; i < sourceLength; ++i)
- result[i] = foldCase(source[i]);
- return sourceLength;
-}
-
-wchar_t toTitleCase(wchar_t c)
-{
- return towupper(c);
-}
-
-Direction direction(UChar32 c)
-{
- return static_cast<Direction>(UnicodeCE::direction(c));
-}
-
-CharCategory category(unsigned int c)
-{
- return static_cast<CharCategory>(TO_MASK((__int8) UnicodeCE::category(c)));
-}
-
-DecompositionType decompositionType(UChar32 c)
-{
- return static_cast<DecompositionType>(UnicodeCE::decompositionType(c));
-}
-
-unsigned char combiningClass(UChar32 c)
-{
- return UnicodeCE::combiningClass(c);
-}
-
-wchar_t mirroredChar(UChar32 c)
-{
- return UnicodeCE::mirroredChar(c);
-}
-
-int digitValue(wchar_t c)
-{
- return UnicodeCE::digitValue(c);
-}
-
-} // namespace Unicode
-} // namespace WTF
diff --git a/JavaScriptCore/wtf/unicode/wince/UnicodeWince.h b/JavaScriptCore/wtf/unicode/wince/UnicodeWince.h
deleted file mode 100644
index c68fc93..0000000
--- a/JavaScriptCore/wtf/unicode/wince/UnicodeWince.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2006 George Staikos <staikos at kde.org>
- * Copyright (C) 2006 Alexey Proskuryakov <ap at nypop.com>
- * Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, 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 UNICODE_WINCE_H
-#define UNICODE_WINCE_H
-
-#include "UnicodeMacrosFromICU.h"
-
-#include "ce_unicode.h"
-
-#define TO_MASK(x) (1 << (x))
-
-namespace WTF {
-
- namespace Unicode {
-
- enum Direction {
- LeftToRight = UnicodeCE::U_LEFT_TO_RIGHT,
- RightToLeft = UnicodeCE::U_RIGHT_TO_LEFT,
- EuropeanNumber = UnicodeCE::U_EUROPEAN_NUMBER,
- EuropeanNumberSeparator = UnicodeCE::U_EUROPEAN_NUMBER_SEPARATOR,
- EuropeanNumberTerminator = UnicodeCE::U_EUROPEAN_NUMBER_TERMINATOR,
- ArabicNumber = UnicodeCE::U_ARABIC_NUMBER,
- CommonNumberSeparator = UnicodeCE::U_COMMON_NUMBER_SEPARATOR,
- BlockSeparator = UnicodeCE::U_BLOCK_SEPARATOR,
- SegmentSeparator = UnicodeCE::U_SEGMENT_SEPARATOR,
- WhiteSpaceNeutral = UnicodeCE::U_WHITE_SPACE_NEUTRAL,
- OtherNeutral = UnicodeCE::U_OTHER_NEUTRAL,
- LeftToRightEmbedding = UnicodeCE::U_LEFT_TO_RIGHT_EMBEDDING,
- LeftToRightOverride = UnicodeCE::U_LEFT_TO_RIGHT_OVERRIDE,
- RightToLeftArabic = UnicodeCE::U_RIGHT_TO_LEFT_ARABIC,
- RightToLeftEmbedding = UnicodeCE::U_RIGHT_TO_LEFT_EMBEDDING,
- RightToLeftOverride = UnicodeCE::U_RIGHT_TO_LEFT_OVERRIDE,
- PopDirectionalFormat = UnicodeCE::U_POP_DIRECTIONAL_FORMAT,
- NonSpacingMark = UnicodeCE::U_DIR_NON_SPACING_MARK,
- BoundaryNeutral = UnicodeCE::U_BOUNDARY_NEUTRAL
- };
-
- enum DecompositionType {
- DecompositionNone = UnicodeCE::U_DT_NONE,
- DecompositionCanonical = UnicodeCE::U_DT_CANONICAL,
- DecompositionCompat = UnicodeCE::U_DT_COMPAT,
- DecompositionCircle = UnicodeCE::U_DT_CIRCLE,
- DecompositionFinal = UnicodeCE::U_DT_FINAL,
- DecompositionFont = UnicodeCE::U_DT_FONT,
- DecompositionFraction = UnicodeCE::U_DT_FRACTION,
- DecompositionInitial = UnicodeCE::U_DT_INITIAL,
- DecompositionIsolated = UnicodeCE::U_DT_ISOLATED,
- DecompositionMedial = UnicodeCE::U_DT_MEDIAL,
- DecompositionNarrow = UnicodeCE::U_DT_NARROW,
- DecompositionNoBreak = UnicodeCE::U_DT_NOBREAK,
- DecompositionSmall = UnicodeCE::U_DT_SMALL,
- DecompositionSquare = UnicodeCE::U_DT_SQUARE,
- DecompositionSub = UnicodeCE::U_DT_SUB,
- DecompositionSuper = UnicodeCE::U_DT_SUPER,
- DecompositionVertical = UnicodeCE::U_DT_VERTICAL,
- DecompositionWide = UnicodeCE::U_DT_WIDE,
- };
-
- enum CharCategory {
- NoCategory = 0,
- Other_NotAssigned = TO_MASK(UnicodeCE::U_GENERAL_OTHER_TYPES),
- Letter_Uppercase = TO_MASK(UnicodeCE::U_UPPERCASE_LETTER),
- Letter_Lowercase = TO_MASK(UnicodeCE::U_LOWERCASE_LETTER),
- Letter_Titlecase = TO_MASK(UnicodeCE::U_TITLECASE_LETTER),
- Letter_Modifier = TO_MASK(UnicodeCE::U_MODIFIER_LETTER),
- Letter_Other = TO_MASK(UnicodeCE::U_OTHER_LETTER),
-
- Mark_NonSpacing = TO_MASK(UnicodeCE::U_NON_SPACING_MARK),
- Mark_Enclosing = TO_MASK(UnicodeCE::U_ENCLOSING_MARK),
- Mark_SpacingCombining = TO_MASK(UnicodeCE::U_COMBINING_SPACING_MARK),
-
- Number_DecimalDigit = TO_MASK(UnicodeCE::U_DECIMAL_DIGIT_NUMBER),
- Number_Letter = TO_MASK(UnicodeCE::U_LETTER_NUMBER),
- Number_Other = TO_MASK(UnicodeCE::U_OTHER_NUMBER),
-
- Separator_Space = TO_MASK(UnicodeCE::U_SPACE_SEPARATOR),
- Separator_Line = TO_MASK(UnicodeCE::U_LINE_SEPARATOR),
- Separator_Paragraph = TO_MASK(UnicodeCE::U_PARAGRAPH_SEPARATOR),
-
- Other_Control = TO_MASK(UnicodeCE::U_CONTROL_CHAR),
- Other_Format = TO_MASK(UnicodeCE::U_FORMAT_CHAR),
- Other_PrivateUse = TO_MASK(UnicodeCE::U_PRIVATE_USE_CHAR),
- Other_Surrogate = TO_MASK(UnicodeCE::U_SURROGATE),
-
- Punctuation_Dash = TO_MASK(UnicodeCE::U_DASH_PUNCTUATION),
- Punctuation_Open = TO_MASK(UnicodeCE::U_START_PUNCTUATION),
- Punctuation_Close = TO_MASK(UnicodeCE::U_END_PUNCTUATION),
- Punctuation_Connector = TO_MASK(UnicodeCE::U_CONNECTOR_PUNCTUATION),
- Punctuation_Other = TO_MASK(UnicodeCE::U_OTHER_PUNCTUATION),
-
- Symbol_Math = TO_MASK(UnicodeCE::U_MATH_SYMBOL),
- Symbol_Currency = TO_MASK(UnicodeCE::U_CURRENCY_SYMBOL),
- Symbol_Modifier = TO_MASK(UnicodeCE::U_MODIFIER_SYMBOL),
- Symbol_Other = TO_MASK(UnicodeCE::U_OTHER_SYMBOL),
-
- Punctuation_InitialQuote = TO_MASK(UnicodeCE::U_INITIAL_PUNCTUATION),
- Punctuation_FinalQuote = TO_MASK(UnicodeCE::U_FINAL_PUNCTUATION)
- };
-
- CharCategory category(unsigned int);
-
- bool isSpace(wchar_t);
- bool isLetter(wchar_t);
- bool isPrintableChar(wchar_t);
- bool isUpper(wchar_t);
- bool isLower(wchar_t);
- bool isPunct(wchar_t);
- bool isDigit(wchar_t);
- bool isAlphanumeric(wchar_t);
- inline bool isSeparatorSpace(wchar_t c) { return category(c) == Separator_Space; }
- inline bool isHighSurrogate(wchar_t c) { return (c & 0xfc00) == 0xd800; }
- inline bool isLowSurrogate(wchar_t c) { return (c & 0xfc00) == 0xdc00; }
-
- wchar_t toLower(wchar_t);
- wchar_t toUpper(wchar_t);
- wchar_t foldCase(wchar_t);
- wchar_t toTitleCase(wchar_t);
- int toLower(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError);
- int toUpper(wchar_t* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError);
- int foldCase(UChar* result, int resultLength, const wchar_t* source, int sourceLength, bool* isError);
-
- int digitValue(wchar_t);
-
- wchar_t mirroredChar(UChar32);
- unsigned char combiningClass(UChar32);
- DecompositionType decompositionType(UChar32);
- Direction direction(UChar32);
- inline bool isArabicChar(UChar32 c)
- {
- return c >= 0x0600 && c <= 0x06FF;
- }
-
- inline bool hasLineBreakingPropertyComplexContext(UChar32)
- {
- return false; // FIXME: implement!
- }
-
- inline int umemcasecmp(const wchar_t* a, const wchar_t* b, int len)
- {
- for (int i = 0; i < len; ++i) {
- wchar_t c1 = foldCase(a[i]);
- wchar_t c2 = foldCase(b[i]);
- if (c1 != c2)
- return c1 - c2;
- }
- return 0;
- }
-
- inline UChar32 surrogateToUcs4(wchar_t high, wchar_t low)
- {
- return (UChar32(high) << 10) + low - 0x35fdc00;
- }
-
- } // namespace Unicode
-
-} // namespace WTF
-
-#endif
-// vim: ts=2 sw=2 et
diff --git a/JavaScriptCore/wtf/wince/FastMallocWinCE.h b/JavaScriptCore/wtf/wince/FastMallocWinCE.h
new file mode 100644
index 0000000..d91a5f2
--- /dev/null
+++ b/JavaScriptCore/wtf/wince/FastMallocWinCE.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WTF_FastMallocWinCE_h
+#define WTF_FastMallocWinCE_h
+
+#include <new.h>
+
+#ifdef __cplusplus
+#include <new>
+#include "MemoryManager.h"
+extern "C" {
+#endif
+
+void* fastMalloc(size_t n);
+void* fastCalloc(size_t n_elements, size_t element_size);
+void fastFree(void* p);
+void* fastRealloc(void* p, size_t n);
+void* fastZeroedMalloc(size_t n);
+// These functions return 0 if an allocation fails.
+void* tryFastMalloc(size_t n);
+void* tryFastZeroedMalloc(size_t n);
+void* tryFastCalloc(size_t n_elements, size_t element_size);
+void* tryFastRealloc(void* p, size_t n);
+char* fastStrDup(const char*);
+
+#ifndef NDEBUG
+void fastMallocForbid();
+void fastMallocAllow();
+#endif
+
+#if !defined(USE_SYSTEM_MALLOC) || !USE_SYSTEM_MALLOC
+
+#define malloc(n) fastMalloc(n)
+#define calloc(n_elements, element_size) fastCalloc(n_elements, element_size)
+#define realloc(p, n) fastRealloc(p, n)
+#define free(p) fastFree(p)
+#define strdup(p) fastStrDup(p)
+
+#else
+
+#define strdup(p) _strdup(p)
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+#if !defined(USE_SYSTEM_MALLOC) || !USE_SYSTEM_MALLOC
+static inline void* __cdecl operator new(size_t s) { return fastMalloc(s); }
+static inline void __cdecl operator delete(void* p) { fastFree(p); }
+static inline void* __cdecl operator new[](size_t s) { return fastMalloc(s); }
+static inline void __cdecl operator delete[](void* p) { fastFree(p); }
+static inline void* operator new(size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }
+static inline void operator delete(void* p, const std::nothrow_t&) throw() { fastFree(p); }
+static inline void* operator new[](size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }
+static inline void operator delete[](void* p, const std::nothrow_t&) throw() { fastFree(p); }
+#endif
+
+namespace WTF {
+ // This defines a type which holds an unsigned integer and is the same
+ // size as the minimally aligned memory allocation.
+ typedef unsigned long long AllocAlignmentInteger;
+
+ namespace Internal {
+ enum AllocType { // Start with an unusual number instead of zero, because zero is common.
+ AllocTypeMalloc = 0x375d6750, // Encompasses fastMalloc, fastZeroedMalloc, fastCalloc, fastRealloc.
+ AllocTypeClassNew, // Encompasses class operator new from FastAllocBase.
+ AllocTypeClassNewArray, // Encompasses class operator new[] from FastAllocBase.
+ AllocTypeFastNew, // Encompasses fastNew.
+ AllocTypeFastNewArray, // Encompasses fastNewArray.
+ AllocTypeNew, // Encompasses global operator new.
+ AllocTypeNewArray // Encompasses global operator new[].
+ };
+ }
+
+
+#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
+
+ // Malloc validation is a scheme whereby a tag is attached to an
+ // allocation which identifies how it was originally allocated.
+ // This allows us to verify that the freeing operation matches the
+ // allocation operation. If memory is allocated with operator new[]
+ // but freed with free or delete, this system would detect that.
+ // In the implementation here, the tag is an integer prepended to
+ // the allocation memory which is assigned one of the AllocType
+ // enumeration values. An alternative implementation of this
+ // scheme could store the tag somewhere else or ignore it.
+ // Users of FastMalloc don't need to know or care how this tagging
+ // is implemented.
+
+ namespace Internal {
+
+ // Return the AllocType tag associated with the allocated block p.
+ inline AllocType fastMallocMatchValidationType(const void* p)
+ {
+ const AllocAlignmentInteger* type = static_cast<const AllocAlignmentInteger*>(p) - 1;
+ return static_cast<AllocType>(*type);
+ }
+
+ // Return the address of the AllocType tag associated with the allocated block p.
+ inline AllocAlignmentInteger* fastMallocMatchValidationValue(void* p)
+ {
+ return reinterpret_cast<AllocAlignmentInteger*>(static_cast<char*>(p) - sizeof(AllocAlignmentInteger));
+ }
+
+ // Set the AllocType tag to be associaged with the allocated block p.
+ inline void setFastMallocMatchValidationType(void* p, AllocType allocType)
+ {
+ AllocAlignmentInteger* type = static_cast<AllocAlignmentInteger*>(p) - 1;
+ *type = static_cast<AllocAlignmentInteger>(allocType);
+ }
+
+ // Handle a detected alloc/free mismatch. By default this calls CRASH().
+ void fastMallocMatchFailed(void* p);
+
+ } // namespace Internal
+
+ // This is a higher level function which is used by FastMalloc-using code.
+ inline void fastMallocMatchValidateMalloc(void* p, Internal::AllocType allocType)
+ {
+ if (!p)
+ return;
+
+ Internal::setFastMallocMatchValidationType(p, allocType);
+ }
+
+ // This is a higher level function which is used by FastMalloc-using code.
+ inline void fastMallocMatchValidateFree(void* p, Internal::AllocType allocType)
+ {
+ if (!p)
+ return;
+
+ if (Internal::fastMallocMatchValidationType(p) != allocType)
+ Internal::fastMallocMatchFailed(p);
+ Internal::setFastMallocMatchValidationType(p, Internal::AllocTypeMalloc); // Set it to this so that fastFree thinks it's OK.
+ }
+
+#else
+
+ inline void fastMallocMatchValidateMalloc(void*, Internal::AllocType)
+ {
+ }
+
+ inline void fastMallocMatchValidateFree(void*, Internal::AllocType)
+ {
+ }
+
+#endif
+
+} // namespace WTF
+
+#endif
+
+#endif // WTF_FastMallocWinCE_h
diff --git a/JavaScriptCore/wtf/wince/FastMallocWince.h b/JavaScriptCore/wtf/wince/FastMallocWince.h
deleted file mode 100644
index 37174f0..0000000
--- a/JavaScriptCore/wtf/wince/FastMallocWince.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, 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., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FastMallocWince_h
-#define FastMallocWince_h
-
-#include <new.h>
-
-#ifdef __cplusplus
-#include <new>
-#include "MemoryManager.h"
-extern "C" {
-#endif
-
-void* fastMalloc(size_t n);
-void* fastCalloc(size_t n_elements, size_t element_size);
-void fastFree(void* p);
-void* fastRealloc(void* p, size_t n);
-void* fastZeroedMalloc(size_t n);
-// These functions return 0 if an allocation fails.
-void* tryFastMalloc(size_t n);
-void* tryFastZeroedMalloc(size_t n);
-void* tryFastCalloc(size_t n_elements, size_t element_size);
-void* tryFastRealloc(void* p, size_t n);
-char* fastStrDup(const char*);
-
-#ifndef NDEBUG
-void fastMallocForbid();
-void fastMallocAllow();
-#endif
-
-#if !defined(USE_SYSTEM_MALLOC) || !USE_SYSTEM_MALLOC
-
-#define malloc(n) fastMalloc(n)
-#define calloc(n_elements, element_size) fastCalloc(n_elements, element_size)
-#define realloc(p, n) fastRealloc(p, n)
-#define free(p) fastFree(p)
-#define strdup(p) fastStrDup(p)
-
-#else
-
-#define strdup(p) _strdup(p)
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifdef __cplusplus
-#if !defined(USE_SYSTEM_MALLOC) || !USE_SYSTEM_MALLOC
-static inline void* __cdecl operator new(size_t s) { return fastMalloc(s); }
-static inline void __cdecl operator delete(void* p) { fastFree(p); }
-static inline void* __cdecl operator new[](size_t s) { return fastMalloc(s); }
-static inline void __cdecl operator delete[](void* p) { fastFree(p); }
-static inline void* operator new(size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }
-static inline void operator delete(void* p, const std::nothrow_t&) throw() { fastFree(p); }
-static inline void* operator new[](size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }
-static inline void operator delete[](void* p, const std::nothrow_t&) throw() { fastFree(p); }
-#endif
-
-namespace WTF {
- // This defines a type which holds an unsigned integer and is the same
- // size as the minimally aligned memory allocation.
- typedef unsigned long long AllocAlignmentInteger;
-
- namespace Internal {
- enum AllocType { // Start with an unusual number instead of zero, because zero is common.
- AllocTypeMalloc = 0x375d6750, // Encompasses fastMalloc, fastZeroedMalloc, fastCalloc, fastRealloc.
- AllocTypeClassNew, // Encompasses class operator new from FastAllocBase.
- AllocTypeClassNewArray, // Encompasses class operator new[] from FastAllocBase.
- AllocTypeFastNew, // Encompasses fastNew.
- AllocTypeFastNewArray, // Encompasses fastNewArray.
- AllocTypeNew, // Encompasses global operator new.
- AllocTypeNewArray // Encompasses global operator new[].
- };
- }
-
-
-#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
-
- // Malloc validation is a scheme whereby a tag is attached to an
- // allocation which identifies how it was originally allocated.
- // This allows us to verify that the freeing operation matches the
- // allocation operation. If memory is allocated with operator new[]
- // but freed with free or delete, this system would detect that.
- // In the implementation here, the tag is an integer prepended to
- // the allocation memory which is assigned one of the AllocType
- // enumeration values. An alternative implementation of this
- // scheme could store the tag somewhere else or ignore it.
- // Users of FastMalloc don't need to know or care how this tagging
- // is implemented.
-
- namespace Internal {
-
- // Return the AllocType tag associated with the allocated block p.
- inline AllocType fastMallocMatchValidationType(const void* p)
- {
- const AllocAlignmentInteger* type = static_cast<const AllocAlignmentInteger*>(p) - 1;
- return static_cast<AllocType>(*type);
- }
-
- // Return the address of the AllocType tag associated with the allocated block p.
- inline AllocAlignmentInteger* fastMallocMatchValidationValue(void* p)
- {
- return reinterpret_cast<AllocAlignmentInteger*>(static_cast<char*>(p) - sizeof(AllocAlignmentInteger));
- }
-
- // Set the AllocType tag to be associaged with the allocated block p.
- inline void setFastMallocMatchValidationType(void* p, AllocType allocType)
- {
- AllocAlignmentInteger* type = static_cast<AllocAlignmentInteger*>(p) - 1;
- *type = static_cast<AllocAlignmentInteger>(allocType);
- }
-
- // Handle a detected alloc/free mismatch. By default this calls CRASH().
- void fastMallocMatchFailed(void* p);
-
- } // namespace Internal
-
- // This is a higher level function which is used by FastMalloc-using code.
- inline void fastMallocMatchValidateMalloc(void* p, Internal::AllocType allocType)
- {
- if (!p)
- return;
-
- Internal::setFastMallocMatchValidationType(p, allocType);
- }
-
- // This is a higher level function which is used by FastMalloc-using code.
- inline void fastMallocMatchValidateFree(void* p, Internal::AllocType allocType)
- {
- if (!p)
- return;
-
- if (Internal::fastMallocMatchValidationType(p) != allocType)
- Internal::fastMallocMatchFailed(p);
- Internal::setFastMallocMatchValidationType(p, Internal::AllocTypeMalloc); // Set it to this so that fastFree thinks it's OK.
- }
-
-#else
-
- inline void fastMallocMatchValidateMalloc(void*, Internal::AllocType)
- {
- }
-
- inline void fastMallocMatchValidateFree(void*, Internal::AllocType)
- {
- }
-
-#endif
-
-} // namespace WTF
-
-#endif
-
-#endif // FastMallocWince_h
-
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b6e78ac..5f1f689 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -17,6 +17,131 @@
2010-09-18 Patrick Gansterer <paroga at paroga.com>
+ Reviewed by Darin Adler.
+
+ Rename Wince files to WinCE
+ https://bugs.webkit.org/show_bug.cgi?id=37287
+
+ * loader/icon/wince/IconDatabaseWinCE.cpp: Copied from WebCore/loader/icon/wince/IconDatabaseWince.cpp.
+ * loader/icon/wince/IconDatabaseWince.cpp: Removed.
+ * page/wince/FrameWinCE.cpp: Copied from WebCore/page/wince/FrameWince.cpp.
+ * page/wince/FrameWince.cpp: Removed.
+ * platform/graphics/MediaPlayer.cpp:
+ * platform/graphics/wince/ColorWinCE.cpp: Copied from WebCore/platform/graphics/wince/ColorWince.cpp.
+ * platform/graphics/wince/ColorWince.cpp: Removed.
+ * platform/graphics/wince/FontCacheWinCE.cpp: Copied from WebCore/platform/graphics/wince/FontCacheWince.cpp.
+ * platform/graphics/wince/FontCacheWince.cpp: Removed.
+ * platform/graphics/wince/FontWinCE.cpp: Copied from WebCore/platform/graphics/wince/FontWince.cpp.
+ * platform/graphics/wince/FontWince.cpp: Removed.
+ * platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp: Copied from WebCore/platform/graphics/wince/GlyphPageTreeNodeWince.cpp.
+ * platform/graphics/wince/GlyphPageTreeNodeWince.cpp: Removed.
+ * platform/graphics/wince/GradientWinCE.cpp: Copied from WebCore/platform/graphics/wince/GradientWince.cpp.
+ * platform/graphics/wince/GradientWince.cpp: Removed.
+ * platform/graphics/wince/GraphicsContextWinCE.cpp: Copied from WebCore/platform/graphics/wince/GraphicsContextWince.cpp.
+ * platform/graphics/wince/GraphicsContextWince.cpp: Removed.
+ * platform/graphics/wince/ImageBufferWinCE.cpp: Copied from WebCore/platform/graphics/wince/ImageBufferWince.cpp.
+ * platform/graphics/wince/ImageBufferWince.cpp: Removed.
+ * platform/graphics/wince/MediaPlayerPrivateWinCE.h: Copied from WebCore/platform/graphics/wince/MediaPlayerPrivateWince.h.
+ * platform/graphics/wince/MediaPlayerPrivateWince.h: Removed.
+ * platform/graphics/wince/PathWinCE.cpp: Copied from WebCore/platform/graphics/wince/PathWince.cpp.
+ * platform/graphics/wince/PathWince.cpp: Removed.
+ * platform/graphics/wince/PlatformPathWinCE.cpp: Copied from WebCore/platform/graphics/wince/PlatformPathWince.cpp.
+ * platform/graphics/wince/PlatformPathWinCE.h: Copied from WebCore/platform/graphics/wince/PlatformPathWince.h.
+ * platform/graphics/wince/PlatformPathWince.cpp: Removed.
+ * platform/graphics/wince/PlatformPathWince.h: Removed.
+ * platform/graphics/wince/SimpleFontDataWinCE.cpp: Copied from WebCore/platform/graphics/wince/SimpleFontDataWince.cpp.
+ * platform/graphics/wince/SimpleFontDataWince.cpp: Removed.
+ * platform/graphics/wince/WinCEGraphicsExtras.h: Copied from WebCore/platform/graphics/wince/WinceGraphicsExtras.h.
+ * platform/graphics/wince/WinceGraphicsExtras.h: Removed.
+ * platform/text/wince/TextBoundariesWinCE.cpp: Copied from WebCore/platform/text/wince/TextBoundariesWince.cpp.
+ * platform/text/wince/TextBoundariesWince.cpp: Removed.
+ * platform/text/wince/TextBreakIteratorWinCE.cpp: Copied from WebCore/platform/text/wince/TextBreakIteratorWince.cpp.
+ * platform/text/wince/TextBreakIteratorWince.cpp: Removed.
+ * platform/wince/CursorWinCE.cpp: Copied from WebCore/platform/wince/CursorWince.cpp.
+ * platform/wince/CursorWince.cpp: Removed.
+ * platform/wince/DragDataWinCE.cpp: Copied from WebCore/platform/wince/DragDataWince.cpp.
+ * platform/wince/DragDataWince.cpp: Removed.
+ * platform/wince/DragImageWinCE.cpp: Copied from WebCore/platform/wince/DragImageWince.cpp.
+ * platform/wince/DragImageWince.cpp: Removed.
+ * platform/wince/EditorWinCE.cpp: Copied from WebCore/platform/wince/EditorWince.cpp.
+ (WebCore::Editor::newGeneralClipboard):
+ * platform/wince/EditorWince.cpp: Removed.
+ * platform/wince/FileChooserWinCE.cpp: Copied from WebCore/platform/wince/FileChooserWince.cpp.
+ * platform/wince/FileChooserWince.cpp: Removed.
+ * platform/wince/FileSystemWinCE.cpp: Copied from WebCore/platform/wince/FileSystemWince.cpp.
+ * platform/wince/FileSystemWince.cpp: Removed.
+ * platform/wince/KURLWinCE.cpp: Copied from WebCore/platform/wince/KURLWince.cpp.
+ * platform/wince/KURLWince.cpp: Removed.
+ * platform/wince/KeygenWinCE.cpp: Copied from WebCore/platform/wince/KeygenWince.cpp.
+ * platform/wince/KeygenWince.cpp: Removed.
+ * platform/wince/MIMETypeRegistryWinCE.cpp: Copied from WebCore/platform/wince/MIMETypeRegistryWince.cpp.
+ * platform/wince/MIMETypeRegistryWince.cpp: Removed.
+ * platform/wince/PasteboardWinCE.cpp: Copied from WebCore/platform/wince/PasteboardWince.cpp.
+ * platform/wince/PasteboardWince.cpp: Removed.
+ * platform/wince/SearchPopupMenuWinCE.cpp: Copied from WebCore/platform/wince/SearchPopupMenuWince.cpp.
+ * platform/wince/SearchPopupMenuWince.cpp: Removed.
+ * platform/wince/SharedTimerWinCE.cpp: Copied from WebCore/platform/wince/SharedTimerWince.cpp.
+ * platform/wince/SharedTimerWince.cpp: Removed.
+ * rendering/RenderThemeWinCE.cpp: Copied from WebCore/rendering/RenderThemeWince.cpp.
+ (WebCore::RenderThemeWinCE::create):
+ (WebCore::RenderTheme::themeForPage):
+ (WebCore::RenderThemeWinCE::RenderThemeWinCE):
+ (WebCore::RenderThemeWinCE::~RenderThemeWinCE):
+ (WebCore::RenderThemeWinCE::platformActiveSelectionBackgroundColor):
+ (WebCore::RenderThemeWinCE::platformInactiveSelectionBackgroundColor):
+ (WebCore::RenderThemeWinCE::platformActiveSelectionForegroundColor):
+ (WebCore::RenderThemeWinCE::platformInactiveSelectionForegroundColor):
+ (WebCore::RenderThemeWinCE::supportsFocus):
+ (WebCore::RenderThemeWinCE::supportsFocusRing):
+ (WebCore::RenderThemeWinCE::determineClassicState):
+ (WebCore::RenderThemeWinCE::getThemeData):
+ (WebCore::RenderThemeWinCE::paintButton):
+ (WebCore::RenderThemeWinCE::setCheckboxSize):
+ (WebCore::RenderThemeWinCE::paintTextField):
+ (WebCore::RenderThemeWinCE::adjustMenuListStyle):
+ (WebCore::RenderThemeWinCE::paintMenuList):
+ (WebCore::RenderThemeWinCE::paintMenuListButton):
+ (WebCore::RenderThemeWinCE::systemFont):
+ (WebCore::RenderThemeWinCE::themeChanged):
+ (WebCore::RenderThemeWinCE::extraDefaultStyleSheet):
+ (WebCore::RenderThemeWinCE::extraQuirksStyleSheet):
+ (WebCore::RenderThemeWinCE::supportsHover):
+ (WebCore::RenderThemeWinCE::systemColor):
+ (WebCore::RenderThemeWinCE::adjustSliderThumbSize):
+ (WebCore::RenderThemeWinCE::adjustButtonInnerStyle):
+ (WebCore::RenderThemeWinCE::adjustSearchFieldStyle):
+ (WebCore::RenderThemeWinCE::paintSearchField):
+ (WebCore::RenderThemeWinCE::paintSearchFieldCancelButton):
+ (WebCore::RenderThemeWinCE::adjustSearchFieldCancelButtonStyle):
+ (WebCore::RenderThemeWinCE::adjustSearchFieldDecorationStyle):
+ (WebCore::RenderThemeWinCE::adjustSearchFieldResultsDecorationStyle):
+ (WebCore::RenderThemeWinCE::paintSearchFieldResultsDecoration):
+ (WebCore::RenderThemeWinCE::adjustSearchFieldResultsButtonStyle):
+ (WebCore::RenderThemeWinCE::paintSearchFieldResultsButton):
+ (WebCore::RenderThemeWinCE::adjustMenuListButtonStyle):
+ (WebCore::RenderThemeWinCE::paintSliderTrack):
+ (WebCore::RenderThemeWinCE::paintSliderThumb):
+ (WebCore::RenderThemeWinCE::paintMediaFullscreenButton):
+ (WebCore::RenderThemeWinCE::paintMediaMuteButton):
+ (WebCore::RenderThemeWinCE::paintMediaPlayButton):
+ (WebCore::RenderThemeWinCE::paintMediaSeekBackButton):
+ (WebCore::RenderThemeWinCE::paintMediaSeekForwardButton):
+ (WebCore::RenderThemeWinCE::paintMediaSliderTrack):
+ (WebCore::RenderThemeWinCE::paintMediaSliderThumb):
+ * rendering/RenderThemeWinCE.h: Copied from WebCore/rendering/RenderThemeWince.h.
+ * rendering/RenderThemeWince.cpp: Removed.
+ * rendering/RenderThemeWince.h: Removed.
+ * storage/wince/DatabaseThreadWinCE.cpp: Copied from WebCore/storage/wince/DatabaseThreadWince.cpp.
+ * storage/wince/DatabaseThreadWinCE.h: Copied from WebCore/storage/wince/DatabaseThreadWince.h.
+ * storage/wince/DatabaseThreadWince.cpp: Removed.
+ * storage/wince/DatabaseThreadWince.h: Removed.
+ * storage/wince/LocalStorageThreadWinCE.cpp: Copied from WebCore/storage/wince/LocalStorageThreadWince.cpp.
+ * storage/wince/LocalStorageThreadWinCE.h: Copied from WebCore/storage/wince/LocalStorageThreadWince.h.
+ * storage/wince/LocalStorageThreadWince.cpp: Removed.
+ * storage/wince/LocalStorageThreadWince.h: Removed.
+
+2010-09-18 Patrick Gansterer <paroga at paroga.com>
+
Reviewed by Eric Seidel.
Move Plugin*None.cpp from CMakeLists.txt into CMakeListsEfl.txt
diff --git a/WebCore/loader/icon/wince/IconDatabaseWince.cpp b/WebCore/loader/icon/wince/IconDatabaseWinCE.cpp
similarity index 100%
rename from WebCore/loader/icon/wince/IconDatabaseWince.cpp
rename to WebCore/loader/icon/wince/IconDatabaseWinCE.cpp
diff --git a/WebCore/page/wince/FrameWince.cpp b/WebCore/page/wince/FrameWinCE.cpp
similarity index 100%
rename from WebCore/page/wince/FrameWince.cpp
rename to WebCore/page/wince/FrameWinCE.cpp
diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp
index 5ae5f55..947fcd7 100644
--- a/WebCore/platform/graphics/MediaPlayer.cpp
+++ b/WebCore/platform/graphics/MediaPlayer.cpp
@@ -48,7 +48,7 @@
#if PLATFORM(MAC)
#include "MediaPlayerPrivateQTKit.h"
#elif OS(WINCE) && !PLATFORM(QT)
-#include "MediaPlayerPrivateWince.h"
+#include "MediaPlayerPrivateWinCE.h"
#elif PLATFORM(WIN)
#include "MediaPlayerPrivateQuickTimeVisualContext.h"
#include "MediaPlayerPrivateQuicktimeWin.h"
diff --git a/WebCore/platform/graphics/wince/ColorWince.cpp b/WebCore/platform/graphics/wince/ColorWinCE.cpp
similarity index 100%
rename from WebCore/platform/graphics/wince/ColorWince.cpp
rename to WebCore/platform/graphics/wince/ColorWinCE.cpp
diff --git a/WebCore/platform/graphics/wince/FontCacheWinCE.cpp b/WebCore/platform/graphics/wince/FontCacheWinCE.cpp
new file mode 100644
index 0000000..ccfc063
--- /dev/null
+++ b/WebCore/platform/graphics/wince/FontCacheWinCE.cpp
@@ -0,0 +1,351 @@
+/*
+* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+* Copyright (C) 2007-2009 Torch Mobile, 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.
+* 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 "Font.h"
+#include "FontData.h"
+#include "SimpleFontData.h"
+#include "UnicodeRange.h"
+#include "wtf/OwnPtr.h"
+
+#include <windows.h>
+#include <mlang.h>
+
+namespace WebCore {
+
+extern HDC g_screenDC;
+
+static IMultiLanguage *multiLanguage = 0;
+
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+static IMLangFontLink2* langFontLink = 0;
+#else
+static IMLangFontLink* langFontLink = 0;
+#endif
+
+IMultiLanguage* FontCache::getMultiLanguageInterface()
+{
+ if (!multiLanguage)
+ CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_INPROC_SERVER, IID_IMultiLanguage, (void**)&multiLanguage);
+
+ return multiLanguage;
+}
+
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+IMLangFontLink2* FontCache::getFontLinkInterface()
+#else
+IMLangFontLink* FontCache::getFontLinkInterface()
+#endif
+{
+ if (!langFontLink) {
+ if (IMultiLanguage* mli = getMultiLanguageInterface())
+ mli->QueryInterface(&langFontLink);
+ }
+
+ return langFontLink;
+}
+
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+static bool currentFontContainsCharacter(IMLangFontLink2* langFontLink, HDC hdc, UChar character)
+{
+ UINT unicodeRanges;
+ if (S_OK != langFontLink->GetFontUnicodeRanges(hdc, &unicodeRanges, 0))
+ return false;
+
+ static Vector<UNICODERANGE, 64> glyphsetBuffer;
+ glyphsetBuffer.resize(unicodeRanges);
+
+ if (S_OK != langFontLink->GetFontUnicodeRanges(hdc, &unicodeRanges, glyphsetBuffer.data()))
+ return false;
+
+ // FIXME: Change this to a binary search. (Yong Li: That's easy. But, is it guaranteed that the ranges are sorted?)
+ for (Vector<UNICODERANGE, 64>::const_iterator i = glyphsetBuffer.begin(); i != glyphsetBuffer.end(); ++i) {
+ if (i->wcTo >= character)
+ return i->wcFrom <= character;
+ }
+
+ return false;
+}
+#else
+static bool currentFontContainsCharacter(IMLangFontLink* langFontLink, HDC hdc, HFONT hfont, UChar character, const wchar_t* faceName)
+{
+ DWORD fontCodePages = 0, charCodePages = 0;
+ HRESULT result = langFontLink->GetFontCodePages(hdc, hfont, &fontCodePages);
+ if (result != S_OK)
+ return false;
+ result = langFontLink->GetCharCodePages(character, &charCodePages);
+ if (result != S_OK)
+ return false;
+
+ fontCodePages |= FontPlatformData::getKnownFontCodePages(faceName);
+ if (fontCodePages & charCodePages)
+ return true;
+
+ return false;
+}
+#endif
+
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+static HFONT createMLangFont(IMLangFontLink2* langFontLink, HDC hdc, DWORD codePageMask, UChar character = 0)
+{
+ HFONT mlangFont;
+ if (SUCCEEDED(langFontLink->MapFont(hdc, codePageMask, character, &mlangFont)))
+ return mlangFont;
+
+ return 0;
+}
+#else
+static HFONT createMLangFont(IMLangFontLink* langFontLink, HDC hdc, const FontPlatformData& refFont, DWORD codePageMask)
+{
+ HFONT mlangFont;
+ LRESULT result = langFontLink->MapFont(hdc, codePageMask, refFont.hfont(), &mlangFont);
+
+ return result == S_OK ? mlangFont : 0;
+}
+#endif
+
+static const Vector<DWORD, 4>& getCJKCodePageMasks()
+{
+ // The default order in which we look for a font for a CJK character. If the user's default code page is
+ // one of these, we will use it first.
+ static const UINT CJKCodePages[] = {
+ 932, /* Japanese */
+ 936, /* Simplified Chinese */
+ 950, /* Traditional Chinese */
+ 949 /* Korean */
+ };
+
+ static Vector<DWORD, 4> codePageMasks;
+ static bool initialized;
+ if (!initialized) {
+ initialized = true;
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+ IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface();
+#else
+ IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface();
+#endif
+ if (!langFontLink)
+ return codePageMasks;
+
+ UINT defaultCodePage;
+ DWORD defaultCodePageMask = 0;
+ if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_RETURN_NUMBER | LOCALE_IDEFAULTANSICODEPAGE, reinterpret_cast<LPWSTR>(&defaultCodePage), sizeof(defaultCodePage)))
+ langFontLink->CodePageToCodePages(defaultCodePage, &defaultCodePageMask);
+
+ if (defaultCodePage == CJKCodePages[0] || defaultCodePage == CJKCodePages[1] || defaultCodePage == CJKCodePages[2] || defaultCodePage == CJKCodePages[3])
+ codePageMasks.append(defaultCodePageMask);
+ for (unsigned i = 0; i < 4; ++i) {
+ if (defaultCodePage != CJKCodePages[i]) {
+ DWORD codePageMask;
+ langFontLink->CodePageToCodePages(CJKCodePages[i], &codePageMask);
+ codePageMasks.append(codePageMask);
+ }
+ }
+ }
+ return codePageMasks;
+}
+
+
+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 = FontPlatformData::adjustedGDIFontWeight(logFont->lfWeight, procData->m_familyName);
+ 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::platformInit()
+{
+}
+
+void FontCache::comInitialize()
+{
+}
+
+void FontCache::comUninitialize()
+{
+ if (langFontLink) {
+ langFontLink->Release();
+ langFontLink = 0;
+ }
+ if (multiLanguage) {
+ multiLanguage->Release();
+ multiLanguage = 0;
+ }
+}
+
+const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+{
+ String familyName;
+ WCHAR name[LF_FACESIZE];
+
+ UChar character = characters[0];
+ const FontPlatformData& origFont = font.primaryFont()->fontDataForCharacter(character)->platformData();
+ unsigned unicodeRange = findCharUnicodeRange(character);
+
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+ if (IMLangFontLink2* langFontLink = getFontLinkInterface()) {
+#else
+ if (IMLangFontLink* langFontLink = getFontLinkInterface()) {
+#endif
+ HGDIOBJ oldFont = GetCurrentObject(g_screenDC, OBJ_FONT);
+ HFONT hfont = 0;
+ DWORD codePages = 0;
+ UINT codePage = 0;
+ // Try MLang font linking first.
+ langFontLink->GetCharCodePages(character, &codePages);
+ if (codePages && unicodeRange == cRangeSetCJK) {
+ // The CJK character may belong to multiple code pages. We want to
+ // do font linking against a single one of them, preferring the default
+ // code page for the user's locale.
+ const Vector<DWORD, 4>& CJKCodePageMasks = getCJKCodePageMasks();
+ unsigned numCodePages = CJKCodePageMasks.size();
+ for (unsigned i = 0; i < numCodePages; ++i) {
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+ hfont = createMLangFont(langFontLink, g_screenDC, CJKCodePageMasks[i]);
+#else
+ hfont = createMLangFont(langFontLink, g_screenDC, origFont, CJKCodePageMasks[i]);
+#endif
+ if (!hfont)
+ continue;
+
+ SelectObject(g_screenDC, hfont);
+ GetTextFace(g_screenDC, LF_FACESIZE, name);
+
+ if (hfont && !(codePages & CJKCodePageMasks[i])) {
+ // We asked about a code page that is not one of the code pages
+ // returned by MLang, so the font might not contain the character.
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+ if (!currentFontContainsCharacter(langFontLink, g_screenDC, character)) {
+#else
+ if (!currentFontContainsCharacter(langFontLink, g_screenDC, hfont, character, name)) {
+#endif
+ SelectObject(g_screenDC, oldFont);
+ langFontLink->ReleaseFont(hfont);
+ hfont = 0;
+ continue;
+ }
+ }
+ break;
+ }
+ } else {
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+ hfont = createMLangFont(langFontLink, g_screenDC, codePages, character);
+#else
+ hfont = createMLangFont(langFontLink, g_screenDC, origFont, codePages);
+#endif
+ SelectObject(g_screenDC, hfont);
+ GetTextFace(g_screenDC, LF_FACESIZE, name);
+ }
+ SelectObject(g_screenDC, oldFont);
+
+ if (hfont) {
+ familyName = name;
+ langFontLink->ReleaseFont(hfont);
+ } else
+ FontPlatformData::mapKnownFont(codePages, familyName);
+ }
+
+ if (familyName.isEmpty())
+ familyName = FontPlatformData::defaultFontFamily();
+
+ if (!familyName.isEmpty()) {
+ // FIXME: temporary workaround for Thai font problem
+ FontDescription fontDescription(font.fontDescription());
+ if (unicodeRange == cRangeThai && fontDescription.weight() > FontWeightNormal)
+ fontDescription.setWeight(FontWeightNormal);
+
+ FontPlatformData* result = getCachedFontPlatformData(fontDescription, familyName);
+ if (result && result->hash() != origFont.hash()) {
+ if (SimpleFontData* fontData = getCachedFontData(result))
+ return fontData;
+ }
+ }
+
+ return 0;
+}
+
+SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
+{
+ return 0;
+}
+
+SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDesc)
+{
+ // 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.
+ return getCachedFontData(fontDesc, FontPlatformData::defaultFontFamily());
+}
+
+FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+{
+ FontPlatformData* result = new FontPlatformData(fontDescription, family);
+ return result;
+}
+
+void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
+{
+ LOGFONT logFont;
+ logFont.lfCharSet = DEFAULT_CHARSET;
+ unsigned familyLength = std::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(g_screenDC, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0);
+ copyToVector(procData.m_traitsMasks, traitsMasks);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/FontCacheWince.cpp b/WebCore/platform/graphics/wince/FontCacheWince.cpp
deleted file mode 100644
index 6b5dfa5..0000000
--- a/WebCore/platform/graphics/wince/FontCacheWince.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
-* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
-* Copyright (C) 2007-2009 Torch Mobile, 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.
-* 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 "Font.h"
-#include "FontData.h"
-#include "SimpleFontData.h"
-#include "UnicodeRange.h"
-#include "wtf/OwnPtr.h"
-
-#include <windows.h>
-#include <mlang.h>
-
-namespace WebCore {
-
-extern HDC g_screenDC;
-
-static IMultiLanguage *multiLanguage = 0;
-
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
-static IMLangFontLink2* langFontLink = 0;
-#else
-static IMLangFontLink* langFontLink = 0;
-#endif
-
-IMultiLanguage* FontCache::getMultiLanguageInterface()
-{
- if (!multiLanguage)
- CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_INPROC_SERVER, IID_IMultiLanguage, (void**)&multiLanguage);
-
- return multiLanguage;
-}
-
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
-IMLangFontLink2* FontCache::getFontLinkInterface()
-#else
-IMLangFontLink* FontCache::getFontLinkInterface()
-#endif
-{
- if (!langFontLink) {
- if (IMultiLanguage* mli = getMultiLanguageInterface())
- mli->QueryInterface(&langFontLink);
- }
-
- return langFontLink;
-}
-
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
-static bool currentFontContainsCharacter(IMLangFontLink2* langFontLink, HDC hdc, UChar character)
-{
- UINT unicodeRanges;
- if (S_OK != langFontLink->GetFontUnicodeRanges(hdc, &unicodeRanges, 0))
- return false;
-
- static Vector<UNICODERANGE, 64> glyphsetBuffer;
- glyphsetBuffer.resize(unicodeRanges);
-
- if (S_OK != langFontLink->GetFontUnicodeRanges(hdc, &unicodeRanges, glyphsetBuffer.data()))
- return false;
-
- // FIXME: Change this to a binary search. (Yong Li: That's easy. But, is it guaranteed that the ranges are sorted?)
- for (Vector<UNICODERANGE, 64>::const_iterator i = glyphsetBuffer.begin(); i != glyphsetBuffer.end(); ++i) {
- if (i->wcTo >= character)
- return i->wcFrom <= character;
- }
-
- return false;
-}
-#else
-static bool currentFontContainsCharacter(IMLangFontLink* langFontLink, HDC hdc, HFONT hfont, UChar character, const wchar_t* faceName)
-{
- DWORD fontCodePages = 0, charCodePages = 0;
- HRESULT result = langFontLink->GetFontCodePages(hdc, hfont, &fontCodePages);
- if (result != S_OK)
- return false;
- result = langFontLink->GetCharCodePages(character, &charCodePages);
- if (result != S_OK)
- return false;
-
- fontCodePages |= FontPlatformData::getKnownFontCodePages(faceName);
- if (fontCodePages & charCodePages)
- return true;
-
- return false;
-}
-#endif
-
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
-static HFONT createMLangFont(IMLangFontLink2* langFontLink, HDC hdc, DWORD codePageMask, UChar character = 0)
-{
- HFONT mlangFont;
- if (SUCCEEDED(langFontLink->MapFont(hdc, codePageMask, character, &mlangFont)))
- return mlangFont;
-
- return 0;
-}
-#else
-static HFONT createMLangFont(IMLangFontLink* langFontLink, HDC hdc, const FontPlatformData& refFont, DWORD codePageMask)
-{
- HFONT mlangFont;
- LRESULT result = langFontLink->MapFont(hdc, codePageMask, refFont.hfont(), &mlangFont);
-
- return result == S_OK ? mlangFont : 0;
-}
-#endif
-
-static const Vector<DWORD, 4>& getCJKCodePageMasks()
-{
- // The default order in which we look for a font for a CJK character. If the user's default code page is
- // one of these, we will use it first.
- static const UINT CJKCodePages[] = {
- 932, /* Japanese */
- 936, /* Simplified Chinese */
- 950, /* Traditional Chinese */
- 949 /* Korean */
- };
-
- static Vector<DWORD, 4> codePageMasks;
- static bool initialized;
- if (!initialized) {
- initialized = true;
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface();
-#else
- IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface();
-#endif
- if (!langFontLink)
- return codePageMasks;
-
- UINT defaultCodePage;
- DWORD defaultCodePageMask = 0;
- if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_RETURN_NUMBER | LOCALE_IDEFAULTANSICODEPAGE, reinterpret_cast<LPWSTR>(&defaultCodePage), sizeof(defaultCodePage)))
- langFontLink->CodePageToCodePages(defaultCodePage, &defaultCodePageMask);
-
- if (defaultCodePage == CJKCodePages[0] || defaultCodePage == CJKCodePages[1] || defaultCodePage == CJKCodePages[2] || defaultCodePage == CJKCodePages[3])
- codePageMasks.append(defaultCodePageMask);
- for (unsigned i = 0; i < 4; ++i) {
- if (defaultCodePage != CJKCodePages[i]) {
- DWORD codePageMask;
- langFontLink->CodePageToCodePages(CJKCodePages[i], &codePageMask);
- codePageMasks.append(codePageMask);
- }
- }
- }
- return codePageMasks;
-}
-
-
-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 = FontPlatformData::adjustedGDIFontWeight(logFont->lfWeight, procData->m_familyName);
- 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::platformInit()
-{
-}
-
-void FontCache::comInitialize()
-{
-}
-
-void FontCache::comUninitialize()
-{
- if (langFontLink) {
- langFontLink->Release();
- langFontLink = 0;
- }
- if (multiLanguage) {
- multiLanguage->Release();
- multiLanguage = 0;
- }
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- String familyName;
- WCHAR name[LF_FACESIZE];
-
- UChar character = characters[0];
- const FontPlatformData& origFont = font.primaryFont()->fontDataForCharacter(character)->platformData();
- unsigned unicodeRange = findCharUnicodeRange(character);
-
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- if (IMLangFontLink2* langFontLink = getFontLinkInterface()) {
-#else
- if (IMLangFontLink* langFontLink = getFontLinkInterface()) {
-#endif
- HGDIOBJ oldFont = GetCurrentObject(g_screenDC, OBJ_FONT);
- HFONT hfont = 0;
- DWORD codePages = 0;
- UINT codePage = 0;
- // Try MLang font linking first.
- langFontLink->GetCharCodePages(character, &codePages);
- if (codePages && unicodeRange == cRangeSetCJK) {
- // The CJK character may belong to multiple code pages. We want to
- // do font linking against a single one of them, preferring the default
- // code page for the user's locale.
- const Vector<DWORD, 4>& CJKCodePageMasks = getCJKCodePageMasks();
- unsigned numCodePages = CJKCodePageMasks.size();
- for (unsigned i = 0; i < numCodePages; ++i) {
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- hfont = createMLangFont(langFontLink, g_screenDC, CJKCodePageMasks[i]);
-#else
- hfont = createMLangFont(langFontLink, g_screenDC, origFont, CJKCodePageMasks[i]);
-#endif
- if (!hfont)
- continue;
-
- SelectObject(g_screenDC, hfont);
- GetTextFace(g_screenDC, LF_FACESIZE, name);
-
- if (hfont && !(codePages & CJKCodePageMasks[i])) {
- // We asked about a code page that is not one of the code pages
- // returned by MLang, so the font might not contain the character.
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- if (!currentFontContainsCharacter(langFontLink, g_screenDC, character)) {
-#else
- if (!currentFontContainsCharacter(langFontLink, g_screenDC, hfont, character, name)) {
-#endif
- SelectObject(g_screenDC, oldFont);
- langFontLink->ReleaseFont(hfont);
- hfont = 0;
- continue;
- }
- }
- break;
- }
- } else {
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- hfont = createMLangFont(langFontLink, g_screenDC, codePages, character);
-#else
- hfont = createMLangFont(langFontLink, g_screenDC, origFont, codePages);
-#endif
- SelectObject(g_screenDC, hfont);
- GetTextFace(g_screenDC, LF_FACESIZE, name);
- }
- SelectObject(g_screenDC, oldFont);
-
- if (hfont) {
- familyName = name;
- langFontLink->ReleaseFont(hfont);
- } else
- FontPlatformData::mapKnownFont(codePages, familyName);
- }
-
- if (familyName.isEmpty())
- familyName = FontPlatformData::defaultFontFamily();
-
- if (!familyName.isEmpty()) {
- // FIXME: temporary workaround for Thai font problem
- FontDescription fontDescription(font.fontDescription());
- if (unicodeRange == cRangeThai && fontDescription.weight() > FontWeightNormal)
- fontDescription.setWeight(FontWeightNormal);
-
- FontPlatformData* result = getCachedFontPlatformData(fontDescription, familyName);
- if (result && result->hash() != origFont.hash()) {
- if (SimpleFontData* fontData = getCachedFontData(result))
- return fontData;
- }
- }
-
- return 0;
-}
-
-SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDesc)
-{
- // 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.
- return getCachedFontData(fontDesc, FontPlatformData::defaultFontFamily());
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- FontPlatformData* result = new FontPlatformData(fontDescription, family);
- return result;
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- LOGFONT logFont;
- logFont.lfCharSet = DEFAULT_CHARSET;
- unsigned familyLength = std::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(g_screenDC, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0);
- copyToVector(procData.m_traitsMasks, traitsMasks);
-}
-
-}
-
diff --git a/WebCore/platform/graphics/wince/FontWinCE.cpp b/WebCore/platform/graphics/wince/FontWinCE.cpp
new file mode 100644
index 0000000..e2ff067
--- /dev/null
+++ b/WebCore/platform/graphics/wince/FontWinCE.cpp
@@ -0,0 +1,337 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, Inc.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ *
+ * 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 "Font.h"
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "FontCache.h"
+#include "FontData.h"
+#include "FontFallbackList.h"
+#include "GlyphBuffer.h"
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include "NotImplemented.h"
+#include "WidthIterator.h"
+#include <wtf/MathExtras.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/unicode/Unicode.h>
+
+#include <windows.h>
+
+using namespace WTF::Unicode;
+
+namespace WebCore {
+
+HDC g_screenDC = GetDC(0);
+
+class ScreenDcReleaser {
+public:
+ ~ScreenDcReleaser()
+ {
+ ReleaseDC(0, g_screenDC);
+ }
+};
+
+ScreenDcReleaser releaseScreenDc;
+
+void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer,
+ int from, int numGlyphs, const FloatPoint& point) const
+{
+ graphicsContext->drawText(fontData, glyphBuffer, from, numGlyphs, point);
+}
+
+class TextRunComponent {
+public:
+ TextRunComponent() : m_textRun(0, 0) {}
+ TextRunComponent(const UChar *start, int length, const TextRun& parentTextRun, const Font &font, int offset);
+ TextRunComponent(int spaces, const Font &font, int offset);
+ ~TextRunComponent() { m_textRun; }
+
+ bool isSpace() const { return m_spaces; }
+ int textLength() const { return m_spaces ? m_spaces : m_textRun.length(); }
+
+ TextRun m_textRun;
+ float m_width;
+ int m_offset;
+ int m_spaces;
+};
+
+TextRunComponent::TextRunComponent(const UChar *start, int length, const TextRun& parentTextRun, const Font &font, int o)
+ : m_textRun(start, length, parentTextRun.allowTabs(), 0, 0
+ , parentTextRun.rtl()
+ , parentTextRun.directionalOverride()
+ , parentTextRun.applyRunRounding()
+ , parentTextRun.applyWordRounding())
+ , m_offset(o)
+ , m_spaces(0)
+{
+ WidthIterator it(&font, m_textRun);
+ it.advance(m_textRun.length(), 0);
+ m_width = it.m_runWidthSoFar;
+}
+
+TextRunComponent::TextRunComponent(int s, const Font &font, int o)
+ : m_textRun(0, 0)
+ , m_offset(o)
+ , m_spaces(s)
+{
+ m_width = s * font.primaryFont()->widthForGlyph(' ');
+}
+
+typedef Vector<TextRunComponent, 128> TextRunComponents;
+
+static int generateComponents(TextRunComponents* components, const Font &font, const TextRun &run)
+{
+ int letterSpacing = font.letterSpacing();
+ int wordSpacing = font.wordSpacing();
+ int padding = run.padding();
+ int numSpaces = 0;
+ if (padding) {
+ for (int i = 0; i < run.length(); i++)
+ if (Font::treatAsSpace(run[i]))
+ ++numSpaces;
+ }
+
+ int offset = 0;
+ if (letterSpacing) {
+ // need to draw every letter on it's own
+ int start = 0;
+ if (Font::treatAsSpace(run[0])) {
+ int add = 0;
+ if (numSpaces) {
+ add = padding/numSpaces;
+ padding -= add;
+ --numSpaces;
+ }
+ components->append(TextRunComponent(1, font, offset));
+ offset += add + letterSpacing + components->last().m_width;
+ start = 1;
+ }
+ for (int i = 1; i < run.length(); ++i) {
+ uint ch = run[i];
+ if (isHighSurrogate(ch) && isLowSurrogate(run[i-1]))
+ ch = surrogateToUcs4(ch, run[i-1]);
+ if (isLowSurrogate(ch) || category(ch) == Mark_NonSpacing)
+ continue;
+ if (Font::treatAsSpace(run[i])) {
+ int add = 0;
+ if (i - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, i - start,
+ run, font, offset));
+ offset += components->last().m_width + letterSpacing;
+ }
+ if (numSpaces) {
+ add = padding/numSpaces;
+ padding -= add;
+ --numSpaces;
+ }
+ components->append(TextRunComponent(1, font, offset));
+ offset += wordSpacing + add + components->last().m_width + letterSpacing;
+ start = i + 1;
+ continue;
+ }
+ if (i - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, i - start,
+ run,
+ font, offset));
+ offset += components->last().m_width + letterSpacing;
+ }
+ start = i;
+ }
+ if (run.length() - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, run.length() - start,
+ run,
+ font, offset));
+ offset += components->last().m_width;
+ }
+ offset += letterSpacing;
+ } else {
+ int start = 0;
+ for (int i = 0; i < run.length(); ++i) {
+ if (Font::treatAsSpace(run[i])) {
+ if (i - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, i - start,
+ run,
+ font, offset));
+ offset += components->last().m_width;
+ }
+ int add = 0;
+ if (numSpaces) {
+ add = padding/numSpaces;
+ padding -= add;
+ --numSpaces;
+ }
+ components->append(TextRunComponent(1, font, offset));
+ offset += add + components->last().m_width;
+ if (i)
+ offset += wordSpacing;
+ start = i + 1;
+ }
+ }
+ if (run.length() - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, run.length() - start,
+ run,
+ font, offset));
+ offset += components->last().m_width;
+ }
+ }
+ return offset;
+}
+
+void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
+ int from, int to) const
+{
+ if (to < 0)
+ to = run.length();
+ if (from < 0)
+ from = 0;
+
+ TextRunComponents components;
+ int w = generateComponents(&components, *this, run);
+
+ int curPos = 0;
+ for (int i = 0; i < (int)components.size(); ++i) {
+ const TextRunComponent& comp = components.at(i);
+ int len = comp.textLength();
+ int curEnd = curPos + len;
+ if (curPos < to && from < curEnd && !comp.isSpace()) {
+ FloatPoint pt = point;
+ if (run.rtl())
+ pt.setX(point.x() + w - comp.m_offset - comp.m_width);
+ else
+ pt.setX(point.x() + comp.m_offset);
+ drawSimpleText(context, comp.m_textRun, pt, from - curPos, std::min(to, curEnd) - curPos);
+ }
+ curPos += len;
+ if (from < curPos)
+ from = curPos;
+ }
+}
+
+float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
+{
+ TextRunComponents components;
+ int w = generateComponents(&components, *this, run);
+ return w;
+}
+
+int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, bool includePartialGlyphs) const
+{
+ // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
+ // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
+ int position = static_cast<int>(xFloat);
+
+ TextRunComponents components;
+ int w = generateComponents(&components, *this, run);
+
+ if (position >= w)
+ return run.length();
+
+ int offset = 0;
+ if (run.rtl()) {
+ for (size_t i = 0; i < components.size(); ++i) {
+ const TextRunComponent& comp = components.at(i);
+ int xe = w - comp.m_offset;
+ int xs = xe - comp.m_width;
+ if (position >= xs)
+ return offset + (comp.isSpace()
+ ? static_cast<int>((position - xe) * comp.m_spaces / std::max(1.f, comp.m_width) + 0.5)
+ : offsetForPositionForSimpleText(comp.m_textRun, position - xs, includePartialGlyphs));
+
+ offset += comp.textLength();
+ }
+ } else {
+ for (size_t i = 0; i < components.size(); ++i) {
+ const TextRunComponent& comp = components.at(i);
+ int xs = comp.m_offset;
+ int xe = xs + comp.m_width;
+ if (position <= xe) {
+ if (position - xs >= xe)
+ return offset + comp.textLength();
+ return offset + (comp.isSpace()
+ ? static_cast<int>((position - xs) * comp.m_spaces / std::max(1.f, comp.m_width) + 0.5)
+ : offsetForPositionForSimpleText(comp.m_textRun, position - xs, includePartialGlyphs));
+ }
+ offset += comp.textLength();
+ }
+ }
+ return run.length();
+}
+
+
+static float cursorToX(const Font* font, const TextRunComponents& components, int width, bool rtl, int cursor)
+{
+ int start = 0;
+ for (size_t i = 0; i < components.size(); ++i) {
+ const TextRunComponent& comp = components.at(i);
+ if (start + comp.textLength() <= cursor) {
+ start += comp.textLength();
+ continue;
+ }
+ int xs = comp.m_offset;
+ if (rtl)
+ xs = width - xs - comp.m_width;
+
+ int pos = cursor - start;
+ if (comp.isSpace()) {
+ if (rtl)
+ pos = comp.textLength() - pos;
+ return xs + pos * comp.m_width / comp.m_spaces;
+ }
+ WidthIterator it(font, comp.m_textRun);
+ it.advance(pos);
+ return xs + it.m_runWidthSoFar;
+ }
+ return width;
+}
+
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& pt,
+ int h, int from, int to) const
+{
+ TextRunComponents components;
+ int w = generateComponents(&components, *this, run);
+
+ if (!from && to == run.length())
+ return FloatRect(pt.x(), pt.y(), w, h);
+
+ float x1 = cursorToX(this, components, w, run.rtl(), from);
+ float x2 = cursorToX(this, components, w, run.rtl(), to);
+ if (x2 < x1)
+ std::swap(x1, x2);
+
+ return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
+}
+
+bool Font::canReturnFallbackFontsForComplexText()
+{
+ return false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/FontWince.cpp b/WebCore/platform/graphics/wince/FontWince.cpp
deleted file mode 100644
index c0948c0..0000000
--- a/WebCore/platform/graphics/wince/FontWince.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, Inc.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * 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 "Font.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "FontCache.h"
-#include "FontData.h"
-#include "FontFallbackList.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "WidthIterator.h"
-#include <wtf/MathExtras.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/unicode/Unicode.h>
-
-#include <windows.h>
-
-using namespace WTF::Unicode;
-
-namespace WebCore {
-
-HDC g_screenDC = GetDC(0);
-
-class ScreenDcReleaser {
-public:
- ~ScreenDcReleaser()
- {
- ReleaseDC(0, g_screenDC);
- }
-};
-
-ScreenDcReleaser releaseScreenDc;
-
-void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point) const
-{
- graphicsContext->drawText(fontData, glyphBuffer, from, numGlyphs, point);
-}
-
-class TextRunComponent {
-public:
- TextRunComponent() : m_textRun(0, 0) {}
- TextRunComponent(const UChar *start, int length, const TextRun& parentTextRun, const Font &font, int offset);
- TextRunComponent(int spaces, const Font &font, int offset);
- ~TextRunComponent() { m_textRun; }
-
- bool isSpace() const { return m_spaces; }
- int textLength() const { return m_spaces ? m_spaces : m_textRun.length(); }
-
- TextRun m_textRun;
- float m_width;
- int m_offset;
- int m_spaces;
-};
-
-TextRunComponent::TextRunComponent(const UChar *start, int length, const TextRun& parentTextRun, const Font &font, int o)
- : m_textRun(start, length, parentTextRun.allowTabs(), 0, 0
- , parentTextRun.rtl()
- , parentTextRun.directionalOverride()
- , parentTextRun.applyRunRounding()
- , parentTextRun.applyWordRounding())
- , m_offset(o)
- , m_spaces(0)
-{
- WidthIterator it(&font, m_textRun);
- it.advance(m_textRun.length(), 0);
- m_width = it.m_runWidthSoFar;
-}
-
-TextRunComponent::TextRunComponent(int s, const Font &font, int o)
- : m_textRun(0, 0)
- , m_offset(o)
- , m_spaces(s)
-{
- m_width = s * font.primaryFont()->widthForGlyph(' ');
-}
-
-typedef Vector<TextRunComponent, 128> TextRunComponents;
-
-static int generateComponents(TextRunComponents* components, const Font &font, const TextRun &run)
-{
- int letterSpacing = font.letterSpacing();
- int wordSpacing = font.wordSpacing();
- int padding = run.padding();
- int numSpaces = 0;
- if (padding) {
- for (int i = 0; i < run.length(); i++)
- if (Font::treatAsSpace(run[i]))
- ++numSpaces;
- }
-
- int offset = 0;
- if (letterSpacing) {
- // need to draw every letter on it's own
- int start = 0;
- if (Font::treatAsSpace(run[0])) {
- int add = 0;
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, font, offset));
- offset += add + letterSpacing + components->last().m_width;
- start = 1;
- }
- for (int i = 1; i < run.length(); ++i) {
- uint ch = run[i];
- if (isHighSurrogate(ch) && isLowSurrogate(run[i-1]))
- ch = surrogateToUcs4(ch, run[i-1]);
- if (isLowSurrogate(ch) || category(ch) == Mark_NonSpacing)
- continue;
- if (Font::treatAsSpace(run[i])) {
- int add = 0;
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run, font, offset));
- offset += components->last().m_width + letterSpacing;
- }
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, font, offset));
- offset += wordSpacing + add + components->last().m_width + letterSpacing;
- start = i + 1;
- continue;
- }
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run,
- font, offset));
- offset += components->last().m_width + letterSpacing;
- }
- start = i;
- }
- if (run.length() - start > 0) {
- components->append(TextRunComponent(run.characters() + start, run.length() - start,
- run,
- font, offset));
- offset += components->last().m_width;
- }
- offset += letterSpacing;
- } else {
- int start = 0;
- for (int i = 0; i < run.length(); ++i) {
- if (Font::treatAsSpace(run[i])) {
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run,
- font, offset));
- offset += components->last().m_width;
- }
- int add = 0;
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, font, offset));
- offset += add + components->last().m_width;
- if (i)
- offset += wordSpacing;
- start = i + 1;
- }
- }
- if (run.length() - start > 0) {
- components->append(TextRunComponent(run.characters() + start, run.length() - start,
- run,
- font, offset));
- offset += components->last().m_width;
- }
- }
- return offset;
-}
-
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
- int from, int to) const
-{
- if (to < 0)
- to = run.length();
- if (from < 0)
- from = 0;
-
- TextRunComponents components;
- int w = generateComponents(&components, *this, run);
-
- int curPos = 0;
- for (int i = 0; i < (int)components.size(); ++i) {
- const TextRunComponent& comp = components.at(i);
- int len = comp.textLength();
- int curEnd = curPos + len;
- if (curPos < to && from < curEnd && !comp.isSpace()) {
- FloatPoint pt = point;
- if (run.rtl())
- pt.setX(point.x() + w - comp.m_offset - comp.m_width);
- else
- pt.setX(point.x() + comp.m_offset);
- drawSimpleText(context, comp.m_textRun, pt, from - curPos, std::min(to, curEnd) - curPos);
- }
- curPos += len;
- if (from < curPos)
- from = curPos;
- }
-}
-
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
-{
- TextRunComponents components;
- int w = generateComponents(&components, *this, run);
- return w;
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, bool includePartialGlyphs) const
-{
- // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
- // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
- int position = static_cast<int>(xFloat);
-
- TextRunComponents components;
- int w = generateComponents(&components, *this, run);
-
- if (position >= w)
- return run.length();
-
- int offset = 0;
- if (run.rtl()) {
- for (size_t i = 0; i < components.size(); ++i) {
- const TextRunComponent& comp = components.at(i);
- int xe = w - comp.m_offset;
- int xs = xe - comp.m_width;
- if (position >= xs)
- return offset + (comp.isSpace()
- ? static_cast<int>((position - xe) * comp.m_spaces / std::max(1.f, comp.m_width) + 0.5)
- : offsetForPositionForSimpleText(comp.m_textRun, position - xs, includePartialGlyphs));
-
- offset += comp.textLength();
- }
- } else {
- for (size_t i = 0; i < components.size(); ++i) {
- const TextRunComponent& comp = components.at(i);
- int xs = comp.m_offset;
- int xe = xs + comp.m_width;
- if (position <= xe) {
- if (position - xs >= xe)
- return offset + comp.textLength();
- return offset + (comp.isSpace()
- ? static_cast<int>((position - xs) * comp.m_spaces / std::max(1.f, comp.m_width) + 0.5)
- : offsetForPositionForSimpleText(comp.m_textRun, position - xs, includePartialGlyphs));
- }
- offset += comp.textLength();
- }
- }
- return run.length();
-}
-
-
-static float cursorToX(const Font* font, const TextRunComponents& components, int width, bool rtl, int cursor)
-{
- int start = 0;
- for (size_t i = 0; i < components.size(); ++i) {
- const TextRunComponent& comp = components.at(i);
- if (start + comp.textLength() <= cursor) {
- start += comp.textLength();
- continue;
- }
- int xs = comp.m_offset;
- if (rtl)
- xs = width - xs - comp.m_width;
-
- int pos = cursor - start;
- if (comp.isSpace()) {
- if (rtl)
- pos = comp.textLength() - pos;
- return xs + pos * comp.m_width / comp.m_spaces;
- }
- WidthIterator it(font, comp.m_textRun);
- it.advance(pos);
- return xs + it.m_runWidthSoFar;
- }
- return width;
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& pt,
- int h, int from, int to) const
-{
- TextRunComponents components;
- int w = generateComponents(&components, *this, run);
-
- if (!from && to == run.length())
- return FloatRect(pt.x(), pt.y(), w, h);
-
- float x1 = cursorToX(this, components, w, run.rtl(), from);
- float x2 = cursorToX(this, components, w, run.rtl(), to);
- if (x2 < x1)
- std::swap(x1, x2);
-
- return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
-}
-
-bool Font::canReturnFallbackFontsForComplexText()
-{
- return false;
-}
-
-}
diff --git a/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp b/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp
new file mode 100644
index 0000000..1c22f23
--- /dev/null
+++ b/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2007-2009 Torch Mobile 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 "GlyphPageTreeNode.h"
+
+#include "Font.h"
+#include "FontCache.h"
+#include "FontData.h"
+#include "SimpleFontData.h"
+
+namespace WebCore {
+
+DWORD getKnownFontCodePages(const wchar_t* family);
+
+typedef unsigned (*funcGetCharCodePages)(unsigned short c, unsigned& lastPos);
+funcGetCharCodePages getCharCodePages = 0;
+
+bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
+{
+ if (length != bufferLength)
+ return false;
+
+ if (fontData->platformData().hfont()) {
+ DWORD fontCodePages = fontData->platformData().codePages();
+ if (fontCodePages) {
+ if (getCharCodePages) {
+ unsigned lastPos = 0;
+ for (unsigned i = 0; i < bufferLength; ++i) {
+ DWORD actualCodePages = getCharCodePages(buffer[i], lastPos);
+ if (!actualCodePages || (actualCodePages & fontCodePages))
+ setGlyphDataForIndex(offset + i, buffer[i], fontData);
+ else
+ setGlyphDataForIndex(offset + i, buffer[i], 0);
+ }
+ return true;
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+ } else if (IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface()) {
+#else
+ } else if (IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface()) {
+#endif
+ for (unsigned i = 0; i < bufferLength; ++i) {
+ DWORD actualCodePages;
+ langFontLink->GetCharCodePages(buffer[i], &actualCodePages);
+ if (!actualCodePages || (actualCodePages & fontCodePages))
+ setGlyphDataForIndex(offset + i, buffer[i], fontData);
+ else
+ setGlyphDataForIndex(offset + i, buffer[i], 0);
+ }
+ return true;
+ }
+ }
+ }
+
+ for (unsigned i = 0; i < length; ++i)
+ setGlyphDataForIndex(offset + i, buffer[i], fontData);
+
+ return true;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/GlyphPageTreeNodeWince.cpp b/WebCore/platform/graphics/wince/GlyphPageTreeNodeWince.cpp
deleted file mode 100644
index 27c4e15..0000000
--- a/WebCore/platform/graphics/wince/GlyphPageTreeNodeWince.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Torch Mobile 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 "GlyphPageTreeNode.h"
-
-#include "Font.h"
-#include "FontCache.h"
-#include "FontData.h"
-#include "SimpleFontData.h"
-
-namespace WebCore {
-
-DWORD getKnownFontCodePages(const wchar_t* family);
-
-typedef unsigned (*funcGetCharCodePages)(unsigned short c, unsigned& lastPos);
-funcGetCharCodePages getCharCodePages = 0;
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- if (length != bufferLength)
- return false;
-
- if (fontData->platformData().hfont()) {
- DWORD fontCodePages = fontData->platformData().codePages();
- if (fontCodePages) {
- if (getCharCodePages) {
- unsigned lastPos = 0;
- for (unsigned i = 0; i < bufferLength; ++i) {
- DWORD actualCodePages = getCharCodePages(buffer[i], lastPos);
- if (!actualCodePages || (actualCodePages & fontCodePages))
- setGlyphDataForIndex(offset + i, buffer[i], fontData);
- else
- setGlyphDataForIndex(offset + i, buffer[i], 0);
- }
- return true;
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- } else if (IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface()) {
-#else
- } else if (IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface()) {
-#endif
- for (unsigned i = 0; i < bufferLength; ++i) {
- DWORD actualCodePages;
- langFontLink->GetCharCodePages(buffer[i], &actualCodePages);
- if (!actualCodePages || (actualCodePages & fontCodePages))
- setGlyphDataForIndex(offset + i, buffer[i], fontData);
- else
- setGlyphDataForIndex(offset + i, buffer[i], 0);
- }
- return true;
- }
- }
- }
-
- for (unsigned i = 0; i < length; ++i)
- setGlyphDataForIndex(offset + i, buffer[i], fontData);
-
- return true;
-}
-
-}
-
diff --git a/WebCore/platform/graphics/wince/GradientWinCE.cpp b/WebCore/platform/graphics/wince/GradientWinCE.cpp
new file mode 100644
index 0000000..73a1fdb
--- /dev/null
+++ b/WebCore/platform/graphics/wince/GradientWinCE.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 Torch Mobile, 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#include "config.h"
+#include "Gradient.h"
+
+#include "GraphicsContext.h"
+
+namespace WebCore {
+
+void Gradient::platformDestroy()
+{
+}
+
+static inline bool compareStops(const Gradient::ColorStop& a, const Gradient::ColorStop& b)
+{
+ return a.stop < b.stop;
+}
+
+const Vector<Gradient::ColorStop>& Gradient::getStops() const
+{
+ if (!m_stopsSorted) {
+ if (m_stops.size())
+ std::stable_sort(m_stops.begin(), m_stops.end(), compareStops);
+ m_stopsSorted = true;
+ }
+ return m_stops;
+}
+
+void Gradient::fill(GraphicsContext* c, const FloatRect& r)
+{
+ c->fillRect(r, this);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/GradientWince.cpp b/WebCore/platform/graphics/wince/GradientWince.cpp
deleted file mode 100644
index 49fa970..0000000
--- a/WebCore/platform/graphics/wince/GradientWince.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2009 Torch Mobile, 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., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "GraphicsContext.h"
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
-}
-
-static inline bool compareStops(const Gradient::ColorStop& a, const Gradient::ColorStop& b)
-{
- return a.stop < b.stop;
-}
-
-const Vector<Gradient::ColorStop>& Gradient::getStops() const
-{
- if (!m_stopsSorted) {
- if (m_stops.size())
- std::stable_sort(m_stops.begin(), m_stops.end(), compareStops);
- m_stopsSorted = true;
- }
- return m_stops;
-}
-
-void Gradient::fill(GraphicsContext* c, const FloatRect& r)
-{
- c->fillRect(r, this);
-}
-
-}
diff --git a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
new file mode 100644
index 0000000..a91b988
--- /dev/null
+++ b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
@@ -0,0 +1,1950 @@
+/*
+ * Copyright (C) 2007-2009 Torch Mobile 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 "GraphicsContext.h"
+
+#include "AffineTransform.h"
+#include "CharacterNames.h"
+#include "Font.h"
+#include "GlyphBuffer.h"
+#include "Gradient.h"
+#include "GraphicsContextPrivate.h"
+#include "NotImplemented.h"
+#include "Path.h"
+#include "PlatformPathWinCE.h"
+#include "SharedBitmap.h"
+#include "SimpleFontData.h"
+#include <wtf/OwnPtr.h>
+
+#include <windows.h>
+
+namespace WebCore {
+
+typedef void (*FuncGradientFillRectLinear)(HDC hdc, const IntRect& r, const IntPoint& p0, const IntPoint& p1, const Vector<Gradient::ColorStop>& stops);
+typedef void (*FuncGradientFillRectRadial)(HDC hdc, const IntRect& r, const IntPoint& p0, const IntPoint& p1, float r0, float r1, const Vector<Gradient::ColorStop>& stops);
+FuncGradientFillRectLinear g_linearGradientFiller = 0;
+FuncGradientFillRectRadial g_radialGradientFiller = 0;
+
+static inline bool isZero(double d)
+{
+ return d > 0 ? d <= 1.E-10 : d >= -1.E-10;
+}
+
+// stableRound rounds -0.5 to 0, where lround rounds -0.5 to -1.
+static inline int stableRound(double d)
+{
+ if (d > 0)
+ return static_cast<int>(d + 0.5);
+
+ int i = static_cast<int>(d);
+ return i - d > 0.5 ? i - 1 : i;
+}
+
+// Unlike enclosingIntRect(), this function does strict rounding.
+static inline IntRect roundRect(const FloatRect& r)
+{
+ return IntRect(stableRound(r.x()), stableRound(r.y()), stableRound(r.right()) - stableRound(r.x()), stableRound(r.bottom()) - stableRound(r.y()));
+}
+
+// Rotation transformation
+class RotationTransform {
+public:
+ RotationTransform()
+ : m_cosA(1.)
+ , m_sinA(0.)
+ , m_preShiftX(0)
+ , m_preShiftY(0)
+ , m_postShiftX(0)
+ , m_postShiftY(0)
+ {
+ }
+ RotationTransform operator-() const
+ {
+ RotationTransform rtn;
+ rtn.m_cosA = m_cosA;
+ rtn.m_sinA = -m_sinA;
+ rtn.m_preShiftX = m_postShiftX;
+ rtn.m_preShiftY = m_postShiftY;
+ rtn.m_postShiftX = m_preShiftX;
+ rtn.m_postShiftY = m_preShiftY;
+ return rtn;
+ }
+ void map(double x1, double y1, double* x2, double* y2) const
+ {
+ x1 += m_preShiftX;
+ y1 += m_preShiftY;
+ *x2 = x1 * m_cosA + y1 * m_sinA + m_postShiftX;
+ *y2 = y1 * m_cosA - x1 * m_sinA + m_postShiftY;
+ }
+ void map(int x1, int y1, int* x2, int* y2) const
+ {
+ x1 += m_preShiftX;
+ y1 += m_preShiftY;
+ *x2 = stableRound(x1 * m_cosA + y1 * m_sinA) + m_postShiftX;
+ *y2 = stableRound(y1 * m_cosA - x1 * m_sinA) + m_postShiftY;
+ }
+
+ double m_cosA;
+ double m_sinA;
+ int m_preShiftX;
+ int m_preShiftY;
+ int m_postShiftX;
+ int m_postShiftY;
+};
+
+template<class T> static inline IntPoint mapPoint(const IntPoint& p, const T& t)
+{
+ int x, y;
+ t.map(p.x(), p.y(), &x, &y);
+ return IntPoint(x, y);
+}
+
+template<class T> static inline FloatPoint mapPoint(const FloatPoint& p, const T& t)
+{
+ double x, y;
+ t.map(p.x(), p.y(), &x, &y);
+ return FloatPoint(static_cast<float>(x), static_cast<float>(y));
+}
+
+template<class Transform, class Rect, class Value> static inline Rect mapRect(const Rect& rect, const Transform& transform)
+{
+ Value x[4], y[4];
+ Value l, t, r, b;
+ r = rect.right() - 1;
+ b = rect.bottom() - 1;
+ transform.map(rect.x(), rect.y(), x, y);
+ transform.map(rect.x(), b, x + 1, y + 1);
+ transform.map(r, b, x + 2, y + 2);
+ transform.map(r, rect.y(), x + 3, y + 3);
+ l = r = x[3];
+ t = b = y[3];
+ for (int i = 0; i < 3; ++i) {
+ if (x[i] < l)
+ l = x[i];
+ else if (x[i] > r)
+ r = x[i];
+
+ if (y[i] < t)
+ t = y[i];
+ else if (y[i] > b)
+ b = y[i];
+ }
+
+ return IntRect(l, t, r - l + 1, b - t + 1);
+}
+
+template<class T> static inline IntRect mapRect(const IntRect& rect, const T& transform)
+{
+ return mapRect<T, IntRect, int>(rect, transform);
+}
+
+template<class T> static inline FloatRect mapRect(const FloatRect& rect, const T& transform)
+{
+ return mapRect<T, FloatRect, double>(rect, transform);
+}
+
+class GraphicsContextPlatformPrivateData {
+public:
+ GraphicsContextPlatformPrivateData()
+ : m_transform()
+ , m_opacity(1.0)
+ {
+ }
+
+ AffineTransform m_transform;
+ float m_opacity;
+ Vector<Path> m_paths;
+};
+
+enum AlphaPaintType {
+ AlphaPaintNone,
+ AlphaPaintImage,
+ AlphaPaintOther,
+};
+
+class GraphicsContextPlatformPrivate : public GraphicsContextPlatformPrivateData {
+public:
+ GraphicsContextPlatformPrivate(HDC dc)
+ : m_dc(dc)
+ {
+ }
+ ~GraphicsContextPlatformPrivate()
+ {
+ while (!m_backupData.isEmpty())
+ restore();
+ }
+
+ IntPoint origin() const
+ {
+ return IntPoint(stableRound(-m_transform.e()), stableRound(-m_transform.f()));
+ }
+
+ void translate(float x, float y)
+ {
+ m_transform.translate(x, y);
+ }
+
+ void scale(const FloatSize& size)
+ {
+ m_transform.scaleNonUniform(size.width(), size.height());
+ }
+
+ void rotate(float radians)
+ {
+ m_transform.rotate(rad2deg(radians));
+ }
+
+ void concatCTM(const AffineTransform& transform)
+ {
+ m_transform = transform * m_transform;
+ }
+
+ IntRect mapRect(const IntRect& rect) const
+ {
+ return m_transform.mapRect(rect);
+ }
+
+ FloatRect mapRect(const FloatRect& rect) const
+ {
+ return m_transform.mapRect(rect);
+ }
+
+ IntPoint mapPoint(const IntPoint& point) const
+ {
+ return m_transform.mapPoint(point);
+ }
+
+ FloatPoint mapPoint(const FloatPoint& point) const
+ {
+ return m_transform.mapPoint(point);
+ }
+
+ FloatSize mapSize(const FloatSize& size) const
+ {
+ double w, h;
+ m_transform.map(size.width(), size.height(), w, h);
+ return FloatSize(static_cast<float>(w), static_cast<float>(h));
+ }
+
+ void save()
+ {
+ if (m_dc)
+ SaveDC(m_dc);
+
+ m_backupData.append(*static_cast<GraphicsContextPlatformPrivateData*>(this));
+ }
+
+ void restore()
+ {
+ if (m_backupData.isEmpty())
+ return;
+
+ if (m_dc)
+ RestoreDC(m_dc, -1);
+
+ GraphicsContextPlatformPrivateData::operator=(m_backupData.last());
+ m_backupData.removeLast();
+ }
+
+ bool hasAlpha() const { return m_bitmap && m_bitmap->hasAlpha(); }
+
+ PassRefPtr<SharedBitmap> getTransparentLayerBitmap(IntRect& origRect, AlphaPaintType alphaPaint, RECT& bmpRect, bool checkClipBox, bool force) const
+ {
+ if (m_opacity <= 0)
+ return 0;
+
+ if (force || m_opacity < 1.) {
+ if (checkClipBox) {
+ RECT clipBox;
+ int clipType = GetClipBox(m_dc, &clipBox);
+ if (clipType == SIMPLEREGION || clipType == COMPLEXREGION)
+ origRect.intersect(clipBox);
+ if (origRect.isEmpty())
+ return 0;
+ }
+
+ RefPtr<SharedBitmap> bmp = SharedBitmap::createInstance(alphaPaint == AlphaPaintNone, origRect.width(), origRect.height(), false);
+ SetRect(&bmpRect, 0, 0, origRect.width(), origRect.height());
+ if (bmp) {
+ switch (alphaPaint) {
+ case AlphaPaintNone:
+ case AlphaPaintImage:
+ {
+ SharedBitmap::DCHolder dc(bmp.get());
+ if (dc.get()) {
+ BitBlt(dc.get(), 0, 0, origRect.width(), origRect.height(), m_dc, origRect.x(), origRect.y(), SRCCOPY);
+ if (bmp->is32bit() && (!m_bitmap || m_bitmap->is16bit())) {
+ // Set alpha channel
+ unsigned* pixels = (unsigned*)bmp->bytes();
+ const unsigned* const pixelsEnd = pixels + bmp->bitmapInfo().numPixels();
+ while (pixels < pixelsEnd) {
+ *pixels |= 0xFF000000;
+ ++pixels;
+ }
+ }
+ return bmp;
+ }
+ }
+ break;
+ //case AlphaPaintOther:
+ default:
+ memset(bmp->bytes(), 0xFF, bmp->bitmapInfo().numPixels() * 4);
+ return bmp;
+ break;
+ }
+ }
+ }
+
+ bmpRect = origRect;
+ return 0;
+ }
+
+ void paintBackTransparentLayerBitmap(HDC hdc, SharedBitmap* bmp, const IntRect& origRect, AlphaPaintType alphaPaint, const RECT& bmpRect)
+ {
+ if (hdc == m_dc)
+ return;
+
+#if !defined(NO_ALPHABLEND)
+ if (alphaPaint == AlphaPaintOther) {
+ ASSERT(bmp && bmp->bytes() && bmp->is32bit());
+ unsigned* pixels = (unsigned*)bmp->bytes();
+ const unsigned* const pixelsEnd = pixels + bmp->bitmapInfo().numPixels();
+ while (pixels < pixelsEnd) {
+ *pixels ^= 0xFF000000;
+ ++pixels;
+ }
+ }
+ if (m_opacity < 1. || alphaPaint == AlphaPaintOther) {
+ const BLENDFUNCTION blend = { AC_SRC_OVER, 0
+ , m_opacity >= 1. ? 255 : (BYTE)(m_opacity * 255)
+ , alphaPaint == AlphaPaintNone ? 0 : AC_SRC_ALPHA };
+ AlphaBlend(m_dc, origRect.x(), origRect.y(), origRect.width(), origRect.height(), hdc, 0, 0, bmpRect.right, bmpRect.bottom, blend);
+ } else
+#endif
+ StretchBlt(m_dc, origRect.x(), origRect.y(), origRect.width(), origRect.height(), hdc, 0, 0, bmpRect.right, bmpRect.bottom, SRCCOPY);
+ }
+
+ HDC m_dc;
+ RefPtr<SharedBitmap> m_bitmap;
+ Vector<GraphicsContextPlatformPrivateData> m_backupData;
+};
+
+static HPEN createPen(const Color& col, double fWidth, StrokeStyle style)
+{
+ int width = stableRound(fWidth);
+ if (width < 1)
+ width = 1;
+
+ int penStyle = PS_NULL;
+ switch (style) {
+ case SolidStroke:
+ penStyle = PS_SOLID;
+ break;
+ case DottedStroke: // not supported on Windows CE
+ case DashedStroke:
+ penStyle = PS_DASH;
+ width = 1;
+ break;
+ default:
+ break;
+ }
+
+ return CreatePen(penStyle, width, RGB(col.red(), col.green(), col.blue()));
+}
+
+static inline HGDIOBJ createBrush(const Color& col)
+{
+ return CreateSolidBrush(RGB(col.red(), col.green(), col.blue()));
+}
+
+template <typename PixelType, bool Is16bit> static void _rotateBitmap(SharedBitmap* destBmp, const SharedBitmap* sourceBmp, const RotationTransform& transform)
+{
+ int destW = destBmp->width();
+ int destH = destBmp->height();
+ int sourceW = sourceBmp->width();
+ int sourceH = sourceBmp->height();
+ PixelType* dest = (PixelType*)destBmp->bytes();
+ const PixelType* source = (const PixelType*)sourceBmp->bytes();
+ int padding;
+ int paddedSourceW;
+ if (Is16bit) {
+ padding = destW & 1;
+ paddedSourceW = sourceW + (sourceW & 1);
+ } else {
+ padding = 0;
+ paddedSourceW = sourceW;
+ }
+ if (isZero(transform.m_sinA)) {
+ int cosA = transform.m_cosA > 0 ? 1 : -1;
+ for (int y = 0; y < destH; ++y) {
+ for (int x = 0; x < destW; ++x) {
+ int x1 = x + transform.m_preShiftX;
+ int y1 = y + transform.m_preShiftY;
+ int srcX = x1 * cosA + transform.m_postShiftX;
+ int srcY = y1 * cosA - transform.m_postShiftY;
+ if (srcX >= 0 && srcX <= sourceW && srcY >= 0 && srcY <= sourceH)
+ *dest++ = source[srcY * paddedSourceW + srcX] | 0xFF000000;
+ else
+ *dest++ |= 0xFF;
+ }
+ dest += padding;
+ }
+ } else if (isZero(transform.m_cosA)) {
+ int sinA = transform.m_sinA > 0 ? 1 : -1;
+ for (int y = 0; y < destH; ++y) {
+ for (int x = 0; x < destW; ++x) {
+ int x1 = x + transform.m_preShiftX;
+ int y1 = y + transform.m_preShiftY;
+ int srcX = y1 * sinA + transform.m_postShiftX;
+ int srcY = -x1 * sinA + transform.m_postShiftY;
+ if (srcX >= 0 && srcX <= sourceW && srcY >= 0 && srcY <= sourceH)
+ *dest++ = source[srcY * paddedSourceW + srcX];
+ }
+ dest += padding;
+ }
+ } else {
+ for (int y = 0; y < destH; ++y) {
+ for (int x = 0; x < destW; ++x) {
+ // FIXME: for best quality, we should get weighted sum of four neighbours,
+ // but that will be too expensive
+ int srcX, srcY;
+ transform.map(x, y, &srcX, &srcY);
+ if (srcX >= 0 && srcX <= sourceW && srcY >= 0 && srcY <= sourceH)
+ *dest++ = source[srcY * paddedSourceW + srcX];
+ }
+ dest += padding;
+ }
+ }
+}
+
+static void rotateBitmap(SharedBitmap* destBmp, const SharedBitmap* sourceBmp, const RotationTransform& transform)
+{
+ ASSERT(destBmp->is16bit() == sourceBmp->is16bit());
+ if (destBmp->is16bit())
+ _rotateBitmap<unsigned short, true>(destBmp, sourceBmp, transform);
+ else
+ _rotateBitmap<unsigned, false>(destBmp, sourceBmp, transform);
+}
+
+class TransparentLayerDC : Noncopyable {
+public:
+ TransparentLayerDC(GraphicsContextPlatformPrivate* data, IntRect& origRect, const IntRect* rectBeforeTransform = 0, int alpha = 255, bool paintImage = false);
+ ~TransparentLayerDC();
+
+ HDC hdc() const { return m_memDc; }
+ const RECT& rect() const { return m_bmpRect; }
+ IntSize toShift() const { return IntSize(m_bmpRect.left - m_origRect.x(), m_bmpRect.top - m_origRect.y()); }
+ void fillAlphaChannel();
+
+private:
+ GraphicsContextPlatformPrivate* m_data;
+ IntRect m_origRect;
+ IntRect m_rotatedOrigRect;
+ HDC m_memDc;
+ RefPtr<SharedBitmap> m_bitmap;
+ RefPtr<SharedBitmap> m_rotatedBitmap;
+ RECT m_bmpRect;
+ unsigned m_key1;
+ unsigned m_key2;
+ RotationTransform m_rotation;
+ float m_oldOpacity;
+ AlphaPaintType m_alphaPaintType;
+};
+
+TransparentLayerDC::TransparentLayerDC(GraphicsContextPlatformPrivate* data, IntRect& origRect, const IntRect* rectBeforeTransform, int alpha, bool paintImage)
+: m_data(data)
+, m_origRect(origRect)
+, m_oldOpacity(data->m_opacity)
+// m_key1 and m_key2 are not initalized here. They are used only in the case that
+// SharedBitmap::getDC() is called, I.E., when m_bitmap is not null.
+{
+ m_data->m_opacity *= alpha / 255.;
+ bool mustCreateLayer;
+ if (!m_data->hasAlpha()) {
+ mustCreateLayer = false;
+ m_alphaPaintType = AlphaPaintNone;
+ } else {
+ mustCreateLayer = true;
+ m_alphaPaintType = paintImage ? AlphaPaintImage : AlphaPaintOther;
+ }
+ if (rectBeforeTransform && !isZero(m_data->m_transform.b())) {
+ m_rotatedOrigRect = origRect;
+ m_rotatedBitmap = m_data->getTransparentLayerBitmap(m_rotatedOrigRect, m_alphaPaintType, m_bmpRect, false, true);
+ if (m_rotatedBitmap) {
+ double a = m_data->m_transform.a();
+ double b = m_data->m_transform.b();
+ double c = _hypot(a, b);
+ m_rotation.m_cosA = a / c;
+ m_rotation.m_sinA = b / c;
+
+ int centerX = origRect.x() + origRect.width() / 2;
+ int centerY = origRect.y() + origRect.height() / 2;
+ m_rotation.m_preShiftX = -centerX;
+ m_rotation.m_preShiftY = -centerY;
+ m_rotation.m_postShiftX = centerX;
+ m_rotation.m_postShiftY = centerY;
+
+ m_origRect = mapRect(m_rotatedOrigRect, m_rotation);
+
+ m_rotation.m_preShiftX += m_rotatedOrigRect.x();
+ m_rotation.m_preShiftY += m_rotatedOrigRect.y();
+ m_rotation.m_postShiftX -= m_origRect.x();
+ m_rotation.m_postShiftY -= m_origRect.y();
+
+ FloatPoint topLeft = m_data->m_transform.mapPoint(FloatPoint(rectBeforeTransform->topLeft()));
+ FloatPoint topRight(rectBeforeTransform->right() - 1, rectBeforeTransform->y());
+ topRight = m_data->m_transform.mapPoint(topRight);
+ FloatPoint bottomLeft(rectBeforeTransform->x(), rectBeforeTransform->bottom() - 1);
+ bottomLeft = m_data->m_transform.mapPoint(bottomLeft);
+ FloatSize sideTop = topRight - topLeft;
+ FloatSize sideLeft = bottomLeft - topLeft;
+ float width = _hypot(sideTop.width() + 1, sideTop.height() + 1);
+ float height = _hypot(sideLeft.width() + 1, sideLeft.height() + 1);
+
+ origRect.inflateX(stableRound((width - origRect.width()) * 0.5));
+ origRect.inflateY(stableRound((height - origRect.height()) * 0.5));
+
+ m_bitmap = SharedBitmap::createInstance(m_rotatedBitmap->is16bit(), m_origRect.width(), m_origRect.height(), true);
+ if (m_bitmap)
+ rotateBitmap(m_bitmap.get(), m_rotatedBitmap.get(), -m_rotation);
+ else
+ m_rotatedBitmap = 0;
+ }
+ } else
+ m_bitmap = m_data->getTransparentLayerBitmap(m_origRect, m_alphaPaintType, m_bmpRect, true, mustCreateLayer);
+ if (m_bitmap)
+ m_memDc = m_bitmap->getDC(&m_key1, &m_key2);
+ else
+ m_memDc = m_data->m_dc;
+}
+
+TransparentLayerDC::~TransparentLayerDC()
+{
+ if (m_rotatedBitmap) {
+ m_bitmap->releaseDC(m_memDc, m_key1, m_key2);
+ m_key1 = m_key2 = 0;
+ rotateBitmap(m_rotatedBitmap.get(), m_bitmap.get(), m_rotation);
+ m_memDc = m_rotatedBitmap->getDC(&m_key1, &m_key2);
+ m_data->paintBackTransparentLayerBitmap(m_memDc, m_rotatedBitmap.get(), m_rotatedOrigRect, m_alphaPaintType, m_bmpRect);
+ m_rotatedBitmap->releaseDC(m_memDc, m_key1, m_key2);
+ } else if (m_bitmap) {
+ m_data->paintBackTransparentLayerBitmap(m_memDc, m_bitmap.get(), m_origRect, m_alphaPaintType, m_bmpRect);
+ m_bitmap->releaseDC(m_memDc, m_key1, m_key2);
+ }
+ m_data->m_opacity = m_oldOpacity;
+}
+
+void TransparentLayerDC::fillAlphaChannel()
+{
+ if (!m_bitmap || !m_bitmap->is32bit())
+ return;
+
+ unsigned* pixels = (unsigned*)m_bitmap->bytes();
+ const unsigned* const pixelsEnd = pixels + m_bitmap->bitmapInfo().numPixels();
+ while (pixels < pixelsEnd) {
+ *pixels |= 0xFF000000;
+ ++pixels;
+ }
+}
+
+class ScopeDCProvider : Noncopyable {
+public:
+ explicit ScopeDCProvider(GraphicsContextPlatformPrivate* data)
+ : m_data(data)
+ {
+ if (m_data->m_bitmap)
+ m_data->m_dc = m_data->m_bitmap->getDC(&m_key1, &m_key2);
+ }
+ ~ScopeDCProvider()
+ {
+ if (m_data->m_bitmap) {
+ m_data->m_bitmap->releaseDC(m_data->m_dc, m_key1, m_key2);
+ m_data->m_dc = 0;
+ }
+ }
+private:
+ GraphicsContextPlatformPrivate* m_data;
+ unsigned m_key1;
+ unsigned m_key2;
+};
+
+
+GraphicsContext::GraphicsContext(PlatformGraphicsContext* dc)
+: m_common(createGraphicsContextPrivate())
+, m_data(new GraphicsContextPlatformPrivate(dc))
+{
+}
+
+GraphicsContext::~GraphicsContext()
+{
+ destroyGraphicsContextPrivate(m_common);
+ delete m_data;
+}
+
+void GraphicsContext::setBitmap(PassRefPtr<SharedBitmap> bmp)
+{
+ ASSERT(!m_data->m_dc);
+ m_data->m_bitmap = bmp;
+}
+
+HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
+{
+ notImplemented();
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
+{
+ notImplemented();
+ ASSERT_NOT_REACHED();
+}
+
+void GraphicsContext::savePlatformState()
+{
+ m_data->save();
+}
+
+void GraphicsContext::restorePlatformState()
+{
+ m_data->restore();
+}
+
+void GraphicsContext::drawRect(const IntRect& rect)
+{
+ if (!m_data->m_opacity || paintingDisabled() || rect.isEmpty())
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = m_data->mapRect(rect);
+ TransparentLayerDC transparentDC(m_data, trRect, &rect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ HGDIOBJ brush = 0;
+ HGDIOBJ oldBrush;
+ if (fillColor().alpha()) {
+ brush = createBrush(fillColor());
+ oldBrush = SelectObject(dc, brush);
+ } else
+ SelectObject(dc, GetStockObject(NULL_BRUSH));
+
+ HGDIOBJ pen = 0;
+ HGDIOBJ oldPen;
+ if (strokeStyle() != NoStroke) {
+ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ oldPen = SelectObject(dc, pen);
+ } else
+ SelectObject(dc, GetStockObject(NULL_PEN));
+
+ if (!brush && !pen)
+ return;
+
+ if (trRect.width() <= 0)
+ trRect.setWidth(1);
+ if (trRect.height() <= 0)
+ trRect.setHeight(1);
+
+ Rectangle(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
+
+ if (pen) {
+ SelectObject(dc, oldPen);
+ DeleteObject(pen);
+ }
+
+ if (brush) {
+ SelectObject(dc, oldBrush);
+ DeleteObject(brush);
+ }
+}
+
+void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
+{
+ if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke || !strokeColor().alpha())
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntPoint trPoint1 = m_data->mapPoint(point1);
+ IntPoint trPoint2 = m_data->mapPoint(point2);
+
+ IntRect lineRect(trPoint1, trPoint2 - trPoint1);
+ lineRect.setHeight(lineRect.height() + strokeThickness());
+ TransparentLayerDC transparentDC(m_data, lineRect, 0, strokeColor().alpha());
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trPoint1 += transparentDC.toShift();
+ trPoint2 += transparentDC.toShift();
+
+ HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ HGDIOBJ oldPen = SelectObject(dc, pen);
+
+ MoveToEx(dc, trPoint1.x(), trPoint1.y(), 0);
+ LineTo(dc, trPoint2.x(), trPoint2.y());
+
+ SelectObject(dc, oldPen);
+ DeleteObject(pen);
+}
+
+void GraphicsContext::drawEllipse(const IntRect& rect)
+{
+ if (!m_data->m_opacity || paintingDisabled() || (!fillColor().alpha() && strokeStyle() == NoStroke))
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = m_data->mapRect(rect);
+ TransparentLayerDC transparentDC(m_data, trRect, &rect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ HGDIOBJ brush = 0;
+ HGDIOBJ oldBrush;
+ if (fillColor().alpha()) {
+ brush = createBrush(fillColor());
+ oldBrush = SelectObject(dc, brush);
+ } else
+ SelectObject(dc, GetStockObject(NULL_BRUSH));
+ HGDIOBJ pen = 0;
+ HGDIOBJ oldPen;
+ if (strokeStyle() != NoStroke) {
+ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ oldPen = SelectObject(dc, pen);
+ } else
+ SelectObject(dc, GetStockObject(NULL_PEN));
+
+ Ellipse(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
+
+ if (pen) {
+ SelectObject(dc, oldPen);
+ DeleteObject(pen);
+ }
+
+ if (brush) {
+ SelectObject(dc, oldBrush);
+ DeleteObject(brush);
+ }
+}
+
+static inline bool equalAngle(double a, double b)
+{
+ return fabs(a - b) < 1E-5;
+}
+
+void getEllipsePointByAngle(double angle, double a, double b, float& x, float& y)
+{
+ while (angle < 0)
+ angle += 2 * piDouble;
+ while (angle >= 2 * piDouble)
+ angle -= 2 * piDouble;
+
+ if (equalAngle(angle, 0) || equalAngle(angle, 2 * piDouble)) {
+ x = a;
+ y = 0;
+ } else if (equalAngle(angle, piDouble)) {
+ x = -a;
+ y = 0;
+ } else if (equalAngle(angle, .5 * piDouble)) {
+ x = 0;
+ y = b;
+ } else if (equalAngle(angle, 1.5 * piDouble)) {
+ x = 0;
+ y = -b;
+ } else {
+ double k = tan(angle);
+ double sqA = a * a;
+ double sqB = b * b;
+ double tmp = 1. / (1. / sqA + (k * k) / sqB);
+ tmp = tmp <= 0 ? 0 : sqrt(tmp);
+ if (angle > .5 * piDouble && angle < 1.5 * piDouble)
+ tmp = -tmp;
+ x = tmp;
+
+ k = tan(.5 * piDouble - angle);
+ tmp = 1. / ((k * k) / sqA + 1 / sqB);
+ tmp = tmp <= 0 ? 0 : sqrt(tmp);
+ if (angle > piDouble)
+ tmp = -tmp;
+ y = tmp;
+ }
+}
+
+void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
+{
+ if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke || rect.isEmpty())
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = m_data->mapRect(rect);
+ TransparentLayerDC transparentDC(m_data, trRect, &rect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ HGDIOBJ oldPen = SelectObject(dc, pen);
+
+ double a = trRect.width() * 0.5;
+ double b = trRect.height() * 0.5;
+ int centerX = stableRound(trRect.x() + a);
+ int centerY = stableRound(trRect.y() + b);
+ float fstartX, fstartY, fendX, fendY;
+ int startX, startY, endX, endY;
+ getEllipsePointByAngle(deg2rad((double)startAngle), a, b, fstartX, fstartY);
+ getEllipsePointByAngle(deg2rad((double)startAngle + angleSpan), a, b, fendX, fendY);
+ startX = stableRound(fstartX);
+ startY = stableRound(fstartY);
+ endX = stableRound(fendX);
+ endY = stableRound(fendY);
+
+ startX += centerX;
+ startY = centerY - startY;
+ endX += centerX;
+ endY = centerY - endY;
+ RECT clipRect;
+ if (startX < endX) {
+ clipRect.left = startX;
+ clipRect.right = endX;
+ } else {
+ clipRect.left = endX;
+ clipRect.right = startX;
+ }
+ if (startY < endY) {
+ clipRect.top = startY;
+ clipRect.bottom = endY;
+ } else {
+ clipRect.top = endY;
+ clipRect.bottom = startY;
+ }
+
+ OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
+ bool newClip;
+ if (GetClipRgn(dc, clipRgn.get()) <= 0) {
+ newClip = true;
+ clipRgn.set(CreateRectRgn(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom));
+ SelectClipRgn(dc, clipRgn.get());
+ } else {
+ newClip = false;
+ IntersectClipRect(dc, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
+ }
+
+ HGDIOBJ oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));
+ Ellipse(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
+ SelectObject(dc, oldBrush);
+
+ if (newClip)
+ SelectClipRgn(dc, 0);
+ else
+ SelectClipRgn(dc, clipRgn.get());
+
+ SelectObject(dc, oldPen);
+ DeleteObject(pen);
+}
+
+void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
+{
+ if (!m_data->m_opacity || paintingDisabled() || npoints <= 1 || !points)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ Vector<POINT, 20> winPoints(npoints);
+ FloatPoint trPoint = m_data->mapPoint(points[0]);
+ winPoints[0].x = stableRound(trPoint.x());
+ winPoints[0].y = stableRound(trPoint.y());
+ RECT rect = { winPoints[0].x, winPoints[0].y, winPoints[0].x, winPoints[0].y };
+ for (size_t i = 1; i < npoints; ++i) {
+ trPoint = m_data->mapPoint(points[i]);
+ winPoints[i].x = stableRound(trPoint.x());
+ winPoints[i].y = stableRound(trPoint.y());
+ if (rect.left > winPoints[i].x)
+ rect.left = winPoints[i].x;
+ else if (rect.right < winPoints[i].x)
+ rect.right = winPoints[i].x;
+ if (rect.top > winPoints[i].y)
+ rect.top = winPoints[i].y;
+ else if (rect.bottom < winPoints[i].y)
+ rect.bottom = winPoints[i].y;
+ }
+ rect.bottom += 1;
+ rect.right += 1;
+
+ IntRect intRect(rect);
+ TransparentLayerDC transparentDC(m_data, intRect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+
+ for (size_t i = 0; i < npoints; ++i) {
+ winPoints[i].x += transparentDC.toShift().width();
+ winPoints[i].y += transparentDC.toShift().height();
+ }
+
+ HGDIOBJ brush = 0;
+ HGDIOBJ oldBrush;
+ if (fillColor().alpha()) {
+ brush = createBrush(fillColor());
+ oldBrush = SelectObject(dc, brush);
+ } else
+ SelectObject(dc, GetStockObject(NULL_BRUSH));
+
+ HGDIOBJ pen = 0;
+ HGDIOBJ oldPen;
+ if (strokeStyle() != NoStroke) {
+ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ oldPen = SelectObject(dc, pen);
+ } else
+ SelectObject(dc, GetStockObject(NULL_PEN));
+
+ if (!brush && !pen)
+ return;
+
+ Polygon(dc, winPoints.data(), npoints);
+
+ if (pen) {
+ SelectObject(dc, oldPen);
+ DeleteObject(pen);
+ }
+
+ if (brush) {
+ SelectObject(dc, oldBrush);
+ DeleteObject(brush);
+ }
+}
+
+void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased)
+{
+ if (paintingDisabled())
+ return;
+
+ if (numPoints <= 1)
+ return;
+
+ // FIXME: IMPLEMENT!!
+}
+
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
+{
+ if (paintingDisabled() || !m_data->m_opacity)
+ return;
+
+ int alpha = color.alpha();
+ if (!alpha)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect intRect = enclosingIntRect(rect);
+ TransparentLayerDC transparentDC(m_data, m_data->mapRect(intRect), &intRect, alpha);
+
+ if (!transparentDC.hdc())
+ return;
+
+ OwnPtr<HBRUSH> hbrush(CreateSolidBrush(RGB(color.red(), color.green(), color.blue())));
+ FillRect(transparentDC.hdc(), &transparentDC.rect(), hbrush.get());
+}
+
+void GraphicsContext::clip(const FloatRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = enclosingIntRect(m_data->mapRect(rect));
+
+ OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
+ if (GetClipRgn(m_data->m_dc, clipRgn.get()) > 0)
+ IntersectClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
+ else {
+ clipRgn.set(CreateRectRgn(trRect.x(), trRect.y(), trRect.right(), trRect.bottom()));
+ SelectClipRgn(m_data->m_dc, clipRgn.get());
+ }
+}
+
+void GraphicsContext::clipOut(const IntRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = m_data->mapRect(rect);
+
+ ExcludeClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
+}
+
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
+void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
+{
+ if (!m_data->m_opacity || paintingDisabled())
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ int radius = (width - 1) / 2;
+ offset += radius;
+
+ unsigned rectCount = rects.size();
+ IntRect finalFocusRect;
+ for (unsigned i = 0; i < rectCount; i++) {
+ IntRect focusRect = rects[i];
+ focusRect.inflate(offset);
+ finalFocusRect.unite(focusRect);
+ }
+
+ IntRect intRect = finalFocusRect;
+ IntRect trRect = m_data->mapRect(finalFocusRect);
+ TransparentLayerDC transparentDC(m_data, trRect, &intRect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ RECT rect = trRect;
+ DrawFocusRect(dc, &rect);
+}
+
+void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
+{
+ if (paintingDisabled())
+ return;
+
+ StrokeStyle oldStyle = strokeStyle();
+ setStrokeStyle(SolidStroke);
+ drawLine(origin, origin + IntSize(width, 0));
+ setStrokeStyle(oldStyle);
+}
+
+void GraphicsContext::drawLineForTextChecking(const IntPoint&, int width, TextCheckingLineStyle style)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setPlatformFillColor(const Color& col, ColorSpace colorSpace)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setPlatformStrokeColor(const Color& col, ColorSpace colorSpace)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setPlatformStrokeThickness(float strokeThickness)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
+{
+ notImplemented();
+}
+
+void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
+{
+ // We can only clip rectangles on WINCE
+ clip(rect);
+}
+
+void GraphicsContext::clearRect(const FloatRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ if (m_data->hasAlpha()) {
+ IntRect trRect = enclosingIntRect(m_data->mapRect(rect));
+ m_data->m_bitmap->clearPixels(trRect);
+ return;
+ }
+
+ fillRect(rect, Color(Color::white), DeviceColorSpace);
+}
+
+void GraphicsContext::strokeRect(const FloatRect& rect, float width)
+{
+ if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect intRect = enclosingIntRect(rect);
+ IntRect trRect = m_data->mapRect(intRect);
+ TransparentLayerDC transparentDC(m_data, trRect, &intRect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ HGDIOBJ oldPen = SelectObject(dc, pen);
+
+ int right = trRect.right() - 1;
+ int bottom = trRect.bottom() - 1;
+ const POINT intPoints[5] =
+ {
+ { trRect.x(), trRect.y() },
+ { right, trRect.y() },
+ { right, bottom },
+ { trRect.x(), bottom },
+ { trRect.x(), trRect.y() }
+ };
+
+ Polyline(dc, intPoints, 5);
+
+ SelectObject(dc, oldPen);
+ DeleteObject(pen);
+}
+
+void GraphicsContext::beginTransparencyLayer(float opacity)
+{
+ m_data->save();
+ m_data->m_opacity *= opacity;
+}
+
+void GraphicsContext::endTransparencyLayer()
+{
+ m_data->restore();
+}
+
+void GraphicsContext::concatCTM(const AffineTransform& transform)
+{
+ m_data->concatCTM(transform);
+}
+
+AffineTransform& GraphicsContext::affineTransform()
+{
+ return m_data->m_transform;
+}
+
+const AffineTransform& GraphicsContext::affineTransform() const
+{
+ return m_data->m_transform;
+}
+
+void GraphicsContext::resetAffineTransform()
+{
+ m_data->m_transform.makeIdentity();
+}
+
+void GraphicsContext::translate(float x, float y)
+{
+ m_data->translate(x, y);
+}
+
+void GraphicsContext::rotate(float radians)
+{
+ m_data->rotate(radians);
+}
+
+IntPoint GraphicsContext::origin()
+{
+ return m_data->origin();
+}
+
+void GraphicsContext::scale(const FloatSize& size)
+{
+ m_data->scale(size);
+}
+
+void GraphicsContext::setLineCap(LineCap lineCap)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setLineJoin(LineJoin lineJoin)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setMiterLimit(float miter)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setAlpha(float alpha)
+{
+ m_data->m_opacity = alpha;
+}
+
+void GraphicsContext::setCompositeOperation(CompositeOperator op)
+{
+ notImplemented();
+}
+
+void GraphicsContext::beginPath()
+{
+ m_data->m_paths.clear();
+}
+
+void GraphicsContext::addPath(const Path& path)
+{
+ m_data->m_paths.append(path);
+}
+
+void GraphicsContext::clip(const Path& path)
+{
+ notImplemented();
+}
+
+void GraphicsContext::canvasClip(const Path& path)
+{
+ clip(path);
+}
+
+void GraphicsContext::clipOut(const Path&)
+{
+ notImplemented();
+}
+
+void GraphicsContext::clipOutEllipseInRect(const IntRect&)
+{
+ notImplemented();
+}
+
+static inline IntPoint rectCenterPoint(const RECT& rect)
+{
+ return IntPoint(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
+}
+void GraphicsContext::fillRoundedRect(const IntRect& fillRect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& c, ColorSpace colorSpace)
+{
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ FloatSize shadowOffset;
+ float shadowBlur = 0;
+ Color shadowColor;
+
+ getShadow(shadowOffset, shadowBlur, shadowColor);
+
+ IntRect dstRect = fillRect;
+
+ dstRect.move(stableRound(shadowOffset.width()), stableRound(shadowOffset.height()));
+ dstRect.inflate(stableRound(shadowBlur));
+ dstRect = m_data->mapRect(dstRect);
+
+ FloatSize newTopLeft(m_data->mapSize(topLeft));
+ FloatSize newTopRight(m_data->mapSize(topRight));
+ FloatSize newBottomLeft(m_data->mapSize(bottomLeft));
+ FloatSize newBottomRight(m_data->mapSize(bottomRight));
+
+ TransparentLayerDC transparentDc(m_data, dstRect, &fillRect);
+ HDC dc = transparentDc.hdc();
+ if (!dc)
+ return;
+
+ dstRect.move(transparentDc.toShift());
+
+ RECT rectWin = dstRect;
+
+ HGDIOBJ brush = createBrush(shadowColor);
+ HGDIOBJ oldBrush = SelectObject(dc, brush);
+
+ SelectObject(dc, GetStockObject(NULL_PEN));
+
+ IntPoint centerPoint = rectCenterPoint(rectWin);
+ // Draw top left half
+ RECT clipRect(rectWin);
+ clipRect.right = centerPoint.x();
+ clipRect.bottom = centerPoint.y();
+
+ OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
+ bool needsNewClip = (GetClipRgn(dc, clipRgn.get()) <= 0);
+
+ drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newTopLeft.width() * 2), stableRound(newTopLeft.height() * 2));
+
+ // Draw top right
+ clipRect = rectWin;
+ clipRect.left = centerPoint.x();
+ clipRect.bottom = centerPoint.y();
+
+ drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newTopRight.width() * 2), stableRound(newTopRight.height() * 2));
+
+ // Draw bottom left
+ clipRect = rectWin;
+ clipRect.right = centerPoint.x();
+ clipRect.top = centerPoint.y();
+
+ drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newBottomLeft.width() * 2), stableRound(newBottomLeft.height() * 2));
+
+ // Draw bottom right
+ clipRect = rectWin;
+ clipRect.left = centerPoint.x();
+ clipRect.top = centerPoint.y();
+
+ drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newBottomRight.width() * 2), stableRound(newBottomRight.height() * 2));
+
+ SelectObject(dc, oldBrush);
+ DeleteObject(brush);
+}
+
+
+void GraphicsContext::drawRoundCorner(bool needsNewClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height)
+{
+ if (!dc)
+ return;
+
+ OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
+ if (needsNewClip) {
+ clipRgn.set(CreateRectRgn(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom));
+ SelectClipRgn(dc, clipRgn.get());
+ } else
+ IntersectClipRect(dc, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
+
+ ::RoundRect(dc, rectWin.left , rectWin.top , rectWin.right , rectWin.bottom , width, height);
+
+ SelectClipRgn(dc, needsNewClip ? 0 : clipRgn.get());
+}
+
+
+FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
+{
+ notImplemented();
+ return frect;
+}
+
+Color gradientAverageColor(const Gradient* gradient)
+{
+ const Vector<Gradient::ColorStop>& stops = gradient->getStops();
+ if (stops.isEmpty())
+ return Color();
+
+ const Gradient::ColorStop& stop = stops.first();
+ if (stops.size() == 1)
+ return Color(stop.red, stop.green, stop.blue, stop.alpha);
+
+ const Gradient::ColorStop& lastStop = stops.last();
+ return Color((stop.red + lastStop.red) * 0.5f
+ , (stop.green + lastStop.green) * 0.5f
+ , (stop.blue + lastStop.blue) * 0.5f
+ , (stop.alpha + lastStop.alpha) * 0.5f);
+}
+
+void GraphicsContext::fillPath()
+{
+ Color c = m_common->state.fillGradient
+ ? gradientAverageColor(m_common->state.fillGradient.get())
+ : fillColor();
+
+ if (!c.alpha() || !m_data->m_opacity)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) {
+ HGDIOBJ brush = createBrush(c);
+ for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) {
+ IntRect trRect = enclosingIntRect(m_data->mapRect(i->boundingRect()));
+ trRect.inflate(1);
+ TransparentLayerDC transparentDC(m_data, trRect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ continue;
+
+ AffineTransform tr = m_data->m_transform;
+ tr.translate(transparentDC.toShift().width(), transparentDC.toShift().height());
+
+ SelectObject(dc, GetStockObject(NULL_PEN));
+ HGDIOBJ oldBrush = SelectObject(dc, brush);
+ i->platformPath()->fillPath(dc, &tr);
+ SelectObject(dc, oldBrush);
+ }
+ DeleteObject(brush);
+ } else {
+ SelectObject(m_data->m_dc, GetStockObject(NULL_PEN));
+ HGDIOBJ brush = createBrush(c);
+ HGDIOBJ oldBrush = SelectObject(m_data->m_dc, brush);
+ for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i)
+ i->platformPath()->fillPath(m_data->m_dc, &m_data->m_transform);
+ SelectObject(m_data->m_dc, oldBrush);
+ DeleteObject(brush);
+ }
+}
+
+
+void GraphicsContext::strokePath()
+{
+ if (!m_data->m_opacity)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) {
+ HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) {
+ IntRect trRect = enclosingIntRect(m_data->mapRect(i->boundingRect()));
+ trRect.inflate(1);
+ TransparentLayerDC transparentDC(m_data, trRect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ continue;
+
+ AffineTransform tr = m_data->m_transform;
+ tr.translate(transparentDC.toShift().width(), transparentDC.toShift().height());
+
+ SelectObject(dc, GetStockObject(NULL_BRUSH));
+ HGDIOBJ oldPen = SelectObject(dc, pen);
+ i->platformPath()->strokePath(dc, &tr);
+ SelectObject(dc, oldPen);
+ }
+ DeleteObject(pen);
+ } else {
+ SelectObject(m_data->m_dc, GetStockObject(NULL_BRUSH));
+ HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
+ HGDIOBJ oldPen = SelectObject(m_data->m_dc, pen);
+ for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i)
+ i->platformPath()->strokePath(m_data->m_dc, &m_data->m_transform);
+ SelectObject(m_data->m_dc, oldPen);
+ DeleteObject(pen);
+ }
+}
+
+void GraphicsContext::fillRect(const FloatRect& r, const Gradient* gradient)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ const Vector<Gradient::ColorStop>& stops = gradient->getStops();
+ if (stops.isEmpty())
+ return;
+
+ size_t numStops = stops.size();
+ if (numStops == 1) {
+ const Gradient::ColorStop& stop = stops.first();
+ Color color(stop.red, stop.green, stop.blue, stop.alpha);
+ fillRect(r, color, DeviceColorSpace);
+ return;
+ }
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect intRect = enclosingIntRect(r);
+ IntRect rect = m_data->mapRect(intRect);
+ TransparentLayerDC transparentDC(m_data, rect, &intRect, 255, true);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+
+ rect.move(transparentDC.toShift());
+ FloatPoint fp0 = m_data->mapPoint(gradient->p0());
+ FloatPoint fp1 = m_data->mapPoint(gradient->p1());
+ IntPoint p0(stableRound(fp0.x()), stableRound(fp0.y()));
+ IntPoint p1(stableRound(fp1.x()), stableRound(fp1.y()));
+ p0 += transparentDC.toShift();
+ p1 += transparentDC.toShift();
+
+ if (gradient->isRadial()) {
+ if (g_radialGradientFiller) {
+ // FIXME: don't support 2D scaling at this time
+ double scale = (m_data->m_transform.a() + m_data->m_transform.d()) * 0.5;
+ float r0 = gradient->r0() * scale;
+ float r1 = gradient->r1() * scale;
+ g_radialGradientFiller(dc, rect, p0, p1, r0, r1, gradient->getStops());
+ return;
+ }
+ } else if (g_linearGradientFiller) {
+ g_linearGradientFiller(dc, rect, p0, p1, gradient->getStops());
+ return;
+ }
+
+ // Simple 1D linear solution that assumes p0 is on the top or left side, and p1 is on the right or bottom side
+ size_t numRects = (numStops - 1);
+ Vector<TRIVERTEX, 20> tv;
+ tv.resize(numRects * 2);
+ Vector<GRADIENT_RECT, 10> mesh;
+ mesh.resize(numRects);
+ int x = rect.x();
+ int y = rect.y();
+ int width = rect.width();
+ int height = rect.height();
+ FloatSize d = gradient->p1() - gradient->p0();
+ bool vertical = fabs(d.height()) > fabs(d.width());
+ for (size_t i = 0; i < numStops; ++i) {
+ const Gradient::ColorStop& stop = stops[i];
+ int iTv = i ? 2 * i - 1 : 0;
+ tv[iTv].Red = stop.red * 0xFFFF;
+ tv[iTv].Green = stop.green * 0xFFFF;
+ tv[iTv].Blue = stop.blue * 0xFFFF;
+ tv[iTv].Alpha = stop.alpha * 0xFFFF;
+ if (i) {
+ tv[iTv].x = vertical ? x + width: x + width * stop.stop;
+ tv[iTv].y = vertical ? y + height * stop.stop : y + height;
+ mesh[i - 1].UpperLeft = iTv - 1;
+ mesh[i - 1].LowerRight = iTv;
+ } else {
+ tv[iTv].x = x;
+ tv[iTv].y = y;
+ }
+
+ if (i && i < numRects) {
+ tv[iTv + 1] = tv[iTv];
+ if (vertical)
+ tv[iTv + 1].x = x;
+ else
+ tv[iTv + 1].y = y;
+ }
+ }
+
+ GradientFill(dc, tv.data(), tv.size(), mesh.data(), mesh.size(), vertical ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H);
+}
+
+AffineTransform GraphicsContext::getCTM() const
+{
+ return m_data->m_transform;
+}
+
+void GraphicsContext::fillRect(const FloatRect& rect)
+{
+ savePlatformState();
+
+ if (m_common->state.fillGradient)
+ fillRect(rect, m_common->state.fillGradient.get());
+ else
+ fillRect(rect, fillColor(), DeviceColorSpace);
+
+ restorePlatformState();
+}
+
+void GraphicsContext::setPlatformShadow(const FloatSize&, float, const Color&, ColorSpace)
+{
+ notImplemented();
+}
+
+void GraphicsContext::clearPlatformShadow()
+{
+ notImplemented();
+}
+
+void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
+{
+ notImplemented();
+}
+
+static inline bool isCharVisible(UChar c)
+{
+ return c && c != zeroWidthSpace;
+}
+
+void GraphicsContext::drawText(const Font& font, const TextRun& run, const IntPoint& point, int from, int to)
+{
+ if (paintingDisabled() || !fillColor().alpha() || !m_data->m_opacity)
+ return;
+
+ bool mustSupportAlpha = m_data->hasAlpha();
+
+ if (!mustSupportAlpha && fillColor().alpha() == 0xFF && m_data->m_opacity >= 1.0) {
+ font.drawText(this, run, point, from, to);
+ return;
+ }
+
+ float oldOpacity = m_data->m_opacity;
+ m_data->m_opacity *= fillColor().alpha() / 255.0;
+
+ FloatRect textRect = font.selectionRectForText(run, point, font.height(), from, to);
+ textRect.setY(textRect.y() - font.ascent());
+ IntRect trRect = enclosingIntRect(m_data->mapRect(textRect));
+ RECT bmpRect;
+ AlphaPaintType alphaPaintType = mustSupportAlpha ? AlphaPaintOther : AlphaPaintNone;
+ if (RefPtr<SharedBitmap> bmp = m_data->getTransparentLayerBitmap(trRect, alphaPaintType, bmpRect, true, mustSupportAlpha)) {
+ {
+ GraphicsContext gc(0);
+ gc.setBitmap(bmp);
+ gc.scale(FloatSize(m_data->m_transform.a(), m_data->m_transform.d()));
+ font.drawText(&gc, run, IntPoint(0, font.ascent()), from, to);
+ }
+ unsigned key1, key2;
+ HDC memDC = bmp->getDC(&key1, &key2);
+ if (memDC) {
+ m_data->paintBackTransparentLayerBitmap(memDC, bmp.get(), trRect, alphaPaintType, bmpRect);
+ bmp->releaseDC(memDC, key1, key2);
+ }
+ }
+
+ m_data->m_opacity = oldOpacity;
+}
+
+void GraphicsContext::drawText(const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer,
+ int from, int numGlyphs, const FloatPoint& point)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ for (;;) {
+ if (!numGlyphs)
+ return;
+ if (isCharVisible(*glyphBuffer.glyphs(from)))
+ break;
+ ++from;
+ --numGlyphs;
+ }
+
+ double scaleX = m_data->m_transform.a();
+ double scaleY = m_data->m_transform.d();
+
+ int height = fontData->platformData().size() * scaleY;
+ int width = fontData->platformData().averageCharWidth() * scaleX;
+
+ if (!height || !width)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ HFONT hFont = height > 1
+ ? fontData->platformData().getScaledFontHandle(height, scaleX == scaleY ? 0 : width)
+ : 0;
+
+ FloatPoint startPoint(point.x(), point.y() - fontData->ascent());
+ FloatPoint trPoint = m_data->mapPoint(startPoint);
+ int y = stableRound(trPoint.y());
+
+ Color color = fillColor();
+ if (!color.alpha())
+ return;
+
+ COLORREF fontColor = RGB(color.red(), color.green(), color.blue());
+
+ if (!hFont) {
+ double offset = trPoint.x();
+ const GlyphBufferAdvance* advance = glyphBuffer.advances(from);
+ if (scaleX == 1.)
+ for (int i = 1; i < numGlyphs; ++i)
+ offset += *advance++;
+ else
+ for (int i = 1; i < numGlyphs; ++i)
+ offset += *advance++ * scaleX;
+
+ offset += width;
+
+ OwnPtr<HPEN> hPen(CreatePen(PS_DASH, 1, fontColor));
+ HGDIOBJ oldPen = SelectObject(m_data->m_dc, hPen.get());
+
+ MoveToEx(m_data->m_dc, stableRound(trPoint.x()), y, 0);
+ LineTo(m_data->m_dc, stableRound(offset), y);
+
+ SelectObject(m_data->m_dc, oldPen);
+ return;
+ }
+
+ FloatSize shadowOffset;
+ float shadowBlur = 0;
+ Color shadowColor;
+ bool hasShadow = textDrawingMode() == cTextFill
+ && getShadow(shadowOffset, shadowBlur, shadowColor)
+ && shadowColor.alpha();
+ COLORREF shadowRGBColor;
+ FloatPoint trShadowPoint;
+ if (hasShadow) {
+ shadowRGBColor = RGB(shadowColor.red(), shadowColor.green(), shadowColor.blue());
+ trShadowPoint = m_data->mapPoint(startPoint + shadowOffset);
+ }
+
+ HGDIOBJ hOldFont = SelectObject(m_data->m_dc, hFont);
+ COLORREF oldTextColor = GetTextColor(m_data->m_dc);
+ int oldTextAlign = GetTextAlign(m_data->m_dc);
+ SetTextAlign(m_data->m_dc, 0);
+
+ int oldBkMode = GetBkMode(m_data->m_dc);
+ SetBkMode(m_data->m_dc, TRANSPARENT);
+
+ if (numGlyphs > 1) {
+ double offset = trPoint.x();
+ Vector<int, 256> glyphSpace(numGlyphs);
+ Vector<UChar, 256> text(numGlyphs);
+ int* curSpace = glyphSpace.data();
+ UChar* curChar = text.data();
+ const UChar* srcChar = glyphBuffer.glyphs(from);
+ const UChar* const srcCharEnd = srcChar + numGlyphs;
+ *curChar++ = *srcChar++;
+ int firstOffset = stableRound(offset);
+ int lastOffset = firstOffset;
+ const GlyphBufferAdvance* advance = glyphBuffer.advances(from);
+ // FIXME: ExtTextOut() can flip over each word for RTL languages, even when TA_RTLREADING is off.
+ // (this can be GDI bug or font driver bug?)
+ // We are not clear how it processes characters and handles specified spaces. On the other side,
+ // our glyph buffer is already in the correct order for rendering. So, the solution is that we
+ // call ExtTextOut() for each single character when the text contains any RTL character.
+ // This solution is not perfect as it is slower than calling ExtTextOut() one time for all characters.
+ // Drawing characters one by one may be too slow.
+ bool drawOneByOne = false;
+ if (scaleX == 1.) {
+ for (; srcChar < srcCharEnd; ++srcChar) {
+ offset += *advance++;
+ int offsetInt = stableRound(offset);
+ if (isCharVisible(*srcChar)) {
+ if (!drawOneByOne && WTF::Unicode::direction(*srcChar) == WTF::Unicode::RightToLeft)
+ drawOneByOne = true;
+ *curChar++ = *srcChar;
+ *curSpace++ = offsetInt - lastOffset;
+ lastOffset = offsetInt;
+ }
+ }
+ } else {
+ for (; srcChar < srcCharEnd; ++srcChar) {
+ offset += *advance++ * scaleX;
+ int offsetInt = stableRound(offset);
+ if (isCharVisible(*srcChar)) {
+ if (!drawOneByOne && WTF::Unicode::direction(*srcChar) == WTF::Unicode::RightToLeft)
+ drawOneByOne = true;
+ *curChar++ = *srcChar;
+ *curSpace++ = offsetInt - lastOffset;
+ lastOffset = offsetInt;
+ }
+ }
+ }
+ numGlyphs = curChar - text.data();
+ if (hasShadow) {
+ SetTextColor(m_data->m_dc, shadowRGBColor);
+ if (drawOneByOne) {
+ int xShadow = firstOffset + stableRound(trShadowPoint.x() - trPoint.x());
+ int yShadow = stableRound(trShadowPoint.y());
+ for (int i = 0; i < numGlyphs; ++i) {
+ ExtTextOut(m_data->m_dc, xShadow, yShadow, 0, NULL, text.data() + i, 1, 0);
+ xShadow += glyphSpace[i];
+ }
+ } else
+ ExtTextOut(m_data->m_dc, firstOffset + stableRound(trShadowPoint.x() - trPoint.x()), stableRound(trShadowPoint.y()), 0, NULL, text.data(), numGlyphs, glyphSpace.data());
+ }
+ SetTextColor(m_data->m_dc, fontColor);
+ if (drawOneByOne) {
+ int x = firstOffset;
+ for (int i = 0; i < numGlyphs; ++i) {
+ ExtTextOut(m_data->m_dc, x, y, 0, NULL, text.data() + i, 1, 0);
+ x += glyphSpace[i];
+ }
+ } else
+ ExtTextOut(m_data->m_dc, firstOffset, y, 0, NULL, text.data(), numGlyphs, glyphSpace.data());
+ } else {
+ UChar c = *glyphBuffer.glyphs(from);
+ if (hasShadow) {
+ SetTextColor(m_data->m_dc, shadowRGBColor);
+ ExtTextOut(m_data->m_dc, stableRound(trShadowPoint.x()), stableRound(trShadowPoint.y()), 0, NULL, &c, 1, 0);
+ }
+ SetTextColor(m_data->m_dc, fontColor);
+ ExtTextOut(m_data->m_dc, stableRound(trPoint.x()), y, 0, NULL, &c, 1, 0);
+ }
+
+ SetTextAlign(m_data->m_dc, oldTextAlign);
+ SetTextColor(m_data->m_dc, oldTextColor);
+ SetBkMode(m_data->m_dc, oldBkMode);
+ SelectObject(m_data->m_dc, hOldFont);
+}
+
+void GraphicsContext::drawFrameControl(const IntRect& rect, unsigned type, unsigned state)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ const int boxWidthBest = 8;
+ const int boxHeightBest = 8;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = m_data->mapRect(rect);
+ TransparentLayerDC transparentDC(m_data, trRect, &rect, 255, true);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ RECT rectWin = trRect;
+
+ if ((rectWin.right - rectWin.left) < boxWidthBest) {
+ RefPtr<SharedBitmap> bmp = SharedBitmap::createInstance(true, boxWidthBest, boxHeightBest, true);
+ SharedBitmap::DCHolder memDC(bmp.get());
+ if (memDC.get()) {
+ RECT tempRect = {0, 0, boxWidthBest, boxHeightBest};
+ DrawFrameControl(memDC.get(), &tempRect, type, state);
+
+ ::StretchBlt(dc, rectWin.left, rectWin.top, rectWin.right - rectWin.left, rectWin.bottom - rectWin.top, memDC.get(), 0, 0, boxWidthBest, boxHeightBest, SRCCOPY);
+ return;
+ }
+ }
+
+ DrawFrameControl(dc, &rectWin, type, state);
+}
+
+void GraphicsContext::drawFocusRect(const IntRect& rect)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = m_data->mapRect(rect);
+ TransparentLayerDC transparentDC(m_data, trRect, &rect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ RECT rectWin = trRect;
+ DrawFocusRect(dc, &rectWin);
+}
+
+void GraphicsContext::paintTextField(const IntRect& rect, unsigned state)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect trRect = m_data->mapRect(rect);
+ TransparentLayerDC transparentDC(m_data, trRect, &rect);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+
+ RECT rectWin = trRect;
+ DrawEdge(dc, &rectWin, EDGE_ETCHED, BF_RECT | BF_ADJUST);
+ FillRect(dc, &rectWin, reinterpret_cast<HBRUSH>(((state & DFCS_INACTIVE) ? COLOR_BTNFACE : COLOR_WINDOW) + 1));
+}
+
+void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect dstRect = m_data->mapRect(dstRectIn);
+ TransparentLayerDC transparentDC(m_data, dstRect, &dstRectIn, 255, true);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ dstRect.move(transparentDC.toShift());
+
+ bmp->draw(dc, dstRect, srcRect, compositeOp);
+
+ if (bmp->is16bit())
+ transparentDC.fillAlphaChannel();
+}
+
+void GraphicsContext::drawBitmapPattern(SharedBitmap* bmp, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRectIn, const IntSize& origSourceSize)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect intDstRect = enclosingIntRect(destRectIn);
+ IntRect trRect = m_data->mapRect(intDstRect);
+ TransparentLayerDC transparentDC(m_data, trRect, &intDstRect, 255, true);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ trRect.move(transparentDC.toShift());
+ FloatRect movedDstRect = m_data->m_transform.inverse().mapRect(FloatRect(trRect));
+ FloatSize moved(movedDstRect.location() - destRectIn.location());
+ AffineTransform transform = m_data->m_transform;
+ transform.translate(moved.width(), moved.height());
+
+ bmp->drawPattern(dc, transform, tileRectIn, patternTransform, phase, styleColorSpace, op, destRectIn, origSourceSize);
+
+ if (!bmp->hasAlpha())
+ transparentDC.fillAlphaChannel();
+}
+
+void GraphicsContext::drawIcon(HICON icon, const IntRect& dstRectIn, UINT flags)
+{
+ if (!m_data->m_opacity)
+ return;
+
+ ScopeDCProvider dcProvider(m_data);
+ if (!m_data->m_dc)
+ return;
+
+ IntRect dstRect = m_data->mapRect(dstRectIn);
+ TransparentLayerDC transparentDC(m_data, dstRect, &dstRectIn, 255, true);
+ HDC dc = transparentDC.hdc();
+ if (!dc)
+ return;
+ dstRect.move(transparentDC.toShift());
+
+ DrawIconEx(dc, dstRect.x(), dstRect.y(), icon, dstRect.width(), dstRect.height(), 0, NULL, flags);
+}
+
+void GraphicsContext::setPlatformShouldAntialias(bool)
+{
+ notImplemented();
+}
+
+void GraphicsContext::setLineDash(const DashArray&, float)
+{
+ notImplemented();
+}
+
+void GraphicsContext::clipPath(WindRule)
+{
+ notImplemented();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp b/WebCore/platform/graphics/wince/GraphicsContextWince.cpp
deleted file mode 100644
index 990a31d..0000000
--- a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp
+++ /dev/null
@@ -1,1950 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Torch Mobile 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 "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "CharacterNames.h"
-#include "Font.h"
-#include "GlyphBuffer.h"
-#include "Gradient.h"
-#include "GraphicsContextPrivate.h"
-#include "NotImplemented.h"
-#include "Path.h"
-#include "PlatformPathWince.h"
-#include "SharedBitmap.h"
-#include "SimpleFontData.h"
-#include <wtf/OwnPtr.h>
-
-#include <windows.h>
-
-namespace WebCore {
-
-typedef void (*FuncGradientFillRectLinear)(HDC hdc, const IntRect& r, const IntPoint& p0, const IntPoint& p1, const Vector<Gradient::ColorStop>& stops);
-typedef void (*FuncGradientFillRectRadial)(HDC hdc, const IntRect& r, const IntPoint& p0, const IntPoint& p1, float r0, float r1, const Vector<Gradient::ColorStop>& stops);
-FuncGradientFillRectLinear g_linearGradientFiller = 0;
-FuncGradientFillRectRadial g_radialGradientFiller = 0;
-
-static inline bool isZero(double d)
-{
- return d > 0 ? d <= 1.E-10 : d >= -1.E-10;
-}
-
-// stableRound rounds -0.5 to 0, where lround rounds -0.5 to -1.
-static inline int stableRound(double d)
-{
- if (d > 0)
- return static_cast<int>(d + 0.5);
-
- int i = static_cast<int>(d);
- return i - d > 0.5 ? i - 1 : i;
-}
-
-// Unlike enclosingIntRect(), this function does strict rounding.
-static inline IntRect roundRect(const FloatRect& r)
-{
- return IntRect(stableRound(r.x()), stableRound(r.y()), stableRound(r.right()) - stableRound(r.x()), stableRound(r.bottom()) - stableRound(r.y()));
-}
-
-// Rotation transformation
-class RotationTransform {
-public:
- RotationTransform()
- : m_cosA(1.)
- , m_sinA(0.)
- , m_preShiftX(0)
- , m_preShiftY(0)
- , m_postShiftX(0)
- , m_postShiftY(0)
- {
- }
- RotationTransform operator-() const
- {
- RotationTransform rtn;
- rtn.m_cosA = m_cosA;
- rtn.m_sinA = -m_sinA;
- rtn.m_preShiftX = m_postShiftX;
- rtn.m_preShiftY = m_postShiftY;
- rtn.m_postShiftX = m_preShiftX;
- rtn.m_postShiftY = m_preShiftY;
- return rtn;
- }
- void map(double x1, double y1, double* x2, double* y2) const
- {
- x1 += m_preShiftX;
- y1 += m_preShiftY;
- *x2 = x1 * m_cosA + y1 * m_sinA + m_postShiftX;
- *y2 = y1 * m_cosA - x1 * m_sinA + m_postShiftY;
- }
- void map(int x1, int y1, int* x2, int* y2) const
- {
- x1 += m_preShiftX;
- y1 += m_preShiftY;
- *x2 = stableRound(x1 * m_cosA + y1 * m_sinA) + m_postShiftX;
- *y2 = stableRound(y1 * m_cosA - x1 * m_sinA) + m_postShiftY;
- }
-
- double m_cosA;
- double m_sinA;
- int m_preShiftX;
- int m_preShiftY;
- int m_postShiftX;
- int m_postShiftY;
-};
-
-template<class T> static inline IntPoint mapPoint(const IntPoint& p, const T& t)
-{
- int x, y;
- t.map(p.x(), p.y(), &x, &y);
- return IntPoint(x, y);
-}
-
-template<class T> static inline FloatPoint mapPoint(const FloatPoint& p, const T& t)
-{
- double x, y;
- t.map(p.x(), p.y(), &x, &y);
- return FloatPoint(static_cast<float>(x), static_cast<float>(y));
-}
-
-template<class Transform, class Rect, class Value> static inline Rect mapRect(const Rect& rect, const Transform& transform)
-{
- Value x[4], y[4];
- Value l, t, r, b;
- r = rect.right() - 1;
- b = rect.bottom() - 1;
- transform.map(rect.x(), rect.y(), x, y);
- transform.map(rect.x(), b, x + 1, y + 1);
- transform.map(r, b, x + 2, y + 2);
- transform.map(r, rect.y(), x + 3, y + 3);
- l = r = x[3];
- t = b = y[3];
- for (int i = 0; i < 3; ++i) {
- if (x[i] < l)
- l = x[i];
- else if (x[i] > r)
- r = x[i];
-
- if (y[i] < t)
- t = y[i];
- else if (y[i] > b)
- b = y[i];
- }
-
- return IntRect(l, t, r - l + 1, b - t + 1);
-}
-
-template<class T> static inline IntRect mapRect(const IntRect& rect, const T& transform)
-{
- return mapRect<T, IntRect, int>(rect, transform);
-}
-
-template<class T> static inline FloatRect mapRect(const FloatRect& rect, const T& transform)
-{
- return mapRect<T, FloatRect, double>(rect, transform);
-}
-
-class GraphicsContextPlatformPrivateData {
-public:
- GraphicsContextPlatformPrivateData()
- : m_transform()
- , m_opacity(1.0)
- {
- }
-
- AffineTransform m_transform;
- float m_opacity;
- Vector<Path> m_paths;
-};
-
-enum AlphaPaintType {
- AlphaPaintNone,
- AlphaPaintImage,
- AlphaPaintOther,
-};
-
-class GraphicsContextPlatformPrivate : public GraphicsContextPlatformPrivateData {
-public:
- GraphicsContextPlatformPrivate(HDC dc)
- : m_dc(dc)
- {
- }
- ~GraphicsContextPlatformPrivate()
- {
- while (!m_backupData.isEmpty())
- restore();
- }
-
- IntPoint origin() const
- {
- return IntPoint(stableRound(-m_transform.e()), stableRound(-m_transform.f()));
- }
-
- void translate(float x, float y)
- {
- m_transform.translate(x, y);
- }
-
- void scale(const FloatSize& size)
- {
- m_transform.scaleNonUniform(size.width(), size.height());
- }
-
- void rotate(float radians)
- {
- m_transform.rotate(rad2deg(radians));
- }
-
- void concatCTM(const AffineTransform& transform)
- {
- m_transform = transform * m_transform;
- }
-
- IntRect mapRect(const IntRect& rect) const
- {
- return m_transform.mapRect(rect);
- }
-
- FloatRect mapRect(const FloatRect& rect) const
- {
- return m_transform.mapRect(rect);
- }
-
- IntPoint mapPoint(const IntPoint& point) const
- {
- return m_transform.mapPoint(point);
- }
-
- FloatPoint mapPoint(const FloatPoint& point) const
- {
- return m_transform.mapPoint(point);
- }
-
- FloatSize mapSize(const FloatSize& size) const
- {
- double w, h;
- m_transform.map(size.width(), size.height(), w, h);
- return FloatSize(static_cast<float>(w), static_cast<float>(h));
- }
-
- void save()
- {
- if (m_dc)
- SaveDC(m_dc);
-
- m_backupData.append(*static_cast<GraphicsContextPlatformPrivateData*>(this));
- }
-
- void restore()
- {
- if (m_backupData.isEmpty())
- return;
-
- if (m_dc)
- RestoreDC(m_dc, -1);
-
- GraphicsContextPlatformPrivateData::operator=(m_backupData.last());
- m_backupData.removeLast();
- }
-
- bool hasAlpha() const { return m_bitmap && m_bitmap->hasAlpha(); }
-
- PassRefPtr<SharedBitmap> getTransparentLayerBitmap(IntRect& origRect, AlphaPaintType alphaPaint, RECT& bmpRect, bool checkClipBox, bool force) const
- {
- if (m_opacity <= 0)
- return 0;
-
- if (force || m_opacity < 1.) {
- if (checkClipBox) {
- RECT clipBox;
- int clipType = GetClipBox(m_dc, &clipBox);
- if (clipType == SIMPLEREGION || clipType == COMPLEXREGION)
- origRect.intersect(clipBox);
- if (origRect.isEmpty())
- return 0;
- }
-
- RefPtr<SharedBitmap> bmp = SharedBitmap::createInstance(alphaPaint == AlphaPaintNone, origRect.width(), origRect.height(), false);
- SetRect(&bmpRect, 0, 0, origRect.width(), origRect.height());
- if (bmp) {
- switch (alphaPaint) {
- case AlphaPaintNone:
- case AlphaPaintImage:
- {
- SharedBitmap::DCHolder dc(bmp.get());
- if (dc.get()) {
- BitBlt(dc.get(), 0, 0, origRect.width(), origRect.height(), m_dc, origRect.x(), origRect.y(), SRCCOPY);
- if (bmp->is32bit() && (!m_bitmap || m_bitmap->is16bit())) {
- // Set alpha channel
- unsigned* pixels = (unsigned*)bmp->bytes();
- const unsigned* const pixelsEnd = pixels + bmp->bitmapInfo().numPixels();
- while (pixels < pixelsEnd) {
- *pixels |= 0xFF000000;
- ++pixels;
- }
- }
- return bmp;
- }
- }
- break;
- //case AlphaPaintOther:
- default:
- memset(bmp->bytes(), 0xFF, bmp->bitmapInfo().numPixels() * 4);
- return bmp;
- break;
- }
- }
- }
-
- bmpRect = origRect;
- return 0;
- }
-
- void paintBackTransparentLayerBitmap(HDC hdc, SharedBitmap* bmp, const IntRect& origRect, AlphaPaintType alphaPaint, const RECT& bmpRect)
- {
- if (hdc == m_dc)
- return;
-
-#if !defined(NO_ALPHABLEND)
- if (alphaPaint == AlphaPaintOther) {
- ASSERT(bmp && bmp->bytes() && bmp->is32bit());
- unsigned* pixels = (unsigned*)bmp->bytes();
- const unsigned* const pixelsEnd = pixels + bmp->bitmapInfo().numPixels();
- while (pixels < pixelsEnd) {
- *pixels ^= 0xFF000000;
- ++pixels;
- }
- }
- if (m_opacity < 1. || alphaPaint == AlphaPaintOther) {
- const BLENDFUNCTION blend = { AC_SRC_OVER, 0
- , m_opacity >= 1. ? 255 : (BYTE)(m_opacity * 255)
- , alphaPaint == AlphaPaintNone ? 0 : AC_SRC_ALPHA };
- AlphaBlend(m_dc, origRect.x(), origRect.y(), origRect.width(), origRect.height(), hdc, 0, 0, bmpRect.right, bmpRect.bottom, blend);
- } else
-#endif
- StretchBlt(m_dc, origRect.x(), origRect.y(), origRect.width(), origRect.height(), hdc, 0, 0, bmpRect.right, bmpRect.bottom, SRCCOPY);
- }
-
- HDC m_dc;
- RefPtr<SharedBitmap> m_bitmap;
- Vector<GraphicsContextPlatformPrivateData> m_backupData;
-};
-
-static HPEN createPen(const Color& col, double fWidth, StrokeStyle style)
-{
- int width = stableRound(fWidth);
- if (width < 1)
- width = 1;
-
- int penStyle = PS_NULL;
- switch (style) {
- case SolidStroke:
- penStyle = PS_SOLID;
- break;
- case DottedStroke: // not supported on Windows CE
- case DashedStroke:
- penStyle = PS_DASH;
- width = 1;
- break;
- default:
- break;
- }
-
- return CreatePen(penStyle, width, RGB(col.red(), col.green(), col.blue()));
-}
-
-static inline HGDIOBJ createBrush(const Color& col)
-{
- return CreateSolidBrush(RGB(col.red(), col.green(), col.blue()));
-}
-
-template <typename PixelType, bool Is16bit> static void _rotateBitmap(SharedBitmap* destBmp, const SharedBitmap* sourceBmp, const RotationTransform& transform)
-{
- int destW = destBmp->width();
- int destH = destBmp->height();
- int sourceW = sourceBmp->width();
- int sourceH = sourceBmp->height();
- PixelType* dest = (PixelType*)destBmp->bytes();
- const PixelType* source = (const PixelType*)sourceBmp->bytes();
- int padding;
- int paddedSourceW;
- if (Is16bit) {
- padding = destW & 1;
- paddedSourceW = sourceW + (sourceW & 1);
- } else {
- padding = 0;
- paddedSourceW = sourceW;
- }
- if (isZero(transform.m_sinA)) {
- int cosA = transform.m_cosA > 0 ? 1 : -1;
- for (int y = 0; y < destH; ++y) {
- for (int x = 0; x < destW; ++x) {
- int x1 = x + transform.m_preShiftX;
- int y1 = y + transform.m_preShiftY;
- int srcX = x1 * cosA + transform.m_postShiftX;
- int srcY = y1 * cosA - transform.m_postShiftY;
- if (srcX >= 0 && srcX <= sourceW && srcY >= 0 && srcY <= sourceH)
- *dest++ = source[srcY * paddedSourceW + srcX] | 0xFF000000;
- else
- *dest++ |= 0xFF;
- }
- dest += padding;
- }
- } else if (isZero(transform.m_cosA)) {
- int sinA = transform.m_sinA > 0 ? 1 : -1;
- for (int y = 0; y < destH; ++y) {
- for (int x = 0; x < destW; ++x) {
- int x1 = x + transform.m_preShiftX;
- int y1 = y + transform.m_preShiftY;
- int srcX = y1 * sinA + transform.m_postShiftX;
- int srcY = -x1 * sinA + transform.m_postShiftY;
- if (srcX >= 0 && srcX <= sourceW && srcY >= 0 && srcY <= sourceH)
- *dest++ = source[srcY * paddedSourceW + srcX];
- }
- dest += padding;
- }
- } else {
- for (int y = 0; y < destH; ++y) {
- for (int x = 0; x < destW; ++x) {
- // FIXME: for best quality, we should get weighted sum of four neighbours,
- // but that will be too expensive
- int srcX, srcY;
- transform.map(x, y, &srcX, &srcY);
- if (srcX >= 0 && srcX <= sourceW && srcY >= 0 && srcY <= sourceH)
- *dest++ = source[srcY * paddedSourceW + srcX];
- }
- dest += padding;
- }
- }
-}
-
-static void rotateBitmap(SharedBitmap* destBmp, const SharedBitmap* sourceBmp, const RotationTransform& transform)
-{
- ASSERT(destBmp->is16bit() == sourceBmp->is16bit());
- if (destBmp->is16bit())
- _rotateBitmap<unsigned short, true>(destBmp, sourceBmp, transform);
- else
- _rotateBitmap<unsigned, false>(destBmp, sourceBmp, transform);
-}
-
-class TransparentLayerDC : Noncopyable {
-public:
- TransparentLayerDC(GraphicsContextPlatformPrivate* data, IntRect& origRect, const IntRect* rectBeforeTransform = 0, int alpha = 255, bool paintImage = false);
- ~TransparentLayerDC();
-
- HDC hdc() const { return m_memDc; }
- const RECT& rect() const { return m_bmpRect; }
- IntSize toShift() const { return IntSize(m_bmpRect.left - m_origRect.x(), m_bmpRect.top - m_origRect.y()); }
- void fillAlphaChannel();
-
-private:
- GraphicsContextPlatformPrivate* m_data;
- IntRect m_origRect;
- IntRect m_rotatedOrigRect;
- HDC m_memDc;
- RefPtr<SharedBitmap> m_bitmap;
- RefPtr<SharedBitmap> m_rotatedBitmap;
- RECT m_bmpRect;
- unsigned m_key1;
- unsigned m_key2;
- RotationTransform m_rotation;
- float m_oldOpacity;
- AlphaPaintType m_alphaPaintType;
-};
-
-TransparentLayerDC::TransparentLayerDC(GraphicsContextPlatformPrivate* data, IntRect& origRect, const IntRect* rectBeforeTransform, int alpha, bool paintImage)
-: m_data(data)
-, m_origRect(origRect)
-, m_oldOpacity(data->m_opacity)
-// m_key1 and m_key2 are not initalized here. They are used only in the case that
-// SharedBitmap::getDC() is called, I.E., when m_bitmap is not null.
-{
- m_data->m_opacity *= alpha / 255.;
- bool mustCreateLayer;
- if (!m_data->hasAlpha()) {
- mustCreateLayer = false;
- m_alphaPaintType = AlphaPaintNone;
- } else {
- mustCreateLayer = true;
- m_alphaPaintType = paintImage ? AlphaPaintImage : AlphaPaintOther;
- }
- if (rectBeforeTransform && !isZero(m_data->m_transform.b())) {
- m_rotatedOrigRect = origRect;
- m_rotatedBitmap = m_data->getTransparentLayerBitmap(m_rotatedOrigRect, m_alphaPaintType, m_bmpRect, false, true);
- if (m_rotatedBitmap) {
- double a = m_data->m_transform.a();
- double b = m_data->m_transform.b();
- double c = _hypot(a, b);
- m_rotation.m_cosA = a / c;
- m_rotation.m_sinA = b / c;
-
- int centerX = origRect.x() + origRect.width() / 2;
- int centerY = origRect.y() + origRect.height() / 2;
- m_rotation.m_preShiftX = -centerX;
- m_rotation.m_preShiftY = -centerY;
- m_rotation.m_postShiftX = centerX;
- m_rotation.m_postShiftY = centerY;
-
- m_origRect = mapRect(m_rotatedOrigRect, m_rotation);
-
- m_rotation.m_preShiftX += m_rotatedOrigRect.x();
- m_rotation.m_preShiftY += m_rotatedOrigRect.y();
- m_rotation.m_postShiftX -= m_origRect.x();
- m_rotation.m_postShiftY -= m_origRect.y();
-
- FloatPoint topLeft = m_data->m_transform.mapPoint(FloatPoint(rectBeforeTransform->topLeft()));
- FloatPoint topRight(rectBeforeTransform->right() - 1, rectBeforeTransform->y());
- topRight = m_data->m_transform.mapPoint(topRight);
- FloatPoint bottomLeft(rectBeforeTransform->x(), rectBeforeTransform->bottom() - 1);
- bottomLeft = m_data->m_transform.mapPoint(bottomLeft);
- FloatSize sideTop = topRight - topLeft;
- FloatSize sideLeft = bottomLeft - topLeft;
- float width = _hypot(sideTop.width() + 1, sideTop.height() + 1);
- float height = _hypot(sideLeft.width() + 1, sideLeft.height() + 1);
-
- origRect.inflateX(stableRound((width - origRect.width()) * 0.5));
- origRect.inflateY(stableRound((height - origRect.height()) * 0.5));
-
- m_bitmap = SharedBitmap::createInstance(m_rotatedBitmap->is16bit(), m_origRect.width(), m_origRect.height(), true);
- if (m_bitmap)
- rotateBitmap(m_bitmap.get(), m_rotatedBitmap.get(), -m_rotation);
- else
- m_rotatedBitmap = 0;
- }
- } else
- m_bitmap = m_data->getTransparentLayerBitmap(m_origRect, m_alphaPaintType, m_bmpRect, true, mustCreateLayer);
- if (m_bitmap)
- m_memDc = m_bitmap->getDC(&m_key1, &m_key2);
- else
- m_memDc = m_data->m_dc;
-}
-
-TransparentLayerDC::~TransparentLayerDC()
-{
- if (m_rotatedBitmap) {
- m_bitmap->releaseDC(m_memDc, m_key1, m_key2);
- m_key1 = m_key2 = 0;
- rotateBitmap(m_rotatedBitmap.get(), m_bitmap.get(), m_rotation);
- m_memDc = m_rotatedBitmap->getDC(&m_key1, &m_key2);
- m_data->paintBackTransparentLayerBitmap(m_memDc, m_rotatedBitmap.get(), m_rotatedOrigRect, m_alphaPaintType, m_bmpRect);
- m_rotatedBitmap->releaseDC(m_memDc, m_key1, m_key2);
- } else if (m_bitmap) {
- m_data->paintBackTransparentLayerBitmap(m_memDc, m_bitmap.get(), m_origRect, m_alphaPaintType, m_bmpRect);
- m_bitmap->releaseDC(m_memDc, m_key1, m_key2);
- }
- m_data->m_opacity = m_oldOpacity;
-}
-
-void TransparentLayerDC::fillAlphaChannel()
-{
- if (!m_bitmap || !m_bitmap->is32bit())
- return;
-
- unsigned* pixels = (unsigned*)m_bitmap->bytes();
- const unsigned* const pixelsEnd = pixels + m_bitmap->bitmapInfo().numPixels();
- while (pixels < pixelsEnd) {
- *pixels |= 0xFF000000;
- ++pixels;
- }
-}
-
-class ScopeDCProvider : Noncopyable {
-public:
- explicit ScopeDCProvider(GraphicsContextPlatformPrivate* data)
- : m_data(data)
- {
- if (m_data->m_bitmap)
- m_data->m_dc = m_data->m_bitmap->getDC(&m_key1, &m_key2);
- }
- ~ScopeDCProvider()
- {
- if (m_data->m_bitmap) {
- m_data->m_bitmap->releaseDC(m_data->m_dc, m_key1, m_key2);
- m_data->m_dc = 0;
- }
- }
-private:
- GraphicsContextPlatformPrivate* m_data;
- unsigned m_key1;
- unsigned m_key2;
-};
-
-
-GraphicsContext::GraphicsContext(PlatformGraphicsContext* dc)
-: m_common(createGraphicsContextPrivate())
-, m_data(new GraphicsContextPlatformPrivate(dc))
-{
-}
-
-GraphicsContext::~GraphicsContext()
-{
- destroyGraphicsContextPrivate(m_common);
- delete m_data;
-}
-
-void GraphicsContext::setBitmap(PassRefPtr<SharedBitmap> bmp)
-{
- ASSERT(!m_data->m_dc);
- m_data->m_bitmap = bmp;
-}
-
-HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- notImplemented();
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- notImplemented();
- ASSERT_NOT_REACHED();
-}
-
-void GraphicsContext::savePlatformState()
-{
- m_data->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- m_data->restore();
-}
-
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (!m_data->m_opacity || paintingDisabled() || rect.isEmpty())
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
- TransparentLayerDC transparentDC(m_data, trRect, &rect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- HGDIOBJ brush = 0;
- HGDIOBJ oldBrush;
- if (fillColor().alpha()) {
- brush = createBrush(fillColor());
- oldBrush = SelectObject(dc, brush);
- } else
- SelectObject(dc, GetStockObject(NULL_BRUSH));
-
- HGDIOBJ pen = 0;
- HGDIOBJ oldPen;
- if (strokeStyle() != NoStroke) {
- pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- oldPen = SelectObject(dc, pen);
- } else
- SelectObject(dc, GetStockObject(NULL_PEN));
-
- if (!brush && !pen)
- return;
-
- if (trRect.width() <= 0)
- trRect.setWidth(1);
- if (trRect.height() <= 0)
- trRect.setHeight(1);
-
- Rectangle(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
-
- if (pen) {
- SelectObject(dc, oldPen);
- DeleteObject(pen);
- }
-
- if (brush) {
- SelectObject(dc, oldBrush);
- DeleteObject(brush);
- }
-}
-
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke || !strokeColor().alpha())
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntPoint trPoint1 = m_data->mapPoint(point1);
- IntPoint trPoint2 = m_data->mapPoint(point2);
-
- IntRect lineRect(trPoint1, trPoint2 - trPoint1);
- lineRect.setHeight(lineRect.height() + strokeThickness());
- TransparentLayerDC transparentDC(m_data, lineRect, 0, strokeColor().alpha());
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trPoint1 += transparentDC.toShift();
- trPoint2 += transparentDC.toShift();
-
- HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- HGDIOBJ oldPen = SelectObject(dc, pen);
-
- MoveToEx(dc, trPoint1.x(), trPoint1.y(), 0);
- LineTo(dc, trPoint2.x(), trPoint2.y());
-
- SelectObject(dc, oldPen);
- DeleteObject(pen);
-}
-
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- if (!m_data->m_opacity || paintingDisabled() || (!fillColor().alpha() && strokeStyle() == NoStroke))
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
- TransparentLayerDC transparentDC(m_data, trRect, &rect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- HGDIOBJ brush = 0;
- HGDIOBJ oldBrush;
- if (fillColor().alpha()) {
- brush = createBrush(fillColor());
- oldBrush = SelectObject(dc, brush);
- } else
- SelectObject(dc, GetStockObject(NULL_BRUSH));
- HGDIOBJ pen = 0;
- HGDIOBJ oldPen;
- if (strokeStyle() != NoStroke) {
- pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- oldPen = SelectObject(dc, pen);
- } else
- SelectObject(dc, GetStockObject(NULL_PEN));
-
- Ellipse(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
-
- if (pen) {
- SelectObject(dc, oldPen);
- DeleteObject(pen);
- }
-
- if (brush) {
- SelectObject(dc, oldBrush);
- DeleteObject(brush);
- }
-}
-
-static inline bool equalAngle(double a, double b)
-{
- return fabs(a - b) < 1E-5;
-}
-
-void getEllipsePointByAngle(double angle, double a, double b, float& x, float& y)
-{
- while (angle < 0)
- angle += 2 * piDouble;
- while (angle >= 2 * piDouble)
- angle -= 2 * piDouble;
-
- if (equalAngle(angle, 0) || equalAngle(angle, 2 * piDouble)) {
- x = a;
- y = 0;
- } else if (equalAngle(angle, piDouble)) {
- x = -a;
- y = 0;
- } else if (equalAngle(angle, .5 * piDouble)) {
- x = 0;
- y = b;
- } else if (equalAngle(angle, 1.5 * piDouble)) {
- x = 0;
- y = -b;
- } else {
- double k = tan(angle);
- double sqA = a * a;
- double sqB = b * b;
- double tmp = 1. / (1. / sqA + (k * k) / sqB);
- tmp = tmp <= 0 ? 0 : sqrt(tmp);
- if (angle > .5 * piDouble && angle < 1.5 * piDouble)
- tmp = -tmp;
- x = tmp;
-
- k = tan(.5 * piDouble - angle);
- tmp = 1. / ((k * k) / sqA + 1 / sqB);
- tmp = tmp <= 0 ? 0 : sqrt(tmp);
- if (angle > piDouble)
- tmp = -tmp;
- y = tmp;
- }
-}
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke || rect.isEmpty())
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
- TransparentLayerDC transparentDC(m_data, trRect, &rect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- HGDIOBJ oldPen = SelectObject(dc, pen);
-
- double a = trRect.width() * 0.5;
- double b = trRect.height() * 0.5;
- int centerX = stableRound(trRect.x() + a);
- int centerY = stableRound(trRect.y() + b);
- float fstartX, fstartY, fendX, fendY;
- int startX, startY, endX, endY;
- getEllipsePointByAngle(deg2rad((double)startAngle), a, b, fstartX, fstartY);
- getEllipsePointByAngle(deg2rad((double)startAngle + angleSpan), a, b, fendX, fendY);
- startX = stableRound(fstartX);
- startY = stableRound(fstartY);
- endX = stableRound(fendX);
- endY = stableRound(fendY);
-
- startX += centerX;
- startY = centerY - startY;
- endX += centerX;
- endY = centerY - endY;
- RECT clipRect;
- if (startX < endX) {
- clipRect.left = startX;
- clipRect.right = endX;
- } else {
- clipRect.left = endX;
- clipRect.right = startX;
- }
- if (startY < endY) {
- clipRect.top = startY;
- clipRect.bottom = endY;
- } else {
- clipRect.top = endY;
- clipRect.bottom = startY;
- }
-
- OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
- bool newClip;
- if (GetClipRgn(dc, clipRgn.get()) <= 0) {
- newClip = true;
- clipRgn.set(CreateRectRgn(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom));
- SelectClipRgn(dc, clipRgn.get());
- } else {
- newClip = false;
- IntersectClipRect(dc, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
- }
-
- HGDIOBJ oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));
- Ellipse(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
- SelectObject(dc, oldBrush);
-
- if (newClip)
- SelectClipRgn(dc, 0);
- else
- SelectClipRgn(dc, clipRgn.get());
-
- SelectObject(dc, oldPen);
- DeleteObject(pen);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (!m_data->m_opacity || paintingDisabled() || npoints <= 1 || !points)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- Vector<POINT, 20> winPoints(npoints);
- FloatPoint trPoint = m_data->mapPoint(points[0]);
- winPoints[0].x = stableRound(trPoint.x());
- winPoints[0].y = stableRound(trPoint.y());
- RECT rect = { winPoints[0].x, winPoints[0].y, winPoints[0].x, winPoints[0].y };
- for (size_t i = 1; i < npoints; ++i) {
- trPoint = m_data->mapPoint(points[i]);
- winPoints[i].x = stableRound(trPoint.x());
- winPoints[i].y = stableRound(trPoint.y());
- if (rect.left > winPoints[i].x)
- rect.left = winPoints[i].x;
- else if (rect.right < winPoints[i].x)
- rect.right = winPoints[i].x;
- if (rect.top > winPoints[i].y)
- rect.top = winPoints[i].y;
- else if (rect.bottom < winPoints[i].y)
- rect.bottom = winPoints[i].y;
- }
- rect.bottom += 1;
- rect.right += 1;
-
- IntRect intRect(rect);
- TransparentLayerDC transparentDC(m_data, intRect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
-
- for (size_t i = 0; i < npoints; ++i) {
- winPoints[i].x += transparentDC.toShift().width();
- winPoints[i].y += transparentDC.toShift().height();
- }
-
- HGDIOBJ brush = 0;
- HGDIOBJ oldBrush;
- if (fillColor().alpha()) {
- brush = createBrush(fillColor());
- oldBrush = SelectObject(dc, brush);
- } else
- SelectObject(dc, GetStockObject(NULL_BRUSH));
-
- HGDIOBJ pen = 0;
- HGDIOBJ oldPen;
- if (strokeStyle() != NoStroke) {
- pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- oldPen = SelectObject(dc, pen);
- } else
- SelectObject(dc, GetStockObject(NULL_PEN));
-
- if (!brush && !pen)
- return;
-
- Polygon(dc, winPoints.data(), npoints);
-
- if (pen) {
- SelectObject(dc, oldPen);
- DeleteObject(pen);
- }
-
- if (brush) {
- SelectObject(dc, oldBrush);
- DeleteObject(brush);
- }
-}
-
-void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased)
-{
- if (paintingDisabled())
- return;
-
- if (numPoints <= 1)
- return;
-
- // FIXME: IMPLEMENT!!
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled() || !m_data->m_opacity)
- return;
-
- int alpha = color.alpha();
- if (!alpha)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect intRect = enclosingIntRect(rect);
- TransparentLayerDC transparentDC(m_data, m_data->mapRect(intRect), &intRect, alpha);
-
- if (!transparentDC.hdc())
- return;
-
- OwnPtr<HBRUSH> hbrush(CreateSolidBrush(RGB(color.red(), color.green(), color.blue())));
- FillRect(transparentDC.hdc(), &transparentDC.rect(), hbrush.get());
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = enclosingIntRect(m_data->mapRect(rect));
-
- OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
- if (GetClipRgn(m_data->m_dc, clipRgn.get()) > 0)
- IntersectClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
- else {
- clipRgn.set(CreateRectRgn(trRect.x(), trRect.y(), trRect.right(), trRect.bottom()));
- SelectClipRgn(m_data->m_dc, clipRgn.get());
- }
-}
-
-void GraphicsContext::clipOut(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
-
- ExcludeClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
-}
-
-void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
-{
- // FIXME: implement
-}
-
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
-{
- if (!m_data->m_opacity || paintingDisabled())
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- int radius = (width - 1) / 2;
- offset += radius;
-
- unsigned rectCount = rects.size();
- IntRect finalFocusRect;
- for (unsigned i = 0; i < rectCount; i++) {
- IntRect focusRect = rects[i];
- focusRect.inflate(offset);
- finalFocusRect.unite(focusRect);
- }
-
- IntRect intRect = finalFocusRect;
- IntRect trRect = m_data->mapRect(finalFocusRect);
- TransparentLayerDC transparentDC(m_data, trRect, &intRect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- RECT rect = trRect;
- DrawFocusRect(dc, &rect);
-}
-
-void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
-{
- if (paintingDisabled())
- return;
-
- StrokeStyle oldStyle = strokeStyle();
- setStrokeStyle(SolidStroke);
- drawLine(origin, origin + IntSize(width, 0));
- setStrokeStyle(oldStyle);
-}
-
-void GraphicsContext::drawLineForTextChecking(const IntPoint&, int width, TextCheckingLineStyle style)
-{
- notImplemented();
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& col, ColorSpace colorSpace)
-{
- notImplemented();
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& col, ColorSpace colorSpace)
-{
- notImplemented();
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float strokeThickness)
-{
- notImplemented();
-}
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
- notImplemented();
-}
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- // We can only clip rectangles on WINCE
- clip(rect);
-}
-
-void GraphicsContext::clearRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->hasAlpha()) {
- IntRect trRect = enclosingIntRect(m_data->mapRect(rect));
- m_data->m_bitmap->clearPixels(trRect);
- return;
- }
-
- fillRect(rect, Color(Color::white), DeviceColorSpace);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& rect, float width)
-{
- if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect intRect = enclosingIntRect(rect);
- IntRect trRect = m_data->mapRect(intRect);
- TransparentLayerDC transparentDC(m_data, trRect, &intRect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- HGDIOBJ oldPen = SelectObject(dc, pen);
-
- int right = trRect.right() - 1;
- int bottom = trRect.bottom() - 1;
- const POINT intPoints[5] =
- {
- { trRect.x(), trRect.y() },
- { right, trRect.y() },
- { right, bottom },
- { trRect.x(), bottom },
- { trRect.x(), trRect.y() }
- };
-
- Polyline(dc, intPoints, 5);
-
- SelectObject(dc, oldPen);
- DeleteObject(pen);
-}
-
-void GraphicsContext::beginTransparencyLayer(float opacity)
-{
- m_data->save();
- m_data->m_opacity *= opacity;
-}
-
-void GraphicsContext::endTransparencyLayer()
-{
- m_data->restore();
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& transform)
-{
- m_data->concatCTM(transform);
-}
-
-AffineTransform& GraphicsContext::affineTransform()
-{
- return m_data->m_transform;
-}
-
-const AffineTransform& GraphicsContext::affineTransform() const
-{
- return m_data->m_transform;
-}
-
-void GraphicsContext::resetAffineTransform()
-{
- m_data->m_transform.makeIdentity();
-}
-
-void GraphicsContext::translate(float x, float y)
-{
- m_data->translate(x, y);
-}
-
-void GraphicsContext::rotate(float radians)
-{
- m_data->rotate(radians);
-}
-
-IntPoint GraphicsContext::origin()
-{
- return m_data->origin();
-}
-
-void GraphicsContext::scale(const FloatSize& size)
-{
- m_data->scale(size);
-}
-
-void GraphicsContext::setLineCap(LineCap lineCap)
-{
- notImplemented();
-}
-
-void GraphicsContext::setLineJoin(LineJoin lineJoin)
-{
- notImplemented();
-}
-
-void GraphicsContext::setMiterLimit(float miter)
-{
- notImplemented();
-}
-
-void GraphicsContext::setAlpha(float alpha)
-{
- m_data->m_opacity = alpha;
-}
-
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
-{
- notImplemented();
-}
-
-void GraphicsContext::beginPath()
-{
- m_data->m_paths.clear();
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- m_data->m_paths.append(path);
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- notImplemented();
-}
-
-void GraphicsContext::canvasClip(const Path& path)
-{
- clip(path);
-}
-
-void GraphicsContext::clipOut(const Path&)
-{
- notImplemented();
-}
-
-void GraphicsContext::clipOutEllipseInRect(const IntRect&)
-{
- notImplemented();
-}
-
-static inline IntPoint rectCenterPoint(const RECT& rect)
-{
- return IntPoint(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
-}
-void GraphicsContext::fillRoundedRect(const IntRect& fillRect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& c, ColorSpace colorSpace)
-{
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- FloatSize shadowOffset;
- float shadowBlur = 0;
- Color shadowColor;
-
- getShadow(shadowOffset, shadowBlur, shadowColor);
-
- IntRect dstRect = fillRect;
-
- dstRect.move(stableRound(shadowOffset.width()), stableRound(shadowOffset.height()));
- dstRect.inflate(stableRound(shadowBlur));
- dstRect = m_data->mapRect(dstRect);
-
- FloatSize newTopLeft(m_data->mapSize(topLeft));
- FloatSize newTopRight(m_data->mapSize(topRight));
- FloatSize newBottomLeft(m_data->mapSize(bottomLeft));
- FloatSize newBottomRight(m_data->mapSize(bottomRight));
-
- TransparentLayerDC transparentDc(m_data, dstRect, &fillRect);
- HDC dc = transparentDc.hdc();
- if (!dc)
- return;
-
- dstRect.move(transparentDc.toShift());
-
- RECT rectWin = dstRect;
-
- HGDIOBJ brush = createBrush(shadowColor);
- HGDIOBJ oldBrush = SelectObject(dc, brush);
-
- SelectObject(dc, GetStockObject(NULL_PEN));
-
- IntPoint centerPoint = rectCenterPoint(rectWin);
- // Draw top left half
- RECT clipRect(rectWin);
- clipRect.right = centerPoint.x();
- clipRect.bottom = centerPoint.y();
-
- OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
- bool needsNewClip = (GetClipRgn(dc, clipRgn.get()) <= 0);
-
- drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newTopLeft.width() * 2), stableRound(newTopLeft.height() * 2));
-
- // Draw top right
- clipRect = rectWin;
- clipRect.left = centerPoint.x();
- clipRect.bottom = centerPoint.y();
-
- drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newTopRight.width() * 2), stableRound(newTopRight.height() * 2));
-
- // Draw bottom left
- clipRect = rectWin;
- clipRect.right = centerPoint.x();
- clipRect.top = centerPoint.y();
-
- drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newBottomLeft.width() * 2), stableRound(newBottomLeft.height() * 2));
-
- // Draw bottom right
- clipRect = rectWin;
- clipRect.left = centerPoint.x();
- clipRect.top = centerPoint.y();
-
- drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newBottomRight.width() * 2), stableRound(newBottomRight.height() * 2));
-
- SelectObject(dc, oldBrush);
- DeleteObject(brush);
-}
-
-
-void GraphicsContext::drawRoundCorner(bool needsNewClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height)
-{
- if (!dc)
- return;
-
- OwnPtr<HRGN> clipRgn(CreateRectRgn(0, 0, 0, 0));
- if (needsNewClip) {
- clipRgn.set(CreateRectRgn(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom));
- SelectClipRgn(dc, clipRgn.get());
- } else
- IntersectClipRect(dc, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
-
- ::RoundRect(dc, rectWin.left , rectWin.top , rectWin.right , rectWin.bottom , width, height);
-
- SelectClipRgn(dc, needsNewClip ? 0 : clipRgn.get());
-}
-
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
-{
- notImplemented();
- return frect;
-}
-
-Color gradientAverageColor(const Gradient* gradient)
-{
- const Vector<Gradient::ColorStop>& stops = gradient->getStops();
- if (stops.isEmpty())
- return Color();
-
- const Gradient::ColorStop& stop = stops.first();
- if (stops.size() == 1)
- return Color(stop.red, stop.green, stop.blue, stop.alpha);
-
- const Gradient::ColorStop& lastStop = stops.last();
- return Color((stop.red + lastStop.red) * 0.5f
- , (stop.green + lastStop.green) * 0.5f
- , (stop.blue + lastStop.blue) * 0.5f
- , (stop.alpha + lastStop.alpha) * 0.5f);
-}
-
-void GraphicsContext::fillPath()
-{
- Color c = m_common->state.fillGradient
- ? gradientAverageColor(m_common->state.fillGradient.get())
- : fillColor();
-
- if (!c.alpha() || !m_data->m_opacity)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) {
- HGDIOBJ brush = createBrush(c);
- for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) {
- IntRect trRect = enclosingIntRect(m_data->mapRect(i->boundingRect()));
- trRect.inflate(1);
- TransparentLayerDC transparentDC(m_data, trRect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- continue;
-
- AffineTransform tr = m_data->m_transform;
- tr.translate(transparentDC.toShift().width(), transparentDC.toShift().height());
-
- SelectObject(dc, GetStockObject(NULL_PEN));
- HGDIOBJ oldBrush = SelectObject(dc, brush);
- i->platformPath()->fillPath(dc, &tr);
- SelectObject(dc, oldBrush);
- }
- DeleteObject(brush);
- } else {
- SelectObject(m_data->m_dc, GetStockObject(NULL_PEN));
- HGDIOBJ brush = createBrush(c);
- HGDIOBJ oldBrush = SelectObject(m_data->m_dc, brush);
- for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i)
- i->platformPath()->fillPath(m_data->m_dc, &m_data->m_transform);
- SelectObject(m_data->m_dc, oldBrush);
- DeleteObject(brush);
- }
-}
-
-
-void GraphicsContext::strokePath()
-{
- if (!m_data->m_opacity)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) {
- HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) {
- IntRect trRect = enclosingIntRect(m_data->mapRect(i->boundingRect()));
- trRect.inflate(1);
- TransparentLayerDC transparentDC(m_data, trRect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- continue;
-
- AffineTransform tr = m_data->m_transform;
- tr.translate(transparentDC.toShift().width(), transparentDC.toShift().height());
-
- SelectObject(dc, GetStockObject(NULL_BRUSH));
- HGDIOBJ oldPen = SelectObject(dc, pen);
- i->platformPath()->strokePath(dc, &tr);
- SelectObject(dc, oldPen);
- }
- DeleteObject(pen);
- } else {
- SelectObject(m_data->m_dc, GetStockObject(NULL_BRUSH));
- HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- HGDIOBJ oldPen = SelectObject(m_data->m_dc, pen);
- for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i)
- i->platformPath()->strokePath(m_data->m_dc, &m_data->m_transform);
- SelectObject(m_data->m_dc, oldPen);
- DeleteObject(pen);
- }
-}
-
-void GraphicsContext::fillRect(const FloatRect& r, const Gradient* gradient)
-{
- if (!m_data->m_opacity)
- return;
-
- const Vector<Gradient::ColorStop>& stops = gradient->getStops();
- if (stops.isEmpty())
- return;
-
- size_t numStops = stops.size();
- if (numStops == 1) {
- const Gradient::ColorStop& stop = stops.first();
- Color color(stop.red, stop.green, stop.blue, stop.alpha);
- fillRect(r, color, DeviceColorSpace);
- return;
- }
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect intRect = enclosingIntRect(r);
- IntRect rect = m_data->mapRect(intRect);
- TransparentLayerDC transparentDC(m_data, rect, &intRect, 255, true);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
-
- rect.move(transparentDC.toShift());
- FloatPoint fp0 = m_data->mapPoint(gradient->p0());
- FloatPoint fp1 = m_data->mapPoint(gradient->p1());
- IntPoint p0(stableRound(fp0.x()), stableRound(fp0.y()));
- IntPoint p1(stableRound(fp1.x()), stableRound(fp1.y()));
- p0 += transparentDC.toShift();
- p1 += transparentDC.toShift();
-
- if (gradient->isRadial()) {
- if (g_radialGradientFiller) {
- // FIXME: don't support 2D scaling at this time
- double scale = (m_data->m_transform.a() + m_data->m_transform.d()) * 0.5;
- float r0 = gradient->r0() * scale;
- float r1 = gradient->r1() * scale;
- g_radialGradientFiller(dc, rect, p0, p1, r0, r1, gradient->getStops());
- return;
- }
- } else if (g_linearGradientFiller) {
- g_linearGradientFiller(dc, rect, p0, p1, gradient->getStops());
- return;
- }
-
- // Simple 1D linear solution that assumes p0 is on the top or left side, and p1 is on the right or bottom side
- size_t numRects = (numStops - 1);
- Vector<TRIVERTEX, 20> tv;
- tv.resize(numRects * 2);
- Vector<GRADIENT_RECT, 10> mesh;
- mesh.resize(numRects);
- int x = rect.x();
- int y = rect.y();
- int width = rect.width();
- int height = rect.height();
- FloatSize d = gradient->p1() - gradient->p0();
- bool vertical = fabs(d.height()) > fabs(d.width());
- for (size_t i = 0; i < numStops; ++i) {
- const Gradient::ColorStop& stop = stops[i];
- int iTv = i ? 2 * i - 1 : 0;
- tv[iTv].Red = stop.red * 0xFFFF;
- tv[iTv].Green = stop.green * 0xFFFF;
- tv[iTv].Blue = stop.blue * 0xFFFF;
- tv[iTv].Alpha = stop.alpha * 0xFFFF;
- if (i) {
- tv[iTv].x = vertical ? x + width: x + width * stop.stop;
- tv[iTv].y = vertical ? y + height * stop.stop : y + height;
- mesh[i - 1].UpperLeft = iTv - 1;
- mesh[i - 1].LowerRight = iTv;
- } else {
- tv[iTv].x = x;
- tv[iTv].y = y;
- }
-
- if (i && i < numRects) {
- tv[iTv + 1] = tv[iTv];
- if (vertical)
- tv[iTv + 1].x = x;
- else
- tv[iTv + 1].y = y;
- }
- }
-
- GradientFill(dc, tv.data(), tv.size(), mesh.data(), mesh.size(), vertical ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H);
-}
-
-AffineTransform GraphicsContext::getCTM() const
-{
- return m_data->m_transform;
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- savePlatformState();
-
- if (m_common->state.fillGradient)
- fillRect(rect, m_common->state.fillGradient.get());
- else
- fillRect(rect, fillColor(), DeviceColorSpace);
-
- restorePlatformState();
-}
-
-void GraphicsContext::setPlatformShadow(const FloatSize&, float, const Color&, ColorSpace)
-{
- notImplemented();
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- notImplemented();
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
-{
- notImplemented();
-}
-
-static inline bool isCharVisible(UChar c)
-{
- return c && c != zeroWidthSpace;
-}
-
-void GraphicsContext::drawText(const Font& font, const TextRun& run, const IntPoint& point, int from, int to)
-{
- if (paintingDisabled() || !fillColor().alpha() || !m_data->m_opacity)
- return;
-
- bool mustSupportAlpha = m_data->hasAlpha();
-
- if (!mustSupportAlpha && fillColor().alpha() == 0xFF && m_data->m_opacity >= 1.0) {
- font.drawText(this, run, point, from, to);
- return;
- }
-
- float oldOpacity = m_data->m_opacity;
- m_data->m_opacity *= fillColor().alpha() / 255.0;
-
- FloatRect textRect = font.selectionRectForText(run, point, font.height(), from, to);
- textRect.setY(textRect.y() - font.ascent());
- IntRect trRect = enclosingIntRect(m_data->mapRect(textRect));
- RECT bmpRect;
- AlphaPaintType alphaPaintType = mustSupportAlpha ? AlphaPaintOther : AlphaPaintNone;
- if (RefPtr<SharedBitmap> bmp = m_data->getTransparentLayerBitmap(trRect, alphaPaintType, bmpRect, true, mustSupportAlpha)) {
- {
- GraphicsContext gc(0);
- gc.setBitmap(bmp);
- gc.scale(FloatSize(m_data->m_transform.a(), m_data->m_transform.d()));
- font.drawText(&gc, run, IntPoint(0, font.ascent()), from, to);
- }
- unsigned key1, key2;
- HDC memDC = bmp->getDC(&key1, &key2);
- if (memDC) {
- m_data->paintBackTransparentLayerBitmap(memDC, bmp.get(), trRect, alphaPaintType, bmpRect);
- bmp->releaseDC(memDC, key1, key2);
- }
- }
-
- m_data->m_opacity = oldOpacity;
-}
-
-void GraphicsContext::drawText(const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point)
-{
- if (!m_data->m_opacity)
- return;
-
- for (;;) {
- if (!numGlyphs)
- return;
- if (isCharVisible(*glyphBuffer.glyphs(from)))
- break;
- ++from;
- --numGlyphs;
- }
-
- double scaleX = m_data->m_transform.a();
- double scaleY = m_data->m_transform.d();
-
- int height = fontData->platformData().size() * scaleY;
- int width = fontData->platformData().averageCharWidth() * scaleX;
-
- if (!height || !width)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- HFONT hFont = height > 1
- ? fontData->platformData().getScaledFontHandle(height, scaleX == scaleY ? 0 : width)
- : 0;
-
- FloatPoint startPoint(point.x(), point.y() - fontData->ascent());
- FloatPoint trPoint = m_data->mapPoint(startPoint);
- int y = stableRound(trPoint.y());
-
- Color color = fillColor();
- if (!color.alpha())
- return;
-
- COLORREF fontColor = RGB(color.red(), color.green(), color.blue());
-
- if (!hFont) {
- double offset = trPoint.x();
- const GlyphBufferAdvance* advance = glyphBuffer.advances(from);
- if (scaleX == 1.)
- for (int i = 1; i < numGlyphs; ++i)
- offset += *advance++;
- else
- for (int i = 1; i < numGlyphs; ++i)
- offset += *advance++ * scaleX;
-
- offset += width;
-
- OwnPtr<HPEN> hPen(CreatePen(PS_DASH, 1, fontColor));
- HGDIOBJ oldPen = SelectObject(m_data->m_dc, hPen.get());
-
- MoveToEx(m_data->m_dc, stableRound(trPoint.x()), y, 0);
- LineTo(m_data->m_dc, stableRound(offset), y);
-
- SelectObject(m_data->m_dc, oldPen);
- return;
- }
-
- FloatSize shadowOffset;
- float shadowBlur = 0;
- Color shadowColor;
- bool hasShadow = textDrawingMode() == cTextFill
- && getShadow(shadowOffset, shadowBlur, shadowColor)
- && shadowColor.alpha();
- COLORREF shadowRGBColor;
- FloatPoint trShadowPoint;
- if (hasShadow) {
- shadowRGBColor = RGB(shadowColor.red(), shadowColor.green(), shadowColor.blue());
- trShadowPoint = m_data->mapPoint(startPoint + shadowOffset);
- }
-
- HGDIOBJ hOldFont = SelectObject(m_data->m_dc, hFont);
- COLORREF oldTextColor = GetTextColor(m_data->m_dc);
- int oldTextAlign = GetTextAlign(m_data->m_dc);
- SetTextAlign(m_data->m_dc, 0);
-
- int oldBkMode = GetBkMode(m_data->m_dc);
- SetBkMode(m_data->m_dc, TRANSPARENT);
-
- if (numGlyphs > 1) {
- double offset = trPoint.x();
- Vector<int, 256> glyphSpace(numGlyphs);
- Vector<UChar, 256> text(numGlyphs);
- int* curSpace = glyphSpace.data();
- UChar* curChar = text.data();
- const UChar* srcChar = glyphBuffer.glyphs(from);
- const UChar* const srcCharEnd = srcChar + numGlyphs;
- *curChar++ = *srcChar++;
- int firstOffset = stableRound(offset);
- int lastOffset = firstOffset;
- const GlyphBufferAdvance* advance = glyphBuffer.advances(from);
- // FIXME: ExtTextOut() can flip over each word for RTL languages, even when TA_RTLREADING is off.
- // (this can be GDI bug or font driver bug?)
- // We are not clear how it processes characters and handles specified spaces. On the other side,
- // our glyph buffer is already in the correct order for rendering. So, the solution is that we
- // call ExtTextOut() for each single character when the text contains any RTL character.
- // This solution is not perfect as it is slower than calling ExtTextOut() one time for all characters.
- // Drawing characters one by one may be too slow.
- bool drawOneByOne = false;
- if (scaleX == 1.) {
- for (; srcChar < srcCharEnd; ++srcChar) {
- offset += *advance++;
- int offsetInt = stableRound(offset);
- if (isCharVisible(*srcChar)) {
- if (!drawOneByOne && WTF::Unicode::direction(*srcChar) == WTF::Unicode::RightToLeft)
- drawOneByOne = true;
- *curChar++ = *srcChar;
- *curSpace++ = offsetInt - lastOffset;
- lastOffset = offsetInt;
- }
- }
- } else {
- for (; srcChar < srcCharEnd; ++srcChar) {
- offset += *advance++ * scaleX;
- int offsetInt = stableRound(offset);
- if (isCharVisible(*srcChar)) {
- if (!drawOneByOne && WTF::Unicode::direction(*srcChar) == WTF::Unicode::RightToLeft)
- drawOneByOne = true;
- *curChar++ = *srcChar;
- *curSpace++ = offsetInt - lastOffset;
- lastOffset = offsetInt;
- }
- }
- }
- numGlyphs = curChar - text.data();
- if (hasShadow) {
- SetTextColor(m_data->m_dc, shadowRGBColor);
- if (drawOneByOne) {
- int xShadow = firstOffset + stableRound(trShadowPoint.x() - trPoint.x());
- int yShadow = stableRound(trShadowPoint.y());
- for (int i = 0; i < numGlyphs; ++i) {
- ExtTextOut(m_data->m_dc, xShadow, yShadow, 0, NULL, text.data() + i, 1, 0);
- xShadow += glyphSpace[i];
- }
- } else
- ExtTextOut(m_data->m_dc, firstOffset + stableRound(trShadowPoint.x() - trPoint.x()), stableRound(trShadowPoint.y()), 0, NULL, text.data(), numGlyphs, glyphSpace.data());
- }
- SetTextColor(m_data->m_dc, fontColor);
- if (drawOneByOne) {
- int x = firstOffset;
- for (int i = 0; i < numGlyphs; ++i) {
- ExtTextOut(m_data->m_dc, x, y, 0, NULL, text.data() + i, 1, 0);
- x += glyphSpace[i];
- }
- } else
- ExtTextOut(m_data->m_dc, firstOffset, y, 0, NULL, text.data(), numGlyphs, glyphSpace.data());
- } else {
- UChar c = *glyphBuffer.glyphs(from);
- if (hasShadow) {
- SetTextColor(m_data->m_dc, shadowRGBColor);
- ExtTextOut(m_data->m_dc, stableRound(trShadowPoint.x()), stableRound(trShadowPoint.y()), 0, NULL, &c, 1, 0);
- }
- SetTextColor(m_data->m_dc, fontColor);
- ExtTextOut(m_data->m_dc, stableRound(trPoint.x()), y, 0, NULL, &c, 1, 0);
- }
-
- SetTextAlign(m_data->m_dc, oldTextAlign);
- SetTextColor(m_data->m_dc, oldTextColor);
- SetBkMode(m_data->m_dc, oldBkMode);
- SelectObject(m_data->m_dc, hOldFont);
-}
-
-void GraphicsContext::drawFrameControl(const IntRect& rect, unsigned type, unsigned state)
-{
- if (!m_data->m_opacity)
- return;
-
- const int boxWidthBest = 8;
- const int boxHeightBest = 8;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
- TransparentLayerDC transparentDC(m_data, trRect, &rect, 255, true);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- RECT rectWin = trRect;
-
- if ((rectWin.right - rectWin.left) < boxWidthBest) {
- RefPtr<SharedBitmap> bmp = SharedBitmap::createInstance(true, boxWidthBest, boxHeightBest, true);
- SharedBitmap::DCHolder memDC(bmp.get());
- if (memDC.get()) {
- RECT tempRect = {0, 0, boxWidthBest, boxHeightBest};
- DrawFrameControl(memDC.get(), &tempRect, type, state);
-
- ::StretchBlt(dc, rectWin.left, rectWin.top, rectWin.right - rectWin.left, rectWin.bottom - rectWin.top, memDC.get(), 0, 0, boxWidthBest, boxHeightBest, SRCCOPY);
- return;
- }
- }
-
- DrawFrameControl(dc, &rectWin, type, state);
-}
-
-void GraphicsContext::drawFocusRect(const IntRect& rect)
-{
- if (!m_data->m_opacity)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
- TransparentLayerDC transparentDC(m_data, trRect, &rect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- RECT rectWin = trRect;
- DrawFocusRect(dc, &rectWin);
-}
-
-void GraphicsContext::paintTextField(const IntRect& rect, unsigned state)
-{
- if (!m_data->m_opacity)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
- TransparentLayerDC transparentDC(m_data, trRect, &rect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- RECT rectWin = trRect;
- DrawEdge(dc, &rectWin, EDGE_ETCHED, BF_RECT | BF_ADJUST);
- FillRect(dc, &rectWin, reinterpret_cast<HBRUSH>(((state & DFCS_INACTIVE) ? COLOR_BTNFACE : COLOR_WINDOW) + 1));
-}
-
-void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
-{
- if (!m_data->m_opacity)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect dstRect = m_data->mapRect(dstRectIn);
- TransparentLayerDC transparentDC(m_data, dstRect, &dstRectIn, 255, true);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- dstRect.move(transparentDC.toShift());
-
- bmp->draw(dc, dstRect, srcRect, compositeOp);
-
- if (bmp->is16bit())
- transparentDC.fillAlphaChannel();
-}
-
-void GraphicsContext::drawBitmapPattern(SharedBitmap* bmp, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRectIn, const IntSize& origSourceSize)
-{
- if (!m_data->m_opacity)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect intDstRect = enclosingIntRect(destRectIn);
- IntRect trRect = m_data->mapRect(intDstRect);
- TransparentLayerDC transparentDC(m_data, trRect, &intDstRect, 255, true);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
- FloatRect movedDstRect = m_data->m_transform.inverse().mapRect(FloatRect(trRect));
- FloatSize moved(movedDstRect.location() - destRectIn.location());
- AffineTransform transform = m_data->m_transform;
- transform.translate(moved.width(), moved.height());
-
- bmp->drawPattern(dc, transform, tileRectIn, patternTransform, phase, styleColorSpace, op, destRectIn, origSourceSize);
-
- if (!bmp->hasAlpha())
- transparentDC.fillAlphaChannel();
-}
-
-void GraphicsContext::drawIcon(HICON icon, const IntRect& dstRectIn, UINT flags)
-{
- if (!m_data->m_opacity)
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect dstRect = m_data->mapRect(dstRectIn);
- TransparentLayerDC transparentDC(m_data, dstRect, &dstRectIn, 255, true);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- dstRect.move(transparentDC.toShift());
-
- DrawIconEx(dc, dstRect.x(), dstRect.y(), icon, dstRect.width(), dstRect.height(), 0, NULL, flags);
-}
-
-void GraphicsContext::setPlatformShouldAntialias(bool)
-{
- notImplemented();
-}
-
-void GraphicsContext::setLineDash(const DashArray&, float)
-{
- notImplemented();
-}
-
-void GraphicsContext::clipPath(WindRule)
-{
- notImplemented();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
new file mode 100644
index 0000000..15720f3
--- /dev/null
+++ b/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
+ * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. 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.
+ */
+
+#include "config.h"
+#include "ImageBuffer.h"
+
+#include "Base64.h"
+#include "GraphicsContext.h"
+#include "Image.h"
+#include "ImageData.h"
+#include "NotImplemented.h"
+#include "SharedBitmap.h"
+#include "UnusedParam.h"
+#include <wtf/UnusedParam.h>
+
+namespace WebCore {
+
+class BufferedImage: public Image {
+
+public:
+ BufferedImage(const ImageBufferData* data)
+ : m_data(data)
+ {
+ }
+
+ virtual IntSize size() const { return IntSize(m_data->m_bitmap->width(), m_data->m_bitmap->height()); }
+ virtual void destroyDecodedData(bool destroyAll = true) {}
+ virtual unsigned decodedSize() const { return 0; }
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
+ virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
+
+ const ImageBufferData* m_data;
+};
+
+void BufferedImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+{
+ IntRect intDstRect = enclosingIntRect(dstRect);
+ IntRect intSrcRect(srcRect);
+ m_data->m_bitmap->draw(ctxt, intDstRect, intSrcRect, styleColorSpace, compositeOp);
+}
+
+void BufferedImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+{
+ m_data->m_bitmap->drawPattern(ctxt, tileRectIn, patternTransform, phase, styleColorSpace, op, destRect, size());
+}
+
+ImageBufferData::ImageBufferData(const IntSize& size)
+: m_bitmap(SharedBitmap::createInstance(false, size.width(), size.height(), false))
+{
+ // http://www.w3.org/TR/2009/WD-html5-20090212/the-canvas-element.html#canvaspixelarray
+ // "When the canvas is initialized it must be set to fully transparent black."
+ m_bitmap->resetPixels(true);
+ m_bitmap->setHasAlpha(true);
+}
+
+ImageBuffer::ImageBuffer(const IntSize& size, ImageColorSpace colorSpace, bool& success)
+ : m_data(size)
+ , m_size(size)
+{
+ // FIXME: colorSpace is not used
+ UNUSED_PARAM(colorSpace);
+
+ m_context.set(new GraphicsContext(0));
+ m_context->setBitmap(m_data.m_bitmap);
+ success = true;
+}
+
+ImageBuffer::~ImageBuffer()
+{
+}
+
+GraphicsContext* ImageBuffer::context() const
+{
+ return m_context.get();
+}
+
+bool ImageBuffer::drawsUsingCopy() const
+{
+ return true;
+}
+
+PassRefPtr<Image> ImageBuffer::copyImage() const
+{
+ return adoptRef(new BufferedImage(&m_data));
+}
+
+void ImageBuffer::clip(GraphicsContext*, const FloatRect&) const
+{
+ notImplemented();
+}
+
+void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
+ CompositeOperator op , bool useLowQualityScale)
+{
+ RefPtr<Image> imageCopy = copyImage();
+ context->drawImage(imageCopy.get(), styleColorSpace, destRect, srcRect, op, useLowQualityScale);
+}
+
+void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+{
+ RefPtr<Image> imageCopy = copyImage();
+ imageCopy->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
+}
+
+template <bool premultiplied> PassRefPtr<ImageData>
+static getImageData(const IntRect& rect, const SharedBitmap* bitmap)
+{
+ PassRefPtr<ImageData> imageData = ImageData::create(rect.width(), rect.height());
+
+ const unsigned char* src = static_cast<const unsigned char*>(bitmap->bytes());
+ if (!src)
+ return imageData;
+
+ IntRect sourceRect(0, 0, bitmap->width(), bitmap->height());
+ sourceRect.intersect(rect);
+ if (sourceRect.isEmpty())
+ return imageData;
+
+ unsigned char* dst = imageData->data()->data()->data();
+ memset(dst, 0, imageData->data()->data()->length());
+ src += (sourceRect.y() * bitmap->width() + sourceRect.x()) * 4;
+ dst += ((sourceRect.y() - rect.y()) * imageData->width() + sourceRect.x() - rect.x()) * 4;
+ int bytesToCopy = sourceRect.width() * 4;
+ int srcSkip = (bitmap->width() - sourceRect.width()) * 4;
+ int dstSkip = (imageData->width() - sourceRect.width()) * 4;
+ const unsigned char* dstEnd = dst + sourceRect.height() * imageData->width() * 4;
+ while (dst < dstEnd) {
+ const unsigned char* dstRowEnd = dst + bytesToCopy;
+ while (dst < dstRowEnd) {
+ // Convert ARGB little endian to RGBA big endian
+ int blue = *src++;
+ int green = *src++;
+ int red = *src++;
+ int alpha = *src++;
+ if (premultiplied) {
+ *dst++ = static_cast<unsigned char>((red * alpha + 254) / 255);
+ *dst++ = static_cast<unsigned char>((green * alpha + 254) / 255);
+ *dst++ = static_cast<unsigned char>((blue * alpha + 254) / 255);
+ *dst++ = static_cast<unsigned char>(alpha);
+ } else {
+ *dst++ = static_cast<unsigned char>(red);
+ *dst++ = static_cast<unsigned char>(green);
+ *dst++ = static_cast<unsigned char>(blue);
+ *dst++ = static_cast<unsigned char>(alpha);
+ ++src;
+ }
+ }
+ src += srcSkip;
+ dst += dstSkip;
+ }
+
+ return imageData;
+}
+
+PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
+{
+ return getImageData<false>(rect, m_data.m_bitmap.get());
+}
+
+PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
+{
+ return getImageData<true>(rect, m_data.m_bitmap.get());
+}
+
+template <bool premultiplied>
+static void putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint, SharedBitmap* bitmap)
+{
+ unsigned char* dst = (unsigned char*)bitmap->bytes();
+ if (!dst)
+ return;
+
+ IntRect destRect(destPoint, sourceRect.size());
+ destRect.intersect(IntRect(0, 0, bitmap->width(), bitmap->height()));
+
+ if (destRect.isEmpty())
+ return;
+
+ const unsigned char* src = source->data()->data()->data();
+ dst += (destRect.y() * bitmap->width() + destRect.x()) * 4;
+ src += (sourceRect.y() * source->width() + sourceRect.x()) * 4;
+ int bytesToCopy = destRect.width() * 4;
+ int dstSkip = (bitmap->width() - destRect.width()) * 4;
+ int srcSkip = (source->width() - destRect.width()) * 4;
+ const unsigned char* dstEnd = dst + destRect.height() * bitmap->width() * 4;
+ while (dst < dstEnd) {
+ const unsigned char* dstRowEnd = dst + bytesToCopy;
+ while (dst < dstRowEnd) {
+ // Convert RGBA big endian to ARGB little endian
+ int red = *src++;
+ int green = *src++;
+ int blue = *src++;
+ int alpha = *src++;
+ if (premultiplied) {
+ *dst++ = static_cast<unsigned char>(blue * 255 / alpha);
+ *dst++ = static_cast<unsigned char>(green * 255 / alpha);
+ *dst++ = static_cast<unsigned char>(red * 255 / alpha);
+ *dst++ = static_cast<unsigned char>(alpha);
+ } else {
+ *dst++ = static_cast<unsigned char>(blue);
+ *dst++ = static_cast<unsigned char>(green);
+ *dst++ = static_cast<unsigned char>(red);
+ *dst++ = static_cast<unsigned char>(alpha);
+ }
+ }
+ src += srcSkip;
+ dst += dstSkip;
+ }
+}
+
+void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+{
+ putImageData<false>(source, sourceRect, destPoint, m_data.m_bitmap.get());
+}
+
+void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+{
+ putImageData<true>(source, sourceRect, destPoint, m_data.m_bitmap.get());
+}
+
+void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
+{
+ UNUSED_PARAM(lookUpTable);
+ notImplemented();
+}
+
+String ImageBuffer::toDataURL(const String& mimeType, const double*) const
+{
+ if (!m_data.m_bitmap->bytes())
+ return "data:,";
+
+ notImplemented();
+ return String();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/ImageBufferWince.cpp b/WebCore/platform/graphics/wince/ImageBufferWince.cpp
deleted file mode 100644
index 1843a56..0000000
--- a/WebCore/platform/graphics/wince/ImageBufferWince.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
- * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. 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.
- */
-
-#include "config.h"
-#include "ImageBuffer.h"
-
-#include "Base64.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-#include "ImageData.h"
-#include "NotImplemented.h"
-#include "SharedBitmap.h"
-#include "UnusedParam.h"
-#include <wtf/UnusedParam.h>
-
-namespace WebCore {
-
-class BufferedImage: public Image {
-
-public:
- BufferedImage(const ImageBufferData* data)
- : m_data(data)
- {
- }
-
- virtual IntSize size() const { return IntSize(m_data->m_bitmap->width(), m_data->m_bitmap->height()); }
- virtual void destroyDecodedData(bool destroyAll = true) {}
- virtual unsigned decodedSize() const { return 0; }
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
- virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
-
- const ImageBufferData* m_data;
-};
-
-void BufferedImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
-{
- IntRect intDstRect = enclosingIntRect(dstRect);
- IntRect intSrcRect(srcRect);
- m_data->m_bitmap->draw(ctxt, intDstRect, intSrcRect, styleColorSpace, compositeOp);
-}
-
-void BufferedImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
-{
- m_data->m_bitmap->drawPattern(ctxt, tileRectIn, patternTransform, phase, styleColorSpace, op, destRect, size());
-}
-
-ImageBufferData::ImageBufferData(const IntSize& size)
-: m_bitmap(SharedBitmap::createInstance(false, size.width(), size.height(), false))
-{
- // http://www.w3.org/TR/2009/WD-html5-20090212/the-canvas-element.html#canvaspixelarray
- // "When the canvas is initialized it must be set to fully transparent black."
- m_bitmap->resetPixels(true);
- m_bitmap->setHasAlpha(true);
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, ImageColorSpace colorSpace, bool& success)
- : m_data(size)
- , m_size(size)
-{
- // FIXME: colorSpace is not used
- UNUSED_PARAM(colorSpace);
-
- m_context.set(new GraphicsContext(0));
- m_context->setBitmap(m_data.m_bitmap);
- success = true;
-}
-
-ImageBuffer::~ImageBuffer()
-{
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- return m_context.get();
-}
-
-bool ImageBuffer::drawsUsingCopy() const
-{
- return true;
-}
-
-PassRefPtr<Image> ImageBuffer::copyImage() const
-{
- return adoptRef(new BufferedImage(&m_data));
-}
-
-void ImageBuffer::clip(GraphicsContext*, const FloatRect&) const
-{
- notImplemented();
-}
-
-void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
- CompositeOperator op , bool useLowQualityScale)
-{
- RefPtr<Image> imageCopy = copyImage();
- context->drawImage(imageCopy.get(), styleColorSpace, destRect, srcRect, op, useLowQualityScale);
-}
-
-void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
-{
- RefPtr<Image> imageCopy = copyImage();
- imageCopy->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
-}
-
-template <bool premultiplied> PassRefPtr<ImageData>
-static getImageData(const IntRect& rect, const SharedBitmap* bitmap)
-{
- PassRefPtr<ImageData> imageData = ImageData::create(rect.width(), rect.height());
-
- const unsigned char* src = static_cast<const unsigned char*>(bitmap->bytes());
- if (!src)
- return imageData;
-
- IntRect sourceRect(0, 0, bitmap->width(), bitmap->height());
- sourceRect.intersect(rect);
- if (sourceRect.isEmpty())
- return imageData;
-
- unsigned char* dst = imageData->data()->data()->data();
- memset(dst, 0, imageData->data()->data()->length());
- src += (sourceRect.y() * bitmap->width() + sourceRect.x()) * 4;
- dst += ((sourceRect.y() - rect.y()) * imageData->width() + sourceRect.x() - rect.x()) * 4;
- int bytesToCopy = sourceRect.width() * 4;
- int srcSkip = (bitmap->width() - sourceRect.width()) * 4;
- int dstSkip = (imageData->width() - sourceRect.width()) * 4;
- const unsigned char* dstEnd = dst + sourceRect.height() * imageData->width() * 4;
- while (dst < dstEnd) {
- const unsigned char* dstRowEnd = dst + bytesToCopy;
- while (dst < dstRowEnd) {
- // Convert ARGB little endian to RGBA big endian
- int blue = *src++;
- int green = *src++;
- int red = *src++;
- int alpha = *src++;
- if (premultiplied) {
- *dst++ = static_cast<unsigned char>((red * alpha + 254) / 255);
- *dst++ = static_cast<unsigned char>((green * alpha + 254) / 255);
- *dst++ = static_cast<unsigned char>((blue * alpha + 254) / 255);
- *dst++ = static_cast<unsigned char>(alpha);
- } else {
- *dst++ = static_cast<unsigned char>(red);
- *dst++ = static_cast<unsigned char>(green);
- *dst++ = static_cast<unsigned char>(blue);
- *dst++ = static_cast<unsigned char>(alpha);
- ++src;
- }
- }
- src += srcSkip;
- dst += dstSkip;
- }
-
- return imageData;
-}
-
-PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
-{
- return getImageData<false>(rect, m_data.m_bitmap.get());
-}
-
-PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
-{
- return getImageData<true>(rect, m_data.m_bitmap.get());
-}
-
-template <bool premultiplied>
-static void putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint, SharedBitmap* bitmap)
-{
- unsigned char* dst = (unsigned char*)bitmap->bytes();
- if (!dst)
- return;
-
- IntRect destRect(destPoint, sourceRect.size());
- destRect.intersect(IntRect(0, 0, bitmap->width(), bitmap->height()));
-
- if (destRect.isEmpty())
- return;
-
- const unsigned char* src = source->data()->data()->data();
- dst += (destRect.y() * bitmap->width() + destRect.x()) * 4;
- src += (sourceRect.y() * source->width() + sourceRect.x()) * 4;
- int bytesToCopy = destRect.width() * 4;
- int dstSkip = (bitmap->width() - destRect.width()) * 4;
- int srcSkip = (source->width() - destRect.width()) * 4;
- const unsigned char* dstEnd = dst + destRect.height() * bitmap->width() * 4;
- while (dst < dstEnd) {
- const unsigned char* dstRowEnd = dst + bytesToCopy;
- while (dst < dstRowEnd) {
- // Convert RGBA big endian to ARGB little endian
- int red = *src++;
- int green = *src++;
- int blue = *src++;
- int alpha = *src++;
- if (premultiplied) {
- *dst++ = static_cast<unsigned char>(blue * 255 / alpha);
- *dst++ = static_cast<unsigned char>(green * 255 / alpha);
- *dst++ = static_cast<unsigned char>(red * 255 / alpha);
- *dst++ = static_cast<unsigned char>(alpha);
- } else {
- *dst++ = static_cast<unsigned char>(blue);
- *dst++ = static_cast<unsigned char>(green);
- *dst++ = static_cast<unsigned char>(red);
- *dst++ = static_cast<unsigned char>(alpha);
- }
- }
- src += srcSkip;
- dst += dstSkip;
- }
-}
-
-void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
-{
- putImageData<false>(source, sourceRect, destPoint, m_data.m_bitmap.get());
-}
-
-void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
-{
- putImageData<true>(source, sourceRect, destPoint, m_data.m_bitmap.get());
-}
-
-void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
-{
- UNUSED_PARAM(lookUpTable);
- notImplemented();
-}
-
-String ImageBuffer::toDataURL(const String& mimeType, const double*) const
-{
- if (!m_data.m_bitmap->bytes())
- return "data:,";
-
- notImplemented();
- return String();
-}
-
-}
diff --git a/WebCore/platform/graphics/wince/MediaPlayerPrivateWinCE.h b/WebCore/platform/graphics/wince/MediaPlayerPrivateWinCE.h
new file mode 100644
index 0000000..f49d8e2
--- /dev/null
+++ b/WebCore/platform/graphics/wince/MediaPlayerPrivateWinCE.h
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Torch Mobile 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 MediaPlayerPrivateWinCE_h
+#define MediaPlayerPrivateWinCE_h
+
+#if ENABLE(VIDEO)
+
+#include <wtf/Forward.h>
+#include "MediaPlayerPrivate.h"
+#include "Timer.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+ class GraphicsContext;
+ class IntSize;
+ class IntRect;
+
+ class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
+ public:
+ static void registerMediaEngine(MediaEngineRegistrar);
+
+ ~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 setRate(float);
+ void setVolume(float);
+
+ MediaPlayer::NetworkState networkState() const { return m_networkState; }
+ MediaPlayer::ReadyState readyState() const { return m_readyState; }
+
+ PassRefPtr<TimeRanges> buffered() const;
+ float maxTimeSeekable() const;
+ unsigned bytesLoaded() const;
+ unsigned totalBytes() const;
+
+ void setVisible(bool);
+ void setSize(const IntSize&);
+
+ void loadStateChanged();
+ void didEnd();
+
+ void paint(GraphicsContext*, const IntRect&);
+
+ private:
+ MediaPlayerPrivate(MediaPlayer*);
+
+ void updateStates();
+ void doSeek();
+ void cancelSeek();
+ void seekTimerFired(Timer<MediaPlayerPrivate>*);
+ float maxTimeLoaded() const;
+ void sawUnsupportedTracks();
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+ void setMediaPlayerProxy(WebMediaPlayerProxy*);
+ void setPoster(const String& url);
+ void deliverNotification(MediaPlayerProxyNotificationType);
+#endif
+
+ // engine support
+ static MediaPlayerPrivateInterface* create(MediaPlayer*);
+ static void getSupportedTypes(HashSet<String>& types);
+ static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
+ static bool isAvailable();
+
+ MediaPlayer* m_player;
+ float m_seekTo;
+ float m_endTime;
+ Timer<MediaPlayerPrivate> m_seekTimer;
+ MediaPlayer::NetworkState m_networkState;
+ MediaPlayer::ReadyState m_readyState;
+ unsigned m_enabledTrackCount;
+ unsigned m_totalTrackCount;
+ bool m_hasUnsupportedTracks;
+ bool m_startedPlaying;
+ bool m_isStreaming;
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+ WebMediaPlayerProxy* m_proxy;
+#endif
+ };
+
+}
+
+#endif // ENABLE(VIDEO)
+
+#endif // MediaPlayerPrivateWinCE_h
diff --git a/WebCore/platform/graphics/wince/MediaPlayerPrivateWince.h b/WebCore/platform/graphics/wince/MediaPlayerPrivateWince.h
deleted file mode 100644
index e86b8a9..0000000
--- a/WebCore/platform/graphics/wince/MediaPlayerPrivateWince.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Torch Mobile 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 MediaPlayerPrivateWince_h
-#define MediaPlayerPrivateWince_h
-
-#if ENABLE(VIDEO)
-
-#include <wtf/Forward.h>
-#include "MediaPlayerPrivate.h"
-#include "Timer.h"
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
- class GraphicsContext;
- class IntSize;
- class IntRect;
-
- class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
- public:
- static void registerMediaEngine(MediaEngineRegistrar);
-
- ~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 setRate(float);
- void setVolume(float);
-
- MediaPlayer::NetworkState networkState() const { return m_networkState; }
- MediaPlayer::ReadyState readyState() const { return m_readyState; }
-
- PassRefPtr<TimeRanges> buffered() const;
- float maxTimeSeekable() const;
- unsigned bytesLoaded() const;
- unsigned totalBytes() const;
-
- void setVisible(bool);
- void setSize(const IntSize&);
-
- void loadStateChanged();
- void didEnd();
-
- void paint(GraphicsContext*, const IntRect&);
-
- private:
- MediaPlayerPrivate(MediaPlayer*);
-
- void updateStates();
- void doSeek();
- void cancelSeek();
- void seekTimerFired(Timer<MediaPlayerPrivate>*);
- float maxTimeLoaded() const;
- void sawUnsupportedTracks();
-#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
- void setMediaPlayerProxy(WebMediaPlayerProxy*);
- void setPoster(const String& url);
- void deliverNotification(MediaPlayerProxyNotificationType);
-#endif
-
- // engine support
- static MediaPlayerPrivateInterface* create(MediaPlayer*);
- static void getSupportedTypes(HashSet<String>& types);
- static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
- static bool isAvailable();
-
- MediaPlayer* m_player;
- float m_seekTo;
- float m_endTime;
- Timer<MediaPlayerPrivate> m_seekTimer;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
- unsigned m_enabledTrackCount;
- unsigned m_totalTrackCount;
- bool m_hasUnsupportedTracks;
- bool m_startedPlaying;
- bool m_isStreaming;
-#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
- WebMediaPlayerProxy* m_proxy;
-#endif
- };
-
-}
-
-#endif
-
-#endif
diff --git a/WebCore/platform/graphics/wince/PathWinCE.cpp b/WebCore/platform/graphics/wince/PathWinCE.cpp
new file mode 100644
index 0000000..4f0195c
--- /dev/null
+++ b/WebCore/platform/graphics/wince/PathWinCE.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2007-2009 Torch Mobile, 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 "Path.h"
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "NotImplemented.h"
+#include "PlatformPathWinCE.h"
+#include "PlatformString.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+Path::Path()
+ : m_path(new PlatformPath())
+{
+}
+
+Path::Path(const Path& other)
+ : m_path(new PlatformPath(*other.m_path))
+{
+}
+
+Path::~Path()
+{
+ delete m_path;
+}
+
+Path& Path::operator=(const Path& other)
+{
+ if (&other != this) {
+ delete m_path;
+ m_path = new PlatformPath(*other.m_path);
+ }
+ return *this;
+}
+
+bool Path::contains(const FloatPoint& point, WindRule rule) const
+{
+ return m_path->contains(point, rule);
+}
+
+void Path::translate(const FloatSize& size)
+{
+ m_path->translate(size);
+}
+
+FloatRect Path::boundingRect() const
+{
+ return m_path->boundingRect();
+}
+
+void Path::moveTo(const FloatPoint& point)
+{
+ m_path->moveTo(point);
+}
+
+void Path::addLineTo(const FloatPoint& point)
+{
+ m_path->addLineTo(point);
+}
+
+void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
+{
+ m_path->addQuadCurveTo(cp, p);
+}
+
+void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
+{
+ m_path->addBezierCurveTo(cp1, cp2, p);
+}
+
+void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
+{
+ m_path->addArcTo(p1, p2, radius);
+}
+
+void Path::closeSubpath()
+{
+ m_path->closeSubpath();
+}
+
+void Path::addArc(const FloatPoint& p, float r, float sar, float ear, bool anticlockwise)
+{
+ m_path->addEllipse(p, r, r, sar, ear, anticlockwise);
+}
+
+void Path::addRect(const FloatRect& r)
+{
+ m_path->addRect(r);
+}
+
+void Path::addEllipse(const FloatRect& r)
+{
+ m_path->addEllipse(r);
+}
+
+void Path::clear()
+{
+ m_path->clear();
+}
+
+bool Path::isEmpty() const
+{
+ return m_path->isEmpty();
+}
+
+String Path::debugString() const
+{
+ return m_path->debugString();
+}
+
+void Path::apply(void* info, PathApplierFunction function) const
+{
+ m_path->apply(info, function);
+}
+
+void Path::transform(const AffineTransform& t)
+{
+ m_path->transform(t);
+}
+
+FloatRect Path::strokeBoundingRect(StrokeStyleApplier *)
+{
+ notImplemented();
+ return FloatRect();
+}
+
+bool Path::strokeContains(StrokeStyleApplier*, const FloatPoint&) const
+{
+ notImplemented();
+ return false;
+}
+
+bool Path::hasCurrentPoint() const
+{
+ // Not sure if this is correct. At the meantime, we do what other ports
+ // do.
+ // See https://bugs.webkit.org/show_bug.cgi?id=27266,
+ // https://bugs.webkit.org/show_bug.cgi?id=27187, and
+ // http://trac.webkit.org/changeset/45873
+ return !isEmpty();
+}
+
+FloatPoint Path::currentPoint() const
+{
+ return m_path->lastPoint();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/PathWince.cpp b/WebCore/platform/graphics/wince/PathWince.cpp
deleted file mode 100644
index 6aa2864..0000000
--- a/WebCore/platform/graphics/wince/PathWince.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Torch Mobile, 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 "Path.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "NotImplemented.h"
-#include "PlatformPathWince.h"
-#include "PlatformString.h"
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-Path::Path()
- : m_path(new PlatformPath())
-{
-}
-
-Path::Path(const Path& other)
- : m_path(new PlatformPath(*other.m_path))
-{
-}
-
-Path::~Path()
-{
- delete m_path;
-}
-
-Path& Path::operator=(const Path& other)
-{
- if (&other != this) {
- delete m_path;
- m_path = new PlatformPath(*other.m_path);
- }
- return *this;
-}
-
-bool Path::contains(const FloatPoint& point, WindRule rule) const
-{
- return m_path->contains(point, rule);
-}
-
-void Path::translate(const FloatSize& size)
-{
- m_path->translate(size);
-}
-
-FloatRect Path::boundingRect() const
-{
- return m_path->boundingRect();
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
- m_path->moveTo(point);
-}
-
-void Path::addLineTo(const FloatPoint& point)
-{
- m_path->addLineTo(point);
-}
-
-void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
-{
- m_path->addQuadCurveTo(cp, p);
-}
-
-void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
-{
- m_path->addBezierCurveTo(cp1, cp2, p);
-}
-
-void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
-{
- m_path->addArcTo(p1, p2, radius);
-}
-
-void Path::closeSubpath()
-{
- m_path->closeSubpath();
-}
-
-void Path::addArc(const FloatPoint& p, float r, float sar, float ear, bool anticlockwise)
-{
- m_path->addEllipse(p, r, r, sar, ear, anticlockwise);
-}
-
-void Path::addRect(const FloatRect& r)
-{
- m_path->addRect(r);
-}
-
-void Path::addEllipse(const FloatRect& r)
-{
- m_path->addEllipse(r);
-}
-
-void Path::clear()
-{
- m_path->clear();
-}
-
-bool Path::isEmpty() const
-{
- return m_path->isEmpty();
-}
-
-String Path::debugString() const
-{
- return m_path->debugString();
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- m_path->apply(info, function);
-}
-
-void Path::transform(const AffineTransform& t)
-{
- m_path->transform(t);
-}
-
-FloatRect Path::strokeBoundingRect(StrokeStyleApplier *)
-{
- notImplemented();
- return FloatRect();
-}
-
-bool Path::strokeContains(StrokeStyleApplier*, const FloatPoint&) const
-{
- notImplemented();
- return false;
-}
-
-bool Path::hasCurrentPoint() const
-{
- // Not sure if this is correct. At the meantime, we do what other ports
- // do.
- // See https://bugs.webkit.org/show_bug.cgi?id=27266,
- // https://bugs.webkit.org/show_bug.cgi?id=27187, and
- // http://trac.webkit.org/changeset/45873
- return !isEmpty();
-}
-
-FloatPoint Path::currentPoint() const
-{
- return m_path->lastPoint();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/PlatformPathWinCE.cpp b/WebCore/platform/graphics/wince/PlatformPathWinCE.cpp
new file mode 100644
index 0000000..4072a18
--- /dev/null
+++ b/WebCore/platform/graphics/wince/PlatformPathWinCE.cpp
@@ -0,0 +1,810 @@
+/*
+ * Copyright (C) 2007-2009 Torch Mobile, 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 "PlatformPathWinCE.h"
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "GraphicsContext.h"
+#include "Path.h"
+#include "PlatformString.h"
+#include "WinCEGraphicsExtras.h"
+#include <wtf/MathExtras.h>
+#include <wtf/OwnPtr.h>
+
+#include <windows.h>
+
+namespace WebCore {
+
+// Implemented in GraphicsContextWinCE.cpp
+void getEllipsePointByAngle(double angle, double a, double b, float& x, float& y);
+
+static void quadCurve(int segments, Vector<PathPoint>& pts, const PathPoint* control)
+{
+ const float step = 1.0 / segments;
+ register float tA = 0.0;
+ register float tB = 1.0;
+
+ float c1x = control[0].x();
+ float c1y = control[0].y();
+ float c2x = control[1].x();
+ float c2y = control[1].y();
+ float c3x = control[2].x();
+ float c3y = control[2].y();
+
+ const int offset = pts.size();
+ pts.resize(offset + segments);
+ PathPoint pp;
+ pp.m_x = c1x;
+ pp.m_y = c1y;
+
+ for (int i = 1; i < segments; ++i) {
+ tA += step;
+ tB -= step;
+
+ const float a = tB * tB;
+ const float b = 2.0 * tA * tB;
+ const float c = tA * tA;
+
+ pp.m_x = c1x * a + c2x * b + c3x * c;
+ pp.m_y = c1y * a + c2y * b + c3y * c;
+
+ pts[offset + i - 1] = pp;
+ }
+
+ pp.m_x = c3x;
+ pp.m_y = c3y;
+ pts[offset + segments - 1] = pp;
+}
+
+static inline void bezier(int segments, Vector<PathPoint>& pts, const PathPoint* control)
+{
+ const float step = 1.0 / segments;
+ register float tA = 0.0;
+ register float tB = 1.0;
+
+ float c1x = control[0].x();
+ float c1y = control[0].y();
+ float c2x = control[1].x();
+ float c2y = control[1].y();
+ float c3x = control[2].x();
+ float c3y = control[2].y();
+ float c4x = control[3].x();
+ float c4y = control[3].y();
+
+ const int offset = pts.size();
+ pts.resize(offset + segments);
+ PathPoint pp;
+ pp.m_x = c1x;
+ pp.m_y = c1y;
+
+ for (int i = 1; i < segments; ++i) {
+ tA += step;
+ tB -= step;
+ const float tAsq = tA * tA;
+ const float tBsq = tB * tB;
+
+ const float a = tBsq * tB;
+ const float b = 3.0 * tA * tBsq;
+ const float c = 3.0 * tB * tAsq;
+ const float d = tAsq * tA;
+
+ pp.m_x = c1x * a + c2x * b + c3x * c + c4x * d;
+ pp.m_y = c1y * a + c2y * b + c3y * c + c4y * d;
+
+ pts[offset + i - 1] = pp;
+ }
+
+ pp.m_x = c4x;
+ pp.m_y = c4y;
+ pts[offset + segments - 1] = pp;
+}
+
+static bool containsPoint(const FloatRect& r, const FloatPoint& p)
+{
+ return p.x() >= r.x() && p.y() >= r.y() && p.x() < r.right() && p.y() < r.bottom();
+}
+
+static void normalizeAngle(float& angle)
+{
+ angle = fmod(angle, 2 * piFloat);
+ if (angle < 0)
+ angle += 2 * piFloat;
+ if (angle < 0.00001f)
+ angle = 0;
+}
+
+static void transformArcPoint(float& x, float& y, const FloatPoint& c)
+{
+ x += c.x();
+ y += c.y();
+}
+
+static void inflateRectToContainPoint(FloatRect& r, float x, float y)
+{
+ if (r.isEmpty()) {
+ r.setX(x);
+ r.setY(y);
+ r.setSize(FloatSize(1, 1));
+ return;
+ }
+ if (x < r.x()) {
+ r.setWidth(r.right() - x);
+ r.setX(x);
+ } else {
+ float w = x - r.x() + 1;
+ if (w > r.width())
+ r.setWidth(w);
+ }
+ if (y < r.y()) {
+ r.setHeight(r.bottom() - y);
+ r.setY(y);
+ } else {
+ float h = y - r.y() + 1;
+ if (h > r.height())
+ r.setHeight(h);
+ }
+}
+
+// return 0-based value: 0 - first Quadrant ( 0 - 90 degree)
+static inline int quadrant(const PathPoint& point, const PathPoint& origin)
+{
+ return point.m_x < origin.m_x ?
+ (point.m_y < origin.m_y ? 2 : 1)
+ : (point.m_y < origin.m_y ? 3 : 0);
+}
+
+static inline bool isQuadrantOnLeft(int q) { return q == 1 || q == 2; }
+static inline bool isQuadrantOnRight(int q) { return q == 0 || q == 3; }
+static inline bool isQuadrantOnTop(int q) { return q == 2 || q == 3; }
+static inline bool isQuadrantOnBottom(int q) { return q == 0 || q == 1; }
+
+static inline int nextQuadrant(int q) { return q == 3 ? 0 : q + 1; }
+static inline int quadrantDiff(int q1, int q2)
+{
+ int d = q1 - q2;
+ while (d < 0)
+ d += 4;
+ return d;
+}
+
+struct PathVector {
+ float m_x;
+ float m_y;
+
+ PathVector() : m_x(0), m_y(0) {}
+ PathVector(float x, float y) : m_x(x), m_y(y) {}
+ double angle() const { return atan2(m_y, m_x); }
+ operator double () const { return angle(); }
+ double length() const { return _hypot(m_x, m_y); }
+};
+
+PathVector operator-(const PathPoint& p1, const PathPoint& p2)
+{
+ return PathVector(p1.m_x - p2.m_x, p1.m_y - p2.m_y);
+}
+
+static void addArcPoint(PathPolygon& poly, const PathPoint& center, const PathPoint& radius, double angle)
+{
+ PathPoint p;
+ getEllipsePointByAngle(angle, radius.m_x, radius.m_y, p.m_x, p.m_y);
+ transformArcPoint(p.m_x, p.m_y, center);
+ if (poly.isEmpty() || poly.last() != p)
+ poly.append(p);
+}
+
+static void addArcPoints(PathPolygon& poly, const PlatformPathElement::ArcTo& data)
+{
+ const PathPoint& startPoint = poly.last();
+ double curAngle = startPoint - data.m_center;
+ double endAngle = data.m_end - data.m_center;
+ double angleStep = 2. / std::max(data.m_radius.m_x, data.m_radius.m_y);
+ if (data.m_clockwise) {
+ if (endAngle <= curAngle || startPoint == data.m_end)
+ endAngle += 2 * piDouble;
+ } else {
+ angleStep = -angleStep;
+ if (endAngle >= curAngle || startPoint == data.m_end)
+ endAngle -= 2 * piDouble;
+ }
+
+ for (curAngle += angleStep; data.m_clockwise ? curAngle < endAngle : curAngle > endAngle; curAngle += angleStep)
+ addArcPoint(poly, data.m_center, data.m_radius, curAngle);
+
+ if (poly.isEmpty() || poly.last() != data.m_end)
+ poly.append(data.m_end);
+}
+
+static void drawPolygons(HDC dc, const Vector<PathPolygon>& polygons, bool fill, const AffineTransform* transformation)
+{
+ MemoryAllocationCanFail canFail;
+ for (Vector<PathPolygon>::const_iterator i = polygons.begin(); i != polygons.end(); ++i) {
+ int npoints = i->size();
+ if (!npoints)
+ continue;
+
+ POINT* winPoints = 0;
+ if (fill) {
+ if (npoints > 2)
+ winPoints = new POINT[npoints + 1];
+ } else
+ winPoints = new POINT[npoints];
+
+ if (winPoints) {
+ if (transformation) {
+ for (int i2 = 0; i2 < npoints; ++i2) {
+ FloatPoint trPoint = transformation->mapPoint(i->at(i2));
+ winPoints[i2].x = stableRound(trPoint.x());
+ winPoints[i2].y = stableRound(trPoint.y());
+ }
+ } else {
+ for (int i2 = 0; i2 < npoints; ++i2) {
+ winPoints[i2].x = stableRound(i->at(i2).x());
+ winPoints[i2].y = stableRound(i->at(i2).y());
+ }
+ }
+
+ if (fill && winPoints[npoints - 1] != winPoints[0]) {
+ winPoints[npoints].x = winPoints[0].x;
+ winPoints[npoints].y = winPoints[0].y;
+ ++npoints;
+ }
+
+ if (fill)
+ ::Polygon(dc, winPoints, npoints);
+ else
+ ::Polyline(dc, winPoints, npoints);
+ delete[] winPoints;
+ }
+ }
+}
+
+
+int PlatformPathElement::numControlPoints() const
+{
+ switch (m_type) {
+ case PathMoveTo:
+ case PathLineTo:
+ return 1;
+ case PathQuadCurveTo:
+ case PathArcTo:
+ return 2;
+ case PathBezierCurveTo:
+ return 3;
+ default:
+ ASSERT(m_type == PathCloseSubpath);
+ return 0;
+ }
+}
+
+int PlatformPathElement::numPoints() const
+{
+ switch (m_type) {
+ case PathMoveTo:
+ case PathLineTo:
+ case PathArcTo:
+ return 1;
+ case PathQuadCurveTo:
+ return 2;
+ case PathBezierCurveTo:
+ return 3;
+ default:
+ ASSERT(m_type == PathCloseSubpath);
+ return 0;
+ }
+}
+
+void PathPolygon::move(const FloatSize& offset)
+{
+ for (Vector<PathPoint>::iterator i = begin(); i < end(); ++i)
+ i->move(offset);
+}
+
+void PathPolygon::transform(const AffineTransform& t)
+{
+ for (Vector<PathPoint>::iterator i = begin(); i < end(); ++i)
+ *i = t.mapPoint(*i);
+}
+
+bool PathPolygon::contains(const FloatPoint& point) const
+{
+ if (size() < 3)
+ return false;
+
+ // Test intersections between the polygon and the vertical line: x = point.x()
+
+ int intersected = 0;
+ const PathPoint* point1 = &last();
+ Vector<PathPoint>::const_iterator last = end();
+ // wasNegative: -1 means unknown, 0 means false, 1 means true.
+ int wasNegative = -1;
+ for (Vector<PathPoint>::const_iterator i = begin(); i != last; ++i) {
+ const PathPoint& point2 = *i;
+ if (point1->x() != point.x()) {
+ if (point2.x() == point.x()) {
+ // We are getting on the vertical line
+ wasNegative = point1->x() < point.x() ? 1 : 0;
+ } else if (point2.x() < point.x() != point1->x() < point.x()) {
+ float y = (point2.y() - point1->y()) / (point2.x() - point1->x()) * (point.x() - point1->x()) + point1->y();
+ if (y >= point.y())
+ ++intersected;
+ }
+ } else {
+ // We were on the vertical line
+
+ // handle special case
+ if (point1->y() == point.y())
+ return true;
+
+ if (point1->y() > point.y()) {
+ if (point2.x() == point.x()) {
+ // see if the point is on this segment
+ if (point2.y() <= point.y())
+ return true;
+
+ // We are still on the line
+ } else {
+ // We are leaving the line now.
+ // We have to get back to see which side we come from. If we come from
+ // the same side we are leaving, no intersection should be counted
+ if (wasNegative < 0) {
+ Vector<PathPoint>::const_iterator jLast = i;
+ Vector<PathPoint>::const_iterator j = i;
+ do {
+ if (j == begin())
+ j = last;
+ else
+ --j;
+ if (j->x() != point.x()) {
+ if (j->x() > point.x())
+ wasNegative = 0;
+ else
+ wasNegative = 1;
+ break;
+ }
+ } while (j != jLast);
+
+ if (wasNegative < 0)
+ return false;
+ }
+ if (wasNegative ? point2.x() > point.x() : point2.x() < point.x())
+ ++intersected;
+ }
+ } else if (point2.x() == point.x() && point2.y() >= point.y())
+ return true;
+ }
+ point1 = &point2;
+ }
+
+ return intersected & 1;
+}
+
+void PlatformPathElement::move(const FloatSize& offset)
+{
+ int n = numControlPoints();
+ for (int i = 0; i < n; ++i)
+ m_data.m_points[i].move(offset);
+}
+
+void PlatformPathElement::transform(const AffineTransform& t)
+{
+ int n = numControlPoints();
+ for (int i = 0; i < n; ++i) {
+ FloatPoint p = t.mapPoint(m_data.m_points[i]);
+ m_data.m_points[i].set(p.x(), p.y());
+ }
+}
+
+void PlatformPathElement::inflateRectToContainMe(FloatRect& r, const FloatPoint& lastPoint) const
+{
+ if (m_type == PathArcTo) {
+ const ArcTo& data = m_data.m_arcToData;
+ PathPoint startPoint;
+ startPoint = lastPoint;
+ PathPoint endPoint = data.m_end;
+ if (!data.m_clockwise)
+ std::swap(startPoint, endPoint);
+
+ int q0 = quadrant(startPoint, data.m_center);
+ int q1 = quadrant(endPoint, data.m_center);
+ bool containsExtremes[4] = { false }; // bottom, left, top, right
+ static const PathPoint extremeVectors[4] = { { 0, 1 }, { -1, 0 }, { 0, -1 }, { 1, 0 } };
+ if (q0 == q1) {
+ if (startPoint.m_x == endPoint.m_x || isQuadrantOnBottom(q0) != startPoint.m_x > endPoint.m_x) {
+ for (int i = 0; i < 4; ++i)
+ containsExtremes[i] = true;
+ }
+ } else {
+ int extreme = q0;
+ int diff = quadrantDiff(q1, q0);
+ for (int i = 0; i < diff; ++i) {
+ containsExtremes[extreme] = true;
+ extreme = nextQuadrant(extreme);
+ }
+ }
+
+ inflateRectToContainPoint(r, startPoint.m_x, startPoint.m_y);
+ inflateRectToContainPoint(r, endPoint.m_x, endPoint.m_y);
+ for (int i = 0; i < 4; ++i) {
+ if (containsExtremes[i])
+ inflateRectToContainPoint(r, data.m_center.m_x + data.m_radius.m_x * extremeVectors[i].m_x, data.m_center.m_y + data.m_radius.m_y * extremeVectors[i].m_y);
+ }
+ } else {
+ int n = numPoints();
+ for (int i = 0; i < n; ++i)
+ inflateRectToContainPoint(r, m_data.m_points[i].m_x, m_data.m_points[i].m_y);
+ }
+}
+
+PathElementType PlatformPathElement::type() const
+{
+ switch (m_type) {
+ case PathMoveTo:
+ return PathElementMoveToPoint;
+ case PathLineTo:
+ return PathElementAddLineToPoint;
+ case PathArcTo:
+ // FIXME: there's no arcTo type for PathElement
+ return PathElementAddLineToPoint;
+ // return PathElementAddQuadCurveToPoint;
+ case PathQuadCurveTo:
+ return PathElementAddQuadCurveToPoint;
+ case PathBezierCurveTo:
+ return PathElementAddCurveToPoint;
+ default:
+ ASSERT(m_type == PathCloseSubpath);
+ return PathElementCloseSubpath;
+ }
+}
+
+PlatformPath::PlatformPath()
+ : m_penLifted(true)
+{
+ m_currentPoint.clear();
+}
+
+void PlatformPath::ensureSubpath()
+{
+ if (m_penLifted) {
+ m_penLifted = false;
+ m_subpaths.append(PathPolygon());
+ m_subpaths.last().append(m_currentPoint);
+ } else
+ ASSERT(!m_subpaths.isEmpty());
+}
+
+void PlatformPath::addToSubpath(const PlatformPathElement& e)
+{
+ if (e.platformType() == PlatformPathElement::PathMoveTo) {
+ m_penLifted = true;
+ m_currentPoint = e.pointAt(0);
+ } else if (e.platformType() == PlatformPathElement::PathCloseSubpath) {
+ m_penLifted = true;
+ if (!m_subpaths.isEmpty()) {
+ if (m_currentPoint != m_subpaths.last()[0]) {
+ // According to W3C, we have to draw a line from current point to the initial point
+ m_subpaths.last().append(m_subpaths.last()[0]);
+ m_currentPoint = m_subpaths.last()[0];
+ }
+ } else
+ m_currentPoint.clear();
+ } else {
+ ensureSubpath();
+ switch (e.platformType()) {
+ case PlatformPathElement::PathLineTo:
+ m_subpaths.last().append(e.pointAt(0));
+ break;
+ case PlatformPathElement::PathArcTo:
+ addArcPoints(m_subpaths.last(), e.arcTo());
+ break;
+ case PlatformPathElement::PathQuadCurveTo:
+ {
+ PathPoint control[] = {
+ m_currentPoint,
+ e.pointAt(0),
+ e.pointAt(1),
+ };
+ // FIXME: magic number?
+ quadCurve(50, m_subpaths.last(), control);
+ }
+ break;
+ case PlatformPathElement::PathBezierCurveTo:
+ {
+ PathPoint control[] = {
+ m_currentPoint,
+ e.pointAt(0),
+ e.pointAt(1),
+ e.pointAt(2),
+ };
+ // FIXME: magic number?
+ bezier(100, m_subpaths.last(), control);
+ }
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ m_currentPoint = m_subpaths.last().last();
+ }
+}
+
+void PlatformPath::append(const PlatformPathElement& e)
+{
+ e.inflateRectToContainMe(m_boundingRect, lastPoint());
+ addToSubpath(e);
+ m_elements.append(e);
+}
+
+void PlatformPath::append(const PlatformPath& p)
+{
+ const PlatformPathElements& e = p.elements();
+ for (PlatformPathElements::const_iterator it(e.begin()); it != e.end(); ++it) {
+ addToSubpath(*it);
+ it->inflateRectToContainMe(m_boundingRect, lastPoint());
+ m_elements.append(*it);
+ }
+}
+
+void PlatformPath::clear()
+{
+ m_elements.clear();
+ m_boundingRect = FloatRect();
+ m_subpaths.clear();
+ m_currentPoint.clear();
+ m_penLifted = true;
+}
+
+void PlatformPath::strokePath(HDC dc, const AffineTransform* transformation) const
+{
+ drawPolygons(dc, m_subpaths, false, transformation);
+}
+
+void PlatformPath::fillPath(HDC dc, const AffineTransform* transformation) const
+{
+ HGDIOBJ oldPen = SelectObject(dc, GetStockObject(NULL_PEN));
+ drawPolygons(dc, m_subpaths, true, transformation);
+ SelectObject(dc, oldPen);
+}
+
+void PlatformPath::translate(const FloatSize& size)
+{
+ for (PlatformPathElements::iterator it(m_elements.begin()); it != m_elements.end(); ++it)
+ it->move(size);
+
+ m_boundingRect.move(size);
+ for (Vector<PathPolygon>::iterator it = m_subpaths.begin(); it != m_subpaths.end(); ++it)
+ it->move(size);
+}
+
+void PlatformPath::transform(const AffineTransform& t)
+{
+ for (PlatformPathElements::iterator it(m_elements.begin()); it != m_elements.end(); ++it)
+ it->transform(t);
+
+ m_boundingRect = t.mapRect(m_boundingRect);
+ for (Vector<PathPolygon>::iterator it = m_subpaths.begin(); it != m_subpaths.end(); ++it)
+ it->transform(t);
+}
+
+bool PlatformPath::contains(const FloatPoint& point, WindRule rule) const
+{
+ // optimization: check the bounding rect first
+ if (!containsPoint(m_boundingRect, point))
+ return false;
+
+ for (Vector<PathPolygon>::const_iterator i = m_subpaths.begin(); i != m_subpaths.end(); ++i) {
+ if (i->contains(point))
+ return true;
+ }
+
+ return false;
+}
+
+void PlatformPath::moveTo(const FloatPoint& point)
+{
+ PlatformPathElement::MoveTo data = { { point.x(), point.y() } };
+ PlatformPathElement pe(data);
+ append(pe);
+}
+
+void PlatformPath::addLineTo(const FloatPoint& point)
+{
+ PlatformPathElement::LineTo data = { { point.x(), point.y() } };
+ PlatformPathElement pe(data);
+ append(pe);
+}
+
+void PlatformPath::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
+{
+ PlatformPathElement::QuadCurveTo data = { { cp.x(), cp.y() }, { p.x(), p.y() } };
+ PlatformPathElement pe(data);
+ append(pe);
+}
+
+void PlatformPath::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
+{
+ PlatformPathElement::BezierCurveTo data = { { cp1.x(), cp1.y() }, { cp2.x(), cp2.y() }, { p.x(), p.y() } };
+ PlatformPathElement pe(data);
+ append(pe);
+}
+
+void PlatformPath::addArcTo(const FloatPoint& fp1, const FloatPoint& fp2, float radius)
+{
+ const PathPoint& p0 = m_currentPoint;
+ PathPoint p1;
+ p1 = fp1;
+ PathPoint p2;
+ p2 = fp2;
+ if (!radius || p0 == p1 || p1 == p2) {
+ addLineTo(p1);
+ return;
+ }
+
+ PathVector v01 = p0 - p1;
+ PathVector v21 = p2 - p1;
+
+ // sin(A - B) = sin(A) * cos(B) - sin(B) * cos(A)
+ double cross = v01.m_x * v21.m_y - v01.m_y * v21.m_x;
+
+ if (fabs(cross) < 1E-10) {
+ // on one line
+ addLineTo(p1);
+ return;
+ }
+
+ double d01 = v01.length();
+ double d21 = v21.length();
+ double angle = (piDouble - fabs(asin(cross / (d01 * d21)))) * 0.5;
+ double span = radius * tan(angle);
+ double rate = span / d01;
+ PathPoint startPoint;
+ startPoint.m_x = p1.m_x + v01.m_x * rate;
+ startPoint.m_y = p1.m_y + v01.m_y * rate;
+
+ addLineTo(startPoint);
+
+ PathPoint endPoint;
+ rate = span / d21;
+ endPoint.m_x = p1.m_x + v21.m_x * rate;
+ endPoint.m_y = p1.m_y + v21.m_y * rate;
+
+ PathPoint midPoint;
+ midPoint.m_x = (startPoint.m_x + endPoint.m_x) * 0.5;
+ midPoint.m_y = (startPoint.m_y + endPoint.m_y) * 0.5;
+
+ PathVector vm1 = midPoint - p1;
+ double dm1 = vm1.length();
+ double d = _hypot(radius, span);
+
+ PathPoint centerPoint;
+ rate = d / dm1;
+ centerPoint.m_x = p1.m_x + vm1.m_x * rate;
+ centerPoint.m_y = p1.m_y + vm1.m_y * rate;
+
+ PlatformPathElement::ArcTo data = {
+ endPoint,
+ centerPoint,
+ { radius, radius },
+ cross < 0
+ };
+ PlatformPathElement pe(data);
+ append(pe);
+}
+
+void PlatformPath::closeSubpath()
+{
+ PlatformPathElement pe;
+ append(pe);
+}
+
+// add a circular arc centred at p with radius r from start angle sar (radians) to end angle ear
+void PlatformPath::addEllipse(const FloatPoint& p, float a, float b, float sar, float ear, bool anticlockwise)
+{
+ float startX, startY, endX, endY;
+
+ normalizeAngle(sar);
+ normalizeAngle(ear);
+
+ getEllipsePointByAngle(sar, a, b, startX, startY);
+ getEllipsePointByAngle(ear, a, b, endX, endY);
+
+ transformArcPoint(startX, startY, p);
+ transformArcPoint(endX, endY, p);
+
+ FloatPoint start(startX, startY);
+ moveTo(start);
+
+ PlatformPathElement::ArcTo data = { { endX, endY }, { p.x(), p.y() }, { a, b }, !anticlockwise };
+ PlatformPathElement pe(data);
+ append(pe);
+}
+
+
+void PlatformPath::addRect(const FloatRect& r)
+{
+ moveTo(r.location());
+
+ float right = r.right() - 1;
+ float bottom = r.bottom() - 1;
+ addLineTo(FloatPoint(right, r.y()));
+ addLineTo(FloatPoint(right, bottom));
+ addLineTo(FloatPoint(r.x(), bottom));
+ addLineTo(r.location());
+}
+
+void PlatformPath::addEllipse(const FloatRect& r)
+{
+ FloatSize radius(r.width() * 0.5, r.height() * 0.5);
+ addEllipse(r.location() + radius, radius.width(), radius.height(), 0, 0, true);
+}
+
+String PlatformPath::debugString() const
+{
+ String ret;
+ for (PlatformPathElements::const_iterator i(m_elements.begin()); i != m_elements.end(); ++i) {
+ switch (i->platformType()) {
+ case PlatformPathElement::PathMoveTo:
+ case PlatformPathElement::PathLineTo:
+ ret += String::format("M %f %f\n", i->pointAt(0).m_x, i->pointAt(0).m_y);
+ break;
+ case PlatformPathElement::PathArcTo:
+ ret += String::format("A %f %f %f %f %f %f %c\n"
+ , i->arcTo().m_end.m_x, i->arcTo().m_end.m_y
+ , i->arcTo().m_center.m_x, i->arcTo().m_center.m_y
+ , i->arcTo().m_radius.m_x, i->arcTo().m_radius.m_y
+ , i->arcTo().m_clockwise? 'Y' : 'N');
+ break;
+ case PlatformPathElement::PathQuadCurveTo:
+ ret += String::format("Q %f %f %f %f\n"
+ , i->pointAt(0).m_x, i->pointAt(0).m_y
+ , i->pointAt(1).m_x, i->pointAt(1).m_y);
+ break;
+ case PlatformPathElement::PathBezierCurveTo:
+ ret += String::format("B %f %f %f %f %f %f\n"
+ , i->pointAt(0).m_x, i->pointAt(0).m_y
+ , i->pointAt(1).m_x, i->pointAt(1).m_y
+ , i->pointAt(2).m_x, i->pointAt(2).m_y);
+ break;
+ default:
+ ASSERT(i->platformType() == PlatformPathElement::PathCloseSubpath);
+ ret += "S\n";
+ break;
+ }
+ }
+
+ return ret;
+}
+
+void PlatformPath::apply(void* info, PathApplierFunction function) const
+{
+ PathElement pelement;
+ FloatPoint points[3];
+ pelement.points = points;
+
+ for (PlatformPathElements::const_iterator it(m_elements.begin()); it != m_elements.end(); ++it) {
+ pelement.type = it->type();
+ int n = it->numPoints();
+ for (int i = 0; i < n; ++i)
+ points[i] = it->pointAt(i);
+ function(info, &pelement);
+ }
+}
+
+} // namespace Webcore
diff --git a/WebCore/platform/graphics/wince/PlatformPathWinCE.h b/WebCore/platform/graphics/wince/PlatformPathWinCE.h
new file mode 100644
index 0000000..3414b04
--- /dev/null
+++ b/WebCore/platform/graphics/wince/PlatformPathWinCE.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2007-2009 Torch Mobile, 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 PlatformPathWinCE_h
+#define PlatformPathWinCE_h
+
+#include "FloatPoint.h"
+#include "FloatRect.h"
+#include "Path.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+ class GraphicsContext;
+
+ struct PathPoint {
+ float m_x;
+ float m_y;
+ const float& x() const { return m_x; }
+ const float& y() const { return m_y; }
+ void set(float x, float y)
+ {
+ m_x = x;
+ m_y = y;
+ };
+ operator FloatPoint() const { return FloatPoint(m_x, m_y); }
+ void move(const FloatSize& offset)
+ {
+ m_x += offset.width();
+ m_y += offset.height();
+ }
+ PathPoint& operator=(const FloatPoint& p)
+ {
+ m_x = p.x();
+ m_y = p.y();
+ return *this;
+ }
+ void clear() { m_x = m_y = 0; }
+ };
+
+ struct PathPolygon: public Vector<PathPoint> {
+ void move(const FloatSize& offset);
+ void transform(const AffineTransform& t);
+ bool contains(const FloatPoint& point) const;
+ };
+
+ class PlatformPathElement {
+ public:
+ enum PlaformPathElementType {
+ PathMoveTo,
+ PathLineTo,
+ PathArcTo,
+ PathQuadCurveTo,
+ PathBezierCurveTo,
+ PathCloseSubpath,
+ };
+
+ struct MoveTo {
+ PathPoint m_end;
+ };
+
+ struct LineTo {
+ PathPoint m_end;
+ };
+
+ struct ArcTo {
+ PathPoint m_end;
+ PathPoint m_center;
+ PathPoint m_radius;
+ bool m_clockwise;
+ };
+
+ struct QuadCurveTo {
+ PathPoint m_point0;
+ PathPoint m_point1;
+ };
+
+ struct BezierCurveTo {
+ PathPoint m_point0;
+ PathPoint m_point1;
+ PathPoint m_point2;
+ };
+
+ PlatformPathElement(): m_type(PathCloseSubpath) { m_data.m_points[0].set(0, 0); }
+ PlatformPathElement(const MoveTo& data): m_type(PathMoveTo) { m_data.m_moveToData = data; }
+ PlatformPathElement(const LineTo& data): m_type(PathLineTo) { m_data.m_lineToData = data; }
+ PlatformPathElement(const ArcTo& data): m_type(PathArcTo) { m_data.m_arcToData = data; }
+ PlatformPathElement(const QuadCurveTo& data): m_type(PathQuadCurveTo) { m_data.m_quadCurveToData = data; }
+ PlatformPathElement(const BezierCurveTo& data): m_type(PathBezierCurveTo) { m_data.m_bezierCurveToData = data; }
+
+ const MoveTo& moveTo() const { return m_data.m_moveToData; }
+ const LineTo& lineTo() const { return m_data.m_lineToData; }
+ const ArcTo& arcTo() const { return m_data.m_arcToData; }
+ const QuadCurveTo& quadCurveTo() const { return m_data.m_quadCurveToData; }
+ const BezierCurveTo& bezierCurveTo() const { return m_data.m_bezierCurveToData; }
+ const PathPoint& lastPoint() const
+ {
+ int n = numPoints();
+ return n > 1 ? m_data.m_points[n - 1] : m_data.m_points[0];
+ }
+ const PathPoint& pointAt(int index) const { return m_data.m_points[index]; }
+ int numPoints() const;
+ int numControlPoints() const;
+ void move(const FloatSize& offset);
+ void transform(const AffineTransform& t);
+ PathElementType type() const;
+ PlaformPathElementType platformType() const { return m_type; }
+ void inflateRectToContainMe(FloatRect& r, const FloatPoint& lastPoint) const;
+
+ private:
+ PlaformPathElementType m_type;
+ union {
+ MoveTo m_moveToData;
+ LineTo m_lineToData;
+ ArcTo m_arcToData;
+ QuadCurveTo m_quadCurveToData;
+ BezierCurveTo m_bezierCurveToData;
+ PathPoint m_points[4];
+ } m_data;
+ };
+
+ typedef Vector<PlatformPathElement> PlatformPathElements;
+
+ class PlatformPath {
+ public:
+ PlatformPath();
+ const PlatformPathElements& elements() const { return m_elements; }
+ void append(const PlatformPathElement& e);
+ void append(const PlatformPath& p);
+ void clear();
+ bool isEmpty() const { return m_elements.isEmpty(); }
+
+ void strokePath(HDC, const AffineTransform* tr) const;
+ void fillPath(HDC, const AffineTransform* tr) const;
+ FloatPoint lastPoint() const { return m_elements.isEmpty() ? FloatPoint(0, 0) : m_elements.last().lastPoint(); }
+
+ const FloatRect& boundingRect() const { return m_boundingRect; }
+ bool contains(const FloatPoint& point, WindRule rule) const;
+ void translate(const FloatSize& size);
+ void transform(const AffineTransform& t);
+
+ void moveTo(const FloatPoint&);
+ void addLineTo(const FloatPoint&);
+ void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point);
+ void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint&);
+ void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
+ void closeSubpath();
+ void addEllipse(const FloatPoint& p, float a, float b, float sar, float ear, bool anticlockwise);
+ void addRect(const FloatRect& r);
+ void addEllipse(const FloatRect& r);
+ String debugString() const;
+ void apply(void* info, PathApplierFunction function) const;
+
+ private:
+ void ensureSubpath();
+ void addToSubpath(const PlatformPathElement& e);
+
+ PlatformPathElements m_elements;
+ FloatRect m_boundingRect;
+ Vector<PathPolygon> m_subpaths;
+ PathPoint m_currentPoint;
+ bool m_penLifted;
+ };
+
+}
+
+#endif // PlatformPathWinCE_h
diff --git a/WebCore/platform/graphics/wince/PlatformPathWince.cpp b/WebCore/platform/graphics/wince/PlatformPathWince.cpp
deleted file mode 100644
index b42b52c..0000000
--- a/WebCore/platform/graphics/wince/PlatformPathWince.cpp
+++ /dev/null
@@ -1,810 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Torch Mobile, 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 "PlatformPathWince.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "Path.h"
-#include "PlatformString.h"
-#include "WinceGraphicsExtras.h"
-#include <wtf/MathExtras.h>
-#include <wtf/OwnPtr.h>
-
-#include <windows.h>
-
-namespace WebCore {
-
-// Implemented in GraphicsContextWince.cpp
-void getEllipsePointByAngle(double angle, double a, double b, float& x, float& y);
-
-static void quadCurve(int segments, Vector<PathPoint>& pts, const PathPoint* control)
-{
- const float step = 1.0 / segments;
- register float tA = 0.0;
- register float tB = 1.0;
-
- float c1x = control[0].x();
- float c1y = control[0].y();
- float c2x = control[1].x();
- float c2y = control[1].y();
- float c3x = control[2].x();
- float c3y = control[2].y();
-
- const int offset = pts.size();
- pts.resize(offset + segments);
- PathPoint pp;
- pp.m_x = c1x;
- pp.m_y = c1y;
-
- for (int i = 1; i < segments; ++i) {
- tA += step;
- tB -= step;
-
- const float a = tB * tB;
- const float b = 2.0 * tA * tB;
- const float c = tA * tA;
-
- pp.m_x = c1x * a + c2x * b + c3x * c;
- pp.m_y = c1y * a + c2y * b + c3y * c;
-
- pts[offset + i - 1] = pp;
- }
-
- pp.m_x = c3x;
- pp.m_y = c3y;
- pts[offset + segments - 1] = pp;
-}
-
-static inline void bezier(int segments, Vector<PathPoint>& pts, const PathPoint* control)
-{
- const float step = 1.0 / segments;
- register float tA = 0.0;
- register float tB = 1.0;
-
- float c1x = control[0].x();
- float c1y = control[0].y();
- float c2x = control[1].x();
- float c2y = control[1].y();
- float c3x = control[2].x();
- float c3y = control[2].y();
- float c4x = control[3].x();
- float c4y = control[3].y();
-
- const int offset = pts.size();
- pts.resize(offset + segments);
- PathPoint pp;
- pp.m_x = c1x;
- pp.m_y = c1y;
-
- for (int i = 1; i < segments; ++i) {
- tA += step;
- tB -= step;
- const float tAsq = tA * tA;
- const float tBsq = tB * tB;
-
- const float a = tBsq * tB;
- const float b = 3.0 * tA * tBsq;
- const float c = 3.0 * tB * tAsq;
- const float d = tAsq * tA;
-
- pp.m_x = c1x * a + c2x * b + c3x * c + c4x * d;
- pp.m_y = c1y * a + c2y * b + c3y * c + c4y * d;
-
- pts[offset + i - 1] = pp;
- }
-
- pp.m_x = c4x;
- pp.m_y = c4y;
- pts[offset + segments - 1] = pp;
-}
-
-static bool containsPoint(const FloatRect& r, const FloatPoint& p)
-{
- return p.x() >= r.x() && p.y() >= r.y() && p.x() < r.right() && p.y() < r.bottom();
-}
-
-static void normalizeAngle(float& angle)
-{
- angle = fmod(angle, 2 * piFloat);
- if (angle < 0)
- angle += 2 * piFloat;
- if (angle < 0.00001f)
- angle = 0;
-}
-
-static void transformArcPoint(float& x, float& y, const FloatPoint& c)
-{
- x += c.x();
- y += c.y();
-}
-
-static void inflateRectToContainPoint(FloatRect& r, float x, float y)
-{
- if (r.isEmpty()) {
- r.setX(x);
- r.setY(y);
- r.setSize(FloatSize(1, 1));
- return;
- }
- if (x < r.x()) {
- r.setWidth(r.right() - x);
- r.setX(x);
- } else {
- float w = x - r.x() + 1;
- if (w > r.width())
- r.setWidth(w);
- }
- if (y < r.y()) {
- r.setHeight(r.bottom() - y);
- r.setY(y);
- } else {
- float h = y - r.y() + 1;
- if (h > r.height())
- r.setHeight(h);
- }
-}
-
-// return 0-based value: 0 - first Quadrant ( 0 - 90 degree)
-static inline int quadrant(const PathPoint& point, const PathPoint& origin)
-{
- return point.m_x < origin.m_x ?
- (point.m_y < origin.m_y ? 2 : 1)
- : (point.m_y < origin.m_y ? 3 : 0);
-}
-
-static inline bool isQuadrantOnLeft(int q) { return q == 1 || q == 2; }
-static inline bool isQuadrantOnRight(int q) { return q == 0 || q == 3; }
-static inline bool isQuadrantOnTop(int q) { return q == 2 || q == 3; }
-static inline bool isQuadrantOnBottom(int q) { return q == 0 || q == 1; }
-
-static inline int nextQuadrant(int q) { return q == 3 ? 0 : q + 1; }
-static inline int quadrantDiff(int q1, int q2)
-{
- int d = q1 - q2;
- while (d < 0)
- d += 4;
- return d;
-}
-
-struct PathVector {
- float m_x;
- float m_y;
-
- PathVector() : m_x(0), m_y(0) {}
- PathVector(float x, float y) : m_x(x), m_y(y) {}
- double angle() const { return atan2(m_y, m_x); }
- operator double () const { return angle(); }
- double length() const { return _hypot(m_x, m_y); }
-};
-
-PathVector operator-(const PathPoint& p1, const PathPoint& p2)
-{
- return PathVector(p1.m_x - p2.m_x, p1.m_y - p2.m_y);
-}
-
-static void addArcPoint(PathPolygon& poly, const PathPoint& center, const PathPoint& radius, double angle)
-{
- PathPoint p;
- getEllipsePointByAngle(angle, radius.m_x, radius.m_y, p.m_x, p.m_y);
- transformArcPoint(p.m_x, p.m_y, center);
- if (poly.isEmpty() || poly.last() != p)
- poly.append(p);
-}
-
-static void addArcPoints(PathPolygon& poly, const PlatformPathElement::ArcTo& data)
-{
- const PathPoint& startPoint = poly.last();
- double curAngle = startPoint - data.m_center;
- double endAngle = data.m_end - data.m_center;
- double angleStep = 2. / std::max(data.m_radius.m_x, data.m_radius.m_y);
- if (data.m_clockwise) {
- if (endAngle <= curAngle || startPoint == data.m_end)
- endAngle += 2 * piDouble;
- } else {
- angleStep = -angleStep;
- if (endAngle >= curAngle || startPoint == data.m_end)
- endAngle -= 2 * piDouble;
- }
-
- for (curAngle += angleStep; data.m_clockwise ? curAngle < endAngle : curAngle > endAngle; curAngle += angleStep)
- addArcPoint(poly, data.m_center, data.m_radius, curAngle);
-
- if (poly.isEmpty() || poly.last() != data.m_end)
- poly.append(data.m_end);
-}
-
-static void drawPolygons(HDC dc, const Vector<PathPolygon>& polygons, bool fill, const AffineTransform* transformation)
-{
- MemoryAllocationCanFail canFail;
- for (Vector<PathPolygon>::const_iterator i = polygons.begin(); i != polygons.end(); ++i) {
- int npoints = i->size();
- if (!npoints)
- continue;
-
- POINT* winPoints = 0;
- if (fill) {
- if (npoints > 2)
- winPoints = new POINT[npoints + 1];
- } else
- winPoints = new POINT[npoints];
-
- if (winPoints) {
- if (transformation) {
- for (int i2 = 0; i2 < npoints; ++i2) {
- FloatPoint trPoint = transformation->mapPoint(i->at(i2));
- winPoints[i2].x = stableRound(trPoint.x());
- winPoints[i2].y = stableRound(trPoint.y());
- }
- } else {
- for (int i2 = 0; i2 < npoints; ++i2) {
- winPoints[i2].x = stableRound(i->at(i2).x());
- winPoints[i2].y = stableRound(i->at(i2).y());
- }
- }
-
- if (fill && winPoints[npoints - 1] != winPoints[0]) {
- winPoints[npoints].x = winPoints[0].x;
- winPoints[npoints].y = winPoints[0].y;
- ++npoints;
- }
-
- if (fill)
- ::Polygon(dc, winPoints, npoints);
- else
- ::Polyline(dc, winPoints, npoints);
- delete[] winPoints;
- }
- }
-}
-
-
-int PlatformPathElement::numControlPoints() const
-{
- switch (m_type) {
- case PathMoveTo:
- case PathLineTo:
- return 1;
- case PathQuadCurveTo:
- case PathArcTo:
- return 2;
- case PathBezierCurveTo:
- return 3;
- default:
- ASSERT(m_type == PathCloseSubpath);
- return 0;
- }
-}
-
-int PlatformPathElement::numPoints() const
-{
- switch (m_type) {
- case PathMoveTo:
- case PathLineTo:
- case PathArcTo:
- return 1;
- case PathQuadCurveTo:
- return 2;
- case PathBezierCurveTo:
- return 3;
- default:
- ASSERT(m_type == PathCloseSubpath);
- return 0;
- }
-}
-
-void PathPolygon::move(const FloatSize& offset)
-{
- for (Vector<PathPoint>::iterator i = begin(); i < end(); ++i)
- i->move(offset);
-}
-
-void PathPolygon::transform(const AffineTransform& t)
-{
- for (Vector<PathPoint>::iterator i = begin(); i < end(); ++i)
- *i = t.mapPoint(*i);
-}
-
-bool PathPolygon::contains(const FloatPoint& point) const
-{
- if (size() < 3)
- return false;
-
- // Test intersections between the polygon and the vertical line: x = point.x()
-
- int intersected = 0;
- const PathPoint* point1 = &last();
- Vector<PathPoint>::const_iterator last = end();
- // wasNegative: -1 means unknown, 0 means false, 1 means true.
- int wasNegative = -1;
- for (Vector<PathPoint>::const_iterator i = begin(); i != last; ++i) {
- const PathPoint& point2 = *i;
- if (point1->x() != point.x()) {
- if (point2.x() == point.x()) {
- // We are getting on the vertical line
- wasNegative = point1->x() < point.x() ? 1 : 0;
- } else if (point2.x() < point.x() != point1->x() < point.x()) {
- float y = (point2.y() - point1->y()) / (point2.x() - point1->x()) * (point.x() - point1->x()) + point1->y();
- if (y >= point.y())
- ++intersected;
- }
- } else {
- // We were on the vertical line
-
- // handle special case
- if (point1->y() == point.y())
- return true;
-
- if (point1->y() > point.y()) {
- if (point2.x() == point.x()) {
- // see if the point is on this segment
- if (point2.y() <= point.y())
- return true;
-
- // We are still on the line
- } else {
- // We are leaving the line now.
- // We have to get back to see which side we come from. If we come from
- // the same side we are leaving, no intersection should be counted
- if (wasNegative < 0) {
- Vector<PathPoint>::const_iterator jLast = i;
- Vector<PathPoint>::const_iterator j = i;
- do {
- if (j == begin())
- j = last;
- else
- --j;
- if (j->x() != point.x()) {
- if (j->x() > point.x())
- wasNegative = 0;
- else
- wasNegative = 1;
- break;
- }
- } while (j != jLast);
-
- if (wasNegative < 0)
- return false;
- }
- if (wasNegative ? point2.x() > point.x() : point2.x() < point.x())
- ++intersected;
- }
- } else if (point2.x() == point.x() && point2.y() >= point.y())
- return true;
- }
- point1 = &point2;
- }
-
- return intersected & 1;
-}
-
-void PlatformPathElement::move(const FloatSize& offset)
-{
- int n = numControlPoints();
- for (int i = 0; i < n; ++i)
- m_data.m_points[i].move(offset);
-}
-
-void PlatformPathElement::transform(const AffineTransform& t)
-{
- int n = numControlPoints();
- for (int i = 0; i < n; ++i) {
- FloatPoint p = t.mapPoint(m_data.m_points[i]);
- m_data.m_points[i].set(p.x(), p.y());
- }
-}
-
-void PlatformPathElement::inflateRectToContainMe(FloatRect& r, const FloatPoint& lastPoint) const
-{
- if (m_type == PathArcTo) {
- const ArcTo& data = m_data.m_arcToData;
- PathPoint startPoint;
- startPoint = lastPoint;
- PathPoint endPoint = data.m_end;
- if (!data.m_clockwise)
- std::swap(startPoint, endPoint);
-
- int q0 = quadrant(startPoint, data.m_center);
- int q1 = quadrant(endPoint, data.m_center);
- bool containsExtremes[4] = { false }; // bottom, left, top, right
- static const PathPoint extremeVectors[4] = { { 0, 1 }, { -1, 0 }, { 0, -1 }, { 1, 0 } };
- if (q0 == q1) {
- if (startPoint.m_x == endPoint.m_x || isQuadrantOnBottom(q0) != startPoint.m_x > endPoint.m_x) {
- for (int i = 0; i < 4; ++i)
- containsExtremes[i] = true;
- }
- } else {
- int extreme = q0;
- int diff = quadrantDiff(q1, q0);
- for (int i = 0; i < diff; ++i) {
- containsExtremes[extreme] = true;
- extreme = nextQuadrant(extreme);
- }
- }
-
- inflateRectToContainPoint(r, startPoint.m_x, startPoint.m_y);
- inflateRectToContainPoint(r, endPoint.m_x, endPoint.m_y);
- for (int i = 0; i < 4; ++i) {
- if (containsExtremes[i])
- inflateRectToContainPoint(r, data.m_center.m_x + data.m_radius.m_x * extremeVectors[i].m_x, data.m_center.m_y + data.m_radius.m_y * extremeVectors[i].m_y);
- }
- } else {
- int n = numPoints();
- for (int i = 0; i < n; ++i)
- inflateRectToContainPoint(r, m_data.m_points[i].m_x, m_data.m_points[i].m_y);
- }
-}
-
-PathElementType PlatformPathElement::type() const
-{
- switch (m_type) {
- case PathMoveTo:
- return PathElementMoveToPoint;
- case PathLineTo:
- return PathElementAddLineToPoint;
- case PathArcTo:
- // FIXME: there's no arcTo type for PathElement
- return PathElementAddLineToPoint;
- // return PathElementAddQuadCurveToPoint;
- case PathQuadCurveTo:
- return PathElementAddQuadCurveToPoint;
- case PathBezierCurveTo:
- return PathElementAddCurveToPoint;
- default:
- ASSERT(m_type == PathCloseSubpath);
- return PathElementCloseSubpath;
- }
-}
-
-PlatformPath::PlatformPath()
- : m_penLifted(true)
-{
- m_currentPoint.clear();
-}
-
-void PlatformPath::ensureSubpath()
-{
- if (m_penLifted) {
- m_penLifted = false;
- m_subpaths.append(PathPolygon());
- m_subpaths.last().append(m_currentPoint);
- } else
- ASSERT(!m_subpaths.isEmpty());
-}
-
-void PlatformPath::addToSubpath(const PlatformPathElement& e)
-{
- if (e.platformType() == PlatformPathElement::PathMoveTo) {
- m_penLifted = true;
- m_currentPoint = e.pointAt(0);
- } else if (e.platformType() == PlatformPathElement::PathCloseSubpath) {
- m_penLifted = true;
- if (!m_subpaths.isEmpty()) {
- if (m_currentPoint != m_subpaths.last()[0]) {
- // According to W3C, we have to draw a line from current point to the initial point
- m_subpaths.last().append(m_subpaths.last()[0]);
- m_currentPoint = m_subpaths.last()[0];
- }
- } else
- m_currentPoint.clear();
- } else {
- ensureSubpath();
- switch (e.platformType()) {
- case PlatformPathElement::PathLineTo:
- m_subpaths.last().append(e.pointAt(0));
- break;
- case PlatformPathElement::PathArcTo:
- addArcPoints(m_subpaths.last(), e.arcTo());
- break;
- case PlatformPathElement::PathQuadCurveTo:
- {
- PathPoint control[] = {
- m_currentPoint,
- e.pointAt(0),
- e.pointAt(1),
- };
- // FIXME: magic number?
- quadCurve(50, m_subpaths.last(), control);
- }
- break;
- case PlatformPathElement::PathBezierCurveTo:
- {
- PathPoint control[] = {
- m_currentPoint,
- e.pointAt(0),
- e.pointAt(1),
- e.pointAt(2),
- };
- // FIXME: magic number?
- bezier(100, m_subpaths.last(), control);
- }
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
- }
- m_currentPoint = m_subpaths.last().last();
- }
-}
-
-void PlatformPath::append(const PlatformPathElement& e)
-{
- e.inflateRectToContainMe(m_boundingRect, lastPoint());
- addToSubpath(e);
- m_elements.append(e);
-}
-
-void PlatformPath::append(const PlatformPath& p)
-{
- const PlatformPathElements& e = p.elements();
- for (PlatformPathElements::const_iterator it(e.begin()); it != e.end(); ++it) {
- addToSubpath(*it);
- it->inflateRectToContainMe(m_boundingRect, lastPoint());
- m_elements.append(*it);
- }
-}
-
-void PlatformPath::clear()
-{
- m_elements.clear();
- m_boundingRect = FloatRect();
- m_subpaths.clear();
- m_currentPoint.clear();
- m_penLifted = true;
-}
-
-void PlatformPath::strokePath(HDC dc, const AffineTransform* transformation) const
-{
- drawPolygons(dc, m_subpaths, false, transformation);
-}
-
-void PlatformPath::fillPath(HDC dc, const AffineTransform* transformation) const
-{
- HGDIOBJ oldPen = SelectObject(dc, GetStockObject(NULL_PEN));
- drawPolygons(dc, m_subpaths, true, transformation);
- SelectObject(dc, oldPen);
-}
-
-void PlatformPath::translate(const FloatSize& size)
-{
- for (PlatformPathElements::iterator it(m_elements.begin()); it != m_elements.end(); ++it)
- it->move(size);
-
- m_boundingRect.move(size);
- for (Vector<PathPolygon>::iterator it = m_subpaths.begin(); it != m_subpaths.end(); ++it)
- it->move(size);
-}
-
-void PlatformPath::transform(const AffineTransform& t)
-{
- for (PlatformPathElements::iterator it(m_elements.begin()); it != m_elements.end(); ++it)
- it->transform(t);
-
- m_boundingRect = t.mapRect(m_boundingRect);
- for (Vector<PathPolygon>::iterator it = m_subpaths.begin(); it != m_subpaths.end(); ++it)
- it->transform(t);
-}
-
-bool PlatformPath::contains(const FloatPoint& point, WindRule rule) const
-{
- // optimization: check the bounding rect first
- if (!containsPoint(m_boundingRect, point))
- return false;
-
- for (Vector<PathPolygon>::const_iterator i = m_subpaths.begin(); i != m_subpaths.end(); ++i) {
- if (i->contains(point))
- return true;
- }
-
- return false;
-}
-
-void PlatformPath::moveTo(const FloatPoint& point)
-{
- PlatformPathElement::MoveTo data = { { point.x(), point.y() } };
- PlatformPathElement pe(data);
- append(pe);
-}
-
-void PlatformPath::addLineTo(const FloatPoint& point)
-{
- PlatformPathElement::LineTo data = { { point.x(), point.y() } };
- PlatformPathElement pe(data);
- append(pe);
-}
-
-void PlatformPath::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
-{
- PlatformPathElement::QuadCurveTo data = { { cp.x(), cp.y() }, { p.x(), p.y() } };
- PlatformPathElement pe(data);
- append(pe);
-}
-
-void PlatformPath::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
-{
- PlatformPathElement::BezierCurveTo data = { { cp1.x(), cp1.y() }, { cp2.x(), cp2.y() }, { p.x(), p.y() } };
- PlatformPathElement pe(data);
- append(pe);
-}
-
-void PlatformPath::addArcTo(const FloatPoint& fp1, const FloatPoint& fp2, float radius)
-{
- const PathPoint& p0 = m_currentPoint;
- PathPoint p1;
- p1 = fp1;
- PathPoint p2;
- p2 = fp2;
- if (!radius || p0 == p1 || p1 == p2) {
- addLineTo(p1);
- return;
- }
-
- PathVector v01 = p0 - p1;
- PathVector v21 = p2 - p1;
-
- // sin(A - B) = sin(A) * cos(B) - sin(B) * cos(A)
- double cross = v01.m_x * v21.m_y - v01.m_y * v21.m_x;
-
- if (fabs(cross) < 1E-10) {
- // on one line
- addLineTo(p1);
- return;
- }
-
- double d01 = v01.length();
- double d21 = v21.length();
- double angle = (piDouble - fabs(asin(cross / (d01 * d21)))) * 0.5;
- double span = radius * tan(angle);
- double rate = span / d01;
- PathPoint startPoint;
- startPoint.m_x = p1.m_x + v01.m_x * rate;
- startPoint.m_y = p1.m_y + v01.m_y * rate;
-
- addLineTo(startPoint);
-
- PathPoint endPoint;
- rate = span / d21;
- endPoint.m_x = p1.m_x + v21.m_x * rate;
- endPoint.m_y = p1.m_y + v21.m_y * rate;
-
- PathPoint midPoint;
- midPoint.m_x = (startPoint.m_x + endPoint.m_x) * 0.5;
- midPoint.m_y = (startPoint.m_y + endPoint.m_y) * 0.5;
-
- PathVector vm1 = midPoint - p1;
- double dm1 = vm1.length();
- double d = _hypot(radius, span);
-
- PathPoint centerPoint;
- rate = d / dm1;
- centerPoint.m_x = p1.m_x + vm1.m_x * rate;
- centerPoint.m_y = p1.m_y + vm1.m_y * rate;
-
- PlatformPathElement::ArcTo data = {
- endPoint,
- centerPoint,
- { radius, radius },
- cross < 0
- };
- PlatformPathElement pe(data);
- append(pe);
-}
-
-void PlatformPath::closeSubpath()
-{
- PlatformPathElement pe;
- append(pe);
-}
-
-// add a circular arc centred at p with radius r from start angle sar (radians) to end angle ear
-void PlatformPath::addEllipse(const FloatPoint& p, float a, float b, float sar, float ear, bool anticlockwise)
-{
- float startX, startY, endX, endY;
-
- normalizeAngle(sar);
- normalizeAngle(ear);
-
- getEllipsePointByAngle(sar, a, b, startX, startY);
- getEllipsePointByAngle(ear, a, b, endX, endY);
-
- transformArcPoint(startX, startY, p);
- transformArcPoint(endX, endY, p);
-
- FloatPoint start(startX, startY);
- moveTo(start);
-
- PlatformPathElement::ArcTo data = { { endX, endY }, { p.x(), p.y() }, { a, b }, !anticlockwise };
- PlatformPathElement pe(data);
- append(pe);
-}
-
-
-void PlatformPath::addRect(const FloatRect& r)
-{
- moveTo(r.location());
-
- float right = r.right() - 1;
- float bottom = r.bottom() - 1;
- addLineTo(FloatPoint(right, r.y()));
- addLineTo(FloatPoint(right, bottom));
- addLineTo(FloatPoint(r.x(), bottom));
- addLineTo(r.location());
-}
-
-void PlatformPath::addEllipse(const FloatRect& r)
-{
- FloatSize radius(r.width() * 0.5, r.height() * 0.5);
- addEllipse(r.location() + radius, radius.width(), radius.height(), 0, 0, true);
-}
-
-String PlatformPath::debugString() const
-{
- String ret;
- for (PlatformPathElements::const_iterator i(m_elements.begin()); i != m_elements.end(); ++i) {
- switch (i->platformType()) {
- case PlatformPathElement::PathMoveTo:
- case PlatformPathElement::PathLineTo:
- ret += String::format("M %f %f\n", i->pointAt(0).m_x, i->pointAt(0).m_y);
- break;
- case PlatformPathElement::PathArcTo:
- ret += String::format("A %f %f %f %f %f %f %c\n"
- , i->arcTo().m_end.m_x, i->arcTo().m_end.m_y
- , i->arcTo().m_center.m_x, i->arcTo().m_center.m_y
- , i->arcTo().m_radius.m_x, i->arcTo().m_radius.m_y
- , i->arcTo().m_clockwise? 'Y' : 'N');
- break;
- case PlatformPathElement::PathQuadCurveTo:
- ret += String::format("Q %f %f %f %f\n"
- , i->pointAt(0).m_x, i->pointAt(0).m_y
- , i->pointAt(1).m_x, i->pointAt(1).m_y);
- break;
- case PlatformPathElement::PathBezierCurveTo:
- ret += String::format("B %f %f %f %f %f %f\n"
- , i->pointAt(0).m_x, i->pointAt(0).m_y
- , i->pointAt(1).m_x, i->pointAt(1).m_y
- , i->pointAt(2).m_x, i->pointAt(2).m_y);
- break;
- default:
- ASSERT(i->platformType() == PlatformPathElement::PathCloseSubpath);
- ret += "S\n";
- break;
- }
- }
-
- return ret;
-}
-
-void PlatformPath::apply(void* info, PathApplierFunction function) const
-{
- PathElement pelement;
- FloatPoint points[3];
- pelement.points = points;
-
- for (PlatformPathElements::const_iterator it(m_elements.begin()); it != m_elements.end(); ++it) {
- pelement.type = it->type();
- int n = it->numPoints();
- for (int i = 0; i < n; ++i)
- points[i] = it->pointAt(i);
- function(info, &pelement);
- }
-}
-
-} // namespace Webcore
diff --git a/WebCore/platform/graphics/wince/PlatformPathWince.h b/WebCore/platform/graphics/wince/PlatformPathWince.h
deleted file mode 100644
index 614e8c5..0000000
--- a/WebCore/platform/graphics/wince/PlatformPathWince.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Torch Mobile, 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 PlatformPathWince_h
-#define PlatformPathWince_h
-
-#include "FloatPoint.h"
-#include "FloatRect.h"
-#include "Path.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
- class GraphicsContext;
-
- struct PathPoint {
- float m_x;
- float m_y;
- const float& x() const { return m_x; }
- const float& y() const { return m_y; }
- void set(float x, float y)
- {
- m_x = x;
- m_y = y;
- };
- operator FloatPoint() const { return FloatPoint(m_x, m_y); }
- void move(const FloatSize& offset)
- {
- m_x += offset.width();
- m_y += offset.height();
- }
- PathPoint& operator=(const FloatPoint& p)
- {
- m_x = p.x();
- m_y = p.y();
- return *this;
- }
- void clear() { m_x = m_y = 0; }
- };
-
- struct PathPolygon: public Vector<PathPoint> {
- void move(const FloatSize& offset);
- void transform(const AffineTransform& t);
- bool contains(const FloatPoint& point) const;
- };
-
- class PlatformPathElement {
- public:
- enum PlaformPathElementType {
- PathMoveTo,
- PathLineTo,
- PathArcTo,
- PathQuadCurveTo,
- PathBezierCurveTo,
- PathCloseSubpath,
- };
-
- struct MoveTo {
- PathPoint m_end;
- };
-
- struct LineTo {
- PathPoint m_end;
- };
-
- struct ArcTo {
- PathPoint m_end;
- PathPoint m_center;
- PathPoint m_radius;
- bool m_clockwise;
- };
-
- struct QuadCurveTo {
- PathPoint m_point0;
- PathPoint m_point1;
- };
-
- struct BezierCurveTo {
- PathPoint m_point0;
- PathPoint m_point1;
- PathPoint m_point2;
- };
-
- PlatformPathElement(): m_type(PathCloseSubpath) { m_data.m_points[0].set(0, 0); }
- PlatformPathElement(const MoveTo& data): m_type(PathMoveTo) { m_data.m_moveToData = data; }
- PlatformPathElement(const LineTo& data): m_type(PathLineTo) { m_data.m_lineToData = data; }
- PlatformPathElement(const ArcTo& data): m_type(PathArcTo) { m_data.m_arcToData = data; }
- PlatformPathElement(const QuadCurveTo& data): m_type(PathQuadCurveTo) { m_data.m_quadCurveToData = data; }
- PlatformPathElement(const BezierCurveTo& data): m_type(PathBezierCurveTo) { m_data.m_bezierCurveToData = data; }
-
- const MoveTo& moveTo() const { return m_data.m_moveToData; }
- const LineTo& lineTo() const { return m_data.m_lineToData; }
- const ArcTo& arcTo() const { return m_data.m_arcToData; }
- const QuadCurveTo& quadCurveTo() const { return m_data.m_quadCurveToData; }
- const BezierCurveTo& bezierCurveTo() const { return m_data.m_bezierCurveToData; }
- const PathPoint& lastPoint() const
- {
- int n = numPoints();
- return n > 1 ? m_data.m_points[n - 1] : m_data.m_points[0];
- }
- const PathPoint& pointAt(int index) const { return m_data.m_points[index]; }
- int numPoints() const;
- int numControlPoints() const;
- void move(const FloatSize& offset);
- void transform(const AffineTransform& t);
- PathElementType type() const;
- PlaformPathElementType platformType() const { return m_type; }
- void inflateRectToContainMe(FloatRect& r, const FloatPoint& lastPoint) const;
-
- private:
- PlaformPathElementType m_type;
- union {
- MoveTo m_moveToData;
- LineTo m_lineToData;
- ArcTo m_arcToData;
- QuadCurveTo m_quadCurveToData;
- BezierCurveTo m_bezierCurveToData;
- PathPoint m_points[4];
- } m_data;
- };
-
- typedef Vector<PlatformPathElement> PlatformPathElements;
-
- class PlatformPath {
- public:
- PlatformPath();
- const PlatformPathElements& elements() const { return m_elements; }
- void append(const PlatformPathElement& e);
- void append(const PlatformPath& p);
- void clear();
- bool isEmpty() const { return m_elements.isEmpty(); }
-
- void strokePath(HDC, const AffineTransform* tr) const;
- void fillPath(HDC, const AffineTransform* tr) const;
- FloatPoint lastPoint() const { return m_elements.isEmpty() ? FloatPoint(0, 0) : m_elements.last().lastPoint(); }
-
- const FloatRect& boundingRect() const { return m_boundingRect; }
- bool contains(const FloatPoint& point, WindRule rule) const;
- void translate(const FloatSize& size);
- void transform(const AffineTransform& t);
-
- void moveTo(const FloatPoint&);
- void addLineTo(const FloatPoint&);
- void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point);
- void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint&);
- void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
- void closeSubpath();
- void addEllipse(const FloatPoint& p, float a, float b, float sar, float ear, bool anticlockwise);
- void addRect(const FloatRect& r);
- void addEllipse(const FloatRect& r);
- String debugString() const;
- void apply(void* info, PathApplierFunction function) const;
-
- private:
- void ensureSubpath();
- void addToSubpath(const PlatformPathElement& e);
-
- PlatformPathElements m_elements;
- FloatRect m_boundingRect;
- Vector<PathPolygon> m_subpaths;
- PathPoint m_currentPoint;
- bool m_penLifted;
- };
-
-}
-
-#endif // PlatformPathWince_h
diff --git a/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp b/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
new file mode 100644
index 0000000..c8c5474
--- /dev/null
+++ b/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, 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.
+ * 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 "SimpleFontData.h"
+
+#include "FloatRect.h"
+#include "Font.h"
+#include "FontCache.h"
+#include "FontDescription.h"
+#include <wtf/MathExtras.h>
+#include <mlang.h>
+#include <tchar.h>
+
+namespace WebCore {
+
+extern HDC g_screenDC;
+
+void SimpleFontData::platformInit()
+{
+ if (!m_platformData.isValid())
+ return;
+
+ const TEXTMETRIC& tm = m_platformData.metrics();
+ m_isSystemFont = m_platformData.isSystemFont();
+
+ m_ascent = (tm.tmAscent * m_platformData.size() + 36) / 72;
+ m_descent = (tm.tmDescent * m_platformData.size() + 36) / 72;
+ m_lineGap = (tm.tmExternalLeading * m_platformData.size() + 36) / 72;
+ m_lineSpacing = m_ascent + m_descent + m_lineGap;
+ m_xHeight = m_ascent * 0.56f;
+}
+
+void SimpleFontData::platformDestroy()
+{
+ delete m_smallCapsFontData;
+ m_smallCapsFontData = 0;
+}
+
+SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
+{
+ if (!m_smallCapsFontData) {
+ FontDescription fontDesc(fontDescription);
+ fontDesc.setComputedSize(lroundf(0.70f * fontDesc.computedSize()));
+ fontDesc.setSpecifiedSize(lroundf(0.70f * fontDesc.specifiedSize()));
+ fontDesc.setKeywordSize(lroundf(0.70f * fontDesc.keywordSize()));
+ FontPlatformData* result = fontCache()->getCachedFontPlatformData(fontDesc, m_platformData.family());
+ if (result)
+ m_smallCapsFontData = new SimpleFontData(*result);
+ }
+ return m_smallCapsFontData;
+}
+
+DWORD getKnownFontCodePages(const wchar_t* family);
+
+bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
+{
+ if (m_platformData.isDisabled())
+ return true;
+
+ // FIXME: Microsoft documentation seems to imply that characters can be output using a given font and DC
+ // merely by testing code page intersection. This seems suspect though. Can't a font only partially
+ // cover a given code page?
+
+ // FIXME: in the case that we failed to get the interface, still use the font.
+#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+ IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface();
+#else
+ IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface();
+#endif
+ if (!langFontLink)
+ return true;
+
+ DWORD fontCodePages = m_platformData.codePages();
+ if (!fontCodePages)
+ return false;
+
+ DWORD acpCodePages = 0;
+ langFontLink->CodePageToCodePages(CP_ACP, &acpCodePages);
+
+ DWORD actualCodePages;
+ long numCharactersProcessed;
+ while (length) {
+ langFontLink->GetStrCodePages(characters, length, acpCodePages, &actualCodePages, &numCharactersProcessed);
+ if (actualCodePages && !(actualCodePages & fontCodePages))
+ return false;
+
+ length -= numCharactersProcessed;
+ characters += numCharactersProcessed;
+ }
+
+ return true;
+}
+
+void SimpleFontData::determinePitch()
+{
+ if (!m_platformData.isValid())
+ return;
+
+ const TEXTMETRIC& tm = m_platformData.metrics();
+
+ // Yes, this looks backwards, but the fixed pitch bit is actually set if the font
+ // is *not* fixed pitch. Unbelievable but true.
+ m_treatAsFixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
+}
+
+FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const
+{
+ return FloatRect();
+}
+
+float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
+{
+ if (m_platformData.isDisabled())
+ return 0;
+
+ HGDIOBJ hOldFont = SelectObject(g_screenDC, m_platformData.hfont());
+
+ SIZE fontSize;
+ wchar_t c = glyph;
+ GetTextExtentPoint32(g_screenDC, &c, 1, &fontSize);
+
+ SelectObject(g_screenDC, hOldFont);
+
+ return (float)fontSize.cx * (float)m_platformData.size() / 72.f;
+}
+
+
+void SimpleFontData::platformCharWidthInit()
+{
+ if (!m_platformData.isValid())
+ return;
+
+ const TEXTMETRIC& tm = m_platformData.metrics();
+ m_avgCharWidth = (tm.tmAveCharWidth * m_platformData.size() + 36) / 72;
+ m_maxCharWidth = (tm.tmMaxCharWidth * m_platformData.size() + 36) / 72;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/wince/SimpleFontDataWince.cpp b/WebCore/platform/graphics/wince/SimpleFontDataWince.cpp
deleted file mode 100644
index 6c815fc..0000000
--- a/WebCore/platform/graphics/wince/SimpleFontDataWince.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, 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.
- * 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 "SimpleFontData.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include <wtf/MathExtras.h>
-#include <mlang.h>
-#include <tchar.h>
-
-namespace WebCore {
-
-extern HDC g_screenDC;
-
-void SimpleFontData::platformInit()
-{
- if (!m_platformData.isValid())
- return;
-
- const TEXTMETRIC& tm = m_platformData.metrics();
- m_isSystemFont = m_platformData.isSystemFont();
-
- m_ascent = (tm.tmAscent * m_platformData.size() + 36) / 72;
- m_descent = (tm.tmDescent * m_platformData.size() + 36) / 72;
- m_lineGap = (tm.tmExternalLeading * m_platformData.size() + 36) / 72;
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
- m_xHeight = m_ascent * 0.56f;
-}
-
-void SimpleFontData::platformDestroy()
-{
- delete m_smallCapsFontData;
- m_smallCapsFontData = 0;
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- FontDescription fontDesc(fontDescription);
- fontDesc.setComputedSize(lroundf(0.70f * fontDesc.computedSize()));
- fontDesc.setSpecifiedSize(lroundf(0.70f * fontDesc.specifiedSize()));
- fontDesc.setKeywordSize(lroundf(0.70f * fontDesc.keywordSize()));
- FontPlatformData* result = fontCache()->getCachedFontPlatformData(fontDesc, m_platformData.family());
- if (result)
- m_smallCapsFontData = new SimpleFontData(*result);
- }
- return m_smallCapsFontData;
-}
-
-DWORD getKnownFontCodePages(const wchar_t* family);
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- if (m_platformData.isDisabled())
- return true;
-
- // FIXME: Microsoft documentation seems to imply that characters can be output using a given font and DC
- // merely by testing code page intersection. This seems suspect though. Can't a font only partially
- // cover a given code page?
-
- // FIXME: in the case that we failed to get the interface, still use the font.
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface();
-#else
- IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface();
-#endif
- if (!langFontLink)
- return true;
-
- DWORD fontCodePages = m_platformData.codePages();
- if (!fontCodePages)
- return false;
-
- DWORD acpCodePages = 0;
- langFontLink->CodePageToCodePages(CP_ACP, &acpCodePages);
-
- DWORD actualCodePages;
- long numCharactersProcessed;
- while (length) {
- langFontLink->GetStrCodePages(characters, length, acpCodePages, &actualCodePages, &numCharactersProcessed);
- if (actualCodePages && !(actualCodePages & fontCodePages))
- return false;
-
- length -= numCharactersProcessed;
- characters += numCharactersProcessed;
- }
-
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- if (!m_platformData.isValid())
- return;
-
- const TEXTMETRIC& tm = m_platformData.metrics();
-
- // Yes, this looks backwards, but the fixed pitch bit is actually set if the font
- // is *not* fixed pitch. Unbelievable but true.
- m_treatAsFixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
-}
-
-FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const
-{
- return FloatRect();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- if (m_platformData.isDisabled())
- return 0;
-
- HGDIOBJ hOldFont = SelectObject(g_screenDC, m_platformData.hfont());
-
- SIZE fontSize;
- wchar_t c = glyph;
- GetTextExtentPoint32(g_screenDC, &c, 1, &fontSize);
-
- SelectObject(g_screenDC, hOldFont);
-
- return (float)fontSize.cx * (float)m_platformData.size() / 72.f;
-}
-
-
-void SimpleFontData::platformCharWidthInit()
-{
- if (!m_platformData.isValid())
- return;
-
- const TEXTMETRIC& tm = m_platformData.metrics();
- m_avgCharWidth = (tm.tmAveCharWidth * m_platformData.size() + 36) / 72;
- m_maxCharWidth = (tm.tmMaxCharWidth * m_platformData.size() + 36) / 72;
-}
-
-}
diff --git a/WebCore/platform/graphics/wince/WinCEGraphicsExtras.h b/WebCore/platform/graphics/wince/WinCEGraphicsExtras.h
new file mode 100644
index 0000000..4cab21c
--- /dev/null
+++ b/WebCore/platform/graphics/wince/WinCEGraphicsExtras.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2007-2009 Torch Mobile, 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 WinCEGraphicsExtras_h
+#define WinCEGraphicsExtras_h
+
+// This file is used to contain small utilities used by WINCE graphics code.
+
+namespace WebCore {
+ // Always round to same direction. 0.5 is rounded to 1,
+ // and -0.5 (0.5 - 1) is rounded to 0 (1 - 1), so that it
+ // is consistent when transformation shifts.
+ static inline int stableRound(double d)
+ {
+ if (d > 0)
+ return static_cast<int>(d + 0.5);
+
+ int i = static_cast<int>(d);
+ return i - d > 0.5 ? i - 1 : i;
+ }
+}
+
+#endif WinCEGraphicsExtras_h
diff --git a/WebCore/platform/graphics/wince/WinceGraphicsExtras.h b/WebCore/platform/graphics/wince/WinceGraphicsExtras.h
deleted file mode 100644
index 2a6fae1..0000000
--- a/WebCore/platform/graphics/wince/WinceGraphicsExtras.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Torch Mobile, 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 WinceGraphicsExtras_h
-#define WinceGraphicsExtras_h
-
-// This file is used to contain small utilities used by WINCE graphics code.
-
-namespace WebCore {
- // Always round to same direction. 0.5 is rounded to 1,
- // and -0.5 (0.5 - 1) is rounded to 0 (1 - 1), so that it
- // is consistent when transformation shifts.
- static inline int stableRound(double d)
- {
- if (d > 0)
- return static_cast<int>(d + 0.5);
-
- int i = static_cast<int>(d);
- return i - d > 0.5 ? i - 1 : i;
- }
-}
-
-#endif WinceGraphicsExtras_h
diff --git a/WebCore/platform/text/wince/TextBoundariesWinCE.cpp b/WebCore/platform/text/wince/TextBoundariesWinCE.cpp
new file mode 100644
index 0000000..f3070a4
--- /dev/null
+++ b/WebCore/platform/text/wince/TextBoundariesWinCE.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack at kde.org>
+ * Copyright (C) 2007-2009 Torch Mobile, 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 "NotImplemented.h"
+#include "PlatformString.h"
+
+using namespace WTF::Unicode;
+
+namespace WebCore {
+
+int findNextWordFromIndex(const UChar * buffer, int len, int position, bool forward)
+{
+ notImplemented();
+ return 0;
+}
+
+void findWordBoundary(const UChar * buffer, int len, int position, int* start, int* end)
+{
+ if (position > len) {
+ *start = 0;
+ *end = 0;
+ return;
+ }
+
+ String str(buffer, len);
+
+ int currentPosition = position - 1;
+ String foundWord;
+ while (currentPosition >= 0 && isLetter(str[currentPosition])) {
+ UChar c = str[currentPosition];
+ foundWord.insert(&c, 1, 0);
+ --currentPosition;
+ }
+
+ // currentPosition == 0 means the first char is not letter
+ // currentPosition == -1 means we reached the beginning
+ int startPos = (currentPosition < 0) ? 0 : ++currentPosition;
+ currentPosition = position;
+ while (isLetter(str[currentPosition])) {
+ foundWord.append(str[currentPosition]);
+ ++currentPosition;
+ }
+
+ *start = startPos;
+ *end = currentPosition;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/text/wince/TextBoundariesWince.cpp b/WebCore/platform/text/wince/TextBoundariesWince.cpp
deleted file mode 100644
index df6f757..0000000
--- a/WebCore/platform/text/wince/TextBoundariesWince.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack at kde.org>
- * Copyright (C) 2007-2009 Torch Mobile, 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 "NotImplemented.h"
-#include "PlatformString.h"
-
-using namespace WTF::Unicode;
-
-namespace WebCore {
-
-int findNextWordFromIndex(const UChar * buffer, int len, int position, bool forward)
-{
- notImplemented();
- return 0;
-}
-
-void findWordBoundary(const UChar * buffer, int len, int position, int* start, int* end)
-{
- if (position > len) {
- *start = 0;
- *end = 0;
- return;
- }
-
- String str(buffer, len);
-
- int currentPosition = position - 1;
- String foundWord;
- while (currentPosition >= 0 && isLetter(str[currentPosition])) {
- UChar c = str[currentPosition];
- foundWord.insert(&c, 1, 0);
- --currentPosition;
- }
-
- // currentPosition == 0 means the first char is not letter
- // currentPosition == -1 means we reached the beginning
- int startPos = (currentPosition < 0) ? 0 : ++currentPosition;
- currentPosition = position;
- while (isLetter(str[currentPosition])) {
- foundWord.append(str[currentPosition]);
- ++currentPosition;
- }
-
- *start = startPos;
- *end = currentPosition;
-}
-
-
-}
diff --git a/WebCore/platform/text/wince/TextBreakIteratorWince.cpp b/WebCore/platform/text/wince/TextBreakIteratorWinCE.cpp
similarity index 100%
rename from WebCore/platform/text/wince/TextBreakIteratorWince.cpp
rename to WebCore/platform/text/wince/TextBreakIteratorWinCE.cpp
diff --git a/WebCore/platform/wince/CursorWinCE.cpp b/WebCore/platform/wince/CursorWinCE.cpp
new file mode 100644
index 0000000..90ba879
--- /dev/null
+++ b/WebCore/platform/wince/CursorWinCE.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2008-2009 Torch Mobile 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 "Cursor.h"
+
+namespace WebCore {
+
+struct AllCursors {
+ AllCursors()
+ {
+ for (int i = 0; i < NumCursorTypes; ++i)
+ m_cursors[i] = (CursorType) i;
+ }
+ Cursor m_cursors[NumCursorTypes];
+};
+
+static const Cursor& getCursor(CursorType type)
+{
+ static AllCursors allCursors;
+ return allCursors.m_cursors[type];
+}
+
+Cursor::Cursor(const Cursor& other)
+: m_platformCursor(other.m_platformCursor)
+{
+}
+
+Cursor::Cursor(Image* img, const IntPoint& hotspot)
+: m_platformCursor(CursorNone)
+{
+}
+
+Cursor::~Cursor()
+{
+}
+
+Cursor& Cursor::operator=(const Cursor& other)
+{
+ m_platformCursor = other.m_platformCursor;
+ return *this;
+}
+
+Cursor::Cursor(PlatformCursor c)
+: m_platformCursor(c)
+{
+}
+
+const Cursor& noneCursor() { return getCursor(CursorNone); }
+const Cursor& pointerCursor() { return getCursor(CursorPointer); }
+const Cursor& crossCursor() { return getCursor(CursorCross); }
+const Cursor& handCursor() { return getCursor(CursorHand); }
+const Cursor& iBeamCursor() { return getCursor(CursorBeam); }
+const Cursor& waitCursor() { return getCursor(CursorWait); }
+const Cursor& helpCursor() { return getCursor(CursorHelp); }
+const Cursor& moveCursor() { return getCursor(CursorMove); }
+const Cursor& eastResizeCursor() { return getCursor(CursorEastResize); }
+const Cursor& northResizeCursor() { return getCursor(CursorNorthResize); }
+const Cursor& northEastResizeCursor() { return getCursor(CursorNorthEastResize); }
+const Cursor& northWestResizeCursor() { return getCursor(CursorNorthWestResize); }
+const Cursor& southResizeCursor() { return getCursor(CursorSouthResize); }
+const Cursor& southEastResizeCursor() { return getCursor(CursorSouthEastResize); }
+const Cursor& southWestResizeCursor() { return getCursor(CursorSouthWestResize); }
+const Cursor& westResizeCursor() { return getCursor(CursorWestResize); }
+const Cursor& northSouthResizeCursor() { return getCursor(CursorNorthSouthResize); }
+const Cursor& eastWestResizeCursor() { return getCursor(CursorEastWestResize); }
+const Cursor& northEastSouthWestResizeCursor() { return getCursor(CursorNorthEastSouthWestResize); }
+const Cursor& northWestSouthEastResizeCursor() { return getCursor(CursorNorthWestSouthEastResize); }
+const Cursor& columnResizeCursor() { return getCursor(CursorColumnResize); }
+const Cursor& rowResizeCursor() { return getCursor(CursorRowResize); }
+const Cursor& verticalTextCursor() { return getCursor(CursorVerticalText); }
+const Cursor& cellCursor() { return getCursor(CursorCell); }
+const Cursor& contextMenuCursor() { return getCursor(CursorContextMenu); }
+const Cursor& noDropCursor() { return getCursor(CursorNoDrop); }
+const Cursor& notAllowedCursor() { return getCursor(CursorNotAllowed); }
+const Cursor& progressCursor() { return getCursor(CursorProgress); }
+const Cursor& aliasCursor() { return getCursor(CursorAlias); }
+const Cursor& zoomInCursor() { return getCursor(CursorZoomIn); }
+const Cursor& zoomOutCursor() { return getCursor(CursorZoomOut); }
+const Cursor& copyCursor() { return getCursor(CursorCopy); }
+const Cursor& middlePanningCursor() { return crossCursor(); }
+const Cursor& eastPanningCursor() { return crossCursor(); }
+const Cursor& northPanningCursor() { return crossCursor(); }
+const Cursor& northEastPanningCursor() { return crossCursor(); }
+const Cursor& northWestPanningCursor() { return crossCursor(); }
+const Cursor& southPanningCursor() { return crossCursor(); }
+const Cursor& southEastPanningCursor() { return crossCursor(); }
+const Cursor& southWestPanningCursor() { return crossCursor(); }
+const Cursor& westPanningCursor() { return crossCursor(); }
+const Cursor& grabbingCursor() { return moveCursor(); }
+const Cursor& grabCursor() { return moveCursor(); }
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/CursorWince.cpp b/WebCore/platform/wince/CursorWince.cpp
deleted file mode 100644
index d7dcfb4..0000000
--- a/WebCore/platform/wince/CursorWince.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Torch Mobile 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 "Cursor.h"
-
-namespace WebCore {
-
-struct AllCursors {
- AllCursors()
- {
- for (int i = 0; i < NumCursorTypes; ++i)
- m_cursors[i] = (CursorType) i;
- }
- Cursor m_cursors[NumCursorTypes];
-};
-
-static const Cursor& getCursor(CursorType type)
-{
- static AllCursors allCursors;
- return allCursors.m_cursors[type];
-}
-
-Cursor::Cursor(const Cursor& other)
-: m_platformCursor(other.m_platformCursor)
-{
-}
-
-Cursor::Cursor(Image* img, const IntPoint& hotspot)
-: m_platformCursor(CursorNone)
-{
-}
-
-Cursor::~Cursor()
-{
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- m_platformCursor = other.m_platformCursor;
- return *this;
-}
-
-Cursor::Cursor(PlatformCursor c)
-: m_platformCursor(c)
-{
-}
-
-const Cursor& noneCursor() { return getCursor(CursorNone); }
-const Cursor& pointerCursor() { return getCursor(CursorPointer); }
-const Cursor& crossCursor() { return getCursor(CursorCross); }
-const Cursor& handCursor() { return getCursor(CursorHand); }
-const Cursor& iBeamCursor() { return getCursor(CursorBeam); }
-const Cursor& waitCursor() { return getCursor(CursorWait); }
-const Cursor& helpCursor() { return getCursor(CursorHelp); }
-const Cursor& moveCursor() { return getCursor(CursorMove); }
-const Cursor& eastResizeCursor() { return getCursor(CursorEastResize); }
-const Cursor& northResizeCursor() { return getCursor(CursorNorthResize); }
-const Cursor& northEastResizeCursor() { return getCursor(CursorNorthEastResize); }
-const Cursor& northWestResizeCursor() { return getCursor(CursorNorthWestResize); }
-const Cursor& southResizeCursor() { return getCursor(CursorSouthResize); }
-const Cursor& southEastResizeCursor() { return getCursor(CursorSouthEastResize); }
-const Cursor& southWestResizeCursor() { return getCursor(CursorSouthWestResize); }
-const Cursor& westResizeCursor() { return getCursor(CursorWestResize); }
-const Cursor& northSouthResizeCursor() { return getCursor(CursorNorthSouthResize); }
-const Cursor& eastWestResizeCursor() { return getCursor(CursorEastWestResize); }
-const Cursor& northEastSouthWestResizeCursor() { return getCursor(CursorNorthEastSouthWestResize); }
-const Cursor& northWestSouthEastResizeCursor() { return getCursor(CursorNorthWestSouthEastResize); }
-const Cursor& columnResizeCursor() { return getCursor(CursorColumnResize); }
-const Cursor& rowResizeCursor() { return getCursor(CursorRowResize); }
-const Cursor& verticalTextCursor() { return getCursor(CursorVerticalText); }
-const Cursor& cellCursor() { return getCursor(CursorCell); }
-const Cursor& contextMenuCursor() { return getCursor(CursorContextMenu); }
-const Cursor& noDropCursor() { return getCursor(CursorNoDrop); }
-const Cursor& notAllowedCursor() { return getCursor(CursorNotAllowed); }
-const Cursor& progressCursor() { return getCursor(CursorProgress); }
-const Cursor& aliasCursor() { return getCursor(CursorAlias); }
-const Cursor& zoomInCursor() { return getCursor(CursorZoomIn); }
-const Cursor& zoomOutCursor() { return getCursor(CursorZoomOut); }
-const Cursor& copyCursor() { return getCursor(CursorCopy); }
-const Cursor& middlePanningCursor() { return crossCursor(); }
-const Cursor& eastPanningCursor() { return crossCursor(); }
-const Cursor& northPanningCursor() { return crossCursor(); }
-const Cursor& northEastPanningCursor() { return crossCursor(); }
-const Cursor& northWestPanningCursor() { return crossCursor(); }
-const Cursor& southPanningCursor() { return crossCursor(); }
-const Cursor& southEastPanningCursor() { return crossCursor(); }
-const Cursor& southWestPanningCursor() { return crossCursor(); }
-const Cursor& westPanningCursor() { return crossCursor(); }
-const Cursor& grabbingCursor() { return moveCursor(); }
-const Cursor& grabCursor() { return moveCursor(); }
-
-}
diff --git a/WebCore/platform/wince/DragDataWinCE.cpp b/WebCore/platform/wince/DragDataWinCE.cpp
new file mode 100644
index 0000000..5535ea9
--- /dev/null
+++ b/WebCore/platform/wince/DragDataWinCE.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2007-2008 Torch Mobile, 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 "DragData.h"
+
+#include "DocumentFragment.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+{
+ return false;
+}
+
+String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
+{
+ return String();
+}
+
+bool DragData::containsFiles() const
+{
+ return false;
+}
+
+void DragData::asFilenames(Vector<String>&) const
+{
+}
+
+bool DragData::containsPlainText() const
+{
+ return false;
+}
+
+String DragData::asPlainText() const
+{
+ return String();
+}
+
+bool DragData::containsColor() const
+{
+ return false;
+}
+
+bool DragData::canSmartReplace() const
+{
+ return false;
+}
+
+bool DragData::containsCompatibleContent() const
+{
+ return false;
+}
+
+PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
+{
+ return 0;
+}
+
+Color DragData::asColor() const
+{
+ return Color();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/DragDataWince.cpp b/WebCore/platform/wince/DragDataWince.cpp
deleted file mode 100644
index 73dd8a2..0000000
--- a/WebCore/platform/wince/DragDataWince.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Torch Mobile, 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 "DragData.h"
-
-#include "DocumentFragment.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
-{
- return false;
-}
-
-String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
-{
- return String();
-}
-
-bool DragData::containsFiles() const
-{
- return false;
-}
-
-void DragData::asFilenames(Vector<String>&) const
-{
-}
-
-bool DragData::containsPlainText() const
-{
- return false;
-}
-
-String DragData::asPlainText() const
-{
- return String();
-}
-
-bool DragData::containsColor() const
-{
- return false;
-}
-
-bool DragData::canSmartReplace() const
-{
- return false;
-}
-
-bool DragData::containsCompatibleContent() const
-{
- return false;
-}
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
-{
- return 0;
-}
-
-Color DragData::asColor() const
-{
- return Color();
-}
-
-}
-
diff --git a/WebCore/platform/wince/DragImageWinCE.cpp b/WebCore/platform/wince/DragImageWinCE.cpp
new file mode 100644
index 0000000..f639b41
--- /dev/null
+++ b/WebCore/platform/wince/DragImageWinCE.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2007-2008 Torch Mobile, 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 "DragImage.h"
+
+#include "CachedImage.h"
+#include "GraphicsContext.h"
+#include "Image.h"
+
+#include <windows.h>
+
+namespace WebCore {
+
+IntSize dragImageSize(DragImageRef)
+{
+ return IntSize(0, 0);
+}
+
+void deleteDragImage(DragImageRef image)
+{
+ if (image)
+ ::DeleteObject(image);
+}
+
+DragImageRef scaleDragImage(DragImageRef, FloatSize)
+{
+ return 0;
+}
+
+DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
+{
+ return image;
+}
+
+DragImageRef createDragImageFromImage(Image*)
+{
+ return 0;
+}
+
+DragImageRef createDragImageIconForCachedImage(CachedImage*)
+{
+ return 0;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/DragImageWince.cpp b/WebCore/platform/wince/DragImageWince.cpp
deleted file mode 100644
index 4d60f80..0000000
--- a/WebCore/platform/wince/DragImageWince.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Torch Mobile, 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 "DragImage.h"
-
-#include "CachedImage.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-IntSize dragImageSize(DragImageRef)
-{
- return IntSize(0, 0);
-}
-
-void deleteDragImage(DragImageRef image)
-{
- if (image)
- ::DeleteObject(image);
-}
-
-DragImageRef scaleDragImage(DragImageRef, FloatSize)
-{
- return 0;
-}
-
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
-{
- return image;
-}
-
-DragImageRef createDragImageFromImage(Image*)
-{
- return 0;
-}
-
-DragImageRef createDragImageIconForCachedImage(CachedImage*)
-{
- return 0;
-}
-
-}
diff --git a/WebCore/platform/wince/EditorWinCE.cpp b/WebCore/platform/wince/EditorWinCE.cpp
new file mode 100644
index 0000000..eb0ecb4
--- /dev/null
+++ b/WebCore/platform/wince/EditorWinCE.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2007-2008 Torch Mobile, 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 "Editor.h"
+
+#include "ClipboardWinCE.h"
+#include "Document.h"
+#include "EditorClient.h"
+#include "Element.h"
+#include "HtmlEditing.h"
+#include "TextIterator.h"
+#include "visible_units.h"
+
+#include <windows.h>
+#define _SYS_GUID_OPERATORS_
+
+namespace WebCore {
+
+PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*)
+{
+ return adoptRef(new ClipboardWinCE(policy, false));
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/EditorWince.cpp b/WebCore/platform/wince/EditorWince.cpp
deleted file mode 100644
index 71f4db9..0000000
--- a/WebCore/platform/wince/EditorWince.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Torch Mobile, 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 "Editor.h"
-
-#include "ClipboardWince.h"
-#include "Document.h"
-#include "EditorClient.h"
-#include "Element.h"
-#include "HtmlEditing.h"
-#include "TextIterator.h"
-#include "visible_units.h"
-
-#include <windows.h>
-#define _SYS_GUID_OPERATORS_
-
-namespace WebCore {
-
-PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*)
-{
- return adoptRef(new ClipboardWince(policy, false));
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/wince/FileChooserWinCE.cpp b/WebCore/platform/wince/FileChooserWinCE.cpp
new file mode 100644
index 0000000..955e68a
--- /dev/null
+++ b/WebCore/platform/wince/FileChooserWinCE.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, 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 "FileChooser.h"
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Document.h"
+#include "Frame.h"
+#include "Icon.h"
+#include "LocalizedStrings.h"
+#include "Page.h"
+#include "StringTruncator.h"
+
+namespace WebCore {
+
+String pathGetFileName(const String& path);
+
+String FileChooser::basenameForWidth(const Font& font, int width) const
+{
+ if (width <= 0)
+ return String();
+
+ String string;
+ if (m_filenames.isEmpty())
+ string = fileButtonNoFileSelectedLabel();
+ else if (m_filenames.size() == 1) {
+ String tmpFilename = m_filenames[0];
+ string = pathGetFileName(tmpFilename);
+ } else
+ return StringTruncator::rightTruncate(String::number(m_filenames.size()) + " files", width, font, false);
+
+ return StringTruncator::centerTruncate(string, width, font, false);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/FileChooserWince.cpp b/WebCore/platform/wince/FileChooserWince.cpp
deleted file mode 100644
index 07c99b1..0000000
--- a/WebCore/platform/wince/FileChooserWince.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, 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 "FileChooser.h"
-
-#include "Chrome.h"
-#include "ChromeClient.h"
-#include "Document.h"
-#include "Frame.h"
-#include "Icon.h"
-#include "LocalizedStrings.h"
-#include "Page.h"
-#include "StringTruncator.h"
-
-namespace WebCore {
-
-String pathGetFileName(const String& path);
-
-String FileChooser::basenameForWidth(const Font& font, int width) const
-{
- if (width <= 0)
- return String();
-
- String string;
- if (m_filenames.isEmpty())
- string = fileButtonNoFileSelectedLabel();
- else if (m_filenames.size() == 1) {
- String tmpFilename = m_filenames[0];
- string = pathGetFileName(tmpFilename);
- } else
- return StringTruncator::rightTruncate(String::number(m_filenames.size()) + " files", width, font, false);
-
- return StringTruncator::centerTruncate(string, width, font, false);
-}
-
-}
diff --git a/WebCore/platform/wince/FileSystemWinCE.cpp b/WebCore/platform/wince/FileSystemWinCE.cpp
new file mode 100644
index 0000000..2a27089
--- /dev/null
+++ b/WebCore/platform/wince/FileSystemWinCE.cpp
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, 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.
+ * 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 "FileSystem.h"
+
+#include "NotImplemented.h"
+#include "PlatformString.h"
+#include <wtf/text/CString.h>
+
+#include <windows.h>
+#include <wincrypt.h>
+
+namespace WebCore {
+
+static bool getFileInfo(const String& path, BY_HANDLE_FILE_INFORMATION& fileInfo)
+{
+ String filename = path;
+ HANDLE hFile = CreateFile(filename.charactersWithNullTermination(), GENERIC_READ, FILE_SHARE_READ, 0
+ , OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, 0);
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ return false;
+
+ bool rtn = GetFileInformationByHandle(hFile, &fileInfo) ? true : false;
+
+ CloseHandle(hFile);
+ return rtn;
+}
+
+bool getFileSize(const String& path, long long& result)
+{
+ BY_HANDLE_FILE_INFORMATION fileInformation;
+ if (!getFileInfo(path, fileInformation))
+ return false;
+
+ ULARGE_INTEGER fileSize;
+ fileSize.LowPart = fileInformation.nFileSizeLow;
+ fileSize.HighPart = fileInformation.nFileSizeHigh;
+
+ result = fileSize.QuadPart;
+
+ return true;
+}
+
+bool getFileModificationTime(const String& path, time_t& result)
+{
+ BY_HANDLE_FILE_INFORMATION fileInformation;
+ if (!getFileInfo(path, fileInformation))
+ return false;
+
+ ULARGE_INTEGER t;
+ memcpy(&t, &fileInformation.ftLastWriteTime, sizeof(t));
+
+ result = t.QuadPart * 0.0000001 - 11644473600.0;
+
+ return true;
+}
+
+bool fileExists(const String& path)
+{
+ String filename = path;
+ HANDLE hFile = CreateFile(filename.charactersWithNullTermination(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE
+ , 0, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, 0);
+
+ CloseHandle(hFile);
+
+ return hFile != INVALID_HANDLE_VALUE;
+}
+
+bool deleteFile(const String& path)
+{
+ String filename = path;
+ return !!DeleteFileW(filename.charactersWithNullTermination());
+}
+
+
+bool deleteEmptyDirectory(const String& path)
+{
+ String filename = path;
+ return !!RemoveDirectoryW(filename.charactersWithNullTermination());
+}
+
+String pathByAppendingComponent(const String& path, const String& component)
+{
+ if (component.isEmpty())
+ return path;
+
+ Vector<UChar, MAX_PATH> buffer;
+
+ buffer.append(path.characters(), path.length());
+
+ if (buffer.last() != L'\\' && buffer.last() != L'/'
+ && component[0] != L'\\' && component[0] != L'/')
+ buffer.append(L'\\');
+
+ buffer.append(component.characters(), component.length());
+
+ return String(buffer.data(), buffer.size());
+}
+
+CString fileSystemRepresentation(const String&)
+{
+ return "";
+}
+
+bool makeAllDirectories(const String& path)
+{
+ int lastDivPos = std::max(path.reverseFind('/'), path.reverseFind('\\'));
+ int endPos = path.length();
+ if (lastDivPos == path.length() - 1) {
+ endPos -= 1;
+ lastDivPos = std::max(path.reverseFind('/', lastDivPos), path.reverseFind('\\', lastDivPos));
+ }
+
+ if (lastDivPos > 0) {
+ if (!makeAllDirectories(path.substring(0, lastDivPos)))
+ return false;
+ }
+
+ String folder(path.substring(0, endPos));
+ CreateDirectory(folder.charactersWithNullTermination(), 0);
+
+ DWORD fileAttr = GetFileAttributes(folder.charactersWithNullTermination());
+ return fileAttr != 0xFFFFFFFF && (fileAttr & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+String homeDirectoryPath()
+{
+ notImplemented();
+ return "";
+}
+
+String pathGetFileName(const String& path)
+{
+ return path.substring(std::max(path.reverseFind('/'), path.reverseFind('\\')) + 1);
+}
+
+String directoryName(const String& path)
+{
+ notImplemented();
+ return String();
+}
+
+CString openTemporaryFile(const char*, PlatformFileHandle& handle)
+{
+ handle = INVALID_HANDLE_VALUE;
+
+ wchar_t tempPath[MAX_PATH];
+ int tempPathLength = ::GetTempPath(_countof(tempPath), tempPath);
+ if (tempPathLength <= 0 || tempPathLength > _countof(tempPath))
+ return CString();
+
+ HCRYPTPROV hCryptProv = 0;
+ if (!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+ return CString();
+
+ String proposedPath;
+ while (1) {
+
+ wchar_t tempFile[] = L"XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names)
+ const int randomPartLength = 8;
+ if (!CryptGenRandom(hCryptProv, randomPartLength * 2, reinterpret_cast<BYTE*>(tempFile)))
+ break;
+
+ // Limit to valid filesystem characters, also excluding others that could be problematic, like punctuation.
+ // don't include both upper and lowercase since Windows file systems are typically not case sensitive.
+ const char validChars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+ for (int i = 0; i < randomPartLength; ++i)
+ tempFile[i] = validChars[tempFile[i] % (sizeof(validChars) - 1)];
+
+ ASSERT(wcslen(tempFile) * 2 == sizeof(tempFile) - 2);
+
+ proposedPath = pathByAppendingComponent(String(tempPath), String(tempFile));
+
+ // use CREATE_NEW to avoid overwriting an existing file with the same name
+ handle = CreateFile(proposedPath.charactersWithNullTermination(), GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
+ if (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS)
+ continue;
+
+ break;
+ }
+
+ CryptReleaseContext(hCryptProv, 0);
+
+ if (!isHandleValid(handle))
+ return CString();
+
+ return proposedPath.latin1();
+}
+
+void closeFile(PlatformFileHandle& handle)
+{
+ if (isHandleValid(handle)) {
+ ::CloseHandle(handle);
+ handle = invalidPlatformFileHandle;
+ }
+}
+
+int writeToFile(PlatformFileHandle handle, const char* data, int length)
+{
+ if (!isHandleValid(handle))
+ return -1;
+
+ DWORD bytesWritten;
+ bool success = WriteFile(handle, data, length, &bytesWritten, 0);
+
+ if (!success)
+ return -1;
+ return static_cast<int>(bytesWritten);
+}
+
+bool unloadModule(PlatformModule module)
+{
+ return ::FreeLibrary(module);
+}
+
+String localUserSpecificStorageDirectory()
+{
+ return String(L"\\");
+}
+
+String roamingUserSpecificStorageDirectory()
+{
+ return String(L"\\");
+}
+
+Vector<String> listDirectory(const String& path, const String& filter)
+{
+ Vector<String> entries;
+
+ Vector<UChar, 256> pattern;
+ pattern.append(path.characters(), path.length());
+ if (pattern.last() != L'/' && pattern.last() != L'\\')
+ pattern.append(L'\\');
+
+ String root(pattern.data(), pattern.size());
+ pattern.append(filter.characters(), filter.length());
+ pattern.append(0);
+
+ WIN32_FIND_DATA findData;
+ HANDLE hFind = FindFirstFile(pattern.data(), &findData);
+ if (INVALID_HANDLE_VALUE != hFind) {
+ do {
+ // FIXEME: should we also add the folders? This function
+ // is so far only called by PluginDatabase.cpp to list
+ // all plugins in a folder, where it's not supposed to list sub-folders.
+ if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ entries.append(root + findData.cFileName);
+ } while (FindNextFile(hFind, &findData));
+ FindClose(hFind);
+ }
+
+ return entries;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/FileSystemWince.cpp b/WebCore/platform/wince/FileSystemWince.cpp
deleted file mode 100644
index cb165a6..0000000
--- a/WebCore/platform/wince/FileSystemWince.cpp
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, 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.
- * 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 "FileSystem.h"
-
-#include "NotImplemented.h"
-#include "PlatformString.h"
-#include <wtf/text/CString.h>
-
-#include <windows.h>
-#include <wincrypt.h>
-
-namespace WebCore {
-
-static bool getFileInfo(const String& path, BY_HANDLE_FILE_INFORMATION& fileInfo)
-{
- String filename = path;
- HANDLE hFile = CreateFile(filename.charactersWithNullTermination(), GENERIC_READ, FILE_SHARE_READ, 0
- , OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, 0);
-
- if (hFile == INVALID_HANDLE_VALUE)
- return false;
-
- bool rtn = GetFileInformationByHandle(hFile, &fileInfo) ? true : false;
-
- CloseHandle(hFile);
- return rtn;
-}
-
-bool getFileSize(const String& path, long long& result)
-{
- BY_HANDLE_FILE_INFORMATION fileInformation;
- if (!getFileInfo(path, fileInformation))
- return false;
-
- ULARGE_INTEGER fileSize;
- fileSize.LowPart = fileInformation.nFileSizeLow;
- fileSize.HighPart = fileInformation.nFileSizeHigh;
-
- result = fileSize.QuadPart;
-
- return true;
-}
-
-bool getFileModificationTime(const String& path, time_t& result)
-{
- BY_HANDLE_FILE_INFORMATION fileInformation;
- if (!getFileInfo(path, fileInformation))
- return false;
-
- ULARGE_INTEGER t;
- memcpy(&t, &fileInformation.ftLastWriteTime, sizeof(t));
-
- result = t.QuadPart * 0.0000001 - 11644473600.0;
-
- return true;
-}
-
-bool fileExists(const String& path)
-{
- String filename = path;
- HANDLE hFile = CreateFile(filename.charactersWithNullTermination(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE
- , 0, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, 0);
-
- CloseHandle(hFile);
-
- return hFile != INVALID_HANDLE_VALUE;
-}
-
-bool deleteFile(const String& path)
-{
- String filename = path;
- return !!DeleteFileW(filename.charactersWithNullTermination());
-}
-
-
-bool deleteEmptyDirectory(const String& path)
-{
- String filename = path;
- return !!RemoveDirectoryW(filename.charactersWithNullTermination());
-}
-
-String pathByAppendingComponent(const String& path, const String& component)
-{
- if (component.isEmpty())
- return path;
-
- Vector<UChar, MAX_PATH> buffer;
-
- buffer.append(path.characters(), path.length());
-
- if (buffer.last() != L'\\' && buffer.last() != L'/'
- && component[0] != L'\\' && component[0] != L'/')
- buffer.append(L'\\');
-
- buffer.append(component.characters(), component.length());
-
- return String(buffer.data(), buffer.size());
-}
-
-CString fileSystemRepresentation(const String&)
-{
- return "";
-}
-
-bool makeAllDirectories(const String& path)
-{
- int lastDivPos = std::max(path.reverseFind('/'), path.reverseFind('\\'));
- int endPos = path.length();
- if (lastDivPos == path.length() - 1) {
- endPos -= 1;
- lastDivPos = std::max(path.reverseFind('/', lastDivPos), path.reverseFind('\\', lastDivPos));
- }
-
- if (lastDivPos > 0) {
- if (!makeAllDirectories(path.substring(0, lastDivPos)))
- return false;
- }
-
- String folder(path.substring(0, endPos));
- CreateDirectory(folder.charactersWithNullTermination(), 0);
-
- DWORD fileAttr = GetFileAttributes(folder.charactersWithNullTermination());
- return fileAttr != 0xFFFFFFFF && (fileAttr & FILE_ATTRIBUTE_DIRECTORY);
-}
-
-String homeDirectoryPath()
-{
- notImplemented();
- return "";
-}
-
-String pathGetFileName(const String& path)
-{
- return path.substring(std::max(path.reverseFind('/'), path.reverseFind('\\')) + 1);
-}
-
-String directoryName(const String& path)
-{
- notImplemented();
- return String();
-}
-
-CString openTemporaryFile(const char*, PlatformFileHandle& handle)
-{
- handle = INVALID_HANDLE_VALUE;
-
- wchar_t tempPath[MAX_PATH];
- int tempPathLength = ::GetTempPath(_countof(tempPath), tempPath);
- if (tempPathLength <= 0 || tempPathLength > _countof(tempPath))
- return CString();
-
- HCRYPTPROV hCryptProv = 0;
- if (!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
- return CString();
-
- String proposedPath;
- while (1) {
-
- wchar_t tempFile[] = L"XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names)
- const int randomPartLength = 8;
- if (!CryptGenRandom(hCryptProv, randomPartLength * 2, reinterpret_cast<BYTE*>(tempFile)))
- break;
-
- // Limit to valid filesystem characters, also excluding others that could be problematic, like punctuation.
- // don't include both upper and lowercase since Windows file systems are typically not case sensitive.
- const char validChars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
- for (int i = 0; i < randomPartLength; ++i)
- tempFile[i] = validChars[tempFile[i] % (sizeof(validChars) - 1)];
-
- ASSERT(wcslen(tempFile) * 2 == sizeof(tempFile) - 2);
-
- proposedPath = pathByAppendingComponent(String(tempPath), String(tempFile));
-
- // use CREATE_NEW to avoid overwriting an existing file with the same name
- handle = CreateFile(proposedPath.charactersWithNullTermination(), GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
- if (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS)
- continue;
-
- break;
- }
-
- CryptReleaseContext(hCryptProv, 0);
-
- if (!isHandleValid(handle))
- return CString();
-
- return proposedPath.latin1();
-}
-
-void closeFile(PlatformFileHandle& handle)
-{
- if (isHandleValid(handle)) {
- ::CloseHandle(handle);
- handle = invalidPlatformFileHandle;
- }
-}
-
-int writeToFile(PlatformFileHandle handle, const char* data, int length)
-{
- if (!isHandleValid(handle))
- return -1;
-
- DWORD bytesWritten;
- bool success = WriteFile(handle, data, length, &bytesWritten, 0);
-
- if (!success)
- return -1;
- return static_cast<int>(bytesWritten);
-}
-
-bool unloadModule(PlatformModule module)
-{
- return ::FreeLibrary(module);
-}
-
-String localUserSpecificStorageDirectory()
-{
- return String(L"\\");
-}
-
-String roamingUserSpecificStorageDirectory()
-{
- return String(L"\\");
-}
-
-Vector<String> listDirectory(const String& path, const String& filter)
-{
- Vector<String> entries;
-
- Vector<UChar, 256> pattern;
- pattern.append(path.characters(), path.length());
- if (pattern.last() != L'/' && pattern.last() != L'\\')
- pattern.append(L'\\');
-
- String root(pattern.data(), pattern.size());
- pattern.append(filter.characters(), filter.length());
- pattern.append(0);
-
- WIN32_FIND_DATA findData;
- HANDLE hFind = FindFirstFile(pattern.data(), &findData);
- if (INVALID_HANDLE_VALUE != hFind) {
- do {
- // FIXEME: should we also add the folders? This function
- // is so far only called by PluginDatabase.cpp to list
- // all plugins in a folder, where it's not supposed to list sub-folders.
- if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- entries.append(root + findData.cFileName);
- } while (FindNextFile(hFind, &findData));
- FindClose(hFind);
- }
-
- return entries;
-}
-
-}
diff --git a/WebCore/platform/wince/KURLWinCE.cpp b/WebCore/platform/wince/KURLWinCE.cpp
new file mode 100644
index 0000000..2bbdfe8
--- /dev/null
+++ b/WebCore/platform/wince/KURLWinCE.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2009 Torch Mobile 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 "KURL.h"
+
+namespace WebCore {
+
+String KURL::fileSystemPath() const
+{
+ return path();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/KURLWince.cpp b/WebCore/platform/wince/KURLWince.cpp
deleted file mode 100644
index 5ca1e4b..0000000
--- a/WebCore/platform/wince/KURLWince.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2009 Torch Mobile 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 "KURL.h"
-
-namespace WebCore {
-
-String KURL::fileSystemPath() const
-{
- return path();
-}
-
-}
diff --git a/WebCore/platform/wince/KeygenWince.cpp b/WebCore/platform/wince/KeygenWinCE.cpp
similarity index 100%
rename from WebCore/platform/wince/KeygenWince.cpp
rename to WebCore/platform/wince/KeygenWinCE.cpp
diff --git a/WebCore/platform/wince/MIMETypeRegistryWinCE.cpp b/WebCore/platform/wince/MIMETypeRegistryWinCE.cpp
new file mode 100644
index 0000000..7534b91
--- /dev/null
+++ b/WebCore/platform/wince/MIMETypeRegistryWinCE.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, 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 "MIMETypeRegistry.h"
+
+#include <wtf/HashMap.h>
+#include <windows.h>
+#include <winreg.h>
+
+namespace WebCore {
+
+static String mimeTypeForExtension(const String& extension)
+{
+ String ext = "." + extension;
+ WCHAR contentTypeStr[256];
+ DWORD contentTypeStrLen = sizeof(contentTypeStr);
+ DWORD valueType;
+
+ HKEY key;
+ String result;
+ if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_CLASSES_ROOT, ext.charactersWithNullTermination(), 0, 0, &key))
+ return result;
+
+ if (ERROR_SUCCESS == RegQueryValueEx(key, L"Content Type", 0, &valueType, (LPBYTE)contentTypeStr, &contentTypeStrLen) && valueType == REG_SZ)
+ result = String(contentTypeStr, contentTypeStrLen / sizeof(contentTypeStr[0]) - 1);
+
+ RegCloseKey(key);
+
+ return result;
+}
+
+static HashMap<String, String> mimetypeMap;
+
+static void initMIMETypeEntensionMap()
+{
+ if (mimetypeMap.isEmpty()) {
+ //fill with initial values
+ mimetypeMap.add("txt", "text/plain");
+ mimetypeMap.add("pdf", "application/pdf");
+ mimetypeMap.add("ps", "application/postscript");
+ mimetypeMap.add("html", "text/html");
+ mimetypeMap.add("htm", "text/html");
+ mimetypeMap.add("xml", "text/xml");
+ mimetypeMap.add("xsl", "text/xsl");
+ mimetypeMap.add("js", "application/x-javascript");
+ mimetypeMap.add("xhtml", "application/xhtml+xml");
+ mimetypeMap.add("rss", "application/rss+xml");
+ mimetypeMap.add("webarchive", "application/x-webarchive");
+ mimetypeMap.add("svg", "image/svg+xml");
+ mimetypeMap.add("svgz", "image/svg+xml");
+ mimetypeMap.add("jpg", "image/jpeg");
+ mimetypeMap.add("jpeg", "image/jpeg");
+ mimetypeMap.add("png", "image/png");
+ mimetypeMap.add("tif", "image/tiff");
+ mimetypeMap.add("tiff", "image/tiff");
+ mimetypeMap.add("ico", "image/ico");
+ mimetypeMap.add("cur", "image/ico");
+ mimetypeMap.add("bmp", "image/bmp");
+ mimetypeMap.add("css", "text/css");
+ // FIXME: Custom font works only when MIME is "text/plain"
+ mimetypeMap.add("ttf", "text/plain"); // "font/ttf"
+ mimetypeMap.add("otf", "text/plain"); // "font/otf"
+#if ENABLE(WML)
+ mimetypeMap.add("wml", "text/vnd.wap.wml");
+#endif
+#if ENABLE(WBXML)
+ mimetypeMap.add("wbxml", "application/vnd.wap.wmlc");
+#endif
+ }
+}
+
+String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
+{
+ if (type.isEmpty())
+ return String();
+
+ // Avoid conflicts with "ttf" and "otf"
+ if (equalIgnoringCase(type, "text/plain"))
+ return "txt";
+
+ initMIMETypeEntensionMap();
+
+ for (HashMap<String, String>::iterator i = mimetypeMap.begin(); i != mimetypeMap.end(); ++i) {
+ if (equalIgnoringCase(i->second, type))
+ return i->first;
+ }
+
+#if ENABLE(XHTMLMP)
+ if (equalIgnoringCase("application/vnd.wap.xhtml+xml", type))
+ return String("xml");
+#endif
+
+ return String();
+}
+
+String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
+{
+ if (ext.isEmpty())
+ return String();
+
+ initMIMETypeEntensionMap();
+
+ String result = mimetypeMap.get(ext.lower());
+ if (result.isEmpty()) {
+ result = mimeTypeForExtension(ext);
+ if (!result.isEmpty())
+ mimetypeMap.add(ext, result);
+ }
+ return result.isEmpty() ? "unknown/unknown" : result;
+}
+
+bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&)
+{
+ return false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/MIMETypeRegistryWince.cpp b/WebCore/platform/wince/MIMETypeRegistryWince.cpp
deleted file mode 100644
index 9e1bece..0000000
--- a/WebCore/platform/wince/MIMETypeRegistryWince.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, 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 "MIMETypeRegistry.h"
-
-#include <wtf/HashMap.h>
-#include <windows.h>
-#include <winreg.h>
-
-namespace WebCore {
-
-static String mimeTypeForExtension(const String& extension)
-{
- String ext = "." + extension;
- WCHAR contentTypeStr[256];
- DWORD contentTypeStrLen = sizeof(contentTypeStr);
- DWORD valueType;
-
- HKEY key;
- String result;
- if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_CLASSES_ROOT, ext.charactersWithNullTermination(), 0, 0, &key))
- return result;
-
- if (ERROR_SUCCESS == RegQueryValueEx(key, L"Content Type", 0, &valueType, (LPBYTE)contentTypeStr, &contentTypeStrLen) && valueType == REG_SZ)
- result = String(contentTypeStr, contentTypeStrLen / sizeof(contentTypeStr[0]) - 1);
-
- RegCloseKey(key);
-
- return result;
-}
-
-static HashMap<String, String> mimetypeMap;
-
-static void initMIMETypeEntensionMap()
-{
- if (mimetypeMap.isEmpty()) {
- //fill with initial values
- mimetypeMap.add("txt", "text/plain");
- mimetypeMap.add("pdf", "application/pdf");
- mimetypeMap.add("ps", "application/postscript");
- mimetypeMap.add("html", "text/html");
- mimetypeMap.add("htm", "text/html");
- mimetypeMap.add("xml", "text/xml");
- mimetypeMap.add("xsl", "text/xsl");
- mimetypeMap.add("js", "application/x-javascript");
- mimetypeMap.add("xhtml", "application/xhtml+xml");
- mimetypeMap.add("rss", "application/rss+xml");
- mimetypeMap.add("webarchive", "application/x-webarchive");
- mimetypeMap.add("svg", "image/svg+xml");
- mimetypeMap.add("svgz", "image/svg+xml");
- mimetypeMap.add("jpg", "image/jpeg");
- mimetypeMap.add("jpeg", "image/jpeg");
- mimetypeMap.add("png", "image/png");
- mimetypeMap.add("tif", "image/tiff");
- mimetypeMap.add("tiff", "image/tiff");
- mimetypeMap.add("ico", "image/ico");
- mimetypeMap.add("cur", "image/ico");
- mimetypeMap.add("bmp", "image/bmp");
- mimetypeMap.add("css", "text/css");
- // FIXME: Custom font works only when MIME is "text/plain"
- mimetypeMap.add("ttf", "text/plain"); // "font/ttf"
- mimetypeMap.add("otf", "text/plain"); // "font/otf"
-#if ENABLE(WML)
- mimetypeMap.add("wml", "text/vnd.wap.wml");
-#endif
-#if ENABLE(WBXML)
- mimetypeMap.add("wbxml", "application/vnd.wap.wmlc");
-#endif
- }
-}
-
-String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
-{
- if (type.isEmpty())
- return String();
-
- // Avoid conflicts with "ttf" and "otf"
- if (equalIgnoringCase(type, "text/plain"))
- return "txt";
-
- initMIMETypeEntensionMap();
-
- for (HashMap<String, String>::iterator i = mimetypeMap.begin(); i != mimetypeMap.end(); ++i) {
- if (equalIgnoringCase(i->second, type))
- return i->first;
- }
-
-#if ENABLE(XHTMLMP)
- if (equalIgnoringCase("application/vnd.wap.xhtml+xml", type))
- return String("xml");
-#endif
-
- return String();
-}
-
-String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
-{
- if (ext.isEmpty())
- return String();
-
- initMIMETypeEntensionMap();
-
- String result = mimetypeMap.get(ext.lower());
- if (result.isEmpty()) {
- result = mimeTypeForExtension(ext);
- if (!result.isEmpty())
- mimetypeMap.add(ext, result);
- }
- return result.isEmpty() ? "unknown/unknown" : result;
-}
-
-bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&)
-{
- return false;
-}
-
-}
diff --git a/WebCore/platform/wince/PasteboardWince.cpp b/WebCore/platform/wince/PasteboardWinCE.cpp
similarity index 100%
rename from WebCore/platform/wince/PasteboardWince.cpp
rename to WebCore/platform/wince/PasteboardWinCE.cpp
diff --git a/WebCore/platform/wince/SearchPopupMenuWinCE.cpp b/WebCore/platform/wince/SearchPopupMenuWinCE.cpp
new file mode 100644
index 0000000..b2a8442
--- /dev/null
+++ b/WebCore/platform/wince/SearchPopupMenuWinCE.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2009 Torch Mobile 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 "SearchPopupMenu.h"
+
+#include "NotImplemented.h"
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
+: PopupMenu(client)
+{
+}
+
+bool SearchPopupMenu::enabled()
+{
+ return false;
+}
+
+void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
+{
+ if (name.isEmpty())
+ return;
+
+ notImplemented();
+}
+
+void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
+{
+ if (name.isEmpty())
+ return;
+
+ notImplemented();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/SearchPopupMenuWince.cpp b/WebCore/platform/wince/SearchPopupMenuWince.cpp
deleted file mode 100644
index f9d65a6..0000000
--- a/WebCore/platform/wince/SearchPopupMenuWince.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2009 Torch Mobile 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 "SearchPopupMenu.h"
-
-#include "NotImplemented.h"
-#include <wtf/text/AtomicString.h>
-
-namespace WebCore {
-
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
-: PopupMenu(client)
-{
-}
-
-bool SearchPopupMenu::enabled()
-{
- return false;
-}
-
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
- notImplemented();
-}
-
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
- notImplemented();
-}
-
-}
diff --git a/WebCore/platform/wince/SharedTimerWinCE.cpp b/WebCore/platform/wince/SharedTimerWinCE.cpp
new file mode 100644
index 0000000..81295e2
--- /dev/null
+++ b/WebCore/platform/wince/SharedTimerWinCE.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2007-2008 Torch Mobile, 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 "SharedTimer.h"
+
+#include "Page.h"
+#include "SystemTime.h"
+#include "WebCoreInstanceHandle.h"
+#include "Widget.h"
+#include <wtf/Assertions.h>
+#include <wtf/CurrentTime.h>
+#include <windows.h>
+
+namespace JSC {
+JS_EXPORTDATA extern void* g_stackBase;
+}
+
+namespace WebCore {
+
+enum {
+ TimerIdNone = 0,
+ TimerIdAuto,
+ TimerIdManual,
+};
+static UINT timerID = TimerIdNone;
+
+static void (*sharedTimerFiredFunction)();
+
+static HWND timerWindowHandle = 0;
+const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
+
+LRESULT CALLBACK TimerWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int dummy;
+ JSC::g_stackBase = &dummy;
+
+ if (message == WM_TIMER) {
+ if (timerID != TimerIdNone)
+ sharedTimerFiredFunction();
+ } else if (message == WM_USER) {
+ if (timerID = TimerIdManual) {
+ sharedTimerFiredFunction();
+ PostMessage(hWnd, WM_USER, 0, 0);
+ }
+ } else {
+ JSC::g_stackBase = 0;
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ JSC::g_stackBase = 0;
+ return 0;
+}
+
+static void initializeOffScreenTimerWindow()
+{
+ if (timerWindowHandle)
+ return;
+
+ WNDCLASS wcex = {0};
+ wcex.lpfnWndProc = TimerWindowWndProc;
+ wcex.hInstance = WebCore::instanceHandle();
+ wcex.lpszClassName = kTimerWindowClassName;
+ RegisterClass(&wcex);
+
+ timerWindowHandle = CreateWindow(kTimerWindowClassName, 0, 0,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, WebCore::instanceHandle(), 0);
+}
+
+void setSharedTimerFiredFunction(void (*f)())
+{
+ sharedTimerFiredFunction = f;
+}
+
+#define USER_TIMER_MAXIMUM 0x7FFFFFFF
+#define USER_TIMER_MINIMUM 0x0000000A
+
+void setSharedTimerFireTime(double fireTime)
+{
+ ASSERT(sharedTimerFiredFunction);
+
+ double interval = (fireTime - currentTime()) * 1000.;
+ unsigned intervalInMS = interval < USER_TIMER_MINIMUM
+ ? USER_TIMER_MINIMUM
+ : interval > USER_TIMER_MAXIMUM
+ ? USER_TIMER_MAXIMUM
+ : static_cast<unsigned>(interval);
+
+ if (timerID == TimerIdAuto) {
+ KillTimer(timerWindowHandle, TimerIdAuto);
+ timerID = TimerIdNone;
+ }
+
+ initializeOffScreenTimerWindow();
+ if (SetTimer(timerWindowHandle, TimerIdAuto, intervalInMS, 0))
+ timerID = TimerIdAuto;
+ else if (timerID != TimerIdManual)
+ PostMessage(timerWindowHandle, WM_USER, 0, 0);
+}
+
+void stopSharedTimer()
+{
+ if (timerID == TimerIdAuto)
+ KillTimer(timerWindowHandle, TimerIdAuto);
+
+ timerID = TimerIdNone;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/wince/SharedTimerWince.cpp b/WebCore/platform/wince/SharedTimerWince.cpp
deleted file mode 100644
index 2328017..0000000
--- a/WebCore/platform/wince/SharedTimerWince.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007-2008 Torch Mobile, 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 "SharedTimer.h"
-
-#include "Page.h"
-#include "SystemTime.h"
-#include "WebCoreInstanceHandle.h"
-#include "Widget.h"
-#include <wtf/Assertions.h>
-#include <wtf/CurrentTime.h>
-#include <windows.h>
-
-namespace JSC {
-JS_EXPORTDATA extern void* g_stackBase;
-}
-
-namespace WebCore {
-
-enum {
- TimerIdNone = 0,
- TimerIdAuto,
- TimerIdManual,
-};
-static UINT timerID = TimerIdNone;
-
-static void (*sharedTimerFiredFunction)();
-
-static HWND timerWindowHandle = 0;
-const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
-
-LRESULT CALLBACK TimerWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- int dummy;
- JSC::g_stackBase = &dummy;
-
- if (message == WM_TIMER) {
- if (timerID != TimerIdNone)
- sharedTimerFiredFunction();
- } else if (message == WM_USER) {
- if (timerID = TimerIdManual) {
- sharedTimerFiredFunction();
- PostMessage(hWnd, WM_USER, 0, 0);
- }
- } else {
- JSC::g_stackBase = 0;
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- JSC::g_stackBase = 0;
- return 0;
-}
-
-static void initializeOffScreenTimerWindow()
-{
- if (timerWindowHandle)
- return;
-
- WNDCLASS wcex = {0};
- wcex.lpfnWndProc = TimerWindowWndProc;
- wcex.hInstance = WebCore::instanceHandle();
- wcex.lpszClassName = kTimerWindowClassName;
- RegisterClass(&wcex);
-
- timerWindowHandle = CreateWindow(kTimerWindowClassName, 0, 0,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, WebCore::instanceHandle(), 0);
-}
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- sharedTimerFiredFunction = f;
-}
-
-#define USER_TIMER_MAXIMUM 0x7FFFFFFF
-#define USER_TIMER_MINIMUM 0x0000000A
-
-void setSharedTimerFireTime(double fireTime)
-{
- ASSERT(sharedTimerFiredFunction);
-
- double interval = (fireTime - currentTime()) * 1000.;
- unsigned intervalInMS = interval < USER_TIMER_MINIMUM
- ? USER_TIMER_MINIMUM
- : interval > USER_TIMER_MAXIMUM
- ? USER_TIMER_MAXIMUM
- : static_cast<unsigned>(interval);
-
- if (timerID == TimerIdAuto) {
- KillTimer(timerWindowHandle, TimerIdAuto);
- timerID = TimerIdNone;
- }
-
- initializeOffScreenTimerWindow();
- if (SetTimer(timerWindowHandle, TimerIdAuto, intervalInMS, 0))
- timerID = TimerIdAuto;
- else if (timerID != TimerIdManual)
- PostMessage(timerWindowHandle, WM_USER, 0, 0);
-}
-
-void stopSharedTimer()
-{
- if (timerID == TimerIdAuto)
- KillTimer(timerWindowHandle, TimerIdAuto);
-
- timerID = TimerIdNone;
-}
-
-}
diff --git a/WebCore/rendering/RenderThemeWinCE.cpp b/WebCore/rendering/RenderThemeWinCE.cpp
new file mode 100644
index 0000000..66cda11
--- /dev/null
+++ b/WebCore/rendering/RenderThemeWinCE.cpp
@@ -0,0 +1,647 @@
+/*
+ * This file is part of the WebKit project.
+ *
+ * Copyright (C) 2006, 2007 Apple Computer, Inc.
+ * Copyright (C) 2007-2009 Torch Mobile, 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 "RenderThemeWinCE.h"
+
+#include "CSSStyleSheet.h"
+#include "CSSValueKeywords.h"
+#include "Document.h"
+#include "GraphicsContext.h"
+#include "NotImplemented.h"
+#if ENABLE(VIDEO)
+#include "HTMLMediaElement.h"
+#endif
+
+#include <windows.h>
+
+/*
+ * The following constants are used to determine how a widget is drawn using
+ * Windows' Theme API. For more information on theme parts and states see
+ * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/topics/partsandstates.asp
+ */
+#define THEME_COLOR 204
+#define THEME_FONT 210
+
+// Generic state constants
+#define TS_NORMAL 1
+#define TS_HOVER 2
+#define TS_ACTIVE 3
+#define TS_DISABLED 4
+#define TS_FOCUSED 5
+
+// Button constants
+#define BP_BUTTON 1
+#define BP_RADIO 2
+#define BP_CHECKBOX 3
+
+// Textfield constants
+#define TFP_TEXTFIELD 1
+#define TFS_READONLY 6
+
+typedef HANDLE (WINAPI*openThemeDataPtr)(HWND hwnd, LPCWSTR pszClassList);
+typedef HRESULT (WINAPI*closeThemeDataPtr)(HANDLE hTheme);
+typedef HRESULT (WINAPI*drawThemeBackgroundPtr)(HANDLE hTheme, HDC hdc, int iPartId,
+ int iStateId, const RECT *pRect,
+ const RECT* pClipRect);
+typedef HRESULT (WINAPI*drawThemeEdgePtr)(HANDLE hTheme, HDC hdc, int iPartId,
+ int iStateId, const RECT *pRect,
+ unsigned uEdge, unsigned uFlags,
+ const RECT* pClipRect);
+typedef HRESULT (WINAPI*getThemeContentRectPtr)(HANDLE hTheme, HDC hdc, int iPartId,
+ int iStateId, const RECT* pRect,
+ RECT* pContentRect);
+typedef HRESULT (WINAPI*getThemePartSizePtr)(HANDLE hTheme, HDC hdc, int iPartId,
+ int iStateId, RECT* prc, int ts,
+ SIZE* psz);
+typedef HRESULT (WINAPI*getThemeSysFontPtr)(HANDLE hTheme, int iFontId, OUT LOGFONT* pFont);
+typedef HRESULT (WINAPI*getThemeColorPtr)(HANDLE hTheme, HDC hdc, int iPartId,
+ int iStateId, int iPropId, OUT COLORREF* pFont);
+
+namespace WebCore {
+
+static const int dropDownButtonWidth = 17;
+static const int trackWidth = 4;
+
+PassRefPtr<RenderTheme> RenderThemeWinCE::create()
+{
+ return adoptRef(new RenderThemeWinCE);
+}
+
+PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page)
+{
+ static RenderTheme* winceTheme = RenderThemeWinCE::create().releaseRef();
+ return winceTheme;
+}
+
+RenderThemeWinCE::RenderThemeWinCE()
+{
+}
+
+RenderThemeWinCE::~RenderThemeWinCE()
+{
+}
+
+Color RenderThemeWinCE::platformActiveSelectionBackgroundColor() const
+{
+ COLORREF color = GetSysColor(COLOR_HIGHLIGHT);
+ return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
+}
+
+Color RenderThemeWinCE::platformInactiveSelectionBackgroundColor() const
+{
+ COLORREF color = GetSysColor(COLOR_GRAYTEXT);
+ return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
+}
+
+Color RenderThemeWinCE::platformActiveSelectionForegroundColor() const
+{
+ COLORREF color = GetSysColor(COLOR_HIGHLIGHTTEXT);
+ return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
+}
+
+Color RenderThemeWinCE::platformInactiveSelectionForegroundColor() const
+{
+ return Color::white;
+}
+
+bool RenderThemeWinCE::supportsFocus(ControlPart appearance) const
+{
+ switch (appearance) {
+ case PushButtonPart:
+ case ButtonPart:
+ case TextFieldPart:
+ case TextAreaPart:
+ return true;
+ default:
+ return false;
+ }
+
+ return false;
+}
+
+bool RenderThemeWinCE::supportsFocusRing(const RenderStyle *style) const
+{
+ return supportsFocus(style->appearance());
+}
+
+unsigned RenderThemeWinCE::determineClassicState(RenderObject* o)
+{
+ unsigned result = 0;
+ if (!isEnabled(o) || isReadOnlyControl(o))
+ result = DFCS_INACTIVE;
+ else if (isPressed(o)) // Active supersedes hover
+ result = DFCS_PUSHED;
+
+ if (isChecked(o))
+ result |= DFCS_CHECKED;
+ return result;
+}
+
+ThemeData RenderThemeWinCE::getThemeData(RenderObject* o)
+{
+ ThemeData result;
+ switch (o->style()->appearance()) {
+ case PushButtonPart:
+ case ButtonPart:
+ result.m_part = BP_BUTTON;
+ result.m_classicState = DFCS_BUTTONPUSH;
+ break;
+ case CheckboxPart:
+ result.m_part = BP_CHECKBOX;
+ result.m_classicState = DFCS_BUTTONCHECK;
+ break;
+ case RadioPart:
+ result.m_part = BP_RADIO;
+ result.m_classicState = DFCS_BUTTONRADIO;
+ break;
+ case ListboxPart:
+ case MenulistPart:
+ case TextFieldPart:
+ case TextAreaPart:
+ result.m_part = TFP_TEXTFIELD;
+ break;
+ }
+
+ result.m_classicState |= determineClassicState(o);
+
+ return result;
+}
+
+bool RenderThemeWinCE::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ // Get the correct theme data for a button
+ ThemeData themeData = getThemeData(o);
+
+ // Now paint the button.
+ i.context->drawFrameControl(r, DFC_BUTTON, themeData.m_classicState);
+ if (isFocused(o)) {
+ if (themeData.m_part == BP_BUTTON) {
+ IntRect focusRect(r);
+ focusRect.inflate(-2);
+ i.context->drawFocusRect(focusRect);
+ } else
+ i.context->drawFocusRect(r);
+ }
+
+ return false;
+}
+
+void RenderThemeWinCE::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.
+ if (style->width().isIntrinsicOrAuto())
+ style->setWidth(Length(13, Fixed));
+ if (style->height().isAuto())
+ style->setHeight(Length(13, Fixed));
+}
+
+bool RenderThemeWinCE::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ // Get the correct theme data for a textfield
+ ThemeData themeData = getThemeData(o);
+
+ // Now paint the text field.
+ i.context->paintTextField(r, themeData.m_classicState);
+
+ return false;
+}
+
+void RenderThemeWinCE::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ style->resetBorder();
+ adjustMenuListButtonStyle(selector, style, e);
+}
+
+bool RenderThemeWinCE::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ paintTextField(o, i, r);
+ paintMenuListButton(o, i, r);
+ return true;
+}
+
+bool RenderThemeWinCE::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ IntRect buttonRect(r.right() - dropDownButtonWidth - 1, r.y(), dropDownButtonWidth, r.height());
+ buttonRect.inflateY(-1);
+ i.context->drawFrameControl(buttonRect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | determineClassicState(o));
+ return true;
+}
+
+void RenderThemeWinCE::systemFont(int propId, FontDescription& fontDescription) const
+{
+ notImplemented();
+}
+
+void RenderThemeWinCE::themeChanged()
+{
+}
+
+String RenderThemeWinCE::extraDefaultStyleSheet()
+{
+ notImplemented();
+ return String();
+}
+
+String RenderThemeWinCE::extraQuirksStyleSheet()
+{
+ notImplemented();
+ return String();
+}
+
+bool RenderThemeWinCE::supportsHover(const RenderStyle*) const
+{
+ return false;
+}
+
+// Map a CSSValue* system color to an index understood by GetSysColor
+static int cssValueIdToSysColorIndex(int cssValueId)
+{
+ switch (cssValueId) {
+ case CSSValueActiveborder: return COLOR_ACTIVEBORDER;
+ case CSSValueActivecaption: return COLOR_ACTIVECAPTION;
+ case CSSValueAppworkspace: return COLOR_APPWORKSPACE;
+ case CSSValueBackground: return COLOR_BACKGROUND;
+ case CSSValueButtonface: return COLOR_BTNFACE;
+ case CSSValueButtonhighlight: return COLOR_BTNHIGHLIGHT;
+ case CSSValueButtonshadow: return COLOR_BTNSHADOW;
+ case CSSValueButtontext: return COLOR_BTNTEXT;
+ case CSSValueCaptiontext: return COLOR_CAPTIONTEXT;
+ case CSSValueGraytext: return COLOR_GRAYTEXT;
+ case CSSValueHighlight: return COLOR_HIGHLIGHT;
+ case CSSValueHighlighttext: return COLOR_HIGHLIGHTTEXT;
+ case CSSValueInactiveborder: return COLOR_INACTIVEBORDER;
+ case CSSValueInactivecaption: return COLOR_INACTIVECAPTION;
+ case CSSValueInactivecaptiontext: return COLOR_INACTIVECAPTIONTEXT;
+ case CSSValueInfobackground: return COLOR_INFOBK;
+ case CSSValueInfotext: return COLOR_INFOTEXT;
+ case CSSValueMenu: return COLOR_MENU;
+ case CSSValueMenutext: return COLOR_MENUTEXT;
+ case CSSValueScrollbar: return COLOR_SCROLLBAR;
+ case CSSValueThreeddarkshadow: return COLOR_3DDKSHADOW;
+ case CSSValueThreedface: return COLOR_3DFACE;
+ case CSSValueThreedhighlight: return COLOR_3DHIGHLIGHT;
+ case CSSValueThreedlightshadow: return COLOR_3DLIGHT;
+ case CSSValueThreedshadow: return COLOR_3DSHADOW;
+ case CSSValueWindow: return COLOR_WINDOW;
+ case CSSValueWindowframe: return COLOR_WINDOWFRAME;
+ case CSSValueWindowtext: return COLOR_WINDOWTEXT;
+ default: return -1; // Unsupported CSSValue
+ }
+}
+
+Color RenderThemeWinCE::systemColor(int cssValueId) const
+{
+ int sysColorIndex = cssValueIdToSysColorIndex(cssValueId);
+ if (sysColorIndex == -1)
+ return RenderTheme::systemColor(cssValueId);
+
+ COLORREF color = GetSysColor(sysColorIndex);
+ return Color(GetRValue(color), GetGValue(color), GetBValue(color));
+}
+
+const int sliderThumbWidth = 7;
+const int sliderThumbHeight = 15;
+
+void RenderThemeWinCE::adjustSliderThumbSize(RenderObject* o) const
+{
+ if (o->style()->appearance() == SliderThumbVerticalPart) {
+ o->style()->setWidth(Length(sliderThumbHeight, Fixed));
+ o->style()->setHeight(Length(sliderThumbWidth, Fixed));
+ } else if (o->style()->appearance() == SliderThumbHorizontalPart) {
+ o->style()->setWidth(Length(sliderThumbWidth, Fixed));
+ o->style()->setHeight(Length(sliderThumbHeight, Fixed));
+ }
+}
+
+#if 0
+void RenderThemeWinCE::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));
+}
+
+void RenderThemeWinCE::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ // Override padding size to match AppKit text positioning.
+ const int padding = 1;
+ style->setPaddingLeft(Length(padding, Fixed));
+ style->setPaddingRight(Length(padding, Fixed));
+ style->setPaddingTop(Length(padding, Fixed));
+ style->setPaddingBottom(Length(padding, Fixed));
+}
+#endif
+
+bool RenderThemeWinCE::paintSearchField(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ return paintTextField(o, i, r);
+}
+
+bool RenderThemeWinCE::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ Color buttonColor = (o->node() && o->node()->active()) ? Color(138, 138, 138) : Color(186, 186, 186);
+
+ IntSize cancelSize(10, 10);
+ IntSize cancelRadius(cancelSize.width() / 2, cancelSize.height() / 2);
+ int x = r.x() + (r.width() - cancelSize.width()) / 2;
+ int y = r.y() + (r.height() - cancelSize.height()) / 2 + 1;
+ IntRect cancelBounds(IntPoint(x, y), cancelSize);
+ paintInfo.context->save();
+ paintInfo.context->addRoundedRectClip(cancelBounds, cancelRadius, cancelRadius, cancelRadius, cancelRadius);
+ paintInfo.context->fillRect(cancelBounds, buttonColor, DeviceColorSpace);
+
+ // Draw the 'x'
+ IntSize xSize(3, 3);
+ IntRect xBounds(cancelBounds.location() + IntSize(3, 3), xSize);
+ paintInfo.context->setStrokeColor(Color::white, DeviceColorSpace);
+ paintInfo.context->drawLine(xBounds.location(), xBounds.location() + xBounds.size());
+ paintInfo.context->drawLine(IntPoint(xBounds.right(), xBounds.y()), IntPoint(xBounds.x(), xBounds.bottom()));
+
+ paintInfo.context->restore();
+ return false;
+}
+
+void RenderThemeWinCE::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ IntSize cancelSize(13, 11);
+ style->setWidth(Length(cancelSize.width(), Fixed));
+ style->setHeight(Length(cancelSize.height(), Fixed));
+}
+
+void RenderThemeWinCE::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ IntSize emptySize(1, 11);
+ style->setWidth(Length(emptySize.width(), Fixed));
+ style->setHeight(Length(emptySize.height(), Fixed));
+}
+
+void RenderThemeWinCE::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ IntSize magnifierSize(15, 11);
+ style->setWidth(Length(magnifierSize.width(), Fixed));
+ style->setHeight(Length(magnifierSize.height(), Fixed));
+}
+
+bool RenderThemeWinCE::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ notImplemented();
+ return false;
+}
+
+void RenderThemeWinCE::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ IntSize magnifierSize(15, 11);
+ style->setWidth(Length(magnifierSize.width(), Fixed));
+ style->setHeight(Length(magnifierSize.height(), Fixed));
+}
+
+bool RenderThemeWinCE::paintSearchFieldResultsButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ paintSearchFieldResultsDecoration(o, paintInfo, r);
+ return false;
+}
+
+void RenderThemeWinCE::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ // These are the paddings needed to place the text correctly in the <select> box
+ const int dropDownBoxPaddingTop = 2;
+ const int dropDownBoxPaddingRight = style->direction() == LTR ? 4 + dropDownButtonWidth : 4;
+ const int dropDownBoxPaddingBottom = 2;
+ const int dropDownBoxPaddingLeft = style->direction() == LTR ? 4 : 4 + dropDownButtonWidth;
+ // The <select> box must be at least 12px high for the button to render nicely on Windows
+ const int dropDownBoxMinHeight = 12;
+
+ // Position the text correctly within the select box and make the box wide enough to fit the dropdown button
+ style->setPaddingTop(Length(dropDownBoxPaddingTop, Fixed));
+ style->setPaddingRight(Length(dropDownBoxPaddingRight, Fixed));
+ style->setPaddingBottom(Length(dropDownBoxPaddingBottom, Fixed));
+ style->setPaddingLeft(Length(dropDownBoxPaddingLeft, Fixed));
+
+ // Height is locked to auto
+ style->setHeight(Length(Auto));
+
+ // Calculate our min-height
+ int minHeight = style->font().height();
+ minHeight = max(minHeight, dropDownBoxMinHeight);
+
+ style->setMinHeight(Length(minHeight, Fixed));
+
+ // White-space is locked to pre
+ style->setWhiteSpace(PRE);
+
+ DWORD colorMenu = GetSysColor(COLOR_MENU);
+ DWORD colorMenuText = GetSysColor(COLOR_MENUTEXT);
+ Color bgColor(GetRValue(colorMenu), GetGValue(colorMenu), GetBValue(colorMenu), 255);
+ Color textColor(GetRValue(colorMenuText), GetGValue(colorMenuText), GetBValue(colorMenuText), 255);
+ if (bgColor == textColor)
+ textColor.setRGB((~bgColor.rgb()) | 0xFF000000);
+ style->clearBackgroundLayers();
+ style->accessBackgroundLayers()->setClip(ContentFillBox);
+ style->setBackgroundColor(bgColor);
+ style->setColor(textColor);
+}
+
+#if ENABLE(VIDEO)
+// Attempt to retrieve a HTMLMediaElement from a Node. Returns 0 if one cannot be found.
+static HTMLMediaElement* mediaElementParent(Node* node)
+{
+ if (!node)
+ return 0;
+ Node* mediaNode = node->shadowAncestorNode();
+ if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag)))
+ return 0;
+
+ return static_cast<HTMLMediaElement*>(mediaNode);
+}
+#endif
+
+bool RenderThemeWinCE::paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ bool rc = RenderTheme::paintSliderTrack(o, i, r);
+ IntPoint left = IntPoint(r.x() + 2, (r.y() + r.bottom()) / 2);
+ i.context->save();
+ i.context->setStrokeColor(Color::gray, DeviceColorSpace);
+ i.context->setFillColor(Color::gray, DeviceColorSpace);
+ i.context->fillRect(r);
+#if ENABLE(VIDEO)
+ HTMLMediaElement* mediaElement = mediaElementParent(o->node());
+ if (mediaElement) {
+ i.context->setStrokeColor(Color(0, 0xff, 0));
+ IntPoint right = IntPoint(left.x() + mediaElement->percentLoaded() * (r.right() - r.x() - 4), (r.y() + r.bottom()) / 2);
+ i.context->drawLine(left, right);
+ left = right;
+ }
+#endif
+ i.context->setStrokeColor(Color::black, DeviceColorSpace);
+ i.context->drawLine(left, IntPoint(r.right() - 2, left.y()));
+ i.context->restore();
+ return rc;
+}
+
+bool RenderThemeWinCE::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ bool rc = RenderTheme::paintSliderThumb(o, i, r);
+ i.context->save();
+ i.context->setStrokeColor(Color::black, DeviceColorSpace);
+ i.context->setFillColor(Color::black, DeviceColorSpace);
+#if ENABLE(VIDEO)
+ HTMLMediaElement* mediaElement = mediaElementParent(o->node());
+ if (mediaElement) {
+ float pt = (mediaElement->currentTime() - mediaElement->startTime()) / mediaElement->duration();
+ FloatRect intRect = r;
+ intRect.setX(intRect.x() + intRect.width() * pt - 2);
+ intRect.setWidth(5);
+ i.context->fillRect(intRect);
+ }
+#endif
+ i.context->restore();
+ return rc;
+}
+
+void RenderThemeWinCE::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ const int padding = 1;
+ style->setPaddingLeft(Length(padding, Fixed));
+ style->setPaddingRight(Length(padding, Fixed));
+ style->setPaddingTop(Length(padding, Fixed));
+ style->setPaddingBottom(Length(padding, Fixed));
+}
+
+#if ENABLE(VIDEO)
+
+bool RenderThemeWinCE::paintMediaFullscreenButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ bool rc = paintButton(o, paintInfo, r);
+ FloatRect imRect = r;
+ imRect.inflate(-2);
+ paintInfo.context->save();
+ paintInfo.context->setStrokeColor(Color::black);
+ paintInfo.context->setFillColor(Color::gray);
+ paintInfo.context->fillRect(imRect);
+ paintInfo.context->restore();
+ return rc;
+}
+
+bool RenderThemeWinCE::paintMediaMuteButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ bool rc = paintButton(o, paintInfo, r);
+ HTMLMediaElement* mediaElement = mediaElementParent(o->node());
+ bool muted = !mediaElement || mediaElement->muted();
+ FloatRect imRect = r;
+ imRect.inflate(-2);
+ paintInfo.context->save();
+ paintInfo.context->setStrokeColor(Color::black);
+ paintInfo.context->setFillColor(Color::black);
+ FloatPoint pts[6] = {
+ FloatPoint(imRect.x() + 1, imRect.y() + imRect.height() / 3.0),
+ FloatPoint(imRect.x() + 1 + imRect.width() / 2.0, imRect.y() + imRect.height() / 3.0),
+ FloatPoint(imRect.right() - 1, imRect.y()),
+ FloatPoint(imRect.right() - 1, imRect.bottom()),
+ FloatPoint(imRect.x() + 1 + imRect.width() / 2.0, imRect.y() + 2.0 * imRect.height() / 3.0),
+ FloatPoint(imRect.x() + 1, imRect.y() + 2.0 * imRect.height() / 3.0)
+ };
+ paintInfo.context->drawConvexPolygon(6, pts);
+ if (muted)
+ paintInfo.context->drawLine(IntPoint(imRect.right(), imRect.y()), IntPoint(imRect.x(), imRect.bottom()));
+ paintInfo.context->restore();
+ return rc;
+}
+
+bool RenderThemeWinCE::paintMediaPlayButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ bool rc = paintButton(o, paintInfo, r);
+ FloatRect imRect = r;
+ imRect.inflate(-3);
+ paintInfo.context->save();
+ paintInfo.context->setStrokeColor(Color::black);
+ paintInfo.context->setFillColor(Color::black);
+ HTMLMediaElement* mediaElement = mediaElementParent(o->node());
+ bool paused = !mediaElement || mediaElement->paused();
+ if (paused) {
+ float width = imRect.width();
+ imRect.setWidth(width / 3.0);
+ paintInfo.context->fillRect(imRect);
+ imRect.move(2.0 * width / 3.0, 0);
+ paintInfo.context->fillRect(imRect);
+ } else {
+ FloatPoint pts[3] = { FloatPoint(imRect.x(), imRect.y()), FloatPoint(imRect.right(), (imRect.y() + imRect.bottom()) / 2.0), FloatPoint(imRect.x(), imRect.bottom()) };
+ paintInfo.context->drawConvexPolygon(3, pts);
+ }
+ paintInfo.context->restore();
+ return rc;
+}
+
+bool RenderThemeWinCE::paintMediaSeekBackButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ bool rc = paintButton(o, paintInfo, r);
+ FloatRect imRect = r;
+ imRect.inflate(-3);
+ FloatPoint pts[3] = { FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.y()), FloatPoint(imRect.x(), (imRect.y() + imRect.bottom()) / 2.0), FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.bottom()) };
+ FloatPoint pts2[3] = { FloatPoint(imRect.right(), imRect.y()), FloatPoint((imRect.x() + imRect.right()) / 2.0, (imRect.y() + imRect.bottom()) / 2.0), FloatPoint(imRect.right(), imRect.bottom()) };
+ paintInfo.context->save();
+ paintInfo.context->setStrokeColor(Color::black);
+ paintInfo.context->setFillColor(Color::black);
+ paintInfo.context->drawConvexPolygon(3, pts);
+ paintInfo.context->drawConvexPolygon(3, pts2);
+ paintInfo.context->restore();
+ return rc;
+}
+
+bool RenderThemeWinCE::paintMediaSeekForwardButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ bool rc = paintButton(o, paintInfo, r);
+ FloatRect imRect = r;
+ imRect.inflate(-3);
+ FloatPoint pts[3] = { FloatPoint(imRect.x(), imRect.y()), FloatPoint((imRect.x() + imRect.right()) / 2.0, (imRect.y() + imRect.bottom()) / 2.0), FloatPoint(imRect.x(), imRect.bottom()) };
+ FloatPoint pts2[3] = { FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.y()), FloatPoint(imRect.right(), (imRect.y() + imRect.bottom()) / 2.0), FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.bottom()) };
+ paintInfo.context->save();
+ paintInfo.context->setStrokeColor(Color::black);
+ paintInfo.context->setFillColor(Color::black);
+ paintInfo.context->drawConvexPolygon(3, pts);
+ paintInfo.context->drawConvexPolygon(3, pts2);
+ paintInfo.context->restore();
+ return rc;
+}
+
+bool RenderThemeWinCE::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ return paintSliderTrack(o, paintInfo, r);
+}
+
+bool RenderThemeWinCE::paintMediaSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+ return paintSliderThumb(o, paintInfo, r);
+}
+#endif
+
+} // namespace WebCore
diff --git a/WebCore/rendering/RenderThemeWinCE.h b/WebCore/rendering/RenderThemeWinCE.h
new file mode 100644
index 0000000..14a5b12
--- /dev/null
+++ b/WebCore/rendering/RenderThemeWinCE.h
@@ -0,0 +1,142 @@
+/*
+ * This file is part of the WebKit project.
+ *
+ * Copyright (C) 2006, 2008 Apple Computer, Inc.
+ * Copyright (C) 2009 Torch Mobile, 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 RenderThemeWinCE_h
+#define RenderThemeWinCE_h
+
+#include "RenderTheme.h"
+
+typedef void* HANDLE;
+typedef struct HINSTANCE__* HINSTANCE;
+typedef HINSTANCE HMODULE;
+
+namespace WebCore {
+
+ struct ThemeData {
+ ThemeData() :m_part(0), m_state(0), m_classicState(0) {}
+ ThemeData(int part, int state)
+ : m_part(part)
+ , m_state(state)
+ , m_classicState(0)
+ { }
+
+ unsigned m_part;
+ unsigned m_state;
+ unsigned m_classicState;
+ };
+
+ class RenderThemeWinCE : public RenderTheme {
+ public:
+ static PassRefPtr<RenderTheme> create();
+ ~RenderThemeWinCE();
+
+ 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;
+
+ virtual Color platformActiveSelectionBackgroundColor() const;
+ virtual Color platformInactiveSelectionBackgroundColor() const;
+ virtual Color platformActiveSelectionForegroundColor() const;
+ virtual Color platformInactiveSelectionForegroundColor() const;
+
+ // System fonts.
+ virtual void systemFont(int propId, FontDescription&) const;
+ virtual Color systemColor(int cssValueId) const;
+
+ virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r)
+ { return paintButton(o, i, r); }
+ virtual void setCheckboxSize(RenderStyle*) const;
+
+ virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r)
+ { return paintButton(o, i, r); }
+ virtual void setRadioSize(RenderStyle* style) const
+ { return setCheckboxSize(style); }
+
+ virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual bool paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
+ { return paintTextField(o, i, r); }
+
+ virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
+ virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
+
+ virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual bool paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r);
+ virtual bool paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r);
+ virtual void adjustSliderThumbSize(RenderObject*) const;
+
+ virtual bool popupOptionSupportsTextIndent() const { return true; }
+
+ virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return false; }
+
+ virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual void themeChanged();
+
+ virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
+ virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
+ virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
+
+ static void setWebKitIsBeingUnloaded();
+
+ virtual bool supportsFocusRing(const RenderStyle*) const;
+
+ #if ENABLE(VIDEO)
+ virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
+ #endif
+
+ private:
+ RenderThemeWinCE();
+
+ unsigned determineClassicState(RenderObject*);
+ bool supportsFocus(ControlPart) const;
+
+ ThemeData getThemeData(RenderObject*);
+ };
+
+};
+
+#endif // RenderThemeWinCE_h
diff --git a/WebCore/rendering/RenderThemeWince.cpp b/WebCore/rendering/RenderThemeWince.cpp
deleted file mode 100644
index 117601b..0000000
--- a/WebCore/rendering/RenderThemeWince.cpp
+++ /dev/null
@@ -1,647 +0,0 @@
-/*
- * This file is part of the WebKit project.
- *
- * Copyright (C) 2006, 2007 Apple Computer, Inc.
- * Copyright (C) 2007-2009 Torch Mobile, 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 "RenderThemeWince.h"
-
-#include "CSSStyleSheet.h"
-#include "CSSValueKeywords.h"
-#include "Document.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#if ENABLE(VIDEO)
-#include "HTMLMediaElement.h"
-#endif
-
-#include <windows.h>
-
-/*
- * The following constants are used to determine how a widget is drawn using
- * Windows' Theme API. For more information on theme parts and states see
- * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/topics/partsandstates.asp
- */
-#define THEME_COLOR 204
-#define THEME_FONT 210
-
-// Generic state constants
-#define TS_NORMAL 1
-#define TS_HOVER 2
-#define TS_ACTIVE 3
-#define TS_DISABLED 4
-#define TS_FOCUSED 5
-
-// Button constants
-#define BP_BUTTON 1
-#define BP_RADIO 2
-#define BP_CHECKBOX 3
-
-// Textfield constants
-#define TFP_TEXTFIELD 1
-#define TFS_READONLY 6
-
-typedef HANDLE (WINAPI*openThemeDataPtr)(HWND hwnd, LPCWSTR pszClassList);
-typedef HRESULT (WINAPI*closeThemeDataPtr)(HANDLE hTheme);
-typedef HRESULT (WINAPI*drawThemeBackgroundPtr)(HANDLE hTheme, HDC hdc, int iPartId,
- int iStateId, const RECT *pRect,
- const RECT* pClipRect);
-typedef HRESULT (WINAPI*drawThemeEdgePtr)(HANDLE hTheme, HDC hdc, int iPartId,
- int iStateId, const RECT *pRect,
- unsigned uEdge, unsigned uFlags,
- const RECT* pClipRect);
-typedef HRESULT (WINAPI*getThemeContentRectPtr)(HANDLE hTheme, HDC hdc, int iPartId,
- int iStateId, const RECT* pRect,
- RECT* pContentRect);
-typedef HRESULT (WINAPI*getThemePartSizePtr)(HANDLE hTheme, HDC hdc, int iPartId,
- int iStateId, RECT* prc, int ts,
- SIZE* psz);
-typedef HRESULT (WINAPI*getThemeSysFontPtr)(HANDLE hTheme, int iFontId, OUT LOGFONT* pFont);
-typedef HRESULT (WINAPI*getThemeColorPtr)(HANDLE hTheme, HDC hdc, int iPartId,
- int iStateId, int iPropId, OUT COLORREF* pFont);
-
-namespace WebCore {
-
-static const int dropDownButtonWidth = 17;
-static const int trackWidth = 4;
-
-PassRefPtr<RenderTheme> RenderThemeWince::create()
-{
- return adoptRef(new RenderThemeWince);
-}
-
-PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page)
-{
- static RenderTheme* winceTheme = RenderThemeWince::create().releaseRef();
- return winceTheme;
-}
-
-RenderThemeWince::RenderThemeWince()
-{
-}
-
-RenderThemeWince::~RenderThemeWince()
-{
-}
-
-Color RenderThemeWince::platformActiveSelectionBackgroundColor() const
-{
- COLORREF color = GetSysColor(COLOR_HIGHLIGHT);
- return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
-}
-
-Color RenderThemeWince::platformInactiveSelectionBackgroundColor() const
-{
- COLORREF color = GetSysColor(COLOR_GRAYTEXT);
- return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
-}
-
-Color RenderThemeWince::platformActiveSelectionForegroundColor() const
-{
- COLORREF color = GetSysColor(COLOR_HIGHLIGHTTEXT);
- return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
-}
-
-Color RenderThemeWince::platformInactiveSelectionForegroundColor() const
-{
- return Color::white;
-}
-
-bool RenderThemeWince::supportsFocus(ControlPart appearance) const
-{
- switch (appearance) {
- case PushButtonPart:
- case ButtonPart:
- case TextFieldPart:
- case TextAreaPart:
- return true;
- default:
- return false;
- }
-
- return false;
-}
-
-bool RenderThemeWince::supportsFocusRing(const RenderStyle *style) const
-{
- return supportsFocus(style->appearance());
-}
-
-unsigned RenderThemeWince::determineClassicState(RenderObject* o)
-{
- unsigned result = 0;
- if (!isEnabled(o) || isReadOnlyControl(o))
- result = DFCS_INACTIVE;
- else if (isPressed(o)) // Active supersedes hover
- result = DFCS_PUSHED;
-
- if (isChecked(o))
- result |= DFCS_CHECKED;
- return result;
-}
-
-ThemeData RenderThemeWince::getThemeData(RenderObject* o)
-{
- ThemeData result;
- switch (o->style()->appearance()) {
- case PushButtonPart:
- case ButtonPart:
- result.m_part = BP_BUTTON;
- result.m_classicState = DFCS_BUTTONPUSH;
- break;
- case CheckboxPart:
- result.m_part = BP_CHECKBOX;
- result.m_classicState = DFCS_BUTTONCHECK;
- break;
- case RadioPart:
- result.m_part = BP_RADIO;
- result.m_classicState = DFCS_BUTTONRADIO;
- break;
- case ListboxPart:
- case MenulistPart:
- case TextFieldPart:
- case TextAreaPart:
- result.m_part = TFP_TEXTFIELD;
- break;
- }
-
- result.m_classicState |= determineClassicState(o);
-
- return result;
-}
-
-bool RenderThemeWince::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
-{
- // Get the correct theme data for a button
- ThemeData themeData = getThemeData(o);
-
- // Now paint the button.
- i.context->drawFrameControl(r, DFC_BUTTON, themeData.m_classicState);
- if (isFocused(o)) {
- if (themeData.m_part == BP_BUTTON) {
- IntRect focusRect(r);
- focusRect.inflate(-2);
- i.context->drawFocusRect(focusRect);
- } else
- i.context->drawFocusRect(r);
- }
-
- return false;
-}
-
-void RenderThemeWince::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.
- if (style->width().isIntrinsicOrAuto())
- style->setWidth(Length(13, Fixed));
- if (style->height().isAuto())
- style->setHeight(Length(13, Fixed));
-}
-
-bool RenderThemeWince::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r)
-{
- // Get the correct theme data for a textfield
- ThemeData themeData = getThemeData(o);
-
- // Now paint the text field.
- i.context->paintTextField(r, themeData.m_classicState);
-
- return false;
-}
-
-void RenderThemeWince::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- style->resetBorder();
- adjustMenuListButtonStyle(selector, style, e);
-}
-
-bool RenderThemeWince::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r)
-{
- paintTextField(o, i, r);
- paintMenuListButton(o, i, r);
- return true;
-}
-
-bool RenderThemeWince::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
-{
- IntRect buttonRect(r.right() - dropDownButtonWidth - 1, r.y(), dropDownButtonWidth, r.height());
- buttonRect.inflateY(-1);
- i.context->drawFrameControl(buttonRect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | determineClassicState(o));
- return true;
-}
-
-void RenderThemeWince::systemFont(int propId, FontDescription& fontDescription) const
-{
- notImplemented();
-}
-
-void RenderThemeWince::themeChanged()
-{
-}
-
-String RenderThemeWince::extraDefaultStyleSheet()
-{
- notImplemented();
- return String();
-}
-
-String RenderThemeWince::extraQuirksStyleSheet()
-{
- notImplemented();
- return String();
-}
-
-bool RenderThemeWince::supportsHover(const RenderStyle*) const
-{
- return false;
-}
-
-// Map a CSSValue* system color to an index understood by GetSysColor
-static int cssValueIdToSysColorIndex(int cssValueId)
-{
- switch (cssValueId) {
- case CSSValueActiveborder: return COLOR_ACTIVEBORDER;
- case CSSValueActivecaption: return COLOR_ACTIVECAPTION;
- case CSSValueAppworkspace: return COLOR_APPWORKSPACE;
- case CSSValueBackground: return COLOR_BACKGROUND;
- case CSSValueButtonface: return COLOR_BTNFACE;
- case CSSValueButtonhighlight: return COLOR_BTNHIGHLIGHT;
- case CSSValueButtonshadow: return COLOR_BTNSHADOW;
- case CSSValueButtontext: return COLOR_BTNTEXT;
- case CSSValueCaptiontext: return COLOR_CAPTIONTEXT;
- case CSSValueGraytext: return COLOR_GRAYTEXT;
- case CSSValueHighlight: return COLOR_HIGHLIGHT;
- case CSSValueHighlighttext: return COLOR_HIGHLIGHTTEXT;
- case CSSValueInactiveborder: return COLOR_INACTIVEBORDER;
- case CSSValueInactivecaption: return COLOR_INACTIVECAPTION;
- case CSSValueInactivecaptiontext: return COLOR_INACTIVECAPTIONTEXT;
- case CSSValueInfobackground: return COLOR_INFOBK;
- case CSSValueInfotext: return COLOR_INFOTEXT;
- case CSSValueMenu: return COLOR_MENU;
- case CSSValueMenutext: return COLOR_MENUTEXT;
- case CSSValueScrollbar: return COLOR_SCROLLBAR;
- case CSSValueThreeddarkshadow: return COLOR_3DDKSHADOW;
- case CSSValueThreedface: return COLOR_3DFACE;
- case CSSValueThreedhighlight: return COLOR_3DHIGHLIGHT;
- case CSSValueThreedlightshadow: return COLOR_3DLIGHT;
- case CSSValueThreedshadow: return COLOR_3DSHADOW;
- case CSSValueWindow: return COLOR_WINDOW;
- case CSSValueWindowframe: return COLOR_WINDOWFRAME;
- case CSSValueWindowtext: return COLOR_WINDOWTEXT;
- default: return -1; // Unsupported CSSValue
- }
-}
-
-Color RenderThemeWince::systemColor(int cssValueId) const
-{
- int sysColorIndex = cssValueIdToSysColorIndex(cssValueId);
- if (sysColorIndex == -1)
- return RenderTheme::systemColor(cssValueId);
-
- COLORREF color = GetSysColor(sysColorIndex);
- return Color(GetRValue(color), GetGValue(color), GetBValue(color));
-}
-
-const int sliderThumbWidth = 7;
-const int sliderThumbHeight = 15;
-
-void RenderThemeWince::adjustSliderThumbSize(RenderObject* o) const
-{
- if (o->style()->appearance() == SliderThumbVerticalPart) {
- o->style()->setWidth(Length(sliderThumbHeight, Fixed));
- o->style()->setHeight(Length(sliderThumbWidth, Fixed));
- } else if (o->style()->appearance() == SliderThumbHorizontalPart) {
- o->style()->setWidth(Length(sliderThumbWidth, Fixed));
- o->style()->setHeight(Length(sliderThumbHeight, Fixed));
- }
-}
-
-#if 0
-void RenderThemeWince::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));
-}
-
-void RenderThemeWince::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- // Override padding size to match AppKit text positioning.
- const int padding = 1;
- style->setPaddingLeft(Length(padding, Fixed));
- style->setPaddingRight(Length(padding, Fixed));
- style->setPaddingTop(Length(padding, Fixed));
- style->setPaddingBottom(Length(padding, Fixed));
-}
-#endif
-
-bool RenderThemeWince::paintSearchField(RenderObject* o, const PaintInfo& i, const IntRect& r)
-{
- return paintTextField(o, i, r);
-}
-
-bool RenderThemeWince::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- Color buttonColor = (o->node() && o->node()->active()) ? Color(138, 138, 138) : Color(186, 186, 186);
-
- IntSize cancelSize(10, 10);
- IntSize cancelRadius(cancelSize.width() / 2, cancelSize.height() / 2);
- int x = r.x() + (r.width() - cancelSize.width()) / 2;
- int y = r.y() + (r.height() - cancelSize.height()) / 2 + 1;
- IntRect cancelBounds(IntPoint(x, y), cancelSize);
- paintInfo.context->save();
- paintInfo.context->addRoundedRectClip(cancelBounds, cancelRadius, cancelRadius, cancelRadius, cancelRadius);
- paintInfo.context->fillRect(cancelBounds, buttonColor, DeviceColorSpace);
-
- // Draw the 'x'
- IntSize xSize(3, 3);
- IntRect xBounds(cancelBounds.location() + IntSize(3, 3), xSize);
- paintInfo.context->setStrokeColor(Color::white, DeviceColorSpace);
- paintInfo.context->drawLine(xBounds.location(), xBounds.location() + xBounds.size());
- paintInfo.context->drawLine(IntPoint(xBounds.right(), xBounds.y()), IntPoint(xBounds.x(), xBounds.bottom()));
-
- paintInfo.context->restore();
- return false;
-}
-
-void RenderThemeWince::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- IntSize cancelSize(13, 11);
- style->setWidth(Length(cancelSize.width(), Fixed));
- style->setHeight(Length(cancelSize.height(), Fixed));
-}
-
-void RenderThemeWince::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- IntSize emptySize(1, 11);
- style->setWidth(Length(emptySize.width(), Fixed));
- style->setHeight(Length(emptySize.height(), Fixed));
-}
-
-void RenderThemeWince::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- IntSize magnifierSize(15, 11);
- style->setWidth(Length(magnifierSize.width(), Fixed));
- style->setHeight(Length(magnifierSize.height(), Fixed));
-}
-
-bool RenderThemeWince::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- notImplemented();
- return false;
-}
-
-void RenderThemeWince::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- IntSize magnifierSize(15, 11);
- style->setWidth(Length(magnifierSize.width(), Fixed));
- style->setHeight(Length(magnifierSize.height(), Fixed));
-}
-
-bool RenderThemeWince::paintSearchFieldResultsButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- paintSearchFieldResultsDecoration(o, paintInfo, r);
- return false;
-}
-
-void RenderThemeWince::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- // These are the paddings needed to place the text correctly in the <select> box
- const int dropDownBoxPaddingTop = 2;
- const int dropDownBoxPaddingRight = style->direction() == LTR ? 4 + dropDownButtonWidth : 4;
- const int dropDownBoxPaddingBottom = 2;
- const int dropDownBoxPaddingLeft = style->direction() == LTR ? 4 : 4 + dropDownButtonWidth;
- // The <select> box must be at least 12px high for the button to render nicely on Windows
- const int dropDownBoxMinHeight = 12;
-
- // Position the text correctly within the select box and make the box wide enough to fit the dropdown button
- style->setPaddingTop(Length(dropDownBoxPaddingTop, Fixed));
- style->setPaddingRight(Length(dropDownBoxPaddingRight, Fixed));
- style->setPaddingBottom(Length(dropDownBoxPaddingBottom, Fixed));
- style->setPaddingLeft(Length(dropDownBoxPaddingLeft, Fixed));
-
- // Height is locked to auto
- style->setHeight(Length(Auto));
-
- // Calculate our min-height
- int minHeight = style->font().height();
- minHeight = max(minHeight, dropDownBoxMinHeight);
-
- style->setMinHeight(Length(minHeight, Fixed));
-
- // White-space is locked to pre
- style->setWhiteSpace(PRE);
-
- DWORD colorMenu = GetSysColor(COLOR_MENU);
- DWORD colorMenuText = GetSysColor(COLOR_MENUTEXT);
- Color bgColor(GetRValue(colorMenu), GetGValue(colorMenu), GetBValue(colorMenu), 255);
- Color textColor(GetRValue(colorMenuText), GetGValue(colorMenuText), GetBValue(colorMenuText), 255);
- if (bgColor == textColor)
- textColor.setRGB((~bgColor.rgb()) | 0xFF000000);
- style->clearBackgroundLayers();
- style->accessBackgroundLayers()->setClip(ContentFillBox);
- style->setBackgroundColor(bgColor);
- style->setColor(textColor);
-}
-
-#if ENABLE(VIDEO)
-// Attempt to retrieve a HTMLMediaElement from a Node. Returns 0 if one cannot be found.
-static HTMLMediaElement* mediaElementParent(Node* node)
-{
- if (!node)
- return 0;
- Node* mediaNode = node->shadowAncestorNode();
- if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag)))
- return 0;
-
- return static_cast<HTMLMediaElement*>(mediaNode);
-}
-#endif
-
-bool RenderThemeWince::paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r)
-{
- bool rc = RenderTheme::paintSliderTrack(o, i, r);
- IntPoint left = IntPoint(r.x() + 2, (r.y() + r.bottom()) / 2);
- i.context->save();
- i.context->setStrokeColor(Color::gray, DeviceColorSpace);
- i.context->setFillColor(Color::gray, DeviceColorSpace);
- i.context->fillRect(r);
-#if ENABLE(VIDEO)
- HTMLMediaElement* mediaElement = mediaElementParent(o->node());
- if (mediaElement) {
- i.context->setStrokeColor(Color(0, 0xff, 0));
- IntPoint right = IntPoint(left.x() + mediaElement->percentLoaded() * (r.right() - r.x() - 4), (r.y() + r.bottom()) / 2);
- i.context->drawLine(left, right);
- left = right;
- }
-#endif
- i.context->setStrokeColor(Color::black, DeviceColorSpace);
- i.context->drawLine(left, IntPoint(r.right() - 2, left.y()));
- i.context->restore();
- return rc;
-}
-
-bool RenderThemeWince::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r)
-{
- bool rc = RenderTheme::paintSliderThumb(o, i, r);
- i.context->save();
- i.context->setStrokeColor(Color::black, DeviceColorSpace);
- i.context->setFillColor(Color::black, DeviceColorSpace);
-#if ENABLE(VIDEO)
- HTMLMediaElement* mediaElement = mediaElementParent(o->node());
- if (mediaElement) {
- float pt = (mediaElement->currentTime() - mediaElement->startTime()) / mediaElement->duration();
- FloatRect intRect = r;
- intRect.setX(intRect.x() + intRect.width() * pt - 2);
- intRect.setWidth(5);
- i.context->fillRect(intRect);
- }
-#endif
- i.context->restore();
- return rc;
-}
-
-void RenderThemeWince::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- const int padding = 1;
- style->setPaddingLeft(Length(padding, Fixed));
- style->setPaddingRight(Length(padding, Fixed));
- style->setPaddingTop(Length(padding, Fixed));
- style->setPaddingBottom(Length(padding, Fixed));
-}
-
-#if ENABLE(VIDEO)
-
-bool RenderThemeWince::paintMediaFullscreenButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- bool rc = paintButton(o, paintInfo, r);
- FloatRect imRect = r;
- imRect.inflate(-2);
- paintInfo.context->save();
- paintInfo.context->setStrokeColor(Color::black);
- paintInfo.context->setFillColor(Color::gray);
- paintInfo.context->fillRect(imRect);
- paintInfo.context->restore();
- return rc;
-}
-
-bool RenderThemeWince::paintMediaMuteButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- bool rc = paintButton(o, paintInfo, r);
- HTMLMediaElement* mediaElement = mediaElementParent(o->node());
- bool muted = !mediaElement || mediaElement->muted();
- FloatRect imRect = r;
- imRect.inflate(-2);
- paintInfo.context->save();
- paintInfo.context->setStrokeColor(Color::black);
- paintInfo.context->setFillColor(Color::black);
- FloatPoint pts[6] = {
- FloatPoint(imRect.x() + 1, imRect.y() + imRect.height() / 3.0),
- FloatPoint(imRect.x() + 1 + imRect.width() / 2.0, imRect.y() + imRect.height() / 3.0),
- FloatPoint(imRect.right() - 1, imRect.y()),
- FloatPoint(imRect.right() - 1, imRect.bottom()),
- FloatPoint(imRect.x() + 1 + imRect.width() / 2.0, imRect.y() + 2.0 * imRect.height() / 3.0),
- FloatPoint(imRect.x() + 1, imRect.y() + 2.0 * imRect.height() / 3.0)
- };
- paintInfo.context->drawConvexPolygon(6, pts);
- if (muted)
- paintInfo.context->drawLine(IntPoint(imRect.right(), imRect.y()), IntPoint(imRect.x(), imRect.bottom()));
- paintInfo.context->restore();
- return rc;
-}
-
-bool RenderThemeWince::paintMediaPlayButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- bool rc = paintButton(o, paintInfo, r);
- FloatRect imRect = r;
- imRect.inflate(-3);
- paintInfo.context->save();
- paintInfo.context->setStrokeColor(Color::black);
- paintInfo.context->setFillColor(Color::black);
- HTMLMediaElement* mediaElement = mediaElementParent(o->node());
- bool paused = !mediaElement || mediaElement->paused();
- if (paused) {
- float width = imRect.width();
- imRect.setWidth(width / 3.0);
- paintInfo.context->fillRect(imRect);
- imRect.move(2.0 * width / 3.0, 0);
- paintInfo.context->fillRect(imRect);
- } else {
- FloatPoint pts[3] = { FloatPoint(imRect.x(), imRect.y()), FloatPoint(imRect.right(), (imRect.y() + imRect.bottom()) / 2.0), FloatPoint(imRect.x(), imRect.bottom()) };
- paintInfo.context->drawConvexPolygon(3, pts);
- }
- paintInfo.context->restore();
- return rc;
-}
-
-bool RenderThemeWince::paintMediaSeekBackButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- bool rc = paintButton(o, paintInfo, r);
- FloatRect imRect = r;
- imRect.inflate(-3);
- FloatPoint pts[3] = { FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.y()), FloatPoint(imRect.x(), (imRect.y() + imRect.bottom()) / 2.0), FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.bottom()) };
- FloatPoint pts2[3] = { FloatPoint(imRect.right(), imRect.y()), FloatPoint((imRect.x() + imRect.right()) / 2.0, (imRect.y() + imRect.bottom()) / 2.0), FloatPoint(imRect.right(), imRect.bottom()) };
- paintInfo.context->save();
- paintInfo.context->setStrokeColor(Color::black);
- paintInfo.context->setFillColor(Color::black);
- paintInfo.context->drawConvexPolygon(3, pts);
- paintInfo.context->drawConvexPolygon(3, pts2);
- paintInfo.context->restore();
- return rc;
-}
-
-bool RenderThemeWince::paintMediaSeekForwardButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- bool rc = paintButton(o, paintInfo, r);
- FloatRect imRect = r;
- imRect.inflate(-3);
- FloatPoint pts[3] = { FloatPoint(imRect.x(), imRect.y()), FloatPoint((imRect.x() + imRect.right()) / 2.0, (imRect.y() + imRect.bottom()) / 2.0), FloatPoint(imRect.x(), imRect.bottom()) };
- FloatPoint pts2[3] = { FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.y()), FloatPoint(imRect.right(), (imRect.y() + imRect.bottom()) / 2.0), FloatPoint((imRect.x() + imRect.right()) / 2.0, imRect.bottom()) };
- paintInfo.context->save();
- paintInfo.context->setStrokeColor(Color::black);
- paintInfo.context->setFillColor(Color::black);
- paintInfo.context->drawConvexPolygon(3, pts);
- paintInfo.context->drawConvexPolygon(3, pts2);
- paintInfo.context->restore();
- return rc;
-}
-
-bool RenderThemeWince::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- return paintSliderTrack(o, paintInfo, r);
-}
-
-bool RenderThemeWince::paintMediaSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- return paintSliderThumb(o, paintInfo, r);
-}
-#endif
-
-}
diff --git a/WebCore/rendering/RenderThemeWince.h b/WebCore/rendering/RenderThemeWince.h
deleted file mode 100644
index c1b57d4..0000000
--- a/WebCore/rendering/RenderThemeWince.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * This file is part of the WebKit project.
- *
- * Copyright (C) 2006, 2008 Apple Computer, Inc.
- * Copyright (C) 2009 Torch Mobile, 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 RenderThemeWince_h
-#define RenderThemeWince_h
-
-#include "RenderTheme.h"
-
-typedef void* HANDLE;
-typedef struct HINSTANCE__* HINSTANCE;
-typedef HINSTANCE HMODULE;
-
-namespace WebCore {
-
- struct ThemeData {
- ThemeData() :m_part(0), m_state(0), m_classicState(0) {}
- ThemeData(int part, int state)
- : m_part(part)
- , m_state(state)
- , m_classicState(0)
- { }
-
- unsigned m_part;
- unsigned m_state;
- unsigned m_classicState;
- };
-
- class RenderThemeWince : public RenderTheme {
- public:
- static PassRefPtr<RenderTheme> create();
- ~RenderThemeWince();
-
- 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;
-
- virtual Color platformActiveSelectionBackgroundColor() const;
- virtual Color platformInactiveSelectionBackgroundColor() const;
- virtual Color platformActiveSelectionForegroundColor() const;
- virtual Color platformInactiveSelectionForegroundColor() const;
-
- // System fonts.
- virtual void systemFont(int propId, FontDescription&) const;
- virtual Color systemColor(int cssValueId) const;
-
- virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r)
- { return paintButton(o, i, r); }
- virtual void setCheckboxSize(RenderStyle*) const;
-
- virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r)
- { return paintButton(o, i, r); }
- virtual void setRadioSize(RenderStyle* style) const
- { return setCheckboxSize(style); }
-
- virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
-
- virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
-
- virtual bool paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
- { return paintTextField(o, i, r); }
-
- virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
- virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
- virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
-
- virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
-
- virtual bool paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r);
- virtual bool paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r);
- virtual void adjustSliderThumbSize(RenderObject*) const;
-
- virtual bool popupOptionSupportsTextIndent() const { return true; }
-
- virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return false; }
-
- virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
-
- virtual void themeChanged();
-
- virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
- virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
- virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
-
- static void setWebKitIsBeingUnloaded();
-
- virtual bool supportsFocusRing(const RenderStyle*) const;
-
- #if ENABLE(VIDEO)
- virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
- virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
- virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
- virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
- virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
- virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
- virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
- #endif
-
- private:
- RenderThemeWince();
-
- unsigned determineClassicState(RenderObject*);
- bool supportsFocus(ControlPart) const;
-
- ThemeData getThemeData(RenderObject*);
- };
-
-};
-
-#endif
diff --git a/WebCore/storage/wince/DatabaseThreadWince.cpp b/WebCore/storage/wince/DatabaseThreadWinCE.cpp
similarity index 100%
rename from WebCore/storage/wince/DatabaseThreadWince.cpp
rename to WebCore/storage/wince/DatabaseThreadWinCE.cpp
diff --git a/WebCore/storage/wince/DatabaseThreadWinCE.h b/WebCore/storage/wince/DatabaseThreadWinCE.h
new file mode 100644
index 0000000..1921cc1
--- /dev/null
+++ b/WebCore/storage/wince/DatabaseThreadWinCE.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Torch Mobile, 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 library is distributed in the hope that i 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 DatabaseThreadWinCE_h
+#define DatabaseThreadWinCE_h
+
+#include <wtf/Deque.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class Database;
+ class DatabaseTask;
+
+ class DatabaseThread: public WTF::RefCounted<DatabaseThread> {
+
+ public:
+ static PassRefPtr<DatabaseThread> create() { return adoptRef(new DatabaseThread); }
+ ~DatabaseThread();
+
+ bool start() { return true; }
+ void requestTermination();
+ bool terminationRequested() const;
+
+ void scheduleTask(PassRefPtr<DatabaseTask>);
+ void scheduleImmediateTask(PassRefPtr<DatabaseTask>);
+ void unscheduleDatabaseTasks(Database*);
+ void recordDatabaseOpen(Database*);
+ void recordDatabaseClosed(Database*);
+#ifndef NDEBUG
+ ThreadIdentifier getThreadID() const { return currentThread(); }
+#endif
+
+ private:
+ DatabaseThread();
+
+ void timerFired(Timer<DatabaseThread>*);
+
+ Deque<RefPtr<DatabaseTask> > m_queue;
+ Timer<DatabaseThread> m_timer;
+ };
+
+} // namespace WebCore
+
+#endif // DatabaseThreadWinCE_h
diff --git a/WebCore/storage/wince/DatabaseThreadWince.h b/WebCore/storage/wince/DatabaseThreadWince.h
deleted file mode 100644
index fafc791..0000000
--- a/WebCore/storage/wince/DatabaseThreadWince.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2009 Torch Mobile, 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 library is distributed in the hope that i 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 DatabaseThreadWince_h
-#define DatabaseThreadWince_h
-
-#include <wtf/Deque.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
- class Database;
- class DatabaseTask;
-
- class DatabaseThread: public WTF::RefCounted<DatabaseThread> {
-
- public:
- static PassRefPtr<DatabaseThread> create() { return adoptRef(new DatabaseThread); }
- ~DatabaseThread();
-
- bool start() { return true; }
- void requestTermination();
- bool terminationRequested() const;
-
- void scheduleTask(PassRefPtr<DatabaseTask>);
- void scheduleImmediateTask(PassRefPtr<DatabaseTask>);
- void unscheduleDatabaseTasks(Database*);
- void recordDatabaseOpen(Database*);
- void recordDatabaseClosed(Database*);
-#ifndef NDEBUG
- ThreadIdentifier getThreadID() const { return currentThread(); }
-#endif
-
- private:
- DatabaseThread();
-
- void timerFired(Timer<DatabaseThread>*);
-
- Deque<RefPtr<DatabaseTask> > m_queue;
- Timer<DatabaseThread> m_timer;
- };
-
-} // namespace WebCore
-
-#endif // DatabaseThreadWince
diff --git a/WebCore/storage/wince/LocalStorageThreadWinCE.cpp b/WebCore/storage/wince/LocalStorageThreadWinCE.cpp
new file mode 100644
index 0000000..90c4e89
--- /dev/null
+++ b/WebCore/storage/wince/LocalStorageThreadWinCE.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Torch Mobile, 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 library is distributed in the hope that i 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 "LocalStorageThread.h"
+
+#include "LocalStorageTask.h"
+#include "StorageAreaSync.h"
+
+namespace WebCore {
+
+LocalStorageThread::LocalStorageThread()
+: m_timer(this, &LocalStorageThread::timerFired)
+{
+}
+
+LocalStorageThread::~LocalStorageThread()
+{
+}
+
+bool LocalStorageThread::start()
+{
+ return true;
+}
+
+void LocalStorageThread::timerFired(Timer<LocalStorageThread>*)
+{
+ if (!m_queue.isEmpty()) {
+ RefPtr<LocalStorageTask> task = m_queue.first();
+ task->performTask();
+ m_queue.removeFirst();
+ if (!m_queue.isEmpty())
+ m_timer.startOneShot(0);
+ }
+}
+
+void LocalStorageThread::scheduleImport(PassRefPtr<StorageAreaSync> area)
+{
+ m_queue.append(LocalStorageTask::createImport(area));
+ if (!m_timer.isActive())
+ m_timer.startOneShot(0);
+}
+
+void LocalStorageThread::scheduleSync(PassRefPtr<StorageAreaSync> area)
+{
+ m_queue.append(LocalStorageTask::createSync(area));
+ if (!m_timer.isActive())
+ m_timer.startOneShot(0);
+}
+
+void LocalStorageThread::terminate()
+{
+ m_queue.clear();
+ m_timer.stop();
+}
+
+void LocalStorageThread::performTerminate()
+{
+ m_queue.clear();
+ m_timer.stop();
+}
+
+} // namespace WebCore
diff --git a/WebCore/storage/wince/LocalStorageThreadWinCE.h b/WebCore/storage/wince/LocalStorageThreadWinCE.h
new file mode 100644
index 0000000..06e7d45
--- /dev/null
+++ b/WebCore/storage/wince/LocalStorageThreadWinCE.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 Torch Mobile, 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 library is distributed in the hope that i 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 LocalStorageThreadWinCE_h
+#define LocalStorageThreadWinCE_h
+
+#include <wtf/Deque.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+ class StorageAreaSync;
+ class LocalStorageTask;
+
+ class LocalStorageThread : public RefCounted<LocalStorageThread> {
+ public:
+ static PassRefPtr<LocalStorageThread> create() { return adoptRef(new LocalStorageThread); }
+
+ ~LocalStorageThread();
+ bool start();
+ void scheduleImport(PassRefPtr<StorageAreaSync>);
+ void scheduleSync(PassRefPtr<StorageAreaSync>);
+ void terminate();
+ void performTerminate();
+
+ private:
+ LocalStorageThread();
+
+ void timerFired(Timer<LocalStorageThread>*);
+
+ Deque<RefPtr<LocalStorageTask> > m_queue;
+ Timer<LocalStorageThread> m_timer;
+ };
+
+} // namespace WebCore
+
+#endif // LocalStorageThreadWinCE_h
diff --git a/WebCore/storage/wince/LocalStorageThreadWince.cpp b/WebCore/storage/wince/LocalStorageThreadWince.cpp
deleted file mode 100644
index 8dcb902..0000000
--- a/WebCore/storage/wince/LocalStorageThreadWince.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2009 Torch Mobile, 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 library is distributed in the hope that i 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 "LocalStorageThread.h"
-
-#include "LocalStorageTask.h"
-#include "StorageAreaSync.h"
-
-namespace WebCore {
-
-LocalStorageThread::LocalStorageThread()
-: m_timer(this, &LocalStorageThread::timerFired)
-{
-}
-
-LocalStorageThread::~LocalStorageThread()
-{
-}
-
-bool LocalStorageThread::start()
-{
- return true;
-}
-
-void LocalStorageThread::timerFired(Timer<LocalStorageThread>*)
-{
- if (!m_queue.isEmpty()) {
- RefPtr<LocalStorageTask> task = m_queue.first();
- task->performTask();
- m_queue.removeFirst();
- if (!m_queue.isEmpty())
- m_timer.startOneShot(0);
- }
-}
-
-void LocalStorageThread::scheduleImport(PassRefPtr<StorageAreaSync> area)
-{
- m_queue.append(LocalStorageTask::createImport(area));
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
-}
-
-void LocalStorageThread::scheduleSync(PassRefPtr<StorageAreaSync> area)
-{
- m_queue.append(LocalStorageTask::createSync(area));
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
-}
-
-void LocalStorageThread::terminate()
-{
- m_queue.clear();
- m_timer.stop();
-}
-
-void LocalStorageThread::performTerminate()
-{
- m_queue.clear();
- m_timer.stop();
-}
-
-}
diff --git a/WebCore/storage/wince/LocalStorageThreadWince.h b/WebCore/storage/wince/LocalStorageThreadWince.h
deleted file mode 100644
index 300abb5..0000000
--- a/WebCore/storage/wince/LocalStorageThreadWince.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2009 Torch Mobile, 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 library is distributed in the hope that i 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 LocalStorageThreadWince_h
-#define LocalStorageThreadWince_h
-
-#include <wtf/Deque.h>
-#include <wtf/PassRefPtr.h>
-
-namespace WebCore {
-
- class StorageAreaSync;
- class LocalStorageTask;
-
- class LocalStorageThread : public RefCounted<LocalStorageThread> {
- public:
- static PassRefPtr<LocalStorageThread> create() { return adoptRef(new LocalStorageThread); }
-
- ~LocalStorageThread();
- bool start();
- void scheduleImport(PassRefPtr<StorageAreaSync>);
- void scheduleSync(PassRefPtr<StorageAreaSync>);
- void terminate();
- void performTerminate();
-
- private:
- LocalStorageThread();
-
- void timerFired(Timer<LocalStorageThread>*);
-
- Deque<RefPtr<LocalStorageTask> > m_queue;
- Timer<LocalStorageThread> m_timer;
- };
-
-} // namespace WebCore
-
-#endif // LocalStorageThreadWince_h
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list