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

TextControl NG: Implement LayoutNGTextControlMultiLine::NodeAtPoint() override

Port LayoutTextControlMultiLine::NodeAtPoint() to
LayoutNGTextControlMultiLine.

- Make LayoutTextControl::HitInnerEditorElement() public and static
  in order to share it with LayoutNGTextControl*.


This CL fixes the following web tests with LayoutNGTextArea flag:
- fast/events/inputevents/inputevent-drag-drop.html
- fast/forms/input-readonly-select.html
- fast/forms/textarea/drag-into-textarea.html
- fast/forms/textarea/drag-out-of-textarea.html

This CL has no behavior changes.  The flag is not enabled yet.

Bug: 1040826
Change-Id: Ia369377659d78476302f8c4b7e32532d60f938f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463007
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815563}
parent bbfb06af
...@@ -90,19 +90,20 @@ int LayoutTextControl::ScrollbarThickness(const LayoutBox& box) { ...@@ -90,19 +90,20 @@ int LayoutTextControl::ScrollbarThickness(const LayoutBox& box) {
} }
void LayoutTextControl::HitInnerEditorElement( void LayoutTextControl::HitInnerEditorElement(
const LayoutBox& box,
HTMLElement& inner_editor,
HitTestResult& result, HitTestResult& result,
const HitTestLocation& hit_test_location, const HitTestLocation& hit_test_location,
const PhysicalOffset& accumulated_offset) { const PhysicalOffset& accumulated_offset) {
NOT_DESTROYED(); NOT_DESTROYED();
HTMLElement* inner_editor = InnerEditorElement(); if (!inner_editor.GetLayoutObject())
if (!inner_editor->GetLayoutObject())
return; return;
PhysicalOffset local_point = PhysicalOffset local_point =
hit_test_location.Point() - accumulated_offset - hit_test_location.Point() - accumulated_offset -
inner_editor->GetLayoutObject()->LocalToAncestorPoint(PhysicalOffset(), inner_editor.GetLayoutObject()->LocalToAncestorPoint(PhysicalOffset(),
this); &box);
result.SetNodeAndPosition(inner_editor, local_point); result.SetNodeAndPosition(&inner_editor, local_point);
} }
static const char* const kFontFamiliesWithInvalidCharWidth[] = { static const char* const kFontFamiliesWithInvalidCharWidth[] = {
......
...@@ -53,6 +53,12 @@ class CORE_EXPORT LayoutTextControl : public LayoutBlockFlow { ...@@ -53,6 +53,12 @@ class CORE_EXPORT LayoutTextControl : public LayoutBlockFlow {
static float GetAvgCharWidth(const ComputedStyle& style); static float GetAvgCharWidth(const ComputedStyle& style);
static bool HasValidAvgCharWidth(const Font& font); static bool HasValidAvgCharWidth(const Font& font);
static void HitInnerEditorElement(const LayoutBox& box,
HTMLElement& inner_editor,
HitTestResult&,
const HitTestLocation&,
const PhysicalOffset& accumulated_offset);
protected: protected:
LayoutTextControl(TextControlElement*); LayoutTextControl(TextControlElement*);
...@@ -62,10 +68,6 @@ class CORE_EXPORT LayoutTextControl : public LayoutBlockFlow { ...@@ -62,10 +68,6 @@ class CORE_EXPORT LayoutTextControl : public LayoutBlockFlow {
void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override; void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override;
void HitInnerEditorElement(HitTestResult&,
const HitTestLocation&,
const PhysicalOffset& accumulated_offset);
LayoutObject* LayoutSpecialExcludedChild(bool relayout_children, LayoutObject* LayoutSpecialExcludedChild(bool relayout_children,
SubtreeLayoutScope&) override; SubtreeLayoutScope&) override;
......
...@@ -50,9 +50,10 @@ bool LayoutTextControlMultiLine::NodeAtPoint( ...@@ -50,9 +50,10 @@ bool LayoutTextControlMultiLine::NodeAtPoint(
return true; return true;
if (result.InnerNode() == GetNode() || if (result.InnerNode() == GetNode() ||
result.InnerNode() == InnerEditorElement()) result.InnerNode() == InnerEditorElement()) {
HitInnerEditorElement(result, hit_test_location, accumulated_offset); HitInnerEditorElement(*this, *InnerEditorElement(), result,
hit_test_location, accumulated_offset);
}
return true; return true;
} }
......
...@@ -171,7 +171,8 @@ bool LayoutTextControlSingleLine::NodeAtPoint( ...@@ -171,7 +171,8 @@ bool LayoutTextControlSingleLine::NodeAtPoint(
container->GetLayoutBox()->PhysicalLocation(); container->GetLayoutBox()->PhysicalLocation();
} }
} }
HitInnerEditorElement(result, hit_test_location, accumulated_offset); HitInnerEditorElement(*this, *InnerEditorElement(), result,
hit_test_location, accumulated_offset);
} }
return true; return true;
} }
......
...@@ -46,7 +46,7 @@ class LayoutNGBlockFlowMixin : public LayoutNGMixin<Base> { ...@@ -46,7 +46,7 @@ class LayoutNGBlockFlowMixin : public LayoutNGMixin<Base> {
bool NodeAtPoint(HitTestResult&, bool NodeAtPoint(HitTestResult&,
const HitTestLocation&, const HitTestLocation&,
const PhysicalOffset& accumulated_offset, const PhysicalOffset& accumulated_offset,
HitTestAction) final; HitTestAction) override;
PositionWithAffinity PositionForPoint(const PhysicalOffset&) const override; PositionWithAffinity PositionForPoint(const PhysicalOffset&) const override;
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.h"
#include "third_party/blink/renderer/core/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/layout/layout_text_control.h"
namespace blink { namespace blink {
LayoutNGTextControlMultiLine::LayoutNGTextControlMultiLine(Element* element) LayoutNGTextControlMultiLine::LayoutNGTextControlMultiLine(Element* element)
...@@ -14,4 +17,26 @@ bool LayoutNGTextControlMultiLine::IsOfType(LayoutObjectType type) const { ...@@ -14,4 +17,26 @@ bool LayoutNGTextControlMultiLine::IsOfType(LayoutObjectType type) const {
LayoutNGBlockFlow::IsOfType(type); LayoutNGBlockFlow::IsOfType(type);
} }
bool LayoutNGTextControlMultiLine::NodeAtPoint(
HitTestResult& result,
const HitTestLocation& hit_test_location,
const PhysicalOffset& accumulated_offset,
HitTestAction hit_test_action) {
if (!LayoutNGBlockFlow::NodeAtPoint(result, hit_test_location,
accumulated_offset, hit_test_action))
return false;
const LayoutObject* stop_node = result.GetHitTestRequest().GetStopNode();
if (stop_node && stop_node->NodeForHitTest() == result.InnerNode())
return true;
HTMLElement* inner_editor =
To<TextControlElement>(GetNode())->InnerEditorElement();
if (result.InnerNode() == GetNode() || result.InnerNode() == inner_editor) {
LayoutTextControl::HitInnerEditorElement(
*this, *inner_editor, result, hit_test_location, accumulated_offset);
}
return true;
}
} // namespace blink } // namespace blink
...@@ -26,6 +26,11 @@ class LayoutNGTextControlMultiLine final : public LayoutNGBlockFlow { ...@@ -26,6 +26,11 @@ class LayoutNGTextControlMultiLine final : public LayoutNGBlockFlow {
NOT_DESTROYED(); NOT_DESTROYED();
return true; return true;
} }
bool NodeAtPoint(HitTestResult& result,
const HitTestLocation& hit_test_location,
const PhysicalOffset& accumulated_offset,
HitTestAction hit_test_action) override;
}; };
} // namespace blink } // namespace blink
......
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