KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 /**
21  * DOM implementation differences for older version of Mozilla (mostly the
22  * hosted mode browser on linux). The main difference is due to changes in
23  * getBoxObjectFor in later versions of mozilla. The relevant bugzilla issues:
24  * https://bugzilla.mozilla.org/show_bug.cgi?id=328881
25  * https://bugzilla.mozilla.org/show_bug.cgi?id=330619
26  */

27 public class DOMImplMozillaOld extends DOMImplMozilla {
28   
29   public native int getAbsoluteLeft(Element elem) /*-{
30     var style = $doc.defaultView.getComputedStyle(elem, null);
31     var left = $doc.getBoxObjectFor(elem).x - Math.round(
32         style.getPropertyCSSValue('border-left-width').getFloatValue(
33         CSSPrimitiveValue.CSS_PX));
34     var parent = elem;
35
36     while (parent) {
37       // Sometimes get NAN.
38       if (parent.scrollLeft > 0) {
39         left -= parent.scrollLeft;
40       }
41       parent = parent.parentNode;
42     }
43
44     // Must cover both Standard and Quirks mode.
45     return left + $doc.body.scrollLeft + $doc.documentElement.scrollLeft;
46   }-*/
;
47
48   public native int getAbsoluteTop(Element elem) /*-{
49     var style = $doc.defaultView.getComputedStyle(elem, null);
50     var top = $doc.getBoxObjectFor(elem).y - Math.round(
51         style.getPropertyCSSValue('border-top-width').getFloatValue(
52         CSSPrimitiveValue.CSS_PX));
53       
54     var parent = elem;
55     while (parent) {
56       // Sometimes get NAN.
57       if (parent.scrollTop > 0) {
58         top -= parent.scrollTop;
59       }
60       parent = parent.parentNode;
61     }
62
63     // Must cover both Standard and Quirks mode.
64     return top + $doc.body.scrollTop + $doc.documentElement.scrollTop;
65   }-*/
;
66 }
67
Popular Tags