Commit 286c8ef9 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Eliminate HitTestResult::is_rect_based_test_

This flag should be a copy of the same flag in an associated
HitTestLocation. In all cases where it is used we have said
HitTestLocation and can use the flag from there instead.

The most complicated case - HitTestResult::ResolveRectBasedTest - will
return a HitTestLocation with the flag cleared, which should mean that
the state invariant is maintained. EventHandlingUtil::HitTestResultInFrame
as changed to take a HitTestLocation to be able to maintain this invariant
a little easier.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I8b8d17a4fabca725ec089f18550523a19b677c75
Reviewed-on: https://chromium-review.googlesource.com/1127939
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573441}
parent d8354966
......@@ -709,7 +709,7 @@ WebInputEventResult EventHandler::HandleMousePressEvent(
// the same behavior and it's more compatible with other browsers.
GetSelectionController().InitializeSelectionState();
HitTestResult hit_test_result = EventHandlingUtil::HitTestResultInFrame(
frame_, document_point, HitTestRequest::kReadOnly);
frame_, HitTestLocation(document_point), HitTestRequest::kReadOnly);
InputDeviceCapabilities* source_capabilities =
frame_->GetDocument()
->domWindow()
......@@ -1461,7 +1461,7 @@ bool EventHandler::BestClickableNodeForHitTestResult(
// FIXME: Unify this with the other best* functions which are very similar.
TRACE_EVENT0("input", "EventHandler::bestClickableNodeForHitTestResult");
DCHECK(result.IsRectBasedTest());
DCHECK(location.IsRectBasedTest());
// If the touch is over a scrollbar, don't adjust the touch point since touch
// adjustment only takes into account DOM nodes so a touch over a scrollbar
......@@ -1492,7 +1492,7 @@ bool EventHandler::BestContextMenuNodeForHitTestResult(
const HitTestResult& result,
IntPoint& target_point,
Node*& target_node) {
DCHECK(result.IsRectBasedTest());
DCHECK(location.IsRectBasedTest());
IntPoint touch_center =
frame_->View()->ConvertToRootFrame(RoundedIntPoint(location.Point()));
IntRect touch_rect =
......@@ -1753,7 +1753,7 @@ GestureEventWithHitTestResults EventHandler::HitTestResultForGestureEvent(
location, hit_type);
}
if (hit_test_result.IsRectBasedTest()) {
if (location.IsRectBasedTest()) {
// Adjust the location of the gesture to the most likely nearby node, as
// appropriate for the type of event.
ApplyTouchAdjustment(&adjusted_event, location, &hit_test_result);
......@@ -1766,16 +1766,16 @@ GestureEventWithHitTestResults EventHandler::HitTestResultForGestureEvent(
LocalFrame* hit_frame = hit_test_result.InnerNodeFrame();
if (!hit_frame)
hit_frame = frame_;
location = HitTestLocation(hit_frame->View()->ConvertFromRootFrame(
LayoutPoint(adjusted_event.PositionInRootFrame())));
hit_test_result = EventHandlingUtil::HitTestResultInFrame(
hit_frame,
hit_frame->View()->ConvertFromRootFrame(
LayoutPoint(adjusted_event.PositionInRootFrame())),
hit_frame, location,
(hit_type | HitTestRequest::kReadOnly) & ~HitTestRequest::kListBased);
}
// If we did a rect-based hit test it must be resolved to the best single node
// by now to ensure consumers don't accidentally use one of the other
// candidates.
DCHECK(!hit_test_result.IsRectBasedTest());
DCHECK(!location.IsRectBasedTest());
if (ShouldApplyTouchAdjustment(gesture_event) &&
(gesture_event.GetType() == WebInputEvent::kGestureTap ||
......@@ -1822,6 +1822,7 @@ void EventHandler::ApplyTouchAdjustment(WebGestureEvent* gesture_event,
if (adjusted) {
LayoutPoint point = frame_->View()->ConvertFromRootFrame(adjusted_point);
DCHECK(location.ContainsPoint(FloatPoint(point)));
DCHECK(location.IsRectBasedTest());
location = hit_test_result->ResolveRectBasedTest(adjusted_node, point);
gesture_event->ApplyTouchAdjustment(
WebFloatPoint(adjusted_point.X(), adjusted_point.Y()));
......
......@@ -18,16 +18,16 @@ namespace EventHandlingUtil {
HitTestResult HitTestResultInFrame(
LocalFrame* frame,
const LayoutPoint& point,
const HitTestLocation& location,
HitTestRequest::HitTestRequestType hit_type) {
HitTestLocation location(point);
DCHECK(!location.IsRectBasedTest());
HitTestResult result(HitTestRequest(hit_type), location);
if (!frame || !frame->ContentLayoutObject())
return result;
if (frame->View()) {
IntRect rect(IntPoint(), frame->View()->Size());
if (!rect.Contains(RoundedIntPoint(point)))
FloatRect rect(FloatPoint(), FloatSize(frame->View()->Size()));
if (!location.Intersects(rect))
return result;
}
frame->ContentLayoutObject()->HitTest(location, result);
......
......@@ -24,7 +24,7 @@ namespace EventHandlingUtil {
HitTestResult HitTestResultInFrame(
LocalFrame*,
const LayoutPoint&,
const HitTestLocation&,
HitTestRequest::HitTestRequestType hit_type = HitTestRequest::kReadOnly |
HitTestRequest::kActive);
......
......@@ -196,7 +196,7 @@ WebInputEventResult GestureManager::HandleGestureTap(
adjusted_point = frame_view->ConvertFromRootFrame(
FlooredIntPoint(gesture_event.PositionInRootFrame()));
current_hit_test = EventHandlingUtil::HitTestResultInFrame(
frame_, adjusted_point, hit_type);
frame_, HitTestLocation(adjusted_point), hit_type);
}
// Capture data for showUnhandledTapUIIfNeeded.
......@@ -259,7 +259,7 @@ WebInputEventResult GestureManager::HandleGestureTap(
main_frame.View()->UpdateAllLifecyclePhases();
adjusted_point = frame_view->ConvertFromRootFrame(tapped_position);
current_hit_test = EventHandlingUtil::HitTestResultInFrame(
frame_, adjusted_point, hit_type);
frame_, HitTestLocation(adjusted_point), hit_type);
}
WebMouseEvent fake_mouse_up(
......
......@@ -532,11 +532,11 @@ void TouchEventManager::UpdateTouchAttributeMapsForPointerDown(
if (touch_sequence_document_ &&
(!touch_node || &touch_node->GetDocument() != touch_sequence_document_)) {
if (touch_sequence_document_->GetFrame()) {
LayoutPoint frame_point = LayoutPoint(
HitTestLocation location(LayoutPoint(
touch_sequence_document_->GetFrame()->View()->ConvertFromRootFrame(
event.PositionInWidget()));
event.PositionInWidget())));
result = EventHandlingUtil::HitTestResultInFrame(
touch_sequence_document_->GetFrame(), frame_point, hit_type);
touch_sequence_document_->GetFrame(), location, hit_type);
Node* node = result.InnerNode();
if (!node)
return;
......
......@@ -50,16 +50,14 @@ using namespace HTMLNames;
HitTestResult::HitTestResult()
: hit_test_request_(HitTestRequest::kReadOnly | HitTestRequest::kActive),
cacheable_(true),
is_over_embedded_content_view_(false),
is_rect_based_test_(false) {}
is_over_embedded_content_view_(false) {}
HitTestResult::HitTestResult(const HitTestRequest& other_request,
const HitTestLocation& location)
: hit_test_request_(other_request),
cacheable_(true),
point_in_inner_node_frame_(location.Point()),
is_over_embedded_content_view_(false),
is_rect_based_test_(location.IsRectBasedTest()) {}
is_over_embedded_content_view_(false) {}
HitTestResult::HitTestResult(const HitTestResult& other)
: hit_test_request_(other.hit_test_request_),
......@@ -71,8 +69,7 @@ HitTestResult::HitTestResult(const HitTestResult& other)
inner_url_element_(other.URLElement()),
scrollbar_(other.GetScrollbar()),
is_over_embedded_content_view_(other.IsOverEmbeddedContentView()),
canvas_region_id_(other.CanvasRegionId()),
is_rect_based_test_(other.IsRectBasedTest()) {
canvas_region_id_(other.CanvasRegionId()) {
// Only copy the NodeSet in case of list hit test.
list_based_test_result_ = other.list_based_test_result_
? new NodeSet(*other.list_based_test_result_)
......@@ -114,7 +111,6 @@ void HitTestResult::PopulateFromCachedResult(const HitTestResult& other) {
is_over_embedded_content_view_ = other.IsOverEmbeddedContentView();
cacheable_ = other.cacheable_;
canvas_region_id_ = other.CanvasRegionId();
is_rect_based_test_ = other.IsRectBasedTest();
// Only copy the NodeSet in case of list hit test.
list_based_test_result_ = other.list_based_test_result_
......@@ -455,7 +451,6 @@ HitTestResult::NodeSet& HitTestResult::MutableListBasedTestResult() {
HitTestLocation HitTestResult::ResolveRectBasedTest(
Node* resolved_inner_node,
const LayoutPoint& resolved_point_in_main_frame) {
DCHECK(IsRectBasedTest());
point_in_inner_node_frame_ = resolved_point_in_main_frame;
inner_node_ = nullptr;
inner_possibly_pseudo_node_ = nullptr;
......@@ -468,7 +463,6 @@ HitTestLocation HitTestResult::ResolveRectBasedTest(
DCHECK(resolved_inner_node);
if (auto* layout_object = resolved_inner_node->GetLayoutObject())
layout_object->UpdateHitTestResult(*this, LayoutPoint());
is_rect_based_test_ = false;
return HitTestLocation(resolved_point_in_main_frame);
}
......
......@@ -94,9 +94,6 @@ class CORE_EXPORT HitTestResult {
return is_over_embedded_content_view_;
}
// Forwarded from HitTestLocation
bool IsRectBasedTest() const { return is_rect_based_test_; }
// The hit-tested point in the coordinates of the innerNode frame, the frame
// containing innerNode.
const LayoutPoint& PointInInnerNodeFrame() const {
......@@ -204,7 +201,6 @@ class CORE_EXPORT HitTestResult {
mutable Member<NodeSet> list_based_test_result_;
String canvas_region_id_;
bool is_rect_based_test_;
};
} // namespace blink
......
......@@ -154,7 +154,7 @@ bool LayoutEmbeddedContent::NodeAtPointOverEmbeddedContentView(
// Check to see if we are really over the EmbeddedContentView itself (and not
// just in the border/padding area).
if ((inside || result.IsRectBasedTest()) && !had_result &&
if ((inside || location_in_container.IsRectBasedTest()) && !had_result &&
result.InnerNode() == GetNode()) {
result.SetIsOverEmbeddedContentView(
ContentBoxRect().Contains(result.LocalPoint()));
......
......@@ -2185,7 +2185,7 @@ PaintLayer* PaintLayer::HitTestLayer(
inside_fragment_background_rect) &&
IsHitCandidate(this, false, z_offset_for_contents_ptr,
unflattened_transform_state.get())) {
if (result.IsRectBasedTest())
if (recursion_data.original_location.IsRectBasedTest())
result.Append(temp_result);
else
result = temp_result;
......@@ -2413,7 +2413,8 @@ PaintLayer* PaintLayer::HitTestChildren(
// If it is a list-based test, we can safely append the temporary result
// since it might had hit nodes but not necesserily had hitLayer set.
DCHECK(!result.IsRectBasedTest() || result.GetHitTestRequest().ListBased());
DCHECK(!recursion_data.original_location.IsRectBasedTest() ||
result.GetHitTestRequest().ListBased());
if (result.GetHitTestRequest().ListBased())
result.Append(temp_result);
......
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