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

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

Issue 2737883002: Rename LayoutPart::widget to LayoutPart::frameViewBase (Closed)
Patch Set: Rename LayoutPart::widget to LayoutPart::frameViewBase Created 3 years, 9 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) 2000 Simon Hausmann <hausmann@kde.org> 3 * (C) 2000 Simon Hausmann <hausmann@kde.org>
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // object points too is invalid, so we have to clear the node so we make sure 81 // object points too is invalid, so we have to clear the node so we make sure
82 // we don't access it in the future. 82 // we don't access it in the future.
83 clearNode(); 83 clearNode();
84 deref(); 84 deref();
85 } 85 }
86 86
87 LayoutPart::~LayoutPart() { 87 LayoutPart::~LayoutPart() {
88 ASSERT(m_refCount <= 0); 88 ASSERT(m_refCount <= 0);
89 } 89 }
90 90
91 FrameViewBase* LayoutPart::widget() const { 91 FrameViewBase* LayoutPart::frameViewBase() const {
92 // Plugin FrameViewBases are stored in their DOM node. 92 // Plugin FrameViewBases are stored in their DOM node.
93 Element* element = toElement(node()); 93 Element* element = toElement(node());
94 94
95 if (element && element->isFrameOwnerElement()) 95 if (element && element->isFrameOwnerElement())
96 return toHTMLFrameOwnerElement(element)->ownedWidget(); 96 return toHTMLFrameOwnerElement(element)->ownedWidget();
97 97
98 return nullptr; 98 return nullptr;
99 } 99 }
100 100
101 PaintLayerType LayoutPart::layerTypeRequired() const { 101 PaintLayerType LayoutPart::layerTypeRequired() const {
102 PaintLayerType type = LayoutReplaced::layerTypeRequired(); 102 PaintLayerType type = LayoutReplaced::layerTypeRequired();
103 if (type != NoPaintLayer) 103 if (type != NoPaintLayer)
104 return type; 104 return type;
105 return ForcedPaintLayer; 105 return ForcedPaintLayer;
106 } 106 }
107 107
108 bool LayoutPart::requiresAcceleratedCompositing() const { 108 bool LayoutPart::requiresAcceleratedCompositing() const {
109 // There are two general cases in which we can return true. First, if this is 109 // There are two general cases in which we can return true. First, if this is
110 // a plugin LayoutObject and the plugin has a layer, then we need a layer. 110 // a plugin LayoutObject and the plugin has a layer, then we need a layer.
111 // Second, if this is a LayoutObject with a contentDocument and that document 111 // Second, if this is a LayoutObject with a contentDocument and that document
112 // needs a layer, then we need a layer. 112 // needs a layer, then we need a layer.
113 if (widget() && widget()->isPluginView() && 113 if (frameViewBase() && frameViewBase()->isPluginView() &&
114 toPluginView(widget())->platformLayer()) 114 toPluginView(frameViewBase())->platformLayer())
115 return true; 115 return true;
116 116
117 if (!node() || !node()->isFrameOwnerElement()) 117 if (!node() || !node()->isFrameOwnerElement())
118 return false; 118 return false;
119 119
120 HTMLFrameOwnerElement* element = toHTMLFrameOwnerElement(node()); 120 HTMLFrameOwnerElement* element = toHTMLFrameOwnerElement(node());
121 if (element->contentFrame() && element->contentFrame()->isRemoteFrame()) 121 if (element->contentFrame() && element->contentFrame()->isRemoteFrame())
122 return true; 122 return true;
123 123
124 if (Document* contentDocument = element->contentDocument()) { 124 if (Document* contentDocument = element->contentDocument()) {
(...skipping 25 matching lines...) Expand all
150 if ((inside || result.isRectBasedTest()) && !hadResult && 150 if ((inside || result.isRectBasedTest()) && !hadResult &&
151 result.innerNode() == node()) 151 result.innerNode() == node())
152 result.setIsOverWidget(contentBoxRect().contains(result.localPoint())); 152 result.setIsOverWidget(contentBoxRect().contains(result.localPoint()));
153 return inside; 153 return inside;
154 } 154 }
155 155
156 bool LayoutPart::nodeAtPoint(HitTestResult& result, 156 bool LayoutPart::nodeAtPoint(HitTestResult& result,
157 const HitTestLocation& locationInContainer, 157 const HitTestLocation& locationInContainer,
158 const LayoutPoint& accumulatedOffset, 158 const LayoutPoint& accumulatedOffset,
159 HitTestAction action) { 159 HitTestAction action) {
160 if (!widget() || !widget()->isFrameView() || 160 if (!frameViewBase() || !frameViewBase()->isFrameView() ||
161 !result.hitTestRequest().allowsChildFrameContent()) 161 !result.hitTestRequest().allowsChildFrameContent())
162 return nodeAtPointOverWidget(result, locationInContainer, accumulatedOffset, 162 return nodeAtPointOverWidget(result, locationInContainer, accumulatedOffset,
163 action); 163 action);
164 164
165 // A hit test can never hit an off-screen element; only off-screen iframes are 165 // A hit test can never hit an off-screen element; only off-screen iframes are
166 // throttled; therefore, hit tests can skip descending into throttled iframes. 166 // throttled; therefore, hit tests can skip descending into throttled iframes.
167 if (toFrameView(widget())->shouldThrottleRendering()) 167 if (toFrameView(frameViewBase())->shouldThrottleRendering())
168 return nodeAtPointOverWidget(result, locationInContainer, accumulatedOffset, 168 return nodeAtPointOverWidget(result, locationInContainer, accumulatedOffset,
169 action); 169 action);
170 170
171 ASSERT(document().lifecycle().state() >= DocumentLifecycle::CompositingClean); 171 ASSERT(document().lifecycle().state() >= DocumentLifecycle::CompositingClean);
172 172
173 if (action == HitTestForeground) { 173 if (action == HitTestForeground) {
174 FrameView* childFrameView = toFrameView(widget()); 174 FrameView* childFrameView = toFrameView(frameViewBase());
175 LayoutViewItem childRootItem = childFrameView->layoutViewItem(); 175 LayoutViewItem childRootItem = childFrameView->layoutViewItem();
176 176
177 if (visibleToHitTestRequest(result.hitTestRequest()) && 177 if (visibleToHitTestRequest(result.hitTestRequest()) &&
178 !childRootItem.isNull()) { 178 !childRootItem.isNull()) {
179 LayoutPoint adjustedLocation = accumulatedOffset + location(); 179 LayoutPoint adjustedLocation = accumulatedOffset + location();
180 LayoutPoint contentOffset = LayoutPoint(borderLeft() + paddingLeft(), 180 LayoutPoint contentOffset = LayoutPoint(borderLeft() + paddingLeft(),
181 borderTop() + paddingTop()) - 181 borderTop() + paddingTop()) -
182 LayoutSize(childFrameView->scrollOffsetInt()); 182 LayoutSize(childFrameView->scrollOffsetInt());
183 HitTestLocation newHitTestLocation(locationInContainer, 183 HitTestLocation newHitTestLocation(locationInContainer,
184 -adjustedLocation - contentOffset); 184 -adjustedLocation - contentOffset);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 CompositingReasons LayoutPart::additionalCompositingReasons() const { 228 CompositingReasons LayoutPart::additionalCompositingReasons() const {
229 if (requiresAcceleratedCompositing()) 229 if (requiresAcceleratedCompositing())
230 return CompositingReasonIFrame; 230 return CompositingReasonIFrame;
231 return CompositingReasonNone; 231 return CompositingReasonNone;
232 } 232 }
233 233
234 void LayoutPart::styleDidChange(StyleDifference diff, 234 void LayoutPart::styleDidChange(StyleDifference diff,
235 const ComputedStyle* oldStyle) { 235 const ComputedStyle* oldStyle) {
236 LayoutReplaced::styleDidChange(diff, oldStyle); 236 LayoutReplaced::styleDidChange(diff, oldStyle);
237 FrameViewBase* frameViewBase = this->widget(); 237 FrameViewBase* frameViewBase = this->frameViewBase();
238 238
239 if (!frameViewBase) 239 if (!frameViewBase)
240 return; 240 return;
241 241
242 // If the iframe has custom scrollbars, recalculate their style. 242 // If the iframe has custom scrollbars, recalculate their style.
243 if (frameViewBase && frameViewBase->isFrameView()) 243 if (frameViewBase && frameViewBase->isFrameView())
244 toFrameView(frameViewBase)->recalculateCustomScrollbarStyle(); 244 toFrameView(frameViewBase)->recalculateCustomScrollbarStyle();
245 245
246 if (style()->visibility() != EVisibility::kVisible) { 246 if (style()->visibility() != EVisibility::kVisible) {
247 frameViewBase->hide(); 247 frameViewBase->hide();
(...skipping 13 matching lines...) Expand all
261 PartPainter(*this).paint(paintInfo, paintOffset); 261 PartPainter(*this).paint(paintInfo, paintOffset);
262 } 262 }
263 263
264 void LayoutPart::paintContents(const PaintInfo& paintInfo, 264 void LayoutPart::paintContents(const PaintInfo& paintInfo,
265 const LayoutPoint& paintOffset) const { 265 const LayoutPoint& paintOffset) const {
266 PartPainter(*this).paintContents(paintInfo, paintOffset); 266 PartPainter(*this).paintContents(paintInfo, paintOffset);
267 } 267 }
268 268
269 CursorDirective LayoutPart::getCursor(const LayoutPoint& point, 269 CursorDirective LayoutPart::getCursor(const LayoutPoint& point,
270 Cursor& cursor) const { 270 Cursor& cursor) const {
271 if (widget() && widget()->isPluginView()) { 271 if (frameViewBase() && frameViewBase()->isPluginView()) {
272 // A plugin is responsible for setting the cursor when the pointer is over 272 // A plugin is responsible for setting the cursor when the pointer is over
273 // it. 273 // it.
274 return DoNotSetCursor; 274 return DoNotSetCursor;
275 } 275 }
276 return LayoutReplaced::getCursor(point, cursor); 276 return LayoutReplaced::getCursor(point, cursor);
277 } 277 }
278 278
279 LayoutRect LayoutPart::replacedContentRect() const { 279 LayoutRect LayoutPart::replacedContentRect() const {
280 // We don't propagate sub-pixel into sub-frame layout, in other words, the 280 // We don't propagate sub-pixel into sub-frame layout, in other words, the
281 // rect is snapped at the document boundary, and sub-pixel movement could 281 // rect is snapped at the document boundary, and sub-pixel movement could
282 // cause the sub-frame to layout due to the 1px snap difference. In order to 282 // cause the sub-frame to layout due to the 1px snap difference. In order to
283 // avoid that, the size of sub-frame is rounded in advance. 283 // avoid that, the size of sub-frame is rounded in advance.
284 LayoutRect sizeRoundedRect = contentBoxRect(); 284 LayoutRect sizeRoundedRect = contentBoxRect();
285 sizeRoundedRect.setSize(LayoutSize(roundedIntSize(sizeRoundedRect.size()))); 285 sizeRoundedRect.setSize(LayoutSize(roundedIntSize(sizeRoundedRect.size())));
286 return sizeRoundedRect; 286 return sizeRoundedRect;
287 } 287 }
288 288
289 void LayoutPart::updateOnWidgetChange() { 289 void LayoutPart::updateOnWidgetChange() {
290 FrameViewBase* frameViewBase = this->widget(); 290 FrameViewBase* frameViewBase = this->frameViewBase();
291 if (!frameViewBase) 291 if (!frameViewBase)
292 return; 292 return;
293 293
294 if (!style()) 294 if (!style())
295 return; 295 return;
296 296
297 if (!needsLayout()) 297 if (!needsLayout())
298 updateGeometryInternal(); 298 updateGeometryInternal();
299 299
300 if (style()->visibility() != EVisibility::kVisible) { 300 if (style()->visibility() != EVisibility::kVisible) {
301 frameViewBase->hide(); 301 frameViewBase->hide();
302 } else { 302 } else {
303 frameViewBase->show(); 303 frameViewBase->show();
304 // FIXME: Why do we issue a full paint invalidation in this case, but not 304 // FIXME: Why do we issue a full paint invalidation in this case, but not
305 // the other? 305 // the other?
306 setShouldDoFullPaintInvalidation(); 306 setShouldDoFullPaintInvalidation();
307 } 307 }
308 } 308 }
309 309
310 void LayoutPart::updateGeometry() { 310 void LayoutPart::updateGeometry() {
311 FrameViewBase* frameViewBase = this->widget(); 311 FrameViewBase* frameViewBase = this->frameViewBase();
312 if (!frameViewBase || 312 if (!frameViewBase ||
313 !node()) // Check the node in case destroy() has been called. 313 !node()) // Check the node in case destroy() has been called.
314 return; 314 return;
315 315
316 LayoutRect newFrame = replacedContentRect(); 316 LayoutRect newFrame = replacedContentRect();
317 DCHECK(newFrame.size() == roundedIntSize(newFrame.size())); 317 DCHECK(newFrame.size() == roundedIntSize(newFrame.size()));
318 bool boundsWillChange = 318 bool boundsWillChange =
319 LayoutSize(frameViewBase->frameRect().size()) != newFrame.size(); 319 LayoutSize(frameViewBase->frameRect().size()) != newFrame.size();
320 320
321 FrameView* frameView = 321 FrameView* frameView =
(...skipping 12 matching lines...) Expand all
334 // If view needs layout, either because bounds have changed or possibly 334 // If view needs layout, either because bounds have changed or possibly
335 // indicating content size is wrong, we have to do a layout to set the right 335 // indicating content size is wrong, we have to do a layout to set the right
336 // FrameViewBase size. 336 // FrameViewBase size.
337 if (frameView && frameView->needsLayout() && frameView->frame().page()) 337 if (frameView && frameView->needsLayout() && frameView->frame().page())
338 frameView->layout(); 338 frameView->layout();
339 339
340 frameViewBase->geometryMayHaveChanged(); 340 frameViewBase->geometryMayHaveChanged();
341 } 341 }
342 342
343 void LayoutPart::updateGeometryInternal() { 343 void LayoutPart::updateGeometryInternal() {
344 FrameViewBase* frameViewBase = this->widget(); 344 FrameViewBase* frameViewBase = this->frameViewBase();
345 DCHECK(frameViewBase); 345 DCHECK(frameViewBase);
346 346
347 // Ignore transform here, as we only care about the sub-pixel accumulation. 347 // Ignore transform here, as we only care about the sub-pixel accumulation.
348 // TODO(trchen): What about multicol? Need a LayoutBox function to query 348 // TODO(trchen): What about multicol? Need a LayoutBox function to query
349 // sub-pixel accumulation. 349 // sub-pixel accumulation.
350 LayoutPoint absoluteLocation(localToAbsolute(FloatPoint())); 350 LayoutPoint absoluteLocation(localToAbsolute(FloatPoint()));
351 LayoutRect absoluteReplacedRect = replacedContentRect(); 351 LayoutRect absoluteReplacedRect = replacedContentRect();
352 absoluteReplacedRect.moveBy(absoluteLocation); 352 absoluteReplacedRect.moveBy(absoluteLocation);
353 353
354 IntRect frameRect(IntPoint(), 354 IntRect frameRect(IntPoint(),
(...skipping 11 matching lines...) Expand all
366 localToAbsoluteQuad(FloatRect(replacedContentRect())).boundingBox(); 366 localToAbsoluteQuad(FloatRect(replacedContentRect())).boundingBox();
367 frameRect.setLocation(roundedIntPoint(absoluteBoundingBox.location())); 367 frameRect.setLocation(roundedIntPoint(absoluteBoundingBox.location()));
368 368
369 // Why is the protector needed? 369 // Why is the protector needed?
370 RefPtr<LayoutPart> protector(this); 370 RefPtr<LayoutPart> protector(this);
371 frameViewBase->setFrameRect(frameRect); 371 frameViewBase->setFrameRect(frameRect);
372 } 372 }
373 373
374 void LayoutPart::invalidatePaintOfSubtreesIfNeeded( 374 void LayoutPart::invalidatePaintOfSubtreesIfNeeded(
375 const PaintInvalidationState& paintInvalidationState) { 375 const PaintInvalidationState& paintInvalidationState) {
376 if (widget() && widget()->isFrameView() && !isThrottledFrameView()) { 376 if (frameViewBase() && frameViewBase()->isFrameView() &&
377 FrameView* childFrameView = toFrameView(widget()); 377 !isThrottledFrameView()) {
378 FrameView* childFrameView = toFrameView(frameViewBase());
378 // |childFrameView| is in another document, which could be 379 // |childFrameView| is in another document, which could be
379 // missing its LayoutView. TODO(jchaffraix): Ideally we should 380 // missing its LayoutView. TODO(jchaffraix): Ideally we should
380 // not need this code. 381 // not need this code.
381 if (LayoutView* childLayoutView = 382 if (LayoutView* childLayoutView =
382 toLayoutView(LayoutAPIShim::layoutObjectFrom( 383 toLayoutView(LayoutAPIShim::layoutObjectFrom(
383 childFrameView->layoutViewItem()))) { 384 childFrameView->layoutViewItem()))) {
384 PaintInvalidationState childViewPaintInvalidationState( 385 PaintInvalidationState childViewPaintInvalidationState(
385 paintInvalidationState, *childLayoutView); 386 paintInvalidationState, *childLayoutView);
386 childFrameView->invalidateTreeIfNeeded(childViewPaintInvalidationState); 387 childFrameView->invalidateTreeIfNeeded(childViewPaintInvalidationState);
387 } 388 }
388 } 389 }
389 390
390 LayoutReplaced::invalidatePaintOfSubtreesIfNeeded(paintInvalidationState); 391 LayoutReplaced::invalidatePaintOfSubtreesIfNeeded(paintInvalidationState);
391 } 392 }
392 393
393 bool LayoutPart::isThrottledFrameView() const { 394 bool LayoutPart::isThrottledFrameView() const {
394 if (!widget() || !widget()->isFrameView()) 395 if (!frameViewBase() || !frameViewBase()->isFrameView())
395 return false; 396 return false;
396 const FrameView* frameView = toFrameView(widget()); 397 const FrameView* frameView = toFrameView(frameViewBase());
397 return frameView->shouldThrottleRendering(); 398 return frameView->shouldThrottleRendering();
398 } 399 }
399 400
400 } // namespace blink 401 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutPart.h ('k') | third_party/WebKit/Source/core/layout/LayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698