2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 22:29:03 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* rendering object for the point that anchors out-of-flow rendering
|
|
|
|
* objects such as floats and absolutely positioned elements
|
|
|
|
*/
|
|
|
|
|
2006-11-06 04:17:32 +03: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 08:20:41 +03: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 04:17:32 +03:00
|
|
|
*
|
2009-12-24 08:20:41 +03: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 04:17:32 +03:00
|
|
|
*/
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifndef nsPlaceholderFrame_h___
|
|
|
|
#define nsPlaceholderFrame_h___
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2020-07-07 01:38:11 +03:00
|
|
|
#include "nsIFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2018-09-14 20:14:53 +03:00
|
|
|
class nsPlaceholderFrame;
|
2019-04-16 10:24:49 +03:00
|
|
|
nsPlaceholderFrame* NS_NewPlaceholderFrame(mozilla::PresShell* aPresShell,
|
2018-09-14 20:14:53 +03:00
|
|
|
mozilla::ComputedStyle* aStyle,
|
|
|
|
nsFrameState aTypeBits);
|
2009-11-17 00:00:07 +03:00
|
|
|
|
2010-06-09 09:28:14 +04:00
|
|
|
#define PLACEHOLDER_TYPE_MASK \
|
|
|
|
(PLACEHOLDER_FOR_FLOAT | PLACEHOLDER_FOR_ABSPOS | PLACEHOLDER_FOR_FIXEDPOS | \
|
2022-11-09 23:38:04 +03:00
|
|
|
PLACEHOLDER_FOR_TOPLAYER)
|
2002-01-10 17:16:05 +03:00
|
|
|
|
1998-11-14 22:26:57 +03:00
|
|
|
/**
|
1999-04-23 18:34:48 +04:00
|
|
|
* Implementation of a frame that's used as a placeholder for a frame that
|
2013-02-11 06:28:50 +04:00
|
|
|
* has been moved out of the flow.
|
1998-11-14 22:26:57 +03:00
|
|
|
*/
|
2020-07-07 01:29:42 +03:00
|
|
|
class nsPlaceholderFrame final : public nsIFrame {
|
1998-04-14 00:24:54 +04:00
|
|
|
public:
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsPlaceholderFrame)
|
2014-01-18 11:08:22 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
#endif
|
2009-09-12 20:49:24 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
2009-11-17 00:00:07 +03:00
|
|
|
* Create a new placeholder frame. aTypeBit must be one of the
|
|
|
|
* PLACEHOLDER_FOR_* constants above.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
2019-04-16 10:24:49 +03:00
|
|
|
friend nsPlaceholderFrame* NS_NewPlaceholderFrame(
|
|
|
|
mozilla::PresShell* aPresShell, ComputedStyle* aStyle,
|
|
|
|
nsFrameState aTypeBits);
|
2018-09-14 20:14:53 +03:00
|
|
|
|
2019-02-05 19:45:54 +03:00
|
|
|
nsPlaceholderFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
|
|
|
|
nsFrameState aTypeBits)
|
2020-07-07 01:29:42 +03:00
|
|
|
: nsIFrame(aStyle, aPresContext, kClassID), mOutOfFlowFrame(nullptr) {
|
2017-10-02 22:08:50 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
aTypeBits == PLACEHOLDER_FOR_FLOAT ||
|
|
|
|
aTypeBits == PLACEHOLDER_FOR_ABSPOS ||
|
|
|
|
aTypeBits == PLACEHOLDER_FOR_FIXEDPOS ||
|
|
|
|
aTypeBits == (PLACEHOLDER_FOR_TOPLAYER | PLACEHOLDER_FOR_ABSPOS) ||
|
|
|
|
aTypeBits == (PLACEHOLDER_FOR_TOPLAYER | PLACEHOLDER_FOR_FIXEDPOS),
|
|
|
|
"Unexpected type bit");
|
|
|
|
AddStateBits(aTypeBits);
|
2009-11-17 00:00:07 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-04-23 18:34:48 +04:00
|
|
|
// Get/Set the associated out of flow frame
|
2013-02-11 06:28:50 +04:00
|
|
|
nsIFrame* GetOutOfFlowFrame() const { return mOutOfFlowFrame; }
|
2009-08-31 22:25:35 +04:00
|
|
|
void SetOutOfFlowFrame(nsIFrame* aFrame) {
|
|
|
|
NS_ASSERTION(!aFrame || !aFrame->GetPrevContinuation(),
|
|
|
|
"OOF must be first continuation");
|
|
|
|
mOutOfFlowFrame = aFrame;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2013-02-11 06:28:50 +04:00
|
|
|
// nsIFrame overrides
|
2023-03-30 00:23:55 +03:00
|
|
|
void AddInlineMinISize(gfxContext* aRenderingContext,
|
|
|
|
InlineMinISizeData* aData) override;
|
|
|
|
void AddInlinePrefISize(gfxContext* aRenderingContext,
|
|
|
|
InlinePrefISizeData* aData) override;
|
|
|
|
|
|
|
|
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
nsReflowStatus& aStatus) override;
|
|
|
|
|
2023-09-07 14:46:30 +03:00
|
|
|
void Destroy(DestroyContext&) override;
|
2005-03-23 06:35:08 +03:00
|
|
|
|
2006-09-19 08:26:20 +04:00
|
|
|
#if defined(DEBUG) || (defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF))
|
2023-03-30 00:23:55 +03:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) override;
|
2006-09-19 08:26:20 +04:00
|
|
|
#endif // DEBUG || (MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF)
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
void List(FILE* out = stderr, const char* aPrefix = "",
|
2020-04-08 03:22:19 +03:00
|
|
|
ListFlags aFlags = ListFlags()) const override;
|
2023-03-30 00:23:55 +03:00
|
|
|
nsresult GetFrameName(nsAString& aResult) const override;
|
2006-09-19 08:26:20 +04:00
|
|
|
#endif // DEBUG
|
1998-07-01 01:35:07 +04:00
|
|
|
|
2023-03-30 00:23:55 +03:00
|
|
|
bool IsEmpty() override { return true; }
|
|
|
|
bool IsSelfEmpty() override { return true; }
|
2001-10-25 05:08:40 +04:00
|
|
|
|
2023-03-30 00:23:55 +03:00
|
|
|
bool CanContinueTextRun() const override;
|
2006-10-19 05:47:47 +04:00
|
|
|
|
2017-05-23 20:09:26 +03:00
|
|
|
void SetLineIsEmptySoFar(bool aValue) {
|
|
|
|
AddOrRemoveStateBits(PLACEHOLDER_LINE_IS_EMPTY_SO_FAR, aValue);
|
|
|
|
AddStateBits(PLACEHOLDER_HAVE_LINE_IS_EMPTY_SO_FAR);
|
|
|
|
}
|
|
|
|
bool GetLineIsEmptySoFar(bool* aResult) const {
|
|
|
|
bool haveValue = HasAnyStateBits(PLACEHOLDER_HAVE_LINE_IS_EMPTY_SO_FAR);
|
|
|
|
if (haveValue) {
|
|
|
|
*aResult = HasAnyStateBits(PLACEHOLDER_LINE_IS_EMPTY_SO_FAR);
|
|
|
|
}
|
|
|
|
return haveValue;
|
|
|
|
}
|
|
|
|
void ForgetLineIsEmptySoFar() {
|
|
|
|
RemoveStateBits(PLACEHOLDER_HAVE_LINE_IS_EMPTY_SO_FAR);
|
|
|
|
}
|
|
|
|
|
2005-09-23 01:59:06 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2023-03-30 00:23:55 +03:00
|
|
|
mozilla::a11y::AccType AccessibleType() override {
|
2010-06-28 16:02:03 +04:00
|
|
|
nsIFrame* realFrame = GetRealFrameForPlaceholder(this);
|
2020-07-07 01:29:42 +03:00
|
|
|
return realFrame ? realFrame->AccessibleType() : nsIFrame::AccessibleType();
|
2005-09-23 01:59:06 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* GetParentComputedStyleForOutOfFlow(
|
|
|
|
nsIFrame** aProviderFrame) const;
|
2011-09-12 20:08:07 +04:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
// Like GetParentComputedStyleForOutOfFlow, but ignores display:contents bits.
|
|
|
|
ComputedStyle* GetLayoutParentStyleForOutOfFlow(
|
|
|
|
nsIFrame** aProviderFrame) const;
|
2017-09-01 05:46:35 +03:00
|
|
|
|
2016-09-01 18:36:22 +03:00
|
|
|
bool RenumberFrameAndDescendants(int32_t* aOrdinal, int32_t aDepth,
|
|
|
|
int32_t aIncrement,
|
|
|
|
bool aForCounting) override {
|
|
|
|
return mOutOfFlowFrame->RenumberFrameAndDescendants(
|
|
|
|
aOrdinal, aDepth, aIncrement, aForCounting);
|
|
|
|
}
|
|
|
|
|
2005-04-14 19:30:35 +04:00
|
|
|
/**
|
|
|
|
* @return the out-of-flow for aFrame if aFrame is a placeholder; otherwise
|
|
|
|
* aFrame
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetRealFrameFor(nsIFrame* aFrame) {
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aFrame, "Must have a frame to work with");
|
2017-04-30 18:30:08 +03:00
|
|
|
if (aFrame->IsPlaceholderFrame()) {
|
2005-04-14 19:30:35 +04: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) {
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aFrame->IsPlaceholderFrame(),
|
|
|
|
"Must have placeholder frame as input");
|
2005-04-14 19:30:35 +04:00
|
|
|
nsIFrame* outOfFlow =
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsPlaceholderFrame*>(aFrame)->GetOutOfFlowFrame();
|
2005-04-14 19:30:35 +04:00
|
|
|
NS_ASSERTION(outOfFlow, "Null out-of-flow for placeholder?");
|
|
|
|
return outOfFlow;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
protected:
|
2017-05-23 20:09:26 +03:00
|
|
|
nsIFrame* mOutOfFlowFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsPlaceholderFrame_h___ */
|