layout/forms/nsLegendFrame.cpp

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsLegendFrame.h"
michael@0 7 #include "nsIContent.h"
michael@0 8 #include "nsGenericHTMLElement.h"
michael@0 9 #include "nsAttrValueInlines.h"
michael@0 10 #include "nsHTMLParts.h"
michael@0 11 #include "nsGkAtoms.h"
michael@0 12 #include "nsStyleConsts.h"
michael@0 13 #include "nsFormControlFrame.h"
michael@0 14
michael@0 15 nsIFrame*
michael@0 16 NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
michael@0 17 {
michael@0 18 #ifdef DEBUG
michael@0 19 const nsStyleDisplay* disp = aContext->StyleDisplay();
michael@0 20 NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
michael@0 21 "Legends should not be positioned and should not float");
michael@0 22 #endif
michael@0 23
michael@0 24 nsIFrame* f = new (aPresShell) nsLegendFrame(aContext);
michael@0 25 if (f) {
michael@0 26 f->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
michael@0 27 }
michael@0 28 return f;
michael@0 29 }
michael@0 30
michael@0 31 NS_IMPL_FRAMEARENA_HELPERS(nsLegendFrame)
michael@0 32
michael@0 33 nsIAtom*
michael@0 34 nsLegendFrame::GetType() const
michael@0 35 {
michael@0 36 return nsGkAtoms::legendFrame;
michael@0 37 }
michael@0 38
michael@0 39 void
michael@0 40 nsLegendFrame::DestroyFrom(nsIFrame* aDestructRoot)
michael@0 41 {
michael@0 42 nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
michael@0 43 nsBlockFrame::DestroyFrom(aDestructRoot);
michael@0 44 }
michael@0 45
michael@0 46 NS_QUERYFRAME_HEAD(nsLegendFrame)
michael@0 47 NS_QUERYFRAME_ENTRY(nsLegendFrame)
michael@0 48 NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
michael@0 49
michael@0 50 nsresult
michael@0 51 nsLegendFrame::Reflow(nsPresContext* aPresContext,
michael@0 52 nsHTMLReflowMetrics& aDesiredSize,
michael@0 53 const nsHTMLReflowState& aReflowState,
michael@0 54 nsReflowStatus& aStatus)
michael@0 55 {
michael@0 56 DO_GLOBAL_REFLOW_COUNT("nsLegendFrame");
michael@0 57 DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
michael@0 58 if (mState & NS_FRAME_FIRST_REFLOW) {
michael@0 59 nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
michael@0 60 }
michael@0 61 return nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
michael@0 62 }
michael@0 63
michael@0 64 // REVIEW: We don't need to override BuildDisplayList, nsBlockFrame will honour
michael@0 65 // our visibility setting
michael@0 66 int32_t nsLegendFrame::GetAlign()
michael@0 67 {
michael@0 68 int32_t intValue = NS_STYLE_TEXT_ALIGN_LEFT;
michael@0 69 if (mParent && NS_STYLE_DIRECTION_RTL == mParent->StyleVisibility()->mDirection) {
michael@0 70 intValue = NS_STYLE_TEXT_ALIGN_RIGHT;
michael@0 71 }
michael@0 72
michael@0 73 nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
michael@0 74
michael@0 75 if (content) {
michael@0 76 const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::align);
michael@0 77 if (attr && attr->Type() == nsAttrValue::eEnum) {
michael@0 78 intValue = attr->GetEnumValue();
michael@0 79 }
michael@0 80 }
michael@0 81 return intValue;
michael@0 82 }
michael@0 83
michael@0 84 #ifdef DEBUG_FRAME_DUMP
michael@0 85 nsresult
michael@0 86 nsLegendFrame::GetFrameName(nsAString& aResult) const
michael@0 87 {
michael@0 88 return MakeFrameName(NS_LITERAL_STRING("Legend"), aResult);
michael@0 89 }
michael@0 90 #endif

mercurial