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

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

Issue 2241833002: Pass MapCoordinatesFlags through SVGLayoutSupport::mapLocalToAncestor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 4 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/layout/svg/LayoutSVGBlock.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/PaintInvalidationState.h" 5 #include "core/layout/PaintInvalidationState.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/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutInline.h" 10 #include "core/layout/LayoutInline.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 , m_svgTransform(parentState.m_svgTransform) 73 , m_svgTransform(parentState.m_svgTransform)
74 , m_pendingDelayedPaintInvalidations(parentState.m_pendingDelayedPaintInvali dations) 74 , m_pendingDelayedPaintInvalidations(parentState.m_pendingDelayedPaintInvali dations)
75 , m_paintingLayer(currentObject.hasLayer() && toLayoutBoxModelObject(current Object).hasSelfPaintingLayer() ? *toLayoutBoxModelObject(currentObject).layer() : parentState.m_paintingLayer) 75 , m_paintingLayer(currentObject.hasLayer() && toLayoutBoxModelObject(current Object).hasSelfPaintingLayer() ? *toLayoutBoxModelObject(currentObject).layer() : parentState.m_paintingLayer)
76 #if ENABLE(ASSERT) 76 #if ENABLE(ASSERT)
77 , m_didUpdateForChildren(false) 77 , m_didUpdateForChildren(false)
78 #endif 78 #endif
79 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY 79 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY
80 , m_canCheckFastPathSlowPathEquality(parentState.m_canCheckFastPathSlowPathE quality) 80 , m_canCheckFastPathSlowPathEquality(parentState.m_canCheckFastPathSlowPathE quality)
81 #endif 81 #endif
82 { 82 {
83 ASSERT(&m_paintingLayer == currentObject.paintingLayer()); 83 DCHECK(&m_paintingLayer == currentObject.paintingLayer());
84 84
85 if (currentObject == parentState.m_currentObject) { 85 if (currentObject == parentState.m_currentObject) {
86 // Sometimes we create a new PaintInvalidationState from parentState on the same object 86 // Sometimes we create a new PaintInvalidationState from parentState on the same object
87 // (e.g. LayoutView, and the HorriblySlowRectMapping cases in LayoutBloc k::invalidatePaintOfSubtreesIfNeeded()). 87 // (e.g. LayoutView, and the HorriblySlowRectMapping cases in LayoutBloc k::invalidatePaintOfSubtreesIfNeeded()).
88 // TODO(wangxianzhu): Avoid this for RuntimeEnabledFeatures::slimmingPai ntInvalidationEnabled(). 88 // TODO(wangxianzhu): Avoid this for RuntimeEnabledFeatures::slimmingPai ntInvalidationEnabled().
89 #if ENABLE(ASSERT) 89 #if ENABLE(ASSERT)
90 m_didUpdateForChildren = parentState.m_didUpdateForChildren; 90 m_didUpdateForChildren = parentState.m_didUpdateForChildren;
91 #endif 91 #endif
92 return; 92 return;
93 } 93 }
94 94
95 ASSERT(parentState.m_didUpdateForChildren); 95 #if ENABLE(ASSERT)
96 DCHECK(parentState.m_didUpdateForChildren);
97 #endif
96 98
97 if (currentObject.isPaintInvalidationContainer()) { 99 if (currentObject.isPaintInvalidationContainer()) {
98 m_paintInvalidationContainer = toLayoutBoxModelObject(&currentObject); 100 m_paintInvalidationContainer = toLayoutBoxModelObject(&currentObject);
99 if (currentObject.styleRef().isStackingContext()) 101 if (currentObject.styleRef().isStackingContext())
100 m_paintInvalidationContainerForStackedContents = toLayoutBoxModelObj ect(&currentObject); 102 m_paintInvalidationContainerForStackedContents = toLayoutBoxModelObj ect(&currentObject);
101 } else if (currentObject.isLayoutView()) { 103 } else if (currentObject.isLayoutView()) {
102 // m_paintInvalidationContainerForStackedContents is only for stacked de scendants in its own frame, 104 // m_paintInvalidationContainerForStackedContents is only for stacked de scendants in its own frame,
103 // because it doesn't establish stacking context for stacked contents in sub-frames. 105 // because it doesn't establish stacking context for stacked contents in sub-frames.
104 // Contents stacked in the root stacking context in this frame should us e this frame's paintInvalidationContainer. 106 // Contents stacked in the root stacking context in this frame should us e this frame's paintInvalidationContainer.
105 m_paintInvalidationContainerForStackedContents = m_paintInvalidationCont ainer; 107 m_paintInvalidationContainerForStackedContents = m_paintInvalidationCont ainer;
(...skipping 20 matching lines...) Expand all
126 128
127 if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer) 129 if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer)
128 m_cachedOffsetsEnabled = supportsCachedOffsets(currentObject); 130 m_cachedOffsetsEnabled = supportsCachedOffsets(currentObject);
129 131
130 if (currentObject.isSVG()) { 132 if (currentObject.isSVG()) {
131 if (currentObject.isSVGRoot()) { 133 if (currentObject.isSVGRoot()) {
132 m_svgTransform = toLayoutSVGRoot(currentObject).localToBorderBoxTran sform(); 134 m_svgTransform = toLayoutSVGRoot(currentObject).localToBorderBoxTran sform();
133 // Don't early return here, because the SVGRoot object needs to exec ute the later code 135 // Don't early return here, because the SVGRoot object needs to exec ute the later code
134 // as a normal LayoutBox. 136 // as a normal LayoutBox.
135 } else { 137 } else {
136 ASSERT(currentObject != m_paintInvalidationContainer); 138 DCHECK(currentObject != m_paintInvalidationContainer);
137 m_svgTransform *= currentObject.localToSVGParentTransform(); 139 m_svgTransform *= currentObject.localToSVGParentTransform();
138 return; 140 return;
139 } 141 }
140 } 142 }
141 143
142 if (currentObject == m_paintInvalidationContainer) { 144 if (currentObject == m_paintInvalidationContainer) {
143 // When we hit a new paint invalidation container, we don't need to 145 // When we hit a new paint invalidation container, we don't need to
144 // continue forcing a check for paint invalidation, since we're 146 // continue forcing a check for paint invalidation, since we're
145 // descending into a different invalidation container. (For instance if 147 // descending into a different invalidation container. (For instance if
146 // our parents were moved, the entire container will just move.) 148 // our parents were moved, the entire container will just move.)
(...skipping 28 matching lines...) Expand all
175 177
176 updateForCurrentObject(parentState); 178 updateForCurrentObject(parentState);
177 } 179 }
178 180
179 void PaintInvalidationState::updateForCurrentObject(const PaintInvalidationState & parentState) 181 void PaintInvalidationState::updateForCurrentObject(const PaintInvalidationState & parentState)
180 { 182 {
181 if (!m_cachedOffsetsEnabled) 183 if (!m_cachedOffsetsEnabled)
182 return; 184 return;
183 185
184 if (m_currentObject.isLayoutView()) { 186 if (m_currentObject.isLayoutView()) {
185 ASSERT(&parentState.m_currentObject == toLayoutView(m_currentObject).fra me()->ownerLayoutObject()); 187 DCHECK(&parentState.m_currentObject == toLayoutView(m_currentObject).fra me()->ownerLayoutObject());
186 m_paintOffset += toLayoutBox(parentState.m_currentObject).contentBoxOffs et(); 188 m_paintOffset += toLayoutBox(parentState.m_currentObject).contentBoxOffs et();
187 // a LayoutView paints with a defined size but a pixel-rounded offset. 189 // a LayoutView paints with a defined size but a pixel-rounded offset.
188 m_paintOffset = LayoutSize(roundedIntSize(m_paintOffset)); 190 m_paintOffset = LayoutSize(roundedIntSize(m_paintOffset));
189 return; 191 return;
190 } 192 }
191 193
192 EPosition position = m_currentObject.styleRef().position(); 194 EPosition position = m_currentObject.styleRef().position();
193 195
194 if (position == FixedPosition) { 196 if (position == FixedPosition) {
195 if (m_paintInvalidationContainer != m_currentObject.view() && m_paintInv alidationContainer->view() == m_currentObject.view()) { 197 if (m_paintInvalidationContainer != m_currentObject.view() && m_paintInv alidationContainer->view() == m_currentObject.view()) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (m_currentObject.isBox()) 238 if (m_currentObject.isBox())
237 m_paintOffset += toLayoutBox(m_currentObject).locationOffset(); 239 m_paintOffset += toLayoutBox(m_currentObject).locationOffset();
238 240
239 if (m_currentObject.isInFlowPositioned() && m_currentObject.hasLayer()) 241 if (m_currentObject.isInFlowPositioned() && m_currentObject.hasLayer())
240 m_paintOffset += toLayoutBoxModelObject(m_currentObject).layer()->offset ForInFlowPosition(); 242 m_paintOffset += toLayoutBoxModelObject(m_currentObject).layer()->offset ForInFlowPosition();
241 } 243 }
242 244
243 void PaintInvalidationState::updateForChildren(PaintInvalidationReason reason) 245 void PaintInvalidationState::updateForChildren(PaintInvalidationReason reason)
244 { 246 {
245 #if ENABLE(ASSERT) 247 #if ENABLE(ASSERT)
246 ASSERT(!m_didUpdateForChildren); 248 DCHECK(!m_didUpdateForChildren);
247 m_didUpdateForChildren = true; 249 m_didUpdateForChildren = true;
248 #endif 250 #endif
249 251
250 switch (reason) { 252 switch (reason) {
251 case PaintInvalidationDelayedFull: 253 case PaintInvalidationDelayedFull:
252 m_pendingDelayedPaintInvalidations.append(&m_currentObject); 254 m_pendingDelayedPaintInvalidations.append(&m_currentObject);
253 break; 255 break;
254 case PaintInvalidationSubtree: 256 case PaintInvalidationSubtree:
255 m_forcedSubtreeInvalidationFlags |= (FullInvalidation | FullInvalidation ForStackedContents); 257 m_forcedSubtreeInvalidationFlags |= (FullInvalidation | FullInvalidation ForStackedContents);
256 break; 258 break;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 310 }
309 311
310 if (!m_currentObject.hasOverflowClip()) 312 if (!m_currentObject.hasOverflowClip())
311 return; 313 return;
312 314
313 const LayoutBox& box = toLayoutBox(m_currentObject); 315 const LayoutBox& box = toLayoutBox(m_currentObject);
314 316
315 // Do not clip or scroll for the paint invalidation container, if it scrolls overflow, because it will always use composited 317 // Do not clip or scroll for the paint invalidation container, if it scrolls overflow, because it will always use composited
316 // scrolling in this case. 318 // scrolling in this case.
317 if (box == m_paintInvalidationContainer && box.scrollsOverflow()) { 319 if (box == m_paintInvalidationContainer && box.scrollsOverflow()) {
318 ASSERT(!m_clipped); // The box establishes paint invalidation container, so no m_clipped inherited. 320 DCHECK(!m_clipped); // The box establishes paint invalidation container, so no m_clipped inherited.
319 } else { 321 } else {
320 addClipRectRelativeToPaintOffset(box.overflowClipRect(LayoutPoint())); 322 addClipRectRelativeToPaintOffset(box.overflowClipRect(LayoutPoint()));
321 m_paintOffset -= box.scrolledContentOffset(); 323 m_paintOffset -= box.scrolledContentOffset();
322 } 324 }
323 325
324 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. 326 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
325 } 327 }
326 328
327 static FloatPoint slowLocalToAncestorPoint(const LayoutObject& object, const Lay outBoxModelObject& ancestor, const FloatPoint& point) 329 static FloatPoint slowLocalToAncestorPoint(const LayoutObject& object, const Lay outBoxModelObject& ancestor, const FloatPoint& point)
328 { 330 {
329 if (object.isLayoutView()) 331 if (object.isLayoutView())
330 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave rseDocumentBoundaries | InputIsInFrameCoordinates); 332 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave rseDocumentBoundaries | InputIsInFrameCoordinates);
331 FloatPoint result = object.localToAncestorPoint(point, &ancestor, TraverseDo cumentBoundaries); 333 FloatPoint result = object.localToAncestorPoint(point, &ancestor, TraverseDo cumentBoundaries);
332 // Paint invalidation does not include scroll of the ancestor. 334 // Paint invalidation does not include scroll of the ancestor.
333 if (ancestor.isBox()) { 335 if (ancestor.isBox()) {
334 const LayoutBox* box = toLayoutBox(&ancestor); 336 const LayoutBox* box = toLayoutBox(&ancestor);
335 if (box->hasOverflowClip()) 337 if (box->hasOverflowClip())
336 result.move(box->scrolledContentOffset()); 338 result.move(box->scrolledContentOffset());
337 } 339 }
338 return result; 340 return result;
339 } 341 }
340 342
341 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking( ) const 343 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking( ) const
342 { 344 {
343 ASSERT(!m_didUpdateForChildren); 345 #if ENABLE(ASSERT)
346 DCHECK(!m_didUpdateForChildren);
347 #endif
344 348
345 FloatPoint point; 349 FloatPoint point;
346 if (m_paintInvalidationContainer != &m_currentObject) { 350 if (m_paintInvalidationContainer != &m_currentObject) {
347 if (m_cachedOffsetsEnabled) { 351 if (m_cachedOffsetsEnabled) {
348 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) 352 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
349 point = m_svgTransform.mapPoint(point); 353 point = m_svgTransform.mapPoint(point);
350 point += FloatPoint(m_paintOffset); 354 point += FloatPoint(m_paintOffset);
351 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY 355 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY
352 // TODO(wangxianzhu): We can't enable this ASSERT for now because of crbug.com/597745. 356 DCHECK(point == slowLocalOriginToAncestorPoint(m_currentObject, m_pa intInvalidationContainer, FloatPoint());
353 // ASSERT(point == slowLocalOriginToAncestorPoint(m_currentObject, m _paintInvalidationContainer, FloatPoint());
354 #endif 357 #endif
355 } else { 358 } else {
356 point = slowLocalToAncestorPoint(m_currentObject, *m_paintInvalidati onContainer, FloatPoint()); 359 point = slowLocalToAncestorPoint(m_currentObject, *m_paintInvalidati onContainer, FloatPoint());
357 } 360 }
358 } 361 }
359 362
360 if (m_paintInvalidationContainer->layer()->groupedMapping()) 363 if (m_paintInvalidationContainer->layer()->groupedMapping())
361 PaintLayer::mapPointInPaintInvalidationContainerToBacking(*m_paintInvali dationContainer, point); 364 PaintLayer::mapPointInPaintInvalidationContainerToBacking(*m_paintInvali dationContainer, point);
362 365
363 return LayoutPoint(point); 366 return LayoutPoint(point);
364 } 367 }
365 368
366 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const 369 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const
367 { 370 {
368 ASSERT(!m_didUpdateForChildren); 371 #if ENABLE(ASSERT)
372 DCHECK(!m_didUpdateForChildren);
373 #endif
369 374
370 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) 375 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
371 return computePaintInvalidationRectInBackingForSVG(); 376 return computePaintInvalidationRectInBackingForSVG();
372 377
373 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation(); 378 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation();
374 mapLocalRectToPaintInvalidationBacking(rect); 379 mapLocalRectToPaintInvalidationBacking(rect);
375 return rect; 380 return rect;
376 } 381 }
377 382
378 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG() const 383 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG() const
(...skipping 30 matching lines...) Expand all
409 toLayoutBox(&object)->flipForWritingMode(rect); 414 toLayoutBox(&object)->flipForWritingMode(rect);
410 415
411 if (object.isLayoutView()) 416 if (object.isLayoutView())
412 toLayoutView(object).mapToVisualRectInAncestorSpace(&ancestor, rect, Inp utIsInFrameCoordinates, DefaultVisualRectFlags); 417 toLayoutView(object).mapToVisualRectInAncestorSpace(&ancestor, rect, Inp utIsInFrameCoordinates, DefaultVisualRectFlags);
413 else 418 else
414 object.mapToVisualRectInAncestorSpace(&ancestor, rect); 419 object.mapToVisualRectInAncestorSpace(&ancestor, rect);
415 } 420 }
416 421
417 void PaintInvalidationState::mapLocalRectToPaintInvalidationContainer(LayoutRect & rect) const 422 void PaintInvalidationState::mapLocalRectToPaintInvalidationContainer(LayoutRect & rect) const
418 { 423 {
419 ASSERT(!m_didUpdateForChildren); 424 #if ENABLE(ASSERT)
425 DCHECK(!m_didUpdateForChildren);
426 #endif
420 427
421 if (m_cachedOffsetsEnabled) { 428 if (m_cachedOffsetsEnabled) {
422 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY 429 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY
423 LayoutRect slowPathRect(rect); 430 LayoutRect slowPathRect(rect);
424 slowMapToVisualRectInAncestorSpace(m_currentObject, *m_paintInvalidation Container, slowPathRect); 431 slowMapToVisualRectInAncestorSpace(m_currentObject, *m_paintInvalidation Container, slowPathRect);
425 #endif 432 #endif
426 rect.move(m_paintOffset); 433 rect.move(m_paintOffset);
427 if (m_clipped) 434 if (m_clipped)
428 rect.intersect(m_clipRect); 435 rect.intersect(m_clipRect);
429 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY 436 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY
(...skipping 19 matching lines...) Expand all
449 if (m_clipped) { 456 if (m_clipped) {
450 m_clipRect.intersect(clipRect); 457 m_clipRect.intersect(clipRect);
451 } else { 458 } else {
452 m_clipRect = clipRect; 459 m_clipRect = clipRect;
453 m_clipped = true; 460 m_clipped = true;
454 } 461 }
455 } 462 }
456 463
457 PaintLayer& PaintInvalidationState::paintingLayer() const 464 PaintLayer& PaintInvalidationState::paintingLayer() const
458 { 465 {
459 ASSERT(&m_paintingLayer == m_currentObject.paintingLayer()); 466 DCHECK(&m_paintingLayer == m_currentObject.paintingLayer());
460 return m_paintingLayer; 467 return m_paintingLayer;
461 } 468 }
462 469
463 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY 470 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY
464 471
465 static bool mayHaveBeenSaturated(LayoutUnit value) 472 static bool mayHaveBeenSaturated(LayoutUnit value)
466 { 473 {
467 // This is not accurate, just to avoid too big values. 474 // This is not accurate, just to avoid too big values.
468 return value.abs() >= LayoutUnit::max() / 2; 475 return value.abs() >= LayoutUnit::max() / 2;
469 } 476 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 WTFLogAlways("Fast path paint invalidation rect differs from slow path: fast : %s vs slow: %s", 513 WTFLogAlways("Fast path paint invalidation rect differs from slow path: fast : %s vs slow: %s",
507 fastPathRect.toString().ascii().data(), slowPathRect.toString().ascii(). data()); 514 fastPathRect.toString().ascii().data(), slowPathRect.toString().ascii(). data());
508 showLayoutTree(&m_currentObject); 515 showLayoutTree(&m_currentObject);
509 516
510 ASSERT_NOT_REACHED(); 517 ASSERT_NOT_REACHED();
511 } 518 }
512 519
513 #endif // CHECK_FAST_PATH_SLOW_PATH_EQUALITY 520 #endif // CHECK_FAST_PATH_SLOW_PATH_EQUALITY
514 521
515 } // namespace blink 522 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/svg/LayoutSVGBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698