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

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

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Created 4 years, 2 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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 1202
1203 bool AXObject::isScrollableContainer() const { 1203 bool AXObject::isScrollableContainer() const {
1204 return !!getScrollableAreaIfScrollable(); 1204 return !!getScrollableAreaIfScrollable();
1205 } 1205 }
1206 1206
1207 IntPoint AXObject::scrollOffset() const { 1207 IntPoint AXObject::scrollOffset() const {
1208 ScrollableArea* area = getScrollableAreaIfScrollable(); 1208 ScrollableArea* area = getScrollableAreaIfScrollable();
1209 if (!area) 1209 if (!area)
1210 return IntPoint(); 1210 return IntPoint();
1211 1211
1212 return IntPoint(area->scrollPosition().x(), area->scrollPosition().y()); 1212 return IntPoint(area->scrollOffsetInt().width(),
1213 area->scrollOffsetInt().height());
1213 } 1214 }
1214 1215
1215 IntPoint AXObject::minimumScrollOffset() const { 1216 IntPoint AXObject::minimumScrollOffset() const {
1216 ScrollableArea* area = getScrollableAreaIfScrollable(); 1217 ScrollableArea* area = getScrollableAreaIfScrollable();
1217 if (!area) 1218 if (!area)
1218 return IntPoint(); 1219 return IntPoint();
1219 1220
1220 return IntPoint(area->minimumScrollPosition().x(), 1221 return IntPoint(area->minimumScrollOffsetInt().width(),
1221 area->minimumScrollPosition().y()); 1222 area->minimumScrollOffsetInt().height());
1222 } 1223 }
1223 1224
1224 IntPoint AXObject::maximumScrollOffset() const { 1225 IntPoint AXObject::maximumScrollOffset() const {
1225 ScrollableArea* area = getScrollableAreaIfScrollable(); 1226 ScrollableArea* area = getScrollableAreaIfScrollable();
1226 if (!area) 1227 if (!area)
1227 return IntPoint(); 1228 return IntPoint();
1228 1229
1229 return IntPoint(area->maximumScrollPosition().x(), 1230 return IntPoint(area->maximumScrollOffsetInt().width(),
1230 area->maximumScrollPosition().y()); 1231 area->maximumScrollOffsetInt().height());
1231 } 1232 }
1232 1233
1233 void AXObject::setScrollOffset(const IntPoint& offset) const { 1234 void AXObject::setScrollOffset(const IntPoint& offset) const {
1234 ScrollableArea* area = getScrollableAreaIfScrollable(); 1235 ScrollableArea* area = getScrollableAreaIfScrollable();
1235 if (!area) 1236 if (!area)
1236 return; 1237 return;
1237 1238
1238 // TODO(bokan): This should potentially be a UserScroll. 1239 // TODO(bokan): This should potentially be a UserScroll.
1239 area->setScrollPosition(DoublePoint(offset.x(), offset.y()), 1240 area->setScrollOffset(ScrollOffset(offset.x(), offset.y()),
1240 ProgrammaticScroll); 1241 ProgrammaticScroll);
1241 } 1242 }
1242 1243
1243 void AXObject::getRelativeBounds(AXObject** outContainer, 1244 void AXObject::getRelativeBounds(AXObject** outContainer,
1244 FloatRect& outBoundsInContainer, 1245 FloatRect& outBoundsInContainer,
1245 SkMatrix44& outContainerTransform) const { 1246 SkMatrix44& outContainerTransform) const {
1246 *outContainer = nullptr; 1247 *outContainer = nullptr;
1247 outBoundsInContainer = FloatRect(); 1248 outBoundsInContainer = FloatRect();
1248 outContainerTransform.setIdentity(); 1249 outContainerTransform.setIdentity();
1249 1250
1250 // First check if it has explicit bounds, for example if this element is tied to a 1251 // First check if it has explicit bounds, for example if this element is tied to a
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1289
1289 if (!container) 1290 if (!container)
1290 return; 1291 return;
1291 *outContainer = container; 1292 *outContainer = container;
1292 outBoundsInContainer = layoutObject->localBoundingBoxRectForAccessibility(); 1293 outBoundsInContainer = layoutObject->localBoundingBoxRectForAccessibility();
1293 1294
1294 // If the container has a scroll offset, subtract that out because we want our 1295 // If the container has a scroll offset, subtract that out because we want our
1295 // bounds to be relative to the *unscrolled* position of the container object. 1296 // bounds to be relative to the *unscrolled* position of the container object.
1296 ScrollableArea* scrollableArea = container->getScrollableAreaIfScrollable(); 1297 ScrollableArea* scrollableArea = container->getScrollableAreaIfScrollable();
1297 if (scrollableArea && !container->isWebArea()) { 1298 if (scrollableArea && !container->isWebArea()) {
1298 IntPoint scrollPosition = scrollableArea->scrollPosition(); 1299 ScrollOffset scrollOffset = scrollableArea->scrollOffset();
1299 outBoundsInContainer.move( 1300 outBoundsInContainer.move(scrollOffset);
1300 FloatSize(scrollPosition.x(), scrollPosition.y()));
1301 } 1301 }
1302 1302
1303 // Compute the transform between the container's coordinate space and this obj ect. 1303 // Compute the transform between the container's coordinate space and this obj ect.
1304 // If the transform is just a simple translation, apply that to the bounding b ox, but 1304 // If the transform is just a simple translation, apply that to the bounding b ox, but
1305 // if it's a non-trivial transformation like a rotation, scaling, etc. then re turn 1305 // if it's a non-trivial transformation like a rotation, scaling, etc. then re turn
1306 // the full matrix instead. 1306 // the full matrix instead.
1307 TransformationMatrix transform = layoutObject->localToAncestorTransform( 1307 TransformationMatrix transform = layoutObject->localToAncestorTransform(
1308 toLayoutBoxModelObject(containerLayoutObject)); 1308 toLayoutBoxModelObject(containerLayoutObject));
1309 if (transform.isIdentityOr2DTranslation()) { 1309 if (transform.isIdentityOr2DTranslation()) {
1310 outBoundsInContainer.move(transform.to2DTranslation()); 1310 outBoundsInContainer.move(transform.to2DTranslation());
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 while (scrollParent) { 1455 while (scrollParent) {
1456 scrollableArea = scrollParent->getScrollableAreaIfScrollable(); 1456 scrollableArea = scrollParent->getScrollableAreaIfScrollable();
1457 if (scrollableArea) 1457 if (scrollableArea)
1458 break; 1458 break;
1459 scrollParent = scrollParent->parentObject(); 1459 scrollParent = scrollParent->parentObject();
1460 } 1460 }
1461 if (!scrollParent || !scrollableArea) 1461 if (!scrollParent || !scrollableArea)
1462 return; 1462 return;
1463 1463
1464 IntRect objectRect = pixelSnappedIntRect(getBoundsInFrameCoordinates()); 1464 IntRect objectRect = pixelSnappedIntRect(getBoundsInFrameCoordinates());
1465 IntPoint scrollPosition = scrollableArea->scrollPosition(); 1465 IntSize scrollOffset = scrollableArea->scrollOffsetInt();
1466 IntRect scrollVisibleRect = scrollableArea->visibleContentRect(); 1466 IntRect scrollVisibleRect = scrollableArea->visibleContentRect();
1467 1467
1468 // Convert the object rect into local coordinates. 1468 // Convert the object rect into local coordinates.
1469 if (!scrollParent->isWebArea()) { 1469 if (!scrollParent->isWebArea()) {
1470 objectRect.moveBy(scrollPosition); 1470 objectRect.moveBy(IntPoint(scrollOffset));
1471 objectRect.moveBy( 1471 objectRect.moveBy(
1472 -pixelSnappedIntRect(scrollParent->getBoundsInFrameCoordinates()) 1472 -pixelSnappedIntRect(scrollParent->getBoundsInFrameCoordinates())
1473 .location()); 1473 .location());
1474 } 1474 }
1475 1475
1476 int desiredX = 1476 int desiredX = computeBestScrollOffset(
1477 computeBestScrollOffset(scrollPosition.x(), objectRect.x() + subfocus.x(), 1477 scrollOffset.width(), objectRect.x() + subfocus.x(),
1478 objectRect.x() + subfocus.maxX(), objectRect.x(), 1478 objectRect.x() + subfocus.maxX(), objectRect.x(), objectRect.maxX(), 0,
1479 objectRect.maxX(), 0, scrollVisibleRect.width()); 1479 scrollVisibleRect.width());
1480 int desiredY = 1480 int desiredY = computeBestScrollOffset(
1481 computeBestScrollOffset(scrollPosition.y(), objectRect.y() + subfocus.y(), 1481 scrollOffset.height(), objectRect.y() + subfocus.y(),
1482 objectRect.y() + subfocus.maxY(), objectRect.y(), 1482 objectRect.y() + subfocus.maxY(), objectRect.y(), objectRect.maxY(), 0,
1483 objectRect.maxY(), 0, scrollVisibleRect.height()); 1483 scrollVisibleRect.height());
1484 1484
1485 scrollParent->setScrollOffset(IntPoint(desiredX, desiredY)); 1485 scrollParent->setScrollOffset(IntPoint(desiredX, desiredY));
1486 1486
1487 // Convert the subfocus into the coordinates of the scroll parent. 1487 // Convert the subfocus into the coordinates of the scroll parent.
1488 IntRect newSubfocus = subfocus; 1488 IntRect newSubfocus = subfocus;
1489 IntRect newElementRect = pixelSnappedIntRect(getBoundsInFrameCoordinates()); 1489 IntRect newElementRect = pixelSnappedIntRect(getBoundsInFrameCoordinates());
1490 IntRect scrollParentRect = 1490 IntRect scrollParentRect =
1491 pixelSnappedIntRect(scrollParent->getBoundsInFrameCoordinates()); 1491 pixelSnappedIntRect(scrollParent->getBoundsInFrameCoordinates());
1492 newSubfocus.move(newElementRect.x(), newElementRect.y()); 1492 newSubfocus.move(newElementRect.x(), newElementRect.y());
1493 newSubfocus.move(-scrollParentRect.x(), -scrollParentRect.y()); 1493 newSubfocus.move(-scrollParentRect.x(), -scrollParentRect.y());
(...skipping 24 matching lines...) Expand all
1518 const AXObject* outer = objects[i]; 1518 const AXObject* outer = objects[i];
1519 const AXObject* inner = objects[i + 1]; 1519 const AXObject* inner = objects[i + 1];
1520 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable(); 1520 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable();
1521 1521
1522 IntRect innerRect = 1522 IntRect innerRect =
1523 inner->isWebArea() 1523 inner->isWebArea()
1524 ? pixelSnappedIntRect( 1524 ? pixelSnappedIntRect(
1525 inner->parentObject()->getBoundsInFrameCoordinates()) 1525 inner->parentObject()->getBoundsInFrameCoordinates())
1526 : pixelSnappedIntRect(inner->getBoundsInFrameCoordinates()); 1526 : pixelSnappedIntRect(inner->getBoundsInFrameCoordinates());
1527 IntRect objectRect = innerRect; 1527 IntRect objectRect = innerRect;
1528 IntPoint scrollPosition = scrollableArea->scrollPosition(); 1528 IntSize scrollOffset = scrollableArea->scrollOffsetInt();
1529 1529
1530 // Convert the object rect into local coordinates. 1530 // Convert the object rect into local coordinates.
1531 objectRect.move(offsetX, offsetY); 1531 objectRect.move(offsetX, offsetY);
1532 if (!outer->isWebArea()) 1532 if (!outer->isWebArea())
1533 objectRect.move(scrollPosition.x(), scrollPosition.y()); 1533 objectRect.move(scrollOffset.width(), scrollOffset.height());
1534 1534
1535 int desiredX = computeBestScrollOffset(0, objectRect.x(), objectRect.maxX(), 1535 int desiredX = computeBestScrollOffset(0, objectRect.x(), objectRect.maxX(),
1536 objectRect.x(), objectRect.maxX(), 1536 objectRect.x(), objectRect.maxX(),
1537 point.x(), point.x()); 1537 point.x(), point.x());
1538 int desiredY = computeBestScrollOffset(0, objectRect.y(), objectRect.maxY(), 1538 int desiredY = computeBestScrollOffset(0, objectRect.y(), objectRect.maxY(),
1539 objectRect.y(), objectRect.maxY(), 1539 objectRect.y(), objectRect.maxY(),
1540 point.y(), point.y()); 1540 point.y(), point.y());
1541 outer->setScrollOffset(IntPoint(desiredX, desiredY)); 1541 outer->setScrollOffset(IntPoint(desiredX, desiredY));
1542 1542
1543 if (outer->isWebArea() && !inner->isWebArea()) { 1543 if (outer->isWebArea() && !inner->isWebArea()) {
1544 // If outer object we just scrolled is a web area (frame) but the inner ob ject 1544 // If outer object we just scrolled is a web area (frame) but the inner ob ject
1545 // is not, keep track of the coordinate transformation to apply to 1545 // is not, keep track of the coordinate transformation to apply to
1546 // future nested calculations. 1546 // future nested calculations.
1547 scrollPosition = scrollableArea->scrollPosition(); 1547 scrollOffset = scrollableArea->scrollOffsetInt();
1548 offsetX -= (scrollPosition.x() + point.x()); 1548 offsetX -= (scrollOffset.width() + point.x());
1549 offsetY -= (scrollPosition.y() + point.y()); 1549 offsetY -= (scrollOffset.height() + point.y());
1550 point.move(scrollPosition.x() - innerRect.x(), 1550 point.move(scrollOffset.width() - innerRect.width(),
1551 scrollPosition.y() - innerRect.y()); 1551 scrollOffset.height() - innerRect.y());
1552 } else if (inner->isWebArea()) { 1552 } else if (inner->isWebArea()) {
1553 // Otherwise, if the inner object is a web area, reset the coordinate tran sformation. 1553 // Otherwise, if the inner object is a web area, reset the coordinate tran sformation.
1554 offsetX = 0; 1554 offsetX = 0;
1555 offsetY = 0; 1555 offsetY = 0;
1556 } 1556 }
1557 } 1557 }
1558 } 1558 }
1559 1559
1560 void AXObject::notifyIfIgnoredValueChanged() { 1560 void AXObject::notifyIfIgnoredValueChanged() {
1561 bool isIgnored = accessibilityIsIgnored(); 1561 bool isIgnored = accessibilityIsIgnored();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 } 1724 }
1725 1725
1726 DEFINE_TRACE(AXObject) { 1726 DEFINE_TRACE(AXObject) {
1727 visitor->trace(m_children); 1727 visitor->trace(m_children);
1728 visitor->trace(m_parent); 1728 visitor->trace(m_parent);
1729 visitor->trace(m_cachedLiveRegionRoot); 1729 visitor->trace(m_cachedLiveRegionRoot);
1730 visitor->trace(m_axObjectCache); 1730 visitor->trace(m_axObjectCache);
1731 } 1731 }
1732 1732
1733 } // namespace blink 1733 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698