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

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

Issue 2727093002: Account for perspective and preserve-3d in mapToVisualRectInAncestorSpace (Closed)
Patch Set: none Created 3 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. 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 *
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // Chromium OS login screen. 458 // Chromium OS login screen.
459 DisableCompositingQueryAsserts disabler; 459 DisableCompositingQueryAsserts disabler;
460 460
461 if (compositor()->inCompositingMode()) 461 if (compositor()->inCompositingMode())
462 compositor()->fullyInvalidatePaint(); 462 compositor()->fullyInvalidatePaint();
463 } 463 }
464 464
465 bool LayoutView::mapToVisualRectInAncestorSpace( 465 bool LayoutView::mapToVisualRectInAncestorSpace(
466 const LayoutBoxModelObject* ancestor, 466 const LayoutBoxModelObject* ancestor,
467 LayoutRect& rect, 467 LayoutRect& rect,
468 VisualRectFlags visualRectFlags) const {
469 return mapToVisualRectInAncestorSpace(ancestor, rect, 0, visualRectFlags);
470 }
471
472 bool LayoutView::mapToVisualRectInAncestorSpace(
473 const LayoutBoxModelObject* ancestor,
474 LayoutRect& rect,
475 MapCoordinatesFlags mode, 468 MapCoordinatesFlags mode,
476 VisualRectFlags visualRectFlags) const { 469 VisualRectFlags visualRectFlags) const {
470 TransformState transformState(TransformState::ApplyTransformDirection,
471 FloatQuad(FloatRect(rect)));
472 bool retval = mapToVisualRectInAncestorSpaceInternal(ancestor, transformState,
473 mode, visualRectFlags);
474 transformState.flatten();
475 rect = LayoutRect(transformState.lastPlanarQuad().boundingBox());
476 return retval;
477 }
478
479 bool LayoutView::mapToVisualRectInAncestorSpaceInternal(
480 const LayoutBoxModelObject* ancestor,
481 TransformState& transformState,
482 VisualRectFlags visualRectFlags) const {
483 return mapToVisualRectInAncestorSpaceInternal(ancestor, transformState, 0,
484 visualRectFlags);
485 }
486
487 bool LayoutView::mapToVisualRectInAncestorSpaceInternal(
488 const LayoutBoxModelObject* ancestor,
489 TransformState& transformState,
490 MapCoordinatesFlags mode,
491 VisualRectFlags visualRectFlags) const {
477 if (mode & IsFixed) 492 if (mode & IsFixed)
478 rect.move(offsetForFixedPosition(true)); 493 transformState.move(offsetForFixedPosition(true));
479 494
480 // Apply our transform if we have one (because of full page zooming). 495 // Apply our transform if we have one (because of full page zooming).
481 if (layer() && layer()->transform()) 496 if (layer() && layer()->transform()) {
482 rect = layer()->transform()->mapRect(rect); 497 transformState.applyTransform(layer()->currentTransform(),
498 TransformState::FlattenTransform);
499 }
500
501 transformState.flatten();
483 502
484 if (ancestor == this) 503 if (ancestor == this)
485 return true; 504 return true;
486 505
487 Element* owner = document().localOwner(); 506 Element* owner = document().localOwner();
488 if (!owner) 507 if (!owner) {
489 return frameView()->mapToVisualRectInTopFrameSpace(rect); 508 LayoutRect rect(transformState.lastPlanarQuad().boundingBox());
509 bool retval = frameView()->mapToVisualRectInTopFrameSpace(rect);
510 transformState.setQuad(FloatQuad(FloatRect(rect)));
511 return retval;
512 }
490 513
491 if (LayoutBox* obj = owner->layoutBox()) { 514 if (LayoutBox* obj = owner->layoutBox()) {
515 LayoutRect rect(transformState.lastPlanarQuad().boundingBox());
492 if (!(mode & InputIsInFrameCoordinates)) { 516 if (!(mode & InputIsInFrameCoordinates)) {
493 // Intersect the viewport with the visual rect. 517 // Intersect the viewport with the visual rect.
494 LayoutRect viewRectangle = viewRect(); 518 LayoutRect viewRectangle = viewRect();
495 if (visualRectFlags & EdgeInclusive) { 519 if (visualRectFlags & EdgeInclusive) {
496 if (!rect.inclusiveIntersect(viewRectangle)) 520 if (!rect.inclusiveIntersect(viewRectangle)) {
521 transformState.setQuad(FloatQuad(FloatRect(rect)));
497 return false; 522 return false;
523 }
498 } else { 524 } else {
499 rect.intersect(viewRectangle); 525 rect.intersect(viewRectangle);
500 } 526 }
501 527
502 // Adjust for scroll offset of the view. 528 // Adjust for scroll offset of the view.
503 rect.moveBy(-viewRectangle.location()); 529 rect.moveBy(-viewRectangle.location());
504 } 530 }
505 // Frames are painted at rounded-int position. Since we cannot efficiently 531 // Frames are painted at rounded-int position. Since we cannot efficiently
506 // compute the subpixel offset of painting at this point in a a bottom-up 532 // compute the subpixel offset of painting at this point in a a bottom-up
507 // walk, round to the enclosing int rect, which will enclose the actual 533 // walk, round to the enclosing int rect, which will enclose the actual
508 // visible rect. 534 // visible rect.
509 rect = LayoutRect(enclosingIntRect(rect)); 535 rect = LayoutRect(enclosingIntRect(rect));
510 536
511 // Adjust for frame border. 537 // Adjust for frame border.
512 rect.move(obj->contentBoxOffset()); 538 rect.move(obj->contentBoxOffset());
513 return obj->mapToVisualRectInAncestorSpace(ancestor, rect, visualRectFlags); 539 transformState.setQuad(FloatQuad(FloatRect(rect)));
540
541 return obj->mapToVisualRectInAncestorSpaceInternal(ancestor, transformState,
542 visualRectFlags);
514 } 543 }
515 544
516 // This can happen, e.g., if the iframe element has display:none. 545 // This can happen, e.g., if the iframe element has display:none.
517 rect = LayoutRect(); 546 transformState.setQuad(FloatQuad(FloatRect()));
518 return false; 547 return false;
519 } 548 }
520 549
521 LayoutSize LayoutView::offsetForFixedPosition(bool includePendingScroll) const { 550 LayoutSize LayoutView::offsetForFixedPosition(bool includePendingScroll) const {
522 FloatSize adjustment; 551 FloatSize adjustment;
523 if (m_frameView) { 552 if (m_frameView) {
524 adjustment += m_frameView->getScrollOffset(); 553 adjustment += m_frameView->getScrollOffset();
525 554
526 // FIXME: Paint invalidation should happen after scroll updates, so there 555 // FIXME: Paint invalidation should happen after scroll updates, so there
527 // should be no pending scroll delta. 556 // should be no pending scroll delta.
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 bool LayoutView::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { 1076 bool LayoutView::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const {
1048 // Frame scroll corner is painted using LayoutView as the display item client. 1077 // Frame scroll corner is painted using LayoutView as the display item client.
1049 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() && 1078 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
1050 (frameView()->horizontalScrollbar() || frameView()->verticalScrollbar())) 1079 (frameView()->horizontalScrollbar() || frameView()->verticalScrollbar()))
1051 return false; 1080 return false;
1052 1081
1053 return LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); 1082 return LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize();
1054 } 1083 }
1055 1084
1056 } // namespace blink 1085 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.h ('k') | third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698