Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1001 if (!elementNode) | 1001 if (!elementNode) |
| 1002 return nullAtom; | 1002 return nullAtom; |
| 1003 | 1003 |
| 1004 if (!elementNode->isElementNode()) | 1004 if (!elementNode->isElementNode()) |
| 1005 return nullAtom; | 1005 return nullAtom; |
| 1006 | 1006 |
| 1007 Element* element = toElement(elementNode); | 1007 Element* element = toElement(elementNode); |
| 1008 return element->fastGetAttribute(attribute); | 1008 return element->fastGetAttribute(attribute); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 // | |
| 1012 // Scrollable containers. | |
| 1013 // | |
| 1014 | |
| 1015 // | |
| 1016 // Scrollable containers. | |
|
aboxhall
2015/05/01 23:05:42
Double comment?
| |
| 1017 // | |
| 1018 | |
| 1019 bool AXObject::isScrollableContainer() const | |
| 1020 { | |
| 1021 return !!getScrollableAreaIfScrollable(); | |
|
aboxhall
2015/05/01 23:05:42
Ugh, I don't like !! but it seems to be the de fac
| |
| 1022 } | |
| 1023 | |
| 1024 IntPoint AXObject::scrollOffset() const | |
| 1025 { | |
| 1026 ScrollableArea* area = getScrollableAreaIfScrollable(); | |
| 1027 if (!area) | |
| 1028 return IntPoint(); | |
| 1029 | |
| 1030 return IntPoint(area->scrollPosition().x(), area->scrollPosition().y()); | |
| 1031 } | |
| 1032 | |
| 1033 IntPoint AXObject::minimumScrollOffset() const | |
| 1034 { | |
| 1035 ScrollableArea* area = getScrollableAreaIfScrollable(); | |
| 1036 if (!area) | |
| 1037 return IntPoint(); | |
| 1038 | |
| 1039 return IntPoint(area->minimumScrollPosition().x(), area->minimumScrollPositi on().y()); | |
| 1040 } | |
| 1041 | |
| 1042 IntPoint AXObject::maximumScrollOffset() const | |
| 1043 { | |
| 1044 ScrollableArea* area = getScrollableAreaIfScrollable(); | |
| 1045 if (!area) | |
| 1046 return IntPoint(); | |
| 1047 | |
| 1048 return IntPoint(area->maximumScrollPosition().x(), area->maximumScrollPositi on().y()); | |
| 1049 } | |
| 1050 | |
| 1051 void AXObject::setScrollOffset(const IntPoint& offset) const | |
| 1052 { | |
| 1053 ScrollableArea* area = getScrollableAreaIfScrollable(); | |
| 1054 if (!area) | |
| 1055 return; | |
| 1056 | |
| 1057 area->setScrollPosition(DoublePoint(offset.x(), offset.y())); | |
| 1058 } | |
| 1059 | |
| 1060 // | |
| 1061 // Modify or take an action on an object. | |
| 1062 // | |
| 1063 | |
| 1011 bool AXObject::press() const | 1064 bool AXObject::press() const |
| 1012 { | 1065 { |
| 1013 Element* actionElem = actionElement(); | 1066 Element* actionElem = actionElement(); |
| 1014 if (!actionElem) | 1067 if (!actionElem) |
| 1015 return false; | 1068 return false; |
| 1016 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1069 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 1017 actionElem->accessKeyAction(true); | 1070 actionElem->accessKeyAction(true); |
| 1018 return true; | 1071 return true; |
| 1019 } | 1072 } |
| 1020 | 1073 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1138 scrollPosition.x(), | 1191 scrollPosition.x(), |
| 1139 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(), | 1192 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(), |
| 1140 objectRect.x(), objectRect.maxX(), | 1193 objectRect.x(), objectRect.maxX(), |
| 1141 0, scrollVisibleRect.width()); | 1194 0, scrollVisibleRect.width()); |
| 1142 int desiredY = computeBestScrollOffset( | 1195 int desiredY = computeBestScrollOffset( |
| 1143 scrollPosition.y(), | 1196 scrollPosition.y(), |
| 1144 objectRect.y() + subfocus.y(), objectRect.y() + subfocus.maxY(), | 1197 objectRect.y() + subfocus.y(), objectRect.y() + subfocus.maxY(), |
| 1145 objectRect.y(), objectRect.maxY(), | 1198 objectRect.y(), objectRect.maxY(), |
| 1146 0, scrollVisibleRect.height()); | 1199 0, scrollVisibleRect.height()); |
| 1147 | 1200 |
| 1148 scrollParent->scrollTo(IntPoint(desiredX, desiredY)); | 1201 scrollParent->setScrollOffset(IntPoint(desiredX, desiredY)); |
| 1149 | 1202 |
| 1150 // Convert the subfocus into the coordinates of the scroll parent. | 1203 // Convert the subfocus into the coordinates of the scroll parent. |
| 1151 IntRect newSubfocus = subfocus; | 1204 IntRect newSubfocus = subfocus; |
| 1152 IntRect newElementRect = pixelSnappedIntRect(elementRect()); | 1205 IntRect newElementRect = pixelSnappedIntRect(elementRect()); |
| 1153 IntRect scrollParentRect = pixelSnappedIntRect(scrollParent->elementRect()); | 1206 IntRect scrollParentRect = pixelSnappedIntRect(scrollParent->elementRect()); |
| 1154 newSubfocus.move(newElementRect.x(), newElementRect.y()); | 1207 newSubfocus.move(newElementRect.x(), newElementRect.y()); |
| 1155 newSubfocus.move(-scrollParentRect.x(), -scrollParentRect.y()); | 1208 newSubfocus.move(-scrollParentRect.x(), -scrollParentRect.y()); |
| 1156 | 1209 |
| 1157 // Recursively make sure the scroll parent itself is visible. | 1210 // Recursively make sure the scroll parent itself is visible. |
| 1158 if (scrollParent->parentObject()) | 1211 if (scrollParent->parentObject()) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 int desiredX = computeBestScrollOffset( | 1247 int desiredX = computeBestScrollOffset( |
| 1195 0, | 1248 0, |
| 1196 objectRect.x(), objectRect.maxX(), | 1249 objectRect.x(), objectRect.maxX(), |
| 1197 objectRect.x(), objectRect.maxX(), | 1250 objectRect.x(), objectRect.maxX(), |
| 1198 point.x(), point.x()); | 1251 point.x(), point.x()); |
| 1199 int desiredY = computeBestScrollOffset( | 1252 int desiredY = computeBestScrollOffset( |
| 1200 0, | 1253 0, |
| 1201 objectRect.y(), objectRect.maxY(), | 1254 objectRect.y(), objectRect.maxY(), |
| 1202 objectRect.y(), objectRect.maxY(), | 1255 objectRect.y(), objectRect.maxY(), |
| 1203 point.y(), point.y()); | 1256 point.y(), point.y()); |
| 1204 outer->scrollTo(IntPoint(desiredX, desiredY)); | 1257 outer->setScrollOffset(IntPoint(desiredX, desiredY)); |
| 1205 | 1258 |
| 1206 if (outer->isAXScrollView() && !inner->isAXScrollView()) { | 1259 if (outer->isAXScrollView() && !inner->isAXScrollView()) { |
| 1207 // If outer object we just scrolled is a scroll view (main window or iframe) but the | 1260 // If outer object we just scrolled is a scroll view (main window or iframe) but the |
| 1208 // inner object is not, keep track of the coordinate transformation to apply to | 1261 // inner object is not, keep track of the coordinate transformation to apply to |
| 1209 // future nested calculations. | 1262 // future nested calculations. |
| 1210 scrollPosition = scrollableArea->scrollPosition(); | 1263 scrollPosition = scrollableArea->scrollPosition(); |
| 1211 offsetX -= (scrollPosition.x() + point.x()); | 1264 offsetX -= (scrollPosition.x() + point.x()); |
| 1212 offsetY -= (scrollPosition.y() + point.y()); | 1265 offsetY -= (scrollPosition.y() + point.y()); |
| 1213 point.move(scrollPosition.x() - innerRect.x(), scrollPosition.y() - innerRect.y()); | 1266 point.move(scrollPosition.x() - innerRect.x(), scrollPosition.y() - innerRect.y()); |
| 1214 } else if (inner->isAXScrollView()) { | 1267 } else if (inner->isAXScrollView()) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1355 } | 1408 } |
| 1356 | 1409 |
| 1357 const AtomicString& AXObject::internalRoleName(AccessibilityRole role) | 1410 const AtomicString& AXObject::internalRoleName(AccessibilityRole role) |
| 1358 { | 1411 { |
| 1359 static const Vector<AtomicString>* internalRoleNameVector = createInternalRo leNameVector(); | 1412 static const Vector<AtomicString>* internalRoleNameVector = createInternalRo leNameVector(); |
| 1360 | 1413 |
| 1361 return internalRoleNameVector->at(role); | 1414 return internalRoleNameVector->at(role); |
| 1362 } | 1415 } |
| 1363 | 1416 |
| 1364 } // namespace blink | 1417 } // namespace blink |
| OLD | NEW |