summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-04-25 15:21:30 +0300
committerHenri Sara <henri.sara@gmail.com>2017-04-25 15:21:30 +0300
commit7bf4f7ade8a022119b4c00c8d92e3474a3b2652b (patch)
treec29d5f57fd0936790fb464e5a8669ccd8a4d16f5
parent54e36557c3062d1d5b5fabef561e34847ecde9be (diff)
downloadvaadin-framework-7bf4f7ade8a022119b4c00c8d92e3474a3b2652b.tar.gz
vaadin-framework-7bf4f7ade8a022119b4c00c8d92e3474a3b2652b.zip
Detect Chrome on iOS as Chrome + Webkit (#9138)
-rw-r--r--client/src/main/java/com/vaadin/client/BrowserInfo.java4
-rw-r--r--client/src/main/java/com/vaadin/client/ResourceLoader.java2
-rw-r--r--client/src/main/java/com/vaadin/client/WidgetUtil.java20
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VButton.java9
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VTabsheet.java2
-rw-r--r--client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java21
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java7
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java2
-rw-r--r--server/src/main/java/com/vaadin/server/WebBrowser.java4
-rw-r--r--shared/src/main/java/com/vaadin/shared/VBrowserDetails.java20
10 files changed, 64 insertions, 27 deletions
diff --git a/client/src/main/java/com/vaadin/client/BrowserInfo.java b/client/src/main/java/com/vaadin/client/BrowserInfo.java
index ecd4e3fd28..7c5c4c8fd0 100644
--- a/client/src/main/java/com/vaadin/client/BrowserInfo.java
+++ b/client/src/main/java/com/vaadin/client/BrowserInfo.java
@@ -253,6 +253,10 @@ public class BrowserInfo {
return browserDetails.isSafari();
}
+ public boolean isSafariOrIOS() {
+ return browserDetails.isSafariOrIOS();
+ }
+
@Deprecated
public boolean isIE8() {
return isIE() && getBrowserMajorVersion() == 8;
diff --git a/client/src/main/java/com/vaadin/client/ResourceLoader.java b/client/src/main/java/com/vaadin/client/ResourceLoader.java
index d1f615a068..1f8266a98b 100644
--- a/client/src/main/java/com/vaadin/client/ResourceLoader.java
+++ b/client/src/main/java/com/vaadin/client/ResourceLoader.java
@@ -329,7 +329,7 @@ public class ResourceLoader {
linkElement.setType("text/css");
linkElement.setHref(url);
- if (BrowserInfo.get().isSafari()) {
+ if (BrowserInfo.get().isSafariOrIOS()) {
// Safari doesn't fire any events for link elements
// See http://www.phpied.com/when-is-a-stylesheet-really-loaded/
Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() {
diff --git a/client/src/main/java/com/vaadin/client/WidgetUtil.java b/client/src/main/java/com/vaadin/client/WidgetUtil.java
index 47aba0271c..b9ea8b81b7 100644
--- a/client/src/main/java/com/vaadin/client/WidgetUtil.java
+++ b/client/src/main/java/com/vaadin/client/WidgetUtil.java
@@ -496,7 +496,7 @@ public class WidgetUtil {
// updated when collapsing/expanding columns
// Also appeared in Safari 5.1 with webkit 534 (#7667)
if ((BrowserInfo.get().isChrome() || (BrowserInfo.get()
- .isSafari()
+ .isSafariOrIOS()
&& BrowserInfo.get().getWebkitVersion() >= 534))
&& (scrollleft > 0 || elem.getScrollLeft() > 0)) {
int scrollvalue = scrollleft;
@@ -794,7 +794,7 @@ public class WidgetUtil {
com.google.gwt.dom.client.Element el, String p)
/*-{
try {
-
+
if (el.currentStyle) {
// IE
return el.currentStyle[p];
@@ -809,7 +809,7 @@ public class WidgetUtil {
} catch (e) {
return "";
}
-
+
}-*/;
/**
@@ -823,7 +823,7 @@ public class WidgetUtil {
try {
el.focus();
} catch (e) {
-
+
}
}-*/;
@@ -1119,7 +1119,7 @@ public class WidgetUtil {
if ($wnd.document.activeElement) {
return $wnd.document.activeElement;
}
-
+
return null;
}-*/;
@@ -1190,11 +1190,11 @@ public class WidgetUtil {
/*-{
var top = elem.offsetTop;
var height = elem.offsetHeight;
-
+
if (elem.parentNode != elem.offsetParent) {
top -= elem.parentNode.offsetTop;
}
-
+
var cur = elem.parentNode;
while (cur && (cur.nodeType == 1)) {
if (top < cur.scrollTop) {
@@ -1203,12 +1203,12 @@ public class WidgetUtil {
if (top + height > cur.scrollTop + cur.clientHeight) {
cur.scrollTop = (top + height) - cur.clientHeight;
}
-
+
var offsetTop = cur.offsetTop;
if (cur.parentNode != cur.offsetParent) {
offsetTop -= cur.parentNode.offsetTop;
}
-
+
top += offsetTop - cur.scrollTop;
cur = cur.parentNode;
}
@@ -1648,7 +1648,7 @@ public class WidgetUtil {
}
var heightWithoutBorder = cloneElement.offsetHeight;
parentElement.removeChild(cloneElement);
-
+
return heightWithBorder - heightWithoutBorder;
}
}-*/;
diff --git a/client/src/main/java/com/vaadin/client/ui/VButton.java b/client/src/main/java/com/vaadin/client/ui/VButton.java
index f872292bf6..3bb6c5a1e8 100644
--- a/client/src/main/java/com/vaadin/client/ui/VButton.java
+++ b/client/src/main/java/com/vaadin/client/ui/VButton.java
@@ -172,9 +172,10 @@ public class VButton extends FocusWidget implements ClickHandler {
// fix for #14632 - on mobile safari 8, if we press the button long
// enough, we might get two click events, so we are suppressing
// second if it is too soon
- boolean isPhantomClickPossible = BrowserInfo.get().isSafari()
- && BrowserInfo.get().isTouchDevice()
- && BrowserInfo.get().getBrowserMajorVersion() == 8;
+ BrowserInfo browserInfo = BrowserInfo.get();
+ boolean isPhantomClickPossible = browserInfo.isSafariOrIOS()
+ && browserInfo.isTouchDevice()
+ && browserInfo.getBrowserMajorVersion() == 8;
long clickTime = isPhantomClickPossible ? System.currentTimeMillis()
: 0;
// If clicks are currently disallowed or phantom, keep it from
@@ -328,7 +329,7 @@ public class VButton extends FocusWidget implements ClickHandler {
*/
@Override
public void onClick(ClickEvent event) {
- if (BrowserInfo.get().isSafari()) {
+ if (BrowserInfo.get().isSafariOrIOS()) {
VButton.this.setFocus(true);
}
diff --git a/client/src/main/java/com/vaadin/client/ui/VTabsheet.java b/client/src/main/java/com/vaadin/client/ui/VTabsheet.java
index ee9ef52154..97add9a0f9 100644
--- a/client/src/main/java/com/vaadin/client/ui/VTabsheet.java
+++ b/client/src/main/java/com/vaadin/client/ui/VTabsheet.java
@@ -1341,7 +1341,7 @@ public class VTabsheet extends VTabsheetBase
scroller.getStyle().setDisplay(Display.NONE);
}
- if (BrowserInfo.get().isSafari()) {
+ if (BrowserInfo.get().isSafariOrIOS()) {
/*
* another hack for webkits. tabscroller sometimes drops without
* "shaking it" reproducable in
diff --git a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
index ee9d9d996c..bc4b7d1524 100644
--- a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
+++ b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
@@ -55,6 +55,7 @@ public class VBrowserDetailsUserAgentParserTest {
private static final String EDGE_WINDOWS_10 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240";
private static final String PHANTOMJS_211_MAC = "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1";
+ private static final String CHROME_57_ON_IOS_10_3_1 = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/57.0.2987.137 Mobile/14E304 Safari/602.1";
@Test
public void testSafari3() {
@@ -205,6 +206,17 @@ public class VBrowserDetailsUserAgentParserTest {
}
@Test
+ public void testChromeIOS() {
+ VBrowserDetails bd = new VBrowserDetails(CHROME_57_ON_IOS_10_3_1);
+ assertWebKit(bd);
+ assertChrome(bd);
+ assertBrowserMajorVersion(bd, 57);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 602f);
+ assertIOS(bd, 10, 3);
+ }
+
+ @Test
public void testFirefox3() {
VBrowserDetails bd = new VBrowserDetails(FIREFOX30_WINDOWS);
assertGecko(bd);
@@ -349,7 +361,8 @@ public class VBrowserDetailsUserAgentParserTest {
@Test
public void testIE11Windows7CompatibilityViewIE7() {
- VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_7_COMPATIBILITY_VIEW_IE7);
+ VBrowserDetails bd = new VBrowserDetails(
+ IE11_WINDOWS_7_COMPATIBILITY_VIEW_IE7);
assertTrident(bd);
assertEngineVersion(bd, 7);
assertIE(bd);
@@ -360,7 +373,8 @@ public class VBrowserDetailsUserAgentParserTest {
@Test
public void testIE11Windows10CompatibilityViewIE7() {
- VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_10_COMPATIBILITY_VIEW_IE7);
+ VBrowserDetails bd = new VBrowserDetails(
+ IE11_WINDOWS_10_COMPATIBILITY_VIEW_IE7);
assertTrident(bd);
assertEngineVersion(bd, 7);
assertIE(bd);
@@ -371,7 +385,8 @@ public class VBrowserDetailsUserAgentParserTest {
@Test
public void testIE11InitialWindows10CompatibilityViewIE7() {
- VBrowserDetails bd = new VBrowserDetails(IE11_INITIAL_WINDOWS_10_COMPATIBILITY_VIEW_IE7);
+ VBrowserDetails bd = new VBrowserDetails(
+ IE11_INITIAL_WINDOWS_10_COMPATIBILITY_VIEW_IE7);
assertTrident(bd);
assertEngineVersion(bd, 7);
assertIE(bd);
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
index 3affa940fc..3328d926e6 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
@@ -5598,7 +5598,7 @@ public class VScrollTable extends FlowPanel
final Element cell = DOM.getChild(getElement(), cellIx);
Style wrapperStyle = cell.getFirstChildElement().getStyle();
int wrapperWidth = width;
- if (BrowserInfo.get().isWebkit()
+ if (BrowserInfo.get().isSafariOrIOS()
|| BrowserInfo.get().isOpera10()) {
/*
* Some versions of Webkit and Opera ignore the width
@@ -7381,11 +7381,10 @@ public class VScrollTable extends FlowPanel
rowRequestHandler.cancel();
- if (BrowserInfo.get().isSafari() && event != null && scrollTop == 0) {
+ if (BrowserInfo.get().isSafariOrIOS() && event != null && scrollTop == 0) {
// due to the webkitoverflowworkaround, top may sometimes report 0
// for webkit, although it really is not. Expecting to have the
- // correct
- // value available soon.
+ // correct value available soon.
Scheduler.get().scheduleDeferred(new Command() {
@Override
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java
index b42f04f9b9..cefd4f079e 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java
@@ -227,7 +227,7 @@ public class VTextArea extends VTextField implements DragImageModifier {
if (info.isFirefox()) {
return true;
}
- if (info.isSafari()) {
+ if (info.isSafariOrIOS()) {
return true;
}
// Vaadin 8 no longer supports IE10
diff --git a/server/src/main/java/com/vaadin/server/WebBrowser.java b/server/src/main/java/com/vaadin/server/WebBrowser.java
index 5c387d0c14..badc27c323 100644
--- a/server/src/main/java/com/vaadin/server/WebBrowser.java
+++ b/server/src/main/java/com/vaadin/server/WebBrowser.java
@@ -141,7 +141,9 @@ public class WebBrowser implements Serializable {
}
/**
- * Tests whether the user is using Safari.
+ * Tests whether the user is using Safari. Note that Chrome on iOS is not
+ * detected as Safari but as Chrome although the underlying browser engine
+ * is the same.
*
* @return true if the user is using Safari, false if the user is not using
* Safari or if no information on the browser is present
diff --git a/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java b/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java
index c3c1baa582..4fac5db636 100644
--- a/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java
+++ b/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java
@@ -79,7 +79,8 @@ public class VBrowserDetails implements Serializable {
isWebKit = !isTrident && userAgent.indexOf("applewebkit") != -1;
// browser name
- isChrome = userAgent.indexOf(" chrome/") != -1;
+ isChrome = userAgent.indexOf(" chrome/") != -1
+ || userAgent.indexOf(" crios/") != -1;
isOpera = userAgent.indexOf("opera") != -1;
isIE = userAgent.indexOf("msie") != -1 && !isOpera
&& (userAgent.indexOf("webtv") == -1);
@@ -163,7 +164,12 @@ public class VBrowserDetails implements Serializable {
int i = userAgent.indexOf(" firefox/") + 9;
parseVersionString(safeSubstring(userAgent, i, i + 5));
} else if (isChrome) {
- int i = userAgent.indexOf(" chrome/") + 8;
+ int i = userAgent.indexOf(" chrome/");
+ if (i != -1) {
+ i += " chrome/".length();
+ } else {
+ i = userAgent.indexOf(" crios/") + " crios/".length();
+ }
parseVersionString(safeSubstring(userAgent, i, i + 5));
} else if (isSafari) {
int i = userAgent.indexOf(" version/") + 9;
@@ -355,6 +361,16 @@ public class VBrowserDetails implements Serializable {
}
/**
+ * Tests if the browser is Safari or runs on IOS (covering also Chrome on
+ * iOS).
+ *
+ * @return true if it is Safari or running on IOS, false otherwise
+ */
+ public boolean isSafariOrIOS() {
+ return isSafari() || isIOS();
+ }
+
+ /**
* Tests if the browser is Chrome.
*
* @return true if it is Chrome, false otherwise