ckyang74 / google-web-toolkit-incubator

Automatically exported from code.google.com/p/google-web-toolkit-incubator
0 stars 0 forks source link

CollapsiblePanel error upon construction when running in Dev Mode #369

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What version of gwt and gwt-incubator are you using?

GWT 2.1 and gwt-incubator from HEAD.

What OS and browser are you using?

Linux and Firefox 

Do you see this error in hosted mode, web mode, or both?

Hosted mode only.  Code within AbsolutePanel that is throwing the error is 
wrapped with 'if (!GWT.isProdMode()) ...'

(If possible, please include a test case that shows the problem)

Basically just do the following in you root panel and run in hosted mode:

   final CollapsiblePanel collapsiblePanel = new CollapsiblePanel();

In the Dev Mode window I'm seeing the following stack trace:

00:13:30.904 [ERROR] Warning: 
com.google.gwt.widgetideas.client.CollapsiblePanel$1 descendants will be 
incorrectly positioned, i.e. not relative to their parent element, when 
'position:static', which is the CSS default, is in effect. One possible fix is 
to call 'panel.getElement().getStyle().setPosition(Position.RELATIVE)'.
java.lang.IllegalStateException: 
com.google.gwt.widgetideas.client.CollapsiblePanel$1 is missing CSS 
'position:{relative,absolute,fixed}'    at 
com.google.gwt.user.client.ui.AbsolutePanel.verifyPositionNotStatic(AbsolutePane
l.java:232)     at 
com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:117)     at 
com.google.gwt.widgetideas.client.CollapsiblePanel.<init>(CollapsiblePanel.java:
320)

Hopefully using the test case you have generously provided, what steps will 
reproduce the problem?
1. Compile root panel that uses CollapsiblePanel.
2. Start in Hosted Mode.
3. Launch Default Browser (Firefox) and observe stack trace in Dev Mode window.

What is the expected output? What do you see instead?

Not expecting to see an error simply constructing a CollapsiblePanel.

Workaround if you have one: None.

Please provide any additional information below,  and thank you for taking the 
time and effort to report this issue, as good issue reports are critical for 
our quest to make GWT's new widgets and libraries shine.

Since this is happening during construction I have to believe the 
AbsolutePanel.add() method is correctly inserting the given widget (either the 
hoverBar or container) so it looks like the check is failing.

Looking at the HTML for this at the time the call to verifyPositionNotStatic it 
looks like this:

<div class="gwt-CollapsiblePanel" style="position: relative; overflow: 
visible;">
  <div style="position: absolute; left: 0px; top: 0px;" class="hover-bar"></div>
  <div style="position: absolute; left: 0px; top: 0px;" class="container"></div>
</div>

Seems right.

I ran this in the debugger and I believe within 
AbsolutePanel.verifyPositionNotStatic(Widget) the call to 
"w.getElement().getOffsetParent()" is not returning an Element.

  private void verifyPositionNotStatic(Widget w) {
    if (!GWT.isProdMode()) {
==>      if (w.getElement().getOffsetParent() != getElement()) {
        String className = getClass().getName();
        GWT.log("Warning: " + className + " descendants will be incorrectly "
            + "positioned, i.e. not relative to their parent element, when "
            + "'position:static', which is the CSS default, is in effect. One "
            + "possible fix is to call "
            + "'panel.getElement().getStyle().setPosition(Position.RELATIVE)'.",
            // Stack trace provides context for the developer
            new IllegalStateException(className
                + " is missing CSS 'position:{relative,absolute,fixed}'"));
      }
    }
  }

If I run this from the Eclipse Display window I get the following:

w.getElement().getOffsetParent()
    Evaluation failed. Reason(s):
        Method "getOffsetParent" with signature "()Lcom/google/gwt/dom/client/Element;" is not applicable on this object

If I step this in the debugger, within ModuleSpace.invokeNativeObject() I see a 
msgPrefix:

Something other than a Java object was returned from JSNI method 
'@com.google.gwt.dom.client.Element::getOffsetParent()'

Therefore, the conditional is failing and the error is being logged.

Original issue reported on code.google.com by mar...@google.com on 11 Aug 2010 at 1:40