Commit 432c9143 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Move ApplyTextTransform to ComputedStyle

Bug: 636993
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I8ef71a1012af008b9cafc497aba7802be23a2880
Reviewed-on: https://chromium-review.googlesource.com/1051548Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557234}
parent 8254aff5
......@@ -1871,8 +1871,8 @@ String HTMLSelectElement::ItemText(const Element& element) const {
else if (auto* option = ToHTMLOptionElementOrNull(element))
item_string = option->TextIndentedToRespectGroupLabel();
if (GetLayoutObject())
ApplyTextTransform(GetLayoutObject()->Style(), item_string, ' ');
if (GetLayoutObject() && GetLayoutObject()->Style())
GetLayoutObject()->Style()->ApplyTextTransform(&item_string);
return item_string;
}
......
......@@ -181,7 +181,7 @@ void LayoutMenuList::UpdateOptionsWidth() const {
String text = option->TextIndentedToRespectGroupLabel();
const ComputedStyle* item_style =
option->GetComputedStyle() ? option->GetComputedStyle() : Style();
ApplyTextTransform(item_style, text, ' ');
item_style->ApplyTextTransform(&text);
// We apply SELECT's style, not OPTION's style because m_optionsWidth is
// used to determine intrinsic width of the menulist box.
TextRun text_run = ConstructTextRun(Style()->GetFont(), text, *Style());
......
......@@ -60,7 +60,6 @@
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/text/bidi_resolver.h"
#include "third_party/blink/renderer/platform/text/capitalize.h"
#include "third_party/blink/renderer/platform/text/character.h"
#include "third_party/blink/renderer/platform/text/hyphenation.h"
#include "third_party/blink/renderer/platform/text/text_break_iterator.h"
......@@ -1663,37 +1662,16 @@ void LayoutText::AddLayerHitTestRects(
// Text nodes aren't event targets, so don't descend any further.
}
void ApplyTextTransform(const ComputedStyle* style,
String& text,
UChar previous_character) {
if (!style)
return;
switch (style->TextTransform()) {
case ETextTransform::kNone:
break;
case ETextTransform::kCapitalize:
text = Capitalize(text, previous_character);
break;
case ETextTransform::kUppercase:
text = text.UpperUnicode(style->Locale());
break;
case ETextTransform::kLowercase:
text = text.LowerUnicode(style->Locale());
break;
}
}
void LayoutText::SetTextInternal(scoped_refptr<StringImpl> text) {
DCHECK(text);
text_ = String(std::move(text));
if (Style()) {
ApplyTextTransform(Style(), text_, PreviousCharacter());
if (const ComputedStyle* style = Style()) {
style->ApplyTextTransform(&text_, PreviousCharacter());
// We use the same characters here as for list markers.
// See the listMarkerText function in LayoutListMarker.cpp.
switch (Style()->TextSecurity()) {
switch (style->TextSecurity()) {
case ETextSecurity::kNone:
break;
case ETextSecurity::kCircle:
......
......@@ -430,8 +430,6 @@ inline LayoutText* Text::GetLayoutObject() const {
return ToLayoutText(CharacterData::GetLayoutObject());
}
void ApplyTextTransform(const ComputedStyle*, String&, UChar);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_H_
......@@ -191,10 +191,10 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
String first_line_string;
if (inline_text_box_.IsFirstLineStyle()) {
first_line_string = layout_item_string;
ApplyTextTransform(
inline_text_box_.GetLineLayoutItem().Style(
inline_text_box_.IsFirstLineStyle()),
first_line_string,
const ComputedStyle& style = inline_text_box_.GetLineLayoutItem().StyleRef(
inline_text_box_.IsFirstLineStyle());
style.ApplyTextTransform(
&first_line_string,
inline_text_box_.GetLineLayoutItem().PreviousCharacter());
// TODO(crbug.com/795498): this is a hack. The root issue is that
// capitalizing letters can change the length of the backing string.
......
......@@ -61,6 +61,7 @@
#include "third_party/blink/renderer/platform/geometry/float_rounded_rect.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/length_functions.h"
#include "third_party/blink/renderer/platform/text/capitalize.h"
#include "third_party/blink/renderer/platform/transforms/rotate_transform_operation.h"
#include "third_party/blink/renderer/platform/transforms/scale_transform_operation.h"
#include "third_party/blink/renderer/platform/transforms/translate_transform_operation.h"
......@@ -1399,6 +1400,24 @@ bool ComputedStyle::ShouldUseTextIndent(bool is_first_line,
: !should_use;
}
void ComputedStyle::ApplyTextTransform(String* text,
UChar previous_character) const {
switch (TextTransform()) {
case ETextTransform::kNone:
return;
case ETextTransform::kCapitalize:
*text = Capitalize(*text, previous_character);
return;
case ETextTransform::kUppercase:
*text = text->UpperUnicode(Locale());
return;
case ETextTransform::kLowercase:
*text = text->LowerUnicode(Locale());
return;
}
NOTREACHED();
}
const AtomicString& ComputedStyle::TextEmphasisMarkString() const {
switch (GetTextEmphasisMark()) {
case TextEmphasisMark::kNone:
......
......@@ -1322,6 +1322,9 @@ class ComputedStyle : public ComputedStyleBase,
bool ShouldUseTextIndent(bool is_first_line,
bool is_after_forced_break) const;
// text-transform utility functions.
void ApplyTextTransform(String*, UChar previous_character = ' ') const;
// Line-height utility functions.
const Length& SpecifiedLineHeight() const;
int ComputedLineHeight() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment