зеркало из https://github.com/mozilla/gecko-dev.git
Bug 373564, r+sr=roc
This commit is contained in:
Родитель
66e808a4af
Коммит
fe29ef194d
|
@ -1737,11 +1737,11 @@ void
|
||||||
nsGfxScrollFrameInner::InternalScrollPositionDidChange(nscoord aX, nscoord aY)
|
nsGfxScrollFrameInner::InternalScrollPositionDidChange(nscoord aX, nscoord aY)
|
||||||
{
|
{
|
||||||
if (mVScrollbarBox)
|
if (mVScrollbarBox)
|
||||||
SetCoordAttribute(mVScrollbarBox, nsGkAtoms::curpos,
|
SetCoordAttribute(mVScrollbarBox->GetContent(), nsGkAtoms::curpos,
|
||||||
aY - GetScrolledRect(GetScrollPortSize()).y);
|
aY - GetScrolledRect(GetScrollPortSize()).y);
|
||||||
|
|
||||||
if (mHScrollbarBox)
|
if (mHScrollbarBox)
|
||||||
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::curpos,
|
SetCoordAttribute(mHScrollbarBox->GetContent(), nsGkAtoms::curpos,
|
||||||
aX - GetScrolledRect(GetScrollPortSize()).x);
|
aX - GetScrolledRect(GetScrollPortSize()).x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2302,6 +2302,21 @@ nsXULScrollFrame::Layout(nsBoxLayoutState& aState)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsGfxScrollFrameInner::FinishReflowForScrollbar(nsIContent* aContent,
|
||||||
|
nscoord aMinXY, nscoord aMaxXY,
|
||||||
|
nscoord aCurPosXY,
|
||||||
|
nscoord aPageIncrement,
|
||||||
|
nscoord aIncrement)
|
||||||
|
{
|
||||||
|
// Scrollbars assume zero is the minimum position, so translate for them.
|
||||||
|
SetCoordAttribute(aContent, nsGkAtoms::curpos, aCurPosXY - aMinXY);
|
||||||
|
SetScrollbarEnabled(aContent, aMaxXY - aMinXY);
|
||||||
|
SetCoordAttribute(aContent, nsGkAtoms::maxpos, aMaxXY - aMinXY);
|
||||||
|
SetCoordAttribute(aContent, nsGkAtoms::pageincrement, aPageIncrement);
|
||||||
|
SetCoordAttribute(aContent, nsGkAtoms::increment, aIncrement);
|
||||||
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsGfxScrollFrameInner::ReflowFinished()
|
nsGfxScrollFrameInner::ReflowFinished()
|
||||||
{
|
{
|
||||||
|
@ -2332,28 +2347,28 @@ nsGfxScrollFrameInner::ReflowFinished()
|
||||||
NS_ASSERTION(!mFrameInitiatedScroll, "We shouldn't be reentering here");
|
NS_ASSERTION(!mFrameInitiatedScroll, "We shouldn't be reentering here");
|
||||||
mFrameInitiatedScroll = PR_TRUE;
|
mFrameInitiatedScroll = PR_TRUE;
|
||||||
|
|
||||||
if (mVScrollbarBox) {
|
nsCOMPtr<nsIContent> vScroll =
|
||||||
NS_PRECONDITION(mVScrollbarBox->IsBoxFrame(), "Must be a box frame!");
|
mVScrollbarBox ? mVScrollbarBox->GetContent() : nsnull;
|
||||||
nscoord curPosX, curPosY;
|
nsCOMPtr<nsIContent> hScroll =
|
||||||
scrollable->GetScrollPosition(curPosX, curPosY);
|
mHScrollbarBox ? mHScrollbarBox->GetContent() : nsnull;
|
||||||
// Scrollbars assume zero is the minimum position, so translate for them.
|
|
||||||
SetCoordAttribute(mVScrollbarBox, nsGkAtoms::curpos, curPosY - minY);
|
|
||||||
SetScrollbarEnabled(mVScrollbarBox, maxY - minY);
|
|
||||||
SetCoordAttribute(mVScrollbarBox, nsGkAtoms::maxpos, maxY - minY);
|
|
||||||
SetCoordAttribute(mVScrollbarBox, nsGkAtoms::pageincrement, nscoord(scrollArea.height - fontHeight));
|
|
||||||
SetCoordAttribute(mVScrollbarBox, nsGkAtoms::increment, fontHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mHScrollbarBox) {
|
// Note, in some cases mOuter may get deleted while finishing reflow
|
||||||
NS_PRECONDITION(mHScrollbarBox->IsBoxFrame(), "Must be a box frame!");
|
// for scrollbars.
|
||||||
|
if (vScroll || hScroll) {
|
||||||
|
nsWeakFrame weakFrame(mOuter);
|
||||||
nscoord curPosX, curPosY;
|
nscoord curPosX, curPosY;
|
||||||
scrollable->GetScrollPosition(curPosX, curPosY);
|
scrollable->GetScrollPosition(curPosX, curPosY);
|
||||||
// Scrollbars assume zero is the minimum position, so translate for them.
|
if (vScroll) {
|
||||||
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::curpos, curPosX - minX);
|
FinishReflowForScrollbar(vScroll, minY, maxY, curPosY,
|
||||||
SetScrollbarEnabled(mHScrollbarBox, maxX - minX);
|
nscoord(scrollArea.height - fontHeight),
|
||||||
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::maxpos, maxX - minX);
|
fontHeight);
|
||||||
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::pageincrement, nscoord(float(scrollArea.width)*0.8));
|
}
|
||||||
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::increment, nsPresContext::CSSPixelsToAppUnits(10));
|
if (hScroll) {
|
||||||
|
FinishReflowForScrollbar(hScroll, minX, maxX, curPosX,
|
||||||
|
nscoord(float(scrollArea.width) * 0.8),
|
||||||
|
nsPresContext::CSSPixelsToAppUnits(10));
|
||||||
|
}
|
||||||
|
NS_ENSURE_TRUE(weakFrame.IsAlive(), PR_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFrameInitiatedScroll = PR_FALSE;
|
mFrameInitiatedScroll = PR_FALSE;
|
||||||
|
@ -2470,19 +2485,18 @@ nsGfxScrollFrameInner::ScrollbarChanged(nsPresContext* aPresContext, nscoord aX,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsGfxScrollFrameInner::SetScrollbarEnabled(nsIBox* aBox, nscoord aMaxPos)
|
nsGfxScrollFrameInner::SetScrollbarEnabled(nsIContent* aContent, nscoord aMaxPos)
|
||||||
{
|
{
|
||||||
nsIContent* content = aBox->GetContent();
|
|
||||||
if (aMaxPos) {
|
if (aMaxPos) {
|
||||||
content->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, PR_TRUE);
|
aContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, PR_TRUE);
|
||||||
} else {
|
} else {
|
||||||
content->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled,
|
aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled,
|
||||||
NS_LITERAL_STRING("true"), PR_TRUE);
|
NS_LITERAL_STRING("true"), PR_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsGfxScrollFrameInner::SetCoordAttribute(nsIBox* aBox, nsIAtom* aAtom,
|
nsGfxScrollFrameInner::SetCoordAttribute(nsIContent* aContent, nsIAtom* aAtom,
|
||||||
nscoord aSize)
|
nscoord aSize)
|
||||||
{
|
{
|
||||||
// convert to pixels
|
// convert to pixels
|
||||||
|
@ -2493,11 +2507,10 @@ nsGfxScrollFrameInner::SetCoordAttribute(nsIBox* aBox, nsIAtom* aAtom,
|
||||||
nsAutoString newValue;
|
nsAutoString newValue;
|
||||||
newValue.AppendInt(aSize);
|
newValue.AppendInt(aSize);
|
||||||
|
|
||||||
nsIContent* content = aBox->GetContent();
|
if (aContent->AttrValueIs(kNameSpaceID_None, aAtom, newValue, eCaseMatters))
|
||||||
if (content->AttrValueIs(kNameSpaceID_None, aAtom, newValue, eCaseMatters))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
content->SetAttr(kNameSpaceID_None, aAtom, newValue, PR_TRUE);
|
aContent->SetAttr(kNameSpaceID_None, aAtom, newValue, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect
|
nsRect
|
||||||
|
|
|
@ -125,8 +125,13 @@ public:
|
||||||
nsGfxScrollFrameInner *mInner;
|
nsGfxScrollFrameInner *mInner;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetScrollbarEnabled(nsIBox* aBox, nscoord aMaxPos);
|
static void FinishReflowForScrollbar(nsIContent* aContent, nscoord aMinXY,
|
||||||
void SetCoordAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord aSize);
|
nscoord aMaxXY, nscoord aCurPosXY,
|
||||||
|
nscoord aPageIncrement,
|
||||||
|
nscoord aIncrement);
|
||||||
|
static void SetScrollbarEnabled(nsIContent* aContent, nscoord aMaxPos);
|
||||||
|
static void SetCoordAttribute(nsIContent* aContent, nsIAtom* aAtom,
|
||||||
|
nscoord aSize);
|
||||||
nscoord GetCoordAttribute(nsIBox* aFrame, nsIAtom* atom, nscoord defaultValue);
|
nscoord GetCoordAttribute(nsIBox* aFrame, nsIAtom* atom, nscoord defaultValue);
|
||||||
|
|
||||||
// Like ScrollPositionDidChange, but initiated by this frame rather than from the
|
// Like ScrollPositionDidChange, but initiated by this frame rather than from the
|
||||||
|
|
Загрузка…
Ссылка в новой задаче