Thomas Broyer has posted comments on this change.

Change subject: making RootPanel.clear(true) respects GWT loader iframe
......................................................................


Patch Set 1:

(1 comment)

....................................................
File user/src/com/google/gwt/user/client/ui/RootPanel.java
Line 329:         if (!shouldNodeBeRemoved(child)) {
Deattaching/reattaching an iframe should result in reloading its page, and I don't think that's what we want:

When an iframe element is inserted into a document, the user agent must create a nested browsing context, and then process the iframe attributes for the first
 time.

 When an iframe element is removed from a document, the user agent must
 discard the nested browsing context.

This happens without any unload events firing (the nested browsing context and
 its Document are discarded, not unloaded).

— Source: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-iframe-element.html#the-iframe-element

Because it's only about one element (for now, but it should remain only a handful elements in the future at most), and it's inserted at the end of the body (well, OK, the module could then add other elements after that, but the original purpose of clearDom was to clear everything on load), how about skipping it in each iteration? Would it really slow down things?

 while (containerElement.hasChildNodes()) {
   Node child = containerElement.getFirstChild();
   while (!shouldNodeBeRemoved(child)) {
     child = child.getNextSibling();
   }
   containerElement.removeChild(child);
 }

Also, is there really a big difference between hasChildNodes/getFirstChild and i<getChildCount()/getChild(i) ? (and one that matters here, because I don't expect clearDom to be used that much, and in 99% of the cases it'll be used to remove a "loading" message, so losing a few milliseconds wouldn't really matter as the "loading" message would still be visible in the interim)

Another alternative would be to search for the first node that we want to keep and remove everything before it, and repeat that process until we reached the last child node. Or even better, mix getFirstChild and getNextSibling to really walk the DOM, skipping the appropriate nodes:

 Node child = containerElement.getFirstChild();
 while (child != null) {
   Node next = child.getNextSibling();
   if (shouldNodeBeRemoved(child)) {
     containerElement.removeChild(child);
   }
   child = next;
 }


--
To view, visit https://gwt-review.googlesource.com/3430
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If876b04c453a1d4e170870e97f3a82d0d86599d5
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Daniel Kurka <[email protected]>
Gerrit-Reviewer: Daniel Kurka <[email protected]>
Gerrit-Reviewer: Leeroy Jenkins <[email protected]>
Gerrit-Reviewer: Manuel Carrasco Moñino <[email protected]>
Gerrit-Reviewer: Thomas Broyer <[email protected]>
Gerrit-HasComments: Yes

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to