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