Commit d1c6bb1f authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Slider NG: Apply LayoutObjectFactory

This CL applies LayoutObjectFactory to
RangeInputType::CreateLayoutObject() and
SliderTrackElement::CreateLayoutObject().

This CL adds LayoutObjectFactory::CreateSliderTrack()
for SliderTrackElement.
 - The function returns LayoutNGBlockFlow for LayoutNG
 - The constructor of LayoutSliderTrack should take Element*.
   CreateObject<> requires it.

This CL has no behavior changes because
RangeInputType::TypeShouldForceLegacyLayout() still returns |true|.

Bug: 1040826
Change-Id: Id4ba89f09e5ff16f6b5f1f7d5c477162395beaff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419091
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@{#808452}
parent da4998c2
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input_type_names.h" #include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/layout/layout_flexible_box.h" #include "third_party/blink/renderer/core/layout/layout_block.h"
#include "third_party/blink/renderer/core/layout/layout_object_factory.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
...@@ -258,13 +259,13 @@ bool RangeInputType::TypeShouldForceLegacyLayout() const { ...@@ -258,13 +259,13 @@ bool RangeInputType::TypeShouldForceLegacyLayout() const {
return true; return true;
} }
LayoutObject* RangeInputType::CreateLayoutObject(const ComputedStyle&, LayoutObject* RangeInputType::CreateLayoutObject(const ComputedStyle& style,
LegacyLayout) const { LegacyLayout legacy) const {
UseCounter::Count(GetElement().GetDocument(), UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutBySlider); WebFeature::kLegacyLayoutBySlider);
// TODO(crbug.com/1040826): input[type=range] should not use // TODO(crbug.com/1040826): input[type=range] should not use
// LayoutFlexibleBox. // LayoutFlexibleBox.
return new LayoutFlexibleBox(&GetElement()); return LayoutObjectFactory::CreateFlexibleBox(GetElement(), style, legacy);
} }
Decimal RangeInputType::ParseToNumber(const String& src, Decimal RangeInputType::ParseToNumber(const String& src,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "third_party/blink/renderer/core/html/forms/slider_track_element.h" #include "third_party/blink/renderer/core/html/forms/slider_track_element.h"
#include "third_party/blink/renderer/core/layout/layout_slider_track.h" #include "third_party/blink/renderer/core/layout/layout_object_factory.h"
namespace blink { namespace blink {
...@@ -13,7 +13,7 @@ SliderTrackElement::SliderTrackElement(Document& document) ...@@ -13,7 +13,7 @@ SliderTrackElement::SliderTrackElement(Document& document)
LayoutObject* SliderTrackElement::CreateLayoutObject(const ComputedStyle& style, LayoutObject* SliderTrackElement::CreateLayoutObject(const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
return new LayoutSliderTrack(this); return LayoutObjectFactory::CreateSliderTrack(*this, style, legacy);
} }
} // namespace blink } // namespace blink
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "third_party/blink/renderer/core/layout/layout_list_item.h" #include "third_party/blink/renderer/core/layout/layout_list_item.h"
#include "third_party/blink/renderer/core/layout/layout_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_list_marker.h"
#include "third_party/blink/renderer/core/layout/layout_outside_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_outside_list_marker.h"
#include "third_party/blink/renderer/core/layout/layout_slider_track.h"
#include "third_party/blink/renderer/core/layout/layout_table.h" #include "third_party/blink/renderer/core/layout/layout_table.h"
#include "third_party/blink/renderer/core/layout/layout_table_caption.h" #include "third_party/blink/renderer/core/layout/layout_table_caption.h"
#include "third_party/blink/renderer/core/layout/layout_table_cell.h" #include "third_party/blink/renderer/core/layout/layout_table_cell.h"
...@@ -264,6 +265,13 @@ LayoutBlockFlow* LayoutObjectFactory::CreateFileUploadControl( ...@@ -264,6 +265,13 @@ LayoutBlockFlow* LayoutObjectFactory::CreateFileUploadControl(
LayoutFileUploadControl>(node, style, legacy); LayoutFileUploadControl>(node, style, legacy);
} }
LayoutObject* LayoutObjectFactory::CreateSliderTrack(Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
return CreateObject<LayoutBlock, LayoutNGBlockFlow, LayoutSliderTrack>(
node, style, legacy);
}
LayoutText* LayoutObjectFactory::CreateText(Node* node, LayoutText* LayoutObjectFactory::CreateText(Node* node,
scoped_refptr<StringImpl> str, scoped_refptr<StringImpl> str,
LegacyLayout legacy) { LegacyLayout legacy) {
......
...@@ -73,6 +73,9 @@ class LayoutObjectFactory { ...@@ -73,6 +73,9 @@ class LayoutObjectFactory {
static LayoutBlockFlow* CreateFileUploadControl(Node& node, static LayoutBlockFlow* CreateFileUploadControl(Node& node,
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy); LegacyLayout legacy);
static LayoutObject* CreateSliderTrack(Node& node,
const ComputedStyle& style,
LegacyLayout legacy);
static LayoutText* CreateText(Node*, scoped_refptr<StringImpl>, LegacyLayout); static LayoutText* CreateText(Node*, scoped_refptr<StringImpl>, LegacyLayout);
static LayoutTextFragment* CreateTextFragment(Node*, static LayoutTextFragment* CreateTextFragment(Node*,
......
...@@ -33,12 +33,11 @@ ...@@ -33,12 +33,11 @@
#include "third_party/blink/renderer/core/dom/shadow_root.h" #include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h" #include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/slider_track_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
namespace blink { namespace blink {
LayoutSliderTrack::LayoutSliderTrack(SliderTrackElement* element) LayoutSliderTrack::LayoutSliderTrack(Element* element)
: LayoutBlockFlow(element) {} : LayoutBlockFlow(element) {}
void LayoutSliderTrack::UpdateLayout() { void LayoutSliderTrack::UpdateLayout() {
......
...@@ -36,11 +36,9 @@ ...@@ -36,11 +36,9 @@
namespace blink { namespace blink {
class SliderTrackElement;
class LayoutSliderTrack final : public LayoutBlockFlow { class LayoutSliderTrack final : public LayoutBlockFlow {
public: public:
explicit LayoutSliderTrack(SliderTrackElement*); explicit LayoutSliderTrack(Element*);
private: private:
void UpdateLayout() override; void UpdateLayout() override;
......
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