Commit 15a1b419 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Slider NG: Add special baseline handling

This CL ports a logic in LayoutFlexibleBox::BaselinePosition() to
LayoutNG.

This CL has no behavior changes because input[type=range] still uses
the legacy layout.

Bug: 1040826
Change-Id: If40a81d75b9fecd02c3b924501258da94b2d2369
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423679
Auto-Submit: Kent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809875}
parent ed1756b9
......@@ -263,7 +263,7 @@ LayoutObject* RangeInputType::CreateLayoutObject(const ComputedStyle& style,
LegacyLayout legacy) const {
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutBySlider);
// TODO(crbug.com/1040826): input[type=range] should not use
// TODO(crbug.com/1131352): input[type=range] should not use
// LayoutFlexibleBox.
return LayoutObjectFactory::CreateFlexibleBox(GetElement(), style, legacy);
}
......
......@@ -219,7 +219,7 @@ LayoutUnit LayoutFlexibleBox::BaselinePosition(FontBaseline,
LinePositionMode mode) const {
CheckIsNotDestroyed();
DCHECK_EQ(mode, kPositionOnContainingLine);
// TODO(crbug.com/1040826): input[type=range] should not use
// TODO(crbug.com/1131352): input[type=range] should not use
// LayoutFlexibleBox. We should move out this code.
if (const auto* input = DynamicTo<HTMLInputElement>(GetNode())) {
if (input->type() == input_type_names::kRange) {
......
......@@ -1205,8 +1205,13 @@ bool NGFlexLayoutAlgorithm::GiveLinesAndItemsFinalPositionAndSize() {
if (!container_builder_.Baseline() && fallback_baseline)
container_builder_.SetBaseline(*fallback_baseline);
if (Node().IsButton())
// TODO(crbug.com/1131352): Avoid control-specific handling.
if (Node().IsButton()) {
AdjustButtonBaseline(final_content_cross_size);
} else if (Node().IsSlider()) {
container_builder_.SetBaseline(BorderScrollbarPadding().BlockSum() +
final_content_cross_size);
}
// Signal if we need to relayout with new child scrollbar information.
return success;
......
......@@ -4,6 +4,8 @@
#include "third_party/blink/renderer/core/layout/ng/ng_layout_input_node.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
#include "third_party/blink/renderer/core/layout/intrinsic_sizing_info.h"
#include "third_party/blink/renderer/core/layout/layout_replaced.h"
......@@ -63,6 +65,12 @@ void AppendNodeToString(NGLayoutInputNode node,
} // namespace
bool NGLayoutInputNode::IsSlider() const {
if (const auto* input = DynamicTo<HTMLInputElement>(box_->GetNode()))
return input->type() == input_type_names::kRange;
return false;
}
bool NGLayoutInputNode::IsEmptyTableSection() const {
return box_->IsTableSection() && To<LayoutNGTableSection>(box_)->IsEmpty();
}
......
......@@ -135,6 +135,8 @@ class CORE_EXPORT NGLayoutInputNode {
bool IsRenderedLegend() const {
return IsBlock() && box_->IsRenderedLegend();
}
// Return true if this node is for <input type=range>.
bool IsSlider() const;
bool IsTable() const { return IsBlock() && box_->IsTable(); }
bool IsTableCaption() const { return IsBlock() && box_->IsTableCaption(); }
......
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