Skip to content

Commit

Permalink
[Site Isolation] Fix some cases where we unnecessarily skip code on o…
Browse files Browse the repository at this point in the history
…ut-of-process frames

https://bugs.webkit.org/show_bug.cgi?id=265563
rdar://118970867

Reviewed by Alex Christensen.

There are several places where we are unnecessarily skipping code on out-of-process frames. We should
avoid downcasting to a local frame if it's not required.

* Source/WebCore/bindings/js/JSLocalDOMWindowCustom.cpp:
(WebCore::jsLocalDOMWindowGetOwnPropertySlotRestrictedAccess):
* Source/WebCore/css/query/MediaQueryFeatures.cpp:
(WebCore::MQ::Features::color):
(WebCore::MQ::Features::dynamicRange):
* Source/WebCore/dom/TreeScope.cpp:
(WebCore::focusedFrameOwnerElement):
* Source/WebCore/html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::didAttachRenderers):
* Source/WebCore/html/MediaElementSession.cpp:
(WebCore::isElementRectMostlyInMainFrame):
* Source/WebCore/inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::canAttachWindow):
(WebCore::InspectorFrontendClientLocal::changeAttachedWindowHeight):

(WebCore::InspectorFrontendClientLocal::changeAttachedWindowWidth):

There is also a behavior change in this function. Previously, we did a null check on `otherMainFrame` and
then used the width on `localMainFrame`, which seemed like a bug.

(WebCore::InspectorFrontendClientLocal::restoreAttachedWindowHeight):
* Source/WebCore/inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::copyText):
* Source/WebCore/inspector/InspectorOverlay.cpp:
(WebCore::localPointToRootPoint):
(WebCore::contentsQuadToCoordinateSystem):
(WebCore::buildRendererHighlight):
(WebCore::drawShapeHighlight):
(WebCore::InspectorOverlay::paint):
(WebCore::InspectorOverlay::highlightQuad):
(WebCore::InspectorOverlay::update):
(WebCore::InspectorOverlay::showPaintRect):
(WebCore::InspectorOverlay::buildGridOverlay):
* Source/WebCore/inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::didPaint):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::completed):
* Source/WebCore/page/DragController.cpp:
(WebCore::DragController::beginDrag):
* Source/WebCore/page/FocusController.cpp:
(WebCore::FocusController::setFocusedInternal):
(WebCore::FocusController::advanceFocusInDocumentOrder):
(WebCore::FocusController::setIsVisibleAndActiveInternal):
* Source/WebCore/page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::computeIntersectionState const):
* Source/WebCore/page/LocalDOMWindow.cpp:
(WebCore::LocalDOMWindow::adjustWindowRect):
(WebCore::LocalDOMWindow::moveTo const):
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::shouldUpdateCompositingLayersAfterScrolling const):
* Source/WebCore/page/Page.cpp:
(WebCore::Page::findString):
(WebCore::Page::screenPropertiesDidChange):
(WebCore::Page::lockAllOverlayScrollbarsToHidden):
(WebCore::Page::setVerticalScrollElasticity):
(WebCore::Page::setDebugger):
(WebCore::Page::subframeCount const):
* Source/WebCore/page/PageOverlay.cpp:
(WebCore::PageOverlay::bounds const):
(WebCore::PageOverlay::drawRect):
* Source/WebCore/page/ResourceUsageOverlay.cpp:
(WebCore::ResourceUsageOverlay::~ResourceUsageOverlay):
(WebCore::ResourceUsageOverlay::mouseEvent):
* Source/WebCore/page/SpatialNavigation.cpp:
(WebCore::rectToAbsoluteCoordinates):
* Source/WebCore/page/mac/DragControllerMac.mm:
(WebCore::DragController::cleanupAfterSystemDrag):
* Source/WebCore/page/mac/ImageOverlayControllerMac.mm:
(WebCore::ImageOverlayController::updateDataDetectorHighlights):
(WebCore::ImageOverlayController::platformHandleMouseEvent):
* Source/WebCore/page/mac/ServicesOverlayController.mm:
(WebCore::ServicesOverlayController::buildSelectionHighlight):
(WebCore::ServicesOverlayController::mouseEvent):
(WebCore::ServicesOverlayController::handleClick):
* Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::setFrameScrollingNodeState):
* Source/WebCore/page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::shouldUpdateScrollLayerPositionSynchronously const):
* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::saveScrollPosition):
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::htmlIFrameElementContentFrame):
* Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::addParametersShared):
* Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp:
(WebKit::createShareableBitmap):
* Source/WebKit/WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::rectsForTextMatchesInRect):
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::size const):
(WebKit::WebFrame::jsContextForServiceWorkerWorld):
(WebKit::WebFrame::contentBounds const):
(WebKit::WebFrame::visibleContentBounds const):
(WebKit::WebFrame::scrollOffset const):
(WebKit::WebFrame::hasVerticalScrollbar const):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::clearMainFrameName):
(WebKit::WebPage::setSize):
(WebKit::WebPage::scaleView):
(WebKit::snapshotColorSpace):

Canonical link: https://commits.webkit.org/271358@main
  • Loading branch information
charliewolfe committed Nov 30, 2023
1 parent 6abbfb0 commit 441ecb3
Show file tree
Hide file tree
Showing 31 changed files with 87 additions and 234 deletions.
5 changes: 2 additions & 3 deletions Source/WebCore/bindings/js/JSLocalDOMWindowCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ bool jsLocalDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMGlobalObject* thisO
// properties that are in Moz but not IE. Since we have some of these, we have to do it
// the Moz way.
// FIXME: Add support to named attributes on RemoteFrames.
auto* frame = window.frame();
if (auto* localFrame = dynamicDowncast<LocalFrame>(frame)) {
if (auto* scopedChild = dynamicDowncast<LocalFrame>(localFrame->tree().scopedChildBySpecifiedName(propertyNameToAtomString(propertyName)))) {
if (RefPtr frame = window.frame()) {
if (auto* scopedChild = dynamicDowncast<LocalFrame>(frame->tree().scopedChildBySpecifiedName(propertyNameToAtomString(propertyName)))) {
slot.setValue(thisObject, PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum, toJS(&lexicalGlobalObject, scopedChild->document()->domWindow()));
return true;
}
Expand Down
8 changes: 2 additions & 6 deletions Source/WebCore/css/query/MediaQueryFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ const FeatureSchema& color()
static MainThreadNeverDestroyed<IntegerSchema> schema {
"color"_s,
[](auto& context) {
if (auto* localFrame = dynamicDowncast<LocalFrame>(context.document.frame()->mainFrame()))
return screenDepthPerComponent(localFrame->view());
return 8;
return screenDepthPerComponent(context.document.frame()->mainFrame().virtualView());
}
};
return schema;
Expand Down Expand Up @@ -351,9 +349,7 @@ const FeatureSchema& dynamicRange()
return true;
if (frame.settings().forcedSupportsHighDynamicRangeValue() == ForcedAccessibilityValue::Off)
return false;
if (auto* localFrame = dynamicDowncast<LocalFrame>(frame.mainFrame()))
return screenSupportsHighDynamicRange(localFrame->view());
return false;
return screenSupportsHighDynamicRange(frame.mainFrame().virtualView());
}();

MatchingIdentifiers identifiers { CSSValueStandard };
Expand Down
7 changes: 2 additions & 5 deletions Source/WebCore/dom/TreeScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,8 @@ RefPtr<Element> TreeScope::findAnchor(StringView name)
static Element* focusedFrameOwnerElement(Frame* focusedFrame, LocalFrame* currentFrame)
{
for (; focusedFrame; focusedFrame = focusedFrame->tree().parent()) {
if (focusedFrame->tree().parent() == currentFrame) {
if (auto* localFrame = dynamicDowncast<LocalFrame>(focusedFrame))
return localFrame->ownerElement();
return nullptr;
}
if (focusedFrame->tree().parent() == currentFrame)
return focusedFrame->ownerElement();
}
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/html/HTMLFrameElementBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void HTMLFrameElementBase::didFinishInsertingNode()
void HTMLFrameElementBase::didAttachRenderers()
{
if (RenderWidget* part = renderWidget()) {
if (RefPtr frame = dynamicDowncast<LocalFrame>(contentFrame()))
part->setWidget(frame->view());
if (RefPtr frame = contentFrame())
part->setWidget(frame->virtualView());
}
}

Expand Down
6 changes: 1 addition & 5 deletions Source/WebCore/html/MediaElementSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,11 +1044,7 @@ static bool isElementRectMostlyInMainFrame(const HTMLMediaElement& element)
if (!documentFrame)
return false;

auto* localFrame = dynamicDowncast<LocalFrame>(documentFrame->mainFrame());
if (!localFrame)
return false;

auto mainFrameView = localFrame->view();
RefPtr mainFrameView = documentFrame->mainFrame().virtualView();
if (!mainFrameView)
return false;

Expand Down
21 changes: 6 additions & 15 deletions Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ bool InspectorFrontendClientLocal::canAttachWindow()
return true;

// Don't allow the attach if the window would be too small to accommodate the minimum inspector size.
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_inspectedPageController->inspectedPage().mainFrame());
unsigned inspectedPageHeight = localMainFrame ? localMainFrame->view()->visibleHeight() : 0;
unsigned inspectedPageWidth = localMainFrame ? localMainFrame->view()->visibleWidth() : 0;
Ref mainFrame = m_inspectedPageController->inspectedPage().mainFrame();
unsigned inspectedPageHeight = mainFrame->virtualView()->visibleHeight();
unsigned inspectedPageWidth = mainFrame->virtualView()->visibleWidth();
unsigned maximumAttachedHeight = inspectedPageHeight * maximumAttachedHeightRatio;
return minimumAttachedHeight <= maximumAttachedHeight && minimumAttachedWidth <= inspectedPageWidth;
}
Expand All @@ -251,23 +251,15 @@ void InspectorFrontendClientLocal::setDockingUnavailable(bool unavailable)

void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
{
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_frontendPage->mainFrame());
if (!localMainFrame)
return;
auto* otherMainFrame = dynamicDowncast<LocalFrame>(m_inspectedPageController->inspectedPage().mainFrame());
unsigned totalHeight = localMainFrame->view()->visibleHeight() + (otherMainFrame ? otherMainFrame->view()->visibleHeight() : 0);
unsigned totalHeight = m_frontendPage->mainFrame().virtualView()->visibleHeight() + m_inspectedPageController->inspectedPage().mainFrame().virtualView()->visibleHeight();
unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight);
m_settings->setProperty(inspectorAttachedHeightSetting, String::number(attachedHeight));
setAttachedWindowHeight(attachedHeight);
}

void InspectorFrontendClientLocal::changeAttachedWindowWidth(unsigned width)
{
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_frontendPage->mainFrame());
if (!localMainFrame)
return;
auto* otherMainFrame = dynamicDowncast<LocalFrame>(m_inspectedPageController->inspectedPage().mainFrame());
unsigned totalWidth = localMainFrame->view()->visibleWidth() + (otherMainFrame ? localMainFrame->view()->visibleWidth() : 0);
unsigned totalWidth = m_frontendPage->mainFrame().virtualView()->visibleWidth() + m_inspectedPageController->inspectedPage().mainFrame().virtualView()->visibleWidth();
unsigned attachedWidth = constrainedAttachedWindowWidth(width, totalWidth);
setAttachedWindowWidth(attachedWidth);
}
Expand Down Expand Up @@ -333,8 +325,7 @@ void InspectorFrontendClientLocal::setAttachedWindow(DockSide dockSide)

void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
{
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_inspectedPageController->inspectedPage().mainFrame());
unsigned inspectedPageHeight = localMainFrame ? localMainFrame->view()->visibleHeight() : 0;
unsigned inspectedPageHeight = m_inspectedPageController->inspectedPage().mainFrame().virtualView()->visibleHeight();
String value = m_settings->getProperty(inspectorAttachedHeightSetting);
unsigned preferredHeight = value.isEmpty() ? defaultAttachedHeight : parseIntegerAllowingTrailingJunk<unsigned>(value).value_or(0);

Expand Down
3 changes: 1 addition & 2 deletions Source/WebCore/inspector/InspectorFrontendHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ String InspectorFrontendHost::platformVersionName() const

void InspectorFrontendHost::copyText(const String& text)
{
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_frontendPage->mainFrame());
auto pageID = m_frontendPage && localMainFrame ? localMainFrame->pageID() : std::nullopt;
auto pageID = m_frontendPage ? m_frontendPage->mainFrame().pageID() : std::nullopt;
Pasteboard::createForCopyAndPaste(PagePasteboardContext::create(WTFMove(pageID)))->writePlainText(text, Pasteboard::CannotSmartReplace);
}

Expand Down
40 changes: 9 additions & 31 deletions Source/WebCore/inspector/InspectorOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ static void truncateWithEllipsis(String& string, size_t length)
string = makeString(StringView(string).left(length), horizontalEllipsis);
}

static FloatPoint localPointToRootPoint(const LocalFrameView* view, const FloatPoint& point)
static FloatPoint localPointToRootPoint(const FrameView* view, const FloatPoint& point)
{
return view->contentsToRootView(point);
}

static void contentsQuadToCoordinateSystem(const LocalFrameView* mainView, const LocalFrameView* view, FloatQuad& quad, InspectorOverlay::CoordinateSystem coordinateSystem)
static void contentsQuadToCoordinateSystem(const FrameView* mainView, const LocalFrameView* view, FloatQuad& quad, InspectorOverlay::CoordinateSystem coordinateSystem)
{
quad.setP1(localPointToRootPoint(view, quad.p1()));
quad.setP2(localPointToRootPoint(view, quad.p2()));
Expand Down Expand Up @@ -145,8 +145,7 @@ static void buildRendererHighlight(RenderObject* renderer, const InspectorOverla

highlight.setDataFromConfig(highlightConfig);
auto* containingView = containingFrame->view();
auto* localMainFrame = dynamicDowncast<LocalFrame>(containingFrame->page()->mainFrame());
auto* mainView = localMainFrame ? localMainFrame->view() : nullptr;
auto* mainView = containingFrame->page()->mainFrame().virtualView();

// (Legacy)RenderSVGRoot should be highlighted through the isBox() code path, all other SVG elements should just dump their absoluteQuads().
bool isSVGRenderer = renderer->node() && renderer->node()->isSVGElement() && !renderer->isRenderOrLegacyRenderSVGRoot();
Expand Down Expand Up @@ -319,8 +318,7 @@ static void drawShapeHighlight(GraphicsContext& context, Node& node, InspectorOv
return;

auto* containingView = containingFrame->view();
auto* localMainFrame = dynamicDowncast<LocalFrame>(containingFrame->page()->mainFrame());
auto* mainView = localMainFrame ? localMainFrame->view() : nullptr;
auto* mainView = containingFrame->page()->mainFrame().virtualView();

static constexpr auto shapeHighlightColor = SRGBA<uint8_t> { 96, 82, 127, 204 };

Expand Down Expand Up @@ -402,11 +400,7 @@ void InspectorOverlay::paint(GraphicsContext& context)
if (!shouldShowOverlay())
return;

auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return;

FloatSize viewportSize = localMainFrame->view()->sizeForVisibleContent();
auto viewportSize = m_page.mainFrame().virtualView()->sizeForVisibleContent();

context.clearRect({ FloatPoint::zero(), viewportSize });

Expand Down Expand Up @@ -603,12 +597,8 @@ void InspectorOverlay::highlightNode(Node* node, const InspectorOverlay::Highlig

void InspectorOverlay::highlightQuad(std::unique_ptr<FloatQuad> quad, const InspectorOverlay::Highlight::Config& highlightConfig)
{
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return;

if (highlightConfig.usePageCoordinates)
*quad -= toIntSize(localMainFrame->view()->scrollPosition());
*quad -= toIntSize(m_page.mainFrame().virtualView()->scrollPosition());

m_quadHighlightConfig = highlightConfig;
m_highlightQuad = WTFMove(quad);
Expand Down Expand Up @@ -654,12 +644,7 @@ void InspectorOverlay::update()
return;
}

auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return;

auto* view = localMainFrame->view();
if (!view)
if (!m_page.mainFrame().virtualView())
return;

m_client->highlight();
Expand All @@ -683,11 +668,7 @@ void InspectorOverlay::showPaintRect(const FloatRect& rect)
if (!m_showPaintRects)
return;

auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return;

IntRect rootRect = localMainFrame->view()->contentsToRootView(enclosingIntRect(rect));
auto rootRect = m_page.mainFrame().virtualView()->contentsToRootView(enclosingIntRect(rect));

const auto removeDelay = 250_ms;

Expand Down Expand Up @@ -1530,11 +1511,8 @@ std::optional<InspectorOverlay::Highlight::GridHighlightOverlay> InspectorOverla
}

constexpr auto translucentLabelBackgroundColor = Color::white.colorWithAlphaByte(230);
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return { };

auto* pageView = localMainFrame->view();
RefPtr pageView = m_page.mainFrame().virtualView();
if (!pageView)
return { };
FloatRect viewportBounds = { { 0, 0 }, pageView->sizeForVisibleContent() };
Expand Down
5 changes: 1 addition & 4 deletions Source/WebCore/inspector/agents/InspectorPageAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,7 @@ void InspectorPageAgent::didPaint(RenderObject& renderer, const LayoutRect& rect
Ref localFrame = view->frame();
if (!localFrame->isMainFrame()) {
IntRect rootViewRect = view->contentsToRootView(snappedIntRect(absoluteRect));
auto* localMainFrame = dynamicDowncast<LocalFrame>(localFrame->mainFrame());
if (!localMainFrame)
return;
rootRect = localMainFrame->view()->rootViewToContents(rootViewRect);
rootRect = localFrame->mainFrame().virtualView()->rootViewToContents(rootViewRect);
}

if (m_client->overridesShowPaintRects()) {
Expand Down
6 changes: 2 additions & 4 deletions Source/WebCore/loader/FrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,10 +1265,8 @@ void FrameLoader::completed()
{
Ref frame = m_frame.get();

for (RefPtr descendant = frame->tree().traverseNext(m_frame.ptr()); descendant; descendant = descendant->tree().traverseNext(m_frame.ptr())) {
if (RefPtr localDescendant = dynamicDowncast<LocalFrame>(*descendant))
localDescendant->navigationScheduler().startTimer();
}
for (RefPtr descendant = frame->tree().traverseNext(m_frame.ptr()); descendant; descendant = descendant->tree().traverseNext(m_frame.ptr()))
descendant->navigationScheduler().startTimer();

if (RefPtr parent = m_frame->tree().parent()) {
if (RefPtr localParent = dynamicDowncast<LocalFrame>(parent.releaseNonNull()))
Expand Down
7 changes: 2 additions & 5 deletions Source/WebCore/page/DragController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,12 +1367,9 @@ void DragController::beginDrag(DragItem dragItem, LocalFrame& frame, const IntPo
m_didInitiateDrag = true;
m_dragInitiator = frame.document();

auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return;
// Protect this frame and view, as a load may occur mid drag and attempt to unload this frame
Ref protectedLocalMainFrame(*localMainFrame);
RefPtr viewProtector = protectedLocalMainFrame->view();
Ref protectedLocalMainFrame(m_page.mainFrame());
RefPtr viewProtector = protectedLocalMainFrame->virtualView();

auto mouseDownPointInRootViewCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(mouseDownPoint));
auto mouseDraggedPointInRootViewCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(mouseDraggedPoint));
Expand Down
16 changes: 5 additions & 11 deletions Source/WebCore/page/FocusController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,8 @@ void FocusController::setFocusedInternal(bool focused)
if (!isFocused())
focusedOrMainFrame().eventHandler().stopAutoscrollTimer();

if (!focusedFrame()) {
if (auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame()))
setFocusedFrame(localMainFrame);
}
if (!focusedFrame())
setFocusedFrame(&m_page.mainFrame());

auto* focusedFrame = focusedLocalFrame();
if (focusedFrame && focusedFrame->view()) {
Expand Down Expand Up @@ -632,7 +630,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
return false;

document->setFocusedElement(nullptr);
setFocusedFrame(dynamicDowncast<LocalFrame>(owner.contentFrame()));
setFocusedFrame(owner.contentFrame());
return true;
}

Expand Down Expand Up @@ -1029,17 +1027,13 @@ static void contentAreaDidShowOrHide(ScrollableArea* scrollableArea, bool didSho

void FocusController::setIsVisibleAndActiveInternal(bool contentIsVisible)
{
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return;

auto* view = localMainFrame->view();
auto* view = m_page.mainFrame().virtualView();
if (!view)
return;

contentAreaDidShowOrHide(view, contentIsVisible);

for (Frame* frame = localMainFrame; frame; frame = frame->tree().traverseNext()) {
for (auto* frame = &m_page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
auto* localFrame = dynamicDowncast<LocalFrame>(frame);
if (!localFrame)
continue;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/IntersectionObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ auto IntersectionObserver::computeIntersectionState(const IntersectionObserverRe

ASSERT(frameView.frame().isMainFrame());
// FIXME: Handle the case of an implicit-root observer that has a target in a different frame tree.
if (dynamicDowncast<LocalFrame>(targetRenderer->frame().mainFrame()) != &frameView.frame())
if (targetRenderer->frame().mainFrame() != frameView.frame())
return;

intersectionState.canComputeIntersection = true;
Expand Down
10 changes: 2 additions & 8 deletions Source/WebCore/page/LocalDOMWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,7 @@ void LocalDOMWindow::dispatchAllPendingUnloadEvents()
// 5) Translate the window rect coordinates to be within the coordinate space of the screen.
FloatRect LocalDOMWindow::adjustWindowRect(Page& page, const FloatRect& pendingChanges)
{
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(page.mainFrame());
if (!localMainFrame)
return FloatRect();
FloatRect screen = screenAvailableRect(localMainFrame->view());
FloatRect screen = screenAvailableRect(page.mainFrame().virtualView());
FloatRect window = page.chrome().windowRect();

// Make sure we're in a valid state before adjusting dimensions.
Expand Down Expand Up @@ -1846,11 +1843,8 @@ void LocalDOMWindow::moveTo(int x, int y) const

CheckedPtr page = frame()->page();
auto fr = page->chrome().windowRect();
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(page->mainFrame());
if (!localMainFrame)
return;

auto sr = screenAvailableRect(localMainFrame->view());
auto sr = screenAvailableRect(page->mainFrame().virtualView());
fr.setLocation(sr.location());
auto update = fr;
update.move(x, y);
Expand Down
6 changes: 1 addition & 5 deletions Source/WebCore/page/LocalFrameView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3007,11 +3007,7 @@ bool LocalFrameView::shouldUpdateCompositingLayersAfterScrolling() const
if (!page)
return true;

auto* localMainFrame = dynamicDowncast<LocalFrame>(page->mainFrame());
if (!localMainFrame)
return true;

if (localMainFrame != m_frame.ptr())
if (page->mainFrame() != m_frame)
return true;

auto scrollingCoordinator = this->scrollingCoordinator();
Expand Down
Loading

0 comments on commit 441ecb3

Please sign in to comment.