Title: [223206] trunk/Source
Revision
223206
Author
[email protected]
Date
2017-10-11 13:30:16 -0700 (Wed, 11 Oct 2017)

Log Message

Allow PAL to log messages
https://bugs.webkit.org/show_bug.cgi?id=171523

Reviewed by Alex Christensen.

Source/WebCore:

Make the model of WebCore/PAL match the model of WebKit/WebCore. This is because PAL will
need to log things (because existing files in WebCore/platform need to log things).

No new tests because there is no behavior change.

* WebCore.xcodeproj/project.pbxproj:
* page/mac/PageMac.mm:
(WebCore::Page::platformInitialize):
* platform/Logging.cpp:
(WebCore::registerNotifyCallback): Deleted.
* platform/Logging.h:
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForWithReason):

Source/WebCore/PAL:

* PAL.xcodeproj/project.pbxproj:
* pal/CMakeLists.txt:
* pal/LogInitialization.h: Copied from Source/WebCore/platform/LogMacros.h.
* pal/LogMacros.h: Copied from Source/WebCore/platform/LogMacros.h.
* pal/Logging.cpp: Copied from Source/WebCore/platform/Logging.cpp.
(PAL::isLogChannelEnabled):
(PAL::setLogChannelToAccumulate):
(PAL::initializeLogChannelsIfNecessary):
(PAL::registerNotifyCallback):
* pal/Logging.h: Copied from Source/WebCore/platform/LogMacros.h.
* pal/PlatformMac.cmake:
* pal/cocoa/LoggingCocoa.mm: Renamed from Source/WebCore/platform/LogMacros.h.
(PAL::logLevelString):

Source/WebKit:

* Platform/Logging.h:
* Scripts/generate-forwarding-headers.pl:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (223205 => 223206)


--- trunk/Source/WebCore/ChangeLog	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/ChangeLog	2017-10-11 20:30:16 UTC (rev 223206)
@@ -1,3 +1,24 @@
+2017-10-11  Myles C. Maxfield  <[email protected]>
+
+        Allow PAL to log messages
+        https://bugs.webkit.org/show_bug.cgi?id=171523
+
+        Reviewed by Alex Christensen.
+
+        Make the model of WebCore/PAL match the model of WebKit/WebCore. This is because PAL will
+        need to log things (because existing files in WebCore/platform need to log things).
+
+        No new tests because there is no behavior change.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/mac/PageMac.mm:
+        (WebCore::Page::platformInitialize):
+        * platform/Logging.cpp:
+        (WebCore::registerNotifyCallback): Deleted.
+        * platform/Logging.h:
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForWithReason):
+
 2017-10-11  Chris Dumez  <[email protected]>
 
         Unreviewed, fix build with some SDKs.

Modified: trunk/Source/WebCore/PAL/ChangeLog (223205 => 223206)


--- trunk/Source/WebCore/PAL/ChangeLog	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/PAL/ChangeLog	2017-10-11 20:30:16 UTC (rev 223206)
@@ -1,3 +1,24 @@
+2017-10-11  Myles C. Maxfield  <[email protected]>
+
+        Allow PAL to log messages
+        https://bugs.webkit.org/show_bug.cgi?id=171523
+
+        Reviewed by Alex Christensen.
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/CMakeLists.txt:
+        * pal/LogInitialization.h: Copied from Source/WebCore/platform/LogMacros.h.
+        * pal/LogMacros.h: Copied from Source/WebCore/platform/LogMacros.h.
+        * pal/Logging.cpp: Copied from Source/WebCore/platform/Logging.cpp.
+        (PAL::isLogChannelEnabled):
+        (PAL::setLogChannelToAccumulate):
+        (PAL::initializeLogChannelsIfNecessary):
+        (PAL::registerNotifyCallback):
+        * pal/Logging.h: Copied from Source/WebCore/platform/LogMacros.h.
+        * pal/PlatformMac.cmake:
+        * pal/cocoa/LoggingCocoa.mm: Renamed from Source/WebCore/platform/LogMacros.h.
+        (PAL::logLevelString):
+
 2017-10-06  Chris Dumez  <[email protected]>
 
         [Beacon][Cocoa] Beacon requests with BufferSource payload should not have a Content-Type HTTP header

Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (223205 => 223206)


--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2017-10-11 20:30:16 UTC (rev 223206)
@@ -105,6 +105,9 @@
 		1C09D0531E31C44100725F18 /* CryptoDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C09D0521E31C44100725F18 /* CryptoDigest.h */; };
 		1C09D0561E31C46500725F18 /* CryptoDigestCommonCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C09D0551E31C46500725F18 /* CryptoDigestCommonCrypto.cpp */; };
 		1C09D0581E31C57E00725F18 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C09D0571E31C57E00725F18 /* config.h */; };
+		1C4876D81F8D7F4E00CCEEBD /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C4876D61F8D7F4E00CCEEBD /* Logging.cpp */; };
+		1C4876D91F8D7F4E00CCEEBD /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4876D71F8D7F4E00CCEEBD /* Logging.h */; };
+		1C4876E01F8D837500CCEEBD /* LoggingCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C4876DF1F8D837500CCEEBD /* LoggingCocoa.mm */; };
 		A10265871F56746100B4C844 /* FoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265861F56746100B4C844 /* FoundationSPI.h */; };
 		A10265891F56747A00B4C844 /* HIToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265881F56747A00B4C844 /* HIToolboxSPI.h */; };
 		A102658B1F56748C00B4C844 /* QuickDrawSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A102658A1F56748C00B4C844 /* QuickDrawSPI.h */; };
@@ -239,6 +242,11 @@
 		1C09D05D1E31C77A00725F18 /* PAL.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = PAL.xcconfig; sourceTree = "<group>"; };
 		1C09D0621E31EC2800725F18 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
 		1C09D0631E31EC3100725F18 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
+		1C4876D61F8D7F4E00CCEEBD /* Logging.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Logging.cpp; sourceTree = "<group>"; };
+		1C4876D71F8D7F4E00CCEEBD /* Logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = "<group>"; };
+		1C4876DC1F8D7FC600CCEEBD /* LogMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LogMacros.h; sourceTree = "<group>"; };
+		1C4876DD1F8D812B00CCEEBD /* LogInitialization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LogInitialization.h; sourceTree = "<group>"; };
+		1C4876DF1F8D837500CCEEBD /* LoggingCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingCocoa.mm; sourceTree = "<group>"; };
 		1C67CEA11E32EDA800F80F2E /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
 		1C67CEA21E32EE2600F80F2E /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
 		A10265861F56746100B4C844 /* FoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoundationSPI.h; sourceTree = "<group>"; };
@@ -457,6 +465,7 @@
 			children = (
 				0C00CFCC1F68CE2300AAC26D /* avfoundation */,
 				0CF99CA51F73841C007EE793 /* cf */,
+				1C4876DE1F8D831300CCEEBD /* cocoa */,
 				1C09D0511E31C41200725F18 /* crypto */,
 				0C2DA0651F33CA3300DBC317 /* spi */,
 				A3788E9F1F05B7CE00679425 /* system */,
@@ -465,6 +474,10 @@
 				A39DE74D1F7C443C007BCB00 /* HysteresisActivity.h */,
 				0708AC321F4C874A001F788F /* Logger.h */,
 				07377ADB1F5777D70027F16D /* LoggerHelper.h */,
+				1C4876D61F8D7F4E00CCEEBD /* Logging.cpp */,
+				1C4876D71F8D7F4E00CCEEBD /* Logging.h */,
+				1C4876DD1F8D812B00CCEEBD /* LogInitialization.h */,
+				1C4876DC1F8D7FC600CCEEBD /* LogMacros.h */,
 				A3C66CDA1F462D6A009E6EE9 /* SessionID.cpp */,
 				A3C66CDB1F462D6A009E6EE9 /* SessionID.h */,
 			);
@@ -501,6 +514,14 @@
 			path = Configurations;
 			sourceTree = "<group>";
 		};
+		1C4876DE1F8D831300CCEEBD /* cocoa */ = {
+			isa = PBXGroup;
+			children = (
+				1C4876DF1F8D837500CCEEBD /* LoggingCocoa.mm */,
+			);
+			path = cocoa;
+			sourceTree = "<group>";
+		};
 		A30D411D1F0DD0AC00B71954 /* text */ = {
 			isa = PBXGroup;
 			children = (
@@ -607,6 +628,7 @@
 				0C2DA1471F3BEB4900DBC317 /* LinkPresentationSPI.h in Headers */,
 				0708AC331F4C874B001F788F /* Logger.h in Headers */,
 				07377ADC1F5777D90027F16D /* LoggerHelper.h in Headers */,
+				1C4876D91F8D7F4E00CCEEBD /* Logging.h in Headers */,
 				0C77858B1F45130F00F4EBB6 /* LookupSPI.h in Headers */,
 				0C2DA1481F3BEB4900DBC317 /* MachVMSPI.h in Headers */,
 				0C5AF91D1F43A4C7002EAC02 /* MediaPlayerSPI.h in Headers */,
@@ -764,6 +786,8 @@
 				A1175B581F6B470500C4B9F0 /* DefaultSearchProvider.cpp in Sources */,
 				A30D41221F0DD0EA00B71954 /* KillRing.cpp in Sources */,
 				A30D41251F0DD12D00B71954 /* KillRingMac.mm in Sources */,
+				1C4876D81F8D7F4E00CCEEBD /* Logging.cpp in Sources */,
+				1C4876E01F8D837500CCEEBD /* LoggingCocoa.mm in Sources */,
 				0CF99CA41F736375007EE793 /* MediaTimeAVFoundation.cpp in Sources */,
 				A1175B4F1F6B337300C4B9F0 /* PopupMenu.mm in Sources */,
 				A3C66CDC1F462D6A009E6EE9 /* SessionID.cpp in Sources */,

Modified: trunk/Source/WebCore/PAL/pal/CMakeLists.txt (223205 => 223206)


--- trunk/Source/WebCore/PAL/pal/CMakeLists.txt	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/PAL/pal/CMakeLists.txt	2017-10-11 20:30:16 UTC (rev 223206)
@@ -1,4 +1,5 @@
 set(PAL_SOURCES
+    Logging.cpp
     SessionID.cpp
 
     system/SleepDisabler.cpp

Copied: trunk/Source/WebCore/PAL/pal/LogInitialization.h (from rev 223205, trunk/Source/WebCore/platform/LogMacros.h) (0 => 223206)


--- trunk/Source/WebCore/PAL/pal/LogInitialization.h	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/LogInitialization.h	2017-10-11 20:30:16 UTC (rev 223206)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2003, 2006, 2013, 2015, 2016, 2017 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Assertions.h>
+#include <wtf/Forward.h>
+#include <wtf/Optional.h>
+#include <wtf/text/WTFString.h>
+
+namespace PAL {
+
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+String logLevelString();
+bool isLogChannelEnabled(const String& name);
+PAL_EXPORT void setLogChannelToAccumulate(const String& name);
+PAL_EXPORT void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt);
+
+#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/PAL/pal/LogMacros.h (from rev 223205, trunk/Source/WebCore/platform/LogMacros.h) (0 => 223206)


--- trunk/Source/WebCore/PAL/pal/LogMacros.h	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/LogMacros.h	2017-10-11 20:30:16 UTC (rev 223206)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015, 2016, 2017 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if LOG_DISABLED
+
+#define LOG_WITH_STREAM(channel, commands) ((void)0)
+
+#else
+
+#define LOG_WITH_STREAM(channel, commands) do { \
+        WTF::TextStream stream(WTF::TextStream::LineMode::SingleLine); \
+        commands; \
+        WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), "%s", stream.release().utf8().data()); \
+    } while (0)
+
+#endif // !LOG_DISABLED
+

Copied: trunk/Source/WebCore/PAL/pal/Logging.cpp (from rev 223205, trunk/Source/WebCore/platform/Logging.cpp) (0 => 223206)


--- trunk/Source/WebCore/PAL/pal/Logging.cpp	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/Logging.cpp	2017-10-11 20:30:16 UTC (rev 223206)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2003, 2006, 2013, 2017 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Logging.h"
+
+#include "LogInitialization.h"
+
+#include <wtf/StdLibExtras.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+#if PLATFORM(COCOA)
+#include <notify.h>
+#include <wtf/BlockPtr.h>
+#endif
+
+namespace PAL {
+
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+#define DEFINE_PAL_LOG_CHANNEL(name) DEFINE_LOG_CHANNEL(name, LOG_CHANNEL_WEBKIT_SUBSYSTEM)
+PAL_LOG_CHANNELS(DEFINE_PAL_LOG_CHANNEL)
+
+static WTFLogChannel* logChannels[] = {
+    PAL_LOG_CHANNELS(LOG_CHANNEL_ADDRESS)
+};
+
+static const size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels);
+
+bool isLogChannelEnabled(const String& name)
+{
+    WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
+    if (!channel)
+        return false;
+    return channel->state != WTFLogChannelOff;
+}
+
+static bool logChannelsNeedInitialization = true;
+
+void setLogChannelToAccumulate(const String& name)
+{
+    WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
+    if (!channel)
+        return;
+
+    channel->state = WTFLogChannelOnWithAccumulation;
+    logChannelsNeedInitialization = true;
+}
+
+void initializeLogChannelsIfNecessary(std::optional<String> logChannelString)
+{
+    if (!logChannelsNeedInitialization && !logChannelString)
+        return;
+
+    logChannelsNeedInitialization = false;
+
+    String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();
+    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
+}
+
+#ifndef NDEBUG
+void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback)
+{
+#if PLATFORM(COCOA)
+    int token;
+    notify_register_dispatch(notifyID.utf8().data(), &token, dispatch_get_main_queue(), BlockPtr<void(int)>::fromCallable([callback = WTFMove(callback)](int) {
+        callback();
+    }).get());
+#else
+    UNUSED_PARAM(notifyID);
+    UNUSED_PARAM(callback);
+#endif
+}
+#endif
+
+#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+} // namespace WebCore
+

Copied: trunk/Source/WebCore/PAL/pal/Logging.h (from rev 223205, trunk/Source/WebCore/platform/LogMacros.h) (0 => 223206)


--- trunk/Source/WebCore/PAL/pal/Logging.h	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/Logging.h	2017-10-11 20:30:16 UTC (rev 223206)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2003-2017 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "LogMacros.h"
+#include <wtf/Assertions.h>
+#include <wtf/Forward.h>
+
+namespace PAL {
+
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+#ifndef LOG_CHANNEL_PREFIX
+#define LOG_CHANNEL_PREFIX PALLog
+#endif
+
+#define PAL_LOG_CHANNELS(M) \
+    M(Network) \
+
+PAL_LOG_CHANNELS(DECLARE_LOG_CHANNEL)
+
+String logLevelString();
+bool isLogChannelEnabled(const String& name);
+PAL_EXPORT void setLogChannelToAccumulate(const String& name);
+#ifndef NDEBUG
+void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback);
+#endif
+
+#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+} // namespace PAL
+

Modified: trunk/Source/WebCore/PAL/pal/PlatformMac.cmake (223205 => 223206)


--- trunk/Source/WebCore/PAL/pal/PlatformMac.cmake	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/PAL/pal/PlatformMac.cmake	2017-10-11 20:30:16 UTC (rev 223206)
@@ -3,6 +3,8 @@
 
     cf/CoreMediaSoftLink.cpp
 
+    cocoa/LoggingCocoa.mm
+
     crypto/commoncrypto/CryptoDigestCommonCrypto.cpp
 
     system/cocoa/SleepDisablerCocoa.cpp

Copied: trunk/Source/WebCore/PAL/pal/cocoa/LoggingCocoa.mm (from rev 223205, trunk/Source/WebCore/platform/LogMacros.h) (0 => 223206)


--- trunk/Source/WebCore/PAL/pal/cocoa/LoggingCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/cocoa/LoggingCocoa.mm	2017-10-11 20:30:16 UTC (rev 223206)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2003, 2006, 2013 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Logging.h"
+
+#include <wtf/text/WTFString.h>
+
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+
+namespace PAL {
+
+static NSString * const defaultsDomain = @"PALLogging";
+
+String logLevelString()
+{
+    return [[NSUserDefaults standardUserDefaults] stringForKey:defaultsDomain];
+}
+
+}
+
+#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
+

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (223205 => 223206)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-11 20:30:16 UTC (rev 223206)
@@ -531,7 +531,6 @@
 		0FDA7C261883333200C954B5 /* JSWebKitPlaybackTargetAvailabilityEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FDA7C241883333200C954B5 /* JSWebKitPlaybackTargetAvailabilityEvent.cpp */; };
 		0FDA7C271883333200C954B5 /* JSWebKitPlaybackTargetAvailabilityEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FDA7C251883333200C954B5 /* JSWebKitPlaybackTargetAvailabilityEvent.h */; };
 		0FDCD7F31D47E655009F08BC /* LogInitialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FDCD7F21D47E655009F08BC /* LogInitialization.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		0FDCD7F51D47E725009F08BC /* LogMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FDCD7F41D47E725009F08BC /* LogMacros.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0FDF45A71BD1C6FD00E4FA8C /* PlatformCAAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FDF45A61BD1C6FD00E4FA8C /* PlatformCAAnimation.cpp */; };
 		0FDF45A91BD1C82500E4FA8C /* TimingFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FDF45A81BD1C82500E4FA8C /* TimingFunction.cpp */; };
 		0FE5806319327A6200DE32EB /* ScrollingTreeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE5806119327A6200DE32EB /* ScrollingTreeMac.cpp */; };
@@ -8097,7 +8096,6 @@
 		0FDA7C241883333200C954B5 /* JSWebKitPlaybackTargetAvailabilityEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitPlaybackTargetAvailabilityEvent.cpp; sourceTree = "<group>"; };
 		0FDA7C251883333200C954B5 /* JSWebKitPlaybackTargetAvailabilityEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitPlaybackTargetAvailabilityEvent.h; sourceTree = "<group>"; };
 		0FDCD7F21D47E655009F08BC /* LogInitialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogInitialization.h; sourceTree = "<group>"; };
-		0FDCD7F41D47E725009F08BC /* LogMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogMacros.h; sourceTree = "<group>"; };
 		0FDF45A61BD1C6FD00E4FA8C /* PlatformCAAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCAAnimation.cpp; sourceTree = "<group>"; };
 		0FDF45A81BD1C82500E4FA8C /* TimingFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimingFunction.cpp; sourceTree = "<group>"; };
 		0FE5806119327A6200DE32EB /* ScrollingTreeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeMac.cpp; sourceTree = "<group>"; };
@@ -24781,7 +24779,6 @@
 				A8239DFE09B3CF8A00B60641 /* Logging.cpp */,
 				A8239DFF09B3CF8A00B60641 /* Logging.h */,
 				0FDCD7F21D47E655009F08BC /* LogInitialization.h */,
-				0FDCD7F41D47E725009F08BC /* LogMacros.h */,
 				46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */,
 				46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */,
 				7AE6C9391BE0C60100E19E03 /* MainThreadSharedTimer.cpp */,
@@ -29384,7 +29381,6 @@
 				A8239E0109B3CF8A00B60641 /* Logging.h in Headers */,
 				9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */,
 				0FDCD7F31D47E655009F08BC /* LogInitialization.h in Headers */,
-				0FDCD7F51D47E725009F08BC /* LogMacros.h in Headers */,
 				93A806171E03B51C008A1F26 /* LongRange.h in Headers */,
 				46EFAF121E5FB9F100E7F34B /* LowPowerModeNotifier.h in Headers */,
 				1A0409DC1A4360B5009E47F3 /* MachSendRight.h in Headers */,

Modified: trunk/Source/WebCore/page/mac/PageMac.mm (223205 => 223206)


--- trunk/Source/WebCore/page/mac/PageMac.mm	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/page/mac/PageMac.mm	2017-10-11 20:30:16 UTC (rev 223206)
@@ -35,6 +35,7 @@
 #import "Logging.h"
 #import "MainFrame.h"
 #import "RenderObject.h"
+#import <pal/Logging.h>
 
 #if PLATFORM(IOS)
 #import "WebCoreThreadInternal.h"
@@ -61,8 +62,8 @@
 #if ENABLE(TREE_DEBUGGING)
     static std::once_flag onceFlag;
     std::call_once(onceFlag, [] {
-        registerNotifyCallback("com.apple.WebKit.showRenderTree", printRenderTreeForLiveDocuments);
-        registerNotifyCallback("com.apple.WebKit.showLayerTree", printLayerTreeForLiveDocuments);
+        PAL::registerNotifyCallback("com.apple.WebKit.showRenderTree", printRenderTreeForLiveDocuments);
+        PAL::registerNotifyCallback("com.apple.WebKit.showLayerTree", printLayerTreeForLiveDocuments);
     });
 #endif
 }

Deleted: trunk/Source/WebCore/platform/LogMacros.h (223205 => 223206)


--- trunk/Source/WebCore/platform/LogMacros.h	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/platform/LogMacros.h	2017-10-11 20:30:16 UTC (rev 223206)
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015, 2016 Apple Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if LOG_DISABLED
-
-#define LOG_WITH_STREAM(channel, commands) ((void)0)
-
-#else
-
-#define LOG_WITH_STREAM(channel, commands) do { \
-        WTF::TextStream stream(WTF::TextStream::LineMode::SingleLine); \
-        commands; \
-        WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), "%s", stream.release().utf8().data()); \
-    } while (0)
-
-#endif // !LOG_DISABLED

Modified: trunk/Source/WebCore/platform/Logging.cpp (223205 => 223206)


--- trunk/Source/WebCore/platform/Logging.cpp	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/platform/Logging.cpp	2017-10-11 20:30:16 UTC (rev 223206)
@@ -80,21 +80,6 @@
     WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
 }
 
-#ifndef NDEBUG
-void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback)
-{
-#if PLATFORM(COCOA)
-    int token;
-    notify_register_dispatch(notifyID.utf8().data(), &token, dispatch_get_main_queue(), BlockPtr<void (int)>::fromCallable([callback = WTFMove(callback)] (int) {
-        callback();
-    }).get());
-#else
-    UNUSED_PARAM(notifyID);
-    UNUSED_PARAM(callback);
-#endif
-}
-#endif
-
 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/Logging.h (223205 => 223206)


--- trunk/Source/WebCore/platform/Logging.h	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/platform/Logging.h	2017-10-11 20:30:16 UTC (rev 223206)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "LogMacros.h"
+#include <pal/LogMacros.h>
 #include <wtf/Assertions.h>
 #include <wtf/Forward.h>
 
@@ -105,9 +105,6 @@
 String logLevelString();
 bool isLogChannelEnabled(const String& name);
 WEBCORE_EXPORT void setLogChannelToAccumulate(const String& name);
-#ifndef NDEBUG
-void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback);
-#endif
 
 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
 

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (223205 => 223206)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-10-11 20:30:16 UTC (rev 223206)
@@ -53,6 +53,7 @@
 #include "SimpleLineLayoutTextFragmentIterator.h"
 #include "Text.h"
 #include "TextPaintStyle.h"
+#include <pal/Logging.h>
 
 namespace WebCore {
 namespace SimpleLineLayout {
@@ -254,9 +255,9 @@
 #ifndef NDEBUG
     static std::once_flag onceFlag;
     std::call_once(onceFlag, [] {
-        registerNotifyCallback("com.apple.WebKit.showSimpleLineLayoutCoverage", WTF::Function<void()> { printSimpleLineLayoutCoverage });
-        registerNotifyCallback("com.apple.WebKit.showSimpleLineLayoutReasons", WTF::Function<void()> { printSimpleLineLayoutBlockList });
-        registerNotifyCallback("com.apple.WebKit.toggleSimpleLineLayout", WTF::Function<void()> { toggleSimpleLineLayout });
+        PAL::registerNotifyCallback("com.apple.WebKit.showSimpleLineLayoutCoverage", WTF::Function<void()> { printSimpleLineLayoutCoverage });
+        PAL::registerNotifyCallback("com.apple.WebKit.showSimpleLineLayoutReasons", WTF::Function<void()> { printSimpleLineLayoutBlockList });
+        PAL::registerNotifyCallback("com.apple.WebKit.toggleSimpleLineLayout", WTF::Function<void()> { toggleSimpleLineLayout });
     });
 #endif
     AvoidanceReasonFlags reasons = { };

Modified: trunk/Source/WebKit/ChangeLog (223205 => 223206)


--- trunk/Source/WebKit/ChangeLog	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebKit/ChangeLog	2017-10-11 20:30:16 UTC (rev 223206)
@@ -1,3 +1,13 @@
+2017-10-11  Myles C. Maxfield  <[email protected]>
+
+        Allow PAL to log messages
+        https://bugs.webkit.org/show_bug.cgi?id=171523
+
+        Reviewed by Alex Christensen.
+
+        * Platform/Logging.h:
+        * Scripts/generate-forwarding-headers.pl:
+
 2017-10-11  Ryosuke Niwa  <[email protected]>
 
         Sanitize URL in pasteboard for other applications and cross origin content

Modified: trunk/Source/WebKit/Platform/Logging.h (223205 => 223206)


--- trunk/Source/WebKit/Platform/Logging.h	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebKit/Platform/Logging.h	2017-10-11 20:30:16 UTC (rev 223206)
@@ -23,10 +23,9 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebKitLogging_h
-#define WebKitLogging_h
+#pragma once
 
-#include <WebCore/LogMacros.h>
+#include <pal/LogMacros.h>
 #include <wtf/Assertions.h>
 #include <wtf/text/WTFString.h>
 
@@ -84,4 +83,3 @@
 
 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
 
-#endif // Logging_h

Modified: trunk/Source/WebKit/Scripts/generate-forwarding-headers.pl (223205 => 223206)


--- trunk/Source/WebKit/Scripts/generate-forwarding-headers.pl	2017-10-11 20:16:37 UTC (rev 223205)
+++ trunk/Source/WebKit/Scripts/generate-forwarding-headers.pl	2017-10-11 20:30:16 UTC (rev 223206)
@@ -37,7 +37,7 @@
 my $srcRoot = realpath(File::Spec->catfile(dirname(abs_path($0)), "../.."));
 my @platformPrefixes = ("ca", "cf", "cocoa", "Cocoa", "CoordinatedGraphics", "curl", "gtk", "ios", "mac", "soup", "win", "wpe");
 my @frameworks = ("_javascript_Core", "WebCore", "WebKit");
-my @skippedPrefixes;
+my @skippedPrefixes = ("PAL");
 my @frameworkHeaders;
 my $framework;
 my %neededHeaders;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to