Commit 0e1cf9ac authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Skip some work if style didn't change

R=kojii@chromium.org,eae@chromium.org

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I6eb59b3683c54d703b311842fe333b2590d05882
Reviewed-on: https://chromium-review.googlesource.com/1217708Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590190}
parent 329c5eb9
......@@ -1151,13 +1151,9 @@ void NGLineBreaker::Rewind(unsigned new_end) {
}
void NGLineBreaker::SetCurrentStyle(const ComputedStyle& style) {
current_style_ = &style;
auto_wrap_ = style.AutoWrap();
if (auto_wrap_) {
break_iterator_.SetLocale(style.LocaleForLineBreakIterator());
if (UNLIKELY(override_break_anywhere_)) {
break_iterator_.SetBreakType(LineBreakType::kBreakCharacter);
} else {
......@@ -1186,6 +1182,15 @@ void NGLineBreaker::SetCurrentStyle(const ComputedStyle& style) {
hyphenation_ = style.GetHyphenation();
}
// The above calls are cheap & necessary. But the following are expensive
// and do not need to be reset every time if the style doesn't change,
// so avoid them if possible.
if (&style == current_style_.get())
return;
current_style_ = &style;
if (auto_wrap_)
break_iterator_.SetLocale(style.LocaleForLineBreakIterator());
spacing_.SetSpacing(style.GetFontDescription());
}
......
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