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

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

Issue 1813383002: Move all fast-path paint invalidation mapping into PaintInvalidationState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 } 78 }
79 79
80 private: 80 private:
81 double m_start; 81 double m_start;
82 bool m_allowsChildFrameContent; 82 bool m_allowsChildFrameContent;
83 }; 83 };
84 84
85 } // namespace 85 } // namespace
86 86
87 bool LayoutView::s_viewClippingAndScrollOffsetDisabled = false;
88
87 LayoutView::LayoutView(Document* document) 89 LayoutView::LayoutView(Document* document)
88 : LayoutBlockFlow(document) 90 : LayoutBlockFlow(document)
89 , m_frameView(document->view()) 91 , m_frameView(document->view())
90 , m_selectionStart(nullptr) 92 , m_selectionStart(nullptr)
91 , m_selectionEnd(nullptr) 93 , m_selectionEnd(nullptr)
92 , m_selectionStartPos(-1) 94 , m_selectionStartPos(-1)
93 , m_selectionEndPos(-1) 95 , m_selectionEndPos(-1)
94 , m_pageLogicalHeight(0) 96 , m_pageLogicalHeight(0)
95 , m_pageLogicalHeightChanged(false) 97 , m_pageLogicalHeightChanged(false)
96 , m_layoutState(nullptr) 98 , m_layoutState(nullptr)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Ditto when not in compositing mode. 318 // Ditto when not in compositing mode.
317 if (!usesCompositing()) 319 if (!usesCompositing())
318 return LayoutBlockFlow::visualOverflowRect(); 320 return LayoutBlockFlow::visualOverflowRect();
319 321
320 // In normal compositing mode, LayoutView doesn't actually apply clipping 322 // In normal compositing mode, LayoutView doesn't actually apply clipping
321 // on its descendants. Instead their visual overflow is propagated to 323 // on its descendants. Instead their visual overflow is propagated to
322 // compositor()->m_rootContentLayer for accelerated scrolling. 324 // compositor()->m_rootContentLayer for accelerated scrolling.
323 return LayoutRect(documentRect()); 325 return LayoutRect(documentRect());
324 } 326 }
325 327
326 void LayoutView::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transf ormState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const PaintI nvalidationState* paintInvalidationState) const 328 void LayoutView::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transf ormState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const
327 { 329 {
328 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed)); 330 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed));
329 331
330 if (!ancestor && mode & UseTransforms && shouldUseTransformFromContainer(0)) { 332 if (!ancestor && mode & UseTransforms && shouldUseTransformFromContainer(0)) {
331 TransformationMatrix t; 333 TransformationMatrix t;
332 getTransformFromContainer(0, LayoutSize(), t); 334 getTransformFromContainer(0, LayoutSize(), t);
333 transformState.applyTransform(t); 335 transformState.applyTransform(t);
334 } 336 }
335 337
336 if ((mode & IsFixed) && m_frameView) { 338 if ((mode & IsFixed) && m_frameView) {
337 transformState.move(toIntSize(m_frameView->scrollPosition())); 339 transformState.move(toIntSize(m_frameView->scrollPosition()));
338 if (hasOverflowClip()) 340 if (hasOverflowClip())
339 transformState.move(scrolledContentOffset()); 341 transformState.move(scrolledContentOffset());
340 // IsFixed flag is only applicable within this LayoutView. 342 // IsFixed flag is only applicable within this LayoutView.
341 mode &= ~IsFixed; 343 mode &= ~IsFixed;
342 } 344 }
343 345
344 if (ancestor == this) 346 if (ancestor == this)
345 return; 347 return;
346 348
347 if (mode & TraverseDocumentBoundaries) { 349 if (mode & TraverseDocumentBoundaries) {
348 if (LayoutPart* parentDocLayoutObject = frame()->ownerLayoutObject()) { 350 if (LayoutPart* parentDocLayoutObject = frame()->ownerLayoutObject()) {
349 transformState.move(-frame()->view()->scrollOffset()); 351 if (!s_viewClippingAndScrollOffsetDisabled)
352 transformState.move(-frame()->view()->scrollOffset());
350 transformState.move(parentDocLayoutObject->contentBoxOffset()); 353 transformState.move(parentDocLayoutObject->contentBoxOffset());
351 354
352 parentDocLayoutObject->mapLocalToAncestor(ancestor, transformState, mode, wasFixed, paintInvalidationState); 355 parentDocLayoutObject->mapLocalToAncestor(ancestor, transformState, mode, wasFixed);
353 } 356 }
354 } 357 }
355 } 358 }
356 359
357 const LayoutObject* LayoutView::pushMappingToContainer(const LayoutBoxModelObjec t* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 360 const LayoutObject* LayoutView::pushMappingToContainer(const LayoutBoxModelObjec t* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
358 { 361 {
359 LayoutSize offsetForFixedPosition; 362 LayoutSize offsetForFixedPosition;
360 LayoutSize offset; 363 LayoutSize offset;
361 LayoutObject* container = nullptr; 364 LayoutObject* container = nullptr;
362 365
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 440
438 void LayoutView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInval idationState) 441 void LayoutView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInval idationState)
439 { 442 {
440 ASSERT(!needsLayout()); 443 ASSERT(!needsLayout());
441 444
442 // We specifically need to issue paint invalidations for the viewRect since other layoutObjects 445 // We specifically need to issue paint invalidations for the viewRect since other layoutObjects
443 // short-circuit on full-paint invalidation. 446 // short-circuit on full-paint invalidation.
444 LayoutRect dirtyRect = viewRect(); 447 LayoutRect dirtyRect = viewRect();
445 if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) { 448 if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) {
446 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidati onState.paintInvalidationContainer(); 449 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidati onState.paintInvalidationContainer();
447 PaintLayer::mapRectToPaintInvalidationBacking(this, &paintInvalidationCo ntainer, dirtyRect, &paintInvalidationState); 450 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(dirtyRect) ;
448 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, Pai ntInvalidationFull); 451 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, Pai ntInvalidationFull);
449 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationFull); 452 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationFull);
450 } 453 }
451 LayoutBlock::invalidateTreeIfNeeded(paintInvalidationState); 454 LayoutBlock::invalidateTreeIfNeeded(paintInvalidationState);
452 } 455 }
453 456
454 static void setShouldDoFullPaintInvalidationForViewAndAllDescendantsInternal(Lay outObject* object) 457 static void setShouldDoFullPaintInvalidationForViewAndAllDescendantsInternal(Lay outObject* object)
455 { 458 {
456 object->setShouldDoFullPaintInvalidation(); 459 object->setShouldDoFullPaintInvalidation();
457 for (LayoutObject* child = object->slowFirstChild(); child; child = child->n extSibling()) { 460 for (LayoutObject* child = object->slowFirstChild(); child; child = child->n extSibling()) {
(...skipping 10 matching lines...) Expand all
468 { 471 {
469 setShouldDoFullPaintInvalidation(); 472 setShouldDoFullPaintInvalidation();
470 473
471 // The only way we know how to hit these ASSERTS below this point is via the Chromium OS login screen. 474 // The only way we know how to hit these ASSERTS below this point is via the Chromium OS login screen.
472 DisableCompositingQueryAsserts disabler; 475 DisableCompositingQueryAsserts disabler;
473 476
474 if (compositor()->inCompositingMode()) 477 if (compositor()->inCompositingMode())
475 compositor()->fullyInvalidatePaint(); 478 compositor()->fullyInvalidatePaint();
476 } 479 }
477 480
478 void LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, const PaintInvalidationState* invalidationState) const 481 void LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect) const
479 { 482 {
480 mapToVisibleRectInAncestorSpace(ancestor, rect, IsNotFixedPosition, invalida tionState); 483 mapToVisibleRectInAncestorSpace(ancestor, rect, IsNotFixedPosition);
481 } 484 }
482 485
483 void LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, ViewportConstrainedPosition viewportConstraint, const P aintInvalidationState* state) const 486 void LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, ViewportConstrainedPosition viewportConstraint) const
484 { 487 {
485 if (document().printing()) 488 if (document().printing())
486 return; 489 return;
487 490
488 if (style()->isFlippedBlocksWritingMode()) { 491 if (style()->isFlippedBlocksWritingMode()) {
489 // We have to flip by hand since the view's logical height has not been determined. We 492 // We have to flip by hand since the view's logical height has not been determined. We
490 // can use the viewport width and height. 493 // can use the viewport width and height.
491 if (style()->isHorizontalWritingMode()) 494 if (style()->isHorizontalWritingMode())
492 rect.setY(viewHeight() - rect.maxY()); 495 rect.setY(viewHeight() - rect.maxY());
493 else 496 else
494 rect.setX(viewWidth() - rect.maxX()); 497 rect.setX(viewWidth() - rect.maxX());
495 } 498 }
496 499
497 adjustViewportConstrainedOffset(rect, viewportConstraint); 500 adjustViewportConstrainedOffset(rect, viewportConstraint);
498 501
499 // Apply our transform if we have one (because of full page zooming). 502 // Apply our transform if we have one (because of full page zooming).
500 if (!ancestor && layer() && layer()->transform()) 503 if (!ancestor && layer() && layer()->transform())
501 rect = layer()->transform()->mapRect(rect); 504 rect = layer()->transform()->mapRect(rect);
502 505
503 ASSERT(ancestor); 506 ASSERT(ancestor);
504 if (ancestor == this) 507 if (ancestor == this)
505 return; 508 return;
506 509
507 Element* owner = document().ownerElement(); 510 Element* owner = document().ownerElement();
508 if (!owner) 511 if (!owner)
509 return; 512 return;
510 513
511 if (LayoutBox* obj = owner->layoutBox()) { 514 if (LayoutBox* obj = owner->layoutBox()) {
512 if (!state || !state->viewClippingAndScrollOffsetDisabled()) { 515 if (!s_viewClippingAndScrollOffsetDisabled) {
513 // Intersect the viewport with the paint invalidation rect. 516 // Intersect the viewport with the paint invalidation rect.
514 LayoutRect viewRectangle = viewRect(); 517 LayoutRect viewRectangle = viewRect();
515 rect.intersect(viewRectangle); 518 rect.intersect(viewRectangle);
516 519
517 // Adjust for scroll offset of the view. 520 // Adjust for scroll offset of the view.
518 rect.moveBy(-viewRectangle.location()); 521 rect.moveBy(-viewRectangle.location());
519 } 522 }
520 523
521 // Adjust for frame border. 524 // Adjust for frame border.
522 rect.move(obj->contentBoxOffset()); 525 rect.move(obj->contentBoxOffset());
523 obj->mapToVisibleRectInAncestorSpace(ancestor, rect, 0); 526 obj->mapToVisibleRectInAncestorSpace(ancestor, rect);
524 } 527 }
525 } 528 }
526 529
527 void LayoutView::adjustViewportConstrainedOffset(LayoutRect& rect, ViewportConst rainedPosition viewportConstraint) const 530 void LayoutView::adjustViewportConstrainedOffset(LayoutRect& rect, ViewportConst rainedPosition viewportConstraint) const
528 { 531 {
529 if (viewportConstraint != IsFixedPosition) 532 if (viewportConstraint != IsFixedPosition)
530 return; 533 return;
531 534
532 if (m_frameView) { 535 if (m_frameView) {
533 rect.move(toIntSize(m_frameView->scrollPosition())); 536 rect.move(toIntSize(m_frameView->scrollPosition()));
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1030
1028 ScrollResult LayoutView::scroll(ScrollGranularity granularity, const FloatSize& delta) 1031 ScrollResult LayoutView::scroll(ScrollGranularity granularity, const FloatSize& delta)
1029 { 1032 {
1030 if (!frameView()) 1033 if (!frameView())
1031 return ScrollResult(); 1034 return ScrollResult();
1032 1035
1033 return frame()->applyScrollDelta(granularity, delta, false); 1036 return frame()->applyScrollDelta(granularity, delta, false);
1034 } 1037 }
1035 1038
1036 } // namespace blink 1039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698