Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1081)

Unified Diff: third_party/WebKit/Source/platform/fonts/Character.cpp

Issue 1742293002: Support src/build/linux/unbundle in CharacterDataGenerator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/Character.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/Character.cpp b/third_party/WebKit/Source/platform/fonts/Character.cpp
index fed39eba26fba29b094584204548a4d5e96d4970..26161793011f786b383383cb39a465ef2ed5ac09 100644
--- a/third_party/WebKit/Source/platform/fonts/Character.cpp
+++ b/third_party/WebKit/Source/platform/fonts/Character.cpp
@@ -35,14 +35,45 @@
#include <algorithm>
#include <unicode/uobject.h>
#include <unicode/uscript.h>
+
+#if defined(USING_SYSTEM_ICU)
+#include "CharacterData.h"
+#include <unicode/uniset.h>
+#else
#define MUTEX_H // Prevent compile failure of utrie2.h on Windows
#include <utrie2.h>
+#endif
using namespace WTF;
using namespace Unicode;
namespace blink {
+#if defined(USING_SYSTEM_ICU)
+static icu::UnicodeSet* createUnicodeSet(
+ const UChar32* characters, size_t charactersCount,
+ const UChar32* ranges, size_t rangesCount)
+{
+ icu::UnicodeSet* unicodeSet = new icu::UnicodeSet();
+ for (size_t i = 0; i < charactersCount; i++)
+ unicodeSet->add(characters[i]);
+ for (size_t i = 0; i < rangesCount; i += 2)
+ unicodeSet->add(ranges[i], ranges[i + 1]);
+ unicodeSet->freeze();
+ return unicodeSet;
+}
+
+#define CREATE_UNICODE_SET(name) \
+ createUnicodeSet( \
+ name##Array, WTF_ARRAY_LENGTH(name##Array), \
+ name##Ranges, WTF_ARRAY_LENGTH(name##Ranges))
+
+#define RETURN_HAS_PROPERTY(c, name) \
+ static icu::UnicodeSet* unicodeSet = nullptr; \
+ if (!unicodeSet) \
+ unicodeSet = CREATE_UNICODE_SET(name); \
+ return unicodeSet->contains(c);
+#else
// Freezed trie tree, see CharacterDataGenerator.cpp.
extern int32_t serializedCharacterDataSize;
extern uint8_t serializedCharacterData[];
@@ -59,7 +90,7 @@ static UTrie2* createTrie()
return trie;
}
-bool Character::hasProperty(UChar32 c, CharacterProperty property)
+static bool hasProperty(UChar32 c, CharacterProperty property)
{
static UTrie2* trie = nullptr;
if (!trie)
@@ -68,6 +99,10 @@ bool Character::hasProperty(UChar32 c, CharacterProperty property)
& static_cast<CharacterPropertyType>(property);
}
+#define RETURN_HAS_PROPERTY(c, name) \
+ return hasProperty(c, CharacterProperty::name);
+#endif
+
// Takes a flattened list of closed intervals
template <class T, size_t size>
bool valueInIntervalList(const T (&intervalList)[size], const T& value)
@@ -184,7 +219,7 @@ CodePath Character::characterRangeCodePath(const UChar* characters, unsigned len
bool Character::isUprightInMixedVertical(UChar32 character)
{
- return hasProperty(character, CharacterProperty::isUprightInMixedVertical);
+ RETURN_HAS_PROPERTY(character, isUprightInMixedVertical)
}
bool Character::isCJKIdeographOrSymbol(UChar32 c)
@@ -193,7 +228,7 @@ bool Character::isCJKIdeographOrSymbol(UChar32 c)
if (c < 0x2C7)
return false;
- return hasProperty(c, CharacterProperty::isCJKIdeographOrSymbol);
+ RETURN_HAS_PROPERTY(c, isCJKIdeographOrSymbol)
}
unsigned Character::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, const TextJustify textJustify)
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Character.h ('k') | third_party/WebKit/Source/platform/fonts/CharacterData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698