Bug 253889: DeCOMtaminate nsIPresShell r=roc

This commit is contained in:
Craig Topper 2010-03-20 17:54:19 -04:00
Родитель fe6f7f5d46
Коммит 3d7073c4a5
17 изменённых файлов: 181 добавлений и 251 удалений

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

@ -6746,12 +6746,11 @@ nsDocument::CreateElem(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
PRBool
nsDocument::IsSafeToFlush() const
{
PRBool isSafeToFlush = PR_TRUE;
nsCOMPtr<nsIPresShell> shell = GetPrimaryShell();
if (shell) {
shell->IsSafeToFlush(isSafeToFlush);
}
return isSafeToFlush;
if (!shell)
return PR_TRUE;
return shell->IsSafeToFlush();
}
nsresult

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

@ -86,8 +86,7 @@ nsContentEventHandler::InitCommon()
// If text frame which has overflowing selection underline is dirty,
// we need to flush the pending reflow here.
nsresult rv = mPresShell->FlushPendingNotifications(Flush_Layout);
NS_ENSURE_SUCCESS(rv, rv);
mPresShell->FlushPendingNotifications(Flush_Layout);
nsCopySupport::GetSelectionForCopy(mPresShell->GetDocument(),
getter_AddRefs(mSelection));
@ -96,7 +95,7 @@ nsContentEventHandler::InitCommon()
nsCOMPtr<nsIDOMRange> firstRange;
rv = mSelection->GetRangeAt(0, getter_AddRefs(firstRange));
nsresult rv = mSelection->GetRangeAt(0, getter_AddRefs(firstRange));
// This shell doesn't support selection.
if (NS_FAILED(rv))
return NS_ERROR_NOT_AVAILABLE;

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

@ -462,9 +462,7 @@ nsXBLWindowKeyHandler::IsEditor()
docShell->GetPresShell(getter_AddRefs(presShell));
if (presShell) {
PRInt16 isEditor;
presShell->GetSelectionFlags(&isEditor);
return isEditor == nsISelectionDisplay::DISPLAY_ALL;
return presShell->GetSelectionFlags() == nsISelectionDisplay::DISPLAY_ALL;
}
return PR_FALSE;

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

@ -5827,8 +5827,7 @@ nsCSSFrameConstructor::FindFrameForContentSibling(nsIContent* aContent,
// If the frame is out-of-flow, GetPrimaryFrame() will have returned the
// out-of-flow frame; we want the placeholder.
if (sibling->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
nsIFrame* placeholderFrame;
mPresShell->GetPlaceholderFrameFor(sibling, &placeholderFrame);
nsIFrame* placeholderFrame = mPresShell->FrameManager()->GetPlaceholderFrameFor(sibling);
NS_ASSERTION(placeholderFrame, "no placeholder for out-of-flow frame");
sibling = placeholderFrame;
}
@ -8247,8 +8246,7 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame)
// are within fixed frames, because that would cause duplicates on the new
// page - bug 389619)
for (nsIFrame* fixed = firstFixed; fixed; fixed = fixed->GetNextSibling()) {
nsIFrame* prevPlaceholder = nsnull;
mPresShell->GetPlaceholderFrameFor(fixed, &prevPlaceholder);
nsIFrame* prevPlaceholder = mPresShell->FrameManager()->GetPlaceholderFrameFor(fixed);
if (prevPlaceholder &&
nsLayoutUtils::IsProperAncestorFrame(prevCanvasFrame, prevPlaceholder)) {
nsresult rv = ConstructFrame(state, fixed->GetContent(),

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

@ -2787,8 +2787,7 @@ DocumentViewerImpl::SetFullZoom(float aFullZoom)
mPrintPreviewZoom = aFullZoom;
pc->SetPrintPreviewScale(aFullZoom * mOriginalPrintPreviewScale);
nsIPageSequenceFrame* pf = nsnull;
shell->GetPageSequenceFrame(&pf);
nsIPageSequenceFrame* pf = shell->GetPageSequenceFrame();
if (pf) {
nsIFrame* f = do_QueryFrame(pf);
shell->FrameNeedsReflow(f, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);

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

@ -514,8 +514,7 @@ nsFrameIterator::GetPlaceholderFrame(nsIFrame* aFrame)
nsIFrame* result = aFrame;
nsIPresShell *presShell = mPresContext->GetPresShell();
if (presShell) {
nsIFrame* placeholder = 0;
presShell->GetPlaceholderFrameFor(aFrame, &placeholder);
nsIFrame* placeholder = presShell->GetPlaceholderFrameFor(aFrame);
if (placeholder)
result = placeholder;
}

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

@ -127,8 +127,8 @@ typedef struct CapturingContentInfo {
} CapturingContentInfo;
#define NS_IPRESSHELL_IID \
{ 0x0e170e5f, 0xf6d4, 0x44c5, \
{ 0xbc, 0x2c, 0x44, 0x94, 0x20, 0x7e, 0xcc, 0x30 } }
{ 0x94c34e88, 0x2da3, 0x49d4, \
{ 0xa5, 0x35, 0x51, 0xa4, 0x16, 0x92, 0xa5, 0x79 } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -182,11 +182,11 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell_base, NS_IPRESSHELL_IID)
class nsIPresShell : public nsIPresShell_base
{
public:
NS_IMETHOD Init(nsIDocument* aDocument,
nsPresContext* aPresContext,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsCompatibility aCompatMode) = 0;
virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument,
nsPresContext* aPresContext,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsCompatibility aCompatMode) = 0;
/**
* All callers are responsible for calling |Destroy| after calling
@ -195,8 +195,8 @@ public:
* content model and printing calls |EndObservingDocument| multiple
* times to make form controls behave nicely when printed.
*/
NS_IMETHOD Destroy() = 0;
virtual NS_HIDDEN_(void) Destroy() = 0;
PRBool IsDestroying() { return mIsDestroying; }
// All frames owned by the shell are allocated from an arena. They
@ -232,7 +232,7 @@ public:
virtual void PushStackMemory() = 0;
virtual void PopStackMemory() = 0;
virtual void* AllocateStackMemory(size_t aSize) = 0;
nsIDocument* GetDocument() const { return mDocument; }
nsPresContext* GetPresContext() { return mPresContext; }
@ -288,7 +288,7 @@ public:
*
* - initially created for bugs 31816, 20760, 22963
*/
NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow) = 0;
virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(PRBool aForceReflow) = 0;
/**
* FrameSelection will return the Frame based selection API.
@ -305,10 +305,10 @@ public:
// Make shell be a document observer. If called after Destroy() has
// been called on the shell, this will be ignored.
NS_IMETHOD BeginObservingDocument() = 0;
virtual NS_HIDDEN_(void) BeginObservingDocument() = 0;
// Make shell stop being a document observer
NS_IMETHOD EndObservingDocument() = 0;
virtual NS_HIDDEN_(void) EndObservingDocument() = 0;
/**
* Return whether InitialReflow() was previously called.
@ -326,18 +326,18 @@ public:
* is guaranteed to survive through arbitrary script execution.
* Calling InitialReflow can execute arbitrary script.
*/
NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight) = 0;
virtual NS_HIDDEN_(nsresult) InitialReflow(nscoord aWidth, nscoord aHeight) = 0;
/**
* Reflow the frame model into a new width and height. The
* coordinates for aWidth and aHeight must be in standard nscoord's.
*/
NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
virtual NS_HIDDEN_(nsresult) ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
/**
* Reflow the frame model with a reflow reason of eReflowReason_StyleChange
*/
NS_IMETHOD StyleChangeReflow() = 0;
virtual NS_HIDDEN_(void) StyleChangeReflow() = 0;
/**
* This calls through to the frame manager to get the root frame.
@ -376,7 +376,7 @@ public:
* Returns the page sequence frame associated with the frame hierarchy.
* Returns NULL if not a paginated view.
*/
NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const = 0;
virtual NS_HIDDEN_(nsIPageSequenceFrame*) GetPageSequenceFrame() const = 0;
/**
* Gets the real primary frame associated with the content object.
@ -391,8 +391,7 @@ public:
* Gets the placeholder frame associated with the specified frame. This is
* a helper frame that forwards the request to the frame manager.
*/
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aPlaceholderFrame) const = 0;
virtual NS_HIDDEN_(nsIFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame) const = 0;
/**
* Tell the pres shell that a frame needs to be marked dirty and needs
@ -407,9 +406,9 @@ public:
eTreeChange, // mark intrinsic widths dirty on aFrame and its ancestors
eStyleChange // Do eTreeChange, plus all of aFrame's descendants
};
NS_IMETHOD FrameNeedsReflow(nsIFrame *aFrame,
IntrinsicDirty aIntrinsicDirty,
nsFrameState aBitToAdd) = 0;
virtual NS_HIDDEN_(void) FrameNeedsReflow(nsIFrame *aFrame,
IntrinsicDirty aIntrinsicDirty,
nsFrameState aBitToAdd) = 0;
/**
* Tell the presshell that the given frame's reflow was interrupted. This
@ -422,9 +421,9 @@ public:
* method doesn't mark any intrinsic widths dirty and doesn't add any bits
* other than NS_FRAME_HAS_DIRTY_CHILDREN.
*/
NS_IMETHOD_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame) = 0;
virtual NS_HIDDEN_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame) = 0;
NS_IMETHOD CancelAllPendingReflows() = 0;
virtual NS_HIDDEN_(void) CancelAllPendingReflows() = 0;
/**
* Recreates the frames for a node
@ -433,13 +432,13 @@ public:
void PostRecreateFramesFor(nsIContent* aContent);
void RestyleForAnimation(nsIContent* aContent);
/**
* Determine if it is safe to flush all pending notifications
* @param aIsSafeToFlush PR_TRUE if it is safe, PR_FALSE otherwise.
*
*/
NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush) = 0;
virtual NS_HIDDEN_(PRBool) IsSafeToFlush() = 0;
/**
* Flush pending notifications of the type specified. This method
@ -450,7 +449,7 @@ public:
*
* @param aType the type of notifications to flush
*/
NS_IMETHOD FlushPendingNotifications(mozFlushType aType) = 0;
virtual NS_HIDDEN_(void) FlushPendingNotifications(mozFlushType aType) = 0;
/**
* Callbacks will be called even if reflow itself fails for
@ -611,21 +610,18 @@ public:
* by the frames. Visual effects may not effect layout, only display.
* Takes effect on next repaint, does not force a repaint itself.
*
* @param aEnabled if PR_TRUE, visual selection effects are enabled
* if PR_FALSE visual selection effects are disabled
* @return always NS_OK
* @param aInEnable if PR_TRUE, visual selection effects are enabled
* if PR_FALSE visual selection effects are disabled
*/
NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable) = 0;
/**
* Gets the current state of non text selection effects
* @param aEnabled [OUT] set to the current state of non text selection,
* as set by SetDisplayNonTextSelection
* @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
* else NS_OK
* @return current state of non text selection,
* as set by SetDisplayNonTextSelection
*/
NS_IMETHOD GetSelectionFlags(PRInt16 *aOutEnabled) = 0;
virtual NS_HIDDEN_(PRInt16) GetSelectionFlags() = 0;
virtual nsISelection* GetCurrentSelection(SelectionType aType) = 0;
/**

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

@ -217,11 +217,7 @@ void
nsImageLoader::DoReflow()
{
nsIPresShell *shell = mFrame->PresContext()->GetPresShell();
#ifdef DEBUG
nsresult rv =
#endif
shell->FrameNeedsReflow(mFrame, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Could not reflow after loading border-image");
shell->FrameNeedsReflow(mFrame, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
}
void

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

@ -659,12 +659,12 @@ public:
NS_DECL_ISUPPORTS
// nsIPresShell
NS_IMETHOD Init(nsIDocument* aDocument,
nsPresContext* aPresContext,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsCompatibility aCompatMode);
NS_IMETHOD Destroy();
virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument,
nsPresContext* aPresContext,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsCompatibility aCompatMode);
virtual NS_HIDDEN_(void) Destroy();
virtual NS_HIDDEN_(void*) AllocateFrame(nsQueryFrame::FrameIID aCode,
size_t aSize);
@ -679,8 +679,8 @@ public:
virtual NS_HIDDEN_(void) PopStackMemory();
virtual NS_HIDDEN_(void*) AllocateStackMemory(size_t aSize);
NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow);
virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(PRBool aForceReflow);
NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection);
virtual nsISelection* GetCurrentSelection(SelectionType aType);
@ -689,23 +689,21 @@ public:
NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion, PRBool aIsSynchronous);
NS_IMETHOD RepaintSelection(SelectionType aType);
NS_IMETHOD BeginObservingDocument();
NS_IMETHOD EndObservingDocument();
NS_IMETHOD GetDidInitialReflow(PRBool *aDidInitialReflow);
NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight);
NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight);
NS_IMETHOD StyleChangeReflow();
NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const;
virtual NS_HIDDEN_(void) BeginObservingDocument();
virtual NS_HIDDEN_(void) EndObservingDocument();
virtual NS_HIDDEN_(nsresult) InitialReflow(nscoord aWidth, nscoord aHeight);
virtual NS_HIDDEN_(nsresult) ResizeReflow(nscoord aWidth, nscoord aHeight);
virtual NS_HIDDEN_(void) StyleChangeReflow();
virtual NS_HIDDEN_(nsIPageSequenceFrame*) GetPageSequenceFrame() const;
virtual NS_HIDDEN_(nsIFrame*) GetRealPrimaryFrameFor(nsIContent* aContent) const;
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aPlaceholderFrame) const;
NS_IMETHOD FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
nsFrameState aBitToAdd);
NS_IMETHOD_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame);
NS_IMETHOD CancelAllPendingReflows();
NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush);
NS_IMETHOD FlushPendingNotifications(mozFlushType aType);
virtual NS_HIDDEN_(nsIFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame) const;
virtual NS_HIDDEN_(void) FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
nsFrameState aBitToAdd);
virtual NS_HIDDEN_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame);
virtual NS_HIDDEN_(void) CancelAllPendingReflows();
virtual NS_HIDDEN_(PRBool) IsSafeToFlush();
virtual NS_HIDDEN_(void) FlushPendingNotifications(mozFlushType aType);
/**
* Recreates the frames for a node
@ -825,6 +823,7 @@ public:
NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable);
NS_IMETHOD GetSelectionFlags(PRInt16 *aOutEnable);
virtual NS_HIDDEN_(PRInt16) GetSelectionFlags();
// nsISelectionController
@ -1563,7 +1562,7 @@ PresShell::~PresShell()
* Initialize the presentation shell. Create view manager and style
* manager.
*/
NS_IMETHODIMP
nsresult
PresShell::Init(nsIDocument* aDocument,
nsPresContext* aPresContext,
nsIViewManager* aViewManager,
@ -1707,7 +1706,7 @@ PresShell::Init(nsIDocument* aDocument,
return NS_OK;
}
NS_IMETHODIMP
void
PresShell::Destroy()
{
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
@ -1722,7 +1721,7 @@ PresShell::Destroy()
#endif
if (mHaveShutDown)
return NS_OK;
return;
MaybeReleaseCapturingContent();
@ -1767,7 +1766,7 @@ PresShell::Destroy()
mCaret->Terminate();
mCaret = nsnull;
}
if (mSelection) {
mSelection->DisconnectFromPresShell();
}
@ -1862,8 +1861,6 @@ PresShell::Destroy()
}
mHaveShutDown = PR_TRUE;
return NS_OK;
}
// Dynamic stack memory allocation
@ -1943,7 +1940,7 @@ nsIPresShell::GetAuthorStyleDisabled()
return mStyleSet->GetAuthorStyleDisabled();
}
NS_IMETHODIMP
nsresult
PresShell::SetPreferenceStyleRules(PRBool aForceReflow)
{
if (!mDocument) {
@ -2409,7 +2406,7 @@ PresShell::RepaintSelection(SelectionType aType)
}
// Make shell be a document observer
NS_IMETHODIMP
void
PresShell::BeginObservingDocument()
{
if (mDocument && !mIsDestroying) {
@ -2420,11 +2417,10 @@ PresShell::BeginObservingDocument()
mIsDocumentGone = PR_FALSE;
}
}
return NS_OK;
}
// Make shell stop being a document observer
NS_IMETHODIMP
void
PresShell::EndObservingDocument()
{
// XXXbz do we need to tell the frame constructor that the document
@ -2433,25 +2429,13 @@ PresShell::EndObservingDocument()
if (mDocument) {
mDocument->RemoveObserver(this);
}
return NS_OK;
}
#ifdef DEBUG_kipp
char* nsPresShell_ReflowStackPointerTop;
#endif
NS_IMETHODIMP
PresShell::GetDidInitialReflow(PRBool *aDidInitialReflow)
{
if (!aDidInitialReflow)
return NS_ERROR_FAILURE;
*aDidInitialReflow = mDidInitialReflow;
return NS_OK;
}
NS_IMETHODIMP
nsresult
PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
{
if (mIsDestroying) {
@ -2612,7 +2596,7 @@ PresShell::AsyncResizeEventCallback(nsITimer* aTimer, void* aPresShell)
static_cast<PresShell*>(aPresShell)->FireResizeEvent();
}
NS_IMETHODIMP
nsresult
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
{
NS_PRECONDITION(!mIsReflowing, "Shouldn't be in reflow here!");
@ -2875,6 +2859,11 @@ NS_IMETHODIMP PresShell::GetSelectionFlags(PRInt16 *aOutEnable)
return NS_OK;
}
PRInt16 PresShell::GetSelectionFlags()
{
return mSelectionFlags;
}
//implementation of nsISelectionController
NS_IMETHODIMP
@ -3068,16 +3057,16 @@ PresShell::CheckVisibility(nsIDOMNode *node, PRInt16 startOffset, PRInt16 EndOff
//end implementations nsISelectionController
NS_IMETHODIMP
void
PresShell::StyleChangeReflow()
{
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
// At the moment at least, we don't have a root frame before the initial
// reflow; it's safe to just ignore the request in that case
if (!rootFrame)
return NS_OK;
return;
return FrameNeedsReflow(rootFrame, eStyleChange, NS_FRAME_IS_DIRTY);
FrameNeedsReflow(rootFrame, eStyleChange, NS_FRAME_IS_DIRTY);
}
nsIFrame*
@ -3117,18 +3106,11 @@ nsIPresShell::GetRootScrollFrameAsScrollableExternal() const
return GetRootScrollFrameAsScrollable();
}
NS_IMETHODIMP
PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const
nsIPageSequenceFrame*
PresShell::GetPageSequenceFrame() const
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = nsnull;
nsIFrame* frame = mFrameConstructor->GetPageSequenceFrame();
*aResult = do_QueryFrame(frame);
return *aResult ? NS_OK : NS_ERROR_FAILURE;
return do_QueryFrame(frame);
}
nsIFrame*
@ -3239,7 +3221,7 @@ PresShell::VerifyHasDirtyRootAncestor(nsIFrame* aFrame)
}
#endif
NS_IMETHODIMP
void
PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
nsFrameState aBitToAdd)
{
@ -3255,17 +3237,16 @@ PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
// If we've not yet done the initial reflow, then don't bother
// enqueuing a reflow command yet.
if (! mDidInitialReflow)
return NS_OK;
return;
// If we're already destroying, don't bother with this either.
if (mIsDestroying)
return NS_OK;
return;
#ifdef DEBUG
//printf("gShellCounter: %d\n", gShellCounter++);
if (mInVerifyReflow) {
return NS_OK;
}
if (mInVerifyReflow)
return;
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
printf("\nPresShell@%p: frame %p needs reflow\n", (void*)this, (void*)aFrame);
@ -3381,11 +3362,9 @@ PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
} while (subtrees.Length() != 0);
MaybeScheduleReflow();
return NS_OK;
}
NS_IMETHODIMP_(void)
void
PresShell::FrameNeedsToContinueReflow(nsIFrame *aFrame)
{
NS_ASSERTION(mIsReflowing, "Must be in reflow when marking path dirty.");
@ -3447,7 +3426,7 @@ nsIPresShell::GetFrameToScrollAsScrollable(
return scrollFrame;
}
NS_IMETHODIMP
void
PresShell::CancelAllPendingReflows()
{
mDirtyRoots.Clear();
@ -3458,8 +3437,6 @@ PresShell::CancelAllPendingReflows()
}
ASSERT_REFLOW_SCHEDULED_STATE();
return NS_OK;
}
#ifdef ACCESSIBILITY
@ -4586,36 +4563,35 @@ PresShell::HandlePostedReflowCallbacks(PRBool aInterruptible)
FlushPendingNotifications(flushType);
}
NS_IMETHODIMP
PresShell::IsSafeToFlush(PRBool& aIsSafeToFlush)
PRBool
PresShell::IsSafeToFlush()
{
// Not safe if we are reflowing or in the middle of frame construction
aIsSafeToFlush = !mIsReflowing &&
!mChangeNestCount;
PRBool isSafeToFlush = !mIsReflowing &&
!mChangeNestCount;
if (aIsSafeToFlush) {
if (isSafeToFlush) {
// Not safe if we are painting
nsIViewManager* viewManager = GetViewManager();
if (viewManager) {
PRBool isPainting = PR_FALSE;
viewManager->IsPainting(isPainting);
if (isPainting) {
aIsSafeToFlush = PR_FALSE;
isSafeToFlush = PR_FALSE;
}
}
}
return NS_OK;
return isSafeToFlush;
}
NS_IMETHODIMP
void
PresShell::FlushPendingNotifications(mozFlushType aType)
{
NS_ASSERTION(aType >= Flush_Frames, "Why did we get called?");
PRBool isSafeToFlush;
IsSafeToFlush(isSafeToFlush);
PRBool isSafeToFlush = IsSafeToFlush();
isSafeToFlush = isSafeToFlush && nsContentUtils::IsSafeToRunScript();
NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager");
@ -4629,7 +4605,7 @@ PresShell::FlushPendingNotifications(mozFlushType aType)
if (mResizeEvent.IsPending()) {
FireResizeEvent();
if (mIsDestroying) {
return NS_OK;
return;
}
}
@ -4714,8 +4690,6 @@ PresShell::FlushPendingNotifications(mozFlushType aType)
}
batch.EndUpdateViewBatch(updateFlags);
}
return NS_OK;
}
NS_IMETHODIMP
@ -5039,12 +5013,10 @@ PresShell::GetRealPrimaryFrameFor(nsIContent* aContent) const
return nsPlaceholderFrame::GetRealFrameFor(primaryFrame);
}
NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const
nsIFrame*
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame) const
{
*aResult = FrameManager()->GetPlaceholderFrameFor(aFrame);
return NS_OK;
return FrameManager()->GetPlaceholderFrameFor(aFrame);
}
//nsIViewObserver

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

@ -82,9 +82,11 @@ nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
// no damage to intrinsic widths, since absolutely positioned frames can't
// change them
return aDelegatingFrame->PresContext()->PresShell()->
aDelegatingFrame->PresContext()->PresShell()->
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
NS_FRAME_HAS_DIRTY_CHILDREN);
return NS_OK;
}
nsresult
@ -104,9 +106,11 @@ nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
// no damage to intrinsic widths, since absolutely positioned frames can't
// change them
return aDelegatingFrame->PresContext()->PresShell()->
aDelegatingFrame->PresContext()->PresShell()->
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
NS_FRAME_HAS_DIRTY_CHILDREN);
return NS_OK;
}
void

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

@ -123,7 +123,7 @@ nsCanvasFrame::SetHasFocus(PRBool aHasFocus)
NS_IMETHODIMP
nsCanvasFrame::SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList)
nsFrameList& aChildList)
{
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.SetInitialChildList(this, aListName, aChildList);
@ -135,10 +135,8 @@ nsCanvasFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
nsCanvasFrame::AppendFrames(nsIAtom* aListName,
nsFrameList& aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.AppendFrames(this, aListName, aFrameList);
@ -146,57 +144,50 @@ nsCanvasFrame::AppendFrames(nsIAtom* aListName,
NS_PRECONDITION(mFrames.IsEmpty(), "already have a child frame");
if (aListName) {
// We only support unnamed principal child list
rv = NS_ERROR_INVALID_ARG;
} else if (!mFrames.IsEmpty()) {
// We only allow a single child frame
rv = NS_ERROR_FAILURE;
} else {
// Insert the new frames
NS_ASSERTION(aFrameList.FirstChild() == aFrameList.LastChild(),
"Only one principal child frame allowed");
#ifdef NS_DEBUG
nsFrame::VerifyDirtyBitSet(aFrameList);
#endif
mFrames.AppendFrames(nsnull, aFrameList);
rv = PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);
return NS_ERROR_INVALID_ARG;
}
return rv;
if (!mFrames.IsEmpty()) {
// We only allow a single child frame
return NS_ERROR_INVALID_ARG;
}
// Insert the new frames
NS_ASSERTION(aFrameList.FirstChild() == aFrameList.LastChild(),
"Only one principal child frame allowed");
#ifdef NS_DEBUG
nsFrame::VerifyDirtyBitSet(aFrameList);
#endif
mFrames.AppendFrames(nsnull, aFrameList);
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);
return NS_OK;
}
NS_IMETHODIMP
nsCanvasFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
nsresult rv;
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.InsertFrames(this, aListName, aPrevFrame, aFrameList);
// Because we only support a single child frame inserting is the same
// as appending
NS_PRECONDITION(!aPrevFrame, "unexpected previous sibling frame");
if (aPrevFrame) {
rv = NS_ERROR_UNEXPECTED;
} else {
rv = AppendFrames(aListName, aFrameList);
}
if (aPrevFrame)
return NS_ERROR_UNEXPECTED;
return rv;
return AppendFrames(aListName, aFrameList);
}
NS_IMETHODIMP
nsCanvasFrame::RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame)
nsIFrame* aOldFrame)
{
nsresult rv;
if (nsGkAtoms::absoluteList == aListName) {
mAbsoluteContainer.RemoveFrame(this, aListName, aOldFrame);
return NS_OK;
@ -205,26 +196,25 @@ nsCanvasFrame::RemoveFrame(nsIAtom* aListName,
NS_ASSERTION(!aListName, "unexpected child list name");
if (aListName) {
// We only support the unnamed principal child list
rv = NS_ERROR_INVALID_ARG;
} else if (aOldFrame == mFrames.FirstChild()) {
// It's our one and only child frame
// Damage the area occupied by the deleted frame
// The child of the canvas probably can't have an outline, but why bother
// thinking about that?
Invalidate(aOldFrame->GetOverflowRect() + aOldFrame->GetPosition());
// Remove the frame and destroy it
mFrames.DestroyFrame(aOldFrame);
rv = PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);
} else {
rv = NS_ERROR_FAILURE;
return NS_ERROR_INVALID_ARG;
}
return rv;
if (aOldFrame != mFrames.FirstChild())
return NS_ERROR_FAILURE;
// It's our one and only child frame
// Damage the area occupied by the deleted frame
// The child of the canvas probably can't have an outline, but why bother
// thinking about that?
Invalidate(aOldFrame->GetOverflowRect() + aOldFrame->GetPosition());
// Remove the frame and destroy it
mFrames.DestroyFrame(aOldFrame);
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);
return NS_OK;
}
nsIAtom*
@ -321,8 +311,8 @@ public:
NS_IMETHODIMP
nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
nsresult rv;

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

@ -908,10 +908,7 @@ nsFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
if (!shell)
return NS_OK;
PRInt16 displaySelection;
nsresult rv = shell->GetSelectionFlags(&displaySelection);
if (NS_FAILED(rv))
return rv;
PRInt16 displaySelection = shell->GetSelectionFlags();
if (!(displaySelection & aContentType))
return NS_OK;
@ -1703,10 +1700,7 @@ nsFrame::GetDataForTableSelection(const nsFrameSelection *aFrameSelection,
*aContentOffset = 0;
*aTarget = 0;
PRInt16 displaySelection;
nsresult result = aPresShell->GetSelectionFlags(&displaySelection);
if (NS_FAILED(result))
return result;
PRInt16 displaySelection = aPresShell->GetSelectionFlags();
PRBool selectingTableCells = aFrameSelection->GetTableCellSelection();
@ -1748,9 +1742,7 @@ nsFrame::GetDataForTableSelection(const nsFrameSelection *aFrameSelection,
//PRBool selectColumn = PR_FALSE;
//PRBool selectRow = PR_FALSE;
result = NS_OK;
while (frame && NS_SUCCEEDED(result))
while (frame)
{
// Check for a table cell by querying to a known CellFrame interface
nsITableCellLayout *cellElement = do_QueryFrame(frame);
@ -1775,7 +1767,6 @@ nsFrame::GetDataForTableSelection(const nsFrameSelection *aFrameSelection,
break;
} else {
frame = frame->GetParent();
result = NS_OK;
// Stop if we have hit the selection's limiting content node
if (frame && frame->GetContent() == limiter)
break;
@ -1910,9 +1901,8 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
// if we are in Navigator and the click is in a draggable node, we don't want
// to start selection because we don't want to interfere with a potential
// drag of said node and steal all its glory.
PRInt16 isEditor = 0;
shell->GetSelectionFlags ( &isEditor );
//weaaak. only the editor can display frame selction not just text and images
PRInt16 isEditor = shell->GetSelectionFlags();
//weaaak. only the editor can display frame selection not just text and images
isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
nsInputEvent* keyEvent = (nsInputEvent*)aEvent;
@ -4683,13 +4673,12 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
//special check. if we allow non-text selection then we can allow a hit location to fall before a table.
//otherwise there is no way to get and click signal to fall before a table (it being a line iterator itself)
PRInt16 isEditor = 0;
nsIPresShell *shell = aPresContext->GetPresShell();
if (!shell)
return NS_ERROR_FAILURE;
shell->GetSelectionFlags ( &isEditor );
PRInt16 isEditor = shell->GetSelectionFlags();
isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
if ( isEditor )
if ( isEditor )
{
if (resultFrame->GetType() == nsGkAtoms::tableOuterFrame)
{

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

@ -1152,8 +1152,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
// Get the placeholder frame
nsIFrame* placeholderFrame;
aPresContext->PresShell()->GetPlaceholderFrameFor(outOfFlow,
&placeholderFrame);
placeholderFrame = aPresContext->PresShell()->GetPlaceholderFrameFor(outOfFlow);
NS_ASSERTION(nsnull != placeholderFrame, "no placeholder frame");
// If both 'left' and 'right' are 'auto' or both 'top' and 'bottom' are

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

@ -1258,12 +1258,9 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
// XXX what on EARTH is this code for?
PRInt16 displaySelection = 0;
nsresult result;
nsPresContext* presContext = PresContext();
result = presContext->PresShell()->GetSelectionFlags(&displaySelection);
if (NS_FAILED(result))
return result;
PRInt16 displaySelection = presContext->PresShell()->GetSelectionFlags();
if (!(displaySelection & nsISelectionDisplay::DISPLAY_IMAGES))
return NS_OK;//no need to check the blue border, we cannot be drawn selected
//insert hook here for image selection drawing

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

@ -1828,10 +1828,7 @@ nsFrameSelection::TakeFocus(nsIContent *aNewFocus,
// BUT only do this in an editor
NS_ENSURE_STATE(mShell);
PRInt16 displaySelection;
nsresult result = mShell->GetSelectionFlags(&displaySelection);
if (NS_FAILED(result))
return result;
PRInt16 displaySelection = mShell->GetSelectionFlags();
// Editor has DISPLAY_ALL selection type
if (displaySelection == nsISelectionDisplay::DISPLAY_ALL)

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

@ -761,8 +761,10 @@ nsMathMLContainerFrame::ReLayoutChildren(nsIFrame* aParentFrame)
if (!parent)
return NS_OK;
return frame->PresContext()->PresShell()->
frame->PresContext()->PresShell()->
FrameNeedsReflow(frame, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
return NS_OK;
}
// There are precise rules governing children of a MathML frame,
@ -839,9 +841,10 @@ nsMathMLContainerFrame::AttributeChanged(PRInt32 aNameSpaceID,
// XXX Since they are numerous MathML attributes that affect layout, and
// we can't check all of them here, play safe by requesting a reflow.
// XXXldb This should only do work for attributes that cause changes!
return PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eStyleChange,
NS_FRAME_IS_DIRTY);
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
return NS_OK;
}
void

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

@ -385,8 +385,7 @@ nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO,
NS_ENSURE_ARG_POINTER(aPO);
// Finds the SimplePageSequencer frame
nsIPageSequenceFrame* seqFrame = nsnull;
aPO->mPresShell->GetPageSequenceFrame(&seqFrame);
nsIPageSequenceFrame* seqFrame = aPO->mPresShell->GetPageSequenceFrame();
if (seqFrame) {
aSeqFrame = do_QueryFrame(seqFrame);
} else {
@ -1798,8 +1797,7 @@ nsPrintEngine::SetupToPrintContent()
if (mIsCreatingPrintPreview) {
// Print Preview -- Pass ownership of docTitleStr and docURLStr
// to the pageSequenceFrame, to be displayed in the header
nsIPageSequenceFrame *seqFrame = nsnull;
mPrt->mPrintObject->mPresShell->GetPageSequenceFrame(&seqFrame);
nsIPageSequenceFrame *seqFrame = mPrt->mPrintObject->mPresShell->GetPageSequenceFrame();
if (seqFrame) {
seqFrame->StartPrint(mPrt->mPrintObject->mPresContext,
mPrt->mPrintSettings, docTitleStr, docURLStr);
@ -2062,8 +2060,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
// this is the frame where the right-hand side of the frame extends
// the furthest
if (mPrt->mShrinkToFit && documentIsTopLevel) {
nsIPageSequenceFrame* pageSequence;
aPO->mPresShell->GetPageSequenceFrame(&pageSequence);
nsIPageSequenceFrame* pageSequence = aPO->mPresShell->GetPageSequenceFrame();
pageSequence->GetSTFPercent(aPO->mShrinkRatio);
}
@ -2121,8 +2118,7 @@ nsPrintEngine::CalcNumPrintablePages(PRInt32& aNumPages)
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
if (po->mPresContext && po->mPresContext->IsRootPaginatedDocument()) {
nsIPageSequenceFrame* pageSequence;
po->mPresShell->GetPageSequenceFrame(&pageSequence);
nsIPageSequenceFrame* pageSequence = po->mPresShell->GetPageSequenceFrame();
nsIFrame * seqFrame = do_QueryFrame(pageSequence);
if (seqFrame) {
nsIFrame* frame = seqFrame->GetFirstChild(nsnull);
@ -2290,8 +2286,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
}
// Ask the page sequence frame to print all the pages
nsIPageSequenceFrame* pageSequence;
poPresShell->GetPageSequenceFrame(&pageSequence);
nsIPageSequenceFrame* pageSequence = poPresShell->GetPageSequenceFrame();
NS_ASSERTION(nsnull != pageSequence, "no page sequence frame");
// We are done preparing for printing, so we can turn this off