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

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

Issue 1817693002: Support edge-inclusive intersections in mapToVisibleRectInAncestorSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-idle-callback
Patch Set: Added IntersectionType flag and unit test for LayoutRect::inclusiveIntersect. 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 { 468 {
469 setShouldDoFullPaintInvalidation(); 469 setShouldDoFullPaintInvalidation();
470 470
471 // The only way we know how to hit these ASSERTS below this point is via the Chromium OS login screen. 471 // The only way we know how to hit these ASSERTS below this point is via the Chromium OS login screen.
472 DisableCompositingQueryAsserts disabler; 472 DisableCompositingQueryAsserts disabler;
473 473
474 if (compositor()->inCompositingMode()) 474 if (compositor()->inCompositingMode())
475 compositor()->fullyInvalidatePaint(); 475 compositor()->fullyInvalidatePaint();
476 } 476 }
477 477
478 void LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, const PaintInvalidationState* invalidationState) const 478 bool LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, const PaintInvalidationState* invalidationState, int fl ags) const
479 { 479 {
480 mapToVisibleRectInAncestorSpace(ancestor, rect, IsNotFixedPosition, invalida tionState); 480 return mapToVisibleRectInAncestorSpace(ancestor, rect, IsNotFixedPosition, i nvalidationState, flags);
481 } 481 }
482 482
483 void LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, ViewportConstrainedPosition viewportConstraint, const P aintInvalidationState* state) const 483 bool LayoutView::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect& rect, ViewportConstrainedPosition viewportConstraint, const P aintInvalidationState* state, int flags) const
484 { 484 {
485 if (document().printing()) 485 if (document().printing())
486 return; 486 return true;
487 487
488 if (style()->isFlippedBlocksWritingMode()) { 488 if (style()->isFlippedBlocksWritingMode()) {
489 // We have to flip by hand since the view's logical height has not been determined. We 489 // 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. 490 // can use the viewport width and height.
491 if (style()->isHorizontalWritingMode()) 491 if (style()->isHorizontalWritingMode())
492 rect.setY(viewHeight() - rect.maxY()); 492 rect.setY(viewHeight() - rect.maxY());
493 else 493 else
494 rect.setX(viewWidth() - rect.maxX()); 494 rect.setX(viewWidth() - rect.maxX());
495 } 495 }
496 496
497 adjustViewportConstrainedOffset(rect, viewportConstraint); 497 adjustViewportConstrainedOffset(rect, viewportConstraint);
498 498
499 // Apply our transform if we have one (because of full page zooming). 499 // Apply our transform if we have one (because of full page zooming).
500 if (!ancestor && layer() && layer()->transform()) 500 if (!ancestor && layer() && layer()->transform())
501 rect = layer()->transform()->mapRect(rect); 501 rect = layer()->transform()->mapRect(rect);
502 502
503 ASSERT(ancestor); 503 ASSERT(ancestor);
504 if (ancestor == this) 504 if (ancestor == this)
505 return; 505 return true;
506 506
507 Element* owner = document().ownerElement(); 507 Element* owner = document().ownerElement();
508 if (!owner) 508 if (!owner)
509 return; 509 return true;
510 510
511 if (LayoutBox* obj = owner->layoutBox()) { 511 if (LayoutBox* obj = owner->layoutBox()) {
512 if (!state || !state->viewClippingAndScrollOffsetDisabled()) { 512 if (!state || !state->viewClippingAndScrollOffsetDisabled()) {
513 // Intersect the viewport with the paint invalidation rect. 513 // Intersect the viewport with the paint invalidation rect.
514 LayoutRect viewRectangle = viewRect(); 514 LayoutRect viewRectangle = viewRect();
515 rect.intersect(viewRectangle); 515 if (flags & EdgeInclusive) {
516 if (!rect.inclusiveIntersect(viewRectangle))
517 return false;
518 } else {
519 rect.intersect(viewRectangle);
chrishtr 2016/03/22 17:25:49 return false here if it's empty? Early out code?
520 }
516 521
517 // Adjust for scroll offset of the view. 522 // Adjust for scroll offset of the view.
518 rect.moveBy(-viewRectangle.location()); 523 rect.moveBy(-viewRectangle.location());
519 } 524 }
520 525
521 // Adjust for frame border. 526 // Adjust for frame border.
522 rect.move(obj->contentBoxOffset()); 527 rect.move(obj->contentBoxOffset());
523 obj->mapToVisibleRectInAncestorSpace(ancestor, rect, 0); 528 return obj->mapToVisibleRectInAncestorSpace(ancestor, rect, 0, flags);
524 } 529 }
530
531 return true;
525 } 532 }
526 533
527 void LayoutView::adjustViewportConstrainedOffset(LayoutRect& rect, ViewportConst rainedPosition viewportConstraint) const 534 void LayoutView::adjustViewportConstrainedOffset(LayoutRect& rect, ViewportConst rainedPosition viewportConstraint) const
528 { 535 {
529 if (viewportConstraint != IsFixedPosition) 536 if (viewportConstraint != IsFixedPosition)
530 return; 537 return;
531 538
532 if (m_frameView) { 539 if (m_frameView) {
533 rect.move(toIntSize(m_frameView->scrollPosition())); 540 rect.move(toIntSize(m_frameView->scrollPosition()));
534 if (hasOverflowClip()) 541 if (hasOverflowClip())
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1034
1028 ScrollResult LayoutView::scroll(ScrollGranularity granularity, const FloatSize& delta) 1035 ScrollResult LayoutView::scroll(ScrollGranularity granularity, const FloatSize& delta)
1029 { 1036 {
1030 if (!frameView()) 1037 if (!frameView())
1031 return ScrollResult(); 1038 return ScrollResult();
1032 1039
1033 return frame()->applyScrollDelta(granularity, delta, false); 1040 return frame()->applyScrollDelta(granularity, delta, false);
1034 } 1041 }
1035 1042
1036 } // namespace blink 1043 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698