| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 if (!m_layoutObject || !m_layoutObject->isBox()) | 249 if (!m_layoutObject || !m_layoutObject->isBox()) |
| 250 return 0; | 250 return 0; |
| 251 | 251 |
| 252 LayoutBox* box = toLayoutBox(m_layoutObject); | 252 LayoutBox* box = toLayoutBox(m_layoutObject); |
| 253 if (!box->canBeScrolledAndHasScrollableArea()) | 253 if (!box->canBeScrolledAndHasScrollableArea()) |
| 254 return 0; | 254 return 0; |
| 255 | 255 |
| 256 return box->getScrollableArea(); | 256 return box->getScrollableArea(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void AXLayoutObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBo
undsInContainer, SkMatrix44& outContainerTransform) const |
| 260 { |
| 261 *outContainer = nullptr; |
| 262 outBoundsInContainer = FloatRect(); |
| 263 outContainerTransform.setIdentity(); |
| 264 |
| 265 if (!m_layoutObject) |
| 266 return; |
| 267 |
| 268 // First compute the container. The container must be an ancestor in the acc
essibility tree, and |
| 269 // its LayoutObject must be an ancestor in the layout tree. Get the first su
ch ancestor that's |
| 270 // either scrollable or has a paint layer. |
| 271 AXObject* container = parentObjectUnignored(); |
| 272 LayoutObject* containerLayoutObject = nullptr; |
| 273 while (container) { |
| 274 containerLayoutObject = container->getLayoutObject(); |
| 275 if (containerLayoutObject && containerLayoutObject->isBoxModelObject() &
& m_layoutObject->isDescendantOf(containerLayoutObject)) { |
| 276 if (container->isScrollableContainer() || containerLayoutObject->has
Layer()) |
| 277 break; |
| 278 } |
| 279 |
| 280 container = container->parentObjectUnignored(); |
| 281 } |
| 282 |
| 283 if (!container) |
| 284 return; |
| 285 *outContainer = container; |
| 286 |
| 287 // Next get the local bounds of this LayoutObject, which is typically |
| 288 // a rect at point (0, 0) with the width and height of the LayoutObject. |
| 289 LayoutRect localBounds; |
| 290 if (m_layoutObject->isText()) { |
| 291 localBounds = toLayoutText(m_layoutObject)->linesBoundingBox(); |
| 292 } else if (m_layoutObject->isLayoutInline()) { |
| 293 localBounds = toLayoutInline(m_layoutObject)->linesBoundingBox(); |
| 294 } else if (m_layoutObject->isBox()) { |
| 295 localBounds = LayoutRect(LayoutPoint(), toLayoutBox(m_layoutObject)->siz
e()); |
| 296 } else if (m_layoutObject->isSVG()) { |
| 297 localBounds = LayoutRect(m_layoutObject->strokeBoundingBox()); |
| 298 } else { |
| 299 DCHECK(false); |
| 300 } |
| 301 outBoundsInContainer = FloatRect(localBounds); |
| 302 |
| 303 // If the container has a scroll offset, subtract that out because we want o
ur |
| 304 // bounds to be relative to the *unscrolled* position of the container objec
t. |
| 305 ScrollableArea* scrollableArea = container->getScrollableAreaIfScrollable(); |
| 306 if (scrollableArea) { |
| 307 IntPoint scrollPosition = scrollableArea->scrollPosition(); |
| 308 outBoundsInContainer.move(FloatSize(scrollPosition.x(), scrollPosition.y
())); |
| 309 } |
| 310 |
| 311 // Compute the transform between the container's coordinate space and this o
bject. |
| 312 // If the transform is just a simple translation, apply that to the bounding
box, but |
| 313 // if it's a non-trivial transformation like a rotation, scaling, etc. then
return |
| 314 // the full matrix instead. |
| 315 TransformationMatrix transform = m_layoutObject->localToAncestorTransform(to
LayoutBoxModelObject(containerLayoutObject)); |
| 316 if (transform.isIdentityOr2DTranslation()) { |
| 317 outBoundsInContainer.move(transform.to2DTranslation()); |
| 318 } else { |
| 319 outContainerTransform = TransformationMatrix::toSkMatrix44(transform); |
| 320 } |
| 321 } |
| 322 |
| 259 static bool isImageOrAltText(LayoutBoxModelObject* box, Node* node) | 323 static bool isImageOrAltText(LayoutBoxModelObject* box, Node* node) |
| 260 { | 324 { |
| 261 if (box && box->isImage()) | 325 if (box && box->isImage()) |
| 262 return true; | 326 return true; |
| 263 if (isHTMLImageElement(node)) | 327 if (isHTMLImageElement(node)) |
| 264 return true; | 328 return true; |
| 265 if (isHTMLInputElement(node) && toHTMLInputElement(node)->hasFallbackContent
()) | 329 if (isHTMLInputElement(node) && toHTMLInputElement(node)->hasFallbackContent
()) |
| 266 return true; | 330 return true; |
| 267 return false; | 331 return false; |
| 268 } | 332 } |
| (...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 result.unite(labelRect); | 2566 result.unite(labelRect); |
| 2503 } | 2567 } |
| 2504 } | 2568 } |
| 2505 } | 2569 } |
| 2506 } | 2570 } |
| 2507 | 2571 |
| 2508 return result; | 2572 return result; |
| 2509 } | 2573 } |
| 2510 | 2574 |
| 2511 } // namespace blink | 2575 } // namespace blink |
| OLD | NEW |