Commit de49bc94 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

AX: Refactor OnNativeScroll* functionality to be consistent.

This patch extracts a snippet used for retrieving and updating
a layout object for scroll action into a separate function, and uses
it in the three OnNativeScroll* functions.


R=aleventhal@chromium.org, chrishtr@chromium.org

Change-Id: I68a580f7dc5887841a874fb705eeaf9da6916740
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157671Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760961}
parent 5fc845fa
......@@ -3419,18 +3419,21 @@ bool AXObject::InternalSetAccessibilityFocusAction() {
return false;
}
bool AXObject::OnNativeScrollToMakeVisibleAction() const {
LayoutObject* AXObject::GetLayoutObjectForNativeScrollAction() const {
Node* node = GetNode();
if (!node || !node->isConnected())
return false;
return nullptr;
// Node might not have a LayoutObject due to the fact that it is in a locked
// subtree. Force the update to create the LayoutObject (and update position
// information) for this node.
GetDocument()->UpdateStyleAndLayoutForNode(
node, DocumentUpdateReason::kDisplayLock);
return node->GetLayoutObject();
}
LayoutObject* layout_object = node->GetLayoutObject();
bool AXObject::OnNativeScrollToMakeVisibleAction() const {
LayoutObject* layout_object = GetLayoutObjectForNativeScrollAction();
if (!layout_object)
return false;
PhysicalRect target_rect(layout_object->AbsoluteBoundingBoxRect());
......@@ -3450,10 +3453,10 @@ bool AXObject::OnNativeScrollToMakeVisibleWithSubFocusAction(
const IntRect& rect,
blink::mojom::blink::ScrollAlignment horizontal_scroll_alignment,
blink::mojom::blink::ScrollAlignment vertical_scroll_alignment) const {
Node* node = GetNode();
LayoutObject* layout_object = node ? node->GetLayoutObject() : nullptr;
if (!layout_object || !node->isConnected())
LayoutObject* layout_object = GetLayoutObjectForNativeScrollAction();
if (!layout_object)
return false;
PhysicalRect target_rect =
layout_object->LocalToAbsoluteRect(PhysicalRect(rect));
layout_object->ScrollRectToVisible(
......@@ -3470,10 +3473,10 @@ bool AXObject::OnNativeScrollToMakeVisibleWithSubFocusAction(
bool AXObject::OnNativeScrollToGlobalPointAction(
const IntPoint& global_point) const {
Node* node = GetNode();
LayoutObject* layout_object = node ? node->GetLayoutObject() : nullptr;
if (!layout_object || !node->isConnected())
LayoutObject* layout_object = GetLayoutObjectForNativeScrollAction();
if (!layout_object)
return false;
PhysicalRect target_rect(layout_object->AbsoluteBoundingBoxRect());
target_rect.Move(-PhysicalOffset(global_point));
layout_object->ScrollRectToVisible(
......
......@@ -1151,6 +1151,12 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> {
const QualifiedName&) const;
bool IsHiddenViaStyle() const;
// Returns an updated layout object to be used in a native scroll action. Note
// that this updates style for `GetNode()` as well as layout for any layout
// objects generated. Returns nullptr if a native scroll action to the node is
// not possible.
LayoutObject* GetLayoutObjectForNativeScrollAction() const;
static unsigned number_of_live_ax_objects_;
DISALLOW_COPY_AND_ASSIGN(AXObject);
......
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