OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
4 * All rights reserved. | 4 * All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "core/layout/LayoutView.h" | 22 #include "core/layout/LayoutView.h" |
23 | 23 |
| 24 #include <inttypes.h> |
24 #include "core/dom/Document.h" | 25 #include "core/dom/Document.h" |
25 #include "core/dom/Element.h" | 26 #include "core/dom/Element.h" |
26 #include "core/editing/FrameSelection.h" | 27 #include "core/editing/FrameSelection.h" |
27 #include "core/frame/FrameView.h" | 28 #include "core/frame/FrameView.h" |
28 #include "core/frame/LocalFrame.h" | 29 #include "core/frame/LocalFrame.h" |
29 #include "core/frame/Settings.h" | 30 #include "core/frame/Settings.h" |
30 #include "core/html/HTMLIFrameElement.h" | 31 #include "core/html/HTMLIFrameElement.h" |
31 #include "core/layout/HitTestResult.h" | 32 #include "core/layout/HitTestResult.h" |
32 #include "core/layout/LayoutGeometryMap.h" | 33 #include "core/layout/LayoutGeometryMap.h" |
33 #include "core/layout/LayoutPart.h" | 34 #include "core/layout/LayoutPart.h" |
34 #include "core/layout/ViewFragmentationContext.h" | 35 #include "core/layout/ViewFragmentationContext.h" |
35 #include "core/layout/api/LayoutAPIShim.h" | 36 #include "core/layout/api/LayoutAPIShim.h" |
36 #include "core/layout/api/LayoutPartItem.h" | 37 #include "core/layout/api/LayoutPartItem.h" |
37 #include "core/layout/api/LayoutViewItem.h" | 38 #include "core/layout/api/LayoutViewItem.h" |
38 #include "core/layout/compositing/PaintLayerCompositor.h" | 39 #include "core/layout/compositing/PaintLayerCompositor.h" |
39 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
40 #include "core/paint/PaintLayer.h" | 41 #include "core/paint/PaintLayer.h" |
| 42 #include "core/paint/ViewPaintInvalidator.h" |
41 #include "core/paint/ViewPainter.h" | 43 #include "core/paint/ViewPainter.h" |
42 #include "core/svg/SVGDocumentExtensions.h" | 44 #include "core/svg/SVGDocumentExtensions.h" |
43 #include "platform/Histogram.h" | 45 #include "platform/Histogram.h" |
44 #include "platform/geometry/FloatQuad.h" | 46 #include "platform/geometry/FloatQuad.h" |
45 #include "platform/geometry/TransformState.h" | 47 #include "platform/geometry/TransformState.h" |
46 #include "platform/graphics/paint/PaintController.h" | 48 #include "platform/graphics/paint/PaintController.h" |
47 #include "platform/instrumentation/tracing/TraceEvent.h" | 49 #include "platform/instrumentation/tracing/TraceEvent.h" |
48 #include "platform/instrumentation/tracing/TracedValue.h" | 50 #include "platform/instrumentation/tracing/TracedValue.h" |
49 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
50 #include "wtf/PtrUtil.h" | 52 #include "wtf/PtrUtil.h" |
51 #include <inttypes.h> | |
52 | 53 |
53 namespace blink { | 54 namespace blink { |
54 | 55 |
55 namespace { | 56 namespace { |
56 | 57 |
57 class HitTestLatencyRecorder { | 58 class HitTestLatencyRecorder { |
58 public: | 59 public: |
59 HitTestLatencyRecorder(bool allowsChildFrameContent) | 60 HitTestLatencyRecorder(bool allowsChildFrameContent) |
60 : m_start(WTF::monotonicallyIncreasingTime()), | 61 : m_start(WTF::monotonicallyIncreasingTime()), |
61 m_allowsChildFrameContent(allowsChildFrameContent) {} | 62 m_allowsChildFrameContent(allowsChildFrameContent) {} |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 (heightChanged && mustInvalidateFillLayersPaintOnHeightChange( | 220 (heightChanged && mustInvalidateFillLayersPaintOnHeightChange( |
220 style()->backgroundLayers()))) | 221 style()->backgroundLayers()))) |
221 setShouldDoFullPaintInvalidation(PaintInvalidationBoundsChange); | 222 setShouldDoFullPaintInvalidation(PaintInvalidationBoundsChange); |
222 } | 223 } |
223 } | 224 } |
224 | 225 |
225 void LayoutView::layout() { | 226 void LayoutView::layout() { |
226 if (!document().paginated()) | 227 if (!document().paginated()) |
227 setPageLogicalHeight(LayoutUnit()); | 228 setPageLogicalHeight(LayoutUnit()); |
228 | 229 |
| 230 // TODO(wangxianzhu): Move this into ViewPaintInvalidator when |
| 231 // rootLayerScrolling is permanently enabled. |
229 IncludeScrollbarsInRect includeScrollbars = | 232 IncludeScrollbarsInRect includeScrollbars = |
230 RuntimeEnabledFeatures::rootLayerScrollingEnabled() ? IncludeScrollbars | 233 RuntimeEnabledFeatures::rootLayerScrollingEnabled() ? IncludeScrollbars |
231 : ExcludeScrollbars; | 234 : ExcludeScrollbars; |
232 setShouldDoFullPaintInvalidationOnResizeIfNeeded( | 235 setShouldDoFullPaintInvalidationOnResizeIfNeeded( |
233 offsetWidth() != layoutSize(includeScrollbars).width(), | 236 offsetWidth() != layoutSize(includeScrollbars).width(), |
234 offsetHeight() != layoutSize(includeScrollbars).height()); | 237 offsetHeight() != layoutSize(includeScrollbars).height()); |
235 | 238 |
236 if (pageLogicalHeight() && shouldUsePrintingLayout()) { | 239 if (pageLogicalHeight() && shouldUsePrintingLayout()) { |
237 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth(); | 240 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth(); |
238 if (!m_fragmentationContext) { | 241 if (!m_fragmentationContext) { |
239 m_fragmentationContext = | 242 m_fragmentationContext = |
240 WTF::wrapUnique(new ViewFragmentationContext(*this)); | 243 WTF::wrapUnique(new ViewFragmentationContext(*this)); |
241 m_paginationStateChanged = true; | 244 m_paginationStateChanged = true; |
242 } | 245 } |
243 } else if (m_fragmentationContext) { | 246 } else if (m_fragmentationContext) { |
244 m_fragmentationContext.reset(); | 247 m_fragmentationContext.reset(); |
245 m_paginationStateChanged = true; | 248 m_paginationStateChanged = true; |
246 } | 249 } |
247 | 250 |
248 SubtreeLayoutScope layoutScope(*this); | 251 SubtreeLayoutScope layoutScope(*this); |
249 | 252 |
250 LayoutRect oldLayoutOverflowRect = layoutOverflowRect(); | |
251 | |
252 // Use calcWidth/Height to get the new width/height, since this will take the | 253 // Use calcWidth/Height to get the new width/height, since this will take the |
253 // full page zoom factor into account. | 254 // full page zoom factor into account. |
254 bool relayoutChildren = | 255 bool relayoutChildren = |
255 !shouldUsePrintingLayout() && | 256 !shouldUsePrintingLayout() && |
256 (!m_frameView || logicalWidth() != viewLogicalWidthForBoxSizing() || | 257 (!m_frameView || logicalWidth() != viewLogicalWidthForBoxSizing() || |
257 logicalHeight() != viewLogicalHeightForBoxSizing()); | 258 logicalHeight() != viewLogicalHeightForBoxSizing()); |
258 if (relayoutChildren) { | 259 if (relayoutChildren) { |
259 layoutScope.setChildNeedsLayout(this); | 260 layoutScope.setChildNeedsLayout(this); |
260 for (LayoutObject* child = firstChild(); child; | 261 for (LayoutObject* child = firstChild(); child; |
261 child = child->nextSibling()) { | 262 child = child->nextSibling()) { |
(...skipping 14 matching lines...) Expand all Loading... |
276 } | 277 } |
277 | 278 |
278 ASSERT(!m_layoutState); | 279 ASSERT(!m_layoutState); |
279 if (!needsLayout()) | 280 if (!needsLayout()) |
280 return; | 281 return; |
281 | 282 |
282 LayoutState rootLayoutState(*this); | 283 LayoutState rootLayoutState(*this); |
283 | 284 |
284 layoutContent(); | 285 layoutContent(); |
285 | 286 |
286 if (layoutOverflowRect() != oldLayoutOverflowRect) { | |
287 // The document element paints the viewport background, so we need to | |
288 // invalidate it when layout overflow changes. | |
289 // FIXME: Improve viewport background styling/invalidation/painting. | |
290 // crbug.com/475115 | |
291 if (Element* documentElement = document().documentElement()) { | |
292 if (LayoutObject* rootObject = documentElement->layoutObject()) | |
293 rootObject->setShouldDoFullPaintInvalidation(); | |
294 } | |
295 } | |
296 | |
297 #if DCHECK_IS_ON() | 287 #if DCHECK_IS_ON() |
298 checkLayoutState(); | 288 checkLayoutState(); |
299 #endif | 289 #endif |
300 clearNeedsLayout(); | 290 clearNeedsLayout(); |
301 } | 291 } |
302 | 292 |
303 LayoutRect LayoutView::visualOverflowRect() const { | 293 LayoutRect LayoutView::visualOverflowRect() const { |
304 // In root layer scrolling mode, the LayoutView performs overflow clipping | 294 // In root layer scrolling mode, the LayoutView performs overflow clipping |
305 // like a regular scrollable div. | 295 // like a regular scrollable div. |
306 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 296 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 void LayoutView::computeSelfHitTestRects(Vector<LayoutRect>& rects, | 408 void LayoutView::computeSelfHitTestRects(Vector<LayoutRect>& rects, |
419 const LayoutPoint&) const { | 409 const LayoutPoint&) const { |
420 // Record the entire size of the contents of the frame. Note that we don't | 410 // Record the entire size of the contents of the frame. Note that we don't |
421 // just use the viewport size (containing block) here because we want to | 411 // just use the viewport size (containing block) here because we want to |
422 // ensure this includes all children (so we can avoid walking them | 412 // ensure this includes all children (so we can avoid walking them |
423 // explicitly). | 413 // explicitly). |
424 rects.push_back( | 414 rects.push_back( |
425 LayoutRect(LayoutPoint::zero(), LayoutSize(frameView()->contentsSize()))); | 415 LayoutRect(LayoutPoint::zero(), LayoutSize(frameView()->contentsSize()))); |
426 } | 416 } |
427 | 417 |
| 418 PaintInvalidationReason LayoutView::invalidatePaintIfNeeded( |
| 419 const PaintInvalidationState& paintInvalidationState) { |
| 420 return LayoutBlockFlow::invalidatePaintIfNeeded(paintInvalidationState); |
| 421 } |
| 422 |
| 423 PaintInvalidationReason LayoutView::invalidatePaintIfNeeded( |
| 424 const PaintInvalidatorContext& context) const { |
| 425 return ViewPaintInvalidator(*this, context).invalidatePaintIfNeeded(); |
| 426 } |
| 427 |
428 void LayoutView::paint(const PaintInfo& paintInfo, | 428 void LayoutView::paint(const PaintInfo& paintInfo, |
429 const LayoutPoint& paintOffset) const { | 429 const LayoutPoint& paintOffset) const { |
430 ViewPainter(*this).paint(paintInfo, paintOffset); | 430 ViewPainter(*this).paint(paintInfo, paintOffset); |
431 } | 431 } |
432 | 432 |
433 void LayoutView::paintBoxDecorationBackground(const PaintInfo& paintInfo, | 433 void LayoutView::paintBoxDecorationBackground(const PaintInfo& paintInfo, |
434 const LayoutPoint&) const { | 434 const LayoutPoint&) const { |
435 ViewPainter(*this).paintBoxDecorationBackground(paintInfo); | 435 ViewPainter(*this).paintBoxDecorationBackground(paintInfo); |
436 } | 436 } |
437 | 437 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 bool LayoutView::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { | 1049 bool LayoutView::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { |
1050 // Frame scroll corner is painted using LayoutView as the display item client. | 1050 // Frame scroll corner is painted using LayoutView as the display item client. |
1051 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 1051 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
1052 (frameView()->horizontalScrollbar() || frameView()->verticalScrollbar())) | 1052 (frameView()->horizontalScrollbar() || frameView()->verticalScrollbar())) |
1053 return false; | 1053 return false; |
1054 | 1054 |
1055 return LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 1055 return LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
1056 } | 1056 } |
1057 | 1057 |
1058 } // namespace blink | 1058 } // namespace blink |
OLD | NEW |