Backed out changeset 4b8936ac4a31

This commit is contained in:
Kyle Huey 2010-03-30 19:56:44 -04:00
parent 6c9540a26d
commit afc6c6ca2d
20 changed files with 205 additions and 143 deletions

View File

@ -322,7 +322,8 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
nsCoreUtils::GetPresShellFor(lastNodeWithCaret);
NS_ENSURE_TRUE(presShell, caretRect);
nsRefPtr<nsCaret> caret = presShell->GetCaret();
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
NS_ENSURE_TRUE(caret, caretRect);
nsCOMPtr<nsISelection> caretSelection(do_QueryReferent(mLastUsedSelection));

View File

@ -307,7 +307,9 @@ nsImageLoadingContent::OnStopDecode(imgIRequest* aRequest,
// to be suppressed for reasons other than the initial paint delay (for
// example - being in the bfcache), but we probably aren't loading images in
// those situations.
if (shell->IsPaintingSuppressed())
PRBool isSuppressed = PR_FALSE;
nsresult rv = shell->IsPaintingSuppressed(&isSuppressed);
if (NS_SUCCEEDED(rv) && isSuppressed)
doRequestDecode = PR_TRUE;
// If we're requesting a decode, do it

View File

@ -135,8 +135,10 @@ nsContentEventHandler::Init(nsQueryContentEvent* aEvent)
NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
aEvent->mReply.mHasSelection = !isCollapsed;
nsRefPtr<nsCaret> caret = mPresShell->GetCaret();
NS_ASSERTION(caret, "GetCaret returned null");
nsRefPtr<nsCaret> caret;
rv = mPresShell->GetCaret(getter_AddRefs(caret));
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(caret, "GetCaret succeeded, but the result is null");
nsRect r;
nsIFrame* frame = caret->GetGeometry(mSelection, &r);
@ -661,8 +663,10 @@ nsContentEventHandler::OnQueryCaretRect(nsQueryContentEvent* aEvent)
if (NS_FAILED(rv))
return rv;
nsRefPtr<nsCaret> caret = mPresShell->GetCaret();
NS_ASSERTION(caret, "GetCaret returned null");
nsRefPtr<nsCaret> caret;
rv = mPresShell->GetCaret(getter_AddRefs(caret));
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(caret, "GetCaret succeeded, but the result is null");
// When the selection is collapsed and the queried offset is current caret
// position, we should return the "real" caret rect.

View File

@ -3904,7 +3904,8 @@ nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
}
}
nsIFrame* frame = shell->GetEventTargetFrame();
nsIFrame* frame = nsnull;
shell->GetEventTargetFrame(&frame);
*aFrame = mCurrentTarget = frame;
return NS_OK;
}
@ -3930,7 +3931,7 @@ nsEventStateManager::GetEventTargetContent(nsEvent* aEvent,
nsIPresShell *presShell = mPresContext->GetPresShell();
if (presShell) {
*aContent = presShell->GetEventTargetContent(aEvent).get();
presShell->GetEventTargetContent(aEvent, aContent);
}
// Some events here may set mCurrentTarget but not set the corresponding

View File

@ -1899,7 +1899,8 @@ nsFocusManager::SetCaretVisible(nsIPresShell* aPresShell,
// When browsing with caret, make sure caret is visible after new focus
// Return early if there is no caret. This can happen for the testcase
// for bug 308025 where a window is closed in a blur handler.
nsRefPtr<nsCaret> caret = aPresShell->GetCaret();
nsRefPtr<nsCaret> caret;
aPresShell->GetCaret(getter_AddRefs(caret));
if (!caret)
return NS_OK;
@ -2053,7 +2054,8 @@ nsFocusManager::GetSelectionLocation(nsIDocument* aDocument,
if (newCaretFrame && newCaretContent) {
// If the caret is exactly at the same position of the new frame,
// then we can use the newCaretFrame and newCaretContent for our position
nsRefPtr<nsCaret> caret = aPresShell->GetCaret();
nsRefPtr<nsCaret> caret;
aPresShell->GetCaret(getter_AddRefs(caret));
nsRect caretRect;
nsIFrame *frame = caret->GetGeometry(domSelection, &caretRect);
if (frame) {

View File

@ -1981,9 +1981,10 @@ nsEditor::QueryComposition(nsTextEventReply* aReply)
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsRefPtr<nsCaret> caretP = ps->GetCaret();
if (caretP) {
nsRefPtr<nsCaret> caretP;
result = ps->GetCaret(getter_AddRefs(caretP));
if (NS_SUCCEEDED(result) && caretP) {
if (aReply) {
caretP->SetCaretDOMSelection(selection);
@ -4362,10 +4363,10 @@ nsresult nsEditor::EndUpdateViewBatch()
GetPresShell(getter_AddRefs(presShell));
if (presShell)
caret = presShell->GetCaret();
presShell->GetCaret(getter_AddRefs(caret));
StCaretHider caretHider(caret);
PRUint32 flags = 0;
GetFlags(&flags);

View File

@ -870,7 +870,8 @@ nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell) {
nsRefPtr<nsCaret> caret = presShell->GetCaret();
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (caret) {
caret->SetIgnoreUserModify(PR_FALSE);
if (selection) {
@ -941,7 +942,8 @@ nsEditorEventListener::Blur(nsIDOMEvent* aEvent)
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell) {
nsRefPtr<nsCaret> caret = presShell->GetCaret();
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (caret) {
caret->SetIgnoreUserModify(PR_TRUE);
}

View File

@ -1576,7 +1576,8 @@ nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString, nsI
nsresult result = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(result)) return result;
nsRefPtr<nsCaret> caretP = ps->GetCaret();
nsRefPtr<nsCaret> caretP;
ps->GetCaret(getter_AddRefs(caretP));
// We should return caret position if it is possible. Because this event
// dispatcher always expects to be returned the correct caret position.

View File

@ -7211,7 +7211,9 @@ ApplyRenderingChangeToTree(nsPresContext* aPresContext,
nsChangeHint aChange)
{
nsIPresShell *shell = aPresContext->PresShell();
if (shell->IsPaintingSuppressed()) {
PRBool isPaintingSuppressed = PR_FALSE;
shell->IsPaintingSuppressed(&isPaintingSuppressed);
if (isPaintingSuppressed) {
// Don't allow synchronous rendering changes when painting is turned off.
aChange = NS_SubtractHint(aChange, nsChangeHint_RepaintFrame);
if (!aChange) {
@ -10729,7 +10731,9 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame)
// XXXbz how exactly would we get here while isReflowing anyway? Should this
// whole test be ifdef DEBUG?
if (mPresShell->IsReflowLocked()) {
PRBool isReflowing;
mPresShell->IsReflowLocked(&isReflowing);
if(isReflowing) {
// don't ReframeContainingBlock, this will result in a crash
// if we remove a tree that's in reflow - see bug 121368 for testcase
NS_ERROR("Atemptted to nsCSSFrameConstructor::ReframeContainingBlock during a Reflow!!!");

View File

@ -1005,7 +1005,9 @@ void nsCaret::DrawCaret(PRBool aInvalidate)
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
NS_ENSURE_TRUE(presShell, /**/);
{
if (presShell->IsPaintingSuppressed())
PRBool isPaintingSuppressed;
presShell->IsPaintingSuppressed(&isPaintingSuppressed);
if (isPaintingSuppressed)
{
if (!mDrawn)
mPendingDraw = PR_TRUE;

View File

@ -82,7 +82,9 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
nsPresContext* pc = aReferenceFrame->PresContext();
nsIPresShell *shell = pc->PresShell();
mIsBackgroundOnly = shell->IsPaintingSuppressed();
PRBool suppressed;
shell->IsPaintingSuppressed(&suppressed);
mIsBackgroundOnly = suppressed;
if (pc->IsRenderingOnlySelection()) {
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
if (selcon) {
@ -189,7 +191,8 @@ nsDisplayListBuilder::IsMovingFrame(nsIFrame* aFrame)
nsCaret *
nsDisplayListBuilder::GetCaret() {
nsRefPtr<nsCaret> caret = CurrentPresShellState()->mPresShell->GetCaret();
nsRefPtr<nsCaret> caret;
CurrentPresShellState()->mPresShell->GetCaret(getter_AddRefs(caret));
return caret;
}
@ -208,7 +211,8 @@ nsDisplayListBuilder::EnterPresShell(nsIFrame* aReferenceFrame,
if (!mBuildCaret)
return;
nsRefPtr<nsCaret> caret = state->mPresShell->GetCaret();
nsRefPtr<nsCaret> caret;
state->mPresShell->GetCaret(getter_AddRefs(caret));
state->mCaretFrame = caret->GetCaretFrame();
if (state->mCaretFrame) {

View File

@ -127,8 +127,8 @@ typedef struct CapturingContentInfo {
} CapturingContentInfo;
#define NS_IPRESSHELL_IID \
{ 0xc8f0b83e, 0x7457, 0x4367, \
{ 0xa9, 0x82, 0xe1, 0xfa, 0x11, 0xf9, 0x60, 0xbc } }
{ 0x94c34e88, 0x2da3, 0x49d4, \
{ 0xa5, 0x35, 0x51, 0xa4, 0x16, 0x92, 0xa5, 0x79 } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -235,9 +235,9 @@ public:
nsIDocument* GetDocument() const { return mDocument; }
nsPresContext* GetPresContext() const { return mPresContext; }
nsPresContext* GetPresContext() { return mPresContext; }
nsIViewManager* GetViewManager() const { return mViewManager; }
nsIViewManager* GetViewManager() { return mViewManager; }
#ifdef _IMPL_NS_LAYOUT
nsStyleSet* StyleSet() { return mStyleSet; }
@ -428,7 +428,7 @@ public:
/**
* Recreates the frames for a node
*/
virtual NS_HIDDEN_(nsresult) RecreateFramesFor(nsIContent* aContent) = 0;
NS_IMETHOD RecreateFramesFor(nsIContent* aContent) = 0;
void PostRecreateFramesFor(nsIContent* aContent);
void RestyleForAnimation(nsIContent* aContent);
@ -438,7 +438,7 @@ public:
* @param aIsSafeToFlush PR_TRUE if it is safe, PR_FALSE otherwise.
*
*/
virtual NS_HIDDEN_(PRBool) IsSafeToFlush() const = 0;
virtual NS_HIDDEN_(PRBool) IsSafeToFlush() = 0;
/**
* Flush pending notifications of the type specified. This method
@ -455,17 +455,17 @@ public:
* Callbacks will be called even if reflow itself fails for
* some reason.
*/
virtual NS_HIDDEN_(nsresult) PostReflowCallback(nsIReflowCallback* aCallback) = 0;
virtual NS_HIDDEN_(void) CancelReflowCallback(nsIReflowCallback* aCallback) = 0;
NS_IMETHOD PostReflowCallback(nsIReflowCallback* aCallback) = 0;
NS_IMETHOD CancelReflowCallback(nsIReflowCallback* aCallback) = 0;
virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame) = 0;
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
/**
* Given a frame, create a rendering context suitable for use with
* the frame.
*/
virtual NS_HIDDEN_(nsresult) CreateRenderingContext(nsIFrame *aFrame,
nsIRenderingContext** aContext) = 0;
NS_IMETHOD CreateRenderingContext(nsIFrame *aFrame,
nsIRenderingContext** aContext) = 0;
/**
* Informs the pres shell that the document is now at the anchor with
@ -475,7 +475,7 @@ public:
* the pres shell that there is no current target, and |aScroll| must
* be false.
*/
virtual NS_HIDDEN_(nsresult) GoToAnchor(const nsAString& aAnchorName, PRBool aScroll) = 0;
NS_IMETHOD GoToAnchor(const nsAString& aAnchorName, PRBool aScroll) = 0;
/**
* Tells the presshell to scroll again to the last anchor scrolled to by
@ -485,7 +485,7 @@ public:
* scrolled to by GoToAnchor (we don't want to keep it alive if it's
* removed from the DOM), so don't call this more than once.
*/
virtual NS_HIDDEN_(nsresult) ScrollToAnchor() = 0;
NS_IMETHOD ScrollToAnchor() = 0;
/**
* Scrolls the view of the document so that the primary frame of the content
@ -516,9 +516,9 @@ public:
* the frame the minimum amount necessary in order for the entire
* frame to be visible horizontally (if possible)
*/
virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent) = 0;
NS_IMETHOD ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent) = 0;
enum {
SCROLL_FIRST_ANCESTOR_ONLY = 0x01,
@ -568,31 +568,31 @@ public:
* Suppress notification of the frame manager that frames are
* being destroyed.
*/
virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(PRBool aIgnore) = 0;
NS_IMETHOD SetIgnoreFrameDestruction(PRBool aIgnore) = 0;
/**
* Notification sent by a frame informing the pres shell that it is about to
* be destroyed.
* This allows any outstanding references to the frame to be cleaned up
*/
virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
NS_IMETHOD NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
/**
* Get link location.
*/
virtual NS_HIDDEN_(nsresult) GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
/**
* Get the caret, if it exists. AddRefs it.
*/
virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret() = 0;
NS_IMETHOD GetCaret(nsCaret **aOutCaret) = 0;
/**
* Invalidate the caret's current position if it's outside of its frame's
* boundaries. This function is useful if you're batching selection
* notifications and might remove the caret's frame out from under it.
*/
virtual NS_HIDDEN_(void) MaybeInvalidateCaretPosition() = 0;
NS_IMETHOD_(void) MaybeInvalidateCaretPosition() = 0;
/**
* Set the current caret to a new caret. To undo this, call RestoreCaret.
@ -652,41 +652,41 @@ public:
/**
* Gets the current target event frame from the PresShell
*/
virtual NS_HIDDEN_(nsIFrame*) GetEventTargetFrame() = 0;
NS_IMETHOD GetEventTargetFrame(nsIFrame** aFrame) = 0;
/**
* Gets the current target event frame from the PresShell
*/
virtual NS_HIDDEN_(already_AddRefed<nsIContent>) GetEventTargetContent(nsEvent* aEvent) = 0;
NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) = 0;
/**
* Get and set the history state for the current document
*/
virtual NS_HIDDEN_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage = PR_FALSE) = 0;
NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage = PR_FALSE) = 0;
/**
* Determine if reflow is currently locked
* @param aIsReflowLocked returns PR_TRUE if reflow is locked, PR_FALSE otherwise
*/
virtual NS_HIDDEN_(PRBool) IsReflowLocked() const = 0;
NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0;
/**
* Called to find out if painting is suppressed for this presshell. If it is suppressd,
* we don't allow the painting of any layer but the background, and we don't
* recur into our children.
*/
virtual NS_HIDDEN_(PRBool) IsPaintingSuppressed() const = 0;
NS_IMETHOD IsPaintingSuppressed(PRBool* aResult)=0;
/**
* Unsuppress painting.
*/
virtual NS_HIDDEN_(void) UnsuppressPainting() = 0;
NS_IMETHOD UnsuppressPainting() = 0;
/**
* Called to disable nsITheme support in a specific presshell.
*/
virtual NS_HIDDEN_(void) DisableThemeSupport() = 0;
NS_IMETHOD DisableThemeSupport() = 0;
/**
* Indicates whether theme support is enabled.

View File

@ -1846,7 +1846,9 @@ nsPresContext::GetUserFontSetInternal()
#ifdef DEBUG
{
PRBool inReflow;
NS_ASSERTION(!userFontSetGottenBefore || !mShell->IsReflowLocked(),
NS_ASSERTION(!userFontSetGottenBefore ||
(NS_SUCCEEDED(mShell->IsReflowLocked(&inReflow)) &&
!inReflow),
"FlushUserFontSet should have been called first");
}
#endif

View File

@ -702,29 +702,29 @@ public:
nsFrameState aBitToAdd);
virtual NS_HIDDEN_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame);
virtual NS_HIDDEN_(void) CancelAllPendingReflows();
virtual NS_HIDDEN_(PRBool) IsSafeToFlush() const;
virtual NS_HIDDEN_(PRBool) IsSafeToFlush();
virtual NS_HIDDEN_(void) FlushPendingNotifications(mozFlushType aType);
/**
* Recreates the frames for a node
*/
virtual NS_HIDDEN_(nsresult) RecreateFramesFor(nsIContent* aContent);
NS_IMETHOD RecreateFramesFor(nsIContent* aContent);
/**
* Post a callback that should be handled after reflow has finished.
*/
virtual NS_HIDDEN_(nsresult) PostReflowCallback(nsIReflowCallback* aCallback);
virtual NS_HIDDEN_(void) CancelReflowCallback(nsIReflowCallback* aCallback);
NS_IMETHOD PostReflowCallback(nsIReflowCallback* aCallback);
NS_IMETHOD CancelReflowCallback(nsIReflowCallback* aCallback);
virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame);
virtual NS_HIDDEN_(nsresult) CreateRenderingContext(nsIFrame *aFrame,
nsIRenderingContext** aContext);
virtual NS_HIDDEN_(nsresult) GoToAnchor(const nsAString& aAnchorName, PRBool aScroll);
virtual NS_HIDDEN_(nsresult) ScrollToAnchor();
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame);
NS_IMETHOD CreateRenderingContext(nsIFrame *aFrame,
nsIRenderingContext** aContext);
NS_IMETHOD GoToAnchor(const nsAString& aAnchorName, PRBool aScroll);
NS_IMETHOD ScrollToAnchor();
virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent);
NS_IMETHOD ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent);
virtual PRBool ScrollFrameRectIntoView(nsIFrame* aFrame,
const nsRect& aRect,
PRIntn aVPercent,
@ -734,17 +734,17 @@ public:
const nsRect &aRect,
nscoord aMinTwips);
virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(PRBool aIgnore);
virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame);
NS_IMETHOD SetIgnoreFrameDestruction(PRBool aIgnore);
NS_IMETHOD NotifyDestroyingFrame(nsIFrame* aFrame);
virtual NS_HIDDEN_(nsresult) GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString);
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString);
virtual NS_HIDDEN_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage);
NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage);
virtual NS_HIDDEN_(PRBool) IsPaintingSuppressed() const;
virtual NS_HIDDEN_(void) UnsuppressPainting();
virtual NS_HIDDEN_(void) DisableThemeSupport();
NS_IMETHOD IsPaintingSuppressed(PRBool* aResult);
NS_IMETHOD UnsuppressPainting();
NS_IMETHOD DisableThemeSupport();
virtual PRBool IsThemeSupportEnabled();
virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets);
@ -756,10 +756,10 @@ public:
NS_IMETHOD HandleEventWithTarget(nsEvent* aEvent, nsIFrame* aFrame,
nsIContent* aContent,
nsEventStatus* aStatus);
virtual NS_HIDDEN_(nsIFrame*) GetEventTargetFrame();
virtual NS_HIDDEN_(already_AddRefed<nsIContent>) GetEventTargetContent(nsEvent* aEvent);
NS_IMETHOD GetEventTargetFrame(nsIFrame** aFrame);
NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent);
virtual NS_HIDDEN_(PRBool) IsReflowLocked() const;
NS_IMETHOD IsReflowLocked(PRBool* aIsLocked);
virtual nsresult ReconstructFrames(void);
virtual void Freeze();
@ -811,8 +811,8 @@ public:
NS_IMETHOD_(void) ClearMouseCapture(nsIView* aView);
// caret handling
virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret();
virtual NS_HIDDEN_(void) MaybeInvalidateCaretPosition();
NS_IMETHOD GetCaret(nsCaret **aOutCaret);
NS_IMETHOD_(void) MaybeInvalidateCaretPosition();
NS_IMETHOD SetCaretEnabled(PRBool aInEnable);
NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly);
NS_IMETHOD GetCaretEnabled(PRBool *aOutEnabled);
@ -2729,13 +2729,14 @@ PresShell::FireResizeEvent()
}
}
void
NS_IMETHODIMP
PresShell::SetIgnoreFrameDestruction(PRBool aIgnore)
{
mIgnoreFrameDestruction = aIgnore;
return NS_OK;
}
void
NS_IMETHODIMP
PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
{
if (!mIgnoreFrameDestruction) {
@ -2760,13 +2761,13 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
mCurrentEventContent = aFrame->GetContent();
mCurrentEventFrame = nsnull;
}
#ifdef NS_DEBUG
if (aFrame == mDrawEventTargetFrame) {
mDrawEventTargetFrame = nsnull;
}
#endif
for (unsigned int i=0; i < mCurrentEventFrameStack.Length(); i++) {
if (aFrame == mCurrentEventFrameStack.ElementAt(i)) {
//One of our stack frames was deleted. Get its content so that when we
@ -2776,17 +2777,21 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
mCurrentEventFrameStack[i] = nsnull;
}
}
mFramesToDirty.RemoveEntry(aFrame);
}
return NS_OK;
}
// note that this can return a null caret, but NS_OK
already_AddRefed<nsCaret> PresShell::GetCaret()
NS_IMETHODIMP PresShell::GetCaret(nsCaret **outCaret)
{
nsCaret* caret = mCaret;
NS_IF_ADDREF(caret);
return caret;
NS_ENSURE_ARG_POINTER(outCaret);
*outCaret = mCaret;
NS_IF_ADDREF(*outCaret);
return NS_OK;
}
NS_IMETHODIMP_(void) PresShell::MaybeInvalidateCaretPosition()
@ -3464,7 +3469,7 @@ void nsIPresShell::InvalidateAccessibleSubtree(nsIContent *aContent)
}
#endif
nsresult
NS_IMETHODIMP
PresShell::RecreateFramesFor(nsIContent* aContent)
{
NS_ENSURE_TRUE(mPresContext, NS_ERROR_FAILURE);
@ -3515,7 +3520,7 @@ nsIPresShell::RestyleForAnimation(nsIContent* aContent)
NS_STYLE_HINT_NONE);
}
void
NS_IMETHODIMP
PresShell::ClearFrameRefs(nsIFrame* aFrame)
{
mPresContext->EventStateManager()->ClearFrameRefs(aFrame);
@ -3529,9 +3534,11 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
}
weakFrame = prev;
}
return NS_OK;
}
nsresult
NS_IMETHODIMP
PresShell::CreateRenderingContext(nsIFrame *aFrame,
nsIRenderingContext** aResult)
{
@ -3577,7 +3584,7 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
return rv;
}
nsresult
NS_IMETHODIMP
PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
{
if (!mDocument) {
@ -3837,7 +3844,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
return rv;
}
nsresult
NS_IMETHODIMP
PresShell::ScrollToAnchor()
{
if (!mLastAnchorScrolledTo)
@ -4029,7 +4036,7 @@ static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame,
aScrollFrame->ScrollTo(scrollPt, nsIScrollableFrame::INSTANT);
}
nsresult
NS_IMETHODIMP
PresShell::ScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent)
@ -4200,7 +4207,7 @@ PresShell::GetRectVisibility(nsIFrame* aFrame,
}
// GetLinkLocation: copy link location to clipboard
nsresult PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString)
NS_IMETHODIMP PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString)
{
#ifdef DEBUG_dr
printf("dr :: PresShell::GetLinkLocation\n");
@ -4336,7 +4343,7 @@ PresShell::ClearMouseCapture(nsIView* aView)
gCaptureInfo.mAllowed = PR_FALSE;
}
nsresult
NS_IMETHODIMP
PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPage)
{
nsresult rv = NS_OK;
@ -4394,10 +4401,11 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa
return NS_OK;
}
PRBool
PresShell::IsPaintingSuppressed() const
NS_IMETHODIMP
PresShell::IsPaintingSuppressed(PRBool* aResult)
{
return mPaintingSuppressed;
*aResult = mPaintingSuppressed;
return NS_OK;
}
void
@ -4434,7 +4442,7 @@ PresShell::UnsuppressAndInvalidate()
mViewManager->SynthesizeMouseMove(PR_FALSE);
}
void
NS_IMETHODIMP
PresShell::UnsuppressPainting()
{
if (mPaintSuppressionTimer) {
@ -4443,7 +4451,7 @@ PresShell::UnsuppressPainting()
}
if (mIsDocumentGone || !mPaintingSuppressed)
return;
return NS_OK;
// If we have reflows pending, just wait until we process
// the reflows and get all the frames where we want them
@ -4453,13 +4461,15 @@ PresShell::UnsuppressPainting()
mShouldUnsuppressPainting = PR_TRUE;
else
UnsuppressAndInvalidate();
return NS_OK;
}
void
NS_IMETHODIMP
PresShell::DisableThemeSupport()
{
// Doesn't have to be dynamic. Just set the bool.
mIsThemeSupportDisabled = PR_TRUE;
return NS_OK;
}
PRBool
@ -4469,7 +4479,7 @@ PresShell::IsThemeSupportEnabled()
}
// Post a request to handle an arbitrary callback after reflow has finished.
nsresult
NS_IMETHODIMP
PresShell::PostReflowCallback(nsIReflowCallback* aCallback)
{
void* result = AllocateMisc(sizeof(nsCallbackEventRequest));
@ -4491,7 +4501,7 @@ PresShell::PostReflowCallback(nsIReflowCallback* aCallback)
return NS_OK;
}
void
NS_IMETHODIMP
PresShell::CancelReflowCallback(nsIReflowCallback* aCallback)
{
nsCallbackEventRequest* before = nsnull;
@ -4522,6 +4532,8 @@ PresShell::CancelReflowCallback(nsIReflowCallback* aCallback)
node = node->next;
}
}
return NS_OK;
}
void
@ -4568,7 +4580,7 @@ PresShell::HandlePostedReflowCallbacks(PRBool aInterruptible)
}
PRBool
PresShell::IsSafeToFlush() const
PresShell::IsSafeToFlush()
{
// Not safe if we are reflowing or in the middle of frame construction
PRBool isSafeToFlush = !mIsReflowing &&
@ -4696,10 +4708,11 @@ PresShell::FlushPendingNotifications(mozFlushType aType)
}
}
PRBool
PresShell::IsReflowLocked() const
NS_IMETHODIMP
PresShell::IsReflowLocked(PRBool* aIsReflowLocked)
{
return mIsReflowing;
*aIsReflowLocked = mIsReflowing;
return NS_OK;
}
void
@ -5752,29 +5765,28 @@ PresShell::GetCurrentEventFrame()
return mCurrentEventFrame;
}
nsIFrame*
PresShell::GetEventTargetFrame()
NS_IMETHODIMP
PresShell::GetEventTargetFrame(nsIFrame** aFrame)
{
return GetCurrentEventFrame();
*aFrame = GetCurrentEventFrame();
return NS_OK;
}
already_AddRefed<nsIContent>
PresShell::GetEventTargetContent(nsEvent* aEvent)
NS_IMETHODIMP
PresShell::GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent)
{
nsIContent* content = nsnull;
if (mCurrentEventContent) {
content = mCurrentEventContent;
NS_IF_ADDREF(content);
*aContent = mCurrentEventContent;
NS_IF_ADDREF(*aContent);
} else {
nsIFrame* currentEventFrame = GetCurrentEventFrame();
if (currentEventFrame) {
currentEventFrame->GetContentForEvent(mPresContext, aEvent, &content);
currentEventFrame->GetContentForEvent(mPresContext, aEvent, aContent);
} else {
content = nsnull;
*aContent = nsnull;
}
}
return content;
return NS_OK;
}
void
@ -6623,7 +6635,9 @@ PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTarge
nsresult rv;
// check caret visibility
nsRefPtr<nsCaret> caret = GetCaret();
nsRefPtr<nsCaret> caret;
rv = GetCaret(getter_AddRefs(caret));
NS_ENSURE_SUCCESS(rv, PR_FALSE);
NS_ENSURE_TRUE(caret, PR_FALSE);
PRBool caretVisible = PR_FALSE;

View File

@ -689,8 +689,9 @@ nsTextInputSelectionImpl::SetCaretReadOnly(PRBool aReadOnly)
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShellWeak, &result);
if (shell)
{
nsRefPtr<nsCaret> caret = shell->GetCaret();
if (caret) {
nsRefPtr<nsCaret> caret;
if (NS_SUCCEEDED(shell->GetCaret(getter_AddRefs(caret))))
{
nsISelection* domSel = mFrameSelection->
GetSelection(nsISelectionController::SELECTION_NORMAL);
if (domSel)
@ -715,8 +716,9 @@ nsTextInputSelectionImpl::GetCaretVisible(PRBool *_retval)
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShellWeak, &result);
if (shell)
{
nsRefPtr<nsCaret> caret = shell->GetCaret();
if (caret) {
nsRefPtr<nsCaret> caret;
if (NS_SUCCEEDED(shell->GetCaret(getter_AddRefs(caret))))
{
nsISelection* domSel = mFrameSelection->
GetSelection(nsISelectionController::SELECTION_NORMAL);
if (domSel)
@ -734,8 +736,9 @@ nsTextInputSelectionImpl::SetCaretVisibilityDuringSelection(PRBool aVisibility)
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShellWeak, &result);
if (shell)
{
nsRefPtr<nsCaret> caret = shell->GetCaret();
if (caret) {
nsRefPtr<nsCaret> caret;
if (NS_SUCCEEDED(shell->GetCaret(getter_AddRefs(caret))))
{
nsISelection* domSel = mFrameSelection->
GetSelection(nsISelectionController::SELECTION_NORMAL);
if (domSel)
@ -1646,9 +1649,9 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
getter_AddRefs(domSelection))) &&
domSelection) {
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(domSelection));
nsRefPtr<nsCaret> caret = shell->GetCaret();
nsRefPtr<nsCaret> caret;
nsCOMPtr<nsISelectionListener> listener;
if (caret) {
if (NS_SUCCEEDED(shell->GetCaret(getter_AddRefs(caret))) && caret) {
listener = do_QueryInterface(caret);
if (listener) {
selPriv->AddSelectionListener(listener);
@ -1880,7 +1883,8 @@ void nsTextControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
if (!ourSel) return;
nsIPresShell* presShell = PresContext()->GetPresShell();
nsRefPtr<nsCaret> caret = presShell->GetCaret();
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (!caret) return;
caret->SetCaretDOMSelection(ourSel);

View File

@ -3681,10 +3681,12 @@ nsIFrame::InvalidateWithFlags(const nsRect& aDamageRect, PRUint32 aFlags)
// painting is suppressed.
nsIPresShell *shell = PresContext()->GetPresShell();
if (shell) {
if (shell->IsPaintingSuppressed())
PRBool suppressed = PR_FALSE;
shell->IsPaintingSuppressed(&suppressed);
if (suppressed)
return;
}
InvalidateInternal(aDamageRect, 0, 0, nsnull, aFlags);
}

View File

@ -788,12 +788,15 @@ nsFrameSelection::FetchDesiredX(nscoord &aDesiredX) //the x position requested b
return NS_OK;
}
nsRefPtr<nsCaret> caret = mShell->GetCaret();
nsRefPtr<nsCaret> caret;
nsresult result = mShell->GetCaret(getter_AddRefs(caret));
if (NS_FAILED(result))
return result;
if (!caret)
return NS_ERROR_NULL_POINTER;
PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL);
nsresult result = caret->SetCaretDOMSelection(mDomSelections[index]);
result = caret->SetCaretDOMSelection(mDomSelections[index]);
if (NS_FAILED(result))
return result;
@ -2083,6 +2086,7 @@ nsFrameSelection::CommonPageMove(PRBool aForward,
// expected behavior for PageMove is to scroll AND move the caret
// and remain relative position of the caret in view. see Bug 4302.
nsresult result;
//get the frame from the scrollable view
nsIFrame* scrolledFrame = aScrollableFrame->GetScrolledFrame();
@ -2094,9 +2098,12 @@ nsFrameSelection::CommonPageMove(PRBool aForward,
nsISelection* domSel = GetSelection(nsISelectionController::SELECTION_NORMAL);
if (!domSel)
return;
nsRefPtr<nsCaret> caret = mShell->GetCaret();
nsRefPtr<nsCaret> caret;
result = mShell->GetCaret(getter_AddRefs(caret));
if (NS_FAILED(result))
return;
nsRect caretPos;
nsIFrame* caretFrame = caret->GetGeometry(domSel, &caretPos);
if (!caretFrame)
@ -4188,8 +4195,9 @@ nsTypedSelection::GetPrimaryFrameForFocusNode(nsIFrame **aReturnFrame, PRInt32 *
nsFrameSelection::HINT hint = mFrameSelection->GetHint();
if (aVisual) {
nsRefPtr<nsCaret> caret = presShell->GetCaret();
if (!caret)
nsRefPtr<nsCaret> caret;
nsresult result = presShell->GetCaret(getter_AddRefs(caret));
if (NS_FAILED(result) || !caret)
return NS_ERROR_FAILURE;
PRUint8 caretBidiLevel = mFrameSelection->GetCaretBidiLevel();
@ -5550,7 +5558,8 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion,
result = GetPresShell(getter_AddRefs(presShell));
if (NS_FAILED(result) || !presShell)
return result;
nsRefPtr<nsCaret> caret = presShell->GetCaret();
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (caret)
{
// Now that text frame character offsets are always valid (though not

View File

@ -400,7 +400,9 @@ nsSVGForeignObjectFrame::NotifySVGChanged(PRUint32 aFlags)
// PresShell and prevent it from reflowing us properly in future. Besides
// that, nsSVGOuterSVGFrame::DidReflow will take care of reflowing us
// synchronously, so there's no need.
if (!PresContext()->PresShell()->IsReflowLocked()) {
PRBool reflowing;
PresContext()->PresShell()->IsReflowLocked(&reflowing);
if (!reflowing) {
UpdateGraphic(); // update mRect before requesting reflow
RequestReflow(nsIPresShell::eResize);
}

View File

@ -552,7 +552,8 @@ CheckCaretDrawingState() {
if (!presShell)
return;
nsRefPtr<nsCaret> caret = presShell->GetCaret();
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (!caret)
return;
caret->CheckCaretDrawingState();

View File

@ -370,7 +370,9 @@ void
nsTreeBodyFrame::EnsureView()
{
if (!mView) {
if (PresContext()->PresShell()->IsReflowLocked()) {
PRBool isInReflow;
PresContext()->PresShell()->IsReflowLocked(&isInReflow);
if (isInReflow) {
if (!mReflowCallbackPosted) {
mReflowCallbackPosted = PR_TRUE;
PresContext()->PresShell()->PostReflowCallback(this);
@ -530,7 +532,9 @@ nsTreeBodyFrame::SetView(nsITreeView * aView)
NS_ENSURE_STATE(weakFrame.IsAlive());
mView->GetRowCount(&mRowCount);
if (!PresContext()->PresShell()->IsReflowLocked()) {
PRBool isInReflow;
PresContext()->PresShell()->IsReflowLocked(&isInReflow);
if (!isInReflow) {
// The scrollbar will need to be updated.
FullScrollbarsUpdate(PR_FALSE);
} else if (!mReflowCallbackPosted) {