Bug 30579. Add a skinnable 'scrollcorner' element to fill in the gap when there are two scrollbars. r+sr=bryner,a=asa

This commit is contained in:
roc+%cs.cmu.edu 2003-11-21 10:45:24 +00:00
parent 48d66442ad
commit 8ab11f1a38
10 changed files with 153 additions and 28 deletions

View File

@ -62,6 +62,7 @@ XUL_ATOM(button, "button")
XUL_ATOM(spinner, "spinner")
XUL_ATOM(scrollbar, "scrollbar")
XUL_ATOM(nativescrollbar, "nativescrollbar")
XUL_ATOM(scrollcorner, "scrollcorner")
XUL_ATOM(slider, "slider")
XUL_ATOM(palettename, "palettename")
XUL_ATOM(fontpicker, "fontpicker")

View File

@ -5089,7 +5089,8 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell
#ifdef MOZ_XUL
// Only cut XUL scrollbars off if they're not in a XUL document. This allows
// scrollbars to be styled from XUL (although not from XML or HTML).
if (content->Tag() == nsXULAtoms::scrollbar) {
nsIAtom* tag = content->Tag();
if (tag == nsXULAtoms::scrollbar || tag == nsXULAtoms::scrollcorner) {
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(aDocument));
if (xulDoc)
content->SetBindingParent(aParent);

View File

@ -135,6 +135,7 @@ public:
nsIBox* mHScrollbarBox;
nsIBox* mVScrollbarBox;
nsIBox* mScrollAreaBox;
nsIBox* mScrollCornerBox;
nscoord mOnePixel;
nsGfxScrollFrame* mOuter;
nsIScrollableView* mScrollableView;
@ -392,8 +393,9 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
ScrollbarStyles styles = GetScrollbarStyles();
if (styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|| styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
PRBool canHaveHorizontal = styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|| styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveHorizontal) {
nsCOMPtr<nsIContent> content;
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -403,8 +405,9 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
aAnonymousChildren.AppendElement(content);
}
if (styles.mVertical == NS_STYLE_OVERFLOW_AUTO
|| styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
PRBool canHaveVertical = styles.mVertical == NS_STYLE_OVERFLOW_AUTO
|| styles.mVertical == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveVertical) {
nsCOMPtr<nsIContent> content;
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -414,6 +417,14 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
aAnonymousChildren.AppendElement(content);
}
if (canHaveHorizontal && canHaveVertical) {
nodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("scrollcorner"), nsnull,
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
nsCOMPtr<nsIContent> content;
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
aAnonymousChildren.AppendElement(content);
}
return NS_OK;
}
@ -436,9 +447,8 @@ nsGfxScrollFrame::Init(nsIPresContext* aPresContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext;
nsresult rv = nsBoxFrame::Init(aPresContext, aContent,
aParent, aStyleContext,
aPrevInFlow);
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aStyleContext,
aPrevInFlow);
return rv;
}
@ -447,6 +457,7 @@ void nsGfxScrollFrame::ReloadChildFrames(nsIPresContext* aPresContext)
mInner->mScrollAreaBox = nsnull;
mInner->mHScrollbarBox = nsnull;
mInner->mVScrollbarBox = nsnull;
mInner->mScrollCornerBox = nsnull;
nsIFrame* frame = nsnull;
FirstChild(aPresContext, nsnull, &frame);
@ -475,6 +486,11 @@ void nsGfxScrollFrame::ReloadChildFrames(nsIPresContext* aPresContext)
mInner->mVScrollbarBox = box;
}
understood = PR_TRUE;
} else {
// probably a scrollcorner
NS_ASSERTION(!mInner->mScrollCornerBox, "Found multiple scrollcorners");
mInner->mScrollCornerBox = box;
understood = PR_TRUE;
}
}
}
@ -869,12 +885,14 @@ NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
//-------------------- Inner ----------------------
nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsGfxScrollFrame* aOuter):mHScrollbarBox(nsnull),
mVScrollbarBox(nsnull),
mScrollAreaBox(nsnull),
mOnePixel(20),
mHasVerticalScrollbar(PR_FALSE),
mHasHorizontalScrollbar(PR_FALSE)
nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsGfxScrollFrame* aOuter)
: mHScrollbarBox(nsnull),
mVScrollbarBox(nsnull),
mScrollAreaBox(nsnull),
mScrollCornerBox(nsnull),
mOnePixel(20),
mHasVerticalScrollbar(PR_FALSE),
mHasHorizontalScrollbar(PR_FALSE)
{
mOuter = aOuter;
mMaxElementWidth = 0;
@ -1548,6 +1566,34 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
needsLayout = PR_FALSE;
}
// place the scrollcorner
if (mScrollCornerBox) {
nsRect r(0, 0, 0, 0);
if (clientRect.x != scrollAreaRect.x) {
// scrollbar (if any) on left
r.x = clientRect.x;
r.width = scrollAreaRect.x - clientRect.x;
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
} else {
// scrollbar (if any) on right
r.x = scrollAreaRect.XMost();
r.width = clientRect.XMost() - scrollAreaRect.XMost();
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
}
if (clientRect.y != scrollAreaRect.y) {
// scrollbar (if any) on top
r.y = clientRect.y;
r.height = scrollAreaRect.y - clientRect.y;
NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
} else {
// scrollbar (if any) on bottom
r.y = scrollAreaRect.YMost();
r.height = clientRect.YMost() - scrollAreaRect.YMost();
NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
}
LayoutBox(aState, mScrollCornerBox, r);
}
// may need to update fixed position children of the viewport,
// if the client area changed size because of some dirty reflow
// (if the reflow is initial or resize, the fixed children will

View File

@ -135,6 +135,7 @@ public:
nsIBox* mHScrollbarBox;
nsIBox* mVScrollbarBox;
nsIBox* mScrollAreaBox;
nsIBox* mScrollCornerBox;
nscoord mOnePixel;
nsGfxScrollFrame* mOuter;
nsIScrollableView* mScrollableView;
@ -392,8 +393,9 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
ScrollbarStyles styles = GetScrollbarStyles();
if (styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|| styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
PRBool canHaveHorizontal = styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|| styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveHorizontal) {
nsCOMPtr<nsIContent> content;
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -403,8 +405,9 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
aAnonymousChildren.AppendElement(content);
}
if (styles.mVertical == NS_STYLE_OVERFLOW_AUTO
|| styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
PRBool canHaveVertical = styles.mVertical == NS_STYLE_OVERFLOW_AUTO
|| styles.mVertical == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveVertical) {
nsCOMPtr<nsIContent> content;
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -414,6 +417,14 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
aAnonymousChildren.AppendElement(content);
}
if (canHaveHorizontal && canHaveVertical) {
nodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("scrollcorner"), nsnull,
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
nsCOMPtr<nsIContent> content;
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
aAnonymousChildren.AppendElement(content);
}
return NS_OK;
}
@ -436,9 +447,8 @@ nsGfxScrollFrame::Init(nsIPresContext* aPresContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext;
nsresult rv = nsBoxFrame::Init(aPresContext, aContent,
aParent, aStyleContext,
aPrevInFlow);
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aStyleContext,
aPrevInFlow);
return rv;
}
@ -447,6 +457,7 @@ void nsGfxScrollFrame::ReloadChildFrames(nsIPresContext* aPresContext)
mInner->mScrollAreaBox = nsnull;
mInner->mHScrollbarBox = nsnull;
mInner->mVScrollbarBox = nsnull;
mInner->mScrollCornerBox = nsnull;
nsIFrame* frame = nsnull;
FirstChild(aPresContext, nsnull, &frame);
@ -475,6 +486,11 @@ void nsGfxScrollFrame::ReloadChildFrames(nsIPresContext* aPresContext)
mInner->mVScrollbarBox = box;
}
understood = PR_TRUE;
} else {
// probably a scrollcorner
NS_ASSERTION(!mInner->mScrollCornerBox, "Found multiple scrollcorners");
mInner->mScrollCornerBox = box;
understood = PR_TRUE;
}
}
}
@ -869,12 +885,14 @@ NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
//-------------------- Inner ----------------------
nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsGfxScrollFrame* aOuter):mHScrollbarBox(nsnull),
mVScrollbarBox(nsnull),
mScrollAreaBox(nsnull),
mOnePixel(20),
mHasVerticalScrollbar(PR_FALSE),
mHasHorizontalScrollbar(PR_FALSE)
nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsGfxScrollFrame* aOuter)
: mHScrollbarBox(nsnull),
mVScrollbarBox(nsnull),
mScrollAreaBox(nsnull),
mScrollCornerBox(nsnull),
mOnePixel(20),
mHasVerticalScrollbar(PR_FALSE),
mHasHorizontalScrollbar(PR_FALSE)
{
mOuter = aOuter;
mMaxElementWidth = 0;
@ -1548,6 +1566,34 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
needsLayout = PR_FALSE;
}
// place the scrollcorner
if (mScrollCornerBox) {
nsRect r(0, 0, 0, 0);
if (clientRect.x != scrollAreaRect.x) {
// scrollbar (if any) on left
r.x = clientRect.x;
r.width = scrollAreaRect.x - clientRect.x;
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
} else {
// scrollbar (if any) on right
r.x = scrollAreaRect.XMost();
r.width = clientRect.XMost() - scrollAreaRect.XMost();
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
}
if (clientRect.y != scrollAreaRect.y) {
// scrollbar (if any) on top
r.y = clientRect.y;
r.height = scrollAreaRect.y - clientRect.y;
NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
} else {
// scrollbar (if any) on bottom
r.y = scrollAreaRect.YMost();
r.height = clientRect.YMost() - scrollAreaRect.YMost();
NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
}
LayoutBox(aState, mScrollCornerBox, r);
}
// may need to update fixed position children of the viewport,
// if the client area changed size because of some dirty reflow
// (if the reflow is initial or resize, the fixed children will

View File

@ -5089,7 +5089,8 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell
#ifdef MOZ_XUL
// Only cut XUL scrollbars off if they're not in a XUL document. This allows
// scrollbars to be styled from XUL (although not from XML or HTML).
if (content->Tag() == nsXULAtoms::scrollbar) {
nsIAtom* tag = content->Tag();
if (tag == nsXULAtoms::scrollbar || tag == nsXULAtoms::scrollcorner) {
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(aDocument));
if (xulDoc)
content->SetBindingParent(aParent);

View File

@ -37,6 +37,12 @@ scrollbar {
cursor: default;
}
/* ::::: square at the corner of two scrollbars ::::: */
scrollcorner {
background-color: -moz-Dialog;
}
/* :::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
/* ::::::::::::::::::::: MEDIA PRINT :::::::::::::::::::::: */
/* :::::::::::::::::::::::::::::::::::::::::::::::::::::::: */

View File

@ -115,6 +115,12 @@ scrollbarbutton:hover:active {
background-color: #666666;
}
/* ::::: square at the corner of two scrollbars ::::: */
scrollcorner {
background-color: -moz-Dialog;
}
/* ..... increment .... */
scrollbarbutton[type="increment"] {

View File

@ -90,6 +90,12 @@ scrollbarbutton:hover:active {
background-position: 1px 2px;
}
/* ::::: square at the corner of two scrollbars ::::: */
scrollcorner {
background-color: -moz-Dialog;
}
/* ..... increment .... */
scrollbarbutton[type="increment"] {

View File

@ -49,6 +49,12 @@ scrollbar {
cursor: default;
}
/* ::::: square at the corner of two scrollbars ::::: */
scrollcorner {
background-color: #B1BBC5;
}
/* ::::: slider ::::: */
slider {

View File

@ -110,6 +110,12 @@ scrollbarbutton:hover:active {
background-color: #9CA8B4;
}
/* ::::: square at the corner of two scrollbars ::::: */
scrollcorner {
background-color: #B1BBC5;
}
/* ..... increment .... */
scrollbarbutton[type="increment"] {