Title: [232159] trunk/Source/WebCore
- Revision
- 232159
- Author
- [email protected]
- Date
- 2018-05-24 12:23:15 -0700 (Thu, 24 May 2018)
Log Message
Cache navigator.userAgent for performance
https://bugs.webkit.org/show_bug.cgi?id=185952
Reviewed by Geoffrey Garen.
Cache navigator.userAgent for performance. Previously, we would ask the client 5 times
while loading apple.com.
* page/Navigator.cpp:
(WebCore::Navigator::userAgent const):
* page/Navigator.h:
* page/NavigatorBase.h:
* page/NavigatorID.idl:
* page/WorkerNavigator.cpp:
(WebCore::WorkerNavigator::userAgent const):
* page/WorkerNavigator.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (232158 => 232159)
--- trunk/Source/WebCore/ChangeLog 2018-05-24 19:23:00 UTC (rev 232158)
+++ trunk/Source/WebCore/ChangeLog 2018-05-24 19:23:15 UTC (rev 232159)
@@ -1,5 +1,24 @@
2018-05-24 Chris Dumez <[email protected]>
+ Cache navigator.userAgent for performance
+ https://bugs.webkit.org/show_bug.cgi?id=185952
+
+ Reviewed by Geoffrey Garen.
+
+ Cache navigator.userAgent for performance. Previously, we would ask the client 5 times
+ while loading apple.com.
+
+ * page/Navigator.cpp:
+ (WebCore::Navigator::userAgent const):
+ * page/Navigator.h:
+ * page/NavigatorBase.h:
+ * page/NavigatorID.idl:
+ * page/WorkerNavigator.cpp:
+ (WebCore::WorkerNavigator::userAgent const):
+ * page/WorkerNavigator.h:
+
+2018-05-24 Chris Dumez <[email protected]>
+
Some of the work in initializeLogChannelsIfNecessary() is unnecessary for release builds
https://bugs.webkit.org/show_bug.cgi?id=185951
Modified: trunk/Source/WebCore/page/Navigator.cpp (232158 => 232159)
--- trunk/Source/WebCore/page/Navigator.cpp 2018-05-24 19:23:00 UTC (rev 232158)
+++ trunk/Source/WebCore/page/Navigator.cpp 2018-05-24 19:23:15 UTC (rev 232159)
@@ -77,17 +77,11 @@
return appVersion;
}
-String Navigator::userAgent() const
+const String& Navigator::userAgent() const
{
- if (!m_frame)
- return String();
-
- // If the frame is already detached, FrameLoader::userAgent may malfunction, because it calls a client method
- // that uses frame's WebView (at least, in Mac WebKit).
- if (!m_frame->page())
- return String();
-
- return m_frame->loader().userAgent(m_frame->document()->url());
+ if (m_userAgent.isNull() && m_frame && m_frame->page())
+ m_userAgent = m_frame->loader().userAgent(m_frame->document()->url());
+ return m_userAgent;
}
bool Navigator::onLine() const
Modified: trunk/Source/WebCore/page/Navigator.h (232158 => 232159)
--- trunk/Source/WebCore/page/Navigator.h 2018-05-24 19:23:00 UTC (rev 232158)
+++ trunk/Source/WebCore/page/Navigator.h 2018-05-24 19:23:15 UTC (rev 232159)
@@ -39,7 +39,7 @@
DOMMimeTypeArray& mimeTypes();
bool cookieEnabled() const;
bool javaEnabled() const;
- String userAgent() const final;
+ const String& userAgent() const final;
bool onLine() const final;
#if PLATFORM(IOS)
@@ -53,6 +53,7 @@
mutable RefPtr<DOMPluginArray> m_plugins;
mutable RefPtr<DOMMimeTypeArray> m_mimeTypes;
+ mutable String m_userAgent;
};
}
Modified: trunk/Source/WebCore/page/NavigatorBase.h (232158 => 232159)
--- trunk/Source/WebCore/page/NavigatorBase.h 2018-05-24 19:23:00 UTC (rev 232158)
+++ trunk/Source/WebCore/page/NavigatorBase.h 2018-05-24 19:23:15 UTC (rev 232159)
@@ -42,7 +42,7 @@
static String appName();
String appVersion() const;
- virtual String userAgent() const = 0;
+ virtual const String& userAgent() const = 0;
static String platform();
static String appCodeName();
Modified: trunk/Source/WebCore/page/NavigatorID.idl (232158 => 232159)
--- trunk/Source/WebCore/page/NavigatorID.idl 2018-05-24 19:23:00 UTC (rev 232158)
+++ trunk/Source/WebCore/page/NavigatorID.idl 2018-05-24 19:23:15 UTC (rev 232159)
@@ -35,7 +35,7 @@
readonly attribute DOMString platform;
readonly attribute DOMString product;
[Exposed=Window] readonly attribute DOMString productSub;
- readonly attribute DOMString userAgent;
+ [CachedAttribute] readonly attribute DOMString userAgent;
[Exposed=Window] readonly attribute DOMString vendor;
[Exposed=Window] readonly attribute DOMString vendorSub;
};
Modified: trunk/Source/WebCore/page/WorkerNavigator.cpp (232158 => 232159)
--- trunk/Source/WebCore/page/WorkerNavigator.cpp 2018-05-24 19:23:00 UTC (rev 232158)
+++ trunk/Source/WebCore/page/WorkerNavigator.cpp 2018-05-24 19:23:15 UTC (rev 232159)
@@ -36,7 +36,7 @@
{
}
-String WorkerNavigator::userAgent() const
+const String& WorkerNavigator::userAgent() const
{
return m_userAgent;
}
Modified: trunk/Source/WebCore/page/WorkerNavigator.h (232158 => 232159)
--- trunk/Source/WebCore/page/WorkerNavigator.h 2018-05-24 19:23:00 UTC (rev 232158)
+++ trunk/Source/WebCore/page/WorkerNavigator.h 2018-05-24 19:23:15 UTC (rev 232159)
@@ -35,7 +35,7 @@
public:
static Ref<WorkerNavigator> create(ScriptExecutionContext& context, const String& userAgent, bool isOnline) { return adoptRef(*new WorkerNavigator(context, userAgent, isOnline)); }
- String userAgent() const final;
+ const String& userAgent() const final;
bool onLine() const final;
void setIsOnline(bool isOnline) { m_isOnline = isOnline; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes