Commit 4313fc6e authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Remove LayoutMenuList::inner_block_height_

This CL removes inner_block_height_, which is a cache of inner_block_'s
height because:

 - The computation of the height doesn't look a heavy operation.
 - inner_block_height_ was referred only if
   -webkit-appearance:menulist*.

This CL has no behavior changes.

Bug: 1040828
Change-Id: Ic70ee31202fffaaaecfacc47c5141f52a921be55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032685Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737195}
parent 299446d1
...@@ -45,7 +45,6 @@ LayoutMenuList::LayoutMenuList(Element* element) ...@@ -45,7 +45,6 @@ LayoutMenuList::LayoutMenuList(Element* element)
: LayoutFlexibleBox(element), : LayoutFlexibleBox(element),
button_text_(nullptr), button_text_(nullptr),
inner_block_(nullptr), inner_block_(nullptr),
inner_block_height_(LayoutUnit()),
options_width_(0) { options_width_(0) {
DCHECK(IsA<HTMLSelectElement>(element)); DCHECK(IsA<HTMLSelectElement>(element));
} }
...@@ -200,14 +199,6 @@ void LayoutMenuList::StyleDidChange(StyleDifference diff, ...@@ -200,14 +199,6 @@ void LayoutMenuList::StyleDidChange(StyleDifference diff,
button_text_->SetStyle(Style()); button_text_->SetStyle(Style());
UpdateInnerStyle(); UpdateInnerStyle();
UpdateInnerBlockHeight();
}
void LayoutMenuList::UpdateInnerBlockHeight() {
const SimpleFontData* font_data = StyleRef().GetFont().PrimaryFont();
DCHECK(font_data);
inner_block_height_ = (font_data ? font_data->GetFontMetrics().Height() : 0) +
inner_block_->BorderAndPaddingHeight();
} }
void LayoutMenuList::UpdateOptionsWidth() const { void LayoutMenuList::UpdateOptionsWidth() const {
...@@ -286,8 +277,14 @@ void LayoutMenuList::ComputeLogicalHeight( ...@@ -286,8 +277,14 @@ void LayoutMenuList::ComputeLogicalHeight(
LayoutUnit logical_height, LayoutUnit logical_height,
LayoutUnit logical_top, LayoutUnit logical_top,
LogicalExtentComputedValues& computed_values) const { LogicalExtentComputedValues& computed_values) const {
if (StyleRef().HasEffectiveAppearance()) if (StyleRef().HasEffectiveAppearance()) {
logical_height = inner_block_height_ + BorderAndPaddingHeight(); const SimpleFontData* font_data = StyleRef().GetFont().PrimaryFont();
DCHECK(font_data);
const LayoutUnit inner_block_height =
(font_data ? font_data->GetFontMetrics().Height() : 0) +
inner_block_->BorderAndPaddingHeight();
logical_height = inner_block_height + BorderAndPaddingHeight();
}
LayoutBox::ComputeLogicalHeight(logical_height, logical_top, computed_values); LayoutBox::ComputeLogicalHeight(logical_height, logical_top, computed_values);
} }
......
...@@ -79,14 +79,12 @@ class CORE_EXPORT LayoutMenuList final : public LayoutFlexibleBox { ...@@ -79,14 +79,12 @@ class CORE_EXPORT LayoutMenuList final : public LayoutFlexibleBox {
void AdjustInnerStyle(const ComputedStyle& parent_style, void AdjustInnerStyle(const ComputedStyle& parent_style,
ComputedStyle& inner_style) const; ComputedStyle& inner_style) const;
bool HasOptionStyleChanged(const ComputedStyle& inner_style) const; bool HasOptionStyleChanged(const ComputedStyle& inner_style) const;
void UpdateInnerBlockHeight();
void UpdateOptionsWidth() const; void UpdateOptionsWidth() const;
void SetIndexToSelectOnCancel(int list_index); void SetIndexToSelectOnCancel(int list_index);
LayoutText* button_text_; LayoutText* button_text_;
LayoutBlock* inner_block_; LayoutBlock* inner_block_;
LayoutUnit inner_block_height_;
// m_optionsWidth is calculated and cached on demand. // m_optionsWidth is calculated and cached on demand.
// updateOptionsWidth() should be called before reading them. // updateOptionsWidth() should be called before reading them.
mutable int options_width_; mutable int options_width_;
......
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