Change FlushPendingNotifications to have more granularity and update callers to

only flush the things they really need flushed.  Bug 144072, r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2004-05-27 22:08:42 +00:00
Родитель 37985e9e8e
Коммит a7bff6ad5b
62 изменённых файлов: 392 добавлений и 202 удалений

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

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Boris Zbarsky.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozFlushType_h___
#define mozFlushType_h___
/**
* This is the enum used by nsIDocument::FlushPendingNotifications to
* decide what to flush.
*/
enum mozFlushType {
Flush_Content = 0x1, /* flush the content model construction */
Flush_SinkNotifications = 0x2, /* flush the frame model construction */
Flush_StyleReresolves = 0x4, /* flush style reresolution */
Flush_OnlyReflow = 0x8, /* flush reflows */
Flush_OnlyPaint = 0x10, /* flush painting */
Flush_Frames = (Flush_Content | Flush_SinkNotifications),
Flush_ContentAndNotify = (Flush_Content | Flush_SinkNotifications),
Flush_Style = (Flush_Content | Flush_SinkNotifications |
Flush_StyleReresolves),
Flush_Layout = (Flush_Content | Flush_SinkNotifications |
Flush_StyleReresolves | Flush_OnlyReflow),
Flush_Display = (Flush_Content | Flush_SinkNotifications |
Flush_StyleReresolves | Flush_OnlyReflow |
Flush_OnlyPaint)
};
#endif /* mozFlushType_h___ */

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

@ -52,6 +52,7 @@
#include "nsILoadGroup.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "mozFlushType.h"
class nsIAtom;
class nsIContent;
@ -510,8 +511,11 @@ public:
PRUint32 aFlags,
nsEventStatus* aEventStatus) = 0;
virtual void FlushPendingNotifications(PRBool aFlushReflows=PR_TRUE,
PRBool aUpdateViews=PR_FALSE) = 0;
/**
* Flush notifications for this document and its parent documents
* (since those may affect the layout of this one).
*/
virtual void FlushPendingNotifications(mozFlushType aType) = 0;
PRInt32 GetAndIncrementContentID()
{

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

@ -105,7 +105,7 @@ public:
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode)
{ return NS_OK; }
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }

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

@ -429,8 +429,8 @@ nsContentList::Item(PRUint32 aIndex, PRBool aDoFlush)
CheckDocumentExistence();
if (mDocument && aDoFlush) {
// Flush pending content changes Bug 4891
mDocument->FlushPendingNotifications(PR_FALSE);
// Flush pending content changes Bug 4891.
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
}
if (mState != LIST_UP_TO_DATE)
@ -963,7 +963,8 @@ void
nsContentList::BringSelfUpToDate(PRBool aDoFlush)
{
if (mDocument && aDoFlush) {
mDocument->FlushPendingNotifications(PR_FALSE); // Flush pending content changes Bug 4891
// Flush pending content changes Bug 4891.
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
}
if (mState != LIST_UP_TO_DATE)

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

@ -863,7 +863,7 @@ nsContentSink::ScrollToRef(PRBool aReallyScroll)
if (shell) {
// Scroll to the anchor
if (aReallyScroll) {
shell->FlushPendingNotifications(PR_FALSE);
shell->FlushPendingNotifications(Flush_Layout);
}
// Check an empty string which might be caused by the UTF-8 conversion

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

@ -3906,10 +3906,11 @@ nsDocument::CreateEventGroup(nsIDOMEventGroup **aInstancePtrResult)
}
void
nsDocument::FlushPendingNotifications(PRBool aFlushReflows,
PRBool aUpdateViews)
nsDocument::FlushPendingNotifications(mozFlushType aType)
{
if (!aFlushReflows || !mScriptGlobalObject) {
if (aType == (aType & (Flush_Content | Flush_SinkNotifications)) ||
!mScriptGlobalObject) {
// Nothing to do here
return;
}
@ -3935,8 +3936,7 @@ nsDocument::FlushPendingNotifications(PRBool aFlushReflows,
if (doc) {
// If we have a parent we must flush the parent too to ensure
// that our container is reflown if its size was changed.
doc->FlushPendingNotifications(aFlushReflows, aUpdateViews);
doc->FlushPendingNotifications(aType);
}
}
}
@ -3948,7 +3948,7 @@ nsDocument::FlushPendingNotifications(PRBool aFlushReflows,
NS_STATIC_CAST(nsIPresShell*, mPresShells[i]);
if (shell) {
shell->FlushPendingNotifications(aUpdateViews);
shell->FlushPendingNotifications(aType);
}
}
}

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

@ -397,8 +397,7 @@ public:
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
virtual void FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE,
PRBool aUpdateViews = PR_FALSE);
virtual void FlushPendingNotifications(mozFlushType aType);
virtual void AddReference(void *aKey, nsISupports *aReference);
virtual already_AddRefed<nsISupports> RemoveReference(void *aKey);
virtual nsIScriptEventManager* GetScriptEventManager();

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

@ -656,7 +656,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
// Note that we are flushing before we add mPresShell as an observer
// to avoid bogus notifications.
mDocument->FlushPendingNotifications(PR_FALSE);
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
}
mPresShell->BeginObservingDocument();
@ -935,9 +935,7 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus)
static PRBool forcePaint
= PR_GetEnv("MOZ_FORCE_PAINT_AFTER_ONLOAD") != nsnull;
if (forcePaint) {
if (mPresShell) {
mPresShell->FlushPendingNotifications(PR_TRUE);
}
mDocument->FlushPendingNotifications(Flush_Display);
nsIURI *uri = mDocument->GetDocumentURI();
nsCAutoString spec;
if (uri) {

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

@ -101,7 +101,7 @@ public:
NS_IMETHOD AddComment(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }

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

@ -503,6 +503,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
GenerateMouseEnterExit(aPresContext, (nsGUIEvent*)aEvent);
// Flush reflows and invalidates to eliminate flicker when both a reflow
// and visual change occur in an event callback. See bug #36849
// XXXbz eeeew. Why not fix viewmanager to flush reflows before painting??
FlushPendingEvents(aPresContext);
break;
case NS_MOUSE_EXIT:
@ -4641,7 +4642,8 @@ nsEventStateManager::FlushPendingEvents(nsIPresContext* aPresContext)
NS_PRECONDITION(nsnull != aPresContext, "nsnull ptr");
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
shell->FlushPendingNotifications(PR_FALSE);
// This is not flushing _Display because of the mess that is bug 36849
shell->FlushPendingNotifications(Flush_Layout);
nsIViewManager* viewManager = shell->GetViewManager();
if (viewManager) {
viewManager->FlushPendingInvalidates();

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

@ -582,7 +582,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
}
// Flush all pending notifications so that our frames are uptodate
mDocument->FlushPendingNotifications();
mDocument->FlushPendingNotifications(Flush_Layout);
// Get the Frame for our content
nsIFrame* frame = nsnull;
@ -933,7 +933,7 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
return;
}
mDocument->FlushPendingNotifications(PR_TRUE, PR_FALSE);
mDocument->FlushPendingNotifications(Flush_Layout);
// Get the presentation shell
nsIPresShell *presShell = mDocument->GetShellAt(0);
@ -1239,7 +1239,7 @@ nsGenericHTMLElement::ScrollIntoView(PRBool aTop)
}
// Now flush to make sure things are up to date
presShell->FlushPendingNotifications(PR_FALSE);
mDocument->FlushPendingNotifications(Flush_Layout);
// Get the primary frame for this element
nsIFrame *frame = nsnull;
@ -2176,7 +2176,7 @@ nsGenericHTMLElement::GetPrimaryFrameFor(nsIContent* aContent,
if (aFlushContent) {
// Cause a flush of content, so we get up-to-date frame
// information
aDocument->FlushPendingNotifications(PR_FALSE);
aDocument->FlushPendingNotifications(Flush_Frames);
}
// Get presentation shell 0

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

@ -221,7 +221,7 @@ nsHTMLAnchorElement::SetFocus(nsIPresContext* aPresContext)
// Make sure the presentation is up-to-date
if (mDocument) {
mDocument->FlushPendingNotifications();
mDocument->FlushPendingNotifications(Flush_Layout);
}
nsIPresShell *presShell = aPresContext->GetPresShell();

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

@ -202,7 +202,7 @@ nsHTMLAreaElement::SetFocus(nsIPresContext* aPresContext)
// Make sure the presentation is up-to-date
if (mDocument) {
mDocument->FlushPendingNotifications();
mDocument->FlushPendingNotifications(Flush_Layout);
}
nsIPresShell *presShell = aPresContext->GetPresShell();

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

@ -373,20 +373,12 @@ nsHTMLBodyElement::GetBgColor(nsAString& aBgColor)
// If we don't have an attribute, find the actual color used for
// (generally from the user agent style sheet) for compatibility
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
// XXX This should just use nsGenericHTMLElement::GetPrimaryFrame()
if (mDocument) {
// Make sure the presentation is up-to-date
mDocument->FlushPendingNotifications();
}
nsCOMPtr<nsIPresContext> context;
GetPresContext(this, getter_AddRefs(context));
if (context) {
nsIFrame* frame;
rv = context->PresShell()->GetPrimaryFrameFor(this, &frame);
NS_ENSURE_SUCCESS(rv, rv);
// Make sure the style is up-to-date, since we need it
mDocument->FlushPendingNotifications(Flush_Style);
nsIFrame* frame = GetPrimaryFrameFor(this, mDocument, PR_FALSE);
if (frame) {
bgcolor = frame->GetStyleBackground()->mBackgroundColor;
NS_RGBToHex(bgcolor, aBgColor);

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

@ -765,7 +765,7 @@ nsHTMLFormElement::DoSubmitOrReset(nsIPresContext* aPresContext,
// Make sure the presentation is up-to-date
if (mDocument) {
mDocument->FlushPendingNotifications();
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
}
// JBK Don't get form frames anymore - bug 34297

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

@ -285,8 +285,8 @@ nsHTMLImageElement::GetXY()
return point;
}
// Flush all pending notifications so that our frames are uptodate
mDocument->FlushPendingNotifications();
// Flush all pending notifications so that our frames are laid out correctly
mDocument->FlushPendingNotifications(Flush_Layout);
// Get the Frame for this image
nsIFrame* frame = nsnull;
@ -339,7 +339,7 @@ nsHTMLImageElement::GetWidthHeight()
// Flush all pending notifications so that our frames are up to date.
// If we're not in a document, we don't have a frame anyway, so we
// don't care.
mDocument->FlushPendingNotifications();
mDocument->FlushPendingNotifications(Flush_Layout);
}
nsIImageFrame* imageFrame;

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

@ -230,7 +230,7 @@ public:
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications();
NS_IMETHOD_(void) FlushContent(PRBool aNotify);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
// nsIHTMLContentSink
@ -727,7 +727,7 @@ public:
return FlushText(aDidFlush, PR_TRUE);
}
nsresult FlushTags(PRBool aNotify = PR_TRUE);
nsresult FlushTags(PRBool aNotify);
PRBool IsCurrentContainer(nsHTMLTag mType);
PRBool IsAncestorContainer(nsHTMLTag mType);
@ -4419,22 +4419,14 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode)
return rv;
}
NS_IMETHODIMP
HTMLContentSink::FlushPendingNotifications()
void
HTMLContentSink::FlushContent(PRBool aNotify)
{
nsresult result = NS_OK;
// Only flush tags if we're not doing the notification ourselves
// (since we aren't reentrant) and if we're in a script (since we
// only care to flush if this is done via script).
//
// Bug 4891: Also flush outside of <script> tags - if script is
// executing after the page has finished loading, and a
// document.write occurs, we might need this flush.
// (since we aren't reentrant)
if (mCurrentContext && !mInNotification) {
result = mCurrentContext->FlushTags();
mCurrentContext->FlushTags(aNotify);
}
return result;
}
NS_IMETHODIMP

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

@ -1299,38 +1299,35 @@ nsHTMLDocument::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID,
}
void
nsHTMLDocument::FlushPendingNotifications(PRBool aFlushReflows,
PRBool aUpdateViews)
nsHTMLDocument::FlushPendingNotifications(mozFlushType aType)
{
// Determine if it is safe to flush the sink
// by determining if it safe to flush all the presshells.
PRBool isSafeToFlush = PR_TRUE;
if (aFlushReflows) {
PRInt32 i = 0, n = mPresShells.Count();
while ((i < n) && (isSafeToFlush)) {
nsCOMPtr<nsIPresShell> shell =
NS_STATIC_CAST(nsIPresShell*, mPresShells[i]);
if (aType & Flush_Content) {
// Determine if it is safe to flush the sink
// by determining if it safe to flush all the presshells.
PRBool isSafeToFlush = PR_TRUE;
if (aType & Flush_SinkNotifications) {
PRInt32 i = 0, n = mPresShells.Count();
while ((i < n) && (isSafeToFlush)) {
nsCOMPtr<nsIPresShell> shell =
NS_STATIC_CAST(nsIPresShell*, mPresShells[i]);
if (shell) {
shell->IsSafeToFlush(isSafeToFlush);
if (shell) {
shell->IsSafeToFlush(isSafeToFlush);
}
++i;
}
}
if (isSafeToFlush && mParser) {
nsCOMPtr<nsIContentSink> sink = mParser->GetContentSink();
if (sink) {
PRBool notify = ((aType & Flush_SinkNotifications) != 0);
sink->FlushContent(notify);
}
++i;
}
}
if (isSafeToFlush && mParser) {
nsCOMPtr<nsIContentSink> sink;
// XXX Ack! Parser doesn't addref sink before passing it back
sink = mParser->GetContentSink();
if (sink) {
nsresult rv = sink->FlushPendingNotifications();
if (NS_FAILED(rv))
return;
}
}
nsDocument::FlushPendingNotifications(aFlushReflows, aUpdateViews);
nsDocument::FlushPendingNotifications(aType);
}
PRBool
@ -2210,7 +2207,7 @@ nsHTMLDocument::Close()
// handler of the frameset fires before the frames get reflowed
// and loaded. That is the long explanation for why we need this
// one line of code here!
FlushPendingNotifications();
FlushPendingNotifications(Flush_Layout);
// Remove the wyciwyg channel request from the document load group
// that we added in OpenCommon(). If all other requests between
@ -2543,7 +2540,7 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
{
*aWidth = *aHeight = 0;
FlushPendingNotifications();
FlushPendingNotifications(Flush_Layout);
// Find the <body> element: this is what we'll want to use for the
// document's width and height values.
@ -3061,6 +3058,10 @@ nsHTMLDocument::UpdateNameTableEntry(const nsAString& aName,
return NS_OK;
}
// NOTE: this indexof is absolutely needed, since we don't flush
// content notifications when we do document.foo resolution. So
// aContent may be in our list already and just now getting notified
// for!
if (list->IndexOf(aContent, PR_FALSE) < 0) {
list->AppendElement(aContent);
}
@ -3304,7 +3305,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
// table changes when we flush.
PRUint32 generation = mIdAndNameHashTable.generation;
FlushPendingNotifications(PR_FALSE);
FlushPendingNotifications(Flush_Content);
if (generation != mIdAndNameHashTable.generation) {
// Table changed, so the entry pointer is no longer valid; look up the

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

@ -136,8 +136,7 @@ public:
PRInt32 aNameSpaceID,
nsIAtom* aAttribute);
virtual void FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE,
PRBool aUpdateViews = PR_FALSE);
virtual void FlushPendingNotifications(mozFlushType aType);
virtual PRBool IsCaseSensitive();

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

@ -80,7 +80,7 @@ public:
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
// nsIHTMLContentSink

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

@ -106,6 +106,8 @@ public:
* Called to get a better count of forms than document.forms can provide
* without calling FlushPendingNotifications (bug 138892).
*/
// XXXbz is this still needed now that we can flush just content,
// not the rest?
virtual PRInt32 GetNumFormsSynchronous() = 0;
virtual PRBool IsWriting() = 0;

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

@ -271,6 +271,11 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName,
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsIDocument* document = mContent->GetDocument();
if (document) {
document->FlushPendingNotifications(Flush_Style);
}
nsIFrame *frame = nsnull;
presShell->GetPrimaryFrameFor(mContent, &frame);
@ -2873,7 +2878,7 @@ nsComputedDOMStyle::FlushPendingReflows()
// Flush all pending notifications so that our frames are up to date
nsIDocument* document = mContent->GetDocument();
if (document) {
document->FlushPendingNotifications();
document->FlushPendingNotifications(Flush_Layout);
}
}

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

@ -59,6 +59,7 @@ nsCSSKeywords.h \
nsCSSPropList.h \
nsCSSProperty.h \
nsCSSProps.h \
mozFlushType.h \
nsFrameManager.h \
nsFrameManagerBase.h \
nsHTMLAtomList.h \

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

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Boris Zbarsky.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozFlushType_h___
#define mozFlushType_h___
/**
* This is the enum used by nsIDocument::FlushPendingNotifications to
* decide what to flush.
*/
enum mozFlushType {
Flush_Content = 0x1, /* flush the content model construction */
Flush_SinkNotifications = 0x2, /* flush the frame model construction */
Flush_StyleReresolves = 0x4, /* flush style reresolution */
Flush_OnlyReflow = 0x8, /* flush reflows */
Flush_OnlyPaint = 0x10, /* flush painting */
Flush_Frames = (Flush_Content | Flush_SinkNotifications),
Flush_ContentAndNotify = (Flush_Content | Flush_SinkNotifications),
Flush_Style = (Flush_Content | Flush_SinkNotifications |
Flush_StyleReresolves),
Flush_Layout = (Flush_Content | Flush_SinkNotifications |
Flush_StyleReresolves | Flush_OnlyReflow),
Flush_Display = (Flush_Content | Flush_SinkNotifications |
Flush_StyleReresolves | Flush_OnlyReflow |
Flush_OnlyPaint)
};
#endif /* mozFlushType_h___ */

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

@ -1118,7 +1118,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
}
// Flush all pending notifications so that our frames are uptodate
presShell->FlushPendingNotifications(PR_FALSE);
mDocument->FlushPendingNotifications(Flush_Layout);
nsIFrame* frame;
presShell->GetPrimaryFrameFor(this, &frame);

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

@ -251,8 +251,8 @@ nsXBLResourceLoader::NotifyBoundElements()
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (doc) {
// Flush first
doc->FlushPendingNotifications();
// Flush first to make sure we can get the frame for content
doc->FlushPendingNotifications(Flush_Frames);
// Notify
nsCOMPtr<nsIContent> parent = content->GetParent();
@ -286,7 +286,8 @@ nsXBLResourceLoader::NotifyBoundElements()
}
// Flush again
doc->FlushPendingNotifications();
// XXXbz why is this needed?
doc->FlushPendingNotifications(Flush_ContentAndNotify);
}
}
}

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

@ -384,7 +384,7 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent)
nsXBLBindingRequest* req = (nsXBLBindingRequest*)mBindingRequests.ElementAt(0);
nsIDocument* document = req->mBoundElement->GetDocument();
if (document)
document->FlushPendingNotifications();
document->FlushPendingNotifications(Flush_ContentAndNotify);
}
// Remove ourselves from the set of pending docs.
@ -429,11 +429,12 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent)
// All reqs normally have the same binding doc. Force a synchronous
// reflow on this binding doc to deal with the fact that iframes
// don't construct or load their subdocs until they get a reflow.
// XXXbz this is still needed for <xul:iframe>. We need to fix that.
if (count > 0) {
nsXBLBindingRequest* req = (nsXBLBindingRequest*)mBindingRequests.ElementAt(0);
nsIDocument* document = req->mBoundElement->GetDocument();
if (document)
document->FlushPendingNotifications();
document->FlushPendingNotifications(Flush_Layout);
}
}

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

@ -121,10 +121,10 @@ nsLoadSaveContentSink::SetParser(nsIParser* aParser)
return mBaseSink->SetParser(aParser);
}
NS_IMETHODIMP
nsLoadSaveContentSink::FlushPendingNotifications(void)
void
nsLoadSaveContentSink::FlushContent(PRBool aNotify)
{
return mBaseSink->FlushPendingNotifications();
mBaseSink->FlushContent(aNotify);
}
NS_IMETHODIMP

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

@ -74,7 +74,7 @@ public:
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications(void);
virtual void FlushContent(PRBool aNotify);
NS_IMETHOD SetDocumentCharset(nsAString& aCharset);
private:

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

@ -85,7 +85,7 @@ public:
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
// nsITransformObserver

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

@ -133,7 +133,7 @@ public:
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
// nsIXULContentSink

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

@ -1585,7 +1585,7 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth,
nsSize size;
nsIFrame* frame;
FlushPendingNotifications();
FlushPendingNotifications(Flush_Layout);
result = aShell->GetPrimaryFrameFor(mRootContent, &frame);
if (NS_SUCCEEDED(result) && frame) {
@ -2167,7 +2167,8 @@ nsXULDocument::StartLayout(void)
// This is done because iframes don't load their subdocs until
// they get reflowed. If we reflow asynchronously, our onload
// will fire too early. -- hyatt
FlushPendingNotifications();
// XXXbz this is still needed for <xul:iframe>. We need to fix that.
FlushPendingNotifications(Flush_Layout);
// Start observing the document _after_ we do the initial
// reflow. Otherwise, we'll get into an trouble trying to

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

@ -5879,7 +5879,9 @@ nsHTMLExternalObjSH::GetPluginInstance(nsIXPConnectWrappedNative *wrapper,
return NS_OK;
}
doc->FlushPendingNotifications();
// Have to flush layout, since plugin instance instantiation
// currently happens in reflow! That's just uncool.
doc->FlushPendingNotifications(Flush_Layout);
// See if we have a frame.
nsIPresShell *shell = doc->GetShellAt(0);

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

@ -96,7 +96,7 @@ nsDOMWindowList::GetLength(PRUint32* aLength)
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domdoc));
if (doc) {
doc->FlushPendingNotifications();
doc->FlushPendingNotifications(Flush_ContentAndNotify);
}
}
@ -129,7 +129,7 @@ nsDOMWindowList::Item(PRUint32 aIndex, nsIDOMWindow** aReturn)
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
if (doc) {
doc->FlushPendingNotifications();
doc->FlushPendingNotifications(Flush_ContentAndNotify);
}
}
@ -166,7 +166,7 @@ nsDOMWindowList::NamedItem(const nsAString& aName, nsIDOMWindow** aReturn)
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domdoc));
if (doc) {
doc->FlushPendingNotifications();
doc->FlushPendingNotifications(Flush_ContentAndNotify);
}
}

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

@ -1537,7 +1537,14 @@ GlobalWindowImpl::SetName(const nsAString& aName)
NS_IMETHODIMP
GlobalWindowImpl::GetInnerWidth(PRInt32* aInnerWidth)
{
FlushPendingNotifications(PR_TRUE);
// If we're a subframe, make sure our size is up to date. It's OK that this
// crosses the content/chrome boundary, since chrome can have pending reflows
// too.
GlobalWindowImpl* parent = NS_STATIC_CAST(GlobalWindowImpl*,
GetPrivateParent());
if (parent) {
parent->FlushPendingNotifications(Flush_Layout);
}
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
*aInnerWidth = 0;
@ -1589,7 +1596,14 @@ GlobalWindowImpl::SetInnerWidth(PRInt32 aInnerWidth)
NS_IMETHODIMP
GlobalWindowImpl::GetInnerHeight(PRInt32* aInnerHeight)
{
FlushPendingNotifications(PR_TRUE);
// If we're a subframe, make sure our size is up to date. It's OK that this
// crosses the content/chrome boundary, since chrome can have pending reflows
// too.
GlobalWindowImpl* parent = NS_STATIC_CAST(GlobalWindowImpl*,
GetPrivateParent());
if (parent) {
parent->FlushPendingNotifications(Flush_Layout);
}
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
*aInnerHeight = 0;
@ -1646,7 +1660,11 @@ GlobalWindowImpl::GetOuterWidth(PRInt32* aOuterWidth)
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
FlushPendingNotifications(PR_TRUE);
GlobalWindowImpl* rootWindow = NS_STATIC_CAST(GlobalWindowImpl*,
GetPrivateRoot());
if (rootWindow) {
rootWindow->FlushPendingNotifications(Flush_Layout);
}
PRInt32 notused;
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(aOuterWidth, &notused),
NS_ERROR_FAILURE);
@ -1689,7 +1707,11 @@ GlobalWindowImpl::GetOuterHeight(PRInt32* aOuterHeight)
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
FlushPendingNotifications(PR_TRUE);
GlobalWindowImpl* rootWindow = NS_STATIC_CAST(GlobalWindowImpl*,
GetPrivateRoot());
if (rootWindow) {
rootWindow->FlushPendingNotifications(Flush_Layout);
}
PRInt32 notused;
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&notused, aOuterHeight),
@ -1862,7 +1884,11 @@ GlobalWindowImpl::CheckSecurityLeftAndTop(PRInt32* aLeft, PRInt32* aTop)
PRInt32 screenLeft, screenTop, screenWidth, screenHeight;
PRInt32 winLeft, winTop, winWidth, winHeight;
FlushPendingNotifications(PR_TRUE);
GlobalWindowImpl* rootWindow = NS_STATIC_CAST(GlobalWindowImpl*,
GetPrivateRoot());
if (rootWindow) {
rootWindow->FlushPendingNotifications(Flush_Layout);
}
// Get the window size
nsCOMPtr<nsIBaseWindow> treeOwner;
@ -2140,7 +2166,7 @@ GlobalWindowImpl::EnsureReflowFlushAndPaint()
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
if (doc) {
doc->FlushPendingNotifications(PR_TRUE, PR_FALSE);
doc->FlushPendingNotifications(Flush_Layout);
}
// Unsuppress painting.
@ -3390,7 +3416,7 @@ GlobalWindowImpl::GetFrames(nsIDOMWindow** aFrames)
*aFrames = this;
NS_ADDREF(*aFrames);
FlushPendingNotifications(PR_FALSE);
FlushPendingNotifications(Flush_ContentAndNotify);
return NS_OK;
}
@ -4184,15 +4210,15 @@ GlobalWindowImpl::GetPrivateParent()
if (NS_STATIC_CAST(nsIDOMWindow *, this) == parent.get()) {
nsCOMPtr<nsIContent> chromeElement(do_QueryInterface(mChromeEventHandler));
if (!chromeElement)
return NS_OK; // This is ok, just means a null parent.
return nsnull; // This is ok, just means a null parent.
nsIDocument* doc = chromeElement->GetDocument();
if (!doc)
return NS_OK; // This is ok, just means a null parent.
return nsnull; // This is ok, just means a null parent.
nsIScriptGlobalObject *globalObject = doc->GetScriptGlobalObject();
if (!globalObject)
return NS_OK; // This is ok, just means a null parent.
return nsnull; // This is ok, just means a null parent.
parent = do_QueryInterface(globalObject);
}
@ -5429,7 +5455,7 @@ GlobalWindowImpl::GetScrollInfo(nsIScrollableView **aScrollableView,
// Flush pending notifications so that the presentation is up to
// date.
FlushPendingNotifications(PR_TRUE);
FlushPendingNotifications(Flush_Layout);
nsCOMPtr<nsIPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
@ -5497,11 +5523,11 @@ GlobalWindowImpl::SecurityCheckURL(const char *aURL)
}
void
GlobalWindowImpl::FlushPendingNotifications(PRBool aFlushReflows)
GlobalWindowImpl::FlushPendingNotifications(mozFlushType aType)
{
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
if (doc) {
doc->FlushPendingNotifications(aFlushReflows);
doc->FlushPendingNotifications(aType);
}
}

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

@ -83,6 +83,7 @@
#include "nsIXPCScriptable.h"
#include "nsPoint.h"
#include "nsSize.h"
#include "mozFlushType.h"
#define DEFAULT_HOME_PAGE "www.mozilla.org"
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
@ -249,7 +250,7 @@ protected:
const nsAString &aPopupURL,
const nsAString &aPopupWindowFeatures);
void FlushPendingNotifications(PRBool aFlushReflows);
void FlushPendingNotifications(mozFlushType aType);
void EnsureReflowFlushAndPaint();
nsresult CheckSecurityWidthAndHeight(PRInt32* width, PRInt32* height);
nsresult CheckSecurityLeftAndTop(PRInt32* left, PRInt32* top);

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

@ -169,7 +169,7 @@ inLayoutUtils::GetScreenOrigin(nsIDOMElement* aElement)
if (presShell) {
// Flush all pending notifications so that our frames are uptodate
presShell->FlushPendingNotifications(PR_FALSE);
doc->FlushPendingNotifications(Flush_Layout);
nsCOMPtr<nsIPresContext> presContext;
presShell->GetPresContext(getter_AddRefs(presContext));

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

@ -163,7 +163,7 @@ nsXPathResult::IterateNext(nsIDOMNode **aResult)
return NS_ERROR_DOM_TYPE_ERR;
if (mDocument)
mDocument->FlushPendingNotifications(PR_FALSE);
mDocument->FlushPendingNotifications(Flush_Content);
if (mInvalidIteratorState)
return NS_ERROR_DOM_INVALID_STATE_ERR;

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

@ -111,7 +111,7 @@ public:
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
private:

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

@ -79,6 +79,7 @@
#include "mozXMLTermSession.h"
#include "nsISelectionController.h"
#include "nsReadableUtils.h"
#include "nsIDocument.h"
/////////////////////////////////////////////////////////////////////////
// mozXMLTermSession definition
@ -3093,7 +3094,10 @@ NS_IMETHODIMP mozXMLTermSession::ScrollToBottomLeft(void)
if (NS_FAILED(result) || !presShell)
return NS_ERROR_FAILURE;
presShell->FlushPendingNotifications(PR_FALSE);
nsIDocument* doc = presShell->GetDocument();
if (doc) {
doc->FlushPendingNotifications(Flush_Layout);
}
// Get DOM Window
nsCOMPtr<nsIDocShell> docShell;

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

@ -656,7 +656,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
// Note that we are flushing before we add mPresShell as an observer
// to avoid bogus notifications.
mDocument->FlushPendingNotifications(PR_FALSE);
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
}
mPresShell->BeginObservingDocument();
@ -935,9 +935,7 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus)
static PRBool forcePaint
= PR_GetEnv("MOZ_FORCE_PAINT_AFTER_ONLOAD") != nsnull;
if (forcePaint) {
if (mPresShell) {
mPresShell->FlushPendingNotifications(PR_TRUE);
}
mDocument->FlushPendingNotifications(Flush_Display);
nsIURI *uri = mDocument->GetDocumentURI();
nsCAutoString spec;
if (uri) {

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

@ -59,6 +59,7 @@
#include "nsCompatibility.h"
#include "nsCOMArray.h"
#include "nsFrameManagerBase.h"
#include "mozFlushType.h"
#include <stdio.h> // for FILE definition
class nsIAtom;
@ -324,11 +325,15 @@ public:
NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush) = 0;
/**
* Flush all pending notifications such that the presentation is
* in sync with the content.
* @param aUpdateViews PR_TRUE causes the affected views to be refreshed immediately.
* Flush pending notifications of the type specified. This method
* will not affect the content model; it'll just affect style and
* frames. Callers that actually want up-to-date presentation (other
* than the document itself) should probably be calling
* nsIDocument::FlushPendingNotifications.
*
* @param aType the type of notifications to flush
*/
NS_IMETHOD FlushPendingNotifications(PRBool aUpdateViews) = 0;
NS_IMETHOD FlushPendingNotifications(mozFlushType aType) = 0;
/**
* Post a request to handle a DOM event after Reflow has finished.

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

@ -1131,7 +1131,7 @@ public:
PRBool aProcessDummyLayoutRequest = PR_TRUE);
NS_IMETHOD CancelAllReflowCommands();
NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush);
NS_IMETHOD FlushPendingNotifications(PRBool aUpdateViews);
NS_IMETHOD FlushPendingNotifications(mozFlushType aType);
/**
* Recreates the frames for a node
@ -3972,6 +3972,10 @@ PresShell::CantRenderReplacedElement(nsIFrame* aFrame)
NS_IMETHODIMP
PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
{
if (!mDocument) {
return NS_ERROR_FAILURE;
}
// Hold a reference to the ESM in case event dispatch tears us down.
nsCOMPtr<nsIEventStateManager> esm = mPresContext->EventStateManager();
@ -4097,7 +4101,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
if (content) {
// Flush notifications so we scroll to the right place
if (aScroll) {
FlushPendingNotifications(PR_FALSE);
mDocument->FlushPendingNotifications(Flush_Layout);
}
// Get the primary frame
@ -5087,7 +5091,7 @@ PresShell::HandlePostedReflowCallbacks()
}
if (shouldFlush)
FlushPendingNotifications(PR_FALSE);
FlushPendingNotifications(Flush_Layout);
}
void
@ -5162,19 +5166,26 @@ PresShell::IsSafeToFlush(PRBool& aIsSafeToFlush)
NS_IMETHODIMP
PresShell::FlushPendingNotifications(PRBool aUpdateViews)
PresShell::FlushPendingNotifications(mozFlushType aType)
{
NS_ASSERTION(aType & (Flush_StyleReresolves | Flush_OnlyReflow |
Flush_OnlyPaint),
"Why did we get called?");
PRBool isSafeToFlush;
IsSafeToFlush(isSafeToFlush);
if (isSafeToFlush) {
if (aUpdateViews && mViewManager) {
PRBool batchViews = (aType & Flush_OnlyPaint);
if (batchViews && mViewManager) {
mViewManager->BeginUpdateViewBatch();
}
ProcessReflowCommands(PR_FALSE);
if (aType & Flush_OnlyReflow) {
ProcessReflowCommands(PR_FALSE);
}
if (aUpdateViews && mViewManager) {
if (batchViews && mViewManager) {
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
}
}
@ -5202,7 +5213,7 @@ PresShell::EndReflowBatching(PRBool aFlushPendingReflows)
nsresult rv = NS_OK;
mBatchReflows = PR_FALSE;
if (aFlushPendingReflows) {
rv = FlushPendingNotifications(PR_FALSE);
rv = FlushPendingNotifications(Flush_Layout);
}
else {
PostReflowEvent();
@ -6303,7 +6314,7 @@ PresShell::DidCauseReflow()
// We may have had more reflow commands appended to the queue during
// our reflow. Make sure these get processed at some point.
if (!gAsyncReflowDuringDocLoad && mDocumentLoading) {
FlushPendingNotifications(PR_FALSE);
FlushPendingNotifications(Flush_Layout);
} else {
PostReflowEvent();
}

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

@ -59,6 +59,7 @@
#include "nsCompatibility.h"
#include "nsCOMArray.h"
#include "nsFrameManagerBase.h"
#include "mozFlushType.h"
#include <stdio.h> // for FILE definition
class nsIAtom;
@ -324,11 +325,15 @@ public:
NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush) = 0;
/**
* Flush all pending notifications such that the presentation is
* in sync with the content.
* @param aUpdateViews PR_TRUE causes the affected views to be refreshed immediately.
* Flush pending notifications of the type specified. This method
* will not affect the content model; it'll just affect style and
* frames. Callers that actually want up-to-date presentation (other
* than the document itself) should probably be calling
* nsIDocument::FlushPendingNotifications.
*
* @param aType the type of notifications to flush
*/
NS_IMETHOD FlushPendingNotifications(PRBool aUpdateViews) = 0;
NS_IMETHOD FlushPendingNotifications(mozFlushType aType) = 0;
/**
* Post a request to handle a DOM event after Reflow has finished.

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

@ -616,7 +616,9 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList)
mDroppedDown = PR_FALSE;
}
aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
// Don't flush anything but reflows lest it destroy us
aPresContext->PresShell()->
GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
if (widget)
widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, aShowList);
@ -1809,8 +1811,6 @@ nsComboboxControlFrame::RedisplayText(PRInt32 aIndex)
//mTextFrame->AddStateBits(NS_FRAME_IS_DIRTY);
mDisplayFrame->AddStateBits(NS_FRAME_IS_DIRTY);
ReflowDirtyChild(mPresContext->PresShell(), mDisplayFrame);
// mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
}
}
return rv;

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

@ -3480,7 +3480,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
// Why aren't they getting flushed each time?
// because this isn't needed for Gfx
if (IsInDropDownMode() == PR_TRUE) {
mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
// Don't flush anything but reflows lest it destroy us
mPresContext->PresShell()->
GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
}
REFLOW_DEBUG_MSG2(" After: %d\n", newIndex);

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

@ -1131,7 +1131,7 @@ public:
PRBool aProcessDummyLayoutRequest = PR_TRUE);
NS_IMETHOD CancelAllReflowCommands();
NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush);
NS_IMETHOD FlushPendingNotifications(PRBool aUpdateViews);
NS_IMETHOD FlushPendingNotifications(mozFlushType aType);
/**
* Recreates the frames for a node
@ -3972,6 +3972,10 @@ PresShell::CantRenderReplacedElement(nsIFrame* aFrame)
NS_IMETHODIMP
PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
{
if (!mDocument) {
return NS_ERROR_FAILURE;
}
// Hold a reference to the ESM in case event dispatch tears us down.
nsCOMPtr<nsIEventStateManager> esm = mPresContext->EventStateManager();
@ -4097,7 +4101,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll)
if (content) {
// Flush notifications so we scroll to the right place
if (aScroll) {
FlushPendingNotifications(PR_FALSE);
mDocument->FlushPendingNotifications(Flush_Layout);
}
// Get the primary frame
@ -5087,7 +5091,7 @@ PresShell::HandlePostedReflowCallbacks()
}
if (shouldFlush)
FlushPendingNotifications(PR_FALSE);
FlushPendingNotifications(Flush_Layout);
}
void
@ -5162,19 +5166,26 @@ PresShell::IsSafeToFlush(PRBool& aIsSafeToFlush)
NS_IMETHODIMP
PresShell::FlushPendingNotifications(PRBool aUpdateViews)
PresShell::FlushPendingNotifications(mozFlushType aType)
{
NS_ASSERTION(aType & (Flush_StyleReresolves | Flush_OnlyReflow |
Flush_OnlyPaint),
"Why did we get called?");
PRBool isSafeToFlush;
IsSafeToFlush(isSafeToFlush);
if (isSafeToFlush) {
if (aUpdateViews && mViewManager) {
PRBool batchViews = (aType & Flush_OnlyPaint);
if (batchViews && mViewManager) {
mViewManager->BeginUpdateViewBatch();
}
ProcessReflowCommands(PR_FALSE);
if (aType & Flush_OnlyReflow) {
ProcessReflowCommands(PR_FALSE);
}
if (aUpdateViews && mViewManager) {
if (batchViews && mViewManager) {
mViewManager->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE);
}
}
@ -5202,7 +5213,7 @@ PresShell::EndReflowBatching(PRBool aFlushPendingReflows)
nsresult rv = NS_OK;
mBatchReflows = PR_FALSE;
if (aFlushPendingReflows) {
rv = FlushPendingNotifications(PR_FALSE);
rv = FlushPendingNotifications(Flush_Layout);
}
else {
PostReflowEvent();
@ -6303,7 +6314,7 @@ PresShell::DidCauseReflow()
// We may have had more reflow commands appended to the queue during
// our reflow. Make sure these get processed at some point.
if (!gAsyncReflowDuringDocLoad && mDocumentLoading) {
FlushPendingNotifications(PR_FALSE);
FlushPendingNotifications(Flush_Layout);
} else {
PostReflowEvent();
}

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

@ -616,7 +616,9 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList)
mDroppedDown = PR_FALSE;
}
aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
// Don't flush anything but reflows lest it destroy us
aPresContext->PresShell()->
GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
if (widget)
widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, aShowList);
@ -1809,8 +1811,6 @@ nsComboboxControlFrame::RedisplayText(PRInt32 aIndex)
//mTextFrame->AddStateBits(NS_FRAME_IS_DIRTY);
mDisplayFrame->AddStateBits(NS_FRAME_IS_DIRTY);
ReflowDirtyChild(mPresContext->PresShell(), mDisplayFrame);
// mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
}
}
return rv;

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

@ -3480,7 +3480,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
// Why aren't they getting flushed each time?
// because this isn't needed for Gfx
if (IsInDropDownMode() == PR_TRUE) {
mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
// Don't flush anything but reflows lest it destroy us
mPresContext->PresShell()->
GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
}
REFLOW_DEBUG_MSG2(" After: %d\n", newIndex);

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

@ -271,6 +271,11 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName,
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsIDocument* document = mContent->GetDocument();
if (document) {
document->FlushPendingNotifications(Flush_Style);
}
nsIFrame *frame = nsnull;
presShell->GetPrimaryFrameFor(mContent, &frame);
@ -2873,7 +2878,7 @@ nsComputedDOMStyle::FlushPendingReflows()
// Flush all pending notifications so that our frames are up to date
nsIDocument* document = mContent->GetDocument();
if (document) {
document->FlushPendingNotifications();
document->FlushPendingNotifications(Flush_Layout);
}
}

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

@ -1060,7 +1060,10 @@ void nsSVGOuterSVGFrame::InitiateReflow()
}
mPresShell->AppendReflowCommand(reflowCmd);
mPresShell->FlushPendingNotifications(PR_FALSE);
// XXXbz why is this synchronously flushing reflows, exactly? If it
// needs to, why is it not using the presshell's reflow batching
// instead of hacking its own?
mPresShell->FlushPendingNotifications(Flush_OnlyReflow);
}

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

@ -187,7 +187,7 @@ nsBoxObject::GetOffsetRect(nsRect& aRect)
if(presShell) {
// Flush all pending notifications so that our frames are uptodate
presShell->FlushPendingNotifications(PR_FALSE);
doc->FlushPendingNotifications(Flush_Layout);
// Get the Frame for our content
nsIFrame* frame = nsnull;
@ -282,7 +282,7 @@ nsBoxObject::GetScreenRect(nsRect& aRect)
if (presShell) {
// Flush all pending notifications so that our frames are uptodate
presShell->FlushPendingNotifications(PR_FALSE);
doc->FlushPendingNotifications(Flush_Layout);
nsCOMPtr<nsIPresContext> presContext;
presShell->GetPresContext(getter_AddRefs(presContext));

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

@ -404,7 +404,8 @@ nsListBoxBodyFrame::PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex)
smoother->Stop();
mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
// Don't flush anything but reflows lest it destroy us
mContent->GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
smoother->mDelta = newTwipIndex > oldTwipIndex ? rowDelta : -rowDelta;
@ -851,7 +852,8 @@ nsListBoxBodyFrame::DoScrollToIndex(PRInt32 aRowIndex, PRBool aForceDestruct)
// This change has to happen immediately.
// Flush any pending reflow commands.
mContent->GetDocument()->FlushPendingNotifications();
// Don't flush anything but reflows lest it destroy us
mContent->GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
return NS_OK;
}
@ -881,8 +883,7 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta, PRBool a
// begin timing how long it takes to scroll a row
PRTime start = PR_Now();
nsIPresShell *shell = mPresContext->PresShell();
shell->FlushPendingNotifications(PR_FALSE);
mContent->GetDocument()->FlushPendingNotifications(Flush_OnlyReflow);
PRInt32 visibleRows = 0;
if (mRowHeight)
@ -927,7 +928,9 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta, PRBool a
nsBoxLayoutState state(mPresContext);
mScrolling = PR_TRUE;
MarkDirtyChildren(state);
shell->FlushPendingNotifications(PR_FALSE); // Calls CreateRows
// Flush calls CreateRows
// XXXbz there has to be a better way to do this than flushing!
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
mScrolling = PR_FALSE;
VerticalScroll(mYPosition);
@ -1318,7 +1321,7 @@ nsListBoxBodyFrame::OnContentInserted(nsIPresContext* aPresContext, nsIContent*
nsBoxLayoutState state(aPresContext);
MarkDirtyChildren(state);
shell->FlushPendingNotifications(PR_FALSE);
shell->FlushPendingNotifications(Flush_OnlyReflow);
}
//
@ -1390,7 +1393,7 @@ nsListBoxBodyFrame::OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aCh
}
MarkDirtyChildren(state);
aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
aPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
}
void

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

@ -802,7 +802,7 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
{
menuPopup->MarkDirty(state);
mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
}
nsRect curRect;
@ -823,7 +823,7 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
if (curRect.height != rect.height || mLastPref.height != rect.height)
{
menuPopup->MarkDirty(state);
mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
}
ActivateMenu(PR_TRUE);

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

@ -563,7 +563,7 @@ nsPopupSetFrame::ActivatePopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
// reflow will cause the popup to show itself again. (bug 71219)
nsIDocument* doc = aEntry->mPopupContent->GetDocument();
if (doc)
doc->FlushPendingNotifications();
doc->FlushPendingNotifications(Flush_OnlyReflow);
// make sure we hide the popup. We can't assume that we'll have a view
// since we could be cleaning up after someone that didn't correctly

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

@ -1047,11 +1047,7 @@ nsSplitterFrameInner::AdjustChildren(nsIPresContext* aPresContext)
frame->GetOffsetFromView(aPresContext, offset, &view);
NS_ASSERTION(nsnull != view, "no view");
}
nsIViewManager* viewManager = view->GetViewManager();
viewManager->DisableRefresh();
aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE);
viewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
aPresContext->PresShell()->FlushPendingNotifications(Flush_Display);
}
else {
nsBoxLayoutState state(aPresContext);

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

@ -109,10 +109,13 @@ public:
NS_IMETHOD SetParser(nsIParser* aParser)=0;
/**
* Flush all pending notifications so that the content model
* is in sync with the state of the sink.
* Flush content so that the content model is in sync with the state
* of the sink.
*
* @param aNotify true if notifications should be fired in the
* process (instead of deferred for now).
*/
NS_IMETHOD FlushPendingNotifications()=0;
virtual void FlushContent(PRBool aNotify)=0;
/**
* Set the document character set. This should be passed on to the

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

@ -104,7 +104,7 @@ public:
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }

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

@ -72,7 +72,7 @@ public:
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }

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

@ -172,7 +172,7 @@ public:
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
virtual void FlushContent(PRBool aNotify) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
// nsIRDFContentSink

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

@ -438,17 +438,8 @@ nsWebCrawler::OnStateChange(nsIWebProgress* aWebProgress,
// Make sure the document bits make it to the screen at least once
nsCOMPtr<nsIPresShell> shell = dont_AddRef(GetPresShell());
if (shell) {
// Force the presentation shell to flush any pending reflows
shell->FlushPendingNotifications(PR_FALSE);
// Force the view manager to update itself
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
if (vm) {
nsIView* rootView;
vm->GetRootView(rootView);
vm->UpdateView(rootView, NS_VMREFRESH_IMMEDIATE);
}
// Force the presentation shell to update the display
shell->FlushPendingNotifications(Flush_Display);
if (mJiggleLayout) {
nsRect r;

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

@ -388,6 +388,7 @@ NS_IMETHODIMP nsContentTreeOwner::SetStatus(PRUint32 aStatusType, const PRUnicha
// XXX: This is nasty because we have to drill down to the nsIDocument to
// force the flushing...
//
// XXXbz no, this is nasty because we're flushing at all!
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> doc;
@ -395,7 +396,7 @@ NS_IMETHODIMP nsContentTreeOwner::SetStatus(PRUint32 aStatusType, const PRUnicha
doc = do_QueryInterface(domDoc);
if (doc) {
doc->FlushPendingNotifications(PR_TRUE, PR_TRUE);
doc->FlushPendingNotifications(Flush_Layout);
}
return NS_OK;