Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXObject.cpp

Issue 2956053005: Keep track of fixed positioning in accessibility tree.
Patch Set: GetSimpleRelativeBounds, add failing test for fixed with transform Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 if (!area) 1483 if (!area)
1484 return; 1484 return;
1485 1485
1486 // TODO(bokan): This should potentially be a UserScroll. 1486 // TODO(bokan): This should potentially be a UserScroll.
1487 area->SetScrollOffset(ScrollOffset(offset.X(), offset.Y()), 1487 area->SetScrollOffset(ScrollOffset(offset.X(), offset.Y()),
1488 kProgrammaticScroll); 1488 kProgrammaticScroll);
1489 } 1489 }
1490 1490
1491 void AXObject::GetRelativeBounds(AXObject** out_container, 1491 void AXObject::GetRelativeBounds(AXObject** out_container,
1492 FloatRect& out_bounds_in_container, 1492 FloatRect& out_bounds_in_container,
1493 SkMatrix44& out_container_transform) const { 1493 SkMatrix44& out_container_transform,
1494 bool& out_is_fixed_positioned) const {
1494 *out_container = nullptr; 1495 *out_container = nullptr;
1495 out_bounds_in_container = FloatRect(); 1496 out_bounds_in_container = FloatRect();
1496 out_container_transform.setIdentity(); 1497 out_container_transform.setIdentity();
1498 out_is_fixed_positioned = false;
1499
1500 if (GetSimpleRelativeBounds(out_container, out_bounds_in_container))
1501 return;
1497 1502
1498 // First check if it has explicit bounds, for example if this element is tied 1503 // First check if it has explicit bounds, for example if this element is tied
1499 // to a canvas path. When explicit coordinates are provided, the ID of the 1504 // to a canvas path. When explicit coordinates are provided, the ID of the
1500 // explicit container element that the coordinates are relative to must be 1505 // explicit container element that the coordinates are relative to must be
1501 // provided too. 1506 // provided too.
1502 if (!explicit_element_rect_.IsEmpty()) { 1507 if (!explicit_element_rect_.IsEmpty()) {
1503 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_); 1508 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_);
1504 if (*out_container) { 1509 if (*out_container) {
1505 out_bounds_in_container = FloatRect(explicit_element_rect_); 1510 out_bounds_in_container = FloatRect(explicit_element_rect_);
1506 return; 1511 return;
1507 } 1512 }
1508 } 1513 }
1509 1514
1510 LayoutObject* layout_object = LayoutObjectForRelativeBounds(); 1515 LayoutObject* layout_object = LayoutObjectForRelativeBounds();
1511 if (!layout_object) 1516 if (!layout_object)
1512 return; 1517 return;
1513 1518
1514 if (IsWebArea()) { 1519 if (IsWebArea()) {
1515 if (layout_object->GetFrame()->View()) { 1520 if (layout_object->GetFrame()->View()) {
1516 out_bounds_in_container.SetSize( 1521 out_bounds_in_container.SetSize(
1517 FloatSize(layout_object->GetFrame()->View()->ContentsSize())); 1522 FloatSize(layout_object->GetFrame()->View()->ContentsSize()));
1518 } 1523 }
1519 return; 1524 return;
1520 } 1525 }
1521 1526
1527 // When the object is fixed-positioned, we just need to return our
1528 // absolute coordinates and indicate that the position is fixed.
1529 if (layout_object->IsFixedPositioned()) {
1530 out_bounds_in_container = layout_object->AbsoluteBoundingBoxFloatRect();
1531 *out_container = AxObjectCache().Root();
1532 out_is_fixed_positioned = true;
1533 return;
1534 }
1535
1522 // First compute the container. The container must be an ancestor in the 1536 // First compute the container. The container must be an ancestor in the
1523 // accessibility tree, and its LayoutObject must be an ancestor in the layout 1537 // accessibility tree, and its LayoutObject must be an ancestor in the layout
1524 // tree. Get the first such ancestor that's either scrollable or has a paint 1538 // tree. Get the first such ancestor that's either scrollable or has a paint
1525 // layer. 1539 // layer.
1526 AXObject* container = ParentObjectUnignored(); 1540 AXObject* container = ParentObjectUnignored();
1527 LayoutObject* container_layout_object = nullptr; 1541 LayoutObject* container_layout_object = nullptr;
1528 while (container) { 1542 while (container) {
1529 container_layout_object = container->GetLayoutObject(); 1543 container_layout_object = container->GetLayoutObject();
1530 if (container_layout_object && container_layout_object->IsBox() && 1544 if (container_layout_object && container_layout_object->IsBox() &&
1531 layout_object->IsDescendantOf(container_layout_object)) { 1545 layout_object->IsDescendantOf(container_layout_object)) {
1532 if (container->IsScrollableContainer() || 1546 if (container->IsScrollableContainer() ||
1533 container_layout_object->HasLayer()) 1547 container_layout_object->HasLayer() ||
1548 container_layout_object->IsFixedPositioned())
1534 break; 1549 break;
1535 } 1550 }
1536 1551
1537 container = container->ParentObjectUnignored(); 1552 container = container->ParentObjectUnignored();
1538 } 1553 }
1539 1554
1540 if (!container) 1555 if (!container)
1541 return; 1556 return;
1542 *out_container = container; 1557 *out_container = container;
1543 out_bounds_in_container = 1558 out_bounds_in_container =
(...skipping 17 matching lines...) Expand all
1561 out_bounds_in_container.Move(transform.To2DTranslation()); 1576 out_bounds_in_container.Move(transform.To2DTranslation());
1562 } else { 1577 } else {
1563 out_container_transform = TransformationMatrix::ToSkMatrix44(transform); 1578 out_container_transform = TransformationMatrix::ToSkMatrix44(transform);
1564 } 1579 }
1565 } 1580 }
1566 1581
1567 LayoutRect AXObject::GetBoundsInFrameCoordinates() const { 1582 LayoutRect AXObject::GetBoundsInFrameCoordinates() const {
1568 AXObject* container = nullptr; 1583 AXObject* container = nullptr;
1569 FloatRect bounds; 1584 FloatRect bounds;
1570 SkMatrix44 transform; 1585 SkMatrix44 transform;
1571 GetRelativeBounds(&container, bounds, transform); 1586 bool is_fixed_positioned;
1587 GetRelativeBounds(&container, bounds, transform, is_fixed_positioned);
1572 FloatRect computed_bounds(0, 0, bounds.Width(), bounds.Height()); 1588 FloatRect computed_bounds(0, 0, bounds.Width(), bounds.Height());
1573 while (container && container != this) { 1589 while (container && container != this) {
1574 computed_bounds.Move(bounds.X(), bounds.Y()); 1590 computed_bounds.Move(bounds.X(), bounds.Y());
1575 if (!container->IsWebArea()) { 1591 if (!container->IsWebArea() && !is_fixed_positioned) {
1576 computed_bounds.Move(-container->GetScrollOffset().X(), 1592 computed_bounds.Move(-container->GetScrollOffset().X(),
1577 -container->GetScrollOffset().Y()); 1593 -container->GetScrollOffset().Y());
1578 } 1594 }
1579 if (!transform.isIdentity()) { 1595 if (!transform.isIdentity()) {
1580 TransformationMatrix transformation_matrix(transform); 1596 TransformationMatrix transformation_matrix(transform);
1581 transformation_matrix.MapRect(computed_bounds); 1597 transformation_matrix.MapRect(computed_bounds);
1582 } 1598 }
1583 container->GetRelativeBounds(&container, bounds, transform); 1599 container->GetRelativeBounds(&container, bounds, transform,
1600 is_fixed_positioned);
1584 } 1601 }
1585 return LayoutRect(computed_bounds); 1602 return LayoutRect(computed_bounds);
1586 } 1603 }
1587 1604
1588 // 1605 //
1589 // Modify or take an action on an object. 1606 // Modify or take an action on an object.
1590 // 1607 //
1591 1608
1592 bool AXObject::Press() { 1609 bool AXObject::Press() {
1593 Document* document = GetDocument(); 1610 Document* document = GetDocument();
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 } 2116 }
2100 2117
2101 DEFINE_TRACE(AXObject) { 2118 DEFINE_TRACE(AXObject) {
2102 visitor->Trace(children_); 2119 visitor->Trace(children_);
2103 visitor->Trace(parent_); 2120 visitor->Trace(parent_);
2104 visitor->Trace(cached_live_region_root_); 2121 visitor->Trace(cached_live_region_root_);
2105 visitor->Trace(ax_object_cache_); 2122 visitor->Trace(ax_object_cache_);
2106 } 2123 }
2107 2124
2108 } // namespace blink 2125 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698