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

Side by Side Diff: third_party/WebKit/Source/core/layout/IntersectionGeometry.cpp

Issue 2849403002: Use const ref for LocalFrame::LocalFrameRoot and FrameTree::Top (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
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/layout/IntersectionGeometry.h" 5 #include "core/layout/IntersectionGeometry.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/html/HTMLFrameOwnerElement.h" 9 #include "core/html/HTMLFrameOwnerElement.h"
10 #include "core/layout/LayoutBox.h" 10 #include "core/layout/LayoutBox.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (length.GetType() == kPercent) { 51 if (length.GetType() == kPercent) {
52 return LayoutUnit(static_cast<int>(reference_length.ToFloat() * 52 return LayoutUnit(static_cast<int>(reference_length.ToFloat() *
53 length.Percent() / 100.0)); 53 length.Percent() / 100.0));
54 } 54 }
55 DCHECK_EQ(length.GetType(), kFixed); 55 DCHECK_EQ(length.GetType(), kFixed);
56 return LayoutUnit(length.IntValue()); 56 return LayoutUnit(length.IntValue());
57 } 57 }
58 58
59 LayoutView* LocalRootView(Element& element) { 59 LayoutView* LocalRootView(Element& element) {
60 LocalFrame* frame = element.GetDocument().GetFrame(); 60 LocalFrame* frame = element.GetDocument().GetFrame();
61 LocalFrame* frame_root = frame ? frame->LocalFrameRoot() : nullptr; 61 LocalFrame* frame_root = frame ? &frame->LocalFrameRoot() : nullptr;
62 return frame_root ? frame_root->ContentLayoutObject() : nullptr; 62 return frame_root ? frame_root->ContentLayoutObject() : nullptr;
63 } 63 }
64 64
65 } // namespace 65 } // namespace
66 66
67 IntersectionGeometry::IntersectionGeometry(Element* root, 67 IntersectionGeometry::IntersectionGeometry(Element* root,
68 Element& target, 68 Element& target,
69 const Vector<Length>& root_margin, 69 const Vector<Length>& root_margin,
70 bool should_report_root_bounds) 70 bool should_report_root_bounds)
71 : root_(root ? root->GetLayoutObject() : LocalRootView(target)), 71 : root_(root ? root->GetLayoutObject() : LocalRootView(target)),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 root_->GetFrameView()->MapQuadToAncestorFrameIncludingScrollOffset( 168 root_->GetFrameView()->MapQuadToAncestorFrameIncludingScrollOffset(
169 root_rect_, root_, 169 root_rect_, root_,
170 RootIsImplicit() ? nullptr : root_->GetDocument().GetLayoutView(), 170 RootIsImplicit() ? nullptr : root_->GetDocument().GetLayoutView(),
171 kUseTransforms | kApplyContainerFlip); 171 kUseTransforms | kApplyContainerFlip);
172 } 172 }
173 173
174 void IntersectionGeometry::MapIntersectionRectToTargetFrameCoordinates() { 174 void IntersectionGeometry::MapIntersectionRectToTargetFrameCoordinates() {
175 Document& target_document = target_->GetDocument(); 175 Document& target_document = target_->GetDocument();
176 if (RootIsImplicit()) { 176 if (RootIsImplicit()) {
177 LocalFrame* target_frame = target_document.GetFrame(); 177 LocalFrame* target_frame = target_document.GetFrame();
178 Frame* root_frame = target_frame->Tree().Top(); 178 Frame& root_frame = target_frame->Tree().Top();
179 LayoutSize scroll_position = 179 LayoutSize scroll_position =
180 LayoutSize(target_document.View()->GetScrollOffset()); 180 LayoutSize(target_document.View()->GetScrollOffset());
181 if (target_frame != root_frame) 181 if (target_frame != &root_frame)
182 MapRectDownToDocument(intersection_rect_, nullptr, target_document); 182 MapRectDownToDocument(intersection_rect_, nullptr, target_document);
183 intersection_rect_.Move(-scroll_position); 183 intersection_rect_.Move(-scroll_position);
184 } else { 184 } else {
185 LayoutSize scroll_position = 185 LayoutSize scroll_position =
186 LayoutSize(target_document.View()->GetScrollOffset()); 186 LayoutSize(target_document.View()->GetScrollOffset());
187 MapRectUpToDocument(intersection_rect_, *root_, root_->GetDocument()); 187 MapRectUpToDocument(intersection_rect_, *root_, root_->GetDocument());
188 intersection_rect_.Move(-scroll_position); 188 intersection_rect_.Move(-scroll_position);
189 } 189 }
190 } 190 }
191 191
192 void IntersectionGeometry::ComputeGeometry() { 192 void IntersectionGeometry::ComputeGeometry() {
193 if (!CanComputeGeometry()) 193 if (!CanComputeGeometry())
194 return; 194 return;
195 ClipToRoot(); 195 ClipToRoot();
196 MapTargetRectToTargetFrameCoordinates(); 196 MapTargetRectToTargetFrameCoordinates();
197 if (does_intersect_) 197 if (does_intersect_)
198 MapIntersectionRectToTargetFrameCoordinates(); 198 MapIntersectionRectToTargetFrameCoordinates();
199 else 199 else
200 intersection_rect_ = LayoutRect(); 200 intersection_rect_ = LayoutRect();
201 // Small optimization: if we're not going to report root bounds, don't bother 201 // Small optimization: if we're not going to report root bounds, don't bother
202 // transforming them to the frame. 202 // transforming them to the frame.
203 if (ShouldReportRootBounds()) 203 if (ShouldReportRootBounds())
204 MapRootRectToRootFrameCoordinates(); 204 MapRootRectToRootFrameCoordinates();
205 } 205 }
206 206
207 } // namespace blink 207 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698