summaryrefslogtreecommitdiffstats
path: root/client
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 /client
parent54e36557c3062d1d5b5fabef561e34847ecde9be (diff)
downloadvaadin-framework-7bf4f7ade8a022119b4c00c8d92e3474a3b2652b.tar.gz
vaadin-framework-7bf4f7ade8a022119b4c00c8d92e3474a3b2652b.zip
Detect Chrome on iOS as Chrome + Webkit (#9138)
Diffstat (limited to 'client')
-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
6 files changed, 39 insertions, 19 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);