Fix for bug 107827 -- avoid excess repainting on Mac when the paint-suppressed page is loading by ignoring widgets belonging to a widget hierarchy whose root is hidden. Improves page load time by 16-20%. r=pinkerton, sr=hyatt, a=asa

This commit is contained in:
sfraser%netscape.com 2002-01-23 00:48:19 +00:00
parent e99044efd2
commit dfb2e2dfc2
2 changed files with 56 additions and 29 deletions

View File

@ -1001,6 +1001,9 @@ NS_IMETHODIMP nsWindow::Invalidate(const nsRect &aRect, PRBool aIsSynchronous)
if (!mWindowPtr)
return NS_OK;
if (!mVisible || !ContainerHierarchyIsVisible())
return NS_OK;
nsRect wRect = aRect;
wRect.MoveBy(mBounds.x, mBounds.y); // beard: this is required, see GetNativeData(NS_NATIVE_OFFSETX).
LocalToWindowCoordinate(wRect);
@ -1037,6 +1040,9 @@ NS_IMETHODIMP nsWindow::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSyn
if (!mWindowPtr)
return NS_OK;
if (!mVisible || !ContainerHierarchyIsVisible())
return NS_OK;
// copy invalid region into a working region.
void* nativeRgn;
aRegion->GetNativeRegion(nativeRgn);
@ -2224,23 +2230,42 @@ PRBool nsWindow::RgnIntersects(RgnHandle aTheRegion, RgnHandle aIntersectRgn)
* @return NOTHING
*/
NS_IMETHODIMP nsWindow::CalcOffset(PRInt32 &aX,PRInt32 &aY)
void
nsWindow::CalcOffset(PRInt32 &aX, PRInt32 &aY)
{
aX = aY = 0;
nsIWidget* grandParent;
nsIWidget* theParent = this->GetParent();
while (theParent)
{
nsRect theRect;
theParent->GetBounds(theRect);
aX += theRect.x;
aY += theRect.y;
aX = aY = 0;
grandParent = theParent->GetParent();
NS_IF_RELEASE(theParent);
theParent = grandParent;
}
return NS_OK;
nsCOMPtr<nsIWidget> theParent = dont_AddRef(GetParent());
while (theParent)
{
nsRect theRect;
theParent->GetBounds(theRect);
aX += theRect.x;
aY += theRect.y;
nsIWidget* grandparent = theParent->GetParent();
theParent = dont_AddRef(grandparent);
}
}
PRBool
nsWindow::ContainerHierarchyIsVisible()
{
nsCOMPtr<nsIWidget> theParent = dont_AddRef(GetParent());
while (theParent)
{
PRBool visible;
theParent->IsVisible(visible);
if (!visible)
return PR_FALSE;
nsIWidget* grandparent = theParent->GetParent();
theParent = dont_AddRef(grandparent);
}
return PR_TRUE;
}
@ -2416,10 +2441,11 @@ void nsWindow::nsRectToMacRect(const nsRect& aRect, Rect& aMacRect) const
* @param nscoord -- Y coordinate to convert
* @return NONE
*/
void nsWindow::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY)
void
nsWindow::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY)
{
PRInt32 offX, offY;
this->CalcOffset(offX,offY);
CalcOffset(offX,offY);
aX += offX;
aY += offY;

View File

@ -160,12 +160,12 @@ public:
virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull);
virtual void EndDraw();
NS_IMETHOD Update();
virtual void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext);
NS_IMETHOD Update();
virtual void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext);
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
void LocalToWindowCoordinate(nsPoint& aPoint) { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); }
void LocalToWindowCoordinate(nscoord& aX, nscoord& aY) { ConvertToDeviceCoordinates(aX, aY); }
void LocalToWindowCoordinate(nsPoint& aPoint) { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); }
void LocalToWindowCoordinate(nscoord& aX, nscoord& aY) { ConvertToDeviceCoordinates(aX, aY); }
void LocalToWindowCoordinate(nsRect& aRect) { ConvertToDeviceCoordinates(aRect.x, aRect.y); }
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
@ -184,17 +184,17 @@ public:
// Mac specific methods
void nsRectToMacRect(const nsRect& aRect, Rect& aMacRect) const;
PRBool RgnIntersects(RgnHandle aTheRegion,RgnHandle aIntersectRgn);
virtual void CalcWindowRegions();
virtual void CalcWindowRegions();
virtual PRBool PointInWidget(Point aThePoint);
virtual nsWindow* FindWidgetHit(Point aThePoint);
virtual PRBool PointInWidget(Point aThePoint);
virtual nsWindow* FindWidgetHit(Point aThePoint);
virtual PRBool DispatchWindowEvent(nsGUIEvent& event);
virtual PRBool DispatchWindowEvent(nsGUIEvent &event,nsEventStatus &aStatus);
virtual PRBool DispatchWindowEvent(nsGUIEvent& event);
virtual PRBool DispatchWindowEvent(nsGUIEvent &event,nsEventStatus &aStatus);
virtual nsresult HandleUpdateEvent(RgnHandle regionToValidate);
virtual void AcceptFocusOnClick(PRBool aBool) { mAcceptFocusOnClick = aBool;};
PRBool AcceptFocusOnClick() { return mAcceptFocusOnClick;};
void Flash(nsPaintEvent &aEvent);
void Flash(nsPaintEvent &aEvent);
public:
// nsIKBStateControl interface
@ -206,8 +206,9 @@ protected:
PRBool ReportMoveEvent();
PRBool ReportSizeEvent();
NS_IMETHOD CalcOffset(PRInt32 &aX,PRInt32 &aY);
void CalcOffset(PRInt32 &aX,PRInt32 &aY);
PRBool ContainerHierarchyIsVisible();
virtual PRBool OnPaint(nsPaintEvent & aEvent);
// our own impl of ::ScrollRect() that uses CopyBits so that it looks good. On