OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 // TODO(tkent): Can we check invisibility by scrollable non-frame elements? | 1027 // TODO(tkent): Can we check invisibility by scrollable non-frame elements? |
1028 | 1028 |
1029 IntSize viewportSize = document().page()->frameHost().visualViewport().size(
); | 1029 IntSize viewportSize = document().page()->frameHost().visualViewport().size(
); |
1030 IntRect rect(0, 0, viewportSize.width(), viewportSize.height()); | 1030 IntRect rect(0, 0, viewportSize.width(), viewportSize.height()); |
1031 // We don't use absoluteBoundingBoxRect() because it can return an IntRect | 1031 // We don't use absoluteBoundingBoxRect() because it can return an IntRect |
1032 // larger the actual size by 1px. crbug.com/470503 | 1032 // larger the actual size by 1px. crbug.com/470503 |
1033 rect.intersect(document().view()->contentsToViewport(roundedIntRect(layoutOb
ject()->absoluteBoundingBoxFloatRect()))); | 1033 rect.intersect(document().view()->contentsToViewport(roundedIntRect(layoutOb
ject()->absoluteBoundingBoxFloatRect()))); |
1034 return rect; | 1034 return rect; |
1035 } | 1035 } |
1036 | 1036 |
| 1037 void Element::clientQuads(Vector<FloatQuad>& quads) |
| 1038 { |
| 1039 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1040 |
| 1041 LayoutObject* elementLayoutObject = layoutObject(); |
| 1042 if (!elementLayoutObject) |
| 1043 return; |
| 1044 |
| 1045 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { |
| 1046 // Get the bounding rectangle from the SVG model. |
| 1047 if (toSVGElement(this)->isSVGGraphicsElement()) |
| 1048 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLayoutO
bject->objectBoundingBox())); |
| 1049 return; |
| 1050 } |
| 1051 |
| 1052 // FIXME: Handle table/inline-table with a caption. |
| 1053 if (elementLayoutObject->isBoxModelObject() || elementLayoutObject->isBR()) |
| 1054 elementLayoutObject->absoluteQuads(quads); |
| 1055 } |
| 1056 |
1037 ClientRectList* Element::getClientRects() | 1057 ClientRectList* Element::getClientRects() |
1038 { | 1058 { |
1039 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 1059 Vector<FloatQuad> quads; |
| 1060 clientQuads(quads); |
| 1061 if (quads.isEmpty()) |
| 1062 return ClientRectList::create(); |
1040 | 1063 |
1041 LayoutObject* elementLayoutObject = layoutObject(); | 1064 LayoutObject* elementLayoutObject = layoutObject(); |
1042 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el
ementLayoutObject->isBR())) | 1065 DCHECK(elementLayoutObject); |
1043 return ClientRectList::create(); | |
1044 | |
1045 // FIXME: Handle SVG elements. | |
1046 // FIXME: Handle table/inline-table with a caption. | |
1047 | |
1048 Vector<FloatQuad> quads; | |
1049 elementLayoutObject->absoluteQuads(quads); | |
1050 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); | 1066 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); |
1051 return ClientRectList::create(quads); | 1067 return ClientRectList::create(quads); |
1052 } | 1068 } |
1053 | 1069 |
1054 ClientRect* Element::getBoundingClientRect() | 1070 ClientRect* Element::getBoundingClientRect() |
1055 { | 1071 { |
1056 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | |
1057 | |
1058 Vector<FloatQuad> quads; | 1072 Vector<FloatQuad> quads; |
1059 LayoutObject* elementLayoutObject = layoutObject(); | 1073 clientQuads(quads); |
1060 if (elementLayoutObject) { | |
1061 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { | |
1062 // Get the bounding rectangle from the SVG model. | |
1063 if (toSVGElement(this)->isSVGGraphicsElement()) | |
1064 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay
outObject->objectBoundingBox())); | |
1065 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec
t->isBR()) { | |
1066 elementLayoutObject->absoluteQuads(quads); | |
1067 } | |
1068 } | |
1069 | |
1070 if (quads.isEmpty()) | 1074 if (quads.isEmpty()) |
1071 return ClientRect::create(); | 1075 return ClientRect::create(); |
1072 | 1076 |
1073 FloatRect result = quads[0].boundingBox(); | 1077 FloatRect result = quads[0].boundingBox(); |
1074 for (size_t i = 1; i < quads.size(); ++i) | 1078 for (size_t i = 1; i < quads.size(); ++i) |
1075 result.unite(quads[i].boundingBox()); | 1079 result.unite(quads[i].boundingBox()); |
1076 | 1080 |
| 1081 LayoutObject* elementLayoutObject = layoutObject(); |
1077 DCHECK(elementLayoutObject); | 1082 DCHECK(elementLayoutObject); |
1078 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); | 1083 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); |
1079 return ClientRect::create(result); | 1084 return ClientRect::create(result); |
1080 } | 1085 } |
1081 | 1086 |
1082 const AtomicString& Element::computedRole() | 1087 const AtomicString& Element::computedRole() |
1083 { | 1088 { |
1084 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 1089 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
1085 std::unique_ptr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(doc
ument()); | 1090 std::unique_ptr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(doc
ument()); |
1086 return cache->get()->computedRoleForNode(this); | 1091 return cache->get()->computedRoleForNode(this); |
(...skipping 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3829 | 3834 |
3830 DEFINE_TRACE_WRAPPERS(Element) | 3835 DEFINE_TRACE_WRAPPERS(Element) |
3831 { | 3836 { |
3832 if (hasRareData()) { | 3837 if (hasRareData()) { |
3833 visitor->traceWrappers(elementRareData()); | 3838 visitor->traceWrappers(elementRareData()); |
3834 } | 3839 } |
3835 ContainerNode::traceWrappers(visitor); | 3840 ContainerNode::traceWrappers(visitor); |
3836 } | 3841 } |
3837 | 3842 |
3838 } // namespace blink | 3843 } // namespace blink |
OLD | NEW |