<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[207025] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/207025">207025</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2016-10-10 14:33:25 -0700 (Mon, 10 Oct 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move NotificationCenter from legacy to new DOM exceptions
https://bugs.webkit.org/show_bug.cgi?id=163217
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/notifications/DOMWindowNotifications.cpp:
(WebCore::DOMWindowNotifications::webkitNotifications): Pass reference to
document instead of pointer. Also use auto and early return.
* Modules/notifications/Notification.cpp:
(WebCore::Notification::Notification): Move checks that can lead to
throwing an exception out of the constructor into the create function.
(WebCore::Notification::create): Changed to use ExceptionOr. Also moved
checks that can lead to throwing an exception here.
(WebCore::Notification::show): Update since NotificationController::client
now returns a reference.
(WebCore::Notification::permission): Ditto.
(WebCore::Notification::requestPermission): Ditto.
* Modules/notifications/Notification.h: Updated for above changes.
* Modules/notifications/NotificationCenter.cpp:
(WebCore::NotificationCenter::create): Take a reference to the script execution
context instead of a pointer.
(WebCore::NotificationCenter::NotificationCenter): Ditto.
(WebCore::NotificationCenter::createNotification): Use ExceptionOr.
(WebCore::NotificationCenter::requestPermission): Take an rvalue reference.
* Modules/notifications/NotificationCenter.h: Use pragma once.
Marked the class final. Updated for changes above.
* Modules/notifications/NotificationCenter.idl: Use non-legacy exceptions.
* Modules/notifications/NotificationController.cpp:
(WebCore::NotificationController::NotificationController): Use a reference rather
than a pointer for m_client, since it is never null.
(WebCore::NotificationController::~NotificationController): Ditto.
(WebCore::NotificationController::clientFrom): Updated for the change above.
* Modules/notifications/NotificationController.h: Updated for the change above.
* Modules/notifications/WorkerGlobalScopeNotifications.cpp:
(WebCore::WorkerGlobalScopeNotifications::webkitNotifications): Updated to
pass a reference for the script execution context. Also added FIXME about the
fact that the client is always null.
Source/WebKit/mac:
* WebView/WebView.mm:
(-[WebView _notificationIDForTesting:]): Pass reference to page rather than pointer.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsDOMWindowNotificationscpp">trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationcpp">trunk/Source/WebCore/Modules/notifications/Notification.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationh">trunk/Source/WebCore/Modules/notifications/Notification.h</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationCentercpp">trunk/Source/WebCore/Modules/notifications/NotificationCenter.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationCenterh">trunk/Source/WebCore/Modules/notifications/NotificationCenter.h</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationCenteridl">trunk/Source/WebCore/Modules/notifications/NotificationCenter.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationControllercpp">trunk/Source/WebCore/Modules/notifications/NotificationController.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationControllerh">trunk/Source/WebCore/Modules/notifications/NotificationController.h</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsWorkerGlobalScopeNotificationscpp">trunk/Source/WebCore/Modules/notifications/WorkerGlobalScopeNotifications.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/ChangeLog        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2016-10-10 Darin Adler <darin@apple.com>
+
+ Move NotificationCenter from legacy to new DOM exceptions
+ https://bugs.webkit.org/show_bug.cgi?id=163217
+
+ Reviewed by Chris Dumez.
+
+ * Modules/notifications/DOMWindowNotifications.cpp:
+ (WebCore::DOMWindowNotifications::webkitNotifications): Pass reference to
+ document instead of pointer. Also use auto and early return.
+
+ * Modules/notifications/Notification.cpp:
+ (WebCore::Notification::Notification): Move checks that can lead to
+ throwing an exception out of the constructor into the create function.
+ (WebCore::Notification::create): Changed to use ExceptionOr. Also moved
+ checks that can lead to throwing an exception here.
+ (WebCore::Notification::show): Update since NotificationController::client
+ now returns a reference.
+ (WebCore::Notification::permission): Ditto.
+ (WebCore::Notification::requestPermission): Ditto.
+
+ * Modules/notifications/Notification.h: Updated for above changes.
+
+ * Modules/notifications/NotificationCenter.cpp:
+ (WebCore::NotificationCenter::create): Take a reference to the script execution
+ context instead of a pointer.
+ (WebCore::NotificationCenter::NotificationCenter): Ditto.
+ (WebCore::NotificationCenter::createNotification): Use ExceptionOr.
+ (WebCore::NotificationCenter::requestPermission): Take an rvalue reference.
+
+ * Modules/notifications/NotificationCenter.h: Use pragma once.
+ Marked the class final. Updated for changes above.
+
+ * Modules/notifications/NotificationCenter.idl: Use non-legacy exceptions.
+
+ * Modules/notifications/NotificationController.cpp:
+ (WebCore::NotificationController::NotificationController): Use a reference rather
+ than a pointer for m_client, since it is never null.
+ (WebCore::NotificationController::~NotificationController): Ditto.
+ (WebCore::NotificationController::clientFrom): Updated for the change above.
+
+ * Modules/notifications/NotificationController.h: Updated for the change above.
+
+ * Modules/notifications/WorkerGlobalScopeNotifications.cpp:
+ (WebCore::WorkerGlobalScopeNotifications::webkitNotifications): Updated to
+ pass a reference for the script execution context. Also added FIXME about the
+ fact that the client is always null.
+
</ins><span class="cx"> 2016-10-10 Antoine Quint <graouts@apple.com>
</span><span class="cx">
</span><span class="cx"> [Modern Media Controls] Placards
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsDOMWindowNotificationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.cpp (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.cpp        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.cpp        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -101,23 +101,24 @@
</span><span class="cx"> NotificationCenter* DOMWindowNotifications::webkitNotifications()
</span><span class="cx"> {
</span><span class="cx"> if (!m_window->isCurrentlyDisplayedInFrame())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> if (m_notificationCenter)
</span><span class="cx"> return m_notificationCenter.get();
</span><span class="cx">
</span><del>- Document* document = m_window->document();
</del><ins>+ auto* document = m_window->document();
</ins><span class="cx"> if (!document)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><del>- Page* page = document->page();
</del><ins>+ auto* page = document->page();
</ins><span class="cx"> if (!page)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><del>- NotificationClient* provider = NotificationController::clientFrom(page);
- if (provider)
- m_notificationCenter = NotificationCenter::create(document, provider);
</del><ins>+ auto* provider = NotificationController::clientFrom(*page);
+ if (!provider)
+ return nullptr;
</ins><span class="cx">
</span><ins>+ m_notificationCenter = NotificationCenter::create(*document, provider);
</ins><span class="cx"> return m_notificationCenter.get();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/Notification.cpp        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -50,22 +50,13 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(LEGACY_NOTIFICATIONS)
</span><span class="cx">
</span><del>-Notification::Notification(const String& title, const String& body, const String& iconURI, ScriptExecutionContext& context, ExceptionCode& ec, NotificationCenter& notificationCenter)
</del><ins>+Notification::Notification(const String& title, const String& body, URL&& iconURL, ScriptExecutionContext& context, NotificationCenter& notificationCenter)
</ins><span class="cx"> : ActiveDOMObject(&context)
</span><ins>+ , m_icon(WTFMove(iconURL))
</ins><span class="cx"> , m_title(title)
</span><span class="cx"> , m_body(body)
</span><span class="cx"> , m_notificationCenter(&notificationCenter)
</span><span class="cx"> {
</span><del>- if (m_notificationCenter->checkPermission() != NotificationClient::PermissionAllowed) {
- ec = SECURITY_ERR;
- return;
- }
-
- m_icon = iconURI.isEmpty() ? URL() : scriptExecutionContext()->completeURL(iconURI);
- if (!m_icon.isEmpty() && !m_icon.isValid()) {
- ec = SYNTAX_ERR;
- return;
- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="lines">@@ -93,11 +84,18 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(LEGACY_NOTIFICATIONS)
</span><span class="cx">
</span><del>-Ref<Notification> Notification::create(const String& title, const String& body, const String& iconURI, ScriptExecutionContext& context, ExceptionCode& ec, NotificationCenter& provider)
</del><ins>+ExceptionOr<Ref<Notification>> Notification::create(const String& title, const String& body, const String& iconURL, ScriptExecutionContext& context, NotificationCenter& provider)
</ins><span class="cx"> {
</span><del>- auto notification = adoptRef(*new Notification(title, body, iconURI, context, ec, provider));
</del><ins>+ if (provider.checkPermission() != NotificationClient::PermissionAllowed)
+ return Exception { SECURITY_ERR };
+
+ URL completedIconURL = iconURL.isEmpty() ? URL() : context.completeURL(iconURL);
+ if (!completedIconURL.isEmpty() && !completedIconURL.isValid())
+ return Exception { SYNTAX_ERR };
+
+ auto notification = adoptRef(*new Notification(title, body, WTFMove(completedIconURL), context, provider));
</ins><span class="cx"> notification.get().suspendIfNeeded();
</span><del>- return notification;
</del><ins>+ return WTFMove(notification);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="lines">@@ -146,7 +144,7 @@
</span><span class="cx"> auto* page = downcast<Document>(*scriptExecutionContext()).page();
</span><span class="cx"> if (!page)
</span><span class="cx"> return;
</span><del>- if (NotificationController::from(page)->client()->checkPermission(scriptExecutionContext()) != NotificationClient::PermissionAllowed) {
</del><ins>+ if (NotificationController::from(page)->client().checkPermission(scriptExecutionContext()) != NotificationClient::PermissionAllowed) {
</ins><span class="cx"> dispatchErrorEvent();
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -224,7 +222,7 @@
</span><span class="cx">
</span><span class="cx"> String Notification::permission(Document& document)
</span><span class="cx"> {
</span><del>- return permissionString(NotificationController::from(document.page())->client()->checkPermission(&document));
</del><ins>+ return permissionString(NotificationController::from(document.page())->client().checkPermission(&document));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String Notification::permissionString(NotificationClient::Permission permission)
</span><span class="lines">@@ -243,7 +241,7 @@
</span><span class="cx">
</span><span class="cx"> void Notification::requestPermission(Document& document, RefPtr<NotificationPermissionCallback>&& callback)
</span><span class="cx"> {
</span><del>- NotificationController::from(document.page())->client()->requestPermission(&document, WTFMove(callback));
</del><ins>+ NotificationController::from(document.page())->client().requestPermission(&document, WTFMove(callback));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/Notification.h (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/Notification.h        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/Notification.h        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -35,14 +35,12 @@
</span><span class="cx">
</span><span class="cx"> #include "ActiveDOMObject.h"
</span><span class="cx"> #include "EventTarget.h"
</span><ins>+#include "ExceptionOr.h"
</ins><span class="cx"> #include "NotificationClient.h"
</span><ins>+#include "Timer.h"
</ins><span class="cx"> #include "URL.h"
</span><span class="cx"> #include "WritingMode.h"
</span><span class="cx">
</span><del>-#if ENABLE(NOTIFICATIONS)
-#include "Timer.h"
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class Document;
</span><span class="lines">@@ -55,7 +53,7 @@
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx"> #if ENABLE(LEGACY_NOTIFICATIONS)
</span><del>- static Ref<Notification> create(const String& title, const String& body, const String& iconURL, ScriptExecutionContext&, ExceptionCode&, NotificationCenter&);
</del><ins>+ static ExceptionOr<Ref<Notification>> create(const String& title, const String& body, const String& iconURL, ScriptExecutionContext&, NotificationCenter&);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(NOTIFICATIONS)
</span><span class="lines">@@ -111,7 +109,7 @@
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> #if ENABLE(LEGACY_NOTIFICATIONS)
</span><del>- Notification(const String& title, const String& body, const String& iconURL, ScriptExecutionContext&, ExceptionCode&, NotificationCenter&);
</del><ins>+ Notification(const String& title, const String& body, URL&& iconURL, ScriptExecutionContext&, NotificationCenter&);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(NOTIFICATIONS)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationCentercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/NotificationCenter.cpp (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/NotificationCenter.cpp        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/NotificationCenter.cpp        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx">
</span><span class="cx"> #include "NotificationCenter.h"
</span><span class="cx">
</span><ins>+#include "ExceptionCode.h"
</ins><span class="cx"> #include "Notification.h"
</span><span class="cx"> #include "ScriptExecutionContext.h"
</span><span class="cx"> #include "SecurityOrigin.h"
</span><span class="lines">@@ -42,7 +43,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-Ref<NotificationCenter> NotificationCenter::create(ScriptExecutionContext* context, NotificationClient* client)
</del><ins>+Ref<NotificationCenter> NotificationCenter::create(ScriptExecutionContext& context, NotificationClient* client)
</ins><span class="cx"> {
</span><span class="cx"> auto notificationCenter = adoptRef(*new NotificationCenter(context, client));
</span><span class="cx"> notificationCenter->suspendIfNeeded();
</span><span class="lines">@@ -49,8 +50,8 @@
</span><span class="cx"> return notificationCenter;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationClient* client)
- : ActiveDOMObject(context)
</del><ins>+NotificationCenter::NotificationCenter(ScriptExecutionContext& context, NotificationClient* client)
+ : ActiveDOMObject(&context)
</ins><span class="cx"> , m_client(client)
</span><span class="cx"> , m_timer([this]() { timerFired(); })
</span><span class="cx"> {
</span><span class="lines">@@ -58,13 +59,11 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(LEGACY_NOTIFICATIONS)
</span><span class="cx">
</span><del>-RefPtr<Notification> NotificationCenter::createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec)
</del><ins>+ExceptionOr<Ref<Notification>> NotificationCenter::createNotification(const String& iconURI, const String& title, const String& body)
</ins><span class="cx"> {
</span><del>- if (!m_client || !scriptExecutionContext()) {
- ec = INVALID_STATE_ERR;
- return nullptr;
- }
- return Notification::create(title, body, iconURI, *scriptExecutionContext(), ec, *this);
</del><ins>+ if (!m_client || !scriptExecutionContext())
+ return Exception { INVALID_STATE_ERR };
+ return Notification::create(title, body, iconURI, *scriptExecutionContext(), *this);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int NotificationCenter::checkPermission()
</span><span class="lines">@@ -85,7 +84,7 @@
</span><span class="cx"> return m_client->checkPermission(scriptExecutionContext());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void NotificationCenter::requestPermission(const RefPtr<VoidCallback>& callback)
</del><ins>+void NotificationCenter::requestPermission(RefPtr<VoidCallback>&& callback)
</ins><span class="cx"> {
</span><span class="cx"> if (!m_client || !scriptExecutionContext())
</span><span class="cx"> return;
</span><span class="lines">@@ -103,12 +102,12 @@
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="cx"> case SecurityOrigin::Ask:
</span><del>- m_client->requestPermission(scriptExecutionContext(), callback.get());
</del><ins>+ m_client->requestPermission(scriptExecutionContext(), WTFMove(callback));
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><del>- m_client->requestPermission(scriptExecutionContext(), callback.get());
</del><ins>+ m_client->requestPermission(scriptExecutionContext(), WTFMove(callback));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationCenterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/NotificationCenter.h (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/NotificationCenter.h        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/NotificationCenter.h        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -29,11 +29,10 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef NotificationCenter_h
-#define NotificationCenter_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><span class="cx"> #include "ActiveDOMObject.h"
</span><del>-#include "ExceptionCode.h"
</del><ins>+#include "ExceptionOr.h"
</ins><span class="cx"> #include "Timer.h"
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx">
</span><span class="lines">@@ -45,15 +44,15 @@
</span><span class="cx"> class NotificationClient;
</span><span class="cx"> class VoidCallback;
</span><span class="cx">
</span><del>-class NotificationCenter : public RefCounted<NotificationCenter>, private ActiveDOMObject {
</del><ins>+class NotificationCenter final : public RefCounted<NotificationCenter>, private ActiveDOMObject {
</ins><span class="cx"> public:
</span><del>- static Ref<NotificationCenter> create(ScriptExecutionContext*, NotificationClient*);
</del><ins>+ static Ref<NotificationCenter> create(ScriptExecutionContext&, NotificationClient*);
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(LEGACY_NOTIFICATIONS)
</span><del>- RefPtr<Notification> createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode&);
</del><ins>+ ExceptionOr<Ref<Notification>> createNotification(const String& iconURL, const String& title, const String& body);
</ins><span class="cx">
</span><span class="cx"> int checkPermission();
</span><del>- void requestPermission(const RefPtr<VoidCallback>&);
</del><ins>+ void requestPermission(RefPtr<VoidCallback>&&);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> NotificationClient* client() const { return m_client; }
</span><span class="lines">@@ -61,11 +60,11 @@
</span><span class="cx"> using ActiveDOMObject::hasPendingActivity;
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- NotificationCenter(ScriptExecutionContext*, NotificationClient*);
</del><ins>+ NotificationCenter(ScriptExecutionContext&, NotificationClient*);
</ins><span class="cx">
</span><del>- void stop() override;
- const char* activeDOMObjectName() const override;
- bool canSuspendForDocumentSuspension() const override;
</del><ins>+ void stop() final;
+ const char* activeDOMObjectName() const final;
+ bool canSuspendForDocumentSuspension() const final;
</ins><span class="cx">
</span><span class="cx"> void timerFired();
</span><span class="cx">
</span><span class="lines">@@ -77,5 +76,3 @@
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
</span><del>-
-#endif // NotificationCenter_h
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationCenteridl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/NotificationCenter.idl (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/NotificationCenter.idl        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/NotificationCenter.idl        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx"> Conditional=LEGACY_NOTIFICATIONS,
</span><span class="cx"> NoInterfaceObject,
</span><span class="cx"> ] interface NotificationCenter {
</span><del>- [MayThrowLegacyException] Notification createNotification(DOMString iconUrl, DOMString title, DOMString body);
</del><ins>+ [MayThrowException] Notification createNotification(DOMString iconUrl, DOMString title, DOMString body);
</ins><span class="cx">
</span><span class="cx"> long checkPermission();
</span><span class="cx"> void requestPermission(optional VoidCallback? callback);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/NotificationController.cpp (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/NotificationController.cpp        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/NotificationController.cpp        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -33,21 +33,22 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> NotificationController::NotificationController(NotificationClient* client)
</span><del>- : m_client(client)
</del><ins>+ : m_client(*client)
</ins><span class="cx"> {
</span><ins>+ ASSERT(client);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NotificationController::~NotificationController()
</span><span class="cx"> {
</span><del>- if (m_client)
- m_client->notificationControllerDestroyed();
</del><ins>+ m_client.notificationControllerDestroyed();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-NotificationClient* NotificationController::clientFrom(Page* page)
</del><ins>+NotificationClient* NotificationController::clientFrom(Page& page)
</ins><span class="cx"> {
</span><del>- if (NotificationController* controller = NotificationController::from(page))
- return controller->client();
- return 0;
</del><ins>+ auto* controller = NotificationController::from(&page);
+ if (!controller)
+ return nullptr;
+ return &controller->client();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const char* NotificationController::supplementName()
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/NotificationController.h (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/NotificationController.h        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/NotificationController.h        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -23,14 +23,12 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef NotificationController_h
-#define NotificationController_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
</span><span class="cx">
</span><span class="cx"> #include "Page.h"
</span><span class="cx"> #include <wtf/Forward.h>
</span><del>-#include <wtf/Noncopyable.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -38,7 +36,6 @@
</span><span class="cx">
</span><span class="cx"> class NotificationController : public Supplement<Page> {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><del>- WTF_MAKE_NONCOPYABLE(NotificationController);
</del><span class="cx"> public:
</span><span class="cx"> explicit NotificationController(NotificationClient*);
</span><span class="cx"> ~NotificationController();
</span><span class="lines">@@ -45,16 +42,14 @@
</span><span class="cx">
</span><span class="cx"> static const char* supplementName();
</span><span class="cx"> static NotificationController* from(Page* page) { return static_cast<NotificationController*>(Supplement<Page>::from(page, supplementName())); }
</span><del>- WEBCORE_EXPORT static NotificationClient* clientFrom(Page*);
</del><ins>+ WEBCORE_EXPORT static NotificationClient* clientFrom(Page&);
</ins><span class="cx">
</span><del>- NotificationClient* client() { return m_client; }
-
</del><ins>+ NotificationClient& client() { return m_client; }
+
</ins><span class="cx"> private:
</span><del>- NotificationClient* m_client;
</del><ins>+ NotificationClient& m_client;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
</span><del>-
-#endif // NotificationController_h
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsWorkerGlobalScopeNotificationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/WorkerGlobalScopeNotifications.cpp (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/WorkerGlobalScopeNotifications.cpp        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebCore/Modules/notifications/WorkerGlobalScopeNotifications.cpp        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -68,8 +68,11 @@
</span><span class="cx">
</span><span class="cx"> NotificationCenter* WorkerGlobalScopeNotifications::webkitNotifications()
</span><span class="cx"> {
</span><ins>+ // FIXME: As of this writing, this always passes nullptr for the client.
+ // If it wasn't for that, the notification center create function could be taking a reference.
+ // How is it useful to create a notification center with no client?
</ins><span class="cx"> if (!m_notificationCenter)
</span><del>- m_notificationCenter = NotificationCenter::create(m_context, m_context->thread().getNotificationClient());
</del><ins>+ m_notificationCenter = NotificationCenter::create(*m_context, m_context->thread().getNotificationClient());
</ins><span class="cx"> return m_notificationCenter.get();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-10-10 Darin Adler <darin@apple.com>
+
+ Move NotificationCenter from legacy to new DOM exceptions
+ https://bugs.webkit.org/show_bug.cgi?id=163217
+
+ Reviewed by Chris Dumez.
+
+ * WebView/WebView.mm:
+ (-[WebView _notificationIDForTesting:]): Pass reference to page rather than pointer.
+
</ins><span class="cx"> 2016-10-09 Wenson Hsieh <wenson_hsieh@apple.com>
</span><span class="cx">
</span><span class="cx"> Support InputEvent.inputType for the new InputEvent spec
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (207024 => 207025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2016-10-10 21:17:47 UTC (rev 207024)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2016-10-10 21:33:25 UTC (rev 207025)
</span><span class="lines">@@ -9002,9 +9002,12 @@
</span><span class="cx"> - (uint64_t)_notificationIDForTesting:(JSValueRef)jsNotification
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
</span><ins>+ auto* page = _private->page;
+ if (!page)
+ return 0;
</ins><span class="cx"> JSContextRef context = [[self mainFrame] globalContext];
</span><del>- WebCore::Notification* notification = JSNotification::toWrapped(toJS(toJS(context), jsNotification));
- return static_cast<WebNotificationClient*>(NotificationController::clientFrom(_private->page))->notificationIDForTesting(notification);
</del><ins>+ auto* notification = JSNotification::toWrapped(toJS(toJS(context), jsNotification));
+ return static_cast<WebNotificationClient*>(NotificationController::clientFrom(*page))->notificationIDForTesting(notification);
</ins><span class="cx"> #else
</span><span class="cx"> return 0;
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>