Commit 751457a6 authored by sunxd's avatar sunxd Committed by Commit Bot

Rename TouchActionRect to HitTestRect

We are going to implement wheel event handler region computation in
ScrollingCoordinator and painting, since wheel event regions share many
similarities to touch action rects, we want to use the same code path
for wheel events. As a result, TouchActionRect will store wheel data as
well and they should be renamed to HitTestRect.

Bug: 841364
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I1d9c967033846d1945163192a437f11cbebdf641
Reviewed-on: https://chromium-review.googlesource.com/1239490Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianda Sun <sunxd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595330}
parent 6ea9f0aa
...@@ -2895,9 +2895,9 @@ void LayoutObject::AddLayerHitTestRects( ...@@ -2895,9 +2895,9 @@ void LayoutObject::AddLayerHitTestRects(
const size_t kMaxRectsPerLayer = 100; const size_t kMaxRectsPerLayer = 100;
LayerHitTestRects::iterator iter = layer_rects.find(current_layer); LayerHitTestRects::iterator iter = layer_rects.find(current_layer);
Vector<TouchActionRect>* iter_value; Vector<HitTestRect>* iter_value;
if (iter == layer_rects.end()) { if (iter == layer_rects.end()) {
iter_value = &layer_rects.insert(current_layer, Vector<TouchActionRect>()) iter_value = &layer_rects.insert(current_layer, Vector<HitTestRect>())
.stored_value->value; .stored_value->value;
} else { } else {
iter_value = &iter->value; iter_value = &iter->value;
...@@ -2910,7 +2910,7 @@ void LayoutObject::AddLayerHitTestRects( ...@@ -2910,7 +2910,7 @@ void LayoutObject::AddLayerHitTestRects(
if (whitelisted_touch_action != container_whitelisted_touch_action || if (whitelisted_touch_action != container_whitelisted_touch_action ||
!container_rect.Contains(own_rects[i])) { !container_rect.Contains(own_rects[i])) {
iter_value->push_back( iter_value->push_back(
TouchActionRect(own_rects[i], whitelisted_touch_action)); HitTestRect(own_rects[i], whitelisted_touch_action));
if (iter_value->size() > kMaxRectsPerLayer) { if (iter_value->size() > kMaxRectsPerLayer) {
// Just mark the entire layer instead, and switch to walking the layer // Just mark the entire layer instead, and switch to walking the layer
// tree instead of the layout tree. // tree instead of the layout tree.
......
...@@ -51,11 +51,11 @@ ...@@ -51,11 +51,11 @@
#include "third_party/blink/renderer/platform/geometry/float_quad.h" #include "third_party/blink/renderer/platform/geometry/float_quad.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/graphics/compositing_reasons.h" #include "third_party/blink/renderer/platform/graphics/compositing_reasons.h"
#include "third_party/blink/renderer/platform/graphics/hit_test_rect.h"
#include "third_party/blink/renderer/platform/graphics/image_orientation.h" #include "third_party/blink/renderer/platform/graphics/image_orientation.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item_client.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item_client.h"
#include "third_party/blink/renderer/platform/graphics/paint_invalidation_reason.h" #include "third_party/blink/renderer/platform/graphics/paint_invalidation_reason.h"
#include "third_party/blink/renderer/platform/graphics/subtree_paint_property_update_reason.h" #include "third_party/blink/renderer/platform/graphics/subtree_paint_property_update_reason.h"
#include "third_party/blink/renderer/platform/graphics/touch_action_rect.h"
#include "third_party/blink/renderer/platform/transforms/transform_state.h" #include "third_party/blink/renderer/platform/transforms/transform_state.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h" #include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
......
...@@ -265,10 +265,10 @@ static void UpdateLayerTouchActionRects(GraphicsLayer& layer) { ...@@ -265,10 +265,10 @@ static void UpdateLayerTouchActionRects(GraphicsLayer& layer) {
return; return;
const auto& layer_state = layer.GetPropertyTreeState(); const auto& layer_state = layer.GetPropertyTreeState();
Vector<TouchActionRect> touch_action_rects_in_layer_space; Vector<HitTestRect> touch_action_rects_in_layer_space;
if (layer.Client().ShouldThrottleRendering()) { if (layer.Client().ShouldThrottleRendering()) {
layer.CcLayer()->SetTouchActionRegion( layer.CcLayer()->SetTouchActionRegion(
TouchActionRect::BuildRegion(touch_action_rects_in_layer_space)); HitTestRect::BuildRegion(touch_action_rects_in_layer_space));
return; return;
} }
for (const auto& chunk : layer.GetPaintController().PaintChunks()) { for (const auto& chunk : layer.GetPaintController().PaintChunks()) {
...@@ -286,12 +286,12 @@ static void UpdateLayerTouchActionRects(GraphicsLayer& layer) { ...@@ -286,12 +286,12 @@ static void UpdateLayerTouchActionRects(GraphicsLayer& layer) {
} }
LayoutRect layout_rect = LayoutRect(rect.Rect()); LayoutRect layout_rect = LayoutRect(rect.Rect());
layout_rect.MoveBy(-layer.GetOffsetFromTransformNode()); layout_rect.MoveBy(-layer.GetOffsetFromTransformNode());
touch_action_rects_in_layer_space.emplace_back(TouchActionRect( touch_action_rects_in_layer_space.emplace_back(
layout_rect, touch_action_rect.whitelisted_touch_action)); HitTestRect(layout_rect, touch_action_rect.whitelisted_touch_action));
} }
} }
layer.CcLayer()->SetTouchActionRegion( layer.CcLayer()->SetTouchActionRegion(
TouchActionRect::BuildRegion(touch_action_rects_in_layer_space)); HitTestRect::BuildRegion(touch_action_rects_in_layer_space));
} }
static void ClearPositionConstraintExceptForLayer(GraphicsLayer* layer, static void ClearPositionConstraintExceptForLayer(GraphicsLayer* layer,
...@@ -630,7 +630,7 @@ void ScrollingCoordinator::ScrollableAreaScrollLayerDidChange( ...@@ -630,7 +630,7 @@ void ScrollingCoordinator::ScrollableAreaScrollLayerDidChange(
} }
using GraphicsLayerHitTestRects = using GraphicsLayerHitTestRects =
WTF::HashMap<const GraphicsLayer*, Vector<TouchActionRect>>; WTF::HashMap<const GraphicsLayer*, Vector<HitTestRect>>;
// In order to do a DFS cross-frame walk of the Layer tree, we need to know // In order to do a DFS cross-frame walk of the Layer tree, we need to know
// which Layers have child frames inside of them. This computes a mapping for // which Layers have child frames inside of them. This computes a mapping for
...@@ -685,18 +685,17 @@ static void ProjectRectsToGraphicsLayerSpaceRecursive( ...@@ -685,18 +685,17 @@ static void ProjectRectsToGraphicsLayerSpaceRecursive(
GraphicsLayerHitTestRects::iterator gl_iter = GraphicsLayerHitTestRects::iterator gl_iter =
graphics_rects.find(graphics_layer); graphics_rects.find(graphics_layer);
Vector<TouchActionRect>* gl_rects; Vector<HitTestRect>* gl_rects;
if (gl_iter == graphics_rects.end()) { if (gl_iter == graphics_rects.end()) {
gl_rects = gl_rects = &graphics_rects.insert(graphics_layer, Vector<HitTestRect>())
&graphics_rects.insert(graphics_layer, Vector<TouchActionRect>()) .stored_value->value;
.stored_value->value;
} else { } else {
gl_rects = &gl_iter->value; gl_rects = &gl_iter->value;
} }
// Transform each rect to the co-ordinate space of the graphicsLayer. // Transform each rect to the co-ordinate space of the graphicsLayer.
for (wtf_size_t i = 0; i < layer_iter->value.size(); ++i) { for (wtf_size_t i = 0; i < layer_iter->value.size(); ++i) {
TouchActionRect rect = layer_iter->value[i]; HitTestRect rect = layer_iter->value[i];
if (composited_layer != cur_layer) { if (composited_layer != cur_layer) {
FloatQuad compositor_quad = geometry_map.MapToAncestor( FloatQuad compositor_quad = geometry_map.MapToAncestor(
FloatRect(rect.rect), &composited_layer->GetLayoutObject()); FloatRect(rect.rect), &composited_layer->GetLayoutObject());
...@@ -873,14 +872,13 @@ void ScrollingCoordinator::SetTouchEventTargetRects( ...@@ -873,14 +872,13 @@ void ScrollingCoordinator::SetTouchEventTargetRects(
GraphicsLayer* main_graphics_layer = GraphicsLayer* main_graphics_layer =
layer->GraphicsLayerBacking(&layer->GetLayoutObject()); layer->GraphicsLayerBacking(&layer->GetLayoutObject());
if (main_graphics_layer) { if (main_graphics_layer) {
graphics_layer_rects.insert(main_graphics_layer, graphics_layer_rects.insert(main_graphics_layer, Vector<HitTestRect>());
Vector<TouchActionRect>());
} }
GraphicsLayer* scrolling_contents_layer = layer->GraphicsLayerBacking(); GraphicsLayer* scrolling_contents_layer = layer->GraphicsLayerBacking();
if (scrolling_contents_layer && if (scrolling_contents_layer &&
scrolling_contents_layer != main_graphics_layer) { scrolling_contents_layer != main_graphics_layer) {
graphics_layer_rects.insert(scrolling_contents_layer, graphics_layer_rects.insert(scrolling_contents_layer,
Vector<TouchActionRect>()); Vector<HitTestRect>());
} }
} }
...@@ -905,7 +903,7 @@ void ScrollingCoordinator::SetTouchEventTargetRects( ...@@ -905,7 +903,7 @@ void ScrollingCoordinator::SetTouchEventTargetRects(
for (const auto& layer_rect : graphics_layer_rects) { for (const auto& layer_rect : graphics_layer_rects) {
const GraphicsLayer* graphics_layer = layer_rect.key; const GraphicsLayer* graphics_layer = layer_rect.key;
graphics_layer->CcLayer()->SetTouchActionRegion( graphics_layer->CcLayer()->SetTouchActionRegion(
TouchActionRect::BuildRegion(layer_rect.value)); HitTestRect::BuildRegion(layer_rect.value));
} }
} }
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h"
#include "third_party/blink/renderer/platform/graphics/compositor_element_id.h" #include "third_party/blink/renderer/platform/graphics/compositor_element_id.h"
#include "third_party/blink/renderer/platform/graphics/touch_action_rect.h" #include "third_party/blink/renderer/platform/graphics/hit_test_rect.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/scroll/main_thread_scrolling_reason.h" #include "third_party/blink/renderer/platform/scroll/main_thread_scrolling_reason.h"
#include "third_party/blink/renderer/platform/scroll/scroll_types.h" #include "third_party/blink/renderer/platform/scroll/scroll_types.h"
......
...@@ -173,13 +173,13 @@ void BlockPainter::RecordHitTestData(const PaintInfo& paint_info, ...@@ -173,13 +173,13 @@ void BlockPainter::RecordHitTestData(const PaintInfo& paint_info,
// TODO(pdr): If we are painting the background into the scrolling contents // TODO(pdr): If we are painting the background into the scrolling contents
// layer, we need to use the overflow rect instead of the border box rect. We // layer, we need to use the overflow rect instead of the border box rect. We
// may want to move the call to RecordTouchActionRect into // may want to move the call to RecordHitTestRect into
// BoxPainter::PaintBoxDecorationBackgroundWithRect and share the logic // BoxPainter::PaintBoxDecorationBackgroundWithRect and share the logic
// the background painting code already uses. // the background painting code already uses.
auto rect = layout_block_.BorderBoxRect(); auto rect = layout_block_.BorderBoxRect();
rect.MoveBy(paint_offset); rect.MoveBy(paint_offset);
HitTestData::RecordTouchActionRect(paint_info.context, layout_block_, HitTestData::RecordHitTestRect(paint_info.context, layout_block_,
TouchActionRect(rect, touch_action)); HitTestRect(rect, touch_action));
} }
DISABLE_CFI_PERF DISABLE_CFI_PERF
......
...@@ -341,9 +341,9 @@ void InlineFlowBoxPainter::RecordHitTestData(const PaintInfo& paint_info, ...@@ -341,9 +341,9 @@ void InlineFlowBoxPainter::RecordHitTestData(const PaintInfo& paint_info,
if (touch_action == TouchAction::kTouchActionAuto) if (touch_action == TouchAction::kTouchActionAuto)
return; return;
HitTestData::RecordTouchActionRect( HitTestData::RecordHitTestRect(
paint_info.context, inline_flow_box_, paint_info.context, inline_flow_box_,
TouchActionRect(AdjustedPaintRect(paint_offset), touch_action)); HitTestRect(AdjustedPaintRect(paint_offset), touch_action));
} }
void InlineFlowBoxPainter::PaintNormalBoxShadow(const PaintInfo& info, void InlineFlowBoxPainter::PaintNormalBoxShadow(const PaintInfo& info,
......
...@@ -205,16 +205,16 @@ void NGBoxFragmentPainter::RecordHitTestData(const PaintInfo& paint_info, ...@@ -205,16 +205,16 @@ void NGBoxFragmentPainter::RecordHitTestData(const PaintInfo& paint_info,
// TODO(pdr): If we are painting the background into the scrolling contents // TODO(pdr): If we are painting the background into the scrolling contents
// layer, we need to use the overflow rect instead of the border box rect. We // layer, we need to use the overflow rect instead of the border box rect. We
// may want to move the call to RecordTouchActionRect into // may want to move the call to RecordHitTestRect into
// BoxPainter::PaintBoxDecorationBackgroundWithRect and share the logic // BoxPainter::PaintBoxDecorationBackgroundWithRect and share the logic
// the background painting code already uses. // the background painting code already uses.
NGPhysicalOffsetRect border_box = physical_fragment.LocalRect(); NGPhysicalOffsetRect border_box = physical_fragment.LocalRect();
if (physical_fragment.IsInline()) if (physical_fragment.IsInline())
border_box.offset += box_fragment_.InlineOffsetToContainerBox(); border_box.offset += box_fragment_.InlineOffsetToContainerBox();
border_box.offset += NGPhysicalOffset(paint_offset); border_box.offset += NGPhysicalOffset(paint_offset);
HitTestData::RecordTouchActionRect( HitTestData::RecordHitTestRect(
paint_info.context, box_fragment_, paint_info.context, box_fragment_,
TouchActionRect(border_box.ToLayoutRect(), touch_action)); HitTestRect(border_box.ToLayoutRect(), touch_action));
} }
void NGBoxFragmentPainter::PaintObject( void NGBoxFragmentPainter::PaintObject(
......
...@@ -3375,7 +3375,7 @@ void PaintLayer::ComputeSelfHitTestRects( ...@@ -3375,7 +3375,7 @@ void PaintLayer::ComputeSelfHitTestRects(
LayerHitTestRects& rects, LayerHitTestRects& rects,
TouchAction supported_fast_actions) const { TouchAction supported_fast_actions) const {
if (!Size().IsEmpty()) { if (!Size().IsEmpty()) {
Vector<TouchActionRect> rect; Vector<HitTestRect> rect;
TouchAction whitelisted_touch_action = TouchAction whitelisted_touch_action =
GetLayoutObject().StyleRef().GetEffectiveTouchAction() & GetLayoutObject().StyleRef().GetEffectiveTouchAction() &
supported_fast_actions; supported_fast_actions;
...@@ -3388,25 +3388,25 @@ void PaintLayer::ComputeSelfHitTestRects( ...@@ -3388,25 +3388,25 @@ void PaintLayer::ComputeSelfHitTestRects(
// composited layer. Skip reporting contents for non-composited layers as // composited layer. Skip reporting contents for non-composited layers as
// they'll get projected to the same layer as the bounding box. // they'll get projected to the same layer as the bounding box.
if (GetCompositingState() != kNotComposited && scrollable_area_) { if (GetCompositingState() != kNotComposited && scrollable_area_) {
rect.push_back(TouchActionRect(scrollable_area_->OverflowRect(), rect.push_back(HitTestRect(scrollable_area_->OverflowRect(),
whitelisted_touch_action)); whitelisted_touch_action));
} }
rects.Set(this, rect); rects.Set(this, rect);
if (const PaintLayer* parent_layer = Parent()) { if (const PaintLayer* parent_layer = Parent()) {
LayerHitTestRects::iterator iter = rects.find(parent_layer); LayerHitTestRects::iterator iter = rects.find(parent_layer);
if (iter == rects.end()) { if (iter == rects.end()) {
rects.insert(parent_layer, Vector<TouchActionRect>()) rects.insert(parent_layer, Vector<HitTestRect>())
.stored_value->value.push_back(TouchActionRect( .stored_value->value.push_back(HitTestRect(
PhysicalBoundingBox(parent_layer), whitelisted_touch_action)); PhysicalBoundingBox(parent_layer), whitelisted_touch_action));
} else { } else {
iter->value.push_back(TouchActionRect( iter->value.push_back(HitTestRect(PhysicalBoundingBox(parent_layer),
PhysicalBoundingBox(parent_layer), whitelisted_touch_action)); whitelisted_touch_action));
} }
} }
} else { } else {
rect.push_back( rect.push_back(
TouchActionRect(LogicalBoundingBox(), whitelisted_touch_action)); HitTestRect(LogicalBoundingBox(), whitelisted_touch_action));
rects.Set(this, rect); rects.Set(this, rect);
} }
} }
......
...@@ -200,8 +200,8 @@ void ReplacedPainter::RecordHitTestData(const PaintInfo& paint_info, ...@@ -200,8 +200,8 @@ void ReplacedPainter::RecordHitTestData(const PaintInfo& paint_info,
auto rect = layout_replaced_.VisualOverflowRect(); auto rect = layout_replaced_.VisualOverflowRect();
rect.MoveBy(paint_offset); rect.MoveBy(paint_offset);
HitTestData::RecordTouchActionRect(paint_info.context, layout_replaced_, HitTestData::RecordHitTestRect(paint_info.context, layout_replaced_,
TouchActionRect(rect, touch_action)); HitTestRect(rect, touch_action));
} }
bool ReplacedPainter::ShouldPaint(const ScopedPaintState& paint_state) const { bool ReplacedPainter::ShouldPaint(const ScopedPaintState& paint_state) const {
......
...@@ -44,9 +44,8 @@ void SVGModelObjectPainter::RecordHitTestData( ...@@ -44,9 +44,8 @@ void SVGModelObjectPainter::RecordHitTestData(
auto rect = auto rect =
LayoutRect(layout_svg_model_object.VisualRectInLocalSVGCoordinates()); LayoutRect(layout_svg_model_object.VisualRectInLocalSVGCoordinates());
HitTestData::RecordTouchActionRect(paint_info.context, HitTestData::RecordHitTestRect(paint_info.context, layout_svg_model_object,
layout_svg_model_object, HitTestRect(rect, touch_action));
TouchActionRect(rect, touch_action));
} }
void SVGModelObjectPainter::PaintOutline(const PaintInfo& paint_info) { void SVGModelObjectPainter::PaintOutline(const PaintInfo& paint_info) {
......
...@@ -47,8 +47,8 @@ void SVGTextPainter::RecordHitTestData(const PaintInfo& paint_info) { ...@@ -47,8 +47,8 @@ void SVGTextPainter::RecordHitTestData(const PaintInfo& paint_info) {
return; return;
auto rect = LayoutRect(layout_svg_text_.VisualRectInLocalSVGCoordinates()); auto rect = LayoutRect(layout_svg_text_.VisualRectInLocalSVGCoordinates());
HitTestData::RecordTouchActionRect(paint_info.context, layout_svg_text_, HitTestData::RecordHitTestRect(paint_info.context, layout_svg_text_,
TouchActionRect(rect, touch_action)); HitTestRect(rect, touch_action));
} }
} // namespace blink } // namespace blink
...@@ -65,8 +65,8 @@ void TablePainter::RecordHitTestData(const PaintInfo& paint_info, ...@@ -65,8 +65,8 @@ void TablePainter::RecordHitTestData(const PaintInfo& paint_info,
auto rect = layout_table_.BorderBoxRect(); auto rect = layout_table_.BorderBoxRect();
rect.MoveBy(paint_offset); rect.MoveBy(paint_offset);
HitTestData::RecordTouchActionRect(paint_info.context, layout_table_, HitTestData::RecordHitTestRect(paint_info.context, layout_table_,
TouchActionRect(rect, touch_action)); HitTestRect(rect, touch_action));
} }
void TablePainter::PaintBoxDecorationBackground( void TablePainter::PaintBoxDecorationBackground(
......
...@@ -80,8 +80,8 @@ void TableRowPainter::RecordHitTestData(const PaintInfo& paint_info, ...@@ -80,8 +80,8 @@ void TableRowPainter::RecordHitTestData(const PaintInfo& paint_info,
auto rect = layout_table_row_.BorderBoxRect(); auto rect = layout_table_row_.BorderBoxRect();
rect.MoveBy(paint_offset); rect.MoveBy(paint_offset);
HitTestData::RecordTouchActionRect(paint_info.context, layout_table_row_, HitTestData::RecordHitTestRect(paint_info.context, layout_table_row_,
TouchActionRect(rect, touch_action)); HitTestRect(rect, touch_action));
} }
void TableRowPainter::PaintBoxDecorationBackground( void TableRowPainter::PaintBoxDecorationBackground(
......
...@@ -966,6 +966,8 @@ jumbo_component("platform") { ...@@ -966,6 +966,8 @@ jumbo_component("platform") {
"graphics/high_contrast_settings.h", "graphics/high_contrast_settings.h",
"graphics/highcontrast/highcontrast_classifier.cc", "graphics/highcontrast/highcontrast_classifier.cc",
"graphics/highcontrast/highcontrast_classifier.h", "graphics/highcontrast/highcontrast_classifier.h",
"graphics/hit_test_rect.cc",
"graphics/hit_test_rect.h",
"graphics/image.cc", "graphics/image.cc",
"graphics/image.h", "graphics/image.h",
"graphics/image_animation_policy.h", "graphics/image_animation_policy.h",
...@@ -1104,8 +1106,6 @@ jumbo_component("platform") { ...@@ -1104,8 +1106,6 @@ jumbo_component("platform") {
"graphics/surface_layer_bridge.h", "graphics/surface_layer_bridge.h",
"graphics/texture_holder.h", "graphics/texture_holder.h",
"graphics/touch_action.h", "graphics/touch_action.h",
"graphics/touch_action_rect.cc",
"graphics/touch_action_rect.h",
"graphics/unaccelerated_static_bitmap_image.cc", "graphics/unaccelerated_static_bitmap_image.cc",
"graphics/unaccelerated_static_bitmap_image.h", "graphics/unaccelerated_static_bitmap_image.h",
"graphics/video_frame_resource_provider.cc", "graphics/video_frame_resource_provider.cc",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/platform/graphics/touch_action_rect.h" #include "third_party/blink/renderer/platform/graphics/hit_test_rect.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "cc/base/region.h" #include "cc/base/region.h"
...@@ -11,16 +11,27 @@ ...@@ -11,16 +11,27 @@
namespace blink { namespace blink {
// static // static
cc::TouchActionRegion TouchActionRect::BuildRegion( cc::TouchActionRegion HitTestRect::BuildRegion(
const Vector<TouchActionRect>& touch_action_rects) { const Vector<HitTestRect>& hit_test_rects) {
base::flat_map<TouchAction, cc::Region> region_map; base::flat_map<TouchAction, cc::Region> region_map;
region_map.reserve(touch_action_rects.size()); region_map.reserve(hit_test_rects.size());
for (const TouchActionRect& touch_action_rect : touch_action_rects) { for (const HitTestRect& hit_test_rect : hit_test_rects) {
TouchAction action = touch_action_rect.whitelisted_touch_action; const TouchAction& action = hit_test_rect.whitelisted_touch_action;
const LayoutRect& rect = touch_action_rect.rect; const LayoutRect& rect = hit_test_rect.rect;
region_map[action].Union(EnclosingIntRect(rect)); region_map[action].Union(EnclosingIntRect(rect));
} }
return cc::TouchActionRegion(std::move(region_map)); return cc::TouchActionRegion(std::move(region_map));
} }
// static
LayoutRect HitTestRect::GetBounds(const Vector<HitTestRect>& hit_test_rects) {
cc::Region region;
for (const HitTestRect& hit_test_rect : hit_test_rects) {
const LayoutRect& rect = hit_test_rect.rect;
region.Union(EnclosingIntRect(rect));
}
const auto& rect = region.bounds();
return LayoutRect(IntRect(rect));
}
} // namespace blink } // namespace blink
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_TOUCH_ACTION_RECT_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_HIT_TEST_RECT_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_TOUCH_ACTION_RECT_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_HIT_TEST_RECT_H_
#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/graphics/touch_action.h" #include "third_party/blink/renderer/platform/graphics/touch_action.h"
...@@ -19,26 +19,31 @@ namespace blink { ...@@ -19,26 +19,31 @@ namespace blink {
class PaintLayer; class PaintLayer;
struct PLATFORM_EXPORT TouchActionRect { struct PLATFORM_EXPORT HitTestRect {
// HitTestRect is a class shared by touch action region, wheel event handler
// region and non fast scrollable region. Wheel event handler region and
// non-fast scrollable rects use a |whitelisted_touch_action| of none.
LayoutRect rect; LayoutRect rect;
TouchAction whitelisted_touch_action; TouchAction whitelisted_touch_action;
TouchActionRect(const LayoutRect& layout_rect, TouchAction action) HitTestRect(const LayoutRect& layout_rect)
: HitTestRect(layout_rect, TouchAction::kTouchActionNone) {}
HitTestRect(const LayoutRect& layout_rect, TouchAction action)
: rect(layout_rect), whitelisted_touch_action(action) {} : rect(layout_rect), whitelisted_touch_action(action) {}
static cc::TouchActionRegion BuildRegion(const Vector<TouchActionRect>&); static cc::TouchActionRegion BuildRegion(const Vector<HitTestRect>&);
static LayoutRect GetBounds(const Vector<HitTestRect>&);
bool operator==(const TouchActionRect& rhs) const { bool operator==(const HitTestRect& rhs) const {
return rect == rhs.rect && return rect == rhs.rect &&
whitelisted_touch_action == rhs.whitelisted_touch_action; whitelisted_touch_action == rhs.whitelisted_touch_action;
} }
bool operator!=(const TouchActionRect& rhs) const { return !(*this == rhs); } bool operator!=(const HitTestRect& rhs) const { return !(*this == rhs); }
}; };
using LayerHitTestRects = using LayerHitTestRects = WTF::HashMap<const PaintLayer*, Vector<HitTestRect>>;
WTF::HashMap<const PaintLayer*, Vector<TouchActionRect>>;
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_TOUCH_ACTION_RECT_H_ #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_HIT_TEST_RECT_H_
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
namespace blink { namespace blink {
void HitTestData::RecordTouchActionRect(GraphicsContext& context, void HitTestData::RecordHitTestRect(GraphicsContext& context,
const DisplayItemClient& client, const DisplayItemClient& client,
const TouchActionRect& action) { const HitTestRect& action) {
DCHECK(RuntimeEnabledFeatures::PaintTouchActionRectsEnabled()); DCHECK(RuntimeEnabledFeatures::PaintTouchActionRectsEnabled());
PaintController& paint_controller = context.GetPaintController(); PaintController& paint_controller = context.GetPaintController();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_HIT_TEST_DATA_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_HIT_TEST_DATA_H_
#include "third_party/blink/renderer/platform/geometry/region.h" #include "third_party/blink/renderer/platform/geometry/region.h"
#include "third_party/blink/renderer/platform/graphics/touch_action_rect.h" #include "third_party/blink/renderer/platform/graphics/hit_test_rect.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.h"
namespace blink { namespace blink {
...@@ -14,12 +14,12 @@ namespace blink { ...@@ -14,12 +14,12 @@ namespace blink {
class DisplayItemClient; class DisplayItemClient;
class GraphicsContext; class GraphicsContext;
using TouchActionRects = Vector<TouchActionRect>; using HitTestRects = Vector<HitTestRect>;
struct PLATFORM_EXPORT HitTestData { struct PLATFORM_EXPORT HitTestData {
TouchActionRects touch_action_rects; HitTestRects touch_action_rects;
Region wheel_event_handler_region; HitTestRects wheel_event_handler_region;
Region non_fast_scrollable_region; HitTestRects non_fast_scrollable_region;
HitTestData() = default; HitTestData() = default;
HitTestData(const HitTestData& other) HitTestData(const HitTestData& other)
...@@ -36,11 +36,11 @@ struct PLATFORM_EXPORT HitTestData { ...@@ -36,11 +36,11 @@ struct PLATFORM_EXPORT HitTestData {
bool operator!=(const HitTestData& rhs) const { return !(*this == rhs); } bool operator!=(const HitTestData& rhs) const { return !(*this == rhs); }
// Records a display item for hit testing to ensure a paint chunk exists and // Records a display item for hit testing to ensure a paint chunk exists and
// is sized to include touch action rects, then adds the touch action rect to // is sized to include hit test rects, then adds the hit test rect to
// |HitTestData.touch_action_rects|. // |HitTestData.touch_action_rects|.
static void RecordTouchActionRect(GraphicsContext&, static void RecordHitTestRect(GraphicsContext&,
const DisplayItemClient&, const DisplayItemClient&,
const TouchActionRect&); const HitTestRect&);
}; };
} // namespace blink } // namespace blink
......
...@@ -30,19 +30,25 @@ String PaintChunk::ToString() const { ...@@ -30,19 +30,25 @@ String PaintChunk::ToString() const {
properties.ToString().Ascii().data(), bounds.ToString().Ascii().data(), properties.ToString().Ascii().data(), bounds.ToString().Ascii().data(),
known_to_be_opaque); known_to_be_opaque);
if (hit_test_data) { if (hit_test_data) {
ret_val.append( ret_val.append(String::Format(
String::Format(", touch_action_rects=(%u), " ", touch_action_rects=(rects: %u, bounds: %s), "
"wheel_event_handler_region=(%s) " "wheel_event_handler_region=(rects: %u, bounds: %s), "
"non_fast_scrollable_region=(%s))", "non_fast_scrollable_region=(rects: %u, bounds: %s))",
hit_test_data->touch_action_rects.size(), hit_test_data->touch_action_rects.size(),
hit_test_data->wheel_event_handler_region.Bounds() HitTestRect::GetBounds(hit_test_data->touch_action_rects)
.ToString() .ToString()
.Ascii() .Ascii()
.data(), .data(),
hit_test_data->non_fast_scrollable_region.Bounds() hit_test_data->wheel_event_handler_region.size(),
.ToString() HitTestRect::GetBounds(hit_test_data->wheel_event_handler_region)
.Ascii() .ToString()
.data())); .Ascii()
.data(),
hit_test_data->non_fast_scrollable_region.size(),
HitTestRect::GetBounds(hit_test_data->non_fast_scrollable_region)
.ToString()
.Ascii()
.data()));
} else { } else {
ret_val.append(")"); ret_val.append(")");
} }
......
...@@ -78,8 +78,8 @@ struct PLATFORM_EXPORT PaintChunk { ...@@ -78,8 +78,8 @@ struct PLATFORM_EXPORT PaintChunk {
size_t total_size = sizeof(*this); size_t total_size = sizeof(*this);
if (hit_test_data) { if (hit_test_data) {
total_size += sizeof(*hit_test_data); total_size += sizeof(*hit_test_data);
total_size += hit_test_data->touch_action_rects.capacity() * total_size +=
sizeof(TouchActionRect); hit_test_data->touch_action_rects.capacity() * sizeof(HitTestRect);
} }
return total_size; return total_size;
} }
......
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