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

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

Issue 2854123004: Hoist layout update out of SVGGraphicsElement::GetBBox and overrides (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/SVGGraphicsElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/ResizeObservation.h" 5 #include "core/dom/ResizeObservation.h"
6 6
7 #include "core/dom/ResizeObserver.h" 7 #include "core/dom/ResizeObserver.h"
8 #include "core/layout/LayoutBox.h" 8 #include "core/layout/LayoutBox.h"
9 #include "core/svg/SVGElement.h" 9 #include "core/svg/SVGElement.h"
10 #include "core/svg/SVGGraphicsElement.h" 10 #include "core/svg/SVGGraphicsElement.h"
(...skipping 20 matching lines...) Expand all
31 31
32 size_t ResizeObservation::TargetDepth() { 32 size_t ResizeObservation::TargetDepth() {
33 unsigned depth = 0; 33 unsigned depth = 0;
34 for (Element* parent = target_; parent; parent = parent->parentElement()) 34 for (Element* parent = target_; parent; parent = parent->parentElement())
35 ++depth; 35 ++depth;
36 return depth; 36 return depth;
37 } 37 }
38 38
39 LayoutSize ResizeObservation::ComputeTargetSize() const { 39 LayoutSize ResizeObservation::ComputeTargetSize() const {
40 if (target_) { 40 if (target_) {
41 if (target_->IsSVGElement() && 41 if (LayoutObject* layout_object = target_->GetLayoutObject()) {
42 ToSVGElement(target_)->IsSVGGraphicsElement()) { 42 if (target_->IsSVGElement() &&
43 SVGGraphicsElement& svg = ToSVGGraphicsElement(*target_); 43 ToSVGElement(target_)->IsSVGGraphicsElement()) {
44 return LayoutSize(svg.GetBBox().Size()); 44 SVGGraphicsElement& svg = ToSVGGraphicsElement(*target_);
45 return LayoutSize(svg.GetBBox().Size());
46 }
47 if (layout_object->IsBox())
48 return ToLayoutBox(layout_object)->ContentSize();
45 } 49 }
46 LayoutBox* layout = target_->GetLayoutBox();
47 if (layout)
48 return layout->ContentSize();
49 } 50 }
50 return LayoutSize(); 51 return LayoutSize();
51 } 52 }
52 53
53 LayoutPoint ResizeObservation::ComputeTargetLocation() const { 54 LayoutPoint ResizeObservation::ComputeTargetLocation() const {
54 if (target_ && !target_->IsSVGElement()) { 55 if (target_ && !target_->IsSVGElement()) {
55 if (LayoutBox* layout = target_->GetLayoutBox()) 56 if (LayoutBox* layout = target_->GetLayoutBox())
56 return LayoutPoint(layout->PaddingLeft(), layout->PaddingTop()); 57 return LayoutPoint(layout->PaddingLeft(), layout->PaddingTop());
57 } 58 }
58 return LayoutPoint(); 59 return LayoutPoint();
59 } 60 }
60 61
61 void ResizeObservation::ElementSizeChanged() { 62 void ResizeObservation::ElementSizeChanged() {
62 element_size_changed_ = true; 63 element_size_changed_ = true;
63 observer_->ElementSizeChanged(); 64 observer_->ElementSizeChanged();
64 } 65 }
65 66
66 DEFINE_TRACE(ResizeObservation) { 67 DEFINE_TRACE(ResizeObservation) {
67 visitor->Trace(target_); 68 visitor->Trace(target_);
68 visitor->Trace(observer_); 69 visitor->Trace(observer_);
69 } 70 }
70 71
71 } // namespace blink 72 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/SVGGraphicsElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698