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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 1516723003: [Element / Autofill] Add boundsInViewportFloat() to fix <input> popup misalignment. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refator to use boundsInViewportFloat() eventually, but keep boundsInViewportInt(). Created 5 years 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 2680
2681 // Convert from FrameView coords into page ("absolute") coordinates. 2681 // Convert from FrameView coords into page ("absolute") coordinates.
2682 rectInContent.moveBy(scrollPosition()); 2682 rectInContent.moveBy(scrollPosition());
2683 2683
2684 // FIXME: we don't have a way to map an absolute rect down to a local quad, so just 2684 // FIXME: we don't have a way to map an absolute rect down to a local quad, so just
2685 // move the rect for now. 2685 // move the rect for now.
2686 rectInContent.setLocation(roundedIntPoint(layoutObject.absoluteToLocal(rectI nContent.location(), UseTransforms))); 2686 rectInContent.setLocation(roundedIntPoint(layoutObject.absoluteToLocal(rectI nContent.location(), UseTransforms)));
2687 return rectInContent; 2687 return rectInContent;
2688 } 2688 }
2689 2689
2690 FloatRect FrameView::convertFromLayoutObject(const LayoutObject& layoutObject, c onst FloatRect& layoutObjectRect) const
2691 {
2692 FloatRect rect = layoutObject.localToAbsoluteQuad(layoutObjectRect).bounding Box();
2693
2694 // Convert from page ("absolute") to FrameView coordinates.
2695 rect.moveBy(-scrollPosition());
2696
2697 return rect;
2698 }
2699
2690 IntPoint FrameView::convertFromLayoutObject(const LayoutObject& layoutObject, co nst IntPoint& layoutObjectPoint) const 2700 IntPoint FrameView::convertFromLayoutObject(const LayoutObject& layoutObject, co nst IntPoint& layoutObjectPoint) const
2691 { 2701 {
2692 IntPoint point = roundedIntPoint(layoutObject.localToAbsolute(layoutObjectPo int, UseTransforms)); 2702 IntPoint point = roundedIntPoint(layoutObject.localToAbsolute(layoutObjectPo int, UseTransforms));
2693 2703
2694 // Convert from page ("absolute") to FrameView coordinates. 2704 // Convert from page ("absolute") to FrameView coordinates.
2695 point.moveBy(-scrollPosition()); 2705 point.moveBy(-scrollPosition());
2696 return point; 2706 return point;
2697 } 2707 }
2698 2708
2699 IntPoint FrameView::convertToLayoutObject(const LayoutObject& layoutObject, cons t IntPoint& framePoint) const 2709 IntPoint FrameView::convertToLayoutObject(const LayoutObject& layoutObject, cons t IntPoint& framePoint) const
(...skipping 17 matching lines...) Expand all
2717 IntRect rect(localRect); 2727 IntRect rect(localRect);
2718 // Add borders and padding?? 2728 // Add borders and padding??
2719 rect.move(layoutObject->borderLeft() + layoutObject->paddingLeft(), 2729 rect.move(layoutObject->borderLeft() + layoutObject->paddingLeft(),
2720 layoutObject->borderTop() + layoutObject->paddingTop()); 2730 layoutObject->borderTop() + layoutObject->paddingTop());
2721 return parentView->convertFromLayoutObject(*layoutObject, rect); 2731 return parentView->convertFromLayoutObject(*layoutObject, rect);
2722 } 2732 }
2723 2733
2724 return localRect; 2734 return localRect;
2725 } 2735 }
2726 2736
2737 FloatRect FrameView::convertToContainingWidget(const FloatRect& localRect) const
2738 {
2739 if (const FrameView* parentView = toFrameView(parent())) {
2740 // Get our layoutObject in the parent view
2741 LayoutPart* layoutObject = m_frame->ownerLayoutObject();
2742 if (!layoutObject)
2743 return localRect;
2744
2745 FloatRect rect(localRect);
2746 // Add borders and padding??
2747 rect.move(layoutObject->borderLeft() + layoutObject->paddingLeft(),
2748 layoutObject->borderTop() + layoutObject->paddingTop());
2749 return parentView->convertFromLayoutObject(*layoutObject, rect);
2750 }
2751
2752 return localRect;
2753 }
2754
2727 IntRect FrameView::convertFromContainingWidget(const IntRect& parentRect) const 2755 IntRect FrameView::convertFromContainingWidget(const IntRect& parentRect) const
2728 { 2756 {
2729 if (const FrameView* parentView = toFrameView(parent())) { 2757 if (const FrameView* parentView = toFrameView(parent())) {
2730 // Get our layoutObject in the parent view 2758 // Get our layoutObject in the parent view
2731 LayoutPart* layoutObject = m_frame->ownerLayoutObject(); 2759 LayoutPart* layoutObject = m_frame->ownerLayoutObject();
2732 if (!layoutObject) 2760 if (!layoutObject)
2733 return parentRect; 2761 return parentRect;
2734 2762
2735 IntRect rect = parentView->convertToLayoutObject(*layoutObject, parentRe ct); 2763 IntRect rect = parentView->convertToLayoutObject(*layoutObject, parentRe ct);
2736 // Subtract borders and padding 2764 // Subtract borders and padding
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 3433
3406 // This call will move children with native widgets (plugins) and invalidate them as well. 3434 // This call will move children with native widgets (plugins) and invalidate them as well.
3407 frameRectsChanged(); 3435 frameRectsChanged();
3408 } 3436 }
3409 3437
3410 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const 3438 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const
3411 { 3439 {
3412 return pointInContentSpace - scrollOffset(); 3440 return pointInContentSpace - scrollOffset();
3413 } 3441 }
3414 3442
3443 FloatPoint FrameView::contentsToFrame(const FloatPoint& pointInContentSpace) con st
3444 {
3445 return FloatPoint(pointInContentSpace - scrollOffset());
3446 }
3447
3415 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const 3448 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const
3416 { 3449 {
3417 return IntRect(contentsToFrame(rectInContentSpace.location()), rectInContent Space.size()); 3450 return IntRect(contentsToFrame(rectInContentSpace.location()), rectInContent Space.size());
3418 } 3451 }
3419 3452
3453 FloatRect FrameView::contentsToFrame(const FloatRect& rectInContentSpace) const
3454 {
3455 return FloatRect(contentsToFrame(rectInContentSpace.location()), rectInConte ntSpace.size());
3456 }
3457
3420 FloatPoint FrameView::frameToContents(const FloatPoint& pointInFrame) const 3458 FloatPoint FrameView::frameToContents(const FloatPoint& pointInFrame) const
3421 { 3459 {
3422 return pointInFrame + scrollOffset(); 3460 return pointInFrame + scrollOffset();
3423 } 3461 }
3424 3462
3425 IntPoint FrameView::frameToContents(const IntPoint& pointInFrame) const 3463 IntPoint FrameView::frameToContents(const IntPoint& pointInFrame) const
3426 { 3464 {
3427 return pointInFrame + scrollOffset(); 3465 return pointInFrame + scrollOffset();
3428 } 3466 }
3429 3467
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3475 return frameToContents(pointInFrame); 3513 return frameToContents(pointInFrame);
3476 } 3514 }
3477 3515
3478 IntRect FrameView::contentsToViewport(const IntRect& rectInContents) const 3516 IntRect FrameView::contentsToViewport(const IntRect& rectInContents) const
3479 { 3517 {
3480 IntRect rectInFrame = contentsToFrame(rectInContents); 3518 IntRect rectInFrame = contentsToFrame(rectInContents);
3481 IntRect rectInRootFrame = convertToRootFrame(rectInFrame); 3519 IntRect rectInRootFrame = convertToRootFrame(rectInFrame);
3482 return m_frame->host()->visualViewport().rootFrameToViewport(rectInRootFrame ); 3520 return m_frame->host()->visualViewport().rootFrameToViewport(rectInRootFrame );
3483 } 3521 }
3484 3522
3523 FloatRect FrameView::contentsToViewport(const FloatRect& rectInContents) const
3524 {
3525 FloatRect rectInFrame = contentsToFrame(rectInContents);
3526 FloatRect rectInRootFrame = convertToRootFrame(rectInFrame);
3527 return m_frame->host()->visualViewport().rootFrameToViewport(rectInRootFrame );
3528 }
3529
3485 IntPoint FrameView::contentsToViewport(const IntPoint& pointInContents) const 3530 IntPoint FrameView::contentsToViewport(const IntPoint& pointInContents) const
3486 { 3531 {
3487 IntPoint pointInFrame = contentsToFrame(pointInContents); 3532 IntPoint pointInFrame = contentsToFrame(pointInContents);
3488 IntPoint pointInRootFrame = convertToRootFrame(pointInFrame); 3533 IntPoint pointInRootFrame = convertToRootFrame(pointInFrame);
3489 return m_frame->host()->visualViewport().rootFrameToViewport(pointInRootFram e); 3534 return m_frame->host()->visualViewport().rootFrameToViewport(pointInRootFram e);
3490 } 3535 }
3491 3536
3492 IntRect FrameView::contentsToScreen(const IntRect& rect) const 3537 IntRect FrameView::contentsToScreen(const IntRect& rect) const
3493 { 3538 {
3494 HostWindow* window = hostWindow(); 3539 HostWindow* window = hostWindow();
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 } 3763 }
3719 3764
3720 IntRect FrameView::convertFromContainingWidgetToScrollbar(const Scrollbar* scrol lbar, const IntRect& parentRect) const 3765 IntRect FrameView::convertFromContainingWidgetToScrollbar(const Scrollbar* scrol lbar, const IntRect& parentRect) const
3721 { 3766 {
3722 IntRect newRect = parentRect; 3767 IntRect newRect = parentRect;
3723 // Scrollbars won't be transformed within us 3768 // Scrollbars won't be transformed within us
3724 newRect.moveBy(-scrollbar->location()); 3769 newRect.moveBy(-scrollbar->location());
3725 return newRect; 3770 return newRect;
3726 } 3771 }
3727 3772
3773 FloatRect FrameView::convertFromScrollbarToContainingWidget(const Scrollbar* scr ollbar, const FloatRect& localRect) const
3774 {
3775 // Scrollbars won't be transformed within us
3776 FloatRect newRect = localRect;
3777 newRect.moveBy(scrollbar->location());
3778 return newRect;
3779 }
3780
3728 // FIXME: test these on windows 3781 // FIXME: test these on windows
3729 IntPoint FrameView::convertFromScrollbarToContainingWidget(const Scrollbar* scro llbar, const IntPoint& localPoint) const 3782 IntPoint FrameView::convertFromScrollbarToContainingWidget(const Scrollbar* scro llbar, const IntPoint& localPoint) const
3730 { 3783 {
3731 // Scrollbars won't be transformed within us 3784 // Scrollbars won't be transformed within us
3732 IntPoint newPoint = localPoint; 3785 IntPoint newPoint = localPoint;
3733 newPoint.moveBy(scrollbar->location()); 3786 newPoint.moveBy(scrollbar->location());
3734 return newPoint; 3787 return newPoint;
3735 } 3788 }
3736 3789
3737 IntPoint FrameView::convertFromContainingWidgetToScrollbar(const Scrollbar* scro llbar, const IntPoint& parentPoint) const 3790 IntPoint FrameView::convertFromContainingWidgetToScrollbar(const Scrollbar* scro llbar, const IntPoint& parentPoint) const
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3985 return m_hiddenForThrottling && m_crossOriginForThrottling; 4038 return m_hiddenForThrottling && m_crossOriginForThrottling;
3986 } 4039 }
3987 4040
3988 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const 4041 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const
3989 { 4042 {
3990 ASSERT(layoutView()); 4043 ASSERT(layoutView());
3991 return *layoutView(); 4044 return *layoutView();
3992 } 4045 }
3993 4046
3994 } // namespace blink 4047 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698