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/. */
|
1998-10-08 08:38:41 +04:00
|
|
|
|
|
|
|
#include "nsLegendFrame.h"
|
|
|
|
#include "nsIContent.h"
|
2005-01-12 22:45:38 +03:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2000-02-09 22:34:39 +03:00
|
|
|
#include "nsFormControlFrame.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
|
2005-11-01 23:40:54 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2009-01-19 21:31:31 +03:00
|
|
|
#ifdef DEBUG
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* disp = aContext->StyleDisplay();
|
2012-08-02 15:38:50 +04:00
|
|
|
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
|
2009-01-19 21:31:31 +03:00
|
|
|
"Legends should not be positioned and should not float");
|
|
|
|
#endif
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsIFrame* f = new (aPresShell) nsLegendFrame(aContext);
|
2016-12-23 21:11:04 +03:00
|
|
|
f->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
|
2006-01-23 02:20:56 +03:00
|
|
|
return f;
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsLegendFrame)
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsLegendFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2000-08-03 02:12:11 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
2000-02-09 22:34:39 +03:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsLegendFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsLegendFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
1998-10-08 08:38:41 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsLegendFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2000-02-09 22:34:39 +03:00
|
|
|
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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsLegendFrame");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, 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 08:38:33 +03:00
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
|
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
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
2000-02-09 22:34:39 +03:00
|
|
|
}
|
|
|
|
|
2016-05-18 14:49:33 +03:00
|
|
|
int32_t
|
|
|
|
nsLegendFrame::GetLogicalAlign(WritingMode aCBWM)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2016-05-18 14:49:33 +03:00
|
|
|
int32_t intValue = NS_STYLE_TEXT_ALIGN_START;
|
|
|
|
nsGenericHTMLElement* content = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 04:00:34 +04:00
|
|
|
if (content) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::align);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eEnum) {
|
|
|
|
intValue = attr->GetEnumValue();
|
2016-05-18 14:49:33 +03:00
|
|
|
switch (intValue) {
|
|
|
|
case NS_STYLE_TEXT_ALIGN_LEFT:
|
|
|
|
intValue = aCBWM.IsBidiLTR() ? NS_STYLE_TEXT_ALIGN_START
|
|
|
|
: NS_STYLE_TEXT_ALIGN_END;
|
|
|
|
break;
|
|
|
|
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
|
|
|
intValue = aCBWM.IsBidiLTR() ? NS_STYLE_TEXT_ALIGN_END
|
|
|
|
: NS_STYLE_TEXT_ALIGN_START;
|
|
|
|
break;
|
|
|
|
}
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return intValue;
|
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsLegendFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Legend"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|