2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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
|
|
|
|
*/
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2013-02-11 06:28:50 +04:00
|
|
|
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "nsFrameManager.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2013-10-02 01:00:38 +04:00
|
|
|
#include "nsIFrameInlines.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2009-11-17 00:00:07 +03:00
|
|
|
NS_NewPlaceholderFrame(nsIPresShell* aPresShell, nsStyleContext* aContext,
|
|
|
|
nsFrameState aTypeBit)
|
2002-09-25 02:13:20 +04:00
|
|
|
{
|
2009-11-17 00:00:07 +03:00
|
|
|
return new (aPresShell) nsPlaceholderFrame(aContext, aTypeBit);
|
2002-09-25 02:13:20 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsPlaceholderFrame)
|
|
|
|
|
2010-06-21 16:37:35 +04:00
|
|
|
/* virtual */ nsSize
|
|
|
|
nsPlaceholderFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState)
|
|
|
|
{
|
|
|
|
nsSize size(0, 0);
|
|
|
|
DISPLAY_MIN_SIZE(this, size);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
|
|
|
nsPlaceholderFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
|
|
|
|
{
|
|
|
|
nsSize size(0, 0);
|
|
|
|
DISPLAY_PREF_SIZE(this, size);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
|
|
|
nsPlaceholderFrame::GetMaxSize(nsBoxLayoutState& aBoxLayoutState)
|
|
|
|
{
|
|
|
|
nsSize size(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
DISPLAY_MAX_SIZE(this, size);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
/* virtual */ void
|
2013-02-11 06:28:50 +04:00
|
|
|
nsPlaceholderFrame::AddInlineMinWidth(nsRenderingContext* aRenderingContext,
|
|
|
|
nsIFrame::InlineMinWidthData* aData)
|
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 08:38:33 +03:00
|
|
|
{
|
|
|
|
// Override AddInlineMinWith so that *nothing* happens. In
|
|
|
|
// particular, we don't want to zero out |aData->trailingWhitespace|,
|
|
|
|
// since nsLineLayout skips placeholders when trimming trailing
|
|
|
|
// whitespace, and we don't want to set aData->skipWhitespace to
|
|
|
|
// false.
|
|
|
|
|
|
|
|
// ...but push floats onto the list
|
2012-08-10 15:16:52 +04:00
|
|
|
if (mOutOfFlowFrame->IsFloating()) {
|
|
|
|
nscoord floatWidth =
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mOutOfFlowFrame,
|
|
|
|
nsLayoutUtils::MIN_WIDTH);
|
|
|
|
aData->floats.AppendElement(
|
|
|
|
InlineIntrinsicWidthData::FloatInfo(mOutOfFlowFrame, floatWidth));
|
|
|
|
}
|
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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
2013-02-11 06:28:50 +04:00
|
|
|
nsPlaceholderFrame::AddInlinePrefWidth(nsRenderingContext* aRenderingContext,
|
|
|
|
nsIFrame::InlinePrefWidthData* aData)
|
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 08:38:33 +03:00
|
|
|
{
|
|
|
|
// Override AddInlinePrefWith so that *nothing* happens. In
|
|
|
|
// particular, we don't want to zero out |aData->trailingWhitespace|,
|
|
|
|
// since nsLineLayout skips placeholders when trimming trailing
|
|
|
|
// whitespace, and we don't want to set aData->skipWhitespace to
|
|
|
|
// false.
|
|
|
|
|
|
|
|
// ...but push floats onto the list
|
2012-08-10 15:16:52 +04:00
|
|
|
if (mOutOfFlowFrame->IsFloating()) {
|
|
|
|
nscoord floatWidth =
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mOutOfFlowFrame,
|
|
|
|
nsLayoutUtils::PREF_WIDTH);
|
|
|
|
aData->floats.AppendElement(
|
|
|
|
InlineIntrinsicWidthData::FloatInfo(mOutOfFlowFrame, floatWidth));
|
|
|
|
}
|
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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
1998-07-29 08:05:49 +04:00
|
|
|
NS_IMETHODIMP
|
2013-02-11 06:28:50 +04:00
|
|
|
nsPlaceholderFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-03 08:28:05 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-29 08:05:49 +04:00
|
|
|
{
|
2013-05-21 20:15:57 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
// We should be getting reflowed before our out-of-flow.
|
|
|
|
// If this is our first reflow, and our out-of-flow has already received its
|
|
|
|
// first reflow (before us), complain.
|
|
|
|
// XXXdholbert This "look for a previous continuation or IB-split sibling"
|
|
|
|
// code could use nsLayoutUtils::GetPrevContinuationOrSpecialSibling(), if
|
|
|
|
// we ever add a function like that. (We currently have a "Next" version.)
|
|
|
|
if ((GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
|
|
|
|
!(mOutOfFlowFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
|
|
|
|
|
|
|
// Unfortunately, this can currently happen when the placeholder is in a
|
|
|
|
// later continuation or later IB-split sibling than its out-of-flow (as
|
|
|
|
// is the case in some of our existing unit tests). So for now, in that
|
|
|
|
// case, we'll warn instead of asserting.
|
|
|
|
bool isInContinuationOrIBSplit = false;
|
|
|
|
nsIFrame* ancestor = this;
|
|
|
|
while ((ancestor = ancestor->GetParent())) {
|
|
|
|
if (ancestor->GetPrevContinuation() ||
|
|
|
|
ancestor->Properties().Get(IBSplitSpecialPrevSibling())) {
|
|
|
|
isInContinuationOrIBSplit = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isInContinuationOrIBSplit) {
|
|
|
|
NS_WARNING("Out-of-flow frame got reflowed before its placeholder");
|
|
|
|
} else {
|
|
|
|
NS_ERROR("Out-of-flow frame got reflowed before its placeholder");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsPlaceholderFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = 0;
|
|
|
|
aDesiredSize.Height() = 0;
|
1998-10-03 08:28:05 +04:00
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-03 08:28:05 +04:00
|
|
|
return NS_OK;
|
1998-07-17 03:31:53 +04:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsPlaceholderFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2005-03-23 06:35:08 +03:00
|
|
|
{
|
2009-12-24 08:20:41 +03:00
|
|
|
nsIFrame* oof = mOutOfFlowFrame;
|
|
|
|
if (oof) {
|
2009-12-24 08:21:15 +03:00
|
|
|
// Unregister out-of-flow frame
|
2013-02-11 06:28:50 +04:00
|
|
|
nsFrameManager* fm = PresContext()->GetPresShell()->FrameManager();
|
|
|
|
fm->UnregisterPlaceholderFrame(this);
|
2012-07-30 18:20:58 +04:00
|
|
|
mOutOfFlowFrame = nullptr;
|
2009-12-24 08:21:15 +03:00
|
|
|
// If aDestructRoot is not an ancestor of the out-of-flow frame,
|
|
|
|
// then call RemoveFrame on it here.
|
|
|
|
// Also destroy it here if it's a popup frame. (Bug 96291)
|
2013-02-11 06:28:50 +04:00
|
|
|
if ((GetStateBits() & PLACEHOLDER_FOR_POPUP) ||
|
|
|
|
!nsLayoutUtils::IsProperAncestorFrame(aDestructRoot, oof)) {
|
2011-08-25 00:54:30 +04:00
|
|
|
ChildListID listId = nsLayoutUtils::GetChildListNameFor(oof);
|
2013-02-11 06:28:50 +04:00
|
|
|
fm->RemoveFrame(listId, oof);
|
2009-12-24 08:21:15 +03:00
|
|
|
}
|
|
|
|
// else oof will be destroyed by its parent
|
2005-03-23 06:35:08 +03:00
|
|
|
}
|
|
|
|
|
2009-12-24 08:21:15 +03:00
|
|
|
nsFrame::DestroyFrom(aDestructRoot);
|
2006-08-24 09:22:16 +04:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsPlaceholderFrame::GetType() const
|
1999-11-02 01:12:45 +03:00
|
|
|
{
|
2013-02-11 06:28:50 +04:00
|
|
|
return nsGkAtoms::placeholderFrame;
|
1999-11-02 01:12:45 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
/* virtual */ bool
|
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 08:38:33 +03:00
|
|
|
nsPlaceholderFrame::CanContinueTextRun() const
|
2006-10-19 05:47:47 +04:00
|
|
|
{
|
|
|
|
if (!mOutOfFlowFrame) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2006-10-19 05:47:47 +04:00
|
|
|
}
|
|
|
|
// first-letter frames can continue text runs, and placeholders for floated
|
|
|
|
// first-letter frames can too
|
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 08:38:33 +03:00
|
|
|
return mOutOfFlowFrame->CanContinueTextRun();
|
2006-10-19 05:47:47 +04:00
|
|
|
}
|
|
|
|
|
2011-09-12 20:08:07 +04:00
|
|
|
nsIFrame*
|
2012-02-15 13:28:21 +04:00
|
|
|
nsPlaceholderFrame::GetParentStyleContextFrame() const
|
2007-07-18 06:01:32 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(GetParent(), "How can we not have a parent here?");
|
|
|
|
|
|
|
|
// Lie about our pseudo so we can step out of all anon boxes and
|
|
|
|
// pseudo-elements. The other option would be to reimplement the
|
|
|
|
// {ib} split gunk here.
|
2011-09-12 20:08:07 +04:00
|
|
|
return CorrectStyleParentFrame(GetParent(), nsGkAtoms::placeholderFrame);
|
2007-07-18 06:01:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
2006-01-26 05:29:17 +03:00
|
|
|
static void
|
2011-04-08 05:04:40 +04:00
|
|
|
PaintDebugPlaceholder(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2006-01-26 05:29:17 +03:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
|
|
|
{
|
|
|
|
aCtx->SetColor(NS_RGB(0, 255, 255));
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord x = nsPresContext::CSSPixelsToAppUnits(-5);
|
2006-01-26 05:29:17 +03:00
|
|
|
aCtx->FillRect(aPt.x + x, aPt.y,
|
2013-02-11 06:28:50 +04:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(13),
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(3));
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord y = nsPresContext::CSSPixelsToAppUnits(-10);
|
2006-01-26 05:29:17 +03:00
|
|
|
aCtx->FillRect(aPt.x, aPt.y + y,
|
2013-02-11 06:28:50 +04:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(3),
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(10));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2006-09-19 08:26:20 +04:00
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
#if defined(DEBUG) || (defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF))
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPlaceholderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-07-17 03:31:53 +04:00
|
|
|
{
|
2006-09-19 08:26:20 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsPlaceholderFrame");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-02-11 06:28:50 +04:00
|
|
|
if (GetShowFrameBorders()) {
|
2013-02-14 15:12:27 +04:00
|
|
|
aLists.Outlines()->AppendNewToTop(
|
2013-02-11 06:28:50 +04:00
|
|
|
new (aBuilder) nsDisplayGeneric(aBuilder, this, PaintDebugPlaceholder,
|
|
|
|
"DebugPlaceholder",
|
|
|
|
nsDisplayItem::TYPE_DEBUG_PLACEHOLDER));
|
|
|
|
}
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2006-09-19 08:26:20 +04:00
|
|
|
#endif // DEBUG || (MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF)
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
1998-11-14 22:26:57 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsPlaceholderFrame::GetFrameName(nsAString& aResult) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Placeholder"), aResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-05-04 00:54:24 +04:00
|
|
|
|
2013-04-30 22:38:52 +04:00
|
|
|
void
|
2012-09-19 18:36:35 +04:00
|
|
|
nsPlaceholderFrame::List(FILE* out, int32_t aIndent, uint32_t aFlags) const
|
1999-05-04 00:54:24 +04:00
|
|
|
{
|
2013-04-30 22:38:52 +04:00
|
|
|
ListGeneric(out, aIndent, aFlags);
|
|
|
|
|
1999-10-29 18:36:00 +04:00
|
|
|
if (mOutOfFlowFrame) {
|
|
|
|
fprintf(out, " outOfFlowFrame=");
|
|
|
|
nsFrame::ListTag(out, mOutOfFlowFrame);
|
|
|
|
}
|
1999-05-04 00:54:24 +04:00
|
|
|
fputs("\n", out);
|
|
|
|
}
|
2014-01-06 03:31:14 +04:00
|
|
|
#endif
|