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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 | 1006 |
1007 bool Element::hasNonEmptyLayoutSize() const | 1007 bool Element::hasNonEmptyLayoutSize() const |
1008 { | 1008 { |
1009 document().updateLayoutIgnorePendingStylesheets(); | 1009 document().updateLayoutIgnorePendingStylesheets(); |
1010 | 1010 |
1011 if (LayoutBoxModelObject* box = layoutBoxModelObject()) | 1011 if (LayoutBoxModelObject* box = layoutBoxModelObject()) |
1012 return box->hasNonEmptyLayoutSize(); | 1012 return box->hasNonEmptyLayoutSize(); |
1013 return false; | 1013 return false; |
1014 } | 1014 } |
1015 | 1015 |
1016 IntRect Element::boundsInViewport() | 1016 bool Element::getBoundingQuads(Vector<FloatQuad>& quads) |
1017 { | 1017 { |
1018 document().updateLayoutIgnorePendingStylesheets(); | 1018 assert(quads.isEmpty()); |
1019 | |
1020 FrameView* view = document().view(); | |
1021 if (!view) | |
1022 return IntRect(); | |
1023 | |
1024 Vector<FloatQuad> quads; | |
1025 if (isSVGElement() && layoutObject()) { | 1019 if (isSVGElement() && layoutObject()) { |
1026 // Get the bounding rectangle from the SVG model. | 1020 // Get the bounding rectangle from the SVG model. |
1027 if (toSVGElement(this)->isSVGGraphicsElement()) | 1021 if (toSVGElement(this)->isSVGGraphicsElement()) |
1028 quads.append(layoutObject()->localToAbsoluteQuad(layoutObject()->obj ectBoundingBox())); | 1022 quads.append(layoutObject()->localToAbsoluteQuad(layoutObject()->obj ectBoundingBox())); |
1029 } else { | 1023 } else { |
1030 // Get the bounding rectangle from the box model. | 1024 // Get the bounding rectangle from the box model. |
1031 if (layoutBoxModelObject()) | 1025 if (layoutBoxModelObject()) |
1032 layoutBoxModelObject()->absoluteQuads(quads); | 1026 layoutBoxModelObject()->absoluteQuads(quads); |
1033 } | 1027 } |
1028 return !quads.isEmpty(); | |
1029 } | |
1034 | 1030 |
1035 if (quads.isEmpty()) | 1031 IntRect Element::boundsInViewport() |
1032 { | |
1033 document().updateLayoutIgnorePendingStylesheets(); | |
1034 | |
1035 FrameView* view = document().view(); | |
1036 if (!view) | |
1037 return IntRect(); | |
1038 | |
1039 Vector<FloatQuad> quads; | |
1040 if (!getBoundingQuads(quads)) | |
1036 return IntRect(); | 1041 return IntRect(); |
1037 | 1042 |
1038 IntRect result = quads[0].enclosingBoundingBox(); | 1043 IntRect result = quads[0].enclosingBoundingBox(); |
1039 for (size_t i = 1; i < quads.size(); ++i) | 1044 for (size_t i = 1; i < quads.size(); ++i) |
1040 result.unite(quads[i].enclosingBoundingBox()); | 1045 result.unite(quads[i].enclosingBoundingBox()); |
1041 | 1046 |
1042 return view->contentsToViewport(result); | 1047 return view->contentsToViewport(result); |
1043 } | 1048 } |
1044 | 1049 |
1050 FloatRect Element::boundsInViewportFloat() | |
bokan
2015/12/10 14:48:39
Perhaps we should just make boundsInViewport retur
huangs
2015/12/10 16:16:14
Replied in main comment.
| |
1051 { | |
1052 document().updateLayoutIgnorePendingStylesheets(); | |
1053 | |
1054 FrameView* view = document().view(); | |
1055 if (!view) | |
1056 return FloatRect(); | |
1057 | |
1058 Vector<FloatQuad> quads; | |
1059 if (!getBoundingQuads(quads)) | |
1060 return FloatRect(); | |
1061 | |
1062 FloatRect result = quads[0].boundingBox(); | |
1063 for (size_t i = 1; i < quads.size(); ++i) | |
1064 result.unite(quads[i].boundingBox()); | |
1065 | |
1066 return view->contentsToViewport(result); | |
1067 } | |
1068 | |
1045 ClientRectList* Element::getClientRects() | 1069 ClientRectList* Element::getClientRects() |
1046 { | 1070 { |
1047 document().updateLayoutIgnorePendingStylesheets(); | 1071 document().updateLayoutIgnorePendingStylesheets(); |
1048 | 1072 |
1049 LayoutObject* elementLayoutObject = layoutObject(); | 1073 LayoutObject* elementLayoutObject = layoutObject(); |
1050 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el ementLayoutObject->isBR())) | 1074 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el ementLayoutObject->isBR())) |
1051 return ClientRectList::create(); | 1075 return ClientRectList::create(); |
1052 | 1076 |
1053 // FIXME: Handle SVG elements. | 1077 // FIXME: Handle SVG elements. |
1054 // FIXME: Handle table/inline-table with a caption. | 1078 // FIXME: Handle table/inline-table with a caption. |
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3631 { | 3655 { |
3632 #if ENABLE(OILPAN) | 3656 #if ENABLE(OILPAN) |
3633 if (hasRareData()) | 3657 if (hasRareData()) |
3634 visitor->trace(elementRareData()); | 3658 visitor->trace(elementRareData()); |
3635 visitor->trace(m_elementData); | 3659 visitor->trace(m_elementData); |
3636 #endif | 3660 #endif |
3637 ContainerNode::trace(visitor); | 3661 ContainerNode::trace(visitor); |
3638 } | 3662 } |
3639 | 3663 |
3640 } // namespace blink | 3664 } // namespace blink |
OLD | NEW |