-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin moving functions from LocalFrameView to FrameView
https://bugs.webkit.org/show_bug.cgi?id=265709 rdar://119058105 Reviewed by Alex Christensen. * Source/WebCore/Sources.txt: * Source/WebCore/page/Frame.cpp: (WebCore::Frame::ownerRenderer const): * Source/WebCore/page/Frame.h: * Source/WebCore/page/FrameView.cpp: Added. (WebCore::FrameView::headerHeight const): (WebCore::FrameView::footerHeight const): (WebCore::FrameView::topContentInset const): (WebCore::FrameView::visibleContentScaleFactor const): (WebCore::FrameView::isActive const): (WebCore::FrameView::enclosingScrollableArea const): (WebCore::FrameView::invalidateRect): (WebCore::FrameView::forceUpdateScrollbarsOnMainThreadForPerformanceTesting const): (WebCore::FrameView::scrollableAreaBoundingBox const): (WebCore::FrameView::hostWindow const): (WebCore::FrameView::scrollbarStyleChanged): (WebCore::FrameView::scrollAnimatorEnabled const): (WebCore::FrameView::convertFromRendererToContainingView const): (WebCore::FrameView::convertFromContainingViewToRenderer const): (WebCore::FrameView::convertToContainingView const): (WebCore::FrameView::convertFromContainingView const): * Source/WebCore/page/FrameView.h: * Source/WebCore/page/InteractionRegion.cpp: (WebCore::interactionRegionForRenderedRegion): * Source/WebCore/page/LocalFrame.cpp: (WebCore::LocalFrame::ownerRenderer const): Deleted. * Source/WebCore/page/LocalFrame.h: * Source/WebCore/page/LocalFrameView.cpp: (WebCore::LocalFrameView::invalidateRect): Deleted. (WebCore::LocalFrameView::headerHeight const): Deleted. (WebCore::LocalFrameView::footerHeight const): Deleted. (WebCore::LocalFrameView::topContentInset const): Deleted. (WebCore::LocalFrameView::hostWindow const): Deleted. (WebCore::LocalFrameView::isActive const): Deleted. (WebCore::LocalFrameView::forceUpdateScrollbarsOnMainThreadForPerformanceTesting const): Deleted. (WebCore::LocalFrameView::visibleContentScaleFactor const): Deleted. (WebCore::LocalFrameView::enclosingScrollableArea const): Deleted. (WebCore::LocalFrameView::scrollableAreaBoundingBox const): Deleted. (WebCore::LocalFrameView::scrollbarStyleChanged): Deleted. (WebCore::LocalFrameView::scrollAnimatorEnabled const): Deleted. (WebCore::LocalFrameView::convertFromRendererToContainingView const): Deleted. (WebCore::LocalFrameView::convertFromContainingViewToRenderer const): Deleted. (WebCore::LocalFrameView::convertToContainingView const): Deleted. (WebCore::LocalFrameView::convertFromContainingView const): Deleted. * Source/WebCore/page/LocalFrameView.h: * Source/WebCore/page/RemoteFrameView.cpp: (WebCore::RemoteFrameView::invalidateRect): Deleted. (WebCore::RemoteFrameView::isActive const): Deleted. (WebCore::RemoteFrameView::forceUpdateScrollbarsOnMainThreadForPerformanceTesting const): Deleted. (WebCore::RemoteFrameView::enclosingScrollableArea const): Deleted. (WebCore::RemoteFrameView::scrollableAreaBoundingBox const): Deleted. (WebCore::RemoteFrameView::hostWindow const): Deleted. * Source/WebCore/page/RemoteFrameView.h: Canonical link: https://commits.webkit.org/271493@main
- Loading branch information
1 parent
fce14d4
commit 10d1e74
Showing
12 changed files
with
431 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,344 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "FrameView.h" | ||
|
||
#include "Chrome.h" | ||
#include "ChromeClient.h" | ||
#include "FocusController.h" | ||
#include "Frame.h" | ||
#include "HTMLFrameOwnerElement.h" | ||
#include "Page.h" | ||
#include "RenderElement.h" | ||
#include "RenderLayer.h" | ||
#include "RenderLayerScrollableArea.h" | ||
#include "RenderWidget.h" | ||
|
||
namespace WebCore { | ||
|
||
int FrameView::headerHeight() const | ||
{ | ||
Ref frame = this->frame(); | ||
if (!frame->isMainFrame()) | ||
return 0; | ||
Page* page = frame->page(); | ||
return page ? page->headerHeight() : 0; | ||
} | ||
|
||
int FrameView::footerHeight() const | ||
{ | ||
Ref frame = this->frame(); | ||
if (!frame->isMainFrame()) | ||
return 0; | ||
Page* page = frame->page(); | ||
return page ? page->footerHeight() : 0; | ||
} | ||
|
||
float FrameView::topContentInset(TopContentInsetType contentInsetTypeToReturn) const | ||
{ | ||
if (platformWidget() && contentInsetTypeToReturn == TopContentInsetType::WebCoreOrPlatformContentInset) | ||
return platformTopContentInset(); | ||
|
||
Ref frame = this->frame(); | ||
if (!frame->isMainFrame()) | ||
return 0; | ||
|
||
Page* page = frame->page(); | ||
return page ? page->topContentInset() : 0; | ||
} | ||
|
||
float FrameView::visibleContentScaleFactor() const | ||
{ | ||
Ref frame = this->frame(); | ||
if (!frame->isMainFrame()) | ||
return 1; | ||
|
||
Page* page = frame->page(); | ||
// FIXME: This !delegatesScaling() is confusing, and the opposite behavior to Frame::frameScaleFactor(). | ||
// This function should probably be renamed to delegatedPageScaleFactor(). | ||
if (!page || !page->delegatesScaling()) | ||
return 1; | ||
|
||
return page->pageScaleFactor(); | ||
} | ||
|
||
bool FrameView::isActive() const | ||
{ | ||
Page* page = frame().page(); | ||
return page && page->focusController().isActive(); | ||
} | ||
|
||
ScrollableArea* FrameView::enclosingScrollableArea() const | ||
{ | ||
Ref frame = this->frame(); | ||
if (frame->isMainFrame()) | ||
return nullptr; | ||
|
||
auto* ownerElement = frame->ownerElement(); | ||
if (!ownerElement) | ||
return nullptr; | ||
|
||
auto* ownerRenderer = ownerElement->renderer(); | ||
if (!ownerRenderer) | ||
return nullptr; | ||
|
||
auto* layer = ownerRenderer->enclosingLayer(); | ||
if (!layer) | ||
return nullptr; | ||
|
||
auto* enclosingScrollableLayer = layer->enclosingScrollableLayer(IncludeSelfOrNot::IncludeSelf, CrossFrameBoundaries::No); | ||
if (!enclosingScrollableLayer) | ||
return nullptr; | ||
|
||
return enclosingScrollableLayer->scrollableArea(); | ||
} | ||
|
||
void FrameView::invalidateRect(const IntRect& rect) | ||
{ | ||
Ref frame = this->frame(); | ||
if (!parent()) { | ||
if (auto* page = frame->page()) | ||
page->chrome().invalidateContentsAndRootView(rect); | ||
return; | ||
} | ||
|
||
auto* renderer = frame->ownerRenderer(); | ||
if (!renderer) | ||
return; | ||
|
||
IntRect repaintRect = rect; | ||
repaintRect.moveBy(roundedIntPoint(renderer->contentBoxLocation())); | ||
renderer->repaintRectangle(repaintRect); | ||
} | ||
|
||
bool FrameView::forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const | ||
{ | ||
Page* page = frame().page(); | ||
return page && page->settings().scrollingPerformanceTestingEnabled(); | ||
} | ||
|
||
IntRect FrameView::scrollableAreaBoundingBox(bool*) const | ||
{ | ||
RenderWidget* ownerRenderer = frame().ownerRenderer(); | ||
if (!ownerRenderer) | ||
return frameRect(); | ||
|
||
return ownerRenderer->absoluteContentQuad().enclosingBoundingBox(); | ||
} | ||
|
||
HostWindow* FrameView::hostWindow() const | ||
{ | ||
auto* page = frame().page(); | ||
return page ? &page->chrome() : nullptr; | ||
} | ||
|
||
void FrameView::scrollbarStyleChanged(ScrollbarStyle newStyle, bool forceUpdate) | ||
{ | ||
Ref frame = this->frame(); | ||
if (!frame->isMainFrame()) | ||
return; | ||
|
||
if (Page* page = frame->page()) | ||
page->chrome().client().recommendedScrollbarStyleDidChange(newStyle); | ||
|
||
ScrollView::scrollbarStyleChanged(newStyle, forceUpdate); | ||
} | ||
|
||
bool FrameView::scrollAnimatorEnabled() const | ||
{ | ||
if (auto* page = frame().page()) | ||
return page->settings().scrollAnimatorEnabled(); | ||
|
||
return false; | ||
} | ||
|
||
IntRect FrameView::convertFromRendererToContainingView(const RenderElement* renderer, const IntRect& rendererRect) const | ||
{ | ||
IntRect rect = snappedIntRect(enclosingLayoutRect(renderer->localToAbsoluteQuad(FloatRect(rendererRect)).boundingBox())); | ||
|
||
return contentsToView(rect); | ||
} | ||
|
||
IntRect FrameView::convertFromContainingViewToRenderer(const RenderElement* renderer, const IntRect& viewRect) const | ||
{ | ||
IntRect rect = viewToContents(viewRect); | ||
|
||
// FIXME: we don't have a way to map an absolute rect down to a local quad, so just | ||
// move the rect for now. | ||
rect.setLocation(roundedIntPoint(renderer->absoluteToLocal(rect.location(), UseTransforms))); | ||
return rect; | ||
} | ||
|
||
FloatRect FrameView::convertFromContainingViewToRenderer(const RenderElement* renderer, const FloatRect& viewRect) const | ||
{ | ||
FloatRect rect = viewToContents(viewRect); | ||
|
||
return (renderer->absoluteToLocalQuad(rect)).boundingBox(); | ||
} | ||
|
||
IntPoint FrameView::convertFromRendererToContainingView(const RenderElement* renderer, const IntPoint& rendererPoint) const | ||
{ | ||
IntPoint point = roundedIntPoint(renderer->localToAbsolute(rendererPoint, UseTransforms)); | ||
|
||
return contentsToView(point); | ||
} | ||
|
||
FloatPoint FrameView::convertFromRendererToContainingView(const RenderElement* renderer, const FloatPoint& rendererPoint) const | ||
{ | ||
return contentsToView(renderer->localToAbsolute(rendererPoint, UseTransforms)); | ||
} | ||
|
||
IntPoint FrameView::convertFromContainingViewToRenderer(const RenderElement* renderer, const IntPoint& viewPoint) const | ||
{ | ||
IntPoint point = viewPoint; | ||
|
||
// Convert from FrameView coords into page ("absolute") coordinates. | ||
if (!delegatesScrollingToNativeView()) | ||
point = viewToContents(point); | ||
|
||
return roundedIntPoint(renderer->absoluteToLocal(point, UseTransforms)); | ||
} | ||
|
||
IntRect FrameView::convertToContainingView(const IntRect& localRect) const | ||
{ | ||
if (const ScrollView* parentScrollView = parent()) { | ||
if (is<FrameView>(*parentScrollView)) { | ||
const FrameView& parentView = downcast<FrameView>(*parentScrollView); | ||
// Get our renderer in the parent view | ||
RenderWidget* renderer = frame().ownerRenderer(); | ||
if (!renderer) | ||
return localRect; | ||
|
||
auto rect = localRect; | ||
rect.moveBy(roundedIntPoint(renderer->contentBoxLocation())); | ||
return parentView.convertFromRendererToContainingView(renderer, rect); | ||
} | ||
return Widget::convertToContainingView(localRect); | ||
} | ||
return localRect; | ||
} | ||
|
||
IntRect FrameView::convertFromContainingView(const IntRect& parentRect) const | ||
{ | ||
if (const ScrollView* parentScrollView = parent()) { | ||
if (is<FrameView>(*parentScrollView)) { | ||
const FrameView& parentView = downcast<FrameView>(*parentScrollView); | ||
|
||
// Get our renderer in the parent view | ||
RenderWidget* renderer = frame().ownerRenderer(); | ||
if (!renderer) | ||
return parentRect; | ||
|
||
auto rect = parentView.convertFromContainingViewToRenderer(renderer, parentRect); | ||
rect.moveBy(-roundedIntPoint(renderer->contentBoxLocation())); | ||
return rect; | ||
} | ||
return Widget::convertFromContainingView(parentRect); | ||
} | ||
return parentRect; | ||
} | ||
|
||
FloatRect FrameView::convertFromContainingView(const FloatRect& parentRect) const | ||
{ | ||
if (const ScrollView* parentScrollView = parent()) { | ||
if (is<FrameView>(*parentScrollView)) { | ||
const FrameView& parentView = downcast<FrameView>(*parentScrollView); | ||
|
||
// Get our renderer in the parent view | ||
RenderWidget* renderer = frame().ownerRenderer(); | ||
if (!renderer) | ||
return parentRect; | ||
|
||
auto rect = parentView.convertFromContainingViewToRenderer(renderer, parentRect); | ||
rect.moveBy(-renderer->contentBoxLocation()); | ||
return rect; | ||
} | ||
return Widget::convertFromContainingView(parentRect); | ||
} | ||
return parentRect; | ||
} | ||
|
||
IntPoint FrameView::convertToContainingView(const IntPoint& localPoint) const | ||
{ | ||
if (const ScrollView* parentScrollView = parent()) { | ||
if (is<FrameView>(*parentScrollView)) { | ||
const FrameView& parentView = downcast<FrameView>(*parentScrollView); | ||
|
||
// Get our renderer in the parent view | ||
RenderWidget* renderer = frame().ownerRenderer(); | ||
if (!renderer) | ||
return localPoint; | ||
|
||
auto point = localPoint; | ||
point.moveBy(roundedIntPoint(renderer->contentBoxLocation())); | ||
return parentView.convertFromRendererToContainingView(renderer, point); | ||
} | ||
return Widget::convertToContainingView(localPoint); | ||
} | ||
return localPoint; | ||
} | ||
|
||
FloatPoint FrameView::convertToContainingView(const FloatPoint& localPoint) const | ||
{ | ||
if (const ScrollView* parentScrollView = parent()) { | ||
if (is<FrameView>(*parentScrollView)) { | ||
const FrameView& parentView = downcast<FrameView>(*parentScrollView); | ||
|
||
// Get our renderer in the parent view | ||
RenderWidget* renderer = frame().ownerRenderer(); | ||
if (!renderer) | ||
return localPoint; | ||
|
||
auto point = localPoint; | ||
point.moveBy(renderer->contentBoxLocation()); | ||
return parentView.convertFromRendererToContainingView(renderer, point); | ||
} | ||
return Widget::convertToContainingView(localPoint); | ||
} | ||
return localPoint; | ||
} | ||
|
||
IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const | ||
{ | ||
if (const ScrollView* parentScrollView = parent()) { | ||
if (is<FrameView>(*parentScrollView)) { | ||
const FrameView& parentView = downcast<FrameView>(*parentScrollView); | ||
|
||
// Get our renderer in the parent view | ||
RenderWidget* renderer = frame().ownerRenderer(); | ||
if (!renderer) | ||
return parentPoint; | ||
|
||
auto point = parentView.convertFromContainingViewToRenderer(renderer, parentPoint); | ||
point.moveBy(-roundedIntPoint(renderer->contentBoxLocation())); | ||
return point; | ||
} | ||
return Widget::convertFromContainingView(parentPoint); | ||
} | ||
return parentPoint; | ||
} | ||
|
||
} |
Oops, something went wrong.