2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-01-26 00:05:21 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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/
|
1999-01-26 00:05:21 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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.
|
1999-01-26 00:05:21 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* rendering object that is the root of the frame tree, which contains
|
|
|
|
* the document's scrollbars and contains fixed-positioned elements
|
|
|
|
*/
|
|
|
|
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2003-01-20 18:04:34 +00:00
|
|
|
#include "nsViewportFrame.h"
|
1999-01-28 17:14:13 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2001-04-17 01:45:38 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2006-04-27 02:45:03 +00:00
|
|
|
#include "nsDisplayList.h"
|
1999-01-26 00:05:21 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewViewportFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-01-26 00:05:21 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) ViewportFrame(aContext);
|
1999-01-26 00:05:21 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ViewportFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
return Super::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
|
|
|
ViewportFrame::Destroy()
|
1999-01-28 17:14:13 +00:00
|
|
|
{
|
2006-04-10 00:16:29 +00:00
|
|
|
mFixedContainer.DestroyFrames(this);
|
|
|
|
nsContainerFrame::Destroy();
|
1999-01-28 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-10 00:16:29 +00:00
|
|
|
ViewportFrame::SetInitialChildList(nsIAtom* aListName,
|
1999-01-28 17:14:13 +00:00
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
2003-01-20 18:04:34 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-01-28 17:14:13 +00:00
|
|
|
|
1999-07-24 03:59:47 +00:00
|
|
|
// See which child list to add the frames to
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aChildList);
|
|
|
|
#endif
|
2003-01-20 18:04:34 +00:00
|
|
|
if (mFixedContainer.GetChildListName() == aListName) {
|
2006-04-10 00:16:29 +00:00
|
|
|
rv = mFixedContainer.SetInitialChildList(this, aListName, aChildList);
|
2003-01-20 18:04:34 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-04-10 00:16:29 +00:00
|
|
|
rv = nsContainerFrame::SetInitialChildList(aListName, aChildList);
|
1999-01-28 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-22 02:43:08 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
// We don't need any special painting or event handling. We just need to
|
|
|
|
// mark our visible out-of-flow frames (i.e., the fixed position frames) so
|
|
|
|
// that display list construction is guaranteed to recurse into their
|
|
|
|
// ancestors.
|
2006-04-27 02:45:03 +00:00
|
|
|
aBuilder->MarkFramesForDisplayList(this, mFixedContainer.GetFirstChild(), aDirtyRect);
|
|
|
|
|
2006-02-05 20:52:13 +00:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
2006-04-27 02:45:03 +00:00
|
|
|
if (!kid)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// make the kid's BorderBackground our own. This ensures that the canvas
|
|
|
|
// frame's background becomes our own background and therefore appears
|
|
|
|
// below negative z-index elements.
|
|
|
|
return BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
|
2000-03-22 02:43:08 +00:00
|
|
|
}
|
|
|
|
|
1999-07-24 03:59:47 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
ViewportFrame::AppendFrames(nsIAtom* aListName,
|
1999-07-24 03:59:47 +00:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2003-01-20 18:04:34 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (mFixedContainer.GetChildListName() == aListName) {
|
2005-02-07 01:58:25 +00:00
|
|
|
rv = mFixedContainer.AppendFrames(this, aListName, aFrameList);
|
2003-01-20 18:04:34 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-07-27 14:15:42 +00:00
|
|
|
// We only expect incremental changes for our fixed frames
|
2003-01-20 18:04:34 +00:00
|
|
|
NS_ERROR("unexpected child list");
|
1999-07-27 14:15:42 +00:00
|
|
|
rv = NS_ERROR_INVALID_ARG;
|
1999-07-24 03:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
ViewportFrame::InsertFrames(nsIAtom* aListName,
|
2003-01-20 18:04:34 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
1999-07-24 03:59:47 +00:00
|
|
|
{
|
2003-01-20 18:04:34 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-07-24 03:59:47 +00:00
|
|
|
|
2003-01-20 18:04:34 +00:00
|
|
|
if (mFixedContainer.GetChildListName() == aListName) {
|
2005-02-07 01:58:25 +00:00
|
|
|
rv = mFixedContainer.InsertFrames(this, aListName, aPrevFrame, aFrameList);
|
2003-01-20 18:04:34 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-07-27 14:15:42 +00:00
|
|
|
// We only expect incremental changes for our fixed frames
|
2003-01-20 18:04:34 +00:00
|
|
|
NS_ERROR("unexpected child list");
|
1999-07-27 14:15:42 +00:00
|
|
|
rv = NS_ERROR_INVALID_ARG;
|
1999-07-24 03:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
ViewportFrame::RemoveFrame(nsIAtom* aListName,
|
2003-01-20 18:04:34 +00:00
|
|
|
nsIFrame* aOldFrame)
|
1999-07-24 03:59:47 +00:00
|
|
|
{
|
2003-01-20 18:04:34 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-07-27 14:15:42 +00:00
|
|
|
|
2003-01-20 18:04:34 +00:00
|
|
|
if (mFixedContainer.GetChildListName() == aListName) {
|
2005-02-07 01:58:25 +00:00
|
|
|
rv = mFixedContainer.RemoveFrame(this, aListName, aOldFrame);
|
2003-01-20 18:04:34 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-07-27 14:15:42 +00:00
|
|
|
// We only expect incremental changes for our fixed frames
|
2003-01-20 18:04:34 +00:00
|
|
|
NS_ERROR("unexpected child list");
|
1999-07-27 14:15:42 +00:00
|
|
|
rv = NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1999-07-24 03:59:47 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIAtom*
|
|
|
|
ViewportFrame::GetAdditionalChildListName(PRInt32 aIndex) const
|
1999-01-28 17:14:13 +00:00
|
|
|
{
|
2004-01-09 14:20:53 +00:00
|
|
|
NS_PRECONDITION(aIndex >= 0, "illegal index");
|
1999-01-28 17:14:13 +00:00
|
|
|
|
2003-01-20 18:04:34 +00:00
|
|
|
if (0 == aIndex) {
|
2004-01-09 14:20:53 +00:00
|
|
|
return mFixedContainer.GetChildListName();
|
1999-01-28 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
return nsnull;
|
1999-01-28 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame*
|
|
|
|
ViewportFrame::GetFirstChild(nsIAtom* aListName) const
|
1999-01-28 17:14:13 +00:00
|
|
|
{
|
2003-01-20 18:04:34 +00:00
|
|
|
if (mFixedContainer.GetChildListName() == aListName) {
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame* result = nsnull;
|
|
|
|
mFixedContainer.FirstChild(this, aListName, &result);
|
|
|
|
return result;
|
1999-01-28 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
return nsContainerFrame::GetFirstChild(aListName);
|
1999-01-28 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nscoord
|
|
|
|
ViewportFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = mFrames.FirstChild()->GetMinWidth(aRenderingContext);
|
|
|
|
|
|
|
|
// XXXldb Deal with mFixedContainer (matters for SizeToContent)!
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
|
|
|
ViewportFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = mFrames.FirstChild()->GetPrefWidth(aRenderingContext);
|
|
|
|
|
|
|
|
// XXXldb Deal with mFixedContainer (matters for SizeToContent)!
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-01-09 19:21:20 +00:00
|
|
|
nsPoint
|
|
|
|
ViewportFrame::AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) const
|
1999-02-03 17:01:51 +00:00
|
|
|
{
|
2002-05-14 01:44:00 +00:00
|
|
|
// Calculate how much room is available for fixed frames. That means
|
|
|
|
// determining if the viewport is scrollable and whether the vertical and/or
|
|
|
|
// horizontal scrollbars are visible
|
1999-02-03 17:01:51 +00:00
|
|
|
|
|
|
|
// Get our prinicpal child frame and see if we're scrollable
|
|
|
|
nsIFrame* kidFrame = mFrames.FirstChild();
|
2001-04-17 01:45:38 +00:00
|
|
|
nsCOMPtr<nsIScrollableFrame> scrollingFrame(do_QueryInterface(kidFrame));
|
|
|
|
|
|
|
|
if (scrollingFrame) {
|
2004-01-09 19:21:20 +00:00
|
|
|
nsMargin scrollbars = scrollingFrame->GetActualScrollbarSizes();
|
2007-01-26 00:05:12 +00:00
|
|
|
aReflowState->SetComputedWidth(aReflowState->ComputedWidth() -
|
|
|
|
(scrollbars.left + scrollbars.right));
|
2004-01-09 19:21:20 +00:00
|
|
|
aReflowState->availableWidth -= scrollbars.left + scrollbars.right;
|
|
|
|
aReflowState->mComputedHeight -= scrollbars.top + scrollbars.bottom;
|
|
|
|
// XXX why don't we also adjust "aReflowState->availableHeight"?
|
|
|
|
return nsPoint(scrollbars.left, scrollbars.top);
|
1999-02-03 17:01:51 +00:00
|
|
|
}
|
2004-01-09 19:21:20 +00:00
|
|
|
return nsPoint(0, 0);
|
1999-02-03 17:01:51 +00:00
|
|
|
}
|
|
|
|
|
1999-01-26 00:05:21 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
ViewportFrame::Reflow(nsPresContext* aPresContext,
|
1999-01-26 00:05:21 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("ViewportFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1999-01-26 00:05:21 +00:00
|
|
|
NS_FRAME_TRACE_REFLOW_IN("ViewportFrame::Reflow");
|
|
|
|
|
2003-01-20 18:04:34 +00:00
|
|
|
// Initialize OUT parameters
|
1999-01-26 00:05:21 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Because |Reflow| sets mComputedHeight on the child to
|
|
|
|
// availableHeight.
|
|
|
|
AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
|
|
|
|
|
2003-02-22 20:13:12 +00:00
|
|
|
// Reflow the main content first so that the placeholders of the
|
|
|
|
// fixed-position frames will be in the right places on an initial
|
|
|
|
// reflow.
|
1999-07-04 04:09:54 +00:00
|
|
|
nsRect kidRect(0,0,aReflowState.availableWidth,aReflowState.availableHeight);
|
|
|
|
|
2003-02-22 20:13:12 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2002-05-10 18:22:41 +00:00
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
// Deal with a non-incremental reflow or an incremental reflow
|
|
|
|
// targeted at our one-and-only principal child frame.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (aReflowState.ShouldReflowAllKids() ||
|
|
|
|
aReflowState.mFlags.mVResize ||
|
|
|
|
(mFrames.FirstChild()->GetStateBits() &
|
|
|
|
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN))) {
|
2002-05-10 18:22:41 +00:00
|
|
|
// Reflow our one-and-only principal child frame
|
|
|
|
nsIFrame* kidFrame = mFrames.FirstChild();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize;
|
2002-05-10 18:22:41 +00:00
|
|
|
nsSize availableSpace(aReflowState.availableWidth,
|
|
|
|
aReflowState.availableHeight);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
kidFrame, availableSpace);
|
|
|
|
|
|
|
|
// Reflow the frame
|
|
|
|
kidReflowState.mComputedHeight = aReflowState.availableHeight;
|
2003-01-20 18:04:34 +00:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
|
|
|
0, 0, 0, aStatus);
|
2002-05-10 18:22:41 +00:00
|
|
|
kidRect.width = kidDesiredSize.width;
|
|
|
|
kidRect.height = kidDesiredSize.height;
|
|
|
|
|
|
|
|
FinishReflowChild(kidFrame, aPresContext, nsnull, kidDesiredSize, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ASSERTION(aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"shouldn't happen anymore");
|
|
|
|
|
|
|
|
// Return the max size as our desired size
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
// Being flowed initially at an unconstrained height means we should
|
|
|
|
// return our child's intrinsic size.
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE
|
|
|
|
? aReflowState.availableHeight
|
|
|
|
: kidRect.height;
|
1999-01-26 00:05:21 +00:00
|
|
|
|
2003-02-22 20:13:12 +00:00
|
|
|
// Make a copy of the reflow state and change the computed width and height
|
|
|
|
// to reflect the available space for the fixed items
|
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
2004-01-09 19:21:20 +00:00
|
|
|
nsPoint offset = AdjustReflowStateForScrollbars(&reflowState);
|
2003-02-22 20:13:12 +00:00
|
|
|
|
2004-01-09 19:21:20 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsIFrame* f;
|
2006-12-26 17:47:52 +00:00
|
|
|
mFixedContainer.FirstChild(this, nsGkAtoms::fixedList, &f);
|
2004-01-09 19:21:20 +00:00
|
|
|
NS_ASSERTION(!f || (offset.x == 0 && offset.y == 0),
|
|
|
|
"We don't handle correct positioning of fixed frames with "
|
|
|
|
"scrollbars in odd positions");
|
|
|
|
#endif
|
|
|
|
|
2004-11-14 20:22:58 +00:00
|
|
|
// Just reflow all the fixed-pos frames.
|
|
|
|
rv = mFixedContainer.Reflow(this, aPresContext, reflowState,
|
2007-01-26 00:05:12 +00:00
|
|
|
reflowState.ComputedWidth(),
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
reflowState.mComputedHeight,
|
|
|
|
PR_TRUE, PR_TRUE); // XXX could be optimized
|
2003-02-22 20:13:12 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// If we were dirty then do a repaint
|
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
2003-01-20 18:04:34 +00:00
|
|
|
nsRect damageRect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
2004-03-10 03:09:05 +00:00
|
|
|
Invalidate(damageRect, PR_FALSE);
|
1999-07-24 15:18:24 +00:00
|
|
|
}
|
|
|
|
|
2007-01-25 02:01:07 +00:00
|
|
|
// XXX Should we do something to clip our children to this?
|
|
|
|
aDesiredSize.mOverflowArea =
|
|
|
|
nsRect(nsPoint(0, 0), nsSize(aDesiredSize.width, aDesiredSize.height));
|
|
|
|
|
1999-01-26 00:05:21 +00:00
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus);
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2003-01-20 18:04:34 +00:00
|
|
|
return rv;
|
1999-01-26 00:05:21 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
ViewportFrame::GetType() const
|
1999-02-14 03:47:33 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::viewportFrame;
|
1999-02-14 03:47:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-12 04:40:17 +00:00
|
|
|
/* virtual */ PRBool
|
|
|
|
ViewportFrame::IsContainingBlock() const
|
2002-11-25 23:40:58 +00:00
|
|
|
{
|
2004-03-12 04:40:17 +00:00
|
|
|
return PR_TRUE;
|
2002-11-25 23:40:58 +00:00
|
|
|
}
|
|
|
|
|
2006-06-08 01:11:43 +00:00
|
|
|
void
|
|
|
|
ViewportFrame::InvalidateInternal(const nsRect& aDamageRect,
|
|
|
|
nscoord aX, nscoord aY, nsIFrame* aForChild,
|
|
|
|
PRBool aImmediate)
|
|
|
|
{
|
|
|
|
nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrame(this);
|
|
|
|
if (parent) {
|
|
|
|
nsPoint pt = GetOffsetTo(parent);
|
|
|
|
parent->InvalidateInternal(aDamageRect, aX + pt.x, aY + pt.y, this, aImmediate);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
InvalidateRoot(aDamageRect, aX, aY, aImmediate);
|
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1999-01-26 00:05:21 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
ViewportFrame::GetFrameName(nsAString& aResult) const
|
1999-01-26 00:05:21 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Viewport"), aResult);
|
1999-01-26 00:05:21 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|