Bug 703260, part 3, remove nsIViewObserver, r=mats

This commit is contained in:
Neil Deakin 2011-11-21 12:53:20 -05:00
Родитель 8adb1bec34
Коммит 0ed659f60c
12 изменённых файлов: 110 добавлений и 294 удалений

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

@ -42,7 +42,6 @@
#include "nsCOMPtr.h"
#include "nsIWidget.h"
#include "nsIViewManager.h"
#include "nsIViewObserver.h"
#include "nsIPresShell.h"
#include "nsISupports.h"
#include "nsPIDOMWindow.h"

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

@ -68,7 +68,6 @@
#include "gfxImageSurface.h"
#include "nsLayoutUtils.h"
#include "nsComputedDOMStyle.h"
#include "nsIViewObserver.h"
#include "nsIPresShell.h"
#include "nsStyleAnimation.h"
#include "nsCSSProps.h"
@ -475,12 +474,9 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
nsEventStatus status;
if (aToWindow) {
nsIPresShell* presShell = presContext->PresShell();
nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
if (!presShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIViewObserver> vo = do_QueryInterface(presShell);
if (!vo)
return NS_ERROR_FAILURE;
nsIViewManager* viewManager = presShell->GetViewManager();
if (!viewManager)
return NS_ERROR_FAILURE;
@ -489,7 +485,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
return NS_ERROR_FAILURE;
status = nsEventStatus_eIgnore;
return vo->HandleEvent(view->GetFrame(), &event, false, &status);
return presShell->HandleEvent(view->GetFrame(), &event, false, &status);
}
return widget->DispatchEvent(&event, status);
}

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

@ -102,11 +102,13 @@ class nsPIDOMWindow;
struct nsPoint;
struct nsIntPoint;
struct nsIntRect;
class nsRegion;
class nsRefreshDriver;
class nsARefreshObserver;
#ifdef ACCESSIBILITY
class nsAccessibilityService;
#endif
class nsIWidget;
typedef short SelectionType;
typedef PRUint64 nsFrameState;
@ -139,8 +141,8 @@ typedef struct CapturingContentInfo {
} CapturingContentInfo;
#define NS_IPRESSHELL_IID \
{ 0x67eab923, 0x5c15, 0x4c13,\
{ 0xb5, 0xcc, 0xb2, 0x75, 0xb3, 0x5a, 0xa5, 0x38 } }
{ 0x4e23d557, 0x741a, 0x4fd0,\
{ 0x91, 0x52, 0x34, 0xe2, 0xb4, 0xef, 0xe8, 0x2e } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -1136,6 +1138,20 @@ public:
*/
virtual void SynthesizeMouseMove(bool aFromScroll) = 0;
virtual void Paint(nsIView* aViewToPaint, nsIWidget* aWidget,
const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground, bool aWillSendDidPaint) = 0;
virtual nsresult HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus) = 0;
virtual bool ShouldIgnoreInvalidation() = 0;
virtual void WillPaint(bool aWillSendDidPaint) = 0;
virtual void DidPaint() = 0;
virtual void ClearMouseCaptureOnView(nsIView* aView) = 0;
virtual bool IsVisible() = 0;
virtual void DispatchSynthMouseMove(nsGUIEvent *aEvent, bool aFlushOnHoverChange) = 0;
/**
* Refresh observer management.
*/

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

@ -955,8 +955,8 @@ PresShell::PresShell()
sLiveShells->PutEntry(this);
}
NS_IMPL_ISUPPORTS8(PresShell, nsIPresShell, nsIDocumentObserver,
nsIViewObserver, nsISelectionController,
NS_IMPL_ISUPPORTS7(PresShell, nsIPresShell, nsIDocumentObserver,
nsISelectionController,
nsISelectionDisplay, nsIObserver, nsISupportsWeakReference,
nsIMutationObserver)
@ -1031,7 +1031,7 @@ PresShell::Init(nsIDocument* aDocument,
mFrameConstructor = new nsCSSFrameConstructor(mDocument, this);
// The document viewer owns both view manager and pres shell.
mViewManager->SetViewObserver(this);
mViewManager->SetPresShell(this);
// Bind the context to the presentation shell.
mPresContext = aPresContext;
@ -1237,7 +1237,7 @@ PresShell::Destroy()
if (mViewManager) {
// Clear the view manager's weak pointer back to |this| in case it
// was leaked.
mViewManager->SetViewObserver(nsnull);
mViewManager->SetPresShell(nsnull);
mViewManager = nsnull;
}
@ -3632,7 +3632,7 @@ nsresult PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationStrin
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP_(void)
void
PresShell::DispatchSynthMouseMove(nsGUIEvent *aEvent,
bool aFlushOnHoverChange)
{
@ -3648,8 +3648,8 @@ PresShell::DispatchSynthMouseMove(nsGUIEvent *aEvent,
}
}
NS_IMETHODIMP_(void)
PresShell::ClearMouseCapture(nsIView* aView)
void
PresShell::ClearMouseCaptureOnView(nsIView* aView)
{
if (gCaptureInfo.mContent) {
if (aView) {
@ -5389,9 +5389,9 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
event.time = PR_IntervalNow();
// XXX set event.isShift, event.isControl, event.isAlt, event.isMeta ?
nsCOMPtr<nsIViewObserver> observer = pointVM->GetViewObserver();
if (observer) {
observer->DispatchSynthMouseMove(&event, !aFromScroll);
nsCOMPtr<nsIPresShell> shell = pointVM->GetPresShell();
if (shell) {
shell->DispatchSynthMouseMove(&event, !aFromScroll);
}
if (!aFromScroll) {
@ -5399,7 +5399,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
}
}
NS_IMETHODIMP
void
PresShell::Paint(nsIView* aViewToPaint,
nsIWidget* aWidgetToPaint,
const nsRegion& aDirtyRegion,
@ -5444,7 +5444,7 @@ PresShell::Paint(nsIView* aViewToPaint,
if (layerManager->EndEmptyTransaction()) {
frame->UpdatePaintCountForPaintedPresShells();
presContext->NotifyDidPaintForSubtree();
return NS_OK;
return;
}
}
@ -5473,7 +5473,7 @@ PresShell::Paint(nsIView* aViewToPaint,
frame->EndDeferringInvalidatesForDisplayRoot();
presContext->NotifyDidPaintForSubtree();
return NS_OK;
return;
}
nsRefPtr<ColorLayer> root = layerManager->CreateColorLayer();
@ -5489,7 +5489,6 @@ PresShell::Paint(nsIView* aViewToPaint,
layerManager->EndTransaction(NULL, NULL);
presContext->NotifyDidPaintForSubtree();
return NS_OK;
}
// static
@ -5645,14 +5644,9 @@ PresShell::RetargetEventToParent(nsGUIEvent* aEvent,
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
nsCOMPtr<nsIPresShell> parentPresShell = GetParentPresShell();
NS_ENSURE_TRUE(parentPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewObserver> parentViewObserver =
do_QueryInterface(parentPresShell);
if (!parentViewObserver) {
return NS_ERROR_FAILURE;
}
// Fake the event as though it's from the parent pres shell's root frame.
return parentViewObserver->HandleEvent(parentPresShell->GetRootFrame(), aEvent, true, aEventStatus);
return parentPresShell->HandleEvent(parentPresShell->GetRootFrame(), aEvent, true, aEventStatus);
}
void
@ -5724,7 +5718,7 @@ PresShell::RecordMouseLocation(nsGUIEvent* aEvent)
}
}
NS_IMETHODIMP
nsresult
PresShell::HandleEvent(nsIFrame *aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
@ -5787,16 +5781,12 @@ PresShell::HandleEvent(nsIFrame *aFrame,
}
if (retargetEventDoc) {
nsIPresShell* presShell = retargetEventDoc->GetShell();
nsCOMPtr<nsIPresShell> presShell = retargetEventDoc->GetShell();
if (!presShell)
return NS_OK;
if (presShell != this) {
nsCOMPtr<nsIViewObserver> viewObserver = do_QueryInterface(presShell);
if (!viewObserver)
return NS_ERROR_FAILURE;
return viewObserver->HandleEvent(presShell->GetRootFrame(), aEvent, true, aEventStatus);
return presShell->HandleEvent(presShell->GetRootFrame(), aEvent, true, aEventStatus);
}
}
}
@ -6071,12 +6061,10 @@ PresShell::HandleEvent(nsIFrame *aFrame,
nsIDocument* targetDoc = eventTarget ? eventTarget->OwnerDoc() : nsnull;
if (targetDoc && targetDoc != mDocument) {
PopCurrentEventInfo();
nsIPresShell* shell = targetDoc->GetShell();
nsCOMPtr<nsIViewObserver> vo = do_QueryInterface(shell);
if (vo) {
rv = static_cast<PresShell*>(shell)->HandleRetargetedEvent(aEvent,
aEventStatus,
eventTarget);
nsCOMPtr<nsIPresShell> shell = targetDoc->GetShell();
if (shell) {
rv = static_cast<PresShell*>(shell.get())->
HandleRetargetedEvent(aEvent, aEventStatus, eventTarget);
}
return rv;
} else {
@ -6852,19 +6840,13 @@ PresShell::GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
NS_IF_ADDREF(*aTargetToUse = focusedContent);
}
NS_IMETHODIMP
PresShell::ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight)
{
return ResizeReflow(aWidth, aHeight);
}
NS_IMETHODIMP_(bool)
bool
PresShell::ShouldIgnoreInvalidation()
{
return mPaintingSuppressed || !mIsActive;
}
NS_IMETHODIMP_(void)
void
PresShell::WillPaint(bool aWillSendDidPaint)
{
// Don't bother doing anything if some viewmanager in our tree is painting
@ -6892,7 +6874,7 @@ PresShell::WillPaint(bool aWillSendDidPaint)
FlushPendingNotifications(Flush_InterruptibleLayout);
}
NS_IMETHODIMP_(void)
void
PresShell::DidPaint()
{
if (mPaintingSuppressed || !mIsActive || !IsVisible()) {
@ -6908,7 +6890,7 @@ PresShell::DidPaint()
}
}
NS_IMETHODIMP_(bool)
bool
PresShell::IsVisible()
{
if (!mViewManager)
@ -8031,7 +8013,7 @@ PresShell::VerifyIncrementalReflow()
newSet.forget();
// Note that after we create the shell, we must make sure to destroy it
sh->SetVerifyReflowEnable(false); // turn off verify reflow while we're reflowing the test frame tree
vm->SetViewObserver((nsIViewObserver *)((PresShell*)sh.get()));
vm->SetPresShell(sh);
{
nsAutoCauseReflowNotifier crNotifier(this);
sh->InitialReflow(r.width, r.height);

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

@ -60,7 +60,6 @@
#define nsPresShell_h_
#include "nsIPresShell.h"
#include "nsIViewObserver.h"
#include "nsStubDocumentObserver.h"
#include "nsISelectionController.h"
#include "nsIObserver.h"
@ -169,7 +168,7 @@ private:
class nsPresShellEventCB;
class nsAutoCauseReflowNotifier;
class PresShell : public nsIPresShell, public nsIViewObserver,
class PresShell : public nsIPresShell,
public nsStubDocumentObserver,
public nsISelectionController, public nsIObserver,
public nsSupportsWeakReference
@ -314,30 +313,25 @@ public:
//nsIViewObserver interface
NS_IMETHOD Paint(nsIView* aViewToPaint,
nsIWidget* aWidget,
const nsRegion& aDirtyRegion,
const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground,
bool aWillSendDidPaint);
NS_IMETHOD HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus);
virtual void Paint(nsIView* aViewToPaint, nsIWidget* aWidget,
const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground, bool aWillSendDidPaint);
virtual nsresult HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus);
virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsEvent* aEvent,
nsEventStatus* aStatus);
virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsIDOMEvent* aEvent,
nsEventStatus* aStatus);
NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight);
NS_IMETHOD_(bool) ShouldIgnoreInvalidation();
NS_IMETHOD_(void) WillPaint(bool aWillSendDidPaint);
NS_IMETHOD_(void) DidPaint();
NS_IMETHOD_(void) DispatchSynthMouseMove(nsGUIEvent *aEvent,
bool aFlushOnHoverChange);
NS_IMETHOD_(void) ClearMouseCapture(nsIView* aView);
NS_IMETHOD_(bool) IsVisible();
virtual bool ShouldIgnoreInvalidation();
virtual void WillPaint(bool aWillSendDidPaint);
virtual void DidPaint();
virtual void DispatchSynthMouseMove(nsGUIEvent *aEvent, bool aFlushOnHoverChange);
virtual void ClearMouseCaptureOnView(nsIView* aView);
virtual bool IsVisible();
// caret handling
virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret() const;

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

@ -48,7 +48,6 @@ EXPORTS = \
nsIView.h \
nsIViewManager.h \
nsViewsCID.h \
nsIViewObserver.h \
nsIScrollPositionListener.h \
$(NULL)

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

@ -46,11 +46,10 @@ class nsIWidget;
struct nsRect;
class nsRegion;
class nsDeviceContext;
class nsIViewObserver;
#define NS_IVIEWMANAGER_IID \
{ 0x144ef328, 0xbece, 0x43d6, \
{ 0xac, 0xac, 0x1a, 0x90, 0x4b, 0x5c, 0xc1, 0x11 } }
{ 0x1262a33f, 0xc19f, 0x4e5b, \
{ 0x85, 0x00, 0xab, 0xf3, 0x7d, 0xcf, 0x30, 0x1d } }
class nsIViewManager : public nsISupports
{
@ -59,7 +58,7 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID)
/**
* Initialize the ViewManager
* Note: this instance does not hold a reference to the viewobserver
* Note: this instance does not hold a reference to the presshell
* because it holds a reference to this instance.
* @result The result of the initialization, NS_OK if no errors
*/
@ -258,15 +257,15 @@ public:
NS_IMETHOD SetViewFloating(nsIView *aView, bool aFloatingView) = 0;
/**
* Set the view observer associated with this manager
* @param aObserver - new observer
* Set the presshell associated with this manager
* @param aPresShell - new presshell
*/
virtual void SetViewObserver(nsIViewObserver *aObserver) = 0;
virtual void SetPresShell(nsIPresShell *aPresShell) = 0;
/**
* Get the view observer associated with this manager
* Get the pres shell associated with this manager
*/
virtual nsIViewObserver* GetViewObserver() = 0;
virtual nsIPresShell* GetPresShell() = 0;
/**
* Get the device context associated with this manager

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

@ -1,156 +0,0 @@
/* -*- 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* 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 nsIViewObserver_h___
#define nsIViewObserver_h___
#include "nsISupports.h"
#include "nsEvent.h"
#include "nsColor.h"
#include "nsRect.h"
class nsRenderingContext;
class nsGUIEvent;
class nsIWidget;
class nsRegion;
class nsIntRegion;
#define NS_IVIEWOBSERVER_IID \
{ 0x0d7ea18f, 0xc154, 0x4e25, \
{ 0x81, 0x0c, 0x5d, 0x60, 0x31, 0xd0, 0xac, 0xc3 } }
class nsIViewObserver : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWOBSERVER_IID)
/* called when the observer needs to paint. This paints the entire
* frame subtree rooted at aViewToPaint, including frame subtrees from
* subdocuments.
* @param aViewToPaint the view for the widget that is being painted
* @param aWidgetToPaint the widget that is being painted, the widget of
* aViewToPaint
* @param aDirtyRegion the region to be painted, in appunits of aDisplayRoot
* and relative to aDisplayRoot
* @param aIntDirtyRegion the region to be painted, in dev pixels, in the
* coordinates of aWidgetToPaint. This conveys the same information as
* aDirtyRegion but in a different format.
* @param aPaintDefaultBackground just paint the default background,
* don't try to paint any content. This is set when the observer
* needs to paint something, but the view tree is unstable, so it
* must *not* paint, or even examine, the frame subtree rooted at the
* view. (It is, however, safe to inspect the state of the view itself,
* and any associated widget.) The name illustrates the expected behavior,
* which is to paint some default background color over the dirty region.
* @return error status
*/
NS_IMETHOD Paint(nsIView* aViewToPaint,
nsIWidget* aWidgetToPaint,
const nsRegion& aDirtyRegion,
const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground,
bool aWillSendDidPaint) = 0;
/* called when the observer needs to handle an event
* @param aFrame - the frame of where to start processing the event;
* must be a frame for this presshell
* @param aEvent - event notification
* @param aEventStatus - out parameter for event handling
* status
* @param aHandled - whether the correct frame was found to
* handle the event
* @return error status
*/
NS_IMETHOD HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus) = 0;
/* called when the view has been resized and the
* content within the view needs to be reflowed.
* @param aWidth - new width of view
* @param aHeight - new height of view
* @return error status
*/
NS_IMETHOD ResizeReflow(nsIView * aView, nscoord aWidth, nscoord aHeight) = 0;
/**
* Returns true if the view observer wants to drop all invalidation right now
* because painting is suppressed. It will invalidate everything when it
* unsuppresses.
*/
NS_IMETHOD_(bool) ShouldIgnoreInvalidation() = 0;
/**
* Notify the observer that we're about to start painting. This
* gives the observer a chance to make some last-minute invalidates
* and geometry changes if it wants to.
*/
NS_IMETHOD_(void) WillPaint(bool aWillSendDidPaint) = 0;
/**
* Notify the observer that we finished painting. This
* gives the observer a chance to make some last-minute invalidates
* and geometry changes if it wants to.
*/
NS_IMETHOD_(void) DidPaint() = 0;
/**
* Dispatch the given synthesized mouse move event, and if
* aFlushOnHoverChange is true, flush layout if :hover changes cause
* any restyles.
*/
NS_IMETHOD_(void) DispatchSynthMouseMove(nsGUIEvent *aEvent,
bool aFlushOnHoverChange) = 0;
/**
* If something within aView is capturing the mouse, clear the capture.
* if aView is null, clear the mouse capture no matter what is capturing it.
*/
NS_IMETHOD_(void) ClearMouseCapture(nsIView* aView) = 0;
/**
* Returns true if the view observer is visible in some way. Otherwise false.
*/
NS_IMETHOD_(bool) IsVisible() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIViewObserver, NS_IVIEWOBSERVER_IID)
#endif

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

@ -213,10 +213,9 @@ nsView::nsView(nsViewManager* aViewManager, nsViewVisibility aVisibility)
void nsView::DropMouseGrabbing()
{
nsCOMPtr<nsIViewObserver> viewObserver = mViewManager->GetViewObserver();
if (viewObserver) {
viewObserver->ClearMouseCapture(this);
}
nsIPresShell* presShell = mViewManager->GetPresShell();
if (presShell)
presShell->ClearMouseCaptureOnView(this);
}
nsView::~nsView()

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

@ -158,7 +158,7 @@ nsViewManager::~nsViewManager()
gViewManagers = nsnull;
}
mObserver = nsnull;
mPresShell = nsnull;
}
NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager)
@ -257,15 +257,15 @@ void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight)
if (!oldDim.IsEqualEdges(newDim)) {
// Don't resize the widget. It is already being set elsewhere.
mRootView->SetDimensions(newDim, true, false);
if (mObserver)
mObserver->ResizeReflow(mRootView, aWidth, aHeight);
if (mPresShell)
mPresShell->ResizeReflow(aWidth, aHeight);
}
}
NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
{
if (mRootView) {
if (mRootView->IsEffectivelyVisible() && mObserver && mObserver->IsVisible()) {
if (mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) {
if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
mDelayedResize != nsSize(aWidth, aHeight)) {
// We have a delayed resize; that now obsolete size may already have
@ -292,9 +292,8 @@ NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow)
if (aDoReflow) {
DoSetWindowDimensions(mDelayedResize.width, mDelayedResize.height);
mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
} else if (mObserver) {
nsCOMPtr<nsIPresShell> shell = do_QueryInterface(mObserver);
nsPresContext* presContext = shell->GetPresContext();
} else if (mPresShell) {
nsPresContext* presContext = mPresShell->GetPresContext();
if (presContext) {
presContext->SetVisibleArea(nsRect(nsPoint(0, 0), mDelayedResize));
}
@ -410,9 +409,9 @@ void nsViewManager::RenderViews(nsView *aView, nsIWidget *aWidget,
NS_ASSERTION(GetDisplayRootFor(aView) == aView,
"Widgets that we paint must all be display roots");
if (mObserver) {
mObserver->Paint(aView, aWidget, aRegion, aIntRegion,
aPaintDefaultBackground, aWillSendDidPaint);
if (mPresShell) {
mPresShell->Paint(aView, aWidget, aRegion, aIntRegion,
aPaintDefaultBackground, aWillSendDidPaint);
mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT);
}
}
@ -602,8 +601,8 @@ static bool
ShouldIgnoreInvalidation(nsViewManager* aVM)
{
while (aVM) {
nsIViewObserver* vo = aVM->GetViewObserver();
if (!vo || vo->ShouldIgnoreInvalidation()) {
nsIPresShell* shell = aVM->GetPresShell();
if (!shell || shell->ShouldIgnoreInvalidation()) {
return true;
}
nsView* view = aVM->GetRootViewImpl()->GetParent();
@ -763,15 +762,15 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
case NS_DONESIZEMOVE:
{
nsCOMPtr<nsIPresShell> shell = do_QueryInterface(mObserver);
if (shell) {
nsPresContext* presContext = shell->GetPresContext();
if (mPresShell) {
nsPresContext* presContext = mPresShell->GetPresContext();
if (presContext) {
nsEventStateManager::ClearGlobalActiveContent(nsnull);
}
mObserver->ClearMouseCapture(aView);
}
nsIPresShell::ClearMouseCapture(nsnull);
}
break;
@ -827,7 +826,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
: nsnull) {
if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
vm->mRootView->IsEffectivelyVisible() &&
mObserver && mObserver->IsVisible()) {
mPresShell && mPresShell->IsVisible()) {
vm->FlushDelayedResize(true);
// Paint later.
@ -855,8 +854,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
nsView* view = static_cast<nsView*>(aView);
if (!transparentWindow) {
nsIViewObserver* observer = GetViewObserver();
if (observer) {
if (mPresShell) {
// Do an update view batch. Make sure not to do it DEFERRED,
// since that would effectively delay any invalidates that are
// triggered by the WillPaint notification (they'd happen when
@ -950,12 +948,12 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
case NS_SYSCOLORCHANGED:
{
// Hold a refcount to the observer. The continued existence of the observer will
// delay deletion of this view hierarchy should the event want to cause its
// destruction in, say, some JavaScript event handler.
nsCOMPtr<nsIViewObserver> obs = GetViewObserver();
if (obs) {
obs->HandleEvent(aView->GetFrame(), aEvent, false, aStatus);
if (mPresShell) {
// Hold a refcount to the presshell. The continued existence of the observer will
// delay deletion of this view hierarchy should the event want to cause its
// destruction in, say, some JavaScript event handler.
nsCOMPtr<nsIPresShell> presShell = mPresShell;
presShell->HandleEvent(aView->GetFrame(), aEvent, false, aStatus);
}
}
break;
@ -980,10 +978,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
if (aEvent->message == NS_DEACTIVATE) {
// if a window is deactivated, clear the mouse capture regardless
// of what is capturing
nsIViewObserver* viewObserver = GetViewObserver();
if (viewObserver) {
viewObserver->ClearMouseCapture(nsnull);
}
nsIPresShell::ClearMouseCapture(nsnull);
}
// Find the view whose coordinates system we're in.
@ -1016,9 +1011,9 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
// Hold a refcount to the presshell. The continued existence of the
// presshell will delay deletion of this view hierarchy should the event
// want to cause its destruction in, say, some JavaScript event handler.
nsCOMPtr<nsIViewObserver> obs = view->GetViewManager()->GetViewObserver();
if (obs) {
obs->HandleEvent(frame, aEvent, false, aStatus);
nsCOMPtr<nsIPresShell> shell = view->GetViewManager()->GetPresShell();
if (shell) {
shell->HandleEvent(frame, aEvent, false, aStatus);
}
}
@ -1572,9 +1567,9 @@ nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint)
if (vm->RootViewManager() == this) {
// One of our kids.
if (vm->mRootView && vm->mRootView->IsEffectivelyVisible()) {
nsCOMPtr<nsIViewObserver> obs = vm->GetViewObserver();
if (obs) {
obs->WillPaint(aWillSendDidPaint);
nsCOMPtr<nsIPresShell> shell = vm->GetPresShell();
if (shell) {
shell->WillPaint(aWillSendDidPaint);
NS_ASSERTION(mUpdateBatchCnt == savedUpdateBatchCnt,
"Observer did not end view batch?");
}
@ -1594,9 +1589,9 @@ nsViewManager::CallDidPaintOnObservers()
if (vm->RootViewManager() == this) {
// One of our kids.
if (vm->mRootView && vm->mRootView->IsEffectivelyVisible()) {
nsCOMPtr<nsIViewObserver> obs = vm->GetViewObserver();
if (obs) {
obs->DidPaint();
nsCOMPtr<nsIPresShell> shell = vm->GetPresShell();
if (shell) {
shell->DidPaint();
}
}
}

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

@ -46,7 +46,7 @@
#include "nsVoidArray.h"
#include "nsThreadUtils.h"
#include "nsView.h"
#include "nsIViewObserver.h"
#include "nsIPresShell.h"
#include "nsDeviceContext.h"
@ -132,8 +132,8 @@ public:
NS_IMETHOD SetViewZIndex(nsIView *aView, bool aAuto, PRInt32 aZIndex, bool aTopMost=false);
virtual void SetViewObserver(nsIViewObserver *aObserver) { mObserver = aObserver; }
virtual nsIViewObserver* GetViewObserver() { return mObserver; }
virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; }
virtual nsIPresShell* GetPresShell() { return mPresShell; }
NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext);
@ -257,7 +257,7 @@ public: // NOT in nsIViewManager, so private to the view module
private:
nsRefPtr<nsDeviceContext> mContext;
nsIViewObserver *mObserver;
nsIPresShell *mPresShell;
// The size for a resize that we delayed until the root view becomes
// visible again.

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

@ -62,7 +62,6 @@
#include "nsIImageLoadingContent.h"
#include "imgIContainer.h"
#include "imgIRequest.h"
#include "nsIViewObserver.h"
#include "nsRegion.h"
#include "nsGUIEvent.h"
#include "nsXULPopupManager.h"
@ -246,13 +245,7 @@ nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
// capture. However, this gets in the way of determining drag
// feedback for things like trees because the event coordinates
// are in the wrong coord system, so turn off mouse capture.
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
if (doc) {
nsCOMPtr<nsIViewObserver> viewObserver = do_QueryInterface(doc->GetShell());
if (viewObserver) {
viewObserver->ClearMouseCapture(nsnull);
}
}
nsIPresShell::ClearMouseCapture(nsnull);
return NS_OK;
}