2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* rendering object for the point that anchors out-of-flow rendering
|
|
|
|
* objects such as floats and absolutely positioned elements
|
|
|
|
*/
|
|
|
|
|
2006-11-06 01:17:32 +00:00
|
|
|
/*
|
|
|
|
* Destruction of a placeholder and its out-of-flow must observe the
|
|
|
|
* following constraints:
|
|
|
|
*
|
|
|
|
* - The mapping from the out-of-flow to the placeholder must be
|
|
|
|
* removed from the frame manager before the placeholder is destroyed.
|
|
|
|
* - The mapping from the out-of-flow to the placeholder must be
|
|
|
|
* removed from the frame manager before the out-of-flow is destroyed.
|
|
|
|
* - The placeholder must be removed from the frame tree, or have the
|
|
|
|
* mapping from it to its out-of-flow cleared, before the out-of-flow
|
|
|
|
* is destroyed (so that the placeholder will not point to a destroyed
|
|
|
|
* frame while it's in the frame tree).
|
|
|
|
*
|
2009-12-24 05:20:41 +00:00
|
|
|
* Furthermore, some code assumes that placeholders point to something
|
|
|
|
* useful, so placeholders without an associated out-of-flow should not
|
|
|
|
* remain in the tree.
|
2006-11-06 01:17:32 +00:00
|
|
|
*
|
2009-12-24 05:20:41 +00:00
|
|
|
* The placeholder's Destroy() implementation handles the destruction of
|
|
|
|
* the placeholder and its out-of-flow. To avoid crashes, frame removal
|
|
|
|
* and destruction code that works with placeholders must not assume
|
|
|
|
* that the placeholder points to its out-of-flow.
|
2006-11-06 01:17:32 +00:00
|
|
|
*/
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#ifndef nsPlaceholderFrame_h___
|
|
|
|
#define nsPlaceholderFrame_h___
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-08-31 18:25:35 +00:00
|
|
|
#include "nsFrame.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2009-11-16 21:00:07 +00:00
|
|
|
nsIFrame* NS_NewPlaceholderFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
nsFrameState aTypeBit);
|
|
|
|
|
2010-06-09 05:28:14 +00:00
|
|
|
#define PLACEHOLDER_TYPE_MASK (PLACEHOLDER_FOR_FLOAT | \
|
|
|
|
PLACEHOLDER_FOR_ABSPOS | \
|
|
|
|
PLACEHOLDER_FOR_FIXEDPOS | \
|
|
|
|
PLACEHOLDER_FOR_POPUP)
|
2002-01-10 14:16:05 +00:00
|
|
|
|
1998-11-14 19:26:57 +00:00
|
|
|
/**
|
1999-04-23 14:34:48 +00:00
|
|
|
* Implementation of a frame that's used as a placeholder for a frame that
|
2013-02-11 02:28:50 +00:00
|
|
|
* has been moved out of the flow.
|
1998-11-14 19:26:57 +00:00
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsPlaceholderFrame final : public nsFrame {
|
1998-04-13 20:24:54 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2014-01-18 07:08:22 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsPlaceholderFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
#endif
|
2009-09-12 16:49:24 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
/**
|
2009-11-16 21:00:07 +00:00
|
|
|
* Create a new placeholder frame. aTypeBit must be one of the
|
|
|
|
* PLACEHOLDER_FOR_* constants above.
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
2009-11-16 21:00:07 +00:00
|
|
|
friend nsIFrame* NS_NewPlaceholderFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
nsFrameState aTypeBit);
|
2013-02-11 02:28:50 +00:00
|
|
|
nsPlaceholderFrame(nsStyleContext* aContext, nsFrameState aTypeBit)
|
|
|
|
: nsFrame(aContext)
|
2009-11-16 21:00:07 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aTypeBit == PLACEHOLDER_FOR_FLOAT ||
|
|
|
|
aTypeBit == PLACEHOLDER_FOR_ABSPOS ||
|
|
|
|
aTypeBit == PLACEHOLDER_FOR_FIXEDPOS ||
|
|
|
|
aTypeBit == PLACEHOLDER_FOR_POPUP,
|
|
|
|
"Unexpected type bit");
|
|
|
|
AddStateBits(aTypeBit);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-04-23 14:34:48 +00:00
|
|
|
// Get/Set the associated out of flow frame
|
2013-02-11 02:28:50 +00:00
|
|
|
nsIFrame* GetOutOfFlowFrame() const { return mOutOfFlowFrame; }
|
2009-08-31 18:25:35 +00:00
|
|
|
void SetOutOfFlowFrame(nsIFrame* aFrame) {
|
|
|
|
NS_ASSERTION(!aFrame || !aFrame->GetPrevContinuation(),
|
|
|
|
"OOF must be first continuation");
|
|
|
|
mOutOfFlowFrame = aFrame;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2013-02-11 02:28:50 +00:00
|
|
|
// nsIFrame overrides
|
|
|
|
// We need to override GetMinSize and GetPrefSize because XUL uses
|
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
|
|
|
// placeholders not within lines.
|
2014-07-24 17:03:25 +00:00
|
|
|
virtual void AddInlineMinISize(nsRenderingContext* aRenderingContext,
|
2015-03-21 16:28:04 +00:00
|
|
|
InlineMinISizeData* aData) override;
|
2014-07-24 17:03:25 +00:00
|
|
|
virtual void AddInlinePrefISize(nsRenderingContext* aRenderingContext,
|
2015-03-21 16:28:04 +00:00
|
|
|
InlinePrefISizeData* aData) override;
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) override;
|
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
|
|
|
|
virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2013-02-11 02:28:50 +00:00
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsReflowStatus& aStatus) override;
|
1998-10-03 04:28:05 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
|
2005-03-23 03:35:08 +00:00
|
|
|
|
2006-09-19 04:26:20 +00:00
|
|
|
#if defined(DEBUG) || (defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF))
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2006-09-19 04:26:20 +00:00
|
|
|
#endif // DEBUG || (MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF)
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 16:28:04 +00:00
|
|
|
void List(FILE* out = stderr, const char* aPrefix = "", uint32_t aFlags = 0) const override;
|
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
2006-09-19 04:26:20 +00:00
|
|
|
#endif // DEBUG
|
1998-06-30 21:35:07 +00:00
|
|
|
|
1999-04-23 14:34:48 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2006-12-26 17:47:52 +00:00
|
|
|
* @see nsGkAtoms::placeholderFrame
|
1999-04-23 14:34:48 +00:00
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsIAtom* GetType() const override;
|
1999-04-23 14:34:48 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsEmpty() override { return true; }
|
|
|
|
virtual bool IsSelfEmpty() override { return true; }
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool CanContinueTextRun() const override;
|
2006-10-19 01:47:47 +00:00
|
|
|
|
2005-09-22 21:59:06 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() override
|
2005-09-22 21:59:06 +00:00
|
|
|
{
|
2010-06-28 12:02:03 +00:00
|
|
|
nsIFrame* realFrame = GetRealFrameForPlaceholder(this);
|
2012-09-28 21:53:44 +00:00
|
|
|
return realFrame ? realFrame->AccessibleType() :
|
|
|
|
nsFrame::AccessibleType();
|
2005-09-22 21:59:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const override;
|
2011-09-12 16:08:07 +00:00
|
|
|
|
2005-04-14 15:30:35 +00:00
|
|
|
/**
|
|
|
|
* @return the out-of-flow for aFrame if aFrame is a placeholder; otherwise
|
|
|
|
* aFrame
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetRealFrameFor(nsIFrame* aFrame) {
|
|
|
|
NS_PRECONDITION(aFrame, "Must have a frame to work with");
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aFrame->GetType() == nsGkAtoms::placeholderFrame) {
|
2005-04-14 15:30:35 +00:00
|
|
|
return GetRealFrameForPlaceholder(aFrame);
|
|
|
|
}
|
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the out-of-flow for aFrame, which is known to be a placeholder
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetRealFrameForPlaceholder(nsIFrame* aFrame) {
|
2006-12-26 17:47:52 +00:00
|
|
|
NS_PRECONDITION(aFrame->GetType() == nsGkAtoms::placeholderFrame,
|
2005-04-14 15:30:35 +00:00
|
|
|
"Must have placeholder frame as input");
|
|
|
|
nsIFrame* outOfFlow =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsPlaceholderFrame*>(aFrame)->GetOutOfFlowFrame();
|
2005-04-14 15:30:35 +00:00
|
|
|
NS_ASSERTION(outOfFlow, "Null out-of-flow for placeholder?");
|
|
|
|
return outOfFlow;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
1999-04-23 14:34:48 +00:00
|
|
|
nsIFrame* mOutOfFlowFrame;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsPlaceholderFrame_h___ */
|