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 implementation of {@link com.google.gwt.user.client.impl.DOMImpl}.
23: */
24: public class DOMImplOpera extends DOMImplStandard {
25:
26: @Override
27: public native int eventGetButton(Event evt) /*-{
28: // Opera and IE disagree on what the button codes for left button should be.
29: // Translating to match IE standard.
30: var button = evt.button;
31: if(button == 0){
32: return 1;
33: } else {
34: return button || -1;
35: }
36: }-*/;
37:
38: @Override
39: public native int eventGetMouseWheelVelocityY(Event evt) /*-{
40: return evt.detail * 4 || -1;
41: }-*/;
42:
43: @Override
44: public native int getAbsoluteLeft(Element elem) /*-{
45: var left = 0;
46: var curr = elem.parentNode;
47: // This intentionally excludes body
48: while (curr != $doc.body) {
49:
50: // see https://bugs.opera.com/show_bug.cgi?id=249965
51: // The net effect is that TR and TBODY elemnts report the scroll offsets
52: // of the BODY and HTML elements instead of 0.
53: if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
54: left -= curr.scrollLeft;
55: }
56: curr = curr.parentNode;
57: }
58:
59: while (elem) {
60: left += elem.offsetLeft;
61: elem = elem.offsetParent;
62: }
63: return left;
64: }-*/;
65:
66: @Override
67: public native int getAbsoluteTop(Element elem) /*-{
68: var top = 0;
69:
70: // This intentionally excludes body
71: var curr = elem.parentNode;
72: while (curr != $doc.body) {
73: // see getAbsoluteLeft()
74: if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
75: top -= curr.scrollTop;
76: }
77: curr = curr.parentNode;
78: }
79:
80: while (elem) {
81: top += elem.offsetTop;
82: elem = elem.offsetParent;
83: }
84: return top;
85: }-*/;
86:
87: @Override
88: public native int windowGetClientHeight() /*-{
89: return $doc.body.clientHeight;
90: }-*/;
91:
92: @Override
93: public native int windowGetClientWidth() /*-{
94: return $doc.body.clientWidth;
95: }-*/;
96: }
|