| 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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 if (!elementNode) | 1033 if (!elementNode) |
| 1034 return nullAtom; | 1034 return nullAtom; |
| 1035 | 1035 |
| 1036 if (!elementNode->isElementNode()) | 1036 if (!elementNode->isElementNode()) |
| 1037 return nullAtom; | 1037 return nullAtom; |
| 1038 | 1038 |
| 1039 Element* element = toElement(elementNode); | 1039 Element* element = toElement(elementNode); |
| 1040 return element->fastGetAttribute(attribute); | 1040 return element->fastGetAttribute(attribute); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 // |
| 1044 // Scrollable containers. |
| 1045 // |
| 1046 |
| 1047 bool AXObject::isScrollableContainer() const |
| 1048 { |
| 1049 return !!getScrollableAreaIfScrollable(); |
| 1050 } |
| 1051 |
| 1052 IntPoint AXObject::scrollOffset() const |
| 1053 { |
| 1054 ScrollableArea* area = getScrollableAreaIfScrollable(); |
| 1055 if (!area) |
| 1056 return IntPoint(); |
| 1057 |
| 1058 return IntPoint(area->scrollPosition().x(), area->scrollPosition().y()); |
| 1059 } |
| 1060 |
| 1061 IntPoint AXObject::minimumScrollOffset() const |
| 1062 { |
| 1063 ScrollableArea* area = getScrollableAreaIfScrollable(); |
| 1064 if (!area) |
| 1065 return IntPoint(); |
| 1066 |
| 1067 return IntPoint(area->minimumScrollPosition().x(), area->minimumScrollPositi
on().y()); |
| 1068 } |
| 1069 |
| 1070 IntPoint AXObject::maximumScrollOffset() const |
| 1071 { |
| 1072 ScrollableArea* area = getScrollableAreaIfScrollable(); |
| 1073 if (!area) |
| 1074 return IntPoint(); |
| 1075 |
| 1076 return IntPoint(area->maximumScrollPosition().x(), area->maximumScrollPositi
on().y()); |
| 1077 } |
| 1078 |
| 1079 void AXObject::setScrollOffset(const IntPoint& offset) const |
| 1080 { |
| 1081 ScrollableArea* area = getScrollableAreaIfScrollable(); |
| 1082 if (!area) |
| 1083 return; |
| 1084 |
| 1085 area->setScrollPosition(DoublePoint(offset.x(), offset.y())); |
| 1086 } |
| 1087 |
| 1088 // |
| 1089 // Modify or take an action on an object. |
| 1090 // |
| 1091 |
| 1043 bool AXObject::press() const | 1092 bool AXObject::press() const |
| 1044 { | 1093 { |
| 1045 Element* actionElem = actionElement(); | 1094 Element* actionElem = actionElement(); |
| 1046 if (!actionElem) | 1095 if (!actionElem) |
| 1047 return false; | 1096 return false; |
| 1048 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1097 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 1049 actionElem->accessKeyAction(true); | 1098 actionElem->accessKeyAction(true); |
| 1050 return true; | 1099 return true; |
| 1051 } | 1100 } |
| 1052 | 1101 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 return (objectMin + objectMax - viewportMin - viewportMax) / 2; | 1197 return (objectMin + objectMax - viewportMin - viewportMax) / 2; |
| 1149 } | 1198 } |
| 1150 | 1199 |
| 1151 void AXObject::scrollToMakeVisibleWithSubFocus(const IntRect& subfocus) const | 1200 void AXObject::scrollToMakeVisibleWithSubFocus(const IntRect& subfocus) const |
| 1152 { | 1201 { |
| 1153 // Search up the parent chain until we find the first one that's scrollable. | 1202 // Search up the parent chain until we find the first one that's scrollable. |
| 1154 AXObject* scrollParent = parentObject(); | 1203 AXObject* scrollParent = parentObject(); |
| 1155 ScrollableArea* scrollableArea = 0; | 1204 ScrollableArea* scrollableArea = 0; |
| 1156 while (scrollParent) { | 1205 while (scrollParent) { |
| 1157 scrollableArea = scrollParent->getScrollableAreaIfScrollable(); | 1206 scrollableArea = scrollParent->getScrollableAreaIfScrollable(); |
| 1158 if (scrollableArea) | 1207 if (scrollableArea && !scrollParent->isAXScrollView()) |
| 1159 break; | 1208 break; |
| 1160 scrollParent = scrollParent->parentObject(); | 1209 scrollParent = scrollParent->parentObject(); |
| 1161 } | 1210 } |
| 1162 if (!scrollParent || !scrollableArea) | 1211 if (!scrollParent || !scrollableArea) |
| 1163 return; | 1212 return; |
| 1164 | 1213 |
| 1165 IntRect objectRect = pixelSnappedIntRect(elementRect()); | 1214 IntRect objectRect = pixelSnappedIntRect(elementRect()); |
| 1166 IntPoint scrollPosition = scrollableArea->scrollPosition(); | 1215 IntPoint scrollPosition = scrollableArea->scrollPosition(); |
| 1167 IntRect scrollVisibleRect = scrollableArea->visibleContentRect(); | 1216 IntRect scrollVisibleRect = scrollableArea->visibleContentRect(); |
| 1168 | 1217 |
| 1169 // Convert the object rect into local coordinates. | 1218 // Convert the object rect into local coordinates. |
| 1170 if (!scrollParent->isAXScrollView()) { | 1219 if (!scrollParent->isWebArea()) { |
| 1171 objectRect.moveBy(scrollPosition); | 1220 objectRect.moveBy(scrollPosition); |
| 1172 objectRect.moveBy(-pixelSnappedIntRect(scrollParent->elementRect()).loca
tion()); | 1221 objectRect.moveBy(-pixelSnappedIntRect(scrollParent->elementRect()).loca
tion()); |
| 1173 } | 1222 } |
| 1174 | 1223 |
| 1175 int desiredX = computeBestScrollOffset( | 1224 int desiredX = computeBestScrollOffset( |
| 1176 scrollPosition.x(), | 1225 scrollPosition.x(), |
| 1177 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(), | 1226 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(), |
| 1178 objectRect.x(), objectRect.maxX(), | 1227 objectRect.x(), objectRect.maxX(), |
| 1179 0, scrollVisibleRect.width()); | 1228 0, scrollVisibleRect.width()); |
| 1180 int desiredY = computeBestScrollOffset( | 1229 int desiredY = computeBestScrollOffset( |
| 1181 scrollPosition.y(), | 1230 scrollPosition.y(), |
| 1182 objectRect.y() + subfocus.y(), objectRect.y() + subfocus.maxY(), | 1231 objectRect.y() + subfocus.y(), objectRect.y() + subfocus.maxY(), |
| 1183 objectRect.y(), objectRect.maxY(), | 1232 objectRect.y(), objectRect.maxY(), |
| 1184 0, scrollVisibleRect.height()); | 1233 0, scrollVisibleRect.height()); |
| 1185 | 1234 |
| 1186 scrollParent->scrollTo(IntPoint(desiredX, desiredY)); | 1235 scrollParent->setScrollOffset(IntPoint(desiredX, desiredY)); |
| 1187 | 1236 |
| 1188 // Convert the subfocus into the coordinates of the scroll parent. | 1237 // Convert the subfocus into the coordinates of the scroll parent. |
| 1189 IntRect newSubfocus = subfocus; | 1238 IntRect newSubfocus = subfocus; |
| 1190 IntRect newElementRect = pixelSnappedIntRect(elementRect()); | 1239 IntRect newElementRect = pixelSnappedIntRect(elementRect()); |
| 1191 IntRect scrollParentRect = pixelSnappedIntRect(scrollParent->elementRect()); | 1240 IntRect scrollParentRect = pixelSnappedIntRect(scrollParent->elementRect()); |
| 1192 newSubfocus.move(newElementRect.x(), newElementRect.y()); | 1241 newSubfocus.move(newElementRect.x(), newElementRect.y()); |
| 1193 newSubfocus.move(-scrollParentRect.x(), -scrollParentRect.y()); | 1242 newSubfocus.move(-scrollParentRect.x(), -scrollParentRect.y()); |
| 1194 | 1243 |
| 1195 // Recursively make sure the scroll parent itself is visible. | 1244 // Recursively make sure the scroll parent itself is visible. |
| 1196 if (scrollParent->parentObject()) | 1245 if (scrollParent->parentObject()) |
| 1197 scrollParent->scrollToMakeVisibleWithSubFocus(newSubfocus); | 1246 scrollParent->scrollToMakeVisibleWithSubFocus(newSubfocus); |
| 1198 } | 1247 } |
| 1199 | 1248 |
| 1200 void AXObject::scrollToGlobalPoint(const IntPoint& globalPoint) const | 1249 void AXObject::scrollToGlobalPoint(const IntPoint& globalPoint) const |
| 1201 { | 1250 { |
| 1202 // Search up the parent chain and create a vector of all scrollable parent o
bjects | 1251 // Search up the parent chain and create a vector of all scrollable parent o
bjects |
| 1203 // and ending with this object itself. | 1252 // and ending with this object itself. |
| 1204 Vector<const AXObject*> objects; | 1253 Vector<const AXObject*> objects; |
| 1205 AXObject* parentObject; | 1254 AXObject* parentObject; |
| 1206 for (parentObject = this->parentObject(); parentObject; parentObject = paren
tObject->parentObject()) { | 1255 for (parentObject = this->parentObject(); parentObject; parentObject = paren
tObject->parentObject()) { |
| 1207 if (parentObject->getScrollableAreaIfScrollable()) | 1256 if (parentObject->getScrollableAreaIfScrollable() && !parentObject->isAX
ScrollView()) |
| 1208 objects.prepend(parentObject); | 1257 objects.prepend(parentObject); |
| 1209 } | 1258 } |
| 1210 objects.append(this); | 1259 objects.append(this); |
| 1211 | 1260 |
| 1212 // Start with the outermost scrollable (the main window) and try to scroll t
he | 1261 // Start with the outermost scrollable (the main window) and try to scroll t
he |
| 1213 // next innermost object to the given point. | 1262 // next innermost object to the given point. |
| 1214 int offsetX = 0, offsetY = 0; | 1263 int offsetX = 0, offsetY = 0; |
| 1215 IntPoint point = globalPoint; | 1264 IntPoint point = globalPoint; |
| 1216 size_t levels = objects.size() - 1; | 1265 size_t levels = objects.size() - 1; |
| 1217 for (size_t i = 0; i < levels; i++) { | 1266 for (size_t i = 0; i < levels; i++) { |
| 1218 const AXObject* outer = objects[i]; | 1267 const AXObject* outer = objects[i]; |
| 1219 const AXObject* inner = objects[i + 1]; | 1268 const AXObject* inner = objects[i + 1]; |
| 1220 | |
| 1221 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable(); | 1269 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable(); |
| 1222 | 1270 |
| 1223 IntRect innerRect = inner->isAXScrollView() ? pixelSnappedIntRect(inner-
>parentObject()->elementRect()) : pixelSnappedIntRect(inner->elementRect()); | 1271 IntRect innerRect = inner->isWebArea() ? pixelSnappedIntRect(inner->pare
ntObject()->elementRect()) : pixelSnappedIntRect(inner->elementRect()); |
| 1224 IntRect objectRect = innerRect; | 1272 IntRect objectRect = innerRect; |
| 1225 IntPoint scrollPosition = scrollableArea->scrollPosition(); | 1273 IntPoint scrollPosition = scrollableArea->scrollPosition(); |
| 1226 | 1274 |
| 1227 // Convert the object rect into local coordinates. | 1275 // Convert the object rect into local coordinates. |
| 1228 objectRect.move(offsetX, offsetY); | 1276 objectRect.move(offsetX, offsetY); |
| 1229 if (!outer->isAXScrollView()) | 1277 if (!outer->isWebArea()) |
| 1230 objectRect.move(scrollPosition.x(), scrollPosition.y()); | 1278 objectRect.move(scrollPosition.x(), scrollPosition.y()); |
| 1231 | 1279 |
| 1232 int desiredX = computeBestScrollOffset( | 1280 int desiredX = computeBestScrollOffset( |
| 1233 0, | 1281 0, |
| 1234 objectRect.x(), objectRect.maxX(), | 1282 objectRect.x(), objectRect.maxX(), |
| 1235 objectRect.x(), objectRect.maxX(), | 1283 objectRect.x(), objectRect.maxX(), |
| 1236 point.x(), point.x()); | 1284 point.x(), point.x()); |
| 1237 int desiredY = computeBestScrollOffset( | 1285 int desiredY = computeBestScrollOffset( |
| 1238 0, | 1286 0, |
| 1239 objectRect.y(), objectRect.maxY(), | 1287 objectRect.y(), objectRect.maxY(), |
| 1240 objectRect.y(), objectRect.maxY(), | 1288 objectRect.y(), objectRect.maxY(), |
| 1241 point.y(), point.y()); | 1289 point.y(), point.y()); |
| 1242 outer->scrollTo(IntPoint(desiredX, desiredY)); | 1290 outer->setScrollOffset(IntPoint(desiredX, desiredY)); |
| 1243 | 1291 |
| 1244 if (outer->isAXScrollView() && !inner->isAXScrollView()) { | 1292 if (outer->isWebArea() && !inner->isWebArea()) { |
| 1245 // If outer object we just scrolled is a scroll view (main window or
iframe) but the | 1293 // If outer object we just scrolled is a web area (frame) but the in
ner object |
| 1246 // inner object is not, keep track of the coordinate transformation
to apply to | 1294 // is not, keep track of the coordinate transformation to apply to |
| 1247 // future nested calculations. | 1295 // future nested calculations. |
| 1248 scrollPosition = scrollableArea->scrollPosition(); | 1296 scrollPosition = scrollableArea->scrollPosition(); |
| 1249 offsetX -= (scrollPosition.x() + point.x()); | 1297 offsetX -= (scrollPosition.x() + point.x()); |
| 1250 offsetY -= (scrollPosition.y() + point.y()); | 1298 offsetY -= (scrollPosition.y() + point.y()); |
| 1251 point.move(scrollPosition.x() - innerRect.x(), scrollPosition.y() -
innerRect.y()); | 1299 point.move(scrollPosition.x() - innerRect.x(), scrollPosition.y() -
innerRect.y()); |
| 1252 } else if (inner->isAXScrollView()) { | 1300 } else if (inner->isWebArea()) { |
| 1253 // Otherwise, if the inner object is a scroll view, reset the coordi
nate transformation. | 1301 // Otherwise, if the inner object is a web area, reset the coordinat
e transformation. |
| 1254 offsetX = 0; | 1302 offsetX = 0; |
| 1255 offsetY = 0; | 1303 offsetY = 0; |
| 1256 } | 1304 } |
| 1257 } | 1305 } |
| 1258 } | 1306 } |
| 1259 | 1307 |
| 1260 void AXObject::notifyIfIgnoredValueChanged() | 1308 void AXObject::notifyIfIgnoredValueChanged() |
| 1261 { | 1309 { |
| 1262 bool isIgnored = accessibilityIsIgnored(); | 1310 bool isIgnored = accessibilityIsIgnored(); |
| 1263 if (lastKnownIsIgnoredValue() != isIgnored) { | 1311 if (lastKnownIsIgnoredValue() != isIgnored) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 } | 1467 } |
| 1420 | 1468 |
| 1421 const AtomicString& AXObject::internalRoleName(AccessibilityRole role) | 1469 const AtomicString& AXObject::internalRoleName(AccessibilityRole role) |
| 1422 { | 1470 { |
| 1423 static const Vector<AtomicString>* internalRoleNameVector = createInternalRo
leNameVector(); | 1471 static const Vector<AtomicString>* internalRoleNameVector = createInternalRo
leNameVector(); |
| 1424 | 1472 |
| 1425 return internalRoleNameVector->at(role); | 1473 return internalRoleNameVector->at(role); |
| 1426 } | 1474 } |
| 1427 | 1475 |
| 1428 } // namespace blink | 1476 } // namespace blink |
| OLD | NEW |