KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > impl > DOMImplOpera


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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   public native int eventGetButton(Event evt) /*-{
27     // Opera and IE disagree on what the button codes for left button should be.
28     // Translating to match IE standard.
29     var button = evt.button;
30     if(button == 0){
31       return 1;
32     } else {
33       return button;
34     }
35   }-*/
;
36
37   public native int eventGetMouseWheelVelocityY(Event evt) /*-{
38     return evt.detail * 4;
39   }-*/
;
40
41   public native int getAbsoluteLeft(Element elem) /*-{
42     var left = 0;
43     var curr = elem.parentNode;
44     // This intentionally excludes body
45     while (curr != $doc.body) {
46
47       // see https://bugs.opera.com/show_bug.cgi?id=249965
48       // The net effect is that TR and TBODY elemnts report the scroll offsets
49       // of the BODY and HTML elements instead of 0.
50       if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
51         left -= curr.scrollLeft;
52       }
53       curr = curr.parentNode;
54     }
55
56     while (elem) {
57       left += elem.offsetLeft;
58       elem = elem.offsetParent;
59     }
60     return left;
61   }-*/
;
62
63   public native int getAbsoluteTop(Element elem) /*-{
64     var top = 0;
65
66     // This intentionally excludes body
67     var curr = elem.parentNode;
68     while (curr != $doc.body) {
69       // see getAbsoluteLeft()
70       if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
71         top -= curr.scrollTop;
72       }
73       curr = curr.parentNode;
74     }
75
76     while (elem) {
77       top += elem.offsetTop;
78       elem = elem.offsetParent;
79     }
80     return top;
81   }-*/
;
82 }
83
Popular Tags