Title: [268473] trunk/Source
Revision
268473
Author
drou...@apple.com
Date
2020-10-14 10:50:54 -0700 (Wed, 14 Oct 2020)

Log Message

Web Inspector: REGRESSION(r267148): new Big Sur styles are not used
https://bugs.webkit.org/show_bug.cgi?id=217682
<rdar://problem/70269030>

Reviewed by Brian Burg.

r267148 changed `navigator.userAgent` from `11_0` to `10_15_7`. This breaks Web Inspector
styling, which relied on this value to know what OS version it was running on in order to
know which styles to use.

Source/WebCore:

* inspector/InspectorFrontendHost.idl:
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::platformVersionName const): Added.
Derive a lowercased kekab-cased platform version name from `__MAC_OS_X_VERSION_MIN_REQUIRED`.

Source/WebInspectorUI:

* UserInterface/Base/Platform.js:
* UserInterface/Views/Variables.css:
(body.mac-platform): Added.
(body.mac-platform:not(.sierra, .high-sierra)): Deleted.
Use `InspectorFrontendHost.platformVersionName` instead of `navigator.userAgent`. Remove
unnecessary platform version names and other unused data.

* UserInterface/Base/Main.js:
(WI.contentLoaded):
(WI.undockedTitleAreaHeight): Added.
* UserInterface/Views/Popover.js:
(WI.Popover.prototype._update):
Provide a way to get the undocked title area height for use in _javascript_ calculations.

* UserInterface/Controllers/HARBuilder.js:
(WI.HARBuilder.creator):
The `WI.Platform.version.build` hasn't changed in a long time, so just remove it.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268472 => 268473)


--- trunk/Source/WebCore/ChangeLog	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebCore/ChangeLog	2020-10-14 17:50:54 UTC (rev 268473)
@@ -1,3 +1,21 @@
+2020-10-14  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: REGRESSION(r267148): new Big Sur styles are not used
+        https://bugs.webkit.org/show_bug.cgi?id=217682
+        <rdar://problem/70269030>
+
+        Reviewed by Brian Burg.
+
+        r267148 changed `navigator.userAgent` from `11_0` to `10_15_7`. This breaks Web Inspector
+        styling, which relied on this value to know what OS version it was running on in order to
+        know which styles to use.
+
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::platformVersionName const): Added.
+        Derive a lowercased kekab-cased platform version name from `__MAC_OS_X_VERSION_MIN_REQUIRED`.
+
 2020-10-14  Zalan Bujtas  <za...@apple.com>
 
         [LFC] Use the term overridden instead of override to indicate priority values

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp (268472 => 268473)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2020-10-14 17:50:54 UTC (rev 268473)
@@ -389,6 +389,19 @@
 #endif
 }
 
+String InspectorFrontendHost::platformVersionName() const
+{
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
+    return "big-sur"_s;
+#elif PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
+    return "catalina"_s;
+#elif PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+    return "mojave"_s;
+#else
+    return emptyString();
+#endif
+}
+
 String InspectorFrontendHost::port() const
 {
 #if PLATFORM(GTK)

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.h (268472 => 268473)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.h	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.h	2020-10-14 17:50:54 UTC (rev 268473)
@@ -89,6 +89,7 @@
     unsigned inspectionLevel() const;
 
     String platform() const;
+    String platformVersionName() const;
     String port() const;
 
     struct DebuggableInfo {

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.idl (268472 => 268473)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.idl	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.idl	2020-10-14 17:50:54 UTC (rev 268473)
@@ -79,6 +79,7 @@
 
     readonly attribute DOMString port;
     readonly attribute DOMString platform;
+    readonly attribute DOMString platformVersionName;
 
     undefined showContextMenu(Event event, sequence<ContextMenuItem> items);
     undefined dispatchEventAsContextMenuEvent(Event event);

Modified: trunk/Source/WebInspectorUI/ChangeLog (268472 => 268473)


--- trunk/Source/WebInspectorUI/ChangeLog	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebInspectorUI/ChangeLog	2020-10-14 17:50:54 UTC (rev 268473)
@@ -1,3 +1,33 @@
+2020-10-14  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: REGRESSION(r267148): new Big Sur styles are not used
+        https://bugs.webkit.org/show_bug.cgi?id=217682
+        <rdar://problem/70269030>
+
+        Reviewed by Brian Burg.
+
+        r267148 changed `navigator.userAgent` from `11_0` to `10_15_7`. This breaks Web Inspector
+        styling, which relied on this value to know what OS version it was running on in order to
+        know which styles to use.
+
+        * UserInterface/Base/Platform.js:
+        * UserInterface/Views/Variables.css:
+        (body.mac-platform): Added.
+        (body.mac-platform:not(.sierra, .high-sierra)): Deleted.
+        Use `InspectorFrontendHost.platformVersionName` instead of `navigator.userAgent`. Remove
+        unnecessary platform version names and other unused data.
+
+        * UserInterface/Base/Main.js:
+        (WI.contentLoaded):
+        (WI.undockedTitleAreaHeight): Added.
+        * UserInterface/Views/Popover.js:
+        (WI.Popover.prototype._update):
+        Provide a way to get the undocked title area height for use in _javascript_ calculations.
+
+        * UserInterface/Controllers/HARBuilder.js:
+        (WI.HARBuilder.creator):
+        The `WI.Platform.version.build` hasn't changed in a long time, so just remove it.
+
 2020-10-13  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: Sources: tab has wrong icon when paused if added after pause

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (268472 => 268473)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2020-10-14 17:50:54 UTC (rev 268473)
@@ -220,10 +220,7 @@
 
     // Add platform style classes so the UI can be tweaked per-platform.
     document.body.classList.add(WI.Platform.name + "-platform");
-    if (WI.Platform.isNightlyBuild)
-        document.body.classList.add("nightly-build");
-
-    if (WI.Platform.name === "mac")
+    if (WI.Platform.version.name)
         document.body.classList.add(WI.Platform.version.name);
 
     document.body.classList.add(WI.sharedApp.debuggableType);
@@ -2773,6 +2770,27 @@
     InspectorFrontendHost.reopen();
 };
 
+WI.undockedTitleAreaHeight = function()
+{
+    if (WI.dockConfiguration !== WI.DockConfiguration.Undocked)
+        return 0;
+
+    if (WI.Platform.name === "mac") {
+        switch (WI.Platform.version.name) {
+        case "big-sur":
+            /* keep in sync with `body.mac-platform.big-sur:not(.docked)` */
+            return 27 / WI.getZoomFactor();
+
+        case "catalina":
+        case "mojave":
+            /* keep in sync with `body.mac-platform:not(.big-sur):not(.docked)` */
+            return 22 / WI.getZoomFactor();
+        }
+    }
+
+    return 0;
+};
+
 WI._showTabAtIndexFromShortcut = function(i)
 {
     if (i <= WI.tabBar.tabCount) {

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Platform.js (268472 => 268473)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Platform.js	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Platform.js	2020-10-14 17:50:54 UTC (rev 268473)
@@ -25,61 +25,7 @@
 
 WI.Platform = {
     name: InspectorFrontendHost.platform,
-    isNightlyBuild: false,
     version: {
-        base: 0,
-        release: 0,
-        name: "",
-        build: "",
+        name: InspectorFrontendHost.platformVersionName,
     }
 };
-
-(function () {
-    let versionMatch = / AppleWebKit\/([^ ]+)/.exec(navigator.userAgent);
-    if (versionMatch) {
-        WI.Platform.version.build = versionMatch[1];
-
-        // Check for a nightly build by looking for a plus in the version number and a small number of stylesheets (indicating combined resources).
-        if (versionMatch[1].indexOf("+") !== -1 && document.styleSheets.length < 10)
-            WI.Platform.isNightlyBuild = true;
-    }
-
-    let osVersionMatch = / Mac OS X (\d+)_(\d+)/.exec(navigator.appVersion);
-    if (osVersionMatch) {
-        WI.Platform.version.base = parseInt(osVersionMatch[1]);
-        WI.Platform.version.release = parseInt(osVersionMatch[2]);
-
-        switch (WI.Platform.version.base) {
-        case 10:
-            switch (WI.Platform.version.release) {
-            case 15:
-                WI.Platform.version.name = "catalina";
-                break;
-            case 14:
-                WI.Platform.version.name = "mojave";
-                break;
-            case 13:
-                WI.Platform.version.name = "high-sierra";
-                break;
-            case 12:
-                WI.Platform.version.name = "sierra";
-                break;
-            default:
-                WI.Platform.version.name = "unknown-mac";
-                break;
-            }
-            break;
-
-        case 11:
-            switch (WI.Platform.version.release) {
-            case 0:
-                WI.Platform.version.name = "big-sur";
-                break;
-            default:
-                WI.Platform.version.name = "unknown-mac";
-                break;
-            }
-            break;
-        }
-    }
-})();

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js (268472 => 268473)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js	2020-10-14 17:50:54 UTC (rev 268473)
@@ -60,7 +60,7 @@
     {
         return {
             name: "WebKit Web Inspector",
-            version: WI.Platform.version.build || "1.0",
+            version: "1.0",
         };
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Popover.js (268472 => 268473)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Popover.js	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Popover.js	2020-10-14 17:50:54 UTC (rev 268473)
@@ -235,7 +235,7 @@
             this._preferredSize = new WI.Size(Math.ceil(popoverBounds.width), Math.ceil(popoverBounds.height));
         }
 
-        var titleBarOffset = WI.Platform.name === "mac" ? 22 : 0;
+        var titleBarOffset = WI.undockedTitleAreaHeight();
         var containerFrame = new WI.Rect(0, titleBarOffset, window.innerWidth, window.innerHeight - titleBarOffset);
         // The frame of the window with a little inset to make sure we have room for shadows.
         containerFrame = containerFrame.inset(WI.Popover.ShadowEdgeInsets);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Variables.css (268472 => 268473)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Variables.css	2020-10-14 17:44:54 UTC (rev 268472)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Variables.css	2020-10-14 17:50:54 UTC (rev 268473)
@@ -245,10 +245,12 @@
 }
 
 body.mac-platform:not(.big-sur):not(.docked) {
+    /* keep in sync with `WI.undockedTitleAreaHeight` */
     --undocked-title-area-height: calc(22px / var(--zoom-factor));
 }
 
 body.mac-platform.big-sur:not(.docked) {
+    /* keep in sync with `WI.undockedTitleAreaHeight` */
     --undocked-title-area-height: calc(27px / var(--zoom-factor));
 }
 
@@ -412,7 +414,7 @@
     }
 }
 
-body.mac-platform:not(.sierra, .high-sierra) {
+body.mac-platform {
     --selected-foreground-color: -apple-system-alternate-selected-text;
     --selected-background-color: -apple-system-selected-content-background;
     --selected-text-background-color: -apple-system-selected-text-background;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to