mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Don't paint blocks that shouldn't be painted when printing
Bug 67296 r=kmcclusk sr=attinasi
This commit is contained in:
parent
686d50ca58
commit
1c8f290f5d
@ -58,6 +58,9 @@
|
||||
#include "prenv.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static PRBool gLamePaintMetrics;
|
||||
@ -6239,6 +6242,43 @@ static void ComputeCombinedArea(nsLineBox* aLine,
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible)
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLHtmlElement> html(do_QueryInterface(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body(do_QueryInterface(mContent));
|
||||
|
||||
if (!html && !body) {
|
||||
rv = selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -6265,24 +6305,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check to see if we are an absolutely positioned block (div)
|
||||
// then then check to see if we need to paint.
|
||||
const nsStylePosition* postionStyle = (const nsStylePosition*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Position);
|
||||
if (NS_STYLE_POSITION_RELATIVE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_ABSOLUTE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_FIXED == postionStyle->mPosition) {
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool isVisible;
|
||||
if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// Only paint the border and background if we're visible
|
||||
if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
if (isVisible && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
(0 != mRect.width) && (0 != mRect.height)) {
|
||||
PRIntn skipSides = GetSkipSides();
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
@ -6303,6 +6332,9 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// If overflow is hidden then set the clip rect so that children don't
|
||||
// leak out of us. Note that because overflow'-clip' only applies to
|
||||
// the content area we do this after painting the border and background
|
||||
|
@ -109,6 +109,11 @@ public:
|
||||
nsEventStatus* aEventStatus);
|
||||
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
|
||||
|
||||
NS_IMETHOD IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible);
|
||||
|
||||
// nsIHTMLReflow
|
||||
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
@ -58,6 +58,9 @@
|
||||
#include "prenv.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static PRBool gLamePaintMetrics;
|
||||
@ -6239,6 +6242,43 @@ static void ComputeCombinedArea(nsLineBox* aLine,
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible)
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLHtmlElement> html(do_QueryInterface(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body(do_QueryInterface(mContent));
|
||||
|
||||
if (!html && !body) {
|
||||
rv = selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -6265,24 +6305,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check to see if we are an absolutely positioned block (div)
|
||||
// then then check to see if we need to paint.
|
||||
const nsStylePosition* postionStyle = (const nsStylePosition*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Position);
|
||||
if (NS_STYLE_POSITION_RELATIVE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_ABSOLUTE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_FIXED == postionStyle->mPosition) {
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool isVisible;
|
||||
if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// Only paint the border and background if we're visible
|
||||
if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
if (isVisible && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
(0 != mRect.width) && (0 != mRect.height)) {
|
||||
PRIntn skipSides = GetSkipSides();
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
@ -6303,6 +6332,9 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// If overflow is hidden then set the clip rect so that children don't
|
||||
// leak out of us. Note that because overflow'-clip' only applies to
|
||||
// the content area we do this after painting the border and background
|
||||
|
@ -58,6 +58,9 @@
|
||||
#include "prenv.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static PRBool gLamePaintMetrics;
|
||||
@ -6239,6 +6242,43 @@ static void ComputeCombinedArea(nsLineBox* aLine,
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible)
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLHtmlElement> html(do_QueryInterface(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body(do_QueryInterface(mContent));
|
||||
|
||||
if (!html && !body) {
|
||||
rv = selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -6265,24 +6305,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check to see if we are an absolutely positioned block (div)
|
||||
// then then check to see if we need to paint.
|
||||
const nsStylePosition* postionStyle = (const nsStylePosition*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Position);
|
||||
if (NS_STYLE_POSITION_RELATIVE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_ABSOLUTE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_FIXED == postionStyle->mPosition) {
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool isVisible;
|
||||
if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// Only paint the border and background if we're visible
|
||||
if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
if (isVisible && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
(0 != mRect.width) && (0 != mRect.height)) {
|
||||
PRIntn skipSides = GetSkipSides();
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
@ -6303,6 +6332,9 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// If overflow is hidden then set the clip rect so that children don't
|
||||
// leak out of us. Note that because overflow'-clip' only applies to
|
||||
// the content area we do this after painting the border and background
|
||||
|
@ -2340,6 +2340,42 @@ nsFrame::ParentDisablesSelection() const
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrame::GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** aSelection)
|
||||
{
|
||||
*aSelection = nsnull;
|
||||
|
||||
// start by checking to see if we are paginated which probably means
|
||||
// we are in print preview or printing
|
||||
PRBool isPaginated;
|
||||
nsresult rv = aPresContext->IsPaginated(&isPaginated);
|
||||
if (NS_SUCCEEDED(rv) && isPaginated) {
|
||||
// now see if we are rendering selection only
|
||||
PRBool isRendingSelection;
|
||||
rv = aPresContext->IsRenderingOnlySelection(&isRendingSelection);
|
||||
if (NS_SUCCEEDED(rv) && isRendingSelection) {
|
||||
// Check the quick way first (typically only leaf nodes)
|
||||
PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
||||
// if we aren't selected in the mState,
|
||||
// we could be a container so check to see if we are in the selection range
|
||||
// this is a expensive
|
||||
if (!isSelected) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
|
||||
if (selcon) {
|
||||
rv = selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -2348,8 +2384,7 @@ nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
nsIStyleContext* sc = mStyleContext;
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)sc->GetStyleData(eStyleStruct_Display);
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
@ -2357,43 +2392,21 @@ nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
PRBool isVisible = PR_TRUE;
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// start by checking to see if we are paginated which probably means
|
||||
// we are in print preview or printing
|
||||
PRBool isPaginated;
|
||||
aPresContext->IsPaginated(&isPaginated);
|
||||
if (isPaginated) {
|
||||
// now see if we are rendering selection only
|
||||
PRBool isRendingSelection;
|
||||
aPresContext->IsRenderingOnlySelection(&isRendingSelection);
|
||||
if (isRendingSelection) {
|
||||
// Check the quick way first (typically only leaf nodes)
|
||||
PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
||||
// if we aren't selected in the mState,
|
||||
// we could be a container so check to see if we are in the selection range
|
||||
// this is a expensive
|
||||
if (!isSelected) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aPresContext->GetShell(getter_AddRefs(shell));
|
||||
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
|
||||
if (selcon) {
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
selection->ContainsNode(node, PR_TRUE, &isVisible);
|
||||
} else {
|
||||
isVisible = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
|
||||
*aIsVisible = isVisible;
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon)
|
||||
{
|
||||
|
@ -430,6 +430,9 @@ protected:
|
||||
// Style post processing hook
|
||||
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext);
|
||||
|
||||
// Helper routine for determining whether to print selection
|
||||
nsresult GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** aSelection);
|
||||
|
||||
//return the line number of the aFrame
|
||||
static PRInt32 GetLineNumber(nsIFrame *aFrame);
|
||||
//given a frame five me the first/last leaf available
|
||||
|
@ -58,6 +58,9 @@
|
||||
#include "prenv.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static PRBool gLamePaintMetrics;
|
||||
@ -6239,6 +6242,43 @@ static void ComputeCombinedArea(nsLineBox* aLine,
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible)
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLHtmlElement> html(do_QueryInterface(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body(do_QueryInterface(mContent));
|
||||
|
||||
if (!html && !body) {
|
||||
rv = selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -6265,24 +6305,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check to see if we are an absolutely positioned block (div)
|
||||
// then then check to see if we need to paint.
|
||||
const nsStylePosition* postionStyle = (const nsStylePosition*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Position);
|
||||
if (NS_STYLE_POSITION_RELATIVE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_ABSOLUTE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_FIXED == postionStyle->mPosition) {
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool isVisible;
|
||||
if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// Only paint the border and background if we're visible
|
||||
if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
if (isVisible && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
(0 != mRect.width) && (0 != mRect.height)) {
|
||||
PRIntn skipSides = GetSkipSides();
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
@ -6303,6 +6332,9 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// If overflow is hidden then set the clip rect so that children don't
|
||||
// leak out of us. Note that because overflow'-clip' only applies to
|
||||
// the content area we do this after painting the border and background
|
||||
|
@ -109,6 +109,11 @@ public:
|
||||
nsEventStatus* aEventStatus);
|
||||
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
|
||||
|
||||
NS_IMETHOD IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible);
|
||||
|
||||
// nsIHTMLReflow
|
||||
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
@ -58,6 +58,9 @@
|
||||
#include "prenv.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static PRBool gLamePaintMetrics;
|
||||
@ -6239,6 +6242,43 @@ static void ComputeCombinedArea(nsLineBox* aLine,
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible)
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLHtmlElement> html(do_QueryInterface(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body(do_QueryInterface(mContent));
|
||||
|
||||
if (!html && !body) {
|
||||
rv = selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -6265,24 +6305,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check to see if we are an absolutely positioned block (div)
|
||||
// then then check to see if we need to paint.
|
||||
const nsStylePosition* postionStyle = (const nsStylePosition*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Position);
|
||||
if (NS_STYLE_POSITION_RELATIVE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_ABSOLUTE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_FIXED == postionStyle->mPosition) {
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool isVisible;
|
||||
if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// Only paint the border and background if we're visible
|
||||
if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
if (isVisible && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
(0 != mRect.width) && (0 != mRect.height)) {
|
||||
PRIntn skipSides = GetSkipSides();
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
@ -6303,6 +6332,9 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// If overflow is hidden then set the clip rect so that children don't
|
||||
// leak out of us. Note that because overflow'-clip' only applies to
|
||||
// the content area we do this after painting the border and background
|
||||
|
@ -58,6 +58,9 @@
|
||||
#include "prenv.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static PRBool gLamePaintMetrics;
|
||||
@ -6239,6 +6242,43 @@ static void ComputeCombinedArea(nsLineBox* aLine,
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible)
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLHtmlElement> html(do_QueryInterface(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body(do_QueryInterface(mContent));
|
||||
|
||||
if (!html && !body) {
|
||||
rv = selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -6265,24 +6305,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check to see if we are an absolutely positioned block (div)
|
||||
// then then check to see if we need to paint.
|
||||
const nsStylePosition* postionStyle = (const nsStylePosition*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Position);
|
||||
if (NS_STYLE_POSITION_RELATIVE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_ABSOLUTE == postionStyle->mPosition ||
|
||||
NS_STYLE_POSITION_FIXED == postionStyle->mPosition) {
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool isVisible;
|
||||
if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// Only paint the border and background if we're visible
|
||||
if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
if (isVisible && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
||||
(0 != mRect.width) && (0 != mRect.height)) {
|
||||
PRIntn skipSides = GetSkipSides();
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
@ -6303,6 +6332,9 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
|
||||
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
||||
// If overflow is hidden then set the clip rect so that children don't
|
||||
// leak out of us. Note that because overflow'-clip' only applies to
|
||||
// the content area we do this after painting the border and background
|
||||
|
@ -2340,6 +2340,42 @@ nsFrame::ParentDisablesSelection() const
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrame::GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** aSelection)
|
||||
{
|
||||
*aSelection = nsnull;
|
||||
|
||||
// start by checking to see if we are paginated which probably means
|
||||
// we are in print preview or printing
|
||||
PRBool isPaginated;
|
||||
nsresult rv = aPresContext->IsPaginated(&isPaginated);
|
||||
if (NS_SUCCEEDED(rv) && isPaginated) {
|
||||
// now see if we are rendering selection only
|
||||
PRBool isRendingSelection;
|
||||
rv = aPresContext->IsRenderingOnlySelection(&isRendingSelection);
|
||||
if (NS_SUCCEEDED(rv) && isRendingSelection) {
|
||||
// Check the quick way first (typically only leaf nodes)
|
||||
PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
||||
// if we aren't selected in the mState,
|
||||
// we could be a container so check to see if we are in the selection range
|
||||
// this is a expensive
|
||||
if (!isSelected) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
|
||||
if (selcon) {
|
||||
rv = selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -2348,8 +2384,7 @@ nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
{
|
||||
// first check to see if we are visible
|
||||
if (aCheckVis) {
|
||||
nsIStyleContext* sc = mStyleContext;
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)sc->GetStyleData(eStyleStruct_Display);
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->IsVisible()) {
|
||||
*aIsVisible = PR_FALSE;
|
||||
return NS_OK;
|
||||
@ -2357,43 +2392,21 @@ nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
|
||||
}
|
||||
|
||||
// Start by assuming we are visible and need to be painted
|
||||
PRBool isVisible = PR_TRUE;
|
||||
*aIsVisible = PR_TRUE;
|
||||
|
||||
// start by checking to see if we are paginated which probably means
|
||||
// we are in print preview or printing
|
||||
PRBool isPaginated;
|
||||
aPresContext->IsPaginated(&isPaginated);
|
||||
if (isPaginated) {
|
||||
// now see if we are rendering selection only
|
||||
PRBool isRendingSelection;
|
||||
aPresContext->IsRenderingOnlySelection(&isRendingSelection);
|
||||
if (isRendingSelection) {
|
||||
// Check the quick way first (typically only leaf nodes)
|
||||
PRBool isSelected = (mState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
||||
// if we aren't selected in the mState,
|
||||
// we could be a container so check to see if we are in the selection range
|
||||
// this is a expensive
|
||||
if (!isSelected) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aPresContext->GetShell(getter_AddRefs(shell));
|
||||
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
|
||||
if (selcon) {
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
selection->ContainsNode(node, PR_TRUE, &isVisible);
|
||||
} else {
|
||||
isVisible = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// NOTE: GetSelectionforVisCheck checks the pagination to make sure we are printing
|
||||
// In otherwords, the selection will ALWAYS be null if we are not printing, meaning
|
||||
// the visibility will be TRUE in that case
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelectionForVisCheck(aPresContext, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(rv) && selection) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
||||
selection->ContainsNode(node, PR_TRUE, aIsVisible);
|
||||
}
|
||||
|
||||
*aIsVisible = isVisible;
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon)
|
||||
{
|
||||
|
@ -430,6 +430,9 @@ protected:
|
||||
// Style post processing hook
|
||||
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext);
|
||||
|
||||
// Helper routine for determining whether to print selection
|
||||
nsresult GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** aSelection);
|
||||
|
||||
//return the line number of the aFrame
|
||||
static PRInt32 GetLineNumber(nsIFrame *aFrame);
|
||||
//given a frame five me the first/last leaf available
|
||||
|
Loading…
Reference in New Issue
Block a user