DEV: Drop non-visualViewport Safari hacks (#15007)

DEV: Drop non-visualViewport Safari hacks (#15007)

Those were required pre-iOS 13.

diff --git a/app/assets/javascripts/discourse/app/components/emoji-picker.js b/app/assets/javascripts/discourse/app/components/emoji-picker.js
index 2018919..3d04b22 100644
--- a/app/assets/javascripts/discourse/app/components/emoji-picker.js
+++ b/app/assets/javascripts/discourse/app/components/emoji-picker.js
@@ -6,7 +6,7 @@ import {
   isSkinTonableEmoji,
 } from "pretty-text/emoji";
 import { emojiUnescape, emojiUrlFor } from "discourse/lib/text";
-import { escapeExpression, safariHacksDisabled } from "discourse/lib/utilities";
+import { escapeExpression } from "discourse/lib/utilities";
 import { later, schedule } from "@ember/runloop";
 import Component from "@ember/component";
 import { createPopper } from "@popperjs/core";
@@ -115,10 +115,7 @@ export default Component.extend({
         this.set("isLoading", false);
 
         schedule("afterRender", () => {
-          if (
-            (!this.site.isMobileDevice || this.isEditorFocused) &&
-            !safariHacksDisabled()
-          ) {
+          if (!this.site.isMobileDevice || this.isEditorFocused) {
             const filter = emojiPicker.querySelector("input.filter");
             filter && filter.focus();
 
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
index 8a769ce..d91dde1 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
@@ -1,11 +1,6 @@
 import Controller, { inject as controller } from "@ember/controller";
 import Session from "discourse/models/session";
-import {
-  iOSWithVisualViewport,
-  isiPad,
-  safariHacksDisabled,
-  setDefaultHomepage,
-} from "discourse/lib/utilities";
+import { setDefaultHomepage } from "discourse/lib/utilities";
 import {
   listColorSchemes,
   loadColorSchemeStylesheet,
@@ -73,18 +68,6 @@ export default Controller.extend({
   },
 
   @discourseComputed()
-  isiPad() {
-    // TODO: remove this preference checkbox when iOS adoption > 90%
-    // (currently only applies to iOS 12 and below)
-    return isiPad() && !iOSWithVisualViewport();
-  },
-
-  @discourseComputed()
-  disableSafariHacks() {
-    return safariHacksDisabled();
-  },
-
-  @discourseComputed()
   availableLocales() {
     return JSON.parse(this.siteSettings.available_locales);
   },
@@ -342,16 +325,6 @@ export default Controller.extend({
 
           this.homeChanged();
 
-          if (this.isiPad) {
-            if (safariHacksDisabled() !== this.disableSafariHacks) {
-              this.session.requiresRefresh = true;
-            }
-            localStorage.setItem(
-              "safari-hacks-disabled",
-              this.disableSafariHacks.toString()
-            );
-          }
-
           if (this.themeId !== this.currentThemeId) {
             reload();
           }
diff --git a/app/assets/javascripts/discourse/app/lib/safari-hacks.js b/app/assets/javascripts/discourse/app/lib/safari-hacks.js
index 3f6c17f..5d9f8f0 100644
--- a/app/assets/javascripts/discourse/app/lib/safari-hacks.js
+++ b/app/assets/javascripts/discourse/app/lib/safari-hacks.js
@@ -1,76 +1,8 @@
-import {
-  iOSWithVisualViewport,
-  safariHacksDisabled,
-} from "discourse/lib/utilities";
 import { INPUT_DELAY } from "discourse-common/config/environment";
 import discourseDebounce from "discourse-common/lib/debounce";
 import { helperContext } from "discourse-common/lib/helpers";
 import { later } from "@ember/runloop";
 
-// TODO: remove calcHeight once iOS 13 adoption > 90%
-// In iOS 13 and up we use visualViewport API to calculate height
-
-// we can't tell what the actual visible window height is
-// because we cannot account for the height of the mobile keyboard
-// and any other mobile autocomplete UI that may appear
-// so let's be conservative here rather than trying to max out every
-// available pixel of height for the editor
-function calcHeight() {
-  // estimate 270 px for keyboard
-  let withoutKeyboard = window.innerHeight - 270;
-  const min = 270;
-
-  // iPhone shrinks header and removes footer controls ( back / forward nav )
-  // at 39px we are at the largest viewport
-  const portrait = window.innerHeight > window.innerWidth;
-  const smallViewport =
-    (portrait ? window.screen.height : window.screen.width) -
-      window.innerHeight >
-    40;
-
-  if (portrait) {
-    // iPhone SE, it is super small so just
-    // have a bit of crop
-    if (window.screen.height === 568) {
-      withoutKeyboard = 270;
-    }
-
-    // iPhone 6/7/8
-    if (window.screen.height === 667) {
-      withoutKeyboard = smallViewport ? 295 : 325;
-    }
-
-    // iPhone 6/7/8 plus
-    if (window.screen.height === 736) {
-      withoutKeyboard = smallViewport ? 353 : 383;
-    }
-
-    // iPhone X
-    if (window.screen.height === 812) {
-      withoutKeyboard = smallViewport ? 340 : 370;
-    }
-
-    // iPhone Xs Max and iPhone Xʀ
-    if (window.screen.height === 896) {
-      withoutKeyboard = smallViewport ? 410 : 440;
-    }
-
-    // iPad can use innerHeight cause it renders nothing in the footer
-    if (window.innerHeight > 920) {
-      withoutKeyboard -= 45;
-    }
-  } else {
-    // landscape
-    // iPad, we have a bigger keyboard
-    if (window.innerHeight > 665) {
-      withoutKeyboard -= 128;
-    }
-  }
-
-  // iPad portrait also has a bigger keyboard
-  return Math.max(withoutKeyboard, min);
-}
-
 let workaroundActive = false;
 
 export function isWorkaroundActive() {
@@ -80,7 +12,7 @@ export function isWorkaroundActive() {
 // per http://stackoverflow.com/questions/29001977/safari-in-ios8-is-scrolling-screen-when-fixed-elements-get-focus/29064810
 function positioningWorkaround($fixedElement) {
   let caps = helperContext().capabilities;
-  if (!caps.isIOS || safariHacksDisabled()) {
+  if (!caps.isIOS) {
     return;
   }
 
@@ -91,8 +23,6 @@ function positioningWorkaround($fixedElement) {
   });
 
   const fixedElement = $fixedElement[0];
-  const oldHeight = fixedElement.style.height;
-
   let originalScrollTop = 0;
   let lastTouchedElement = null;
 
@@ -106,11 +36,6 @@ function positioningWorkaround($fixedElement) {
       }
 
       workaroundActive = false;
-
-      if (!iOSWithVisualViewport()) {
-        fixedElement.style.height = oldHeight;
-        later(() => $(fixedElement).removeClass("no-transition"), 500);
-      }
     }
   };
 
@@ -172,8 +97,8 @@ function positioningWorkaround($fixedElement) {
 
     let delay = caps.isIpadOS ? 350 : 150;
 
-    later(function () {
-      if (caps.isIpadOS && iOSWithVisualViewport()) {
+    later(() => {
+      if (caps.isIpadOS) {
         // disable hacks when using a hardware keyboard
         // by default, a hardware keyboard will show the keyboard accessory bar
         // whose height is currently 55px (using 75 for a bit of a buffer)
@@ -191,12 +116,6 @@ function positioningWorkaround($fixedElement) {
       document.body.classList.add("ios-safari-composer-hacks");
       window.scrollTo(0, 0);
 
-      if (!iOSWithVisualViewport()) {
-        const height = calcHeight();
-        fixedElement.style.height = height + "px";
-        $(fixedElement).addClass("no-transition");
-      }
-
       evt.preventDefault();
       _this.focus();
       workaroundActive = true;
diff --git a/app/assets/javascripts/discourse/app/lib/utilities.js b/app/assets/javascripts/discourse/app/lib/utilities.js
index acdc698..c6a5ca1 100644
--- a/app/assets/javascripts/discourse/app/lib/utilities.js
+++ b/app/assets/javascripts/discourse/app/lib/utilities.js
@@ -5,6 +5,7 @@ import { deepMerge } from "discourse-common/lib/object";
 import { escape } from "pretty-text/sanitizer";
 import { helperContext } from "discourse-common/lib/helpers";
 import toMarkdown from "discourse/lib/to-markdown";
+import deprecated from "discourse-common/lib/deprecated";
 
 let _defaultHomepage;
 

[... diff too long, it was truncated ...]

GitHub sha: cabacb5c48090ba12b307503b0d873fe4ffbaace

This commit appears in #15007 which was approved by pmusaraj. It was merged by CvX.