From 681064b65eaab85da616c7f66f294e48af73803a Mon Sep 17 00:00:00 2001 From: "caillon%returnzero.com" Date: Fri, 27 Dec 2002 07:32:17 +0000 Subject: [PATCH] Bug 186752 - Crash during background painting when there is no scrollable frame. Add a null check. r+sr=dbaron --- layout/base/nsCSSRendering.cpp | 38 ++++++++++++------------ layout/html/style/src/nsCSSRendering.cpp | 38 ++++++++++++------------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index da0fa1559dbb..13a6a5efc189 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -2929,26 +2929,26 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext, scrollableFrame = GetRootScrollableFrame(aPresContext, rootFrame); } - NS_ASSERTION(scrollableFrame, "no scrollable frame"); + if (scrollableFrame) { + // Now, account for scrollbars, if we have any. + PRBool verticalVisible; + PRBool horizontalVisible; + scrollableFrame->GetScrollbarVisibility(aPresContext, &verticalVisible, + &horizontalVisible); - // Now, account for scrollbars, if we have any. - PRBool verticalVisible; - PRBool horizontalVisible; - scrollableFrame->GetScrollbarVisibility(aPresContext, &verticalVisible, - &horizontalVisible); - - if (verticalVisible || horizontalVisible) { - nscoord verticalWidth; - nscoord horizontalHeight; - scrollableFrame->GetScrollbarSizes(aPresContext, &verticalWidth, - &horizontalHeight); - if (verticalVisible) { - // Assumes vertical scrollbars are on the right. - viewportArea.width -= verticalWidth; - } - if (horizontalVisible) { - // Assumes horizontal scrollbars are on the bottom. - viewportArea.height -= horizontalHeight; + if (verticalVisible || horizontalVisible) { + nscoord verticalWidth; + nscoord horizontalHeight; + scrollableFrame->GetScrollbarSizes(aPresContext, &verticalWidth, + &horizontalHeight); + if (verticalVisible) { + // Assumes vertical scrollbars are on the right. + viewportArea.width -= verticalWidth; + } + if (horizontalVisible) { + // Assumes horizontal scrollbars are on the bottom. + viewportArea.height -= horizontalHeight; + } } } diff --git a/layout/html/style/src/nsCSSRendering.cpp b/layout/html/style/src/nsCSSRendering.cpp index da0fa1559dbb..13a6a5efc189 100644 --- a/layout/html/style/src/nsCSSRendering.cpp +++ b/layout/html/style/src/nsCSSRendering.cpp @@ -2929,26 +2929,26 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext, scrollableFrame = GetRootScrollableFrame(aPresContext, rootFrame); } - NS_ASSERTION(scrollableFrame, "no scrollable frame"); + if (scrollableFrame) { + // Now, account for scrollbars, if we have any. + PRBool verticalVisible; + PRBool horizontalVisible; + scrollableFrame->GetScrollbarVisibility(aPresContext, &verticalVisible, + &horizontalVisible); - // Now, account for scrollbars, if we have any. - PRBool verticalVisible; - PRBool horizontalVisible; - scrollableFrame->GetScrollbarVisibility(aPresContext, &verticalVisible, - &horizontalVisible); - - if (verticalVisible || horizontalVisible) { - nscoord verticalWidth; - nscoord horizontalHeight; - scrollableFrame->GetScrollbarSizes(aPresContext, &verticalWidth, - &horizontalHeight); - if (verticalVisible) { - // Assumes vertical scrollbars are on the right. - viewportArea.width -= verticalWidth; - } - if (horizontalVisible) { - // Assumes horizontal scrollbars are on the bottom. - viewportArea.height -= horizontalHeight; + if (verticalVisible || horizontalVisible) { + nscoord verticalWidth; + nscoord horizontalHeight; + scrollableFrame->GetScrollbarSizes(aPresContext, &verticalWidth, + &horizontalHeight); + if (verticalVisible) { + // Assumes vertical scrollbars are on the right. + viewportArea.width -= verticalWidth; + } + if (horizontalVisible) { + // Assumes horizontal scrollbars are on the bottom. + viewportArea.height -= horizontalHeight; + } } }