mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
manage view visibility better, hide collapsed views and hidden views with widgets
This commit is contained in:
parent
7911885f43
commit
cd5a8a17d1
@ -6441,26 +6441,60 @@ SyncAndInvalidateView(nsIView* aView, nsIFrame* aFrame,
|
||||
aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) disp);
|
||||
|
||||
aViewManager->SetViewOpacity(aView, color->mOpacity);
|
||||
PRBool viewVisible = (NS_STYLE_VISIBILITY_VISIBLE == disp->mVisible);
|
||||
// XXX Troy, you need to hook in the leaf node logic here.
|
||||
|
||||
// XXX also need to set transparency in the view
|
||||
if (! viewVisible) {
|
||||
nsIView* parentView = nsnull;
|
||||
aView->GetParent(parentView);
|
||||
if (parentView) {
|
||||
nsRect bounds;
|
||||
aView->GetBounds(bounds);
|
||||
aViewManager->UpdateView(parentView, bounds, NS_VMREFRESH_NO_SYNC);
|
||||
// See if the view should be hidden or visible
|
||||
PRBool viewIsVisible = PR_TRUE;
|
||||
PRBool viewHasTransparentContent = (color->mBackgroundFlags &
|
||||
NS_STYLE_BG_COLOR_TRANSPARENT) == NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
|
||||
if (NS_STYLE_VISIBILITY_COLLAPSE == disp->mVisible) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
else if (NS_STYLE_VISIBILITY_HIDDEN == disp->mVisible) {
|
||||
// If it has a widget, hide the view because the widget can't deal with it
|
||||
nsIWidget* widget = nsnull;
|
||||
aView->GetWidget(widget);
|
||||
if (widget) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
else {
|
||||
// XXX??? how to deal with this??? Do we even have to?
|
||||
// If it's a scroll frame, then hide the view. This means that
|
||||
// child elements can't override their parent's visibility, but
|
||||
// it's not practical to leave it visible in all cases because
|
||||
// the scrollbars will be showing
|
||||
nsIAtom* frameType;
|
||||
aFrame->GetFrameType(&frameType);
|
||||
|
||||
if (frameType == nsLayoutAtoms::scrollFrame) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
} else {
|
||||
// If it's a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIFrame* firstChild;
|
||||
|
||||
aFrame->FirstChild(nsnull, &firstChild);
|
||||
if (firstChild) {
|
||||
// It's not a left frame, so the view needs to be visible, but
|
||||
// marked as having transparent content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// It's a leaf frame so go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(frameType);
|
||||
}
|
||||
aView->SetVisibility(nsViewVisibility_kHide);
|
||||
}
|
||||
|
||||
if (viewIsVisible) {
|
||||
aViewManager->SetViewContentTransparency(aView, viewHasTransparentContent);
|
||||
aViewManager->SetViewVisibility(aView, nsViewVisibility_kShow);
|
||||
}
|
||||
else {
|
||||
aView->SetVisibility(nsViewVisibility_kShow);
|
||||
aViewManager->UpdateView(aView, nsnull, NS_VMREFRESH_NO_SYNC);
|
||||
aViewManager->SetViewVisibility(aView, nsViewVisibility_kHide);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1122,35 +1122,47 @@ nsFrame::DidReflow(nsIPresContext& aPresContext,
|
||||
PRBool viewHasTransparentContent = (color->mBackgroundFlags &
|
||||
NS_STYLE_BG_COLOR_TRANSPARENT) == NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
|
||||
if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it's a scroll frame, then hide the view. This means that
|
||||
// child elements can't override their parent's visibility, but
|
||||
// it's not practical to leave it visible in all cases because
|
||||
// the scrollbars will be showing
|
||||
nsIAtom* frameType;
|
||||
GetFrameType(&frameType);
|
||||
|
||||
if (frameType == nsLayoutAtoms::scrollFrame) {
|
||||
if (NS_STYLE_VISIBILITY_COLLAPSE == display->mVisible) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
else if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it has a widget, hide the view because the widget can't deal with it
|
||||
nsIWidget* widget = nsnull;
|
||||
mView->GetWidget(widget);
|
||||
if (widget) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
|
||||
} else {
|
||||
// If we're a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIFrame* firstChild;
|
||||
|
||||
FirstChild(nsnull, &firstChild);
|
||||
if (firstChild) {
|
||||
// Not a left frame, so the view needs to be visible, but marked
|
||||
// as having transparent content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Leaf frame so go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
else {
|
||||
// If it's a scroll frame, then hide the view. This means that
|
||||
// child elements can't override their parent's visibility, but
|
||||
// it's not practical to leave it visible in all cases because
|
||||
// the scrollbars will be showing
|
||||
nsIAtom* frameType;
|
||||
GetFrameType(&frameType);
|
||||
|
||||
if (frameType == nsLayoutAtoms::scrollFrame) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
|
||||
} else {
|
||||
// If we're a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIFrame* firstChild;
|
||||
|
||||
FirstChild(nsnull, &firstChild);
|
||||
if (firstChild) {
|
||||
// Not a left frame, so the view needs to be visible, but marked
|
||||
// as having transparent content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Leaf frame so go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(frameType);
|
||||
}
|
||||
NS_IF_RELEASE(frameType);
|
||||
}
|
||||
|
||||
// Make sure visibility is correct
|
||||
|
@ -408,30 +408,42 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext& aPresContext,
|
||||
PRBool viewHasTransparentContent = (color->mBackgroundFlags &
|
||||
NS_STYLE_BG_COLOR_TRANSPARENT) == NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
|
||||
if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it's a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIContent* content;
|
||||
if (NS_STYLE_VISIBILITY_COLLAPSE == display->mVisible) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
else if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it has a widget, hide the view because the widget can't deal with it
|
||||
nsIWidget* widget = nsnull;
|
||||
view->GetWidget(widget);
|
||||
if (widget) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
else {
|
||||
// If it's a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIContent* content;
|
||||
|
||||
// Because this function is called before processing the content
|
||||
// object's child elements, we can't tell if it's a leaf by looking
|
||||
// at whether the frame has any child frames
|
||||
aFrame->GetContent(&content);
|
||||
if (content) {
|
||||
PRBool isContainer;
|
||||
// Because this function is called before processing the content
|
||||
// object's child elements, we can't tell if it's a leaf by looking
|
||||
// at whether the frame has any child frames
|
||||
aFrame->GetContent(&content);
|
||||
if (content) {
|
||||
PRBool isContainer;
|
||||
|
||||
content->CanContainChildren(isContainer);
|
||||
if (isContainer) {
|
||||
// The view needs to be visible, but marked as having transparent
|
||||
// content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
content->CanContainChildren(isContainer);
|
||||
if (isContainer) {
|
||||
// The view needs to be visible, but marked as having transparent
|
||||
// content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1122,35 +1122,47 @@ nsFrame::DidReflow(nsIPresContext& aPresContext,
|
||||
PRBool viewHasTransparentContent = (color->mBackgroundFlags &
|
||||
NS_STYLE_BG_COLOR_TRANSPARENT) == NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
|
||||
if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it's a scroll frame, then hide the view. This means that
|
||||
// child elements can't override their parent's visibility, but
|
||||
// it's not practical to leave it visible in all cases because
|
||||
// the scrollbars will be showing
|
||||
nsIAtom* frameType;
|
||||
GetFrameType(&frameType);
|
||||
|
||||
if (frameType == nsLayoutAtoms::scrollFrame) {
|
||||
if (NS_STYLE_VISIBILITY_COLLAPSE == display->mVisible) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
else if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it has a widget, hide the view because the widget can't deal with it
|
||||
nsIWidget* widget = nsnull;
|
||||
mView->GetWidget(widget);
|
||||
if (widget) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
|
||||
} else {
|
||||
// If we're a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIFrame* firstChild;
|
||||
|
||||
FirstChild(nsnull, &firstChild);
|
||||
if (firstChild) {
|
||||
// Not a left frame, so the view needs to be visible, but marked
|
||||
// as having transparent content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Leaf frame so go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
else {
|
||||
// If it's a scroll frame, then hide the view. This means that
|
||||
// child elements can't override their parent's visibility, but
|
||||
// it's not practical to leave it visible in all cases because
|
||||
// the scrollbars will be showing
|
||||
nsIAtom* frameType;
|
||||
GetFrameType(&frameType);
|
||||
|
||||
if (frameType == nsLayoutAtoms::scrollFrame) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
|
||||
} else {
|
||||
// If we're a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIFrame* firstChild;
|
||||
|
||||
FirstChild(nsnull, &firstChild);
|
||||
if (firstChild) {
|
||||
// Not a left frame, so the view needs to be visible, but marked
|
||||
// as having transparent content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Leaf frame so go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(frameType);
|
||||
}
|
||||
NS_IF_RELEASE(frameType);
|
||||
}
|
||||
|
||||
// Make sure visibility is correct
|
||||
|
@ -408,30 +408,42 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext& aPresContext,
|
||||
PRBool viewHasTransparentContent = (color->mBackgroundFlags &
|
||||
NS_STYLE_BG_COLOR_TRANSPARENT) == NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
|
||||
if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it's a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIContent* content;
|
||||
if (NS_STYLE_VISIBILITY_COLLAPSE == display->mVisible) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
else if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) {
|
||||
// If it has a widget, hide the view because the widget can't deal with it
|
||||
nsIWidget* widget = nsnull;
|
||||
view->GetWidget(widget);
|
||||
if (widget) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
else {
|
||||
// If it's a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIContent* content;
|
||||
|
||||
// Because this function is called before processing the content
|
||||
// object's child elements, we can't tell if it's a leaf by looking
|
||||
// at whether the frame has any child frames
|
||||
aFrame->GetContent(&content);
|
||||
if (content) {
|
||||
PRBool isContainer;
|
||||
// Because this function is called before processing the content
|
||||
// object's child elements, we can't tell if it's a leaf by looking
|
||||
// at whether the frame has any child frames
|
||||
aFrame->GetContent(&content);
|
||||
if (content) {
|
||||
PRBool isContainer;
|
||||
|
||||
content->CanContainChildren(isContainer);
|
||||
if (isContainer) {
|
||||
// The view needs to be visible, but marked as having transparent
|
||||
// content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
content->CanContainChildren(isContainer);
|
||||
if (isContainer) {
|
||||
// The view needs to be visible, but marked as having transparent
|
||||
// content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// Go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6441,26 +6441,60 @@ SyncAndInvalidateView(nsIView* aView, nsIFrame* aFrame,
|
||||
aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) disp);
|
||||
|
||||
aViewManager->SetViewOpacity(aView, color->mOpacity);
|
||||
PRBool viewVisible = (NS_STYLE_VISIBILITY_VISIBLE == disp->mVisible);
|
||||
// XXX Troy, you need to hook in the leaf node logic here.
|
||||
|
||||
// XXX also need to set transparency in the view
|
||||
if (! viewVisible) {
|
||||
nsIView* parentView = nsnull;
|
||||
aView->GetParent(parentView);
|
||||
if (parentView) {
|
||||
nsRect bounds;
|
||||
aView->GetBounds(bounds);
|
||||
aViewManager->UpdateView(parentView, bounds, NS_VMREFRESH_NO_SYNC);
|
||||
// See if the view should be hidden or visible
|
||||
PRBool viewIsVisible = PR_TRUE;
|
||||
PRBool viewHasTransparentContent = (color->mBackgroundFlags &
|
||||
NS_STYLE_BG_COLOR_TRANSPARENT) == NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
|
||||
if (NS_STYLE_VISIBILITY_COLLAPSE == disp->mVisible) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
else if (NS_STYLE_VISIBILITY_HIDDEN == disp->mVisible) {
|
||||
// If it has a widget, hide the view because the widget can't deal with it
|
||||
nsIWidget* widget = nsnull;
|
||||
aView->GetWidget(widget);
|
||||
if (widget) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
else {
|
||||
// XXX??? how to deal with this??? Do we even have to?
|
||||
// If it's a scroll frame, then hide the view. This means that
|
||||
// child elements can't override their parent's visibility, but
|
||||
// it's not practical to leave it visible in all cases because
|
||||
// the scrollbars will be showing
|
||||
nsIAtom* frameType;
|
||||
aFrame->GetFrameType(&frameType);
|
||||
|
||||
if (frameType == nsLayoutAtoms::scrollFrame) {
|
||||
viewIsVisible = PR_FALSE;
|
||||
} else {
|
||||
// If it's a container element, then leave the view visible, but
|
||||
// mark it as having transparent content. The reason we need to
|
||||
// do this is that child elements can override their parent's
|
||||
// hidden visibility and be visible anyway
|
||||
nsIFrame* firstChild;
|
||||
|
||||
aFrame->FirstChild(nsnull, &firstChild);
|
||||
if (firstChild) {
|
||||
// It's not a left frame, so the view needs to be visible, but
|
||||
// marked as having transparent content
|
||||
viewHasTransparentContent = PR_TRUE;
|
||||
} else {
|
||||
// It's a leaf frame so go ahead and hide the view
|
||||
viewIsVisible = PR_FALSE;
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(frameType);
|
||||
}
|
||||
aView->SetVisibility(nsViewVisibility_kHide);
|
||||
}
|
||||
|
||||
if (viewIsVisible) {
|
||||
aViewManager->SetViewContentTransparency(aView, viewHasTransparentContent);
|
||||
aViewManager->SetViewVisibility(aView, nsViewVisibility_kShow);
|
||||
}
|
||||
else {
|
||||
aView->SetVisibility(nsViewVisibility_kShow);
|
||||
aViewManager->UpdateView(aView, nsnull, NS_VMREFRESH_NO_SYNC);
|
||||
aViewManager->SetViewVisibility(aView, nsViewVisibility_kHide);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user