2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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 NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
1998-05-03 07:51:48 +04:00
|
|
|
#include "nsIPresShell.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
1999-08-08 05:15:30 +04:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsILinkHandler.h"
|
|
|
|
#include "nsHTMLValue.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIURL.h"
|
1998-05-05 08:47:53 +04:00
|
|
|
#include "nsPlaceholderFrame.h"
|
1998-05-29 06:13:25 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLParts.h"
|
1998-06-04 21:50:19 +04:00
|
|
|
#include "nsIView.h"
|
1998-09-23 06:29:31 +04:00
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsViewsCID.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsIDOMEvent.h"
|
1998-12-18 08:25:36 +03:00
|
|
|
#include "nsIScrollableView.h"
|
1999-01-28 20:14:13 +03:00
|
|
|
#include "nsWidgetsCID.h"
|
1999-02-24 07:03:50 +03:00
|
|
|
#include "nsIStyleSet.h"
|
1999-08-24 23:26:03 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2002-05-10 22:22:41 +04:00
|
|
|
#include "nsReflowPath.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-07 01:01:41 +04:00
|
|
|
NS_IMETHODIMP
|
2001-09-19 16:35:19 +04:00
|
|
|
nsHTMLContainerFrame::Paint(nsIPresContext* aPresContext,
|
1998-10-07 01:01:41 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-08-28 01:48:21 +04:00
|
|
|
if (NS_FRAME_IS_UNFLOWABLE & mState) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-09-05 01:45:47 +04:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
GetFrameType(getter_AddRefs(frameType));
|
|
|
|
|
|
|
|
// Paint inline element backgrounds in the foreground layer, but
|
|
|
|
// others in the background (bug 36710).
|
|
|
|
if (((frameType.get() == nsLayoutAtoms::inlineFrame)?NS_FRAME_PAINT_LAYER_FOREGROUND:NS_FRAME_PAINT_LAYER_BACKGROUND) == aWhichLayer) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)((nsIStyleContext*)mStyleContext)->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
if (vis->IsVisible() && mRect.width && mRect.height) {
|
1998-12-18 18:54:23 +03:00
|
|
|
// Paint our background and border
|
|
|
|
PRIntn skipSides = GetSkipSides();
|
2001-02-07 12:57:26 +03:00
|
|
|
const nsStyleBorder* border = (const nsStyleBorder*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Border);
|
|
|
|
const nsStyleOutline* outline = (const nsStyleOutline*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Outline);
|
1998-10-07 01:01:41 +04:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
2002-01-08 02:46:07 +03:00
|
|
|
aDirtyRect, rect, *border, 0, 0);
|
1998-12-18 18:54:23 +03:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
2002-01-08 02:46:07 +03:00
|
|
|
aDirtyRect, rect, *border, mStyleContext,
|
|
|
|
skipSides);
|
1999-08-19 18:35:48 +04:00
|
|
|
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
|
2002-01-08 02:46:07 +03:00
|
|
|
aDirtyRect, rect, *border, *outline,
|
|
|
|
mStyleContext, 0);
|
2000-05-17 02:12:54 +04:00
|
|
|
|
|
|
|
// The sole purpose of this is to trigger display
|
|
|
|
// of the selection window for Named Anchors,
|
|
|
|
// which don't have any children and normally don't
|
|
|
|
// have any size, but in Editor we use CSS to display
|
|
|
|
// an image to represent this "hidden" element.
|
|
|
|
if (!mFrames.FirstChild())
|
|
|
|
{
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
|
2000-05-17 02:12:54 +04:00
|
|
|
}
|
1998-10-07 01:01:41 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-11-19 06:52:29 +03:00
|
|
|
|
2001-04-25 23:52:49 +04:00
|
|
|
if (frameType.get() == nsLayoutAtoms::canvasFrame) {
|
|
|
|
// We are wrapping the root frame of a document. We
|
|
|
|
// need to check the pres shell to find out if painting is locked
|
|
|
|
// down (because we're still in the early stages of document
|
|
|
|
// and frame construction. If painting is locked down, then we
|
|
|
|
// do not paint our children.
|
|
|
|
PRBool paintingSuppressed = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
shell->IsPaintingSuppressed(&paintingSuppressed);
|
|
|
|
if (paintingSuppressed)
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-19 06:52:29 +03:00
|
|
|
// Now paint the kids. Note that child elements have the opportunity to
|
|
|
|
// override the visibility property and display even if their parent is
|
|
|
|
// hidden
|
2000-05-17 02:12:54 +04:00
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
|
2000-08-09 03:38:00 +04:00
|
|
|
|
2001-04-12 05:26:57 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-09-23 06:29:31 +04:00
|
|
|
/**
|
|
|
|
* Create a next-in-flow for aFrame. Will return the newly created
|
|
|
|
* frame in aNextInFlowResult <b>if and only if</b> a new frame is
|
|
|
|
* created; otherwise nsnull is returned in aNextInFlowResult.
|
|
|
|
*/
|
|
|
|
nsresult
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLContainerFrame::CreateNextInFlow(nsIPresContext* aPresContext,
|
1998-09-23 06:29:31 +04:00
|
|
|
nsIFrame* aOuterFrame,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIFrame*& aNextInFlowResult)
|
|
|
|
{
|
|
|
|
aNextInFlowResult = nsnull;
|
|
|
|
|
|
|
|
nsIFrame* nextInFlow;
|
1999-02-24 07:48:08 +03:00
|
|
|
aFrame->GetNextInFlow(&nextInFlow);
|
1998-09-23 06:29:31 +04:00
|
|
|
if (nsnull == nextInFlow) {
|
|
|
|
// Create a continuation frame for the child frame and insert it
|
|
|
|
// into our lines child list.
|
|
|
|
nsIFrame* nextFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
aFrame->GetNextSibling(&nextFrame);
|
1999-02-24 07:03:50 +03:00
|
|
|
|
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(&presShell);
|
1999-02-24 07:03:50 +03:00
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
1999-11-24 09:03:41 +03:00
|
|
|
styleSet->CreateContinuingFrame(aPresContext, aFrame, aOuterFrame, &nextInFlow);
|
1999-02-24 07:03:50 +03:00
|
|
|
NS_RELEASE(styleSet);
|
|
|
|
|
1998-09-23 06:29:31 +04:00
|
|
|
if (nsnull == nextInFlow) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aFrame->SetNextSibling(nextInFlow);
|
|
|
|
nextInFlow->SetNextSibling(nextFrame);
|
|
|
|
|
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_NEW_FRAMES,
|
1999-03-19 00:03:25 +03:00
|
|
|
("nsHTMLContainerFrame::MaybeCreateNextInFlow: frame=%p nextInFlow=%p",
|
1998-09-23 06:29:31 +04:00
|
|
|
aFrame, nextInFlow));
|
|
|
|
|
|
|
|
aNextInFlowResult = nextInFlow;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-11 08:22:00 +04:00
|
|
|
static nsresult
|
1999-10-26 08:44:41 +04:00
|
|
|
ReparentFrameViewTo(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
1999-08-24 23:26:03 +04:00
|
|
|
nsIViewManager* aViewManager,
|
|
|
|
nsIView* aNewParentView,
|
|
|
|
nsIView* aOldParentView)
|
1999-04-11 08:22:00 +04:00
|
|
|
{
|
|
|
|
nsIView* view;
|
|
|
|
|
2001-12-01 17:31:45 +03:00
|
|
|
// XXX What to do about placeholder views for "position: fixed" elements?
|
|
|
|
// They should be reparented too.
|
|
|
|
|
1999-04-11 08:22:00 +04:00
|
|
|
// Does aFrame have a view?
|
1999-10-26 08:44:41 +04:00
|
|
|
aFrame->GetView(aPresContext, &view);
|
1999-04-11 08:22:00 +04:00
|
|
|
if (view) {
|
|
|
|
// Verify that the current parent view is what we think it is
|
2001-04-12 05:26:57 +04:00
|
|
|
//nsIView* parentView;
|
2000-08-08 18:11:09 +04:00
|
|
|
//NS_ASSERTION(parentView == aOldParentView, "unexpected parent view");
|
1999-04-11 08:22:00 +04:00
|
|
|
|
2001-12-01 17:31:45 +03:00
|
|
|
aViewManager->RemoveChild(view);
|
1999-04-11 08:22:00 +04:00
|
|
|
|
2001-12-01 17:31:45 +03:00
|
|
|
// The view will remember the Z-order and other attributes that have been set on it.
|
|
|
|
// XXX Pretend this view is last of the parent's views in document order
|
|
|
|
aViewManager->InsertChild(aNewParentView, view, nsnull, PR_TRUE);
|
1999-04-11 08:22:00 +04:00
|
|
|
} else {
|
|
|
|
// Iterate the child frames, and check each child frame to see if it has
|
|
|
|
// a view
|
|
|
|
nsIFrame* childFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
aFrame->FirstChild(aPresContext, nsnull, &childFrame);
|
|
|
|
while (childFrame) {
|
|
|
|
ReparentFrameViewTo(aPresContext, childFrame, aViewManager, aNewParentView, aOldParentView);
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
1999-04-11 08:22:00 +04:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
// Also check the overflow-list
|
|
|
|
aFrame->FirstChild(aPresContext, nsLayoutAtoms::overflowList, &childFrame);
|
1999-04-11 08:22:00 +04:00
|
|
|
while (childFrame) {
|
1999-10-26 08:44:41 +04:00
|
|
|
ReparentFrameViewTo(aPresContext, childFrame, aViewManager, aNewParentView, aOldParentView);
|
1999-04-11 08:22:00 +04:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
2001-03-23 17:43:09 +03:00
|
|
|
|
|
|
|
// Also check the floater-list
|
|
|
|
aFrame->FirstChild(aPresContext, nsLayoutAtoms::floaterList, &childFrame);
|
|
|
|
while (childFrame) {
|
|
|
|
ReparentFrameViewTo(aPresContext, childFrame, aViewManager, aNewParentView, aOldParentView);
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
|
|
|
|
1999-04-11 08:22:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-24 23:26:03 +04:00
|
|
|
// Helper function that returns the nearest view to this frame. Checks
|
|
|
|
// this frame, its parent frame, its parent frame, ...
|
1999-04-11 08:22:00 +04:00
|
|
|
static nsIView*
|
1999-10-26 08:44:41 +04:00
|
|
|
GetClosestViewFor(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
1999-04-11 08:22:00 +04:00
|
|
|
{
|
1999-08-24 23:26:03 +04:00
|
|
|
NS_PRECONDITION(aFrame, "null frame pointer");
|
1999-04-11 08:22:00 +04:00
|
|
|
nsIView* view;
|
|
|
|
|
1999-08-24 23:26:03 +04:00
|
|
|
do {
|
1999-10-26 08:44:41 +04:00
|
|
|
aFrame->GetView(aPresContext, &view);
|
1999-08-24 23:26:03 +04:00
|
|
|
if (view) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
aFrame->GetParent(&aFrame);
|
|
|
|
} while (aFrame);
|
1999-04-11 08:22:00 +04:00
|
|
|
|
|
|
|
NS_POSTCONDITION(view, "no containing view");
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
nsIFrame* aOldParentFrame,
|
|
|
|
nsIFrame* aNewParentFrame)
|
1999-04-11 08:22:00 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aChildFrame, "null child frame pointer");
|
|
|
|
NS_PRECONDITION(aOldParentFrame, "null old parent frame pointer");
|
|
|
|
NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
|
|
|
|
NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
|
|
|
|
|
1999-08-24 23:26:03 +04:00
|
|
|
nsIView* childView;
|
|
|
|
nsIView* oldParentView;
|
|
|
|
nsIView* newParentView;
|
|
|
|
|
|
|
|
// This code is called often and we need it to be as fast as possible, so
|
|
|
|
// see if we can trivially detect that no work needs to be done
|
1999-10-26 08:44:41 +04:00
|
|
|
aChildFrame->GetView(aPresContext, &childView);
|
1999-08-24 23:26:03 +04:00
|
|
|
if (!childView) {
|
|
|
|
// Child frame doesn't have a view. See if it has any child frames
|
|
|
|
nsIFrame* firstChild;
|
2000-01-22 04:16:50 +03:00
|
|
|
aChildFrame->FirstChild(aPresContext, nsnull, &firstChild);
|
1999-08-24 23:26:03 +04:00
|
|
|
if (!firstChild) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if either the old parent frame or the new parent frame have a view
|
1999-10-26 08:44:41 +04:00
|
|
|
aOldParentFrame->GetView(aPresContext, &oldParentView);
|
|
|
|
aNewParentFrame->GetView(aPresContext, &newParentView);
|
1999-08-24 23:26:03 +04:00
|
|
|
|
|
|
|
if (!oldParentView && !newParentView) {
|
|
|
|
// Walk up both the old parent frame and the new parent frame nodes
|
|
|
|
// stopping when we either find a common parent or views for one
|
|
|
|
// or both of the frames.
|
|
|
|
//
|
|
|
|
// This works well in the common case where we push/pull and the old parent
|
|
|
|
// frame and the new parent frame are part of the same flow. They will
|
|
|
|
// typically be the same distance (height wise) from the
|
|
|
|
do {
|
|
|
|
aOldParentFrame->GetParent(&aOldParentFrame);
|
|
|
|
aNewParentFrame->GetParent(&aNewParentFrame);
|
|
|
|
|
|
|
|
// We should never walk all the way to the root frame without finding
|
|
|
|
// a view
|
|
|
|
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
|
1999-04-11 08:22:00 +04:00
|
|
|
|
1999-08-24 23:26:03 +04:00
|
|
|
// See if we reached a common parent
|
|
|
|
if (aOldParentFrame == aNewParentFrame) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the views
|
1999-10-26 08:44:41 +04:00
|
|
|
aOldParentFrame->GetView(aPresContext, &oldParentView);
|
|
|
|
aNewParentFrame->GetView(aPresContext, &newParentView);
|
1999-08-24 23:26:03 +04:00
|
|
|
} while (!(oldParentView || newParentView));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// See if we found a common parent frame
|
|
|
|
if (aOldParentFrame == aNewParentFrame) {
|
|
|
|
// We found a common parent and there are no views between the old parent
|
|
|
|
// and the common parent or the new parent frame and the common parent.
|
|
|
|
// Because neither the old parent frame nor the new parent frame have views,
|
|
|
|
// then any child views don't need reparenting
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We found views for one or both of the parent frames before we found a
|
|
|
|
// common parent
|
|
|
|
NS_ASSERTION(oldParentView || newParentView, "internal error");
|
|
|
|
if (!oldParentView) {
|
1999-10-26 08:44:41 +04:00
|
|
|
oldParentView = GetClosestViewFor(aPresContext, aOldParentFrame);
|
1999-08-24 23:26:03 +04:00
|
|
|
}
|
|
|
|
if (!newParentView) {
|
1999-10-26 08:44:41 +04:00
|
|
|
newParentView = GetClosestViewFor(aPresContext, aNewParentFrame);
|
1999-08-24 23:26:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// See if the old parent frame and the new parent frame are in the
|
|
|
|
// same view sub-hierarchy. If they are then we don't have to do
|
|
|
|
// anything
|
1999-04-11 08:22:00 +04:00
|
|
|
if (oldParentView != newParentView) {
|
1999-08-24 23:26:03 +04:00
|
|
|
nsCOMPtr<nsIViewManager> viewManager;
|
|
|
|
oldParentView->GetViewManager(*getter_AddRefs(viewManager));
|
|
|
|
|
|
|
|
// They're not so we need to reparent any child views
|
1999-10-26 08:44:41 +04:00
|
|
|
return ReparentFrameViewTo(aPresContext, aChildFrame, viewManager, newParentView,
|
1999-08-24 23:26:03 +04:00
|
|
|
oldParentView);
|
1999-04-11 08:22:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-12 06:09:36 +03:00
|
|
|
nsresult
|
|
|
|
nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrameList,
|
|
|
|
nsIFrame* aOldParentFrame,
|
|
|
|
nsIFrame* aNewParentFrame)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aChildFrameList, "null child frame list");
|
|
|
|
NS_PRECONDITION(aOldParentFrame, "null old parent frame pointer");
|
|
|
|
NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
|
|
|
|
NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
|
|
|
|
|
|
|
|
nsIView* oldParentView;
|
|
|
|
nsIView* newParentView;
|
|
|
|
|
|
|
|
// See if either the old parent frame or the new parent frame have a view
|
|
|
|
aOldParentFrame->GetView(aPresContext, &oldParentView);
|
|
|
|
aNewParentFrame->GetView(aPresContext, &newParentView);
|
|
|
|
|
|
|
|
if (!oldParentView && !newParentView) {
|
|
|
|
// Walk up both the old parent frame and the new parent frame nodes
|
|
|
|
// stopping when we either find a common parent or views for one
|
|
|
|
// or both of the frames.
|
|
|
|
//
|
|
|
|
// This works well in the common case where we push/pull and the old parent
|
|
|
|
// frame and the new parent frame are part of the same flow. They will
|
|
|
|
// typically be the same distance (height wise) from the
|
|
|
|
do {
|
|
|
|
aOldParentFrame->GetParent(&aOldParentFrame);
|
|
|
|
aNewParentFrame->GetParent(&aNewParentFrame);
|
|
|
|
|
|
|
|
// We should never walk all the way to the root frame without finding
|
|
|
|
// a view
|
|
|
|
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
|
|
|
|
|
|
|
|
// See if we reached a common parent
|
|
|
|
if (aOldParentFrame == aNewParentFrame) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the views
|
|
|
|
aOldParentFrame->GetView(aPresContext, &oldParentView);
|
|
|
|
aNewParentFrame->GetView(aPresContext, &newParentView);
|
|
|
|
} while (!(oldParentView || newParentView));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// See if we found a common parent frame
|
|
|
|
if (aOldParentFrame == aNewParentFrame) {
|
|
|
|
// We found a common parent and there are no views between the old parent
|
|
|
|
// and the common parent or the new parent frame and the common parent.
|
|
|
|
// Because neither the old parent frame nor the new parent frame have views,
|
|
|
|
// then any child views don't need reparenting
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We found views for one or both of the parent frames before we found a
|
|
|
|
// common parent
|
|
|
|
NS_ASSERTION(oldParentView || newParentView, "internal error");
|
|
|
|
if (!oldParentView) {
|
|
|
|
oldParentView = GetClosestViewFor(aPresContext, aOldParentFrame);
|
|
|
|
}
|
|
|
|
if (!newParentView) {
|
|
|
|
newParentView = GetClosestViewFor(aPresContext, aNewParentFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the old parent frame and the new parent frame are in the
|
|
|
|
// same view sub-hierarchy. If they are then we don't have to do
|
|
|
|
// anything
|
|
|
|
if (oldParentView != newParentView) {
|
|
|
|
nsCOMPtr<nsIViewManager> viewManager;
|
|
|
|
oldParentView->GetViewManager(*getter_AddRefs(viewManager));
|
|
|
|
|
|
|
|
// They're not so we need to reparent any child views
|
|
|
|
for (nsIFrame* f = aChildFrameList; f; f->GetNextSibling(&f)) {
|
|
|
|
ReparentFrameViewTo(aPresContext, f, viewManager, newParentView,
|
|
|
|
oldParentView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-25 08:43:11 +04:00
|
|
|
static PRBool
|
|
|
|
IsContainerContent(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIContent* content;
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
aFrame->GetContent(&content);
|
|
|
|
if (content) {
|
|
|
|
content->CanContainChildren(result);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-09-23 06:29:31 +04:00
|
|
|
nsresult
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
|
1998-09-23 06:29:31 +04:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIStyleContext* aStyleContext,
|
2000-08-12 23:44:11 +04:00
|
|
|
nsIFrame* aContentParentFrame,
|
1998-09-23 06:29:31 +04:00
|
|
|
PRBool aForce)
|
|
|
|
{
|
|
|
|
nsIView* view;
|
1999-11-24 09:03:41 +03:00
|
|
|
aFrame->GetView(aPresContext, &view);
|
1998-12-04 22:03:44 +03:00
|
|
|
// If we don't yet have a view, see if we need a view
|
1998-09-23 06:29:31 +04:00
|
|
|
if (nsnull == view) {
|
1999-04-22 01:27:50 +04:00
|
|
|
PRBool fixedBackgroundAttachment = PR_FALSE;
|
1998-10-23 21:54:23 +04:00
|
|
|
|
1998-12-04 22:03:44 +03:00
|
|
|
// Get nsStyleColor and nsStyleDisplay
|
|
|
|
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
|
|
|
aStyleContext->GetStyleData(eStyleStruct_Display);
|
2000-08-12 23:44:11 +04:00
|
|
|
const nsStylePosition* position = (const nsStylePosition*)
|
|
|
|
aStyleContext->GetStyleData(eStyleStruct_Position);
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis = (const nsStyleVisibility*)
|
|
|
|
aStyleContext->GetStyleData(eStyleStruct_Visibility);
|
2000-08-12 23:44:11 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (vis->mOpacity != 1.0f) {
|
1998-10-23 21:54:23 +04:00
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsHTMLContainerFrame::CreateViewForFrame: frame=%p opacity=%g",
|
2001-06-01 02:19:43 +04:00
|
|
|
aFrame, vis->mOpacity));
|
1998-10-23 21:54:23 +04:00
|
|
|
aForce = PR_TRUE;
|
1998-09-23 06:29:31 +04:00
|
|
|
}
|
|
|
|
|
1999-04-22 02:08:01 +04:00
|
|
|
// See if the frame has a fixed background attachment
|
2002-01-08 02:46:07 +03:00
|
|
|
const nsStyleBackground *color;
|
|
|
|
PRBool isCanvas;
|
|
|
|
PRBool hasBackground =
|
|
|
|
nsCSSRendering::FindBackground(aPresContext, aFrame, &color, &isCanvas);
|
|
|
|
if (hasBackground &&
|
|
|
|
NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) {
|
1999-04-22 02:08:01 +04:00
|
|
|
aForce = PR_TRUE;
|
|
|
|
fixedBackgroundAttachment = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-04 22:03:44 +03:00
|
|
|
// See if the frame is being relatively positioned or absolutely
|
|
|
|
// positioned
|
1998-09-23 06:29:31 +04:00
|
|
|
if (!aForce) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
|
1998-09-23 06:29:31 +04:00
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsHTMLContainerFrame::CreateViewForFrame: frame=%p relatively positioned",
|
2000-08-12 23:44:11 +04:00
|
|
|
aFrame));
|
1998-09-23 06:29:31 +04:00
|
|
|
aForce = PR_TRUE;
|
2001-06-01 02:19:43 +04:00
|
|
|
} else if (display->IsAbsolutelyPositioned()) {
|
1998-12-04 22:03:44 +03:00
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
2000-08-12 23:44:11 +04:00
|
|
|
("nsHTMLContainerFrame::CreateViewForFrame: frame=%p absolutely positioned",
|
|
|
|
aFrame));
|
1998-12-04 22:03:44 +03:00
|
|
|
aForce = PR_TRUE;
|
1998-09-23 06:29:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-04 08:56:06 +03:00
|
|
|
// See if the frame is a scrolled frame
|
|
|
|
if (!aForce) {
|
|
|
|
nsIAtom* pseudoTag;
|
|
|
|
aStyleContext->GetPseudoType(pseudoTag);
|
1999-08-08 05:15:30 +04:00
|
|
|
if (pseudoTag == nsLayoutAtoms::scrolledContentPseudo) {
|
1998-12-04 22:03:44 +03:00
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsHTMLContainerFrame::CreateViewForFrame: scrolled frame=%p", aFrame));
|
1998-12-04 08:56:06 +03:00
|
|
|
aForce = PR_TRUE;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(pseudoTag);
|
|
|
|
}
|
|
|
|
|
2000-04-25 08:43:11 +04:00
|
|
|
// See if the frame is block-level and has 'overflow' set to 'hidden'. If
|
|
|
|
// so and it can have child frames, then we need to give it a view so clipping
|
|
|
|
// of any child views works correctly. Note that if it's floated it is also
|
|
|
|
// block-level, but we can't trust that the style context 'display' value is
|
|
|
|
// set correctly
|
|
|
|
if (!aForce) {
|
|
|
|
if ((display->IsBlockLevel() || display->IsFloating()) &&
|
|
|
|
(display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) {
|
|
|
|
|
|
|
|
// The reason for the check of whether it can contain children is just
|
|
|
|
// to avoid giving it a view unnecessarily
|
|
|
|
if (::IsContainerContent(aFrame)) {
|
|
|
|
// XXX Check for the frame being a block frame and only force a view
|
|
|
|
// in that case, because adding a view for box frames seems to cause
|
|
|
|
// problems for XUL...
|
|
|
|
nsIAtom* frameType;
|
|
|
|
|
|
|
|
aFrame->GetFrameType(&frameType);
|
|
|
|
if ((frameType == nsLayoutAtoms::blockFrame) ||
|
|
|
|
(frameType == nsLayoutAtoms::areaFrame)) {
|
|
|
|
aForce = PR_TRUE;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-23 06:29:31 +04:00
|
|
|
if (aForce) {
|
|
|
|
// Create a view
|
2000-08-12 23:44:11 +04:00
|
|
|
nsIFrame* parent = nsnull;
|
|
|
|
nsIView* parentView = nsnull;
|
1998-09-23 06:29:31 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
aFrame->GetParentWithView(aPresContext, &parent);
|
1998-09-23 06:29:31 +04:00
|
|
|
NS_ASSERTION(parent, "GetParentWithView failed");
|
1999-11-24 09:03:41 +03:00
|
|
|
parent->GetView(aPresContext, &parentView);
|
1998-12-18 08:25:36 +03:00
|
|
|
NS_ASSERTION(parentView, "no parent with view");
|
1998-09-23 06:29:31 +04:00
|
|
|
|
|
|
|
// Create a view
|
2001-10-25 05:08:40 +04:00
|
|
|
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
|
1998-09-23 06:29:31 +04:00
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult result = nsComponentManager::CreateInstance(kViewCID,
|
1998-09-23 06:29:31 +04:00
|
|
|
nsnull,
|
2001-01-04 23:44:42 +03:00
|
|
|
NS_GET_IID(nsIView),
|
1998-09-23 06:29:31 +04:00
|
|
|
(void **)&view);
|
|
|
|
if (NS_OK == result) {
|
|
|
|
nsIViewManager* viewManager;
|
1998-12-18 08:25:36 +03:00
|
|
|
parentView->GetViewManager(viewManager);
|
1998-09-23 06:29:31 +04:00
|
|
|
NS_ASSERTION(nsnull != viewManager, "null view manager");
|
|
|
|
|
1998-12-18 08:25:36 +03:00
|
|
|
// Initialize the view
|
1998-09-23 06:29:31 +04:00
|
|
|
nsRect bounds;
|
|
|
|
aFrame->GetRect(bounds);
|
1998-12-18 08:25:36 +03:00
|
|
|
view->Init(viewManager, bounds, parentView);
|
|
|
|
|
1999-04-22 02:08:01 +04:00
|
|
|
// If the frame has a fixed background attachment, then indicate that the
|
1999-09-27 00:40:29 +04:00
|
|
|
// view's contents should be repainted and not bitblt'd
|
1999-04-24 08:53:42 +04:00
|
|
|
if (fixedBackgroundAttachment) {
|
2001-12-01 17:31:45 +03:00
|
|
|
viewManager->SetViewBitBltEnabled(view, PR_FALSE);
|
1999-04-24 08:53:42 +04:00
|
|
|
}
|
1999-04-22 02:08:01 +04:00
|
|
|
|
1998-12-18 08:25:36 +03:00
|
|
|
// Insert the view into the view hierarchy. If the parent view is a
|
|
|
|
// scrolling view we need to do this differently
|
|
|
|
nsIScrollableView* scrollingView;
|
2001-01-04 23:44:42 +03:00
|
|
|
if (NS_SUCCEEDED(parentView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) {
|
1998-12-18 08:25:36 +03:00
|
|
|
scrollingView->SetScrolledView(view);
|
|
|
|
} else {
|
2000-08-12 23:44:11 +04:00
|
|
|
PRInt32 zIndex = 0;
|
|
|
|
PRBool autoZIndex = PR_FALSE;
|
|
|
|
|
|
|
|
// Get the z-index to use
|
|
|
|
if (position->mZIndex.GetUnit() == eStyleUnit_Integer) {
|
|
|
|
zIndex = position->mZIndex.GetIntValue();
|
|
|
|
} else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) {
|
|
|
|
autoZIndex = PR_TRUE;
|
|
|
|
}
|
2001-12-01 17:31:45 +03:00
|
|
|
|
|
|
|
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
|
|
|
|
// XXX Drop it at the end of the document order until we can do better
|
|
|
|
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
|
2000-08-12 23:44:11 +04:00
|
|
|
|
|
|
|
if (nsnull != aContentParentFrame) {
|
|
|
|
// If, for some reason, GetView below fails to initialize zParentView,
|
|
|
|
// then ensure that we completely bypass InsertZPlaceholder below.
|
|
|
|
// The effect will be as if we never knew about aContentParentFrame
|
|
|
|
// in the first place, so at least this code won't be doing any damage.
|
|
|
|
nsIView* zParentView = parentView;
|
|
|
|
|
|
|
|
aContentParentFrame->GetView(aPresContext, &zParentView);
|
|
|
|
|
|
|
|
if (nsnull == zParentView) {
|
|
|
|
nsIFrame* zParentFrame = nsnull;
|
|
|
|
|
|
|
|
aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame);
|
|
|
|
NS_ASSERTION(zParentFrame, "GetParentWithView failed");
|
|
|
|
zParentFrame->GetView(aPresContext, &zParentView);
|
|
|
|
NS_ASSERTION(zParentView, "no parent with view");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zParentView != parentView) {
|
2001-12-01 17:31:45 +03:00
|
|
|
viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE);
|
2000-08-12 23:44:11 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-18 08:25:36 +03:00
|
|
|
}
|
|
|
|
|
1999-09-27 00:40:29 +04:00
|
|
|
// See if the view should be hidden
|
|
|
|
PRBool viewIsVisible = PR_TRUE;
|
2002-01-08 02:46:07 +03:00
|
|
|
PRBool viewHasTransparentContent =
|
|
|
|
!isCanvas &&
|
|
|
|
(!hasBackground ||
|
|
|
|
(color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT));
|
|
|
|
|
1999-09-27 00:40:29 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) {
|
1999-09-29 07:37:02 +04:00
|
|
|
viewIsVisible = PR_FALSE;
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
else if (NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) {
|
1999-09-29 07:37:02 +04:00
|
|
|
// If it has a widget, hide the view because the widget can't deal with it
|
|
|
|
nsIWidget* widget = nsnull;
|
|
|
|
view->GetWidget(widget);
|
|
|
|
if (widget) {
|
|
|
|
viewIsVisible = PR_FALSE;
|
|
|
|
NS_RELEASE(widget);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If it's a container element, then leave the view visible, but
|
|
|
|
// mark it as having transparent content. The reason we need to
|
|
|
|
// do this is that child elements can override their parent's
|
2000-04-25 08:43:11 +04:00
|
|
|
// hidden visibility and be visible anyway.
|
|
|
|
//
|
1999-09-29 07:37:02 +04:00
|
|
|
// Because this function is called before processing the content
|
|
|
|
// object's child elements, we can't tell if it's a leaf by looking
|
|
|
|
// at whether the frame has any child frames
|
2000-04-25 08:43:11 +04:00
|
|
|
if (::IsContainerContent(aFrame)) {
|
|
|
|
// The view needs to be visible, but marked as having transparent
|
|
|
|
// content
|
|
|
|
viewHasTransparentContent = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
// Go ahead and hide the view
|
|
|
|
viewIsVisible = PR_FALSE;
|
1999-09-27 00:40:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewIsVisible) {
|
|
|
|
if (viewHasTransparentContent) {
|
|
|
|
viewManager->SetViewContentTransparency(view, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2001-12-01 17:31:45 +03:00
|
|
|
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
|
1998-10-15 01:31:41 +04:00
|
|
|
}
|
1999-05-20 02:14:11 +04:00
|
|
|
|
1999-09-15 08:16:31 +04:00
|
|
|
// XXX If it's fixed positioned, then create a widget so it floats
|
|
|
|
// above the scrolling area
|
2001-06-01 02:19:43 +04:00
|
|
|
if (NS_STYLE_POSITION_FIXED == display->mPosition) {
|
1999-12-01 08:10:50 +03:00
|
|
|
view->CreateWidget(kCChildCID);
|
1999-01-28 20:14:13 +03:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
viewManager->SetViewOpacity(view, vis->mOpacity);
|
1998-09-23 06:29:31 +04:00
|
|
|
NS_RELEASE(viewManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remember our view
|
1999-11-24 09:03:41 +03:00
|
|
|
aFrame->SetView(aPresContext, view);
|
1998-09-23 06:29:31 +04:00
|
|
|
|
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsHTMLContainerFrame::CreateViewForFrame: frame=%p view=%p",
|
|
|
|
aFrame));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-04-28 11:53:41 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
nsHTMLContainerFrame::CheckInvalidateBorder(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
// XXX This method ought to deal with padding as well
|
|
|
|
// If this is a style change reflow targeted at this frame, we must repaint
|
|
|
|
// everything (well, we really just have to repaint the borders but we're
|
|
|
|
// a bunch of lazybones).
|
|
|
|
if (aReflowState.reason == eReflowReason_Incremental) {
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand *command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command) {
|
2002-04-28 11:53:41 +04:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetType(type);
|
2002-04-28 11:53:41 +04:00
|
|
|
if (type == eReflowType_StyleChanged) {
|
|
|
|
|
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
|
|
|
printf("%p invalidate 1 (%d, %d, %d, %d)\n",
|
|
|
|
this, 0, 0, mRect.width, mRect.height);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Lots of things could have changed so damage our entire bounds
|
|
|
|
nsRect damageRect(0, 0, mRect.width, mRect.height);
|
|
|
|
if (!damageRect.IsEmpty()) {
|
|
|
|
Invalidate(aPresContext,damageRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we changed size, we must invalidate the parts of us that have changed
|
|
|
|
// to make the border show up.
|
|
|
|
if ((aReflowState.reason == eReflowReason_Incremental ||
|
|
|
|
aReflowState.reason == eReflowReason_Dirty)) {
|
|
|
|
nsMargin border = aReflowState.mComputedBorderPadding -
|
|
|
|
aReflowState.mComputedPadding;
|
|
|
|
|
|
|
|
// See if our width changed
|
|
|
|
if ((aDesiredSize.width != mRect.width) && (border.right > 0)) {
|
|
|
|
nsRect damageRect;
|
|
|
|
|
|
|
|
if (aDesiredSize.width < mRect.width) {
|
|
|
|
// Our new width is smaller, so we need to make sure that
|
|
|
|
// we paint our border in its new position
|
|
|
|
damageRect.x = aDesiredSize.width - border.right;
|
|
|
|
damageRect.width = border.right;
|
|
|
|
damageRect.y = 0;
|
|
|
|
damageRect.height = aDesiredSize.height;
|
|
|
|
} else {
|
|
|
|
// Our new width is larger, so we need to erase our border in its
|
|
|
|
// old position
|
|
|
|
damageRect.x = mRect.width - border.right;
|
|
|
|
damageRect.width = border.right;
|
|
|
|
damageRect.y = 0;
|
|
|
|
damageRect.height = mRect.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
|
|
|
printf("%p invalidate 2 (%d, %d, %d, %d)\n",
|
|
|
|
this, damageRect.x, damageRect.y, damageRect.width, damageRect.height);
|
|
|
|
#endif
|
|
|
|
if (!damageRect.IsEmpty()) {
|
|
|
|
Invalidate(aPresContext, damageRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if our height changed
|
|
|
|
if ((aDesiredSize.height != mRect.height) && (border.bottom > 0)) {
|
|
|
|
nsRect damageRect;
|
|
|
|
|
|
|
|
if (aDesiredSize.height < mRect.height) {
|
|
|
|
// Our new height is smaller, so we need to make sure that
|
|
|
|
// we paint our border in its new position
|
|
|
|
damageRect.x = 0;
|
|
|
|
damageRect.width = aDesiredSize.width;
|
|
|
|
damageRect.y = aDesiredSize.height - border.bottom;
|
|
|
|
damageRect.height = border.bottom;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Our new height is larger, so we need to erase our border in its
|
|
|
|
// old position
|
|
|
|
damageRect.x = 0;
|
|
|
|
damageRect.width = mRect.width;
|
|
|
|
damageRect.y = mRect.height - border.bottom;
|
|
|
|
damageRect.height = border.bottom;
|
|
|
|
}
|
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
|
|
|
printf("%p invalidate 3 (%d, %d, %d, %d)\n",
|
|
|
|
this, damageRect.x, damageRect.y, damageRect.width, damageRect.height);
|
|
|
|
#endif
|
|
|
|
if (!damageRect.IsEmpty()) {
|
|
|
|
Invalidate(aPresContext, damageRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|