Skip to content

Commit 795dbd9

Browse files
nipunshukla21rreno
authored andcommitted
Web Inspector: InspectorFrontendHost should not call setPageAndTextZoomFactors on the LocalFrame
https://bugs.webkit.org/show_bug.cgi?id=280493 rdar://136798696 Reviewed by BJ Burg. Setting zoom for inspector previously used a function which recursively iterates through the frame stack and sets state. However, we were using a variant which would not zoom into RemoteFrames. This patch changes that to use the function from the UI Process, which can traverse the full frame tree including local and remote frames. * Source/WebCore/inspector/InspectorFrontendClient.h: (WebCore::InspectorFrontendClient::setPageAndTextZoomFactors): (WebCore::InspectorFrontendClient::pageZoomFactor const): * Source/WebCore/inspector/InspectorFrontendHost.cpp: (WebCore::InspectorFrontendHost::setZoomFactor): (WebCore::InspectorFrontendHost::zoomFactor): * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp: (WebKit::RemoteWebInspectorUIProxy::setPageAndTextZoomFactors): * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h: * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in: * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp: (WebKit::WebInspectorUIProxy::setPageAndTextZoomFactors): * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h: * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in: * Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp: (WebKit::RemoteWebInspectorUI::setPageAndTextZoomFactors): (WebKit::RemoteWebInspectorUI::pageZoomFactor const): * Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h: * Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp: (WebKit::WebInspectorUI::setPageAndTextZoomFactors): (WebKit::WebInspectorUI::pageZoomFactor const): * Source/WebKit/WebProcess/Inspector/WebInspectorUI.h: Canonical link: https://commits.webkit.org/301271@main
1 parent 2ad7f50 commit 795dbd9

12 files changed

Lines changed: 62 additions & 10 deletions

Source/WebCore/inspector/InspectorFrontendClient.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ class InspectorFrontendClient : public CanMakeWeakPtr<InspectorFrontendClient> {
150150

151151
virtual void setInspectorPageDeveloperExtrasEnabled(bool) = 0;
152152

153+
virtual void setPageAndTextZoomFactors(double /* pageZoomFactor */, double /* textZoomFactor */) { }
154+
virtual double pageZoomFactor() const { return 1.0; }
155+
153156
#if ENABLE(INSPECTOR_TELEMETRY)
154157
virtual bool supportsDiagnosticLogging() { return false; }
155158
virtual bool diagnosticLoggingAvailable() { return false; }

Source/WebCore/inspector/InspectorFrontendHost.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,13 @@ void InspectorFrontendHost::inspectedURLChanged(const String& newURL)
276276

277277
void InspectorFrontendHost::setZoomFactor(float zoom)
278278
{
279-
if (m_frontendPage) {
280-
if (RefPtr localMainFrame = m_frontendPage->localMainFrame())
281-
localMainFrame->setPageAndTextZoomFactors(zoom, 1);
282-
}
279+
if (m_client)
280+
m_client->setPageAndTextZoomFactors(zoom, 1);
283281
}
284282

285283
float InspectorFrontendHost::zoomFactor()
286284
{
287-
if (m_frontendPage) {
288-
if (RefPtr localMainFrame = m_frontendPage->localMainFrame())
289-
return localMainFrame->pageZoomFactor();
290-
}
291-
292-
return 1.0;
285+
return m_client ? m_client->pageZoomFactor() : 1.0;
293286
}
294287

295288
void InspectorFrontendHost::setForcedAppearance(String appearance)

Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ void RemoteWebInspectorUIProxy::setInspectorPageDeveloperExtrasEnabled(bool enab
220220
inspectorPage->protectedPreferences()->setDeveloperExtrasEnabled(enabled);
221221
}
222222

223+
void RemoteWebInspectorUIProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
224+
{
225+
RefPtr inspectorPage = m_inspectorPage.get();
226+
if (!inspectorPage)
227+
return;
228+
229+
inspectorPage->setPageAndTextZoomFactors(pageZoomFactor, textZoomFactor);
230+
}
231+
223232
void RemoteWebInspectorUIProxy::sendMessageToBackend(const String& message)
224233
{
225234
if (CheckedPtr client = m_client.get())

Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class RemoteWebInspectorUIProxy : public RefCounted<RemoteWebInspectorUIProxy>,
158158
void revealFileExternally(const String& path);
159159
void showCertificate(const WebCore::CertificateInfo&);
160160
void setInspectorPageDeveloperExtrasEnabled(bool);
161+
void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
161162
void sendMessageToBackend(const String& message);
162163

163164
void createFrontendPageAndWindow();

Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ messages -> RemoteWebInspectorUIProxy {
5050
SendMessageToBackend(String message)
5151

5252
SetInspectorPageDeveloperExtrasEnabled(bool enabled)
53+
54+
SetPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
5355
}

Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,15 @@ void WebInspectorUIProxy::setInspectorPageDeveloperExtrasEnabled(bool enabled)
748748
inspectorPage->protectedPreferences()->setDeveloperExtrasEnabled(enabled);
749749
}
750750

751+
void WebInspectorUIProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
752+
{
753+
RefPtr inspectorPage = m_inspectorPage.get();
754+
if (!inspectorPage)
755+
return;
756+
757+
inspectorPage->setPageAndTextZoomFactors(pageZoomFactor, textZoomFactor);
758+
}
759+
751760
void WebInspectorUIProxy::elementSelectionChanged(bool active)
752761
{
753762
m_elementSelectionActive = active;

Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ class WebInspectorUIProxy
290290
void inspectedURLChanged(const String&);
291291
void showCertificate(const WebCore::CertificateInfo&);
292292
void setInspectorPageDeveloperExtrasEnabled(bool);
293+
void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
293294
void elementSelectionChanged(bool);
294295
void timelineRecordingChanged(bool);
295296

Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,6 @@ messages -> WebInspectorUIProxy {
6262
StartWindowDrag()
6363

6464
SetInspectorPageDeveloperExtrasEnabled(bool enabled)
65+
66+
SetPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
6567
}

Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,17 @@ void RemoteWebInspectorUI::setInspectorPageDeveloperExtrasEnabled(bool enabled)
242242
WebProcess::singleton().protectedParentProcessConnection()->send(Messages::RemoteWebInspectorUIProxy::SetInspectorPageDeveloperExtrasEnabled(enabled), m_page->identifier());
243243
}
244244

245+
void RemoteWebInspectorUI::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
246+
{
247+
m_pageZoomFactor = pageZoomFactor;
248+
WebProcess::singleton().protectedParentProcessConnection()->send(Messages::RemoteWebInspectorUIProxy::SetPageAndTextZoomFactors(pageZoomFactor, textZoomFactor), m_page->identifier());
249+
}
250+
251+
double RemoteWebInspectorUI::pageZoomFactor() const
252+
{
253+
return m_pageZoomFactor;
254+
}
255+
245256
Inspector::DebuggableType RemoteWebInspectorUI::debuggableType() const
246257
{
247258
return m_debuggableInfo.debuggableType;

Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ class RemoteWebInspectorUI final
115115
void inspectedURLChanged(const String&) override;
116116
void showCertificate(const WebCore::CertificateInfo&) override;
117117
void setInspectorPageDeveloperExtrasEnabled(bool) override;
118+
119+
void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor) override;
120+
double pageZoomFactor() const override;
121+
118122
void sendMessageToBackend(const String&) override;
119123
WebCore::InspectorFrontendAPIDispatcher& frontendAPIDispatcher() override { return m_frontendAPIDispatcher; }
120124
WebCore::Page* frontendPage() final;
@@ -159,6 +163,8 @@ class RemoteWebInspectorUI final
159163
#if ENABLE(INSPECTOR_TELEMETRY)
160164
bool m_diagnosticLoggingAvailable { false };
161165
#endif
166+
167+
double m_pageZoomFactor { 1.0 };
162168
};
163169

164170
} // namespace WebKit

0 commit comments

Comments
 (0)