Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2349653002: Added support of getClientRects() for SVG Elements. (Closed)
Patch Set: nits Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 // TODO(tkent): Can we check invisibility by scrollable non-frame elements? 1024 // TODO(tkent): Can we check invisibility by scrollable non-frame elements?
1025 1025
1026 IntSize viewportSize = document().page()->frameHost().visualViewport().size( ); 1026 IntSize viewportSize = document().page()->frameHost().visualViewport().size( );
1027 IntRect rect(0, 0, viewportSize.width(), viewportSize.height()); 1027 IntRect rect(0, 0, viewportSize.width(), viewportSize.height());
1028 // We don't use absoluteBoundingBoxRect() because it can return an IntRect 1028 // We don't use absoluteBoundingBoxRect() because it can return an IntRect
1029 // larger the actual size by 1px. crbug.com/470503 1029 // larger the actual size by 1px. crbug.com/470503
1030 rect.intersect(document().view()->contentsToViewport(roundedIntRect(layoutOb ject()->absoluteBoundingBoxFloatRect()))); 1030 rect.intersect(document().view()->contentsToViewport(roundedIntRect(layoutOb ject()->absoluteBoundingBoxFloatRect())));
1031 return rect; 1031 return rect;
1032 } 1032 }
1033 1033
1034 void Element::clientQuads(Vector<FloatQuad>& quads)
1035 {
1036 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
1037
1038 LayoutObject* elementLayoutObject = layoutObject();
1039 if (!elementLayoutObject)
1040 return;
1041
1042 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) {
1043 // Get the bounding rectangle from the SVG model.
1044 if (toSVGElement(this)->isSVGGraphicsElement())
1045 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLayoutO bject->objectBoundingBox()));
1046 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObject->i sBR()) {
1047 elementLayoutObject->absoluteQuads(quads);
1048 }
1049 }
1050
1034 ClientRectList* Element::getClientRects() 1051 ClientRectList* Element::getClientRects()
1035 { 1052 {
1036 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 1053 Vector<FloatQuad> quads;
1054 clientQuads(quads);
1055 if (quads.isEmpty())
1056 return ClientRectList::create();
1057
1058 // FIXME: Handle table/inline-table with a caption.
1037 1059
1038 LayoutObject* elementLayoutObject = layoutObject(); 1060 LayoutObject* elementLayoutObject = layoutObject();
1039 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el ementLayoutObject->isBR())) 1061 DCHECK(elementLayoutObject);
1040 return ClientRectList::create();
1041
1042 // FIXME: Handle SVG elements.
1043 // FIXME: Handle table/inline-table with a caption.
rwlbuis 2016/09/19 17:24:59 Don't we want to keep these FIXMEs?
Shanmuga Pandi 2016/09/20 05:43:10 I kept the FIXME for table/inline-table... And rem
1044
1045 Vector<FloatQuad> quads;
1046 elementLayoutObject->absoluteQuads(quads);
1047 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj ect); 1062 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj ect);
1048 return ClientRectList::create(quads); 1063 return ClientRectList::create(quads);
1049 } 1064 }
1050 1065
1051 ClientRect* Element::getBoundingClientRect() 1066 ClientRect* Element::getBoundingClientRect()
1052 { 1067 {
1053 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
1054
1055 Vector<FloatQuad> quads; 1068 Vector<FloatQuad> quads;
1056 LayoutObject* elementLayoutObject = layoutObject(); 1069 clientQuads(quads);
1057 if (elementLayoutObject) {
1058 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) {
1059 // Get the bounding rectangle from the SVG model.
1060 if (toSVGElement(this)->isSVGGraphicsElement())
1061 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay outObject->objectBoundingBox()));
1062 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec t->isBR()) {
1063 elementLayoutObject->absoluteQuads(quads);
1064 }
1065 }
1066
1067 if (quads.isEmpty()) 1070 if (quads.isEmpty())
1068 return ClientRect::create(); 1071 return ClientRect::create();
1069 1072
1070 FloatRect result = quads[0].boundingBox(); 1073 FloatRect result = quads[0].boundingBox();
1071 for (size_t i = 1; i < quads.size(); ++i) 1074 for (size_t i = 1; i < quads.size(); ++i)
1072 result.unite(quads[i].boundingBox()); 1075 result.unite(quads[i].boundingBox());
1073 1076
1077 LayoutObject* elementLayoutObject = layoutObject();
1074 DCHECK(elementLayoutObject); 1078 DCHECK(elementLayoutObject);
1075 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj ect); 1079 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj ect);
1076 return ClientRect::create(result); 1080 return ClientRect::create(result);
1077 } 1081 }
1078 1082
1079 const AtomicString& Element::computedRole() 1083 const AtomicString& Element::computedRole()
1080 { 1084 {
1081 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 1085 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
1082 std::unique_ptr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(doc ument()); 1086 std::unique_ptr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(doc ument());
1083 return cache->get()->computedRoleForNode(this); 1087 return cache->get()->computedRoleForNode(this);
(...skipping 2733 matching lines...) Expand 10 before | Expand all | Expand 10 after
3817 3821
3818 DEFINE_TRACE_WRAPPERS(Element) 3822 DEFINE_TRACE_WRAPPERS(Element)
3819 { 3823 {
3820 if (hasRareData()) { 3824 if (hasRareData()) {
3821 visitor->traceWrappers(elementRareData()); 3825 visitor->traceWrappers(elementRareData());
3822 } 3826 }
3823 ContainerNode::traceWrappers(visitor); 3827 ContainerNode::traceWrappers(visitor);
3824 } 3828 }
3825 3829
3826 } // namespace blink 3830 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698