01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.user.client.impl;
17:
18: import com.google.gwt.user.client.Element;
19: import com.google.gwt.user.client.Event;
20:
21: /**
22: * Opera fix for GWT bug 1556. The mygwt.jar must precede the GWT jars for this
23: * class to be visible.
24: */
25: public class DOMImplOpera extends DOMImplStandard {
26:
27: public native int windowGetClientHeight() /*-{
28: return $doc.body.clientHeight;
29: }-*/;
30:
31: public native int windowGetClientWidth() /*-{
32: return $doc.body.clientWidth;
33: }-*/;
34:
35: public native int eventGetButton(Event evt) /*-{
36: // Opera and IE disagree on what the button codes for left button should be.
37: // Translating to match IE standard.
38: var button = evt.button;
39: if(button == 0){
40: return 1;
41: } else {
42: return button || -1;
43: }
44: }-*/;
45:
46: public native int eventGetMouseWheelVelocityY(Event evt) /*-{
47: return evt.detail * 4 || -1;
48: }-*/;
49:
50: public native int getAbsoluteLeft(Element elem) /*-{
51: var left = 0;
52: var curr = elem.parentNode;
53: // This intentionally excludes body
54: while (curr && curr.offsetParent != null) {
55:
56: // see https://bugs.opera.com/show_bug.cgi?id=249965
57: // The net effect is that TR and TBODY elemnts report the scroll offsets
58: // of the BODY and HTML elements instead of 0.
59: if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
60: left -= curr.scrollLeft;
61: }
62: curr = curr.parentNode;
63: }
64:
65: while (elem) {
66: left += elem.offsetLeft;
67: elem = elem.offsetParent;
68: }
69: return left;
70: }-*/;
71:
72: public native int getAbsoluteTop(Element elem) /*-{
73: var top = 0;
74:
75: // This intentionally excludes body
76: var curr = elem.parentNode;
77: while (curr && curr.offsetParent != null) {
78: // see getAbsoluteLeft()
79: if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
80: top -= curr.scrollTop;
81: }
82: curr = curr.parentNode;
83: }
84:
85: while (elem) {
86: top += elem.offsetTop;
87: elem = elem.offsetParent;
88: }
89: return top;
90: }-*/;
91: }
|