Modified: trunk/Source/WebCore/ChangeLog (290347 => 290348)
--- trunk/Source/WebCore/ChangeLog 2022-02-23 05:11:34 UTC (rev 290347)
+++ trunk/Source/WebCore/ChangeLog 2022-02-23 06:01:13 UTC (rev 290348)
@@ -1,3 +1,20 @@
+2022-02-22 Tim Nguyen <[email protected]>
+
+ Create a DOMWindow::printWarningMessage method and start using it in DOMWindow.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=237047
+
+ Reviewed by Darin Adler.
+
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::close):
+ (WebCore::DOMWindow::webkitRequestAnimationFrame):
+ (WebCore::DOMWindow::startListeningForDeviceOrientationIfNecessary):
+ (WebCore::DOMWindow::startListeningForDeviceMotionIfNecessary):
+ (WebCore::DOMWindow::printConsoleMessage const):
+ (WebCore::DOMWindow::printErrorMessage const):
+ (WebCore::DOMWindow::printWarningMessage const):
+ * page/DOMWindow.h:
+
2022-02-22 Chris Dumez <[email protected]>
Share more code between dispatchSessionStorageEvents() and dispatchLocalStorageEvents()
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (290347 => 290348)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2022-02-23 05:11:34 UTC (rev 290347)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2022-02-23 06:01:13 UTC (rev 290348)
@@ -1066,7 +1066,7 @@
return;
if (!(page->openedByDOM() || page->backForward().count() <= 1)) {
- console()->addMessage(MessageSource::JS, MessageLevel::Warning, "Can't close the window since it was not opened by _javascript_"_s);
+ printWarningMessage("Can't close the window since it was not opened by _javascript_"_s);
return;
}
@@ -1874,8 +1874,8 @@
int DOMWindow::webkitRequestAnimationFrame(Ref<RequestAnimationFrameCallback>&& callback)
{
static bool firstTime = true;
- if (firstTime && document()) {
- document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "webkitRequestAnimationFrame() is deprecated and will be removed. Please use requestAnimationFrame() instead."_s);
+ if (firstTime) {
+ printWarningMessage("webkitRequestAnimationFrame() is deprecated and will be removed. Please use requestAnimationFrame() instead."_s);
firstTime = false;
}
return requestAnimationFrame(WTFMove(callback));
@@ -2110,8 +2110,7 @@
String innerMessage;
if (!isAllowedToUseDeviceOrientation(innerMessage) || !hasPermissionToReceiveDeviceMotionOrOrientationEvents(innerMessage)) {
- if (RefPtr document = this->document())
- document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("No device orientation events will be fired, reason: ", innerMessage, "."));
+ printWarningMessage(makeString("No device orientation events will be fired, reason: ", innerMessage, "."));
return;
}
@@ -2139,8 +2138,7 @@
String innerMessage;
if (!isAllowedToUseDeviceMotion(innerMessage) || !hasPermissionToReceiveDeviceMotionOrOrientationEvents(innerMessage)) {
failedToRegisterDeviceMotionEventListener();
- if (RefPtr document = this->document())
- document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("No device motion events will be fired, reason: ", innerMessage, "."));
+ printWarningMessage(makeString("No device motion events will be fired, reason: ", innerMessage, "."));
return;
}
@@ -2428,15 +2426,25 @@
lockHistory, lockBackForwardList);
}
-void DOMWindow::printErrorMessage(const String& message) const
+void DOMWindow::printConsoleMessage(const String& message, MessageLevel level) const
{
if (message.isEmpty())
return;
if (PageConsoleClient* pageConsole = console())
- pageConsole->addMessage(MessageSource::JS, MessageLevel::Error, message);
+ pageConsole->addMessage(MessageSource::JS, level, message);
}
+void DOMWindow::printErrorMessage(const String& message) const
+{
+ printConsoleMessage(message, MessageLevel::Error);
+}
+
+void DOMWindow::printWarningMessage(const String& message) const
+{
+ printConsoleMessage(message, MessageLevel::Warning);
+}
+
String DOMWindow::crossDomainAccessErrorMessage(const DOMWindow& activeWindow, IncludeTargetOrigin includeTargetOrigin)
{
const URL& activeWindowURL = activeWindow.document()->url();
Modified: trunk/Source/WebCore/page/DOMWindow.h (290347 => 290348)
--- trunk/Source/WebCore/page/DOMWindow.h 2022-02-23 05:11:34 UTC (rev 290347)
+++ trunk/Source/WebCore/page/DOMWindow.h 2022-02-23 06:01:13 UTC (rev 290348)
@@ -440,6 +440,9 @@
void decrementGamepadEventListenerCount();
#endif
+ void printConsoleMessage(const String&, MessageLevel) const;
+ void printWarningMessage(const String&) const;
+
bool m_shouldPrintWhenFinishedLoading { false };
bool m_suspendedForDocumentSuspension { false };
bool m_isSuspendingObservers { false };