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

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

Issue 2956053005: Keep track of fixed positioning in accessibility tree.
Patch Set: 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;
1497 1499
1498 // First check if it has explicit bounds, for example if this element is tied 1500 // 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 1501 // 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 1502 // explicit container element that the coordinates are relative to must be
1501 // provided too. 1503 // provided too.
1502 if (!explicit_element_rect_.IsEmpty()) { 1504 if (!explicit_element_rect_.IsEmpty()) {
1503 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_); 1505 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_);
1504 if (*out_container) { 1506 if (*out_container) {
1505 out_bounds_in_container = FloatRect(explicit_element_rect_); 1507 out_bounds_in_container = FloatRect(explicit_element_rect_);
1506 return; 1508 return;
1507 } 1509 }
1508 } 1510 }
1509 1511
1510 LayoutObject* layout_object = LayoutObjectForRelativeBounds(); 1512 LayoutObject* layout_object = LayoutObjectForRelativeBounds();
1511 if (!layout_object) 1513 if (!layout_object)
1512 return; 1514 return;
1513 1515
1514 if (IsWebArea()) { 1516 if (IsWebArea()) {
1515 if (layout_object->GetFrame()->View()) { 1517 if (layout_object->GetFrame()->View()) {
1516 out_bounds_in_container.SetSize( 1518 out_bounds_in_container.SetSize(
1517 FloatSize(layout_object->GetFrame()->View()->ContentsSize())); 1519 FloatSize(layout_object->GetFrame()->View()->ContentsSize()));
1518 } 1520 }
1519 return; 1521 return;
1520 } 1522 }
1521 1523
1524 // When the object is fixed-positioned, we just need to return our
1525 // absolute coordinates and indicate that the position is fixed.
1526 if (layout_object->IsFixedPositioned()) {
1527 out_bounds_in_container = layout_object->AbsoluteBoundingBoxFloatRect();
1528 *out_container = AxObjectCache().Root();
1529 out_is_fixed_positioned = true;
1530 return;
1531 }
1532
1522 // First compute the container. The container must be an ancestor in the 1533 // 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 1534 // 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 1535 // tree. Get the first such ancestor that's either scrollable or has a paint
1525 // layer. 1536 // layer.
1526 AXObject* container = ParentObjectUnignored(); 1537 AXObject* container = ParentObjectUnignored();
1527 LayoutObject* container_layout_object = nullptr; 1538 LayoutObject* container_layout_object = nullptr;
1528 while (container) { 1539 while (container) {
1529 container_layout_object = container->GetLayoutObject(); 1540 container_layout_object = container->GetLayoutObject();
1530 if (container_layout_object && 1541 if (container_layout_object && container_layout_object->IsBox() &&
1531 container_layout_object->IsBoxModelObject() &&
1532 layout_object->IsDescendantOf(container_layout_object)) { 1542 layout_object->IsDescendantOf(container_layout_object)) {
1533 if (container->IsScrollableContainer() || 1543 if (container->IsScrollableContainer() ||
1534 container_layout_object->HasLayer()) 1544 container_layout_object->HasLayer() ||
1545 container_layout_object->IsFixedPositioned())
1535 break; 1546 break;
1536 } 1547 }
1537 1548
1538 container = container->ParentObjectUnignored(); 1549 container = container->ParentObjectUnignored();
1539 } 1550 }
1540 1551
1541 if (!container) 1552 if (!container)
1542 return; 1553 return;
1543 *out_container = container; 1554 *out_container = container;
1544 out_bounds_in_container = 1555 out_bounds_in_container =
(...skipping 17 matching lines...) Expand all
1562 out_bounds_in_container.Move(transform.To2DTranslation()); 1573 out_bounds_in_container.Move(transform.To2DTranslation());
1563 } else { 1574 } else {
1564 out_container_transform = TransformationMatrix::ToSkMatrix44(transform); 1575 out_container_transform = TransformationMatrix::ToSkMatrix44(transform);
1565 } 1576 }
1566 } 1577 }
1567 1578
1568 LayoutRect AXObject::GetBoundsInFrameCoordinates() const { 1579 LayoutRect AXObject::GetBoundsInFrameCoordinates() const {
1569 AXObject* container = nullptr; 1580 AXObject* container = nullptr;
1570 FloatRect bounds; 1581 FloatRect bounds;
1571 SkMatrix44 transform; 1582 SkMatrix44 transform;
1572 GetRelativeBounds(&container, bounds, transform); 1583 bool is_fixed_positioned;
1584 GetRelativeBounds(&container, bounds, transform, is_fixed_positioned);
1573 FloatRect computed_bounds(0, 0, bounds.Width(), bounds.Height()); 1585 FloatRect computed_bounds(0, 0, bounds.Width(), bounds.Height());
1574 while (container && container != this) { 1586 while (container && container != this) {
1575 computed_bounds.Move(bounds.X(), bounds.Y()); 1587 computed_bounds.Move(bounds.X(), bounds.Y());
1576 if (!container->IsWebArea()) { 1588 if (!container->IsWebArea() && !is_fixed_positioned) {
1577 computed_bounds.Move(-container->GetScrollOffset().X(), 1589 computed_bounds.Move(-container->GetScrollOffset().X(),
1578 -container->GetScrollOffset().Y()); 1590 -container->GetScrollOffset().Y());
1579 } 1591 }
1580 if (!transform.isIdentity()) { 1592 if (!transform.isIdentity()) {
1581 TransformationMatrix transformation_matrix(transform); 1593 TransformationMatrix transformation_matrix(transform);
1582 transformation_matrix.MapRect(computed_bounds); 1594 transformation_matrix.MapRect(computed_bounds);
1583 } 1595 }
1584 container->GetRelativeBounds(&container, bounds, transform); 1596 container->GetRelativeBounds(&container, bounds, transform,
1597 is_fixed_positioned);
1585 } 1598 }
1586 return LayoutRect(computed_bounds); 1599 return LayoutRect(computed_bounds);
1587 } 1600 }
1588 1601
1589 // 1602 //
1590 // Modify or take an action on an object. 1603 // Modify or take an action on an object.
1591 // 1604 //
1592 1605
1593 bool AXObject::Press() { 1606 bool AXObject::Press() {
1594 Document* document = GetDocument(); 1607 Document* document = GetDocument();
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 } 2113 }
2101 2114
2102 DEFINE_TRACE(AXObject) { 2115 DEFINE_TRACE(AXObject) {
2103 visitor->Trace(children_); 2116 visitor->Trace(children_);
2104 visitor->Trace(parent_); 2117 visitor->Trace(parent_);
2105 visitor->Trace(cached_live_region_root_); 2118 visitor->Trace(cached_live_region_root_);
2106 visitor->Trace(ax_object_cache_); 2119 visitor->Trace(ax_object_cache_);
2107 } 2120 }
2108 2121
2109 } // namespace blink 2122 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698