Skip to content

Commit ffb9ff3

Browse files
author
jossonsmith
committed
IE will complain about minus css width, check minus css width/height before setting it
1 parent 2fc9de3 commit ffb9ff3

File tree

1 file changed

+17
-16
lines changed
  • sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets

1 file changed

+17
-16
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/ToolItem.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -578,49 +578,50 @@ void updateItemBounds(int w, int h) {
578578
if ((p.style & SWT.FLAT) != 0) {
579579
border = 2;
580580
}
581-
handle.style.width = (w - 8 - border) + "px";
582-
handle.style.height = (h - 5 - border) + "px";
581+
CSSStyle s = handle.style;
582+
s.width = Math.max(0, w - 8 - border) + "px";
583+
s.height = Math.max(0, h - 5 - border) + "px";
583584
if ((style & SWT.SEPARATOR) != 0) {
584585
if (control != null) {
585-
handle.style.width = w + "px";
586-
handle.style.height = h + "px";
586+
s.width = w + "px";
587+
s.height = h + "px";
587588
control.setSize(w, h);
588589
Point pt = getLocation();
589590
control.left = pt.x;
590591
control.top = pt.y;
591592
} else {
592-
handle.style.height = (h - 6) + "px";
593+
s.height = (h - 6) + "px";
593594
}
594595
} else if (!hasText/* && (style & SWT.SEPARATOR) == 0*/) {
595-
handle.style.width = (w - 8 - border) + "px";
596-
handle.style.height = (h - 5 - border) + "px";
596+
s.width = Math.max(0, w - 8 - border) + "px";
597+
s.height = Math.max(0, h - 5 - border) + "px";
597598
if (OS.isIE && (p.style & SWT.RIGHT) == 0) { // TODO: I hate this IE hacking!
598599
// 2 : padding between image and text?
599600
if (p.containsImage) {
600-
handle.style.fontSize = "0";
601+
s.fontSize = "0";
601602
if (hasImage && p.containsText) {
602-
handle.style.height = (h - 5 - border - 2) + "px";
603+
s.height = Math.max(0, h - 5 - border - 2) + "px";
603604
} else {
604-
handle.style.height = (h - 5 - border - 1) + "px";
605+
s.height = Math.max(0, h - 5 - border - 1) + "px";
605606
}
606607
} else {
607-
handle.style.fontSize = "0";
608-
handle.style.height = (h - 5 - border + 1) + "px";
608+
s.fontSize = "0";
609+
s.height = Math.max(0, h - 5 - border + 1) + "px";
609610
}
610611
}
611612
if (!p.containsText) {
612-
handle.style.backgroundPosition = "center center";
613+
s.backgroundPosition = "center center";
613614
} else if ((parent.style & SWT.RIGHT) == 0) {
614-
handle.style.backgroundPosition = "center top";
615+
s.backgroundPosition = "center top";
615616
} else {
616-
handle.style.backgroundPosition = "left center";
617+
s.backgroundPosition = "left center";
617618
}
618619
}
619620
if (OS.isIE && dropDownEl != null) { // TODO: I hate this IE hacking!
620621
dropDownEl.style.height = (h - border + 1) + "px";
621622
if (hasImage && (p.style & SWT.RIGHT) == 0) {
622623
// 2 : padding between image and text?
623-
dropDownEl.style.height = (h - 2 - border) + "px";
624+
dropDownEl.style.height = Math.max(0, h - 2 - border) + "px";
624625
}
625626
//dropDownEl.childNodes[0].style.top = ((h - 5 - border - 4) / 2 - 7) + "px";
626627
}

0 commit comments

Comments
 (0)