Diff
Modified: trunk/Source/WebCore/ChangeLog (237227 => 237228)
--- trunk/Source/WebCore/ChangeLog 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/ChangeLog 2018-10-17 18:11:18 UTC (rev 237228)
@@ -1,3 +1,55 @@
+2018-10-17 Chris Dumez <cdu...@apple.com>
+
+ Update more DOMWindow getters to return references instead of raw pointers
+ https://bugs.webkit.org/show_bug.cgi?id=190654
+
+ Reviewed by Youenn Fablet.
+
+ Update more DOMWindow getters to return references instead of raw pointers, since they
+ can no longer return null after recent refactoring.
+
+ * Modules/gamepad/GamepadManager.cpp:
+ (WebCore::navigatorGamepadFromDOMWindow):
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::JSDOMWindow::heapSnapshot):
+ * dom/Document.cpp:
+ (WebCore::Document::location const):
+ (WebCore::Document::dispatchPopstateEvent):
+ * dom/Event.cpp:
+ (WebCore::Event::timeStampForBindings const):
+ * loader/DocumentThreadableLoader.cpp:
+ (WebCore::DocumentThreadableLoader::loadRequest):
+ * loader/ResourceTimingInformation.cpp:
+ (WebCore::ResourceTimingInformation::addResourceTiming):
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::screen):
+ (WebCore::DOMWindow::history):
+ (WebCore::DOMWindow::crypto const):
+ (WebCore::DOMWindow::locationbar):
+ (WebCore::DOMWindow::menubar):
+ (WebCore::DOMWindow::personalbar):
+ (WebCore::DOMWindow::scrollbars):
+ (WebCore::DOMWindow::statusbar):
+ (WebCore::DOMWindow::toolbar):
+ (WebCore::DOMWindow::applicationCache):
+ (WebCore::DOMWindow::navigator):
+ (WebCore::DOMWindow::performance const):
+ (WebCore::DOMWindow::nowTimestamp const):
+ (WebCore::DOMWindow::location):
+ (WebCore::DOMWindow::visualViewport):
+ (WebCore::DOMWindow::styleMedia):
+ * page/DOMWindow.h:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::updateLayoutViewport):
+ * page/History.cpp:
+ (WebCore::History::stateObjectAdded):
+ * page/IntersectionObserver.cpp:
+ (WebCore::IntersectionObserver::createTimestamp const):
+ * page/PerformanceObserver.cpp:
+ (WebCore::PerformanceObserver::PerformanceObserver):
+ * platform/cocoa/VideoFullscreenModelVideoElement.mm:
+ (WebCore::VideoFullscreenModelVideoElement::requestFullscreenMode):
+
2018-10-17 Chris Fleizach <cfleiz...@apple.com>
AX: Certain tags should identify their context to iOS API
Modified: trunk/Source/WebCore/Modules/gamepad/GamepadManager.cpp (237227 => 237228)
--- trunk/Source/WebCore/Modules/gamepad/GamepadManager.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/Modules/gamepad/GamepadManager.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -43,11 +43,7 @@
static NavigatorGamepad* navigatorGamepadFromDOMWindow(DOMWindow* window)
{
- Navigator* navigator = window->navigator();
- if (!navigator)
- return nullptr;
-
- return NavigatorGamepad::from(navigator);
+ return NavigatorGamepad::from(&window->navigator());
}
GamepadManager& GamepadManager::singleton()
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (237227 => 237228)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -312,8 +312,8 @@
void JSDOMWindow::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
{
JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(cell);
- if (auto* location = thisObject->wrapped().location())
- builder.setLabelForCell(cell, location->href());
+ auto& location = thisObject->wrapped().location();
+ builder.setLabelForCell(cell, location.href());
Base::heapSnapshot(cell, builder);
}
Modified: trunk/Source/WebCore/dom/Document.cpp (237227 => 237228)
--- trunk/Source/WebCore/dom/Document.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/dom/Document.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -2829,10 +2829,7 @@
Location* Document::location() const
{
auto* window = domWindow();
- if (!window)
- return nullptr;
-
- return window->location();
+ return window ? &window->location() : nullptr;
}
HTMLHeadElement* Document::head()
@@ -6110,7 +6107,7 @@
void Document::dispatchPopstateEvent(RefPtr<SerializedScriptValue>&& stateObject)
{
- dispatchWindowEvent(PopStateEvent::create(WTFMove(stateObject), m_domWindow ? m_domWindow->history() : nullptr));
+ dispatchWindowEvent(PopStateEvent::create(WTFMove(stateObject), m_domWindow ? &m_domWindow->history() : nullptr));
}
void Document::addMediaCanStartListener(MediaCanStartListener* listener)
Modified: trunk/Source/WebCore/dom/Event.cpp (237227 => 237228)
--- trunk/Source/WebCore/dom/Event.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/dom/Event.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -151,7 +151,7 @@
if (is<WorkerGlobalScope>(context))
performance = &downcast<WorkerGlobalScope>(context).performance();
else if (auto* window = downcast<Document>(context).domWindow())
- performance = window->performance();
+ performance = &window->performance();
if (!performance)
return 0;
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (237227 => 237228)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -623,8 +623,8 @@
if (options().initiatorContext == InitiatorContext::Worker)
finishedTimingForWorkerLoad(resourceTiming);
else {
- if (document().domWindow() && document().domWindow()->performance())
- document().domWindow()->performance()->addResourceTiming(WTFMove(resourceTiming));
+ if (auto* window = document().domWindow())
+ window->performance().addResourceTiming(WTFMove(resourceTiming));
}
}
Modified: trunk/Source/WebCore/loader/ResourceTimingInformation.cpp (237227 => 237228)
--- trunk/Source/WebCore/loader/ResourceTimingInformation.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/loader/ResourceTimingInformation.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -76,14 +76,14 @@
}
if (!initiatorDocument)
return;
- if (!initiatorDocument->domWindow())
+
+ auto* initiatorWindow = initiatorDocument->domWindow();
+ if (!initiatorWindow)
return;
- if (!initiatorDocument->domWindow()->performance())
- return;
resourceTiming.overrideInitiatorName(info.name);
- initiatorDocument->domWindow()->performance()->addResourceTiming(WTFMove(resourceTiming));
+ initiatorWindow->performance().addResourceTiming(WTFMove(resourceTiming));
info.added = Added;
}
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (237227 => 237228)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -635,67 +635,67 @@
#endif
-Screen* DOMWindow::screen()
+Screen& DOMWindow::screen()
{
if (!m_screen)
m_screen = Screen::create(*this);
- return m_screen.get();
+ return *m_screen;
}
-History* DOMWindow::history()
+History& DOMWindow::history()
{
if (!m_history)
m_history = History::create(*this);
- return m_history.get();
+ return *m_history;
}
-Crypto* DOMWindow::crypto() const
+Crypto& DOMWindow::crypto() const
{
if (!m_crypto)
m_crypto = Crypto::create(document());
- return m_crypto.get();
+ return *m_crypto;
}
-BarProp* DOMWindow::locationbar()
+BarProp& DOMWindow::locationbar()
{
if (!m_locationbar)
m_locationbar = BarProp::create(*this, BarProp::Locationbar);
- return m_locationbar.get();
+ return *m_locationbar;
}
-BarProp* DOMWindow::menubar()
+BarProp& DOMWindow::menubar()
{
if (!m_menubar)
m_menubar = BarProp::create(*this, BarProp::Menubar);
- return m_menubar.get();
+ return *m_menubar;
}
-BarProp* DOMWindow::personalbar()
+BarProp& DOMWindow::personalbar()
{
if (!m_personalbar)
m_personalbar = BarProp::create(*this, BarProp::Personalbar);
- return m_personalbar.get();
+ return *m_personalbar;
}
-BarProp* DOMWindow::scrollbars()
+BarProp& DOMWindow::scrollbars()
{
if (!m_scrollbars)
m_scrollbars = BarProp::create(*this, BarProp::Scrollbars);
- return m_scrollbars.get();
+ return *m_scrollbars;
}
-BarProp* DOMWindow::statusbar()
+BarProp& DOMWindow::statusbar()
{
if (!m_statusbar)
m_statusbar = BarProp::create(*this, BarProp::Statusbar);
- return m_statusbar.get();
+ return *m_statusbar;
}
-BarProp* DOMWindow::toolbar()
+BarProp& DOMWindow::toolbar()
{
if (!m_toolbar)
m_toolbar = BarProp::create(*this, BarProp::Toolbar);
- return m_toolbar.get();
+ return *m_toolbar;
}
PageConsoleClient* DOMWindow::console() const
@@ -707,47 +707,47 @@
return frame->page() ? &frame->page()->console() : nullptr;
}
-DOMApplicationCache* DOMWindow::applicationCache()
+DOMApplicationCache& DOMWindow::applicationCache()
{
if (!m_applicationCache)
m_applicationCache = DOMApplicationCache::create(*this);
- return m_applicationCache.get();
+ return *m_applicationCache;
}
-Navigator* DOMWindow::navigator()
+Navigator& DOMWindow::navigator()
{
if (!m_navigator)
m_navigator = Navigator::create(scriptExecutionContext(), *this);
- return m_navigator.get();
+ return *m_navigator;
}
-Performance* DOMWindow::performance() const
+Performance& DOMWindow::performance() const
{
if (!m_performance) {
MonotonicTime timeOrigin = document() && document()->loader() ? document()->loader()->timing().referenceMonotonicTime() : MonotonicTime::now();
m_performance = Performance::create(document(), timeOrigin);
}
- return m_performance.get();
+ return *m_performance;
}
double DOMWindow::nowTimestamp() const
{
- return performance() ? performance()->now() / 1000 : 0;
+ return performance().now() / 1000.;
}
-Location* DOMWindow::location()
+Location& DOMWindow::location()
{
if (!m_location)
m_location = Location::create(*this);
- return m_location.get();
+ return *m_location;
}
-VisualViewport* DOMWindow::visualViewport()
+VisualViewport& DOMWindow::visualViewport()
{
if (!m_visualViewport)
m_visualViewport = VisualViewport::create(*this);
- return m_visualViewport.get();
+ return *m_visualViewport;
}
#if ENABLE(USER_MESSAGE_HANDLERS)
@@ -1433,11 +1433,11 @@
return downcast<Document>(ContextDestructionObserver::scriptExecutionContext());
}
-RefPtr<StyleMedia> DOMWindow::styleMedia()
+StyleMedia& DOMWindow::styleMedia()
{
if (!m_media)
m_media = StyleMedia::create(*this);
- return m_media;
+ return *m_media;
}
Ref<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element& element, const String& pseudoElt) const
Modified: trunk/Source/WebCore/page/DOMWindow.h (237227 => 237228)
--- trunk/Source/WebCore/page/DOMWindow.h 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/page/DOMWindow.h 2018-10-17 18:11:18 UTC (rev 237228)
@@ -131,20 +131,20 @@
static bool canShowModalDialog(const Frame&);
WEBCORE_EXPORT void setCanShowModalDialogOverride(bool);
- Screen* screen();
- History* history();
- Crypto* crypto() const;
- BarProp* locationbar();
- BarProp* menubar();
- BarProp* personalbar();
- BarProp* scrollbars();
- BarProp* statusbar();
- BarProp* toolbar();
- Navigator* navigator();
+ Screen& screen();
+ History& history();
+ Crypto& crypto() const;
+ BarProp& locationbar();
+ BarProp& menubar();
+ BarProp& personalbar();
+ BarProp& scrollbars();
+ BarProp& statusbar();
+ BarProp& toolbar();
+ Navigator& navigator();
Navigator* optionalNavigator() const { return m_navigator.get(); }
- Navigator* clientInformation() { return navigator(); }
+ Navigator& clientInformation() { return navigator(); }
- Location* location();
+ Location& location();
void setLocation(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& location, SetLocationLocking = LockHistoryBasedOnGestureState);
DOMSelection* getSelection();
@@ -209,7 +209,7 @@
// CSSOM View Module
- RefPtr<StyleMedia> styleMedia();
+ StyleMedia& styleMedia();
// DOM Level 2 Style Interface
@@ -245,7 +245,7 @@
void resizeBy(float x, float y) const;
void resizeTo(float width, float height) const;
- VisualViewport* visualViewport();
+ VisualViewport& visualViewport();
// Timers
ExceptionOr<int> setTimeout(JSC::ExecState&, std::unique_ptr<ScheduledAction>, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
@@ -286,7 +286,7 @@
Storage* optionalSessionStorage() const { return m_sessionStorage.get(); }
Storage* optionalLocalStorage() const { return m_localStorage.get(); }
- DOMApplicationCache* applicationCache();
+ DOMApplicationCache& applicationCache();
DOMApplicationCache* optionalApplicationCache() const { return m_applicationCache.get(); }
CustomElementRegistry* customElementRegistry() { return m_customElementRegistry.get(); }
@@ -302,7 +302,7 @@
int orientation() const;
#endif
- Performance* performance() const;
+ Performance& performance() const;
WEBCORE_EXPORT double nowTimestamp() const;
#if PLATFORM(IOS)
Modified: trunk/Source/WebCore/page/FrameView.cpp (237227 => 237228)
--- trunk/Source/WebCore/page/FrameView.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/page/FrameView.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -1711,10 +1711,8 @@
setLayoutViewportOverrideRect(LayoutRect(newOrigin, m_layoutViewportOverrideRect.value().size()));
}
if (frame().settings().visualViewportAPIEnabled()) {
- if (Document* document = frame().document()) {
- if (VisualViewport* visualViewport = document->domWindow()->visualViewport())
- visualViewport->update();
- }
+ if (auto* window = frame().window())
+ window->visualViewport().update();
}
return;
}
@@ -1725,10 +1723,8 @@
LOG_WITH_STREAM(Scrolling, stream << "layoutViewport changed to " << layoutViewportRect());
}
if (frame().settings().visualViewportAPIEnabled()) {
- if (Document* document = frame().document()) {
- if (VisualViewport* visualViewport = document->domWindow()->visualViewport())
- visualViewport->update();
- }
+ if (auto* window = frame().window())
+ window->visualViewport().update();
}
}
Modified: trunk/Source/WebCore/page/History.cpp (237227 => 237228)
--- trunk/Source/WebCore/page/History.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/page/History.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -208,23 +208,19 @@
if (!allowSandboxException && !documentSecurityOrigin.canRequest(fullURL) && (fullURL.path() != documentURL.path() || fullURL.query() != documentURL.query()))
return createBlockedURLSecurityErrorWithMessageSuffix("Paths and fragments must match for a sandboxed document.");
- Document* mainDocument = frame->page()->mainFrame().document();
- History* mainHistory = nullptr;
- if (mainDocument) {
- if (auto* mainDOMWindow = mainDocument->domWindow())
- mainHistory = mainDOMWindow->history();
- }
-
- if (!mainHistory)
+ auto* mainWindow = frame->page()->mainFrame().window();
+ if (!mainWindow)
return { };
+ auto& mainHistory = mainWindow->history();
+
WallTime currentTimestamp = WallTime::now();
- if (currentTimestamp - mainHistory->m_currentStateObjectTimeSpanStart > stateObjectTimeSpan) {
- mainHistory->m_currentStateObjectTimeSpanStart = currentTimestamp;
- mainHistory->m_currentStateObjectTimeSpanObjectsAdded = 0;
+ if (currentTimestamp - mainHistory.m_currentStateObjectTimeSpanStart > stateObjectTimeSpan) {
+ mainHistory.m_currentStateObjectTimeSpanStart = currentTimestamp;
+ mainHistory.m_currentStateObjectTimeSpanObjectsAdded = 0;
}
- if (mainHistory->m_currentStateObjectTimeSpanObjectsAdded >= perStateObjectTimeSpanLimit) {
+ if (mainHistory.m_currentStateObjectTimeSpanObjectsAdded >= perStateObjectTimeSpanLimit) {
if (stateObjectType == StateObjectType::Replace)
return Exception { SecurityError, String::format("Attempt to use history.replaceState() more than %u times per %f seconds", perStateObjectTimeSpanLimit, stateObjectTimeSpan.seconds()) };
return Exception { SecurityError, String::format("Attempt to use history.pushState() more than %u times per %f seconds", perStateObjectTimeSpanLimit, stateObjectTimeSpan.seconds()) };
@@ -240,7 +236,7 @@
payloadSize += urlSize;
payloadSize += data ? data->data().size() : 0;
- Checked<uint64_t> newTotalUsage = mainHistory->m_totalStateObjectUsage;
+ Checked<uint64_t> newTotalUsage = mainHistory.m_totalStateObjectUsage;
if (stateObjectType == StateObjectType::Replace)
newTotalUsage -= m_mostRecentStateObjectUsage;
@@ -254,8 +250,8 @@
m_mostRecentStateObjectUsage = payloadSize.unsafeGet();
- mainHistory->m_totalStateObjectUsage = newTotalUsage.unsafeGet();
- ++mainHistory->m_currentStateObjectTimeSpanObjectsAdded;
+ mainHistory.m_totalStateObjectUsage = newTotalUsage.unsafeGet();
+ ++mainHistory.m_currentStateObjectTimeSpanObjectsAdded;
if (!urlString.isEmpty())
frame->document()->updateURLForPushOrReplaceState(fullURL);
Modified: trunk/Source/WebCore/page/IntersectionObserver.cpp (237227 => 237228)
--- trunk/Source/WebCore/page/IntersectionObserver.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/page/IntersectionObserver.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -236,10 +236,8 @@
ASSERT(context->isDocument());
auto& document = downcast<Document>(*context);
if (auto* window = document.domWindow()) {
- if (auto* performance = window->performance()) {
- timestamp = performance->now();
- return true;
- }
+ timestamp = window->performance().now();
+ return true;
}
return false;
}
Modified: trunk/Source/WebCore/page/PerformanceObserver.cpp (237227 => 237228)
--- trunk/Source/WebCore/page/PerformanceObserver.cpp 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/page/PerformanceObserver.cpp 2018-10-17 18:11:18 UTC (rev 237228)
@@ -40,7 +40,7 @@
if (is<Document>(scriptExecutionContext)) {
auto& document = downcast<Document>(scriptExecutionContext);
if (DOMWindow* window = document.domWindow())
- m_performance = window->performance();
+ m_performance = &window->performance();
} else if (is<WorkerGlobalScope>(scriptExecutionContext)) {
auto& workerGlobalScope = downcast<WorkerGlobalScope>(scriptExecutionContext);
m_performance = &workerGlobalScope.performance();
Modified: trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm (237227 => 237228)
--- trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm 2018-10-17 18:07:26 UTC (rev 237227)
+++ trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm 2018-10-17 18:11:18 UTC (rev 237228)
@@ -150,10 +150,8 @@
if (m_videoElement && finishedWithMedia && mode == MediaPlayerEnums::VideoFullscreenModeNone) {
if (m_videoElement->document().isMediaDocument()) {
- if (DOMWindow* window = m_videoElement->document().domWindow()) {
- if (History* history = window->history())
- history->back();
- }
+ if (auto* window = m_videoElement->document().domWindow())
+ window->history().back();
}
}
}