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

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: Disable fast-path/slow-path comparison because of saturated operations of LayoutUnit Created 4 years, 8 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Ditto when not in compositing mode. 316 // Ditto when not in compositing mode.
317 if (!usesCompositing()) 317 if (!usesCompositing())
318 return LayoutBlockFlow::visualOverflowRect(); 318 return LayoutBlockFlow::visualOverflowRect();
319 319
320 // In normal compositing mode, LayoutView doesn't actually apply clipping 320 // In normal compositing mode, LayoutView doesn't actually apply clipping
321 // on its descendants. Instead their visual overflow is propagated to 321 // on its descendants. Instead their visual overflow is propagated to
322 // compositor()->m_rootContentLayer for accelerated scrolling. 322 // compositor()->m_rootContentLayer for accelerated scrolling.
323 return LayoutRect(documentRect()); 323 return LayoutRect(documentRect());
324 } 324 }
325 325
326 void LayoutView::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transf ormState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const PaintI nvalidationState* paintInvalidationState) const 326 void LayoutView::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transf ormState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const
327 { 327 {
328 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed)); 328 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed));
329 329
330 if (!ancestor && mode & UseTransforms && shouldUseTransformFromContainer(0)) { 330 if (!ancestor && mode & UseTransforms && shouldUseTransformFromContainer(0)) {
331 TransformationMatrix t; 331 TransformationMatrix t;
332 getTransformFromContainer(0, LayoutSize(), t); 332 getTransformFromContainer(0, LayoutSize(), t);
333 transformState.applyTransform(t); 333 transformState.applyTransform(t);
334 } 334 }
335 335
336 if ((mode & IsFixed) && m_frameView) { 336 if ((mode & IsFixed) && m_frameView) {
337 transformState.move(toIntSize(m_frameView->scrollPosition())); 337 transformState.move(toIntSize(m_frameView->scrollPosition()));
338 if (hasOverflowClip()) 338 if (hasOverflowClip())
339 transformState.move(scrolledContentOffset()); 339 transformState.move(scrolledContentOffset());
340 // IsFixed flag is only applicable within this LayoutView. 340 // IsFixed flag is only applicable within this LayoutView.
341 mode &= ~IsFixed; 341 mode &= ~IsFixed;
342 } 342 }
343 343
344 if (ancestor == this) 344 if (ancestor == this)
345 return; 345 return;
346 346
347 if (mode & TraverseDocumentBoundaries) { 347 if (mode & TraverseDocumentBoundaries) {
348 if (LayoutPart* parentDocLayoutObject = frame()->ownerLayoutObject()) { 348 if (LayoutPart* parentDocLayoutObject = frame()->ownerLayoutObject()) {
349 transformState.move(-frame()->view()->scrollOffset()); 349 if (!(mode & InputIsInFrameCoordinates)) {
350 transformState.move(-frame()->view()->scrollOffset());
351 } else {
352 // The flag applies to immediate LayoutView only.
353 mode &= ~InputIsInFrameCoordinates;
354 }
355
350 transformState.move(parentDocLayoutObject->contentBoxOffset()); 356 transformState.move(parentDocLayoutObject->contentBoxOffset());
351 357
352 parentDocLayoutObject->mapLocalToAncestor(ancestor, transformState, mode, wasFixed, paintInvalidationState); 358 parentDocLayoutObject->mapLocalToAncestor(ancestor, transformState, mode, wasFixed);
353 } 359 }
354 } 360 }
355 } 361 }
356 362
357 const LayoutObject* LayoutView::pushMappingToContainer(const LayoutBoxModelObjec t* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 363 const LayoutObject* LayoutView::pushMappingToContainer(const LayoutBoxModelObjec t* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
358 { 364 {
359 LayoutSize offsetForFixedPosition; 365 LayoutSize offsetForFixedPosition;
360 LayoutSize offset; 366 LayoutSize offset;
361 LayoutObject* container = nullptr; 367 LayoutObject* container = nullptr;
362 368
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 443
438 void LayoutView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInval idationState) 444 void LayoutView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInval idationState)
439 { 445 {
440 ASSERT(!needsLayout()); 446 ASSERT(!needsLayout());
441 447
442 // We specifically need to issue paint invalidations for the viewRect since other layoutObjects 448 // We specifically need to issue paint invalidations for the viewRect since other layoutObjects
443 // short-circuit on full-paint invalidation. 449 // short-circuit on full-paint invalidation.
444 LayoutRect dirtyRect = viewRect(); 450 LayoutRect dirtyRect = viewRect();
445 if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) { 451 if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) {
446 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidati onState.paintInvalidationContainer(); 452 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidati onState.paintInvalidationContainer();
447 PaintLayer::mapRectToPaintInvalidationBacking(this, &paintInvalidationCo ntainer, dirtyRect, &paintInvalidationState); 453 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(dirtyRect) ;
448 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, Pai ntInvalidationFull); 454 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, Pai ntInvalidationFull);
449 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationFull); 455 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationFull);
450 } 456 }
451 LayoutBlock::invalidateTreeIfNeeded(paintInvalidationState); 457 LayoutBlock::invalidateTreeIfNeeded(paintInvalidationState);
452 } 458 }
453 459
454 static void setShouldDoFullPaintInvalidationForViewAndAllDescendantsInternal(Lay outObject* object) 460 static void setShouldDoFullPaintInvalidationForViewAndAllDescendantsInternal(Lay outObject* object)
455 { 461 {
456 object->setShouldDoFullPaintInvalidation(); 462 object->setShouldDoFullPaintInvalidation();
457 for (LayoutObject* child = object->slowFirstChild(); child; child = child->n extSibling()) { 463 for (LayoutObject* child = object->slowFirstChild(); child; child = child->n extSibling()) {
(...skipping 10 matching lines...) Expand all
468 { 474 {
469 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); 475 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
470 476
471 // The only way we know how to hit these ASSERTS below this point is via the Chromium OS login screen. 477 // The only way we know how to hit these ASSERTS below this point is via the Chromium OS login screen.
472 DisableCompositingQueryAsserts disabler; 478 DisableCompositingQueryAsserts disabler;
473 479
474 if (compositor()->inCompositingMode()) 480 if (compositor()->inCompositingMode())
475 compositor()->fullyInvalidatePaint(); 481 compositor()->fullyInvalidatePaint();
476 } 482 }
477 483
478 bool LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, const PaintInvalidationState* invalidationState, Visibl eRectFlags visibleRectFlags) const 484 bool LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, VisibleRectFlags visibleRectFlags) const
479 { 485 {
480 return mapToVisibleRectInAncestorSpace(ancestor, rect, IsNotFixedPosition, i nvalidationState, visibleRectFlags); 486 return mapToVisibleRectInAncestorSpace(ancestor, rect, 0, visibleRectFlags);
481 } 487 }
482 488
483 bool LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, ViewportConstrainedPosition viewportConstraint, const P aintInvalidationState* paintInvalidationState, VisibleRectFlags visibleRectFlags ) const 489 bool LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, MapCoordinatesFlags mode, VisibleRectFlags visibleRectF lags) const
484 { 490 {
485 if (document().printing()) 491 if (document().printing())
486 return true; 492 return true;
487 493
488 // TODO(chrishtr): fix PaintInvalidationState offsets for LayoutViews.
489
490 if (style()->isFlippedBlocksWritingMode()) { 494 if (style()->isFlippedBlocksWritingMode()) {
491 // We have to flip by hand since the view's logical height has not been determined. We 495 // We have to flip by hand since the view's logical height has not been determined. We
492 // can use the viewport width and height. 496 // can use the viewport width and height.
493 if (style()->isHorizontalWritingMode()) 497 if (style()->isHorizontalWritingMode())
494 rect.setY(viewHeight() - rect.maxY()); 498 rect.setY(viewHeight() - rect.maxY());
495 else 499 else
496 rect.setX(viewWidth() - rect.maxX()); 500 rect.setX(viewWidth() - rect.maxX());
497 } 501 }
498 502
499 adjustViewportConstrainedOffset(rect, viewportConstraint); 503 if (mode & IsFixed)
504 adjustOffsetForFixedPosition(rect);
500 505
501 // Apply our transform if we have one (because of full page zooming). 506 // Apply our transform if we have one (because of full page zooming).
502 if (!ancestor && layer() && layer()->transform()) 507 if (!ancestor && layer() && layer()->transform())
503 rect = layer()->transform()->mapRect(rect); 508 rect = layer()->transform()->mapRect(rect);
504 509
505 ASSERT(ancestor); 510 ASSERT(ancestor);
506 if (ancestor == this) 511 if (ancestor == this)
507 return true; 512 return true;
508 513
509 Element* owner = document().ownerElement(); 514 Element* owner = document().ownerElement();
510 if (!owner) 515 if (!owner)
511 return true; 516 return true;
512 517
513 if (LayoutBox* obj = owner->layoutBox()) { 518 if (LayoutBox* obj = owner->layoutBox()) {
514 if (!paintInvalidationState || !paintInvalidationState->viewClippingAndS crollOffsetDisabled()) { 519 if (!(mode & InputIsInFrameCoordinates)) {
515 // Intersect the viewport with the paint invalidation rect. 520 // Intersect the viewport with the paint invalidation rect.
516 LayoutRect viewRectangle = viewRect(); 521 LayoutRect viewRectangle = viewRect();
517 if (visibleRectFlags & EdgeInclusive) { 522 if (visibleRectFlags & EdgeInclusive) {
518 if (!rect.inclusiveIntersect(viewRectangle)) 523 if (!rect.inclusiveIntersect(viewRectangle))
519 return false; 524 return false;
520 } else { 525 } else {
521 rect.intersect(viewRectangle); 526 rect.intersect(viewRectangle);
522 } 527 }
523 528
524 // Adjust for scroll offset of the view. 529 // Adjust for scroll offset of the view.
525 rect.moveBy(-viewRectangle.location()); 530 rect.moveBy(-viewRectangle.location());
526 } 531 }
527 532
528 // Adjust for frame border. 533 // Adjust for frame border.
529 rect.move(obj->contentBoxOffset()); 534 rect.move(obj->contentBoxOffset());
530 return obj->mapToVisibleRectInAncestorSpace(ancestor, rect, 0, visibleRe ctFlags); 535 return obj->mapToVisibleRectInAncestorSpace(ancestor, rect, visibleRectF lags);
531 } 536 }
532 537
533 return true; 538 return true;
534 } 539 }
535 540
536 void LayoutView::adjustViewportConstrainedOffset(LayoutRect& rect, ViewportConst rainedPosition viewportConstraint) const 541 void LayoutView::adjustOffsetForFixedPosition(LayoutRect& rect) const
537 { 542 {
538 if (viewportConstraint != IsFixedPosition)
539 return;
540
541 if (m_frameView) { 543 if (m_frameView) {
542 rect.move(toIntSize(m_frameView->scrollPosition())); 544 rect.move(toIntSize(m_frameView->scrollPosition()));
543 if (hasOverflowClip()) 545 if (hasOverflowClip())
544 rect.move(scrolledContentOffset()); 546 rect.move(scrolledContentOffset());
545 547
546 // FIXME: Paint invalidation should happen after scroll updates, so ther e should be no pending scroll delta. 548 // FIXME: Paint invalidation should happen after scroll updates, so ther e should be no pending scroll delta.
547 // However, we still have paint invalidation during layout, so we can't ASSERT for now. crbug.com/434950. 549 // However, we still have paint invalidation during layout, so we can't ASSERT for now. crbug.com/434950.
548 // ASSERT(m_frameView->pendingScrollDelta().isZero()); 550 // ASSERT(m_frameView->pendingScrollDelta().isZero());
549 // If we have a pending scroll, invalidate the previous scroll position. 551 // If we have a pending scroll, invalidate the previous scroll position.
550 if (!m_frameView->pendingScrollDelta().isZero()) 552 if (!m_frameView->pendingScrollDelta().isZero())
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1038
1037 ScrollResult LayoutView::scroll(ScrollGranularity granularity, const FloatSize& delta) 1039 ScrollResult LayoutView::scroll(ScrollGranularity granularity, const FloatSize& delta)
1038 { 1040 {
1039 if (!frameView()) 1041 if (!frameView())
1040 return ScrollResult(); 1042 return ScrollResult();
1041 1043
1042 return frame()->applyScrollDelta(granularity, delta, false); 1044 return frame()->applyScrollDelta(granularity, delta, false);
1043 } 1045 }
1044 1046
1045 } // namespace blink 1047 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.h ('k') | third_party/WebKit/Source/core/layout/PaintInvalidationState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698