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
|
|
|
|
*/
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2013-02-11 02:28:50 +00:00
|
|
|
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "nsFrameManager.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2009-11-16 21:00:07 +00:00
|
|
|
NS_NewPlaceholderFrame(nsIPresShell* aPresShell, nsStyleContext* aContext,
|
|
|
|
nsFrameState aTypeBit)
|
2002-09-24 22:13:20 +00:00
|
|
|
{
|
2009-11-16 21:00:07 +00:00
|
|
|
return new (aPresShell) nsPlaceholderFrame(aContext, aTypeBit);
|
2002-09-24 22:13:20 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsPlaceholderFrame)
|
|
|
|
|
2010-06-21 12:37:35 +00: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 05:38:33 +00:00
|
|
|
/* virtual */ void
|
2013-02-11 02:28:50 +00: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 05:38:33 +00: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 11:16:52 +00: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 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
2013-02-11 02:28:50 +00: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 05:38:33 +00: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 11:16:52 +00: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 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
1998-07-29 04:05:49 +00:00
|
|
|
NS_IMETHODIMP
|
2013-02-11 02:28:50 +00:00
|
|
|
nsPlaceholderFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-03 04:28:05 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-29 04:05:49 +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
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsPlaceholderFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1998-07-29 19:33:27 +00:00
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
1998-10-03 04:28:05 +00:00
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-03 04:28:05 +00:00
|
|
|
return NS_OK;
|
1998-07-16 23:31:53 +00:00
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsPlaceholderFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2005-03-23 03:35:08 +00:00
|
|
|
{
|
2009-12-24 05:20:41 +00:00
|
|
|
nsIFrame* oof = mOutOfFlowFrame;
|
|
|
|
if (oof) {
|
2009-12-24 05:21:15 +00:00
|
|
|
// Unregister out-of-flow frame
|
2013-02-11 02:28:50 +00:00
|
|
|
nsFrameManager* fm = PresContext()->GetPresShell()->FrameManager();
|
|
|
|
fm->UnregisterPlaceholderFrame(this);
|
2012-07-30 14:20:58 +00:00
|
|
|
mOutOfFlowFrame = nullptr;
|
2009-12-24 05:21:15 +00: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 02:28:50 +00:00
|
|
|
if ((GetStateBits() & PLACEHOLDER_FOR_POPUP) ||
|
|
|
|
!nsLayoutUtils::IsProperAncestorFrame(aDestructRoot, oof)) {
|
2011-08-24 20:54:30 +00:00
|
|
|
ChildListID listId = nsLayoutUtils::GetChildListNameFor(oof);
|
2013-02-11 02:28:50 +00:00
|
|
|
fm->RemoveFrame(listId, oof);
|
2009-12-24 05:21:15 +00:00
|
|
|
}
|
|
|
|
// else oof will be destroyed by its parent
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
nsFrame::DestroyFrom(aDestructRoot);
|
2006-08-24 05:22:16 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsPlaceholderFrame::GetType() const
|
1999-11-01 22:12:45 +00:00
|
|
|
{
|
2013-02-11 02:28:50 +00:00
|
|
|
return nsGkAtoms::placeholderFrame;
|
1999-11-01 22:12:45 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00: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 05:38:33 +00:00
|
|
|
nsPlaceholderFrame::CanContinueTextRun() const
|
2006-10-19 01:47:47 +00:00
|
|
|
{
|
|
|
|
if (!mOutOfFlowFrame) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2006-10-19 01:47:47 +00: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 05:38:33 +00:00
|
|
|
return mOutOfFlowFrame->CanContinueTextRun();
|
2006-10-19 01:47:47 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame*
|
2012-02-15 09:28:21 +00:00
|
|
|
nsPlaceholderFrame::GetParentStyleContextFrame() const
|
2007-07-18 02:01:32 +00: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 16:08:07 +00:00
|
|
|
return CorrectStyleParentFrame(GetParent(), nsGkAtoms::placeholderFrame);
|
2007-07-18 02:01:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
2006-01-26 02:29:17 +00:00
|
|
|
static void
|
2011-04-08 01:04:40 +00:00
|
|
|
PaintDebugPlaceholder(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
|
|
|
{
|
|
|
|
aCtx->SetColor(NS_RGB(0, 255, 255));
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord x = nsPresContext::CSSPixelsToAppUnits(-5);
|
2006-01-26 02:29:17 +00:00
|
|
|
aCtx->FillRect(aPt.x + x, aPt.y,
|
2013-02-11 02:28:50 +00:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(13),
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(3));
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord y = nsPresContext::CSSPixelsToAppUnits(-10);
|
2006-01-26 02:29:17 +00:00
|
|
|
aCtx->FillRect(aPt.x, aPt.y + y,
|
2013-02-11 02:28:50 +00:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(3),
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(10));
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2006-09-19 04:26:20 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
#if defined(DEBUG) || (defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF))
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPlaceholderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-07-16 23:31:53 +00:00
|
|
|
{
|
2006-09-19 04:26:20 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsPlaceholderFrame");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-02-11 02:28:50 +00:00
|
|
|
if (GetShowFrameBorders()) {
|
2013-02-14 11:12:27 +00:00
|
|
|
aLists.Outlines()->AppendNewToTop(
|
2013-02-11 02:28:50 +00:00
|
|
|
new (aBuilder) nsDisplayGeneric(aBuilder, this, PaintDebugPlaceholder,
|
|
|
|
"DebugPlaceholder",
|
|
|
|
nsDisplayItem::TYPE_DEBUG_PLACEHOLDER));
|
|
|
|
}
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2006-09-19 04:26:20 +00:00
|
|
|
#endif // DEBUG || (MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF)
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-09-19 04:26:20 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-14 19:26:57 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsPlaceholderFrame::GetFrameName(nsAString& aResult) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Placeholder"), aResult);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1999-05-03 20:54:24 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-09-19 14:36:35 +00:00
|
|
|
nsPlaceholderFrame::List(FILE* out, int32_t aIndent, uint32_t aFlags) const
|
1999-05-03 20:54:24 +00:00
|
|
|
{
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
ListTag(out);
|
2003-06-19 23:44:01 +00:00
|
|
|
if (HasView()) {
|
2003-06-30 10:46:59 +00:00
|
|
|
fprintf(out, " [view=%p]", (void*)GetView());
|
1999-05-03 20:54:24 +00:00
|
|
|
}
|
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
|
|
|
|
if (0 != mState) {
|
2011-12-20 03:46:39 +00:00
|
|
|
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
|
1999-05-03 20:54:24 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
nsIFrame* prevInFlow = GetPrevInFlow();
|
|
|
|
nsIFrame* nextInFlow = GetNextInFlow();
|
2013-02-11 02:28:50 +00:00
|
|
|
if (prevInFlow) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " prev-in-flow=%p", static_cast<void*>(prevInFlow));
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
2013-02-11 02:28:50 +00:00
|
|
|
if (nextInFlow) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " next-in-flow=%p", static_cast<void*>(nextInFlow));
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
2013-02-11 02:28:50 +00:00
|
|
|
if (mContent) {
|
2009-10-16 02:47:03 +00:00
|
|
|
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
|
|
|
|
}
|
2013-02-11 02:28:50 +00:00
|
|
|
if (mStyleContext) {
|
2010-06-25 21:51:17 +00:00
|
|
|
fprintf(out, " [sc=%p]", static_cast<void*>(mStyleContext));
|
|
|
|
}
|
1999-10-29 14:36:00 +00:00
|
|
|
if (mOutOfFlowFrame) {
|
|
|
|
fprintf(out, " outOfFlowFrame=");
|
|
|
|
nsFrame::ListTag(out, mOutOfFlowFrame);
|
|
|
|
}
|
1999-05-03 20:54:24 +00:00
|
|
|
fputs("\n", out);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-02-11 02:28:50 +00:00
|
|
|
#endif // DEBUG
|