From: Matti Tahvonen Date: Tue, 22 Dec 2009 15:14:35 +0000 (+0000) Subject: fixes #3764, yet another webkit scrollbar issue fixed. Hopefully got it fixed without... X-Git-Tag: 6.7.0.beta1~2084^2~27 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1014f3598918a96054f84f55f21d8b3dabd6cf78;p=vaadin-framework.git fixes #3764, yet another webkit scrollbar issue fixed. Hopefully got it fixed without regressions (fought whole day with them). svn changeset:10530/svn branch:6.2 --- diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index a46f9fa7d7..ca0165974a 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -548,18 +548,29 @@ public class Util { if ("hidden".equals(originalOverflow)) { return; } + + // check the scrolltop value before hiding the element + final int scrolltop = elem.getScrollTop(); elem.getStyle().setProperty("overflow", "hidden"); DeferredCommand.addCommand(new Command() { public void execute() { // Dough, Safari scroll auto means actually just a moped elem.getStyle().setProperty("overflow", originalOverflow); - if (elem.getScrollTop() > 0) { + + if (scrolltop > 0 || elem.getScrollTop() > 0) { + int scrollvalue = scrolltop; + if (scrolltop == 0) { + // mysterious are the ways of webkits scrollbar + // handling. In some cases webkit reports bad (0) + // scrolltop before hiding the elment temporary, + // sometimes after. + scrollvalue = elem.getScrollTop(); + } // fix another bug where scrollbar remains in wrong // position - int scrolltop = elem.getScrollTop(); - elem.setScrollTop(scrolltop - 1); - elem.setScrollTop(scrolltop); + elem.setScrollTop(scrollvalue - 1); + elem.setScrollTop(scrollvalue); } } }); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 6e8d672493..8c26210369 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -2702,10 +2702,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler { if (currentlyVisible < pageLength && currentlyVisible < totalRows) { // shake scrollpanel to fill empty space - bodyContainer.setScrollPosition(bodyContainer - .getScrollPosition() + 1); - bodyContainer.setScrollPosition(bodyContainer - .getScrollPosition() - 1); + bodyContainer.setScrollPosition(scrollTop + 1); + bodyContainer.setScrollPosition(scrollTop - 1); } } } @@ -2876,6 +2874,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler { } private int contentAreaBorderHeight = -1; + private int scrollLeft; + private int scrollTop; /** * @return border top + border bottom of the scrollable area of table @@ -2954,8 +2954,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler { * user scrolls */ public void onScroll(ScrollEvent event) { - int scrollLeft = bodyContainer.getElement().getScrollLeft(); - int scrollTop = bodyContainer.getScrollPosition(); + scrollLeft = bodyContainer.getElement().getScrollLeft(); + scrollTop = bodyContainer.getScrollPosition(); if (!initializedAndAttached) { return; } @@ -2967,6 +2967,19 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler { rowRequestHandler.cancel(); + if (BrowserInfo.get().isSafari() && event != null && scrollTop == 0) { + // due to the webkitoverflowworkaround, top may sometimes report 0 + // for webkit, although it really is not. Expecting to have the + // correct + // value available soon. + DeferredCommand.addCommand(new Command() { + public void execute() { + onScroll(null); + } + }); + return; + } + // fix headers horizontal scrolling tHead.setHorizontalScrollPosition(scrollLeft);