| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 return new AXLayoutObject(layoutObject, axObjectCache); | 192 return new AXLayoutObject(layoutObject, axObjectCache); |
| 193 } | 193 } |
| 194 | 194 |
| 195 AXLayoutObject::~AXLayoutObject() | 195 AXLayoutObject::~AXLayoutObject() |
| 196 { | 196 { |
| 197 ASSERT(isDetached()); | 197 ASSERT(isDetached()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 LayoutRect AXLayoutObject::elementRect() const | 200 LayoutRect AXLayoutObject::elementRect() const |
| 201 { | 201 { |
| 202 if (!m_explicitElementRect.isEmpty()) | 202 if (!m_explicitElementRect.isEmpty()) { |
| 203 return m_explicitElementRect; | 203 LayoutRect bounds = m_explicitElementRect; |
| 204 AXObject* canvas = axObjectCache().objectFromAXID(m_explicitContainerID)
; |
| 205 if (canvas) |
| 206 bounds.moveBy(canvas->elementRect().location()); |
| 207 return bounds; |
| 208 } |
| 204 | 209 |
| 205 // FIXME(dmazzoni): use relative bounds instead since this is a bottleneck. | 210 // FIXME(dmazzoni): use relative bounds instead since this is a bottleneck. |
| 206 // http://crbug.com/618120 | 211 // http://crbug.com/618120 |
| 207 return computeElementRect(); | 212 return computeElementRect(); |
| 208 } | 213 } |
| 209 | 214 |
| 210 SkMatrix44 AXLayoutObject::transformFromLocalParentFrame() const | 215 SkMatrix44 AXLayoutObject::transformFromLocalParentFrame() const |
| 211 { | 216 { |
| 212 if (!m_layoutObject) | 217 if (!m_layoutObject) |
| 213 return SkMatrix44(); | 218 return SkMatrix44(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 250 |
| 246 return box->getScrollableArea(); | 251 return box->getScrollableArea(); |
| 247 } | 252 } |
| 248 | 253 |
| 249 void AXLayoutObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBo
undsInContainer, SkMatrix44& outContainerTransform) const | 254 void AXLayoutObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBo
undsInContainer, SkMatrix44& outContainerTransform) const |
| 250 { | 255 { |
| 251 *outContainer = nullptr; | 256 *outContainer = nullptr; |
| 252 outBoundsInContainer = FloatRect(); | 257 outBoundsInContainer = FloatRect(); |
| 253 outContainerTransform.setIdentity(); | 258 outContainerTransform.setIdentity(); |
| 254 | 259 |
| 260 // First check if it has explicit bounds, for example if this element is tie
d to a |
| 261 // canvas path. When explicit coordinates are provided, the ID of the explic
it container |
| 262 // element that the coordinates are relative to must be provided too. |
| 263 if (!m_explicitElementRect.isEmpty()) { |
| 264 *outContainer = axObjectCache().objectFromAXID(m_explicitContainerID); |
| 265 if (*outContainer) { |
| 266 outBoundsInContainer = FloatRect(m_explicitElementRect); |
| 267 return; |
| 268 } |
| 269 } |
| 270 |
| 255 if (!m_layoutObject) | 271 if (!m_layoutObject) |
| 256 return; | 272 return; |
| 257 | 273 |
| 274 if (isWebArea()) { |
| 275 if (m_layoutObject->frame()->view()) |
| 276 outBoundsInContainer.setSize(FloatSize(m_layoutObject->frame()->view
()->contentsSize())); |
| 277 return; |
| 278 } |
| 279 |
| 258 // First compute the container. The container must be an ancestor in the acc
essibility tree, and | 280 // First compute the container. The container must be an ancestor in the acc
essibility tree, and |
| 259 // its LayoutObject must be an ancestor in the layout tree. Get the first su
ch ancestor that's | 281 // its LayoutObject must be an ancestor in the layout tree. Get the first su
ch ancestor that's |
| 260 // either scrollable or has a paint layer. | 282 // either scrollable or has a paint layer. |
| 261 AXObject* container = parentObjectUnignored(); | 283 AXObject* container = parentObjectUnignored(); |
| 262 LayoutObject* containerLayoutObject = nullptr; | 284 LayoutObject* containerLayoutObject = nullptr; |
| 263 while (container) { | 285 while (container) { |
| 264 containerLayoutObject = container->getLayoutObject(); | 286 containerLayoutObject = container->getLayoutObject(); |
| 265 if (containerLayoutObject && containerLayoutObject->isBoxModelObject() &
& m_layoutObject->isDescendantOf(containerLayoutObject)) { | 287 if (containerLayoutObject && containerLayoutObject->isBoxModelObject() &
& m_layoutObject->isDescendantOf(containerLayoutObject)) { |
| 266 if (container->isScrollableContainer() || containerLayoutObject->has
Layer()) | 288 if (container->isScrollableContainer() || containerLayoutObject->has
Layer()) |
| 267 break; | 289 break; |
| 268 } | 290 } |
| 269 | 291 |
| 270 container = container->parentObjectUnignored(); | 292 container = container->parentObjectUnignored(); |
| 271 } | 293 } |
| 272 | 294 |
| 273 if (!container) | 295 if (!container) |
| 274 return; | 296 return; |
| 275 *outContainer = container; | 297 *outContainer = container; |
| 276 | 298 |
| 277 // Next get the local bounds of this LayoutObject, which is typically | 299 // Next get the local bounds of this LayoutObject, which is typically |
| 278 // a rect at point (0, 0) with the width and height of the LayoutObject. | 300 // a rect at point (0, 0) with the width and height of the LayoutObject. |
| 279 LayoutRect localBounds; | 301 LayoutRect localBounds; |
| 280 if (m_layoutObject->isText()) { | 302 if (m_layoutObject->isText()) { |
| 281 localBounds = toLayoutText(m_layoutObject)->linesBoundingBox(); | 303 Vector<FloatQuad> quads; |
| 304 toLayoutText(m_layoutObject)->quads(quads, LayoutText::ClipToEllipsis, L
ayoutText::LocalQuads); |
| 305 for (const FloatQuad& quad : quads) |
| 306 localBounds.unite(LayoutRect(quad.boundingBox())); |
| 282 } else if (m_layoutObject->isLayoutInline()) { | 307 } else if (m_layoutObject->isLayoutInline()) { |
| 283 localBounds = toLayoutInline(m_layoutObject)->linesBoundingBox(); | 308 Vector<LayoutRect> rects; |
| 309 toLayoutInline(m_layoutObject)->addOutlineRects(rects, LayoutPoint(), La
youtObject::IncludeBlockVisualOverflow); |
| 310 localBounds = unionRect(rects); |
| 284 } else if (m_layoutObject->isBox()) { | 311 } else if (m_layoutObject->isBox()) { |
| 285 localBounds = LayoutRect(LayoutPoint(), toLayoutBox(m_layoutObject)->siz
e()); | 312 localBounds = LayoutRect(LayoutPoint(), toLayoutBox(m_layoutObject)->siz
e()); |
| 286 } else if (m_layoutObject->isSVG()) { | 313 } else if (m_layoutObject->isSVG()) { |
| 287 localBounds = LayoutRect(m_layoutObject->strokeBoundingBox()); | 314 localBounds = LayoutRect(m_layoutObject->strokeBoundingBox()); |
| 288 } else { | 315 } else { |
| 289 DCHECK(false); | 316 DCHECK(false); |
| 290 } | 317 } |
| 291 outBoundsInContainer = FloatRect(localBounds); | 318 outBoundsInContainer = FloatRect(localBounds); |
| 292 | 319 |
| 293 // If the container has a scroll offset, subtract that out because we want o
ur | 320 // If the container has a scroll offset, subtract that out because we want o
ur |
| 294 // bounds to be relative to the *unscrolled* position of the container objec
t. | 321 // bounds to be relative to the *unscrolled* position of the container objec
t. |
| 295 ScrollableArea* scrollableArea = container->getScrollableAreaIfScrollable(); | 322 ScrollableArea* scrollableArea = container->getScrollableAreaIfScrollable(); |
| 296 if (scrollableArea) { | 323 if (scrollableArea && !container->isWebArea()) { |
| 297 IntPoint scrollPosition = scrollableArea->scrollPosition(); | 324 IntPoint scrollPosition = scrollableArea->scrollPosition(); |
| 298 outBoundsInContainer.move(FloatSize(scrollPosition.x(), scrollPosition.y
())); | 325 outBoundsInContainer.move(FloatSize(scrollPosition.x(), scrollPosition.y
())); |
| 299 } | 326 } |
| 300 | 327 |
| 301 // Compute the transform between the container's coordinate space and this o
bject. | 328 // Compute the transform between the container's coordinate space and this o
bject. |
| 302 // If the transform is just a simple translation, apply that to the bounding
box, but | 329 // If the transform is just a simple translation, apply that to the bounding
box, but |
| 303 // if it's a non-trivial transformation like a rotation, scaling, etc. then
return | 330 // if it's a non-trivial transformation like a rotation, scaling, etc. then
return |
| 304 // the full matrix instead. | 331 // the full matrix instead. |
| 305 TransformationMatrix transform = m_layoutObject->localToAncestorTransform(to
LayoutBoxModelObject(containerLayoutObject)); | 332 TransformationMatrix transform = m_layoutObject->localToAncestorTransform(to
LayoutBoxModelObject(containerLayoutObject)); |
| 306 if (transform.isIdentityOr2DTranslation()) { | 333 if (transform.isIdentityOr2DTranslation()) { |
| (...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2548 if (obj->node()) // If we are a continuation, we want to make sure to use th
e primary layoutObject. | 2575 if (obj->node()) // If we are a continuation, we want to make sure to use th
e primary layoutObject. |
| 2549 obj = obj->node()->layoutObject(); | 2576 obj = obj->node()->layoutObject(); |
| 2550 | 2577 |
| 2551 // absoluteFocusRingBoundingBox will query the hierarchy below this element,
which for large webpages can be very slow. | 2578 // absoluteFocusRingBoundingBox will query the hierarchy below this element,
which for large webpages can be very slow. |
| 2552 // For a web area, which will have the most elements of any element, absolut
eQuads should be used. | 2579 // For a web area, which will have the most elements of any element, absolut
eQuads should be used. |
| 2553 // We should also use absoluteQuads for SVG elements, otherwise transforms w
on't be applied. | 2580 // We should also use absoluteQuads for SVG elements, otherwise transforms w
on't be applied. |
| 2554 | 2581 |
| 2555 LayoutRect result; | 2582 LayoutRect result; |
| 2556 if (obj->isText()) { | 2583 if (obj->isText()) { |
| 2557 Vector<FloatQuad> quads; | 2584 Vector<FloatQuad> quads; |
| 2558 toLayoutText(obj)->absoluteQuads(quads, LayoutText::ClipToEllipsis); | 2585 toLayoutText(obj)->quads(quads, LayoutText::ClipToEllipsis, LayoutText::
AbsoluteQuads); |
| 2559 result = LayoutRect(boundingBoxForQuads(obj, quads)); | 2586 result = LayoutRect(boundingBoxForQuads(obj, quads)); |
| 2560 } else if (isWebArea() || obj->isSVGRoot()) { | 2587 } else if (isWebArea() || obj->isSVGRoot()) { |
| 2561 result = LayoutRect(obj->absoluteBoundingBoxRect()); | 2588 result = LayoutRect(obj->absoluteBoundingBoxRect()); |
| 2562 } else { | 2589 } else { |
| 2563 result = LayoutRect(obj->absoluteElementBoundingBoxRect()); | 2590 result = LayoutRect(obj->absoluteElementBoundingBoxRect()); |
| 2564 } | 2591 } |
| 2565 | 2592 |
| 2566 Document* document = this->getDocument(); | 2593 Document* document = this->getDocument(); |
| 2567 if (document && document->isSVGDocument()) | 2594 if (document && document->isSVGDocument()) |
| 2568 offsetBoundingBoxForRemoteSVGElement(result); | 2595 offsetBoundingBoxForRemoteSVGElement(result); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2587 result.unite(labelRect); | 2614 result.unite(labelRect); |
| 2588 } | 2615 } |
| 2589 } | 2616 } |
| 2590 } | 2617 } |
| 2591 } | 2618 } |
| 2592 | 2619 |
| 2593 return result; | 2620 return result; |
| 2594 } | 2621 } |
| 2595 | 2622 |
| 2596 } // namespace blink | 2623 } // namespace blink |
| OLD | NEW |