Skip to content

Commit

Permalink
Rename Script() returning UScriptCode to GetScript()
Browse files Browse the repository at this point in the history
To avoid naming conflict between Script() and a new class Script that will
be introduced by https://codereview.chromium.org/2780463002/.

BUG=686281

Review-Url: https://codereview.chromium.org/2815523002
Cr-Commit-Position: refs/heads/master@{#464064}
  • Loading branch information
hiroshige-g authored and Commit bot committed Apr 12, 2017
1 parent c3af64f commit c6494e2
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/core/css/CSSFontSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static AtomicString FamilyNameFromSettings(
return FontCache::GetGenericFamilyNameForScript(generic_family_name,
font_description);
#else
UScriptCode script = font_description.Script();
UScriptCode script = font_description.GetScript();
if (font_description.GenericFamily() == FontDescription::kStandardFamily)
return settings.Standard(script);
if (generic_family_name == FontFamilyNames::webkit_serif)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class NGLayoutInlineItem {
return bidi_level_ & 1 ? TextDirection::kRtl : TextDirection::kLtr;
}
UBiDiLevel BidiLevel() const { return bidi_level_; }
UScriptCode Script() const { return script_; }
UScriptCode GetScript() const { return script_; }
const ComputedStyle* Style() const { return style_; }
LayoutObject* GetLayoutObject() const { return layout_object_; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ String NGLayoutInlineItemsBuilder::ToString() {
// Unicode East Asian Width
// http://unicode.org/reports/tr11/
static bool IsAmbiguosEastAsianWidthWide(const ComputedStyle* style) {
UScriptCode script = style->GetFontDescription().Script();
UScriptCode script = style->GetFontDescription().GetScript();
return script == USCRIPT_KATAKANA_OR_HIRAGANA ||
script == USCRIPT_SIMPLIFIED_HAN || script == USCRIPT_TRADITIONAL_HAN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static ResolvedUnderlinePosition ResolveUnderlinePosition(
case kIdeographicBaseline:
// Compute language-appropriate default underline position.
// https://drafts.csswg.org/css-text-decor-3/#default-stylesheet
UScriptCode script = style.GetFontDescription().Script();
UScriptCode script = style.GetFontDescription().GetScript();
if (script == USCRIPT_KATAKANA_OR_HIRAGANA || script == USCRIPT_HANGUL)
return ResolvedUnderlinePosition::kOver;
return ResolvedUnderlinePosition::kUnder;
Expand Down
4 changes: 2 additions & 2 deletions third_party/WebKit/Source/platform/LayoutLocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void LayoutLocale::ComputeScriptForHan() const {
DCHECK(IsUnambiguousHanScript(script_for_han_));
}

UScriptCode LayoutLocale::ScriptForHan() const {
UScriptCode LayoutLocale::GetScriptForHan() const {
if (script_for_han_ == USCRIPT_COMMON)
ComputeScriptForHan();
return script_for_han_;
Expand Down Expand Up @@ -103,7 +103,7 @@ void LayoutLocale::ComputeLocaleForHan() {
}

const char* LayoutLocale::LocaleForHanForSkFontMgr() const {
const char* locale = ToSkFontMgrLocale(ScriptForHan());
const char* locale = ToSkFontMgrLocale(GetScriptForHan());
DCHECK(locale);
return locale;
}
Expand Down
4 changes: 2 additions & 2 deletions third_party/WebKit/Source/platform/LayoutLocale.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class PLATFORM_EXPORT LayoutLocale : public RefCounted<LayoutLocale> {
return harfbuzz_language_;
}
const char* LocaleForSkFontMgr() const;
UScriptCode Script() const { return script_; }
UScriptCode GetScript() const { return script_; }

// Disambiguation of the Unified Han Ideographs.
UScriptCode ScriptForHan() const;
UScriptCode GetScriptForHan() const;
bool HasScriptForHan() const;
static const LayoutLocale* LocaleForHan(const LayoutLocale*);
static void InvalidateLocaleForHan() { default_for_han_computed_ = false; }
Expand Down
16 changes: 9 additions & 7 deletions third_party/WebKit/Source/platform/LayoutLocaleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,17 @@ TEST(LayoutLocaleTest, ScriptTest) {

for (const auto& test : tests) {
RefPtr<LayoutLocale> locale = LayoutLocale::CreateForTesting(test.locale);
EXPECT_EQ(test.script, locale->Script()) << test.locale;
EXPECT_EQ(test.script, locale->GetScript()) << test.locale;
EXPECT_EQ(test.has_script_for_han, locale->HasScriptForHan())
<< test.locale;
if (!test.has_script_for_han)
EXPECT_EQ(USCRIPT_SIMPLIFIED_HAN, locale->ScriptForHan()) << test.locale;
else if (test.script_for_han)
EXPECT_EQ(test.script_for_han, locale->ScriptForHan()) << test.locale;
else
EXPECT_EQ(test.script, locale->ScriptForHan()) << test.locale;
if (!test.has_script_for_han) {
EXPECT_EQ(USCRIPT_SIMPLIFIED_HAN, locale->GetScriptForHan())
<< test.locale;
} else if (test.script_for_han) {
EXPECT_EQ(test.script_for_han, locale->GetScriptForHan()) << test.locale;
} else {
EXPECT_EQ(test.script, locale->GetScriptForHan()) << test.locale;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST(AcceptLanguagesResolverTest, AcceptLanguagesChanged) {
}

ASSERT_NE(nullptr, locale) << test.accept_languages;
EXPECT_EQ(test.script, locale->ScriptForHan()) << test.accept_languages;
EXPECT_EQ(test.script, locale->GetScriptForHan()) << test.accept_languages;
EXPECT_STRCASEEQ(test.locale, locale->LocaleForHanForSkFontMgr())
<< test.accept_languages;
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/platform/fonts/FontDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class PLATFORM_EXPORT FontDescription {
const LayoutLocale& LocaleOrDefault() const {
return LayoutLocale::ValueOrDefault(locale_.Get());
}
UScriptCode Script() const { return LocaleOrDefault().Script(); }
UScriptCode GetScript() const { return LocaleOrDefault().GetScript(); }
bool IsSyntheticBold() const { return fields_.synthetic_bold_; }
bool IsSyntheticItalic() const { return fields_.synthetic_italic_; }
bool UseSubpixelPositioning() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ AtomicString FontCache::GetGenericFamilyNameForScript(
// or locale. We need an API that honors both to find appropriate
// fonts. crbug.com/642340
UChar32 exampler_char;
switch (content_locale->Script()) {
switch (content_locale->GetScript()) {
case USCRIPT_SIMPLIFIED_HAN:
case USCRIPT_TRADITIONAL_HAN:
case USCRIPT_KATAKANA_OR_HIRAGANA:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST(FontCacheAndroid, fallbackFontForCharacter) {

FontDescription font_description;
font_description.SetLocale(LayoutLocale::Get("zh"));
ASSERT_EQ(USCRIPT_SIMPLIFIED_HAN, font_description.Script());
ASSERT_EQ(USCRIPT_SIMPLIFIED_HAN, font_description.GetScript());
font_description.SetGenericFamily(FontDescription::kStandardFamily);

FontCache* font_cache = FontCache::GetFontCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CachingWordShaperTest : public ::testing::Test {
void SetUp() override {
font_description.SetComputedSize(12.0);
font_description.SetLocale(LayoutLocale::Get("en"));
ASSERT_EQ(USCRIPT_LATIN, font_description.Script());
ASSERT_EQ(USCRIPT_LATIN, font_description.GetScript());
font_description.SetGenericFamily(FontDescription::kStandardFamily);

font = Font(font_description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void InitializeScriptFontMap(ScriptToFontMap& script_font_map) {
}

// Initialize the locale-dependent mapping from system locale.
UScriptCode han_script = LayoutLocale::GetSystem().ScriptForHan();
UScriptCode han_script = LayoutLocale::GetSystem().GetScriptForHan();
DCHECK(han_script != USCRIPT_HAN);
if (script_font_map[han_script].candidate_family_names) {
script_font_map[USCRIPT_HAN].candidate_family_names =
Expand Down Expand Up @@ -505,7 +505,7 @@ const UChar* GetFallbackFamily(UChar32 character,
if (script == USCRIPT_HAN) {
if (const LayoutLocale* locale_for_han =
LayoutLocale::LocaleForHan(content_locale))
script = locale_for_han->ScriptForHan();
script = locale_for_han->GetScriptForHan();
// If still unknown, USCRIPT_HAN uses UI locale.
// See initializeScriptFontMap().
}
Expand Down

0 comments on commit c6494e2

Please sign in to comment.