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

Move InDragMode() out from LayoutSlider

to RangeInputType.
This CL has no behavior changes.

Bug: 1040828
Change-Id: I6d4ba4faf0467da4db268ebd4cc4d37a992c973b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006897Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732780}
parent c6608291
......@@ -2003,4 +2003,8 @@ PaintLayerScrollableArea* HTMLInputElement::GetScrollableArea() const {
return Element::GetScrollableArea();
}
bool HTMLInputElement::IsDraggedSlider() const {
return input_type_view_->IsDraggedSlider();
}
} // namespace blink
......@@ -319,6 +319,8 @@ class CORE_EXPORT HTMLInputElement
void SetHasBeenPasswordField() { has_been_password_field_ = true; }
bool IsDraggedSlider() const;
protected:
void DefaultEventHandler(Event&) override;
void CreateShadowSubtree();
......
......@@ -189,6 +189,10 @@ void InputTypeView::RestoreFormControlState(const FormControlState& state) {
GetElement().setValue(state[0]);
}
bool InputTypeView::IsDraggedSlider() const {
return false;
}
bool InputTypeView::HasBadInput() const {
return false;
}
......
......@@ -135,6 +135,7 @@ class CORE_EXPORT InputTypeView : public GarbageCollectedMixin {
virtual bool HasFallbackContent() const { return false; }
virtual FormControlState SaveFormControlState() const;
virtual void RestoreFormControlState(const FormControlState&);
virtual bool IsDraggedSlider() const;
// Validation functions
virtual bool HasBadInput() const;
......
......@@ -419,4 +419,8 @@ void RangeInputType::ValueAttributeChanged() {
UpdateView();
}
bool RangeInputType::IsDraggedSlider() const {
return GetSliderThumbElement()->IsActive();
}
} // namespace blink
......@@ -86,6 +86,7 @@ class RangeInputType final : public InputType, public InputTypeView {
// InputTypeView function:
void UpdateView() override;
void ValueAttributeChanged() override;
bool IsDraggedSlider() const override;
bool tick_mark_values_dirty_;
Vector<Decimal> tick_mark_values_;
......
......@@ -19,10 +19,7 @@
#include "third_party/blink/renderer/core/layout/layout_slider.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/slider_thumb_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
......@@ -57,14 +54,4 @@ void LayoutSlider::ComputeIntrinsicLogicalWidths(
min_logical_width = max_logical_width;
}
inline SliderThumbElement* LayoutSlider::GetSliderThumbElement() const {
return To<SliderThumbElement>(
To<Element>(GetNode())->UserAgentShadowRoot()->getElementById(
shadow_element_names::SliderThumb()));
}
bool LayoutSlider::InDragMode() const {
return GetSliderThumbElement()->IsActive();
}
} // namespace blink
......@@ -27,7 +27,6 @@
namespace blink {
class HTMLInputElement;
class SliderThumbElement;
class CORE_EXPORT LayoutSlider final : public LayoutFlexibleBox {
public:
......@@ -36,8 +35,6 @@ class CORE_EXPORT LayoutSlider final : public LayoutFlexibleBox {
explicit LayoutSlider(HTMLInputElement*);
~LayoutSlider() override;
bool InDragMode() const;
const char* GetName() const override { return "LayoutSlider"; }
private:
......@@ -53,8 +50,6 @@ class CORE_EXPORT LayoutSlider final : public LayoutFlexibleBox {
void ComputeIntrinsicLogicalWidths(
LayoutUnit& min_logical_width,
LayoutUnit& max_logical_width) const override;
SliderThumbElement* GetSliderThumbElement() const;
};
DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSlider, IsSlider());
......
......@@ -8,7 +8,6 @@
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/html/html_div_element.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/layout/layout_slider.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_div_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_input_element.h"
......@@ -41,12 +40,14 @@ bool MediaControlElementsHelper::IsUserInteractionEventForSlider(
return true;
// Some events are only captured during a slider drag.
const LayoutSlider* slider = ToLayoutSlider(layout_object);
// TODO(crbug.com/695459#c1): LayoutSliderItem::inDragMode is incorrectly
const HTMLInputElement* slider = nullptr;
if (layout_object)
slider = DynamicTo<HTMLInputElement>(layout_object->GetNode());
// TODO(crbug.com/695459#c1): HTMLInputElement::IsDraggedSlider is incorrectly
// false for drags that start from the track instead of the thumb.
// Use SliderThumbElement::m_inDragMode and
// SliderContainerElement::m_touchStarted instead.
if (slider && !slider->InDragMode())
// Use SliderThumbElement::in_drag_mode_ and
// SliderContainerElement::touch_started_ instead.
if (slider && !slider->IsDraggedSlider())
return false;
const AtomicString& type = event.type();
......
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