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

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

Issue 967213004: Removed FrameView's windowToContents and contentsToWindow methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 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
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 RELEASE_ASSERT_NOT_REACHED(); 1719 RELEASE_ASSERT_NOT_REACHED();
1720 } 1720 }
1721 1721
1722 IntRect paintRect = rectInContent; 1722 IntRect paintRect = rectInContent;
1723 if (clipsPaintInvalidations()) 1723 if (clipsPaintInvalidations())
1724 paintRect.intersect(visibleContentRect()); 1724 paintRect.intersect(visibleContentRect());
1725 if (paintRect.isEmpty()) 1725 if (paintRect.isEmpty())
1726 return; 1726 return;
1727 1727
1728 if (HostWindow* window = hostWindow()) 1728 if (HostWindow* window = hostWindow())
1729 window->invalidateRect(contentsToWindow(paintRect)); 1729 window->invalidateRect(contentsToRootFrame(paintRect));
1730 } 1730 }
1731 1731
1732 void FrameView::contentsResized() 1732 void FrameView::contentsResized()
1733 { 1733 {
1734 if (m_frame->isMainFrame() && m_frame->document()) { 1734 if (m_frame->isMainFrame() && m_frame->document()) {
1735 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) 1735 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer())
1736 textAutosizer->updatePageInfoInAllFrames(); 1736 textAutosizer->updatePageInfoInAllFrames();
1737 } 1737 }
1738 1738
1739 ScrollableArea::contentsResized(); 1739 ScrollableArea::contentsResized();
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 m_frame->document()->enqueueAnimationFrameEvent(event.release()); 2143 m_frame->document()->enqueueAnimationFrameEvent(event.release());
2144 } 2144 }
2145 2145
2146 } 2146 }
2147 2147
2148 IntRect FrameView::windowClipRect(IncludeScrollbarsInRect scrollbarInclusion) co nst 2148 IntRect FrameView::windowClipRect(IncludeScrollbarsInRect scrollbarInclusion) co nst
2149 { 2149 {
2150 ASSERT(m_frame->view() == this); 2150 ASSERT(m_frame->view() == this);
2151 2151
2152 // Set our clip rect to be our contents. 2152 // Set our clip rect to be our contents.
2153 IntRect clipRect = contentsToWindow(visibleContentRect(scrollbarInclusion)); 2153 IntRect clipRect = contentsToRootFrame(visibleContentRect(scrollbarInclusion ));
2154 if (!m_frame->deprecatedLocalOwner()) 2154 if (!m_frame->deprecatedLocalOwner())
2155 return clipRect; 2155 return clipRect;
2156 2156
2157 // Take our owner element and get its clip rect. 2157 // Take our owner element and get its clip rect.
2158 // FIXME: Do we need to do this for remote frames? 2158 // FIXME: Do we need to do this for remote frames?
2159 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 2159 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
2160 FrameView* parentView = ownerElement->document().view(); 2160 FrameView* parentView = ownerElement->document().view();
2161 if (parentView) 2161 if (parentView)
2162 clipRect.intersect(parentView->windowClipRectForFrameOwner(ownerElement) ); 2162 clipRect.intersect(parentView->windowClipRectForFrameOwner(ownerElement) );
2163 return clipRect; 2163 return clipRect;
2164 } 2164 }
2165 2165
2166 IntRect FrameView::windowClipRectForFrameOwner(const HTMLFrameOwnerElement* owne rElement) const 2166 IntRect FrameView::windowClipRectForFrameOwner(const HTMLFrameOwnerElement* owne rElement) const
2167 { 2167 {
2168 // The renderer can sometimes be null when style="display:none" interacts 2168 // The renderer can sometimes be null when style="display:none" interacts
2169 // with external content and plugins. 2169 // with external content and plugins.
2170 if (!ownerElement->layoutObject()) 2170 if (!ownerElement->layoutObject())
2171 return windowClipRect(); 2171 return windowClipRect();
2172 2172
2173 // If we have no layer, just return our window clip rect. 2173 // If we have no layer, just return our window clip rect.
2174 const DeprecatedPaintLayer* enclosingLayer = ownerElement->layoutObject()->e nclosingLayer(); 2174 const DeprecatedPaintLayer* enclosingLayer = ownerElement->layoutObject()->e nclosingLayer();
2175 if (!enclosingLayer) 2175 if (!enclosingLayer)
2176 return windowClipRect(); 2176 return windowClipRect();
2177 2177
2178 // FIXME: childrenClipRect relies on compositingState, which is not necessar ily up to date. 2178 // FIXME: childrenClipRect relies on compositingState, which is not necessar ily up to date.
2179 // https://code.google.com/p/chromium/issues/detail?id=343769 2179 // https://code.google.com/p/chromium/issues/detail?id=343769
2180 DisableCompositingQueryAsserts disabler; 2180 DisableCompositingQueryAsserts disabler;
2181 2181
2182 // Apply the clip from the layer. 2182 // Apply the clip from the layer.
2183 IntRect clipRect = contentsToWindow(pixelSnappedIntRect(enclosingLayer->clip per().childrenClipRect())); 2183 IntRect clipRect = contentsToRootFrame(pixelSnappedIntRect(enclosingLayer->c lipper().childrenClipRect()));
2184 return intersection(clipRect, windowClipRect()); 2184 return intersection(clipRect, windowClipRect());
2185 } 2185 }
2186 2186
2187 bool FrameView::shouldUseIntegerScrollOffset() const 2187 bool FrameView::shouldUseIntegerScrollOffset() const
2188 { 2188 {
2189 if (m_frame->settings() && !m_frame->settings()->preferCompositingToLCDTextE nabled()) 2189 if (m_frame->settings() && !m_frame->settings()->preferCompositingToLCDTextE nabled())
2190 return true; 2190 return true;
2191 return false; 2191 return false;
2192 } 2192 }
2193 2193
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 IntPoint framePoint = contentsToFrame(contentsPoint); 3618 IntPoint framePoint = contentsToFrame(contentsPoint);
3619 return convertToContainingWindow(framePoint); 3619 return convertToContainingWindow(framePoint);
3620 } 3620 }
3621 3621
3622 IntRect FrameView::contentsToRootFrame(const IntRect& contentsRect) const 3622 IntRect FrameView::contentsToRootFrame(const IntRect& contentsRect) const
3623 { 3623 {
3624 IntRect rectInFrame = contentsToFrame(contentsRect); 3624 IntRect rectInFrame = contentsToFrame(contentsRect);
3625 return convertToContainingWindow(rectInFrame); 3625 return convertToContainingWindow(rectInFrame);
3626 } 3626 }
3627 3627
3628 IntPoint FrameView::windowToContents(const IntPoint& windowPoint) const 3628 FloatPoint FrameView::rootFrameToContents(const FloatPoint& windowPoint) const
3629 {
3630 IntPoint framePoint = convertFromContainingWindow(windowPoint);
3631 return frameToContents(framePoint);
3632 }
3633
3634 FloatPoint FrameView::windowToContents(const FloatPoint& windowPoint) const
3635 { 3629 {
3636 FloatPoint framePoint = convertFromContainingWindow(windowPoint); 3630 FloatPoint framePoint = convertFromContainingWindow(windowPoint);
3637 return frameToContents(framePoint); 3631 return frameToContents(framePoint);
3638 } 3632 }
3639 3633
3640 IntPoint FrameView::contentsToWindow(const IntPoint& contentsPoint) const 3634 IntRect FrameView::viewportToContents(const IntRect& rectInViewport) const
3641 { 3635 {
3642 IntPoint framePoint = contentsToFrame(contentsPoint); 3636 IntRect rectInRootFrame = page()->frameHost().pinchViewport().viewportToRoot Frame(rectInViewport);
3643 return convertToContainingWindow(framePoint); 3637 IntRect frameRect = convertFromContainingWindow(rectInRootFrame);
3638 return frameToContents(frameRect);
3644 } 3639 }
3645 3640
3646 IntRect FrameView::windowToContents(const IntRect& windowRect) const 3641 IntPoint FrameView::viewportToContents(const IntPoint& pointInViewport) const
3647 { 3642 {
3648 IntRect rectInFrame = convertFromContainingWindow(windowRect); 3643 IntPoint pointInRootFrame = page()->frameHost().pinchViewport().viewportToRo otFrame(pointInViewport);
3649 return frameToContents(rectInFrame); 3644 IntPoint pointInFrame = convertFromContainingWindow(pointInRootFrame);
3645 return frameToContents(pointInFrame);
3650 } 3646 }
3651 3647
3652 IntRect FrameView::contentsToWindow(const IntRect& contentsRect) const 3648 IntRect FrameView::contentsToViewport(const IntRect& rectInContents) const
3653 { 3649 {
3654 IntRect rectInFrame = contentsToFrame(contentsRect); 3650 IntRect rectInFrame = contentsToFrame(rectInContents);
3655 return convertToContainingWindow(rectInFrame); 3651 IntRect rectInRootFrame = convertToContainingWindow(rectInFrame);
3652 return page()->frameHost().pinchViewport().rootFrameToViewport(rectInRootFra me);
3653 }
3654
3655 IntPoint FrameView::contentsToViewport(const IntPoint& pointInContents) const
3656 {
3657 IntPoint pointInFrame = contentsToFrame(pointInContents);
3658 IntPoint pointInRootFrame = convertToContainingWindow(pointInFrame);
3659 return page()->frameHost().pinchViewport().rootFrameToViewport(pointInRootFr ame);
3656 } 3660 }
3657 3661
3658 IntRect FrameView::contentsToScreen(const IntRect& rect) const 3662 IntRect FrameView::contentsToScreen(const IntRect& rect) const
3659 { 3663 {
3660 HostWindow* window = hostWindow(); 3664 HostWindow* window = hostWindow();
3661 if (!window) 3665 if (!window)
3662 return IntRect(); 3666 return IntRect();
3663 return window->viewportToScreen(contentsToWindow(rect)); 3667 return window->viewportToScreen(contentsToViewport(rect));
3668 }
3669
3670 IntRect FrameView::soonToBeRemovedContentsToUnscaledViewport(const IntRect& rect InContents) const
3671 {
3672 IntRect rectInFrame = contentsToFrame(rectInContents);
3673 IntRect rectInRootFrame = convertToContainingWindow(rectInFrame);
3674 return enclosingIntRect(page()->frameHost().pinchViewport().mainViewToViewpo rtCSSPixels(rectInRootFrame));
3675 }
3676
3677 IntPoint FrameView::soonToBeRemovedUnscaledViewportToContents(const IntPoint& po intInViewport) const
3678 {
3679 IntPoint pointInRootFrame = flooredIntPoint(page()->frameHost().pinchViewpor t().viewportCSSPixelsToRootFrame(pointInViewport));
3680 IntPoint pointInThisFrame = convertFromContainingWindow(pointInRootFrame);
3681 return frameToContents(pointInThisFrame);
3664 } 3682 }
3665 3683
3666 bool FrameView::containsScrollbarsAvoidingResizer() const 3684 bool FrameView::containsScrollbarsAvoidingResizer() const
3667 { 3685 {
3668 return !m_scrollbarsAvoidingResizer; 3686 return !m_scrollbarsAvoidingResizer;
3669 } 3687 }
3670 3688
3671 void FrameView::adjustScrollbarsAvoidingResizerCount(int overlapDelta) 3689 void FrameView::adjustScrollbarsAvoidingResizerCount(int overlapDelta)
3672 { 3690 {
3673 int oldCount = m_scrollbarsAvoidingResizer; 3691 int oldCount = m_scrollbarsAvoidingResizer;
(...skipping 21 matching lines...) Expand all
3695 if (m_horizontalScrollbar) 3713 if (m_horizontalScrollbar)
3696 m_horizontalScrollbar->invalidate(); 3714 m_horizontalScrollbar->invalidate();
3697 if (m_verticalScrollbar) 3715 if (m_verticalScrollbar)
3698 m_verticalScrollbar->invalidate(); 3716 m_verticalScrollbar->invalidate();
3699 3717
3700 // Invalidate the scroll corner too on unsuppress. 3718 // Invalidate the scroll corner too on unsuppress.
3701 invalidateRect(scrollCornerRect()); 3719 invalidateRect(scrollCornerRect());
3702 } 3720 }
3703 } 3721 }
3704 3722
3705 Scrollbar* FrameView::scrollbarAtWindowPoint(const IntPoint& windowPoint) 3723 Scrollbar* FrameView::scrollbarAtRootFramePoint(const IntPoint& pointInRootFrame )
3706 { 3724 {
3707 IntPoint pointInFrame = convertFromContainingWindow(windowPoint); 3725 IntPoint pointInFrame = convertFromContainingWindow(pointInRootFrame);
3708 return scrollbarAtFramePoint(pointInFrame); 3726 return scrollbarAtFramePoint(pointInFrame);
3709 } 3727 }
3710 3728
3711 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) 3729 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame)
3712 { 3730 {
3713 if (m_horizontalScrollbar && m_horizontalScrollbar->shouldParticipateInHitTe sting() && m_horizontalScrollbar->frameRect().contains(pointInFrame)) 3731 if (m_horizontalScrollbar && m_horizontalScrollbar->shouldParticipateInHitTe sting() && m_horizontalScrollbar->frameRect().contains(pointInFrame))
3714 return m_horizontalScrollbar.get(); 3732 return m_horizontalScrollbar.get();
3715 if (m_verticalScrollbar && m_verticalScrollbar->shouldParticipateInHitTestin g() && m_verticalScrollbar->frameRect().contains(pointInFrame)) 3733 if (m_verticalScrollbar && m_verticalScrollbar->shouldParticipateInHitTestin g() && m_verticalScrollbar->frameRect().contains(pointInFrame))
3716 return m_verticalScrollbar.get(); 3734 return m_verticalScrollbar.get();
3717 return nullptr; 3735 return nullptr;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3810 void FrameView::invalidateScrollCornerRect(const IntRect& rect) 3828 void FrameView::invalidateScrollCornerRect(const IntRect& rect)
3811 { 3829 {
3812 invalidateRect(rect); 3830 invalidateRect(rect);
3813 } 3831 }
3814 3832
3815 void FrameView::paintPanScrollIcon(GraphicsContext* context) 3833 void FrameView::paintPanScrollIcon(GraphicsContext* context)
3816 { 3834 {
3817 DEFINE_STATIC_REF(Image, panScrollIcon, (Image::loadPlatformResource("panIco n"))); 3835 DEFINE_STATIC_REF(Image, panScrollIcon, (Image::loadPlatformResource("panIco n")));
3818 IntPoint iconGCPoint = m_panScrollIconPoint; 3836 IntPoint iconGCPoint = m_panScrollIconPoint;
3819 if (parent()) 3837 if (parent())
3820 iconGCPoint = toFrameView(parent())->windowToContents(iconGCPoint); 3838 iconGCPoint = toFrameView(parent())->rootFrameToContents(iconGCPoint);
3821 context->drawImage(panScrollIcon, iconGCPoint); 3839 context->drawImage(panScrollIcon, iconGCPoint);
3822 } 3840 }
3823 3841
3824 void FrameView::paint(GraphicsContext* context, const IntRect& rect) 3842 void FrameView::paint(GraphicsContext* context, const IntRect& rect)
3825 { 3843 {
3826 FramePainter(*this).paint(context, rect); 3844 FramePainter(*this).paint(context, rect);
3827 } 3845 }
3828 3846
3829 void FrameView::paintContents(GraphicsContext* context, const IntRect& damageRec t) 3847 void FrameView::paintContents(GraphicsContext* context, const IntRect& damageRec t)
3830 { 3848 {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 { 4049 {
4032 Settings* settings = frame().settings(); 4050 Settings* settings = frame().settings();
4033 if (!settings || !settings->rootLayerScrolls()) 4051 if (!settings || !settings->rootLayerScrolls())
4034 return this; 4052 return this;
4035 4053
4036 LayoutView* layoutView = this->layoutView(); 4054 LayoutView* layoutView = this->layoutView();
4037 return layoutView ? layoutView->scrollableArea() : nullptr; 4055 return layoutView ? layoutView->scrollableArea() : nullptr;
4038 } 4056 }
4039 4057
4040 } // namespace blink 4058 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698