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/. */
|
1998-10-08 08:38:41 +04:00
|
|
|
|
|
|
|
#include "nsLegendFrame.h"
|
2018-11-13 01:20:52 +03:00
|
|
|
|
|
|
|
#include "ComputedStyle.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#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"
|
2017-09-27 15:12:00 +03:00
|
|
|
#include "nsCheckboxRadioFrame.h"
|
2018-11-13 01:20:52 +03:00
|
|
|
#include "WritingModes.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
1998-10-08 08:38:41 +04:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
nsIFrame* NS_NewLegendFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
|
2009-01-19 21:31:31 +03:00
|
|
|
#ifdef DEBUG
|
2018-03-22 21:20:41 +03:00
|
|
|
const nsStyleDisplay* disp = aStyle->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
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
nsIFrame* f = new (aPresShell) nsLegendFrame(aStyle);
|
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)
|
|
|
|
|
2017-11-07 03:20:33 +03:00
|
|
|
void nsLegendFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) {
|
2017-09-27 15:12:00 +03:00
|
|
|
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2017-11-07 03:20:33 +03:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
2000-02-09 22:34:39 +03:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsLegendFrame)
|
2018-12-07 23:00:18 +03:00
|
|
|
NS_QUERYFRAME_ENTRY(nsLegendFrame)
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
1998-10-08 08:38:41 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void 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);
|
2017-09-13 13:00:25 +03:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
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) {
|
2017-09-27 15:12:00 +03:00
|
|
|
nsCheckboxRadioFrame::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) {
|
|
|
|
int32_t intValue = NS_STYLE_TEXT_ALIGN_START;
|
2018-03-22 00:39:04 +03:00
|
|
|
nsGenericHTMLElement* content = nsGenericHTMLElement::FromNode(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
|
2001-11-14 04:33:42 +03:00
|
|
|
nsresult nsLegendFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Legend"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|