Skip to content

Commit 5561fd3

Browse files
committed
WebCore::Page becomes a RefPtr
1 parent 71b4344 commit 5561fd3

File tree

9 files changed

+43
-42
lines changed

9 files changed

+43
-42
lines changed

Source/WebKitLegacy/qt/Api/qwebhistory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ void QWebHistoryPrivate::goToItem(RefPtr<WebCore::HistoryItem>&& item)
596596
if (!item)
597597
return;
598598

599-
WebCore::Page* page = lst->page().page;
599+
auto page = lst->page().page;
600600
page->goToItem(*item, WebCore::FrameLoadType::IndexedBackForward, WebCore::ShouldTreatAsContinuingLoad::No);
601601
}
602602

Source/WebKitLegacy/qt/WebCoreSupport/ChromeClientQt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Page* ChromeClientQt::createWindow(LocalFrame& frame, const WindowFeatures& feat
189189
if (!newPage)
190190
return 0;
191191

192-
return newPage->page;
192+
return newPage->page.get();
193193
}
194194

195195
void ChromeClientQt::show()

Source/WebKitLegacy/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPageAdapter
340340

341341
void DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior(QWebPageAdapter* adapter)
342342
{
343-
Page* corePage = adapter->page;
343+
RefPtr corePage = adapter->page;
344344
if (!corePage)
345345
return;
346346
corePage->settings().setEditingBehaviorType(EditingBehaviorType::Windows);
@@ -479,53 +479,53 @@ void DumpRenderTreeSupportQt::scalePageBy(QWebFrameAdapter* adapter, float scale
479479
void DumpRenderTreeSupportQt::setMockDeviceOrientation(QWebPageAdapter* adapter, bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
480480
{
481481
#if ENABLE(DEVICE_ORIENTATION)
482-
Page* corePage = adapter->page;
483-
DeviceOrientationClientMock* mockClient = toDeviceOrientationClientMock(DeviceOrientationController::from(corePage)->deviceOrientationClient());
482+
RefPtr corePage = adapter->page;
483+
DeviceOrientationClientMock* mockClient = toDeviceOrientationClientMock(DeviceOrientationController::from(corePage.get())->deviceOrientationClient());
484484
mockClient->setOrientation(DeviceOrientationData::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma));
485485
#endif
486486
}
487487

488488
void DumpRenderTreeSupportQt::resetGeolocationMock(QWebPageAdapter* adapter)
489489
{
490490
#if ENABLE(GEOLOCATION)
491-
Page* corePage = adapter->page;
492-
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client());
491+
RefPtr corePage = adapter->page;
492+
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage.get())->client());
493493
mockClient.reset();
494494
#endif
495495
}
496496

497497
void DumpRenderTreeSupportQt::setMockGeolocationPermission(QWebPageAdapter* adapter, bool allowed)
498498
{
499499
#if ENABLE(GEOLOCATION)
500-
Page* corePage = adapter->page;
501-
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client());
500+
RefPtr corePage = adapter->page;
501+
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage.get())->client());
502502
mockClient.setPermission(allowed);
503503
#endif
504504
}
505505

506506
void DumpRenderTreeSupportQt::setMockGeolocationPosition(QWebPageAdapter* adapter, double latitude, double longitude, double accuracy)
507507
{
508508
#if ENABLE(GEOLOCATION)
509-
Page* corePage = adapter->page;
510-
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client());
509+
RefPtr corePage = adapter->page;
510+
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage.get())->client());
511511
mockClient.setPosition(GeolocationPositionData { WallTime::now().secondsSinceEpoch().seconds(), latitude, longitude, accuracy });
512512
#endif
513513
}
514514

515515
void DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(QWebPageAdapter* adapter, const QString& message)
516516
{
517517
#if ENABLE(GEOLOCATION)
518-
Page* corePage = adapter->page;
519-
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client());
518+
RefPtr corePage = adapter->page;
519+
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage.get())->client());
520520
mockClient.setPositionUnavailableError(message);
521521
#endif
522522
}
523523

524524
int DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(QWebPageAdapter* adapter)
525525
{
526526
#if ENABLE(GEOLOCATION)
527-
Page* corePage = adapter->page;
528-
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage)->client());
527+
RefPtr corePage = adapter->page;
528+
auto& mockClient = toGeolocationClientMock(GeolocationController::from(corePage.get())->client());
529529
return mockClient.numberOfPendingPermissionRequests();
530530
#else
531531
return -1;
@@ -616,14 +616,14 @@ void DumpRenderTreeSupportQt::simulateDesktopNotificationClick(const QString& ti
616616

617617
void DumpRenderTreeSupportQt::setDefersLoading(QWebPageAdapter* adapter, bool flag)
618618
{
619-
Page* corePage = adapter->page;
619+
RefPtr corePage = adapter->page;
620620
if (corePage)
621621
corePage->setDefersLoading(flag);
622622
}
623623

624624
void DumpRenderTreeSupportQt::goBack(QWebPageAdapter* adapter)
625625
{
626-
Page* corePage = adapter->page;
626+
RefPtr corePage = adapter->page;
627627
if (corePage)
628628
corePage->backForward().goBack();
629629
}
@@ -649,7 +649,7 @@ void DumpRenderTreeSupportQt::addURLToRedirect(const QString& origin, const QStr
649649

650650
void DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(QWebPageAdapter* adapter, bool enable)
651651
{
652-
Page* corePage = adapter->page;
652+
RefPtr corePage = adapter->page;
653653
if (corePage)
654654
corePage->settings().setInteractiveFormValidationEnabled(enable);
655655
}
@@ -661,7 +661,7 @@ QStringList DumpRenderTreeSupportQt::contextMenu(QWebPageAdapter* page)
661661

662662
bool DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(QWebPageAdapter *adapter, const QUrl& url, const QUrl& firstPartyUrl)
663663
{
664-
Page* corePage = adapter->page;
664+
RefPtr corePage = adapter->page;
665665
auto* localFrame = dynamicDowncast<LocalFrame>(corePage->mainFrame());
666666
if (!localFrame)
667667
return false;

Source/WebKitLegacy/qt/WebCoreSupport/EditorClientQt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ bool EditorClientQt::shouldInsertNode(Node& node, const std::optional<SimpleRang
310310

311311
bool EditorClientQt::smartInsertDeleteEnabled()
312312
{
313-
Page* page = m_page->page;
313+
RefPtr page = m_page->page;
314314
if (!page)
315315
return false;
316316
return page->settings().smartInsertDeleteEnabled();
@@ -319,7 +319,7 @@ bool EditorClientQt::smartInsertDeleteEnabled()
319319
#if USE(AUTOMATIC_TEXT_REPLACEMENT)
320320
void EditorClientQt::toggleSmartInsertDelete()
321321
{
322-
Page* page = m_page->page;
322+
RefPtr page = m_page->page;
323323
if (page) {
324324
page->settings().setSmartInsertDeleteEnabled(!page->settings().smartInsertDeleteEnabled());
325325
page->settings().setSelectTrailingWhitespaceEnabled(!page->settings().selectTrailingWhitespaceEnabled());
@@ -329,7 +329,7 @@ void EditorClientQt::toggleSmartInsertDelete()
329329

330330
bool EditorClientQt::isSelectTrailingWhitespaceEnabled() const
331331
{
332-
Page* page = m_page->page;
332+
RefPtr page = m_page->page;
333333
if (!page)
334334
return false;
335335
return page->settings().selectTrailingWhitespaceEnabled();

Source/WebKitLegacy/qt/WebCoreSupport/GeolocationClientQt.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ void GeolocationClientQt::positionUpdated(const QGeoPositionInfo& geoPosition)
9090
if (providesSpeed)
9191
m_lastPosition->speed = speed;
9292

93-
WebCore::Page* page = m_webPage->page;
94-
GeolocationController::from(page)->positionChanged(m_lastPosition);
93+
RefPtr page = m_webPage->page;
94+
GeolocationController::from(page.get())->positionChanged(m_lastPosition);
9595
}
9696

9797
void GeolocationClientQt::startUpdating(const String&, bool)
@@ -100,9 +100,9 @@ void GeolocationClientQt::startUpdating(const String&, bool)
100100
connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
101101

102102
if (!m_location) {
103-
WebCore::Page* page = m_webPage->page;
103+
RefPtr page = m_webPage->page;
104104
auto error = GeolocationError::create(GeolocationError::PositionUnavailable, String::fromLatin1(failedToStartServiceErrorMessage));
105-
GeolocationController::from(page)->errorOccurred(error.get());
105+
GeolocationController::from(page.get())->errorOccurred(error.get());
106106
return;
107107
}
108108

Source/WebKitLegacy/qt/WebCoreSupport/InspectorClientQt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Inspector::FrontendChannel* InspectorClientQt::openLocalFrontend(WebCore::Inspec
184184

185185
// Is 'controller' the same object as 'inspectorController' (which appears to be unused)?
186186
InspectorController& controller = inspectorPage->page->inspectorController();
187-
m_frontendClient = std::make_unique<InspectorFrontendClientQt>(m_inspectedWebPage, inspectorController, WTFMove(inspectorView), inspectorPage->page, this);
187+
m_frontendClient = std::make_unique<InspectorFrontendClientQt>(m_inspectedWebPage, inspectorController, WTFMove(inspectorView), inspectorPage->page.get(), this);
188188
controller.setInspectorFrontendClient(m_frontendClient.get());
189189
m_frontendWebPage = inspectorPage;
190190

Source/WebKitLegacy/qt/WebCoreSupport/QWebFrameAdapter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ qreal QWebFrameAdapter::zoomFactor() const
333333

334334
void QWebFrameAdapter::init(QWebPageAdapter* pageAdapter)
335335
{
336-
QWebFrameData frameData(pageAdapter->page);
336+
QWebFrameData frameData(pageAdapter->page.get());
337337
init(pageAdapter, &frameData);
338338
}
339339

Source/WebKitLegacy/qt/WebCoreSupport/QWebPageAdapter.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static Ref<WebCore::LocalWebLockRegistry> getOrCreateWebLockRegistry(bool isPriv
251251

252252
QWebPageAdapter::QWebPageAdapter()
253253
: settings(0)
254-
, page(0)
254+
, page(nullptr)
255255
, pluginFactory(0)
256256
, forwardUnsupportedContent(false)
257257
, insideOpenCall(false)
@@ -311,18 +311,18 @@ void QWebPageAdapter::initializeWebCorePage()
311311
pageConfiguration.storageNamespaceProvider = WebKitLegacy::WebStorageNamespaceProvider::create(
312312
QWebSettings::globalSettings()->localStoragePath());
313313
pageConfiguration.visitedLinkStore = &VisitedLinkStoreQt::singleton();
314-
page = new Page(WTFMove(pageConfiguration));
314+
page = WebCore::Page::create(WTFMove(pageConfiguration));
315315

316316
#if ENABLE(GEOLOCATION)
317317
if (useMock) {
318318
// In case running in DumpRenderTree mode set the controller to mock provider.
319319
GeolocationClientMock* mock = new GeolocationClientMock;
320-
WebCore::provideGeolocationTo(page, *mock);
321-
mock->setController(WebCore::GeolocationController::from(page));
320+
WebCore::provideGeolocationTo(page.get(), *mock);
321+
mock->setController(WebCore::GeolocationController::from(page.get()));
322322
}
323323
#if HAVE(QTPOSITIONING)
324324
else
325-
WebCore::provideGeolocationTo(page, *new GeolocationClientQt(this));
325+
WebCore::provideGeolocationTo(page.get(), *new GeolocationClientQt(this));
326326
#endif
327327
#endif
328328

@@ -338,9 +338,9 @@ void QWebPageAdapter::initializeWebCorePage()
338338
}
339339
#endif
340340
if (m_deviceOrientationClient)
341-
WebCore::provideDeviceOrientationTo(page, m_deviceOrientationClient);
341+
WebCore::provideDeviceOrientationTo(page.get(), m_deviceOrientationClient);
342342
if (m_deviceMotionClient)
343-
WebCore::provideDeviceMotionTo(page, m_deviceMotionClient);
343+
WebCore::provideDeviceMotionTo(page.get(), m_deviceMotionClient);
344344
#endif
345345

346346
// By default each page is put into their own unique page group, which affects popup windows
@@ -352,18 +352,17 @@ void QWebPageAdapter::initializeWebCorePage()
352352

353353
page->addLayoutMilestones(WebCore::LayoutMilestone::DidFirstVisuallyNonEmptyLayout);
354354

355-
settings = new QWebSettings(page);
355+
settings = new QWebSettings(page.get());
356356

357357
#if ENABLE(NOTIFICATIONS)
358-
WebCore::provideNotification(page, NotificationPresenterClientQt::notificationPresenter());
358+
WebCore::provideNotification(page.get(), NotificationPresenterClientQt::notificationPresenter());
359359
#endif
360360

361361
history.d = new QWebHistoryPrivate(static_cast<BackForwardList*>(&page->backForward().client()));
362362
}
363363

364364
QWebPageAdapter::~QWebPageAdapter()
365365
{
366-
delete page;
367366
delete settings;
368367

369368
#if ENABLE(NOTIFICATIONS)
@@ -380,8 +379,7 @@ void QWebPageAdapter::deletePage()
380379
// Before we delete the page, detach the mainframe's loader
381380
FrameLoader& loader = mainFrameAdapter().frame->loader();
382381
loader.detachFromParent();
383-
delete page;
384-
page = 0;
382+
page = nullptr;
385383
}
386384

387385
QWebPageAdapter* QWebPageAdapter::kit(Page* page)
@@ -996,7 +994,7 @@ QWebHitTestResultPrivate* QWebPageAdapter::updatePositionDependentMenuActions(co
996994
WebCore::ContextMenu* webcoreMenu = page->contextMenuController().contextMenu();
997995
QList<MenuItem> itemDescriptions;
998996
if (client && webcoreMenu)
999-
itemDescriptions = descriptionForPlatformMenu(webcoreMenu->items(), page);
997+
itemDescriptions = descriptionForPlatformMenu(webcoreMenu->items(), page.get());
1000998
createAndSetCurrentContextMenu(itemDescriptions, visitedWebActions);
1001999
if (result.scrollbar())
10021000
return 0;

Source/WebKitLegacy/qt/WebCoreSupport/QWebPageAdapter.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "qwebelement.h"
2424
#include "qwebhistory.h"
2525

26+
#include <WebCore/Page.h>
27+
#include <wtf/RefPtr.h>
28+
2629
#include <memory>
2730
#include <qbasictimer.h>
2831
#include <qevent.h>
@@ -394,7 +397,7 @@ class QWEBKIT_EXPORT QWebPageAdapter {
394397

395398
QWebSettings *settings;
396399

397-
WebCore::Page *page;
400+
RefPtr<WebCore::Page> page;
398401
QScopedPointer<QWebPageClient> client;
399402

400403
QWebPluginFactory *pluginFactory;

0 commit comments

Comments
 (0)