зеркало из https://github.com/mozilla/gecko-dev.git
Родитель
038dcc7f63
Коммит
abeceb3744
|
@ -58,6 +58,7 @@
|
|||
#include "nsIScrollableView.h"
|
||||
#include "nsRepeatService.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsSprocketLayout.h"
|
||||
|
||||
#define DEBUG_SLIDER PR_FALSE
|
||||
|
||||
|
@ -293,25 +294,6 @@ nsSliderFrame::Layout(nsBoxLayoutState& aState)
|
|||
aState.GetPresContext()->GetScaledPixelsToTwips(&p2t);
|
||||
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
||||
|
||||
/*
|
||||
if (aReflowState.mComputedHeight == NS_INTRINSICSIZE)
|
||||
aDesiredSize.height = isHorizontal ? thumbSize.height : 200*onePixel;
|
||||
else {
|
||||
aDesiredSize.height = aReflowState.mComputedHeight;
|
||||
// if (aDesiredSize.height < thumbSize.height)
|
||||
// aDesiredSize.height = thumbSize.height;
|
||||
}
|
||||
|
||||
// set the width to the computed or if intrinsic then the width of the thumb.
|
||||
if (aReflowState.mComputedWidth == NS_INTRINSICSIZE)
|
||||
aDesiredSize.width = isHorizontal ? 200*onePixel : thumbSize.width;
|
||||
else {
|
||||
aDesiredSize.width = aReflowState.mComputedWidth;
|
||||
// if (aDesiredSize.width < thumbSize.width)
|
||||
// aDesiredSize.width = thumbSize.width;
|
||||
}
|
||||
*/
|
||||
|
||||
// get max pos in twips
|
||||
nscoord maxpos = maxpospx*onePixel;
|
||||
|
||||
|
@ -327,7 +309,7 @@ nsSliderFrame::Layout(nsBoxLayoutState& aState)
|
|||
// if there is more room than the thumb need stretch the
|
||||
// thumb
|
||||
|
||||
nscoord thumbsize = nscoord(ourmaxpos * mRatio);
|
||||
nscoord thumbsize = nsSprocketLayout::Round(nscoord(ourmaxpos * mRatio), onePixel);
|
||||
|
||||
if (thumbsize > thumbcoord) {
|
||||
nscoord flex = 0;
|
||||
|
@ -336,9 +318,9 @@ nsSliderFrame::Layout(nsBoxLayoutState& aState)
|
|||
// if the thumb is flexible make the thumb bigger.
|
||||
if (flex > 0) {
|
||||
if (isHorizontal)
|
||||
thumbSize.width = nscoord(ourmaxpos * mRatio);
|
||||
thumbSize.width = thumbsize;
|
||||
else
|
||||
thumbSize.height = nscoord(ourmaxpos * mRatio);
|
||||
thumbSize.height = thumbsize;
|
||||
}
|
||||
} else {
|
||||
ourmaxpos -= thumbcoord;
|
||||
|
|
|
@ -944,6 +944,16 @@ nsSprocketLayout::InvalidateComputedSizes(nsComputedBoxSize* aComputedBoxSizes)
|
|||
}
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsSprocketLayout::Round(PRInt32 aCoord, PRInt32 aOnePixel)
|
||||
{
|
||||
PRInt32 newCoordPx = aCoord/aOnePixel;
|
||||
PRInt32 diff = aCoord - (newCoordPx*aOnePixel);
|
||||
if (diff > aOnePixel/2)
|
||||
newCoordPx++;
|
||||
|
||||
return newCoordPx*aOnePixel;
|
||||
}
|
||||
|
||||
void
|
||||
nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
|
||||
|
@ -952,6 +962,11 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
|
|||
nsBoxSize* aBoxSizes,
|
||||
nsComputedBoxSize*& aComputedBoxSizes)
|
||||
{
|
||||
|
||||
float p2t;
|
||||
aState.GetPresContext()->GetScaledPixelsToTwips(&p2t);
|
||||
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
||||
|
||||
PRInt32 sizeRemaining = aGivenSize;
|
||||
PRInt32 springConstantsRemaining = 0;
|
||||
|
||||
|
@ -1035,7 +1050,8 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
|
|||
|
||||
// ----- look at our min and max limits make sure we aren't too small or too big -----
|
||||
if (!computedBoxSizes->valid) {
|
||||
PRInt32 newSize = pref + (sizeRemaining*flex/springConstantsRemaining);
|
||||
PRInt32 newSize = Round(pref + (sizeRemaining*flex/springConstantsRemaining), onePixel);
|
||||
|
||||
if (newSize<=min) {
|
||||
computedBoxSizes->size = min;
|
||||
computedBoxSizes->valid = PR_TRUE;
|
||||
|
@ -1076,7 +1092,7 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
|
|||
flex = boxSizes->flex;
|
||||
|
||||
if (!computedBoxSizes->valid) {
|
||||
computedBoxSizes->size = pref + flex*sizeRemaining/springConstantsRemaining;
|
||||
computedBoxSizes->size = Round(pref + flex*sizeRemaining/springConstantsRemaining,onePixel);
|
||||
computedBoxSizes->valid = PR_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ public:
|
|||
|
||||
nsSprocketLayout();
|
||||
|
||||
static PRInt32 Round(PRInt32 aCoord, PRInt32 aOnePixel);
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRBool IsHorizontal(nsIBox* aBox) const;
|
||||
|
@ -156,6 +158,9 @@ protected:
|
|||
virtual void GetFrameState(nsIBox* aBox, nsFrameState& aState);
|
||||
virtual void SetFrameState(nsIBox* aBox, nsFrameState aState);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// because the sprocket layout manager has no instance variables. We
|
||||
// can make a static on and reuse it everywhere.
|
||||
static nsCOMPtr<nsIBoxLayout> gInstance;
|
||||
|
|
Загрузка…
Ссылка в новой задаче