Sfoglia il codice sorgente

Better fix for #1923 - Panel issues in IE6

svn changeset:5468/svn branch:trunk
tags/6.7.0.beta1
Artur Signell 15 anni fa
parent
commit
4d3cdd25dc

+ 34
- 4
src/com/itmill/toolkit/terminal/gwt/client/Util.java Vedi File

@@ -53,10 +53,6 @@ public class Util {
Set<Container> parents = new HashSet<Container>();

for (Widget widget : widgets) {
/* ApplicationConnection.getConsole().log(
"Size changed for widget: "
+ widget.toString().split(">")[0]);
*/
Widget parent = widget.getParent();
while (parent != null && !(parent instanceof Container)) {
parent = parent.getParent();
@@ -215,4 +211,38 @@ public class Util {
/*-{
return element.cloneNode(deep);
}-*/;

public static int measureHorizontalPadding(Element element, int paddingGuess) {
String originalWidth = DOM.getStyleAttribute(element, "width");
int originalOffsetWidth = element.getOffsetWidth();
int widthGuess = (originalOffsetWidth + paddingGuess);
DOM.setStyleAttribute(element, "width", widthGuess + "px");
int padding = widthGuess - element.getOffsetWidth();

DOM.setStyleAttribute(element, "width", originalWidth);
return padding;
}

public static void setWidthExcludingPadding(Element element,
int requestedWidth, int paddingGuess) {

int widthGuess = requestedWidth - paddingGuess;
if (widthGuess < 0) {
widthGuess = 0;
}

DOM.setStyleAttribute(element, "width", widthGuess + "px");
int captionOffsetWidth = DOM.getElementPropertyInt(element,
"offsetWidth");

int actualPadding = captionOffsetWidth - widthGuess;

if (actualPadding != paddingGuess) {
DOM.setStyleAttribute(element, "width", requestedWidth
- actualPadding + "px");

}

}

}

+ 31
- 23
src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java Vedi File

@@ -240,29 +240,37 @@ public class IPanel extends SimplePanel implements Paintable,

public void iLayout(boolean runGeckoFix) {

// IE6 width fix
if (BrowserInfo.get().isIE6()) {
int captionOffsetWidth = DOM.getElementPropertyInt(captionNode,
"offsetWidth");
int borderWidthGuess = 200;
int widthGuess = captionOffsetWidth - borderWidthGuess;
if (widthGuess < 0) {
widthGuess = 0;
}
DOM.setStyleAttribute(contentNode, "width", widthGuess + "px");

int actualBorder = DOM.getElementPropertyInt(contentNode,
"offsetWidth")
- widthGuess;
if (actualBorder != borderWidthGuess) {
int realWidthIncludingBorder = captionOffsetWidth
- actualBorder;
if (realWidthIncludingBorder < 0) {
realWidthIncludingBorder = 0;
}
DOM.setStyleAttribute(contentNode, "width",
realWidthIncludingBorder + "px");
}
if (BrowserInfo.get().isIE6() && width != null && !width.equals("")) {
/*
* IE6 requires overflow-hidden elements to have a width specified
*/
/*
* Fixes #1923 IPanel: Horizontal scrollbar does not appear in IE6
* with wide content
*/

/*
* Caption must be shrunk for parent measurements to return correct
* result in IE6
*/
DOM.setStyleAttribute(captionNode, "width", "1px");

int parentPadding = Util.measureHorizontalPadding(getElement(), 0);

int parentWidthExcludingPadding = getElement().getOffsetWidth()
- parentPadding;

int captionMarginLeft = captionNode.getAbsoluteLeft()
- getElement().getAbsoluteLeft();
Util.setWidthExcludingPadding(captionNode,
parentWidthExcludingPadding - captionMarginLeft, 26);

int contentMarginLeft = contentNode.getAbsoluteLeft()
- getElement().getAbsoluteLeft();

Util.setWidthExcludingPadding(contentNode,
parentWidthExcludingPadding - contentMarginLeft, 2);

}

if (height != null && height != "") {

Loading…
Annulla
Salva