Fixed the return values of getAbsoluteTop/Left() in IE when the browser is zoomed in. Previously, getAbsoluteTop/Left() returned real coordinates instead of logical coordinates, as they do in FF.
Patch by: jlabanca
Review by: ecc
Issue: 3172
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4276 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
index 60e3bd1..d80ab61 100644
--- a/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
+++ b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
@@ -47,6 +47,7 @@
addIssue(new Issue2392());
addIssue(new Issue2443());
addIssue(new Issue2855());
+ addIssue(new Issue3172());
}
public void addVisuals() {
diff --git a/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue3172.java b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue3172.java
new file mode 100644
index 0000000..7d9a974
--- /dev/null
+++ b/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue3172.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.museum.client.defaultmuseum;
+
+import com.google.gwt.museum.client.common.AbstractIssue;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.MenuBar;
+import com.google.gwt.user.client.ui.MenuItem;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Verify that IE returns the correct value for getAbsoluteLeft() when zoomed
+ * in. The absolute left coordinate should NOT depend on the zoom. That is, an
+ * elements absoluteLeft position should be the same regardless of zoom (IE
+ * automatically multiplies it by the zoom).
+ */
+public class Issue3172 extends AbstractIssue {
+
+ @Override
+ public Widget createIssue() {
+ // Create a command that will execute on menu item selection
+ Command emptyCommand = new Command() {
+ public void execute() {
+ }
+ };
+
+ // Create a menu bar
+ MenuBar menu = new MenuBar();
+ menu.setWidth("500px");
+ menu.setAutoOpen(true);
+
+ // Create a sub menu of recent documents
+ MenuBar recentDocsMenu = new MenuBar(true);
+ recentDocsMenu.addItem("Document 0", emptyCommand);
+ recentDocsMenu.addItem("Document 1", emptyCommand);
+ recentDocsMenu.addItem("Document 2", emptyCommand);
+
+ // Create the file menu
+ MenuBar fileMenu = new MenuBar(true);
+ menu.addItem(new MenuItem("File", fileMenu));
+ fileMenu.addItem("New", emptyCommand);
+ fileMenu.addItem("Print", emptyCommand);
+ fileMenu.addItem("Recent Docs", recentDocsMenu);
+
+ // Create the edit menu
+ MenuBar editMenu = new MenuBar(true);
+ menu.addItem(new MenuItem("Edit", editMenu));
+ editMenu.addItem("Cut", emptyCommand);
+ editMenu.addItem("Copy", emptyCommand);
+ editMenu.addItem("Paste", emptyCommand);
+
+ // Create the help menu
+ MenuBar helpMenu = new MenuBar(true);
+ menu.addItem(new MenuItem("Help", helpMenu));
+ helpMenu.addItem("Settings", emptyCommand);
+ helpMenu.addItem("About", emptyCommand);
+
+ return menu;
+ }
+
+ @Override
+ public String getInstructions() {
+ return "In IE, press Ctrl++ to zoom in, then verify that the sub menus open"
+ + " in the correct locations.";
+ }
+
+ @Override
+ public String getSummary() {
+ return "getAbsoluteLeft() with zoom in IE";
+ }
+
+ @Override
+ public boolean hasCSS() {
+ return false;
+ }
+}
diff --git a/reference/code-museum/src/com/google/gwt/museum/public/DefaultMuseum.html b/reference/code-museum/src/com/google/gwt/museum/public/DefaultMuseum.html
index a4ffbdc..210131c 100644
--- a/reference/code-museum/src/com/google/gwt/museum/public/DefaultMuseum.html
+++ b/reference/code-museum/src/com/google/gwt/museum/public/DefaultMuseum.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Museum</title>
diff --git a/reference/code-museum/src/com/google/gwt/museum/public/Museum.html b/reference/code-museum/src/com/google/gwt/museum/public/Museum.html
index 6e53528..fa19fea 100644
--- a/reference/code-museum/src/com/google/gwt/museum/public/Museum.html
+++ b/reference/code-museum/src/com/google/gwt/museum/public/Museum.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Museum</title>
diff --git a/reference/code-museum/src/com/google/gwt/museum/public/SingleIssue.html b/reference/code-museum/src/com/google/gwt/museum/public/SingleIssue.html
index 8acd8e6..1d7ad13 100644
--- a/reference/code-museum/src/com/google/gwt/museum/public/SingleIssue.html
+++ b/reference/code-museum/src/com/google/gwt/museum/public/SingleIssue.html
@@ -1,4 +1,5 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Single issue from Museum</title>
diff --git a/user/src/com/google/gwt/dom/client/DOMImplIE6.java b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
index 14baeb8..36fad77 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplIE6.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
@@ -41,13 +41,15 @@
@Override
public native int getAbsoluteLeft(Element elem) /*-{
- return elem.getBoundingClientRect().left +
+ return (elem.getBoundingClientRect().left /
+ this.@com.google.gwt.dom.client.DOMImplIE6::getZoomMultiple()()) +
@com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollLeft;
}-*/;
@Override
public native int getAbsoluteTop(Element elem) /*-{
- return elem.getBoundingClientRect().top +
+ return (elem.getBoundingClientRect().top /
+ this.@com.google.gwt.dom.client.DOMImplIE6::getZoomMultiple()()) +
@com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollTop;
}-*/;
@@ -112,4 +114,15 @@
public native void setInnerText(Element elem, String text) /*-{
elem.innerText = text || '';
}-*/;
+
+ /**
+ * Get the zoom multiple based on the current IE zoom level. A multiple of
+ * 2.0 means that the user has zoomed in to 200%.
+ *
+ * @return the zoom multiple
+ */
+ @SuppressWarnings("unused")
+ private native double getZoomMultiple() /*-{
+ return $doc.body.parentElement.offsetWidth / $doc.body.offsetWidth;
+ }-*/;
}