Bug 130078. Reverting fix because of regressions. We'll have to come back to this again :-(.

This commit is contained in:
roc+%cs.cmu.edu 2006-11-23 01:12:52 +00:00
Родитель beb5b22eb9
Коммит 2f8f7e5581
4 изменённых файлов: 50 добавлений и 56 удалений

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

@ -2795,18 +2795,19 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext,
if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
nsIView* rootView;
vm->GetRootView(rootView);
PRBool useDefaultBackgroundColor = rootView->IsUsingDefaultBackgroundColor();
if (!rootView->GetParent() && rootView->HasWidget()) {
PRBool widgetIsTranslucent;
rootView->GetWidget()->GetWindowTranslucency(widgetIsTranslucent);
useDefaultBackgroundColor = !widgetIsTranslucent;
}
if (!rootView->GetParent()) {
PRBool widgetIsTranslucent = PR_FALSE;
if (useDefaultBackgroundColor) {
// Ensure that we always paint a color for the root (in case there's
// no background at all or a partly transparent image).
canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor();
if (rootView->HasWidget()) {
rootView->GetWidget()->GetWindowTranslucency(widgetIsTranslucent);
}
if (!widgetIsTranslucent) {
// Ensure that we always paint a color for the root (in case there's
// no background at all or a partly transparent image).
canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor();
}
}
}

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

@ -502,23 +502,14 @@ nsDisplayBackground::IsOpaque(nsDisplayListBuilder* aBuilder) {
PRBool isCanvas;
const nsStyleBackground* bg;
nsPresContext* presContext = mFrame->GetPresContext();
PRBool hasBG =
nsCSSRendering::FindBackground(presContext, mFrame, &bg, &isCanvas);
if (!hasBG)
nsCSSRendering::FindBackground(mFrame->GetPresContext(), mFrame, &bg, &isCanvas);
if (!hasBG || (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) ||
bg->mBackgroundClip != NS_STYLE_BG_CLIP_BORDER ||
HasNonZeroSide(mFrame->GetStyleBorder()->mBorderRadius) ||
NS_GET_A(bg->mBackgroundColor) < 255)
return PR_FALSE;
PRBool isTranslucentColor = NS_GET_A(bg->mBackgroundColor) < 255 ||
(bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
if (isCanvas) {
nsIView* rootView;
presContext->GetViewManager()->GetRootView(rootView);
if (rootView->IsUsingDefaultBackgroundColor()) {
isTranslucentColor = NS_GET_A(presContext->DefaultBackgroundColor()) < 255;
}
}
return !isTranslucentColor &&
bg->mBackgroundClip == NS_STYLE_BG_CLIP_BORDER &&
!HasNonZeroSide(mFrame->GetStyleBorder()->mBorderRadius);
return PR_TRUE;
}
PRBool

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

@ -2331,29 +2331,45 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
tbounds.y = 0;
// Create a child window of the parent that is our "root view/window"
// if aParentWidget has a view, we'll hook our view manager up to its view tree
nsIView* containerView = nsView::GetViewFor(aParentWidget);
if (containerView) {
// see if the containerView has already been hooked into a foreign view manager hierarchy
// if it has, then we have to hook into the hierarchy too otherwise bad things will happen.
nsIViewManager* containerVM = containerView->GetViewManager();
nsIView* pView = containerView;
do {
pView = pView->GetParent();
} while (pView && pView->GetViewManager() == containerVM);
if (!pView) {
// OK, so the container is not already hooked up into a foreign view manager hierarchy.
// That means we can choose not to hook ourselves up.
//
// If the parent container is a chrome shell then we won't hook into its view
// tree. This will improve performance a little bit (especially given scrolling/painting perf bugs)
// but is really just for peace of mind. This check can be removed if we want to support fancy
// chrome effects like transparent controls floating over content, transparent Web browsers, and
// things like that, and the perf bugs are fixed.
nsCOMPtr<nsIDocShellTreeItem> container(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShellTreeItem> parentContainer;
PRInt32 itemType;
if (nsnull == container
|| NS_FAILED(container->GetParent(getter_AddRefs(parentContainer)))
|| nsnull == parentContainer
|| NS_FAILED(parentContainer->GetItemType(&itemType))
|| itemType != nsIDocShellTreeItem::typeContent) {
containerView = nsnull;
}
}
}
// Create a view
nsIView* view = mViewManager->CreateView(tbounds, containerView);
if (!view)
return NS_ERROR_OUT_OF_MEMORY;
if (containerView) {
nsCOMPtr<nsIDocShellTreeItem> container(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShellTreeItem> parentContainer;
PRInt32 itemType;
PRInt32 parentItemType;
if (container
&& NS_SUCCEEDED(container->GetItemType(&itemType))
&& itemType == nsIDocShellTreeItem::typeContent
&& NS_SUCCEEDED(container->GetParent(getter_AddRefs(parentContainer)))
&& parentContainer
&& NS_SUCCEEDED(parentContainer->GetItemType(&parentItemType))
&& parentItemType != nsIDocShellTreeItem::typeContent) {
view->SetUseDefaultBackgroundColor(PR_TRUE);
}
}
// pass in a native widget to be the parent widget ONLY if the view hierarchy will stand alone.
// otherwise the view will find its own parent widget and "do the right thing" to
// establish a parent/child widget relationship

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

@ -90,8 +90,6 @@ enum nsViewVisibility {
// is z-index:auto also
#define NS_VIEW_FLAG_TOPMOST 0x0010
#define NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND 0x0020
struct nsViewZIndex {
PRBool mIsAuto;
PRInt32 mZIndex;
@ -284,19 +282,7 @@ public:
PRBool HasUniformBackground() {
return mVFlags & NS_VIEW_FLAG_UNIFORM_BACKGROUND;
}
void SetUseDefaultBackgroundColor(PRBool aUseDefault) {
if (aUseDefault) {
mVFlags |= NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND;
} else {
mVFlags &= ~NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND;
}
}
PRBool IsUsingDefaultBackgroundColor() {
return mVFlags & NS_VIEW_FLAG_USE_DEFAULT_BACKGROUND;
}
/**
* Set the view's link to client owned data.
* @param aData - data to associate with view. nsnull to disassociate