Bug 874792 - Make adjustment sign consistent and use a transform for moving the arrow. r=Enn

This commit is contained in:
Markus Stange 2014-01-08 10:35:19 +01:00
Родитель 09a84514ab
Коммит 1e6ad124bb
2 изменённых файлов: 7 добавлений и 12 удалений

Просмотреть файл

@ -1003,13 +1003,10 @@ nsMenuPopupFrame::SlideOrResize(nscoord& aScreenPoint, nscoord aSize,
{ {
// The popup may be positioned such that either the left/top or bottom/right // The popup may be positioned such that either the left/top or bottom/right
// is outside the screen - but never both. // is outside the screen - but never both.
if (aScreenPoint < aScreenBegin) { nscoord newPos =
*aOffset = aScreenBegin - aScreenPoint; std::max(aScreenBegin, std::min(aScreenEnd - aSize, aScreenPoint));
aScreenPoint = aScreenBegin; *aOffset = newPos - aScreenPoint;
} else if (aScreenPoint + aSize > aScreenEnd) { aScreenPoint = newPos;
*aOffset = aScreenPoint + aSize - aScreenEnd;
aScreenPoint = std::max(aScreenEnd - aSize, 0);
}
return std::min(aSize, aScreenEnd - aScreenPoint); return std::min(aSize, aScreenEnd - aScreenPoint);
} }

Просмотреть файл

@ -380,17 +380,16 @@
var position = this.alignmentPosition; var position = this.alignmentPosition;
var offset = this.alignmentOffset; var offset = this.alignmentOffset;
// if this panel has a "sliding" arrow, we may have previously set margins... // if this panel has a "sliding" arrow, we may have previously set margins...
arrowbox.style.removeProperty("margin"); arrowbox.style.removeProperty("transform");
if (position.indexOf("start_") == 0 || position.indexOf("end_") == 0) { if (position.indexOf("start_") == 0 || position.indexOf("end_") == 0) {
container.orient = ""; container.orient = "";
arrowbox.orient = "vertical"; arrowbox.orient = "vertical";
if (position.indexOf("_after") > 0) { if (position.indexOf("_after") > 0) {
arrowbox.pack = "end"; arrowbox.pack = "end";
arrowbox.style.marginBottom = offset + "px";
} else { } else {
arrowbox.pack = "start"; arrowbox.pack = "start";
arrowbox.style.marginTop = offset + "px";
} }
arrowbox.style.transform = "translate(0, " + -offset + "px)";
// The assigned side stays the same regardless of direction. // The assigned side stays the same regardless of direction.
var isRTL = (window.getComputedStyle(this).direction == "rtl"); var isRTL = (window.getComputedStyle(this).direction == "rtl");
@ -409,11 +408,10 @@
arrowbox.orient = ""; arrowbox.orient = "";
if (position.indexOf("_end") > 0) { if (position.indexOf("_end") > 0) {
arrowbox.pack = "end"; arrowbox.pack = "end";
arrowbox.style.marginRight = this.alignmentOffset + "px";
} else { } else {
arrowbox.pack = "start"; arrowbox.pack = "start";
arrowbox.style.marginLeft = this.alignmentOffset + "px";
} }
arrowbox.style.transform = "translate(" + -offset + "px, 0)";
if (position.indexOf("before_") == 0) { if (position.indexOf("before_") == 0) {
container.dir = "reverse"; container.dir = "reverse";