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

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

Issue 2723993002: Rename platform/Widget to platform/FrameViewBase in core. (Closed)
Patch Set: 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 23 matching lines...) Expand all
34 #include "core/layout/api/LayoutAPIShim.h" 34 #include "core/layout/api/LayoutAPIShim.h"
35 #include "core/layout/api/LayoutViewItem.h" 35 #include "core/layout/api/LayoutViewItem.h"
36 #include "core/paint/PartPainter.h" 36 #include "core/paint/PartPainter.h"
37 #include "core/plugins/PluginView.h" 37 #include "core/plugins/PluginView.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 LayoutPart::LayoutPart(Element* element) 41 LayoutPart::LayoutPart(Element* element)
42 : LayoutReplaced(element), 42 : LayoutReplaced(element),
43 // Reference counting is used to prevent the part from being destroyed 43 // Reference counting is used to prevent the part from being destroyed
44 // while inside the Widget code, which might not be able to handle that. 44 // while inside the FrameViewBase code, which might not be able to handle
45 // that.
45 m_refCount(1) { 46 m_refCount(1) {
46 ASSERT(element); 47 ASSERT(element);
47 frameView()->addPart(this); 48 frameView()->addPart(this);
48 setInline(false); 49 setInline(false);
49 } 50 }
50 51
51 void LayoutPart::deref() { 52 void LayoutPart::deref() {
52 if (--m_refCount <= 0) 53 if (--m_refCount <= 0)
53 delete this; 54 delete this;
54 } 55 }
(...skipping 25 matching lines...) Expand all
80 // 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
81 // we don't access it in the future. 82 // we don't access it in the future.
82 clearNode(); 83 clearNode();
83 deref(); 84 deref();
84 } 85 }
85 86
86 LayoutPart::~LayoutPart() { 87 LayoutPart::~LayoutPart() {
87 ASSERT(m_refCount <= 0); 88 ASSERT(m_refCount <= 0);
88 } 89 }
89 90
90 Widget* LayoutPart::widget() const { 91 FrameViewBase* LayoutPart::widget() const {
91 // Plugin widgets are stored in their DOM node. 92 // Plugin FrameViewBases are stored in their DOM node.
92 Element* element = toElement(node()); 93 Element* element = toElement(node());
93 94
94 if (element && element->isFrameOwnerElement()) 95 if (element && element->isFrameOwnerElement())
95 return toHTMLFrameOwnerElement(element)->ownedWidget(); 96 return toHTMLFrameOwnerElement(element)->ownedWidget();
96 97
97 return nullptr; 98 return nullptr;
98 } 99 }
99 100
100 PaintLayerType LayoutPart::layerTypeRequired() const { 101 PaintLayerType LayoutPart::layerTypeRequired() const {
101 PaintLayerType type = LayoutReplaced::layerTypeRequired(); 102 PaintLayerType type = LayoutReplaced::layerTypeRequired();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 bool LayoutPart::nodeAtPointOverWidget( 139 bool LayoutPart::nodeAtPointOverWidget(
139 HitTestResult& result, 140 HitTestResult& result,
140 const HitTestLocation& locationInContainer, 141 const HitTestLocation& locationInContainer,
141 const LayoutPoint& accumulatedOffset, 142 const LayoutPoint& accumulatedOffset,
142 HitTestAction action) { 143 HitTestAction action) {
143 bool hadResult = result.innerNode(); 144 bool hadResult = result.innerNode();
144 bool inside = LayoutReplaced::nodeAtPoint(result, locationInContainer, 145 bool inside = LayoutReplaced::nodeAtPoint(result, locationInContainer,
145 accumulatedOffset, action); 146 accumulatedOffset, action);
146 147
147 // Check to see if we are really over the widget itself (and not just in the 148 // Check to see if we are really over the FrameViewBase itself (and not just
148 // border/padding area). 149 // in the border/padding area).
149 if ((inside || result.isRectBasedTest()) && !hadResult && 150 if ((inside || result.isRectBasedTest()) && !hadResult &&
150 result.innerNode() == node()) 151 result.innerNode() == node())
151 result.setIsOverWidget(contentBoxRect().contains(result.localPoint())); 152 result.setIsOverWidget(contentBoxRect().contains(result.localPoint()));
152 return inside; 153 return inside;
153 } 154 }
154 155
155 bool LayoutPart::nodeAtPoint(HitTestResult& result, 156 bool LayoutPart::nodeAtPoint(HitTestResult& result,
156 const HitTestLocation& locationInContainer, 157 const HitTestLocation& locationInContainer,
157 const LayoutPoint& accumulatedOffset, 158 const LayoutPoint& accumulatedOffset,
158 HitTestAction action) { 159 HitTestAction action) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 227
227 CompositingReasons LayoutPart::additionalCompositingReasons() const { 228 CompositingReasons LayoutPart::additionalCompositingReasons() const {
228 if (requiresAcceleratedCompositing()) 229 if (requiresAcceleratedCompositing())
229 return CompositingReasonIFrame; 230 return CompositingReasonIFrame;
230 return CompositingReasonNone; 231 return CompositingReasonNone;
231 } 232 }
232 233
233 void LayoutPart::styleDidChange(StyleDifference diff, 234 void LayoutPart::styleDidChange(StyleDifference diff,
234 const ComputedStyle* oldStyle) { 235 const ComputedStyle* oldStyle) {
235 LayoutReplaced::styleDidChange(diff, oldStyle); 236 LayoutReplaced::styleDidChange(diff, oldStyle);
236 Widget* widget = this->widget(); 237 FrameViewBase* frameViewBase = this->widget();
237 238
238 if (!widget) 239 if (!frameViewBase)
239 return; 240 return;
240 241
241 // If the iframe has custom scrollbars, recalculate their style. 242 // If the iframe has custom scrollbars, recalculate their style.
242 if (widget && widget->isFrameView()) 243 if (frameViewBase && frameViewBase->isFrameView())
243 toFrameView(widget)->recalculateCustomScrollbarStyle(); 244 toFrameView(frameViewBase)->recalculateCustomScrollbarStyle();
244 245
245 if (style()->visibility() != EVisibility::kVisible) { 246 if (style()->visibility() != EVisibility::kVisible) {
246 widget->hide(); 247 frameViewBase->hide();
247 } else { 248 } else {
248 widget->show(); 249 frameViewBase->show();
249 } 250 }
250 } 251 }
251 252
252 void LayoutPart::layout() { 253 void LayoutPart::layout() {
253 ASSERT(needsLayout()); 254 ASSERT(needsLayout());
254 LayoutAnalyzer::Scope analyzer(*this); 255 LayoutAnalyzer::Scope analyzer(*this);
255 clearNeedsLayout(); 256 clearNeedsLayout();
256 } 257 }
257 258
258 void LayoutPart::paint(const PaintInfo& paintInfo, 259 void LayoutPart::paint(const PaintInfo& paintInfo,
(...skipping 20 matching lines...) Expand all
279 // 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
280 // 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
281 // 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
282 // avoid that, the size of sub-frame is rounded in advance. 283 // avoid that, the size of sub-frame is rounded in advance.
283 LayoutRect sizeRoundedRect = contentBoxRect(); 284 LayoutRect sizeRoundedRect = contentBoxRect();
284 sizeRoundedRect.setSize(LayoutSize(roundedIntSize(sizeRoundedRect.size()))); 285 sizeRoundedRect.setSize(LayoutSize(roundedIntSize(sizeRoundedRect.size())));
285 return sizeRoundedRect; 286 return sizeRoundedRect;
286 } 287 }
287 288
288 void LayoutPart::updateOnWidgetChange() { 289 void LayoutPart::updateOnWidgetChange() {
289 Widget* widget = this->widget(); 290 FrameViewBase* frameViewBase = this->widget();
290 if (!widget) 291 if (!frameViewBase)
291 return; 292 return;
292 293
293 if (!style()) 294 if (!style())
294 return; 295 return;
295 296
296 if (!needsLayout()) 297 if (!needsLayout())
297 updateWidgetGeometryInternal(); 298 updateWidgetGeometryInternal();
298 299
299 if (style()->visibility() != EVisibility::kVisible) { 300 if (style()->visibility() != EVisibility::kVisible) {
300 widget->hide(); 301 frameViewBase->hide();
301 } else { 302 } else {
302 widget->show(); 303 frameViewBase->show();
303 // 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
304 // the other? 305 // the other?
305 setShouldDoFullPaintInvalidation(); 306 setShouldDoFullPaintInvalidation();
306 } 307 }
307 } 308 }
308 309
309 void LayoutPart::updateWidgetGeometry() { 310 void LayoutPart::updateWidgetGeometry() {
310 Widget* widget = this->widget(); 311 FrameViewBase* frameViewBase = this->widget();
311 if (!widget || !node()) // Check the node in case destroy() has been called. 312 if (!frameViewBase ||
313 !node()) // Check the node in case destroy() has been called.
312 return; 314 return;
313 315
314 LayoutRect newFrame = replacedContentRect(); 316 LayoutRect newFrame = replacedContentRect();
315 DCHECK(newFrame.size() == roundedIntSize(newFrame.size())); 317 DCHECK(newFrame.size() == roundedIntSize(newFrame.size()));
316 bool boundsWillChange = 318 bool boundsWillChange =
317 LayoutSize(widget->frameRect().size()) != newFrame.size(); 319 LayoutSize(frameViewBase->frameRect().size()) != newFrame.size();
318 320
319 FrameView* frameView = widget->isFrameView() ? toFrameView(widget) : nullptr; 321 FrameView* frameView =
322 frameViewBase->isFrameView() ? toFrameView(frameViewBase) : nullptr;
320 323
321 // If frame bounds are changing mark the view for layout. Also check the 324 // If frame bounds are changing mark the view for layout. Also check the
322 // frame's page to make sure that the frame isn't in the process of being 325 // frame's page to make sure that the frame isn't in the process of being
323 // destroyed. If iframe scrollbars needs reconstruction from native to custom 326 // destroyed. If iframe scrollbars needs reconstruction from native to custom
324 // scrollbar, then also we need to layout the frameview. 327 // scrollbar, then also we need to layout the frameview.
325 if (frameView && frameView->frame().page() && 328 if (frameView && frameView->frame().page() &&
326 (boundsWillChange || frameView->needsScrollbarReconstruction())) 329 (boundsWillChange || frameView->needsScrollbarReconstruction()))
327 frameView->setNeedsLayout(); 330 frameView->setNeedsLayout();
328 331
329 updateWidgetGeometryInternal(); 332 updateWidgetGeometryInternal();
330 333
331 // If view needs layout, either because bounds have changed or possibly 334 // If view needs layout, either because bounds have changed or possibly
332 // 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
333 // widget size. 336 // FrameViewBase size.
334 if (frameView && frameView->needsLayout() && frameView->frame().page()) 337 if (frameView && frameView->needsLayout() && frameView->frame().page())
335 frameView->layout(); 338 frameView->layout();
336 339
337 widget->widgetGeometryMayHaveChanged(); 340 frameViewBase->widgetGeometryMayHaveChanged();
338 } 341 }
339 342
340 void LayoutPart::updateWidgetGeometryInternal() { 343 void LayoutPart::updateWidgetGeometryInternal() {
341 Widget* widget = this->widget(); 344 FrameViewBase* frameViewBase = this->widget();
342 ASSERT(widget); 345 DCHECK(frameViewBase);
343 346
344 // 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.
345 // TODO(trchen): What about multicol? Need a LayoutBox function to query 348 // TODO(trchen): What about multicol? Need a LayoutBox function to query
346 // sub-pixel accumulation. 349 // sub-pixel accumulation.
347 LayoutPoint absoluteLocation(localToAbsolute(FloatPoint())); 350 LayoutPoint absoluteLocation(localToAbsolute(FloatPoint()));
348 LayoutRect absoluteReplacedRect = replacedContentRect(); 351 LayoutRect absoluteReplacedRect = replacedContentRect();
349 absoluteReplacedRect.moveBy(absoluteLocation); 352 absoluteReplacedRect.moveBy(absoluteLocation);
350 353
351 IntRect frameRect(IntPoint(), 354 IntRect frameRect(IntPoint(),
352 pixelSnappedIntRect(absoluteReplacedRect).size()); 355 pixelSnappedIntRect(absoluteReplacedRect).size());
353 // Normally the location of the frame rect is ignored by the painter, but 356 // Normally the location of the frame rect is ignored by the painter, but
354 // currently it is still used by a family of coordinate conversion function in 357 // currently it is still used by a family of coordinate conversion function in
355 // Widget/FrameView. This is incorrect because coordinate conversion needs to 358 // FrameViewBase/FrameView. This is incorrect because coordinate conversion
356 // take transform and into account. 359 // needs to take transform and into account. A few callers still use the
357 // A few callers still use the family of conversion function, including but 360 // family of conversion function, including but not exhaustive:
358 // not exhaustive:
359 // FrameView::updateViewportIntersectionIfNeeded() 361 // FrameView::updateViewportIntersectionIfNeeded()
360 // RemoteFrameView::frameRectsChanged(). 362 // RemoteFrameView::frameRectsChanged().
361 // WebPluginContainerImpl::reportGeometry() 363 // WebPluginContainerImpl::reportGeometry()
362 // TODO(trchen): Remove this hack once we fixed all callers. 364 // TODO(trchen): Remove this hack once we fixed all callers.
363 FloatRect absoluteBoundingBox = 365 FloatRect absoluteBoundingBox =
364 localToAbsoluteQuad(FloatRect(replacedContentRect())).boundingBox(); 366 localToAbsoluteQuad(FloatRect(replacedContentRect())).boundingBox();
365 frameRect.setLocation(roundedIntPoint(absoluteBoundingBox.location())); 367 frameRect.setLocation(roundedIntPoint(absoluteBoundingBox.location()));
366 368
367 // Why is the protector needed? 369 // Why is the protector needed?
368 RefPtr<LayoutPart> protector(this); 370 RefPtr<LayoutPart> protector(this);
369 widget->setFrameRect(frameRect); 371 frameViewBase->setFrameRect(frameRect);
370 } 372 }
371 373
372 void LayoutPart::invalidatePaintOfSubtreesIfNeeded( 374 void LayoutPart::invalidatePaintOfSubtreesIfNeeded(
373 const PaintInvalidationState& paintInvalidationState) { 375 const PaintInvalidationState& paintInvalidationState) {
374 if (widget() && widget()->isFrameView() && !isThrottledFrameView()) { 376 if (widget() && widget()->isFrameView() && !isThrottledFrameView()) {
375 FrameView* childFrameView = toFrameView(widget()); 377 FrameView* childFrameView = toFrameView(widget());
376 // |childFrameView| is in another document, which could be 378 // |childFrameView| is in another document, which could be
377 // missing its LayoutView. TODO(jchaffraix): Ideally we should 379 // missing its LayoutView. TODO(jchaffraix): Ideally we should
378 // not need this code. 380 // not need this code.
379 if (LayoutView* childLayoutView = 381 if (LayoutView* childLayoutView =
380 toLayoutView(LayoutAPIShim::layoutObjectFrom( 382 toLayoutView(LayoutAPIShim::layoutObjectFrom(
381 childFrameView->layoutViewItem()))) { 383 childFrameView->layoutViewItem()))) {
382 PaintInvalidationState childViewPaintInvalidationState( 384 PaintInvalidationState childViewPaintInvalidationState(
383 paintInvalidationState, *childLayoutView); 385 paintInvalidationState, *childLayoutView);
384 childFrameView->invalidateTreeIfNeeded(childViewPaintInvalidationState); 386 childFrameView->invalidateTreeIfNeeded(childViewPaintInvalidationState);
385 } 387 }
386 } 388 }
387 389
388 LayoutReplaced::invalidatePaintOfSubtreesIfNeeded(paintInvalidationState); 390 LayoutReplaced::invalidatePaintOfSubtreesIfNeeded(paintInvalidationState);
389 } 391 }
390 392
391 bool LayoutPart::isThrottledFrameView() const { 393 bool LayoutPart::isThrottledFrameView() const {
392 if (!widget() || !widget()->isFrameView()) 394 if (!widget() || !widget()->isFrameView())
393 return false; 395 return false;
394 const FrameView* frameView = toFrameView(widget()); 396 const FrameView* frameView = toFrameView(widget());
395 return frameView->shouldThrottleRendering(); 397 return frameView->shouldThrottleRendering();
396 } 398 }
397 399
398 } // namespace blink 400 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutPart.h ('k') | third_party/WebKit/Source/core/layout/LayoutScrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698