WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-96282-20120920172037.patch (text/plain), 19.70 KB, created by
Mark Pilgrim (Google)
on 2012-09-20 14:21:15 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Mark Pilgrim (Google)
Created:
2012-09-20 14:21:15 PDT
Size:
19.70 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 129167) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,37 @@ >+2012-09-20 Mark Pilgrim <pilgrim@chromium.org> >+ >+ [Chromium] remove getFontFamilyForCharacters from PlatformSupport >+ https://bugs.webkit.org/show_bug.cgi?id=96282 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Migrating away from PlatformSupport. getFontFamilyForCharacters is >+ moved to FontFamily.h and overridden by the two platforms that >+ need it (Chromium and Blackberry). New files for the overrides. >+ Part of a larger refactoring series. See tracking bug 82948. >+ >+ * PlatformBlackBerry.cmake: >+ * WebCore.gypi: >+ * platform/chromium/PlatformSupport.h: >+ (PlatformSupport): >+ * platform/graphics/FontFamily.h: >+ (SimpleFontFamily): >+ (FontFamily): >+ * platform/graphics/blackberry/FontFamilyBlackberry.cpp: Added. >+ (WebCore): >+ (WebCore::FontFamily::getFontFamilyForCharacters): >+ * platform/graphics/blackberry/skia/PlatformSupport.cpp: >+ (WebCore): >+ * platform/graphics/blackberry/skia/PlatformSupport.h: >+ (PlatformSupport): >+ * platform/graphics/chromium/FontCacheAndroid.cpp: >+ (WebCore::FontCache::getFontDataForCharacters): >+ * platform/graphics/chromium/FontFamilyChromiumLinux.cpp: Added. >+ (WebCore): >+ (WebCore::FontFamily::getFontFamilyForCharacters): >+ * platform/graphics/skia/FontCacheSkia.cpp: >+ (WebCore::FontCache::getFontDataForCharacters): >+ > 2012-09-20 Patrick Gansterer <paroga@webkit.org> > > Add String::numberToFixedPrecisionString() >Index: Source/WebCore/PlatformBlackBerry.cmake >=================================================================== >--- Source/WebCore/PlatformBlackBerry.cmake (revision 129121) >+++ Source/WebCore/PlatformBlackBerry.cmake (working copy) >@@ -42,6 +42,7 @@ LIST(APPEND WebCore_SOURCES > > # Skia font backend sources > LIST(APPEND WebCore_SOURCES >+ platform/graphics/blackberry/FontFamilyBlackberry.cpp > platform/graphics/blackberry/skia/PlatformBridge.cpp > platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp > platform/graphics/harfbuzz/FontHarfBuzz.cpp >Index: Source/WebCore/WebCore.gypi >=================================================================== >--- Source/WebCore/WebCore.gypi (revision 129121) >+++ Source/WebCore/WebCore.gypi (working copy) >@@ -4890,6 +4890,7 @@ > 'platform/graphics/chromium/FontCacheAndroid.cpp', > 'platform/graphics/chromium/FontCacheChromiumWin.cpp', > 'platform/graphics/chromium/FontChromiumWin.cpp', >+ 'platform/graphics/chromium/FontFamilyChromiumLinux.cpp', > 'platform/graphics/chromium/FontPlatformData.h', > 'platform/graphics/chromium/FontPlatformDataChromiumWin.cpp', > 'platform/graphics/chromium/FontPlatformDataChromiumWin.h', >Index: Source/WebCore/platform/chromium/PlatformSupport.h >=================================================================== >--- Source/WebCore/platform/chromium/PlatformSupport.h (revision 129121) >+++ Source/WebCore/platform/chromium/PlatformSupport.h (working copy) >@@ -101,13 +101,6 @@ public: > #endif > #if OS(DARWIN) > static bool loadFont(NSFont* srcFont, CGFontRef*, uint32_t* fontID); >-#elif OS(UNIX) >- struct FontFamily { >- String name; >- bool isBold; >- bool isItalic; >- }; >- static void getFontFamilyForCharacters(const UChar*, size_t numCharacters, const char* preferredLocale, FontFamily*); > #endif > > // IndexedDB ---------------------------------------------------------- >Index: Source/WebCore/platform/graphics/FontFamily.h >=================================================================== >--- Source/WebCore/platform/graphics/FontFamily.h (revision 129121) >+++ Source/WebCore/platform/graphics/FontFamily.h (working copy) >@@ -47,6 +47,13 @@ public: > void appendFamily(PassRefPtr<SharedFontFamily>); > PassRefPtr<SharedFontFamily> releaseNext(); > >+ struct SimpleFontFamily { >+ String name; >+ bool isBold; >+ bool isItalic; >+ }; >+ static void getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, SimpleFontFamily*); >+ > private: > AtomicString m_family; > ListRefPtr<SharedFontFamily> m_next; >Index: Source/WebCore/platform/graphics/blackberry/FontFamilyBlackberry.cpp >=================================================================== >--- Source/WebCore/platform/graphics/blackberry/FontFamilyBlackberry.cpp (revision 0) >+++ Source/WebCore/platform/graphics/blackberry/FontFamilyBlackberry.cpp (revision 0) >@@ -0,0 +1,120 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "FontFamily.h" >+ >+#include "FontRenderStyle.h" >+ >+#include <fontconfig/fontconfig.h> >+#include <string.h> >+#include <unicode/utf16.h> >+#include <wtf/text/CString.h> >+ >+namespace WebCore { >+ >+void FontFamily::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char*, FontFamily::SimpleFontFamily* family) >+{ >+ FcCharSet* cset = FcCharSetCreate(); >+ for (size_t i = 0; i < numCharacters; ++i) { >+ if (U16_IS_SURROGATE(characters[i]) >+ && U16_IS_SURROGATE_LEAD(characters[i]) >+ && i != numCharacters - 1 >+ && U16_IS_TRAIL(characters[i + 1])) { >+ FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1])); >+ i++; >+ } else >+ FcCharSetAddChar(cset, characters[i]); >+ } >+ FcPattern* pattern = FcPatternCreate(); >+ >+ FcValue fcvalue; >+ fcvalue.type = FcTypeCharSet; >+ fcvalue.u.c = cset; >+ FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse); >+ >+ fcvalue.type = FcTypeBool; >+ fcvalue.u.b = FcTrue; >+ FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse); >+ >+ FcConfigSubstitute(0, pattern, FcMatchPattern); >+ FcDefaultSubstitute(pattern); >+ >+ FcResult result; >+ FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result); >+ FcPatternDestroy(pattern); >+ FcCharSetDestroy(cset); >+ >+ if (!fontSet) { >+ family->name = String(); >+ family->isBold = false; >+ family->isItalic = false; >+ return; >+ } >+ >+ // Older versions of fontconfig have a bug where they cannot select >+ // only scalable fonts so we have to manually filter the results. >+ for (int i = 0; i < fontSet->nfont; ++i) { >+ FcPattern* current = fontSet->fonts[i]; >+ FcBool isScalable; >+ >+ if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch >+ || !isScalable) >+ continue; >+ >+ // fontconfig can also return fonts which are unreadable >+ FcChar8* cFilename; >+ if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch) >+ continue; >+ >+ if (access(reinterpret_cast<char*>(cFilename), R_OK)) >+ continue; >+ >+ FcChar8* familyName; >+ if (FcPatternGetString(current, FC_FAMILY, 0, &familyName) == FcResultMatch) { >+ const char* charFamily = reinterpret_cast<char*>(familyName); >+ family->name = String::fromUTF8(charFamily, strlen(charFamily)); >+ } >+ >+ int weight; >+ if (FcPatternGetInteger(current, FC_WEIGHT, 0, &weight) == FcResultMatch) >+ family->isBold = weight >= FC_WEIGHT_BOLD; >+ else >+ family->isBold = false; >+ >+ int slant; >+ if (FcPatternGetInteger(current, FC_SLANT, 0, &slant) == FcResultMatch) >+ family->isItalic = slant != FC_SLANT_ROMAN; >+ else >+ family->isItalic = false; >+ >+ FcFontSetDestroy(fontSet); >+ return; >+ } >+ >+ FcFontSetDestroy(fontSet); >+} >+ >+}; // namespace WebCore >Index: Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp >=================================================================== >--- Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp (revision 129121) >+++ Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp (working copy) >@@ -129,86 +129,4 @@ void PlatformSupport::getRenderStyleForS > FcPatternDestroy(match); > } > >-void PlatformSupport::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char*, FontFamily* family) >-{ >- FcCharSet* cset = FcCharSetCreate(); >- for (size_t i = 0; i < numCharacters; ++i) { >- if (U16_IS_SURROGATE(characters[i]) >- && U16_IS_SURROGATE_LEAD(characters[i]) >- && i != numCharacters - 1 >- && U16_IS_TRAIL(characters[i + 1])) { >- FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1])); >- i++; >- } else >- FcCharSetAddChar(cset, characters[i]); >- } >- FcPattern* pattern = FcPatternCreate(); >- >- FcValue fcvalue; >- fcvalue.type = FcTypeCharSet; >- fcvalue.u.c = cset; >- FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse); >- >- fcvalue.type = FcTypeBool; >- fcvalue.u.b = FcTrue; >- FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse); >- >- FcConfigSubstitute(0, pattern, FcMatchPattern); >- FcDefaultSubstitute(pattern); >- >- FcResult result; >- FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result); >- FcPatternDestroy(pattern); >- FcCharSetDestroy(cset); >- >- if (!fontSet) { >- family->name = String(); >- family->isBold = false; >- family->isItalic = false; >- return; >- } >- >- // Older versions of fontconfig have a bug where they cannot select >- // only scalable fonts so we have to manually filter the results. >- for (int i = 0; i < fontSet->nfont; ++i) { >- FcPattern* current = fontSet->fonts[i]; >- FcBool isScalable; >- >- if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch >- || !isScalable) >- continue; >- >- // fontconfig can also return fonts which are unreadable >- FcChar8* cFilename; >- if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch) >- continue; >- >- if (access(reinterpret_cast<char*>(cFilename), R_OK)) >- continue; >- >- FcChar8* familyName; >- if (FcPatternGetString(current, FC_FAMILY, 0, &familyName) == FcResultMatch) { >- const char* charFamily = reinterpret_cast<char*>(familyName); >- family->name = String::fromUTF8(charFamily, strlen(charFamily)); >- } >- >- int weight; >- if (FcPatternGetInteger(current, FC_WEIGHT, 0, &weight) == FcResultMatch) >- family->isBold = weight >= FC_WEIGHT_BOLD; >- else >- family->isBold = false; >- >- int slant; >- if (FcPatternGetInteger(current, FC_SLANT, 0, &slant) == FcResultMatch) >- family->isItalic = slant != FC_SLANT_ROMAN; >- else >- family->isItalic = false; >- >- FcFontSetDestroy(fontSet); >- return; >- } >- >- FcFontSetDestroy(fontSet); >-} >- > }; // namespace WebCore >Index: Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.h >=================================================================== >--- Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.h (revision 129121) >+++ Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.h (working copy) >@@ -42,12 +42,6 @@ struct FontRenderStyle; > class PlatformSupport { > public: > static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result); >- struct FontFamily { >- String name; >- bool isBold; >- bool isItalic; >- }; >- static void getFontFamilyForCharacters(const UChar*, size_t numCharacters, const char* preferredLocale, FontFamily*); > }; > > } // namespace WebCore >Index: Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp >=================================================================== >--- Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp (revision 129121) >+++ Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp (working copy) >@@ -35,7 +35,6 @@ > #include "FontDescription.h" > #include "FontPlatformData.h" > #include "NotImplemented.h" >-#include "PlatformSupport.h" > #include "SimpleFontData.h" > > #include "SkPaint.h" >@@ -100,13 +99,9 @@ void FontCache::platformInit() > > const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) > { >- icu::Locale locale = icu::Locale::getDefault(); >- PlatformSupport::FontFamily family; >- PlatformSupport::getFontFamilyForCharacters(characters, length, locale.getLanguage(), &family); >- if (family.name.isEmpty()) >- return 0; >- >- AtomicString atomicFamily(family.name); >+ // FIXME: We do not use fontconfig on Android, so use simple logic for now. >+ // https://bugs.webkit.org/show_bug.cgi?id=67587 >+ AtomicString atomicFamily("Arial"); > return getCachedFontData(getCachedFontPlatformData(font.fontDescription(), atomicFamily, DoNotRetain), DoNotRetain); > } > >Index: Source/WebCore/platform/graphics/chromium/FontFamilyChromiumLinux.cpp >=================================================================== >--- Source/WebCore/platform/graphics/chromium/FontFamilyChromiumLinux.cpp (revision 0) >+++ Source/WebCore/platform/graphics/chromium/FontFamilyChromiumLinux.cpp (revision 0) >@@ -0,0 +1,48 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "FontFamily.h" >+ >+#include <public/linux/WebFontFamily.h> >+#include <public/linux/WebFontInfo.h> >+#include <public/linux/WebSandboxSupport.h> >+#include <public/Platform.h> >+ >+namespace WebCore { >+ >+void FontFamily::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, FontFamily::SimpleFontFamily* family) >+{ >+ WebKit::WebFontFamily webFamily; >+ if (WebKit::Platform::current()->sandboxSupport()) >+ WebKit::Platform::current()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters, preferredLocale, &webFamily); >+ else >+ WebKit::WebFontInfo::familyForChars(characters, numCharacters, preferredLocale, &webFamily); >+ family->name = String::fromUTF8(webFamily.name.data(), webFamily.name.length()); >+ family->isBold = webFamily.isBold; >+ family->isItalic = webFamily.isItalic; >+} >+ >+} >Index: Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp >=================================================================== >--- Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp (revision 129121) >+++ Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp (working copy) >@@ -33,6 +33,7 @@ > > #include "Font.h" > #include "FontDescription.h" >+#include "FontFamily.h" > #include "FontPlatformData.h" > #include "Logging.h" > #include "NotImplemented.h" >@@ -59,8 +60,8 @@ const SimpleFontData* FontCache::getFont > int length) > { > icu::Locale locale = icu::Locale::getDefault(); >- PlatformSupport::FontFamily family; >- PlatformSupport::getFontFamilyForCharacters(characters, length, locale.getLanguage(), &family); >+ FontFamily::SimpleFontFamily family; >+ FontFamily::getFontFamilyForCharacters(characters, length, locale.getLanguage(), &family); > if (family.name.isEmpty()) > return 0; > >Index: Source/WebKit/chromium/ChangeLog >=================================================================== >--- Source/WebKit/chromium/ChangeLog (revision 129167) >+++ Source/WebKit/chromium/ChangeLog (working copy) >@@ -1,3 +1,15 @@ >+2012-09-20 Mark Pilgrim <pilgrim@chromium.org> >+ >+ [Chromium] remove getFontFamilyForCharacters from PlatformSupport >+ https://bugs.webkit.org/show_bug.cgi?id=96282 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Part of a refactoring series. See tracking bug 82948. >+ >+ * src/PlatformSupport.cpp: >+ (WebCore): >+ > 2012-09-20 Dirk Pranke <dpranke@chromium.org> > > roll Chromium to r157829. >Index: Source/WebKit/chromium/src/PlatformSupport.cpp >=================================================================== >--- Source/WebKit/chromium/src/PlatformSupport.cpp (revision 129121) >+++ Source/WebKit/chromium/src/PlatformSupport.cpp (working copy) >@@ -233,26 +233,6 @@ bool PlatformSupport::loadFont(NSFont* s > return false; > } > #elif OS(UNIX) >-void PlatformSupport::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, FontFamily* family) >-{ >-#if OS(ANDROID) >- // FIXME: We do not use fontconfig on Android, so use simple logic for now. >- // https://bugs.webkit.org/show_bug.cgi?id=67587 >- family->name = "Arial"; >- family->isBold = false; >- family->isItalic = false; >-#else >- WebFontFamily webFamily; >- if (WebKit::Platform::current()->sandboxSupport()) >- WebKit::Platform::current()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters, preferredLocale, &webFamily); >- else >- WebFontInfo::familyForChars(characters, numCharacters, preferredLocale, &webFamily); >- family->name = String::fromUTF8(webFamily.name.data(), webFamily.name.length()); >- family->isBold = webFamily.isBold; >- family->isItalic = webFamily.isItalic; >-#endif >-} >- > #endif > > // Indexed Database -----------------------------------------------------------
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 96282
:
163152
|
164979
|
165158
|
165187