Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/forms/nsLegendFrame.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "nsLegendFrame.h"
8
#include "nsIContent.h"
9
#include "nsGenericHTMLElement.h"
10
#include "nsAttrValueInlines.h"
11
#include "nsHTMLParts.h"
12
#include "nsGkAtoms.h"
13
#include "nsStyleConsts.h"
14
#include "nsCheckboxRadioFrame.h"
15
16
nsIFrame*
17
NS_NewLegendFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
18
0
{
19
#ifdef DEBUG
20
  const nsStyleDisplay* disp = aStyle->StyleDisplay();
21
  NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
22
               "Legends should not be positioned and should not float");
23
#endif
24
25
0
  nsIFrame* f = new (aPresShell) nsLegendFrame(aStyle);
26
0
  f->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
27
0
  return f;
28
0
}
29
30
NS_IMPL_FRAMEARENA_HELPERS(nsLegendFrame)
31
32
void
33
nsLegendFrame::DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData)
34
0
{
35
0
  nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
36
0
  nsBlockFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
37
0
}
38
39
0
NS_QUERYFRAME_HEAD(nsLegendFrame)
40
0
  NS_QUERYFRAME_ENTRY(nsLegendFrame)
41
0
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
42
43
void
44
nsLegendFrame::Reflow(nsPresContext*          aPresContext,
45
                     ReflowOutput&     aDesiredSize,
46
                     const ReflowInput& aReflowInput,
47
                     nsReflowStatus&          aStatus)
48
0
{
49
0
  DO_GLOBAL_REFLOW_COUNT("nsLegendFrame");
50
0
  DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
51
0
  MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
52
0
  if (mState & NS_FRAME_FIRST_REFLOW) {
53
0
    nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
54
0
  }
55
0
  return nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowInput, aStatus);
56
0
}
57
58
int32_t
59
nsLegendFrame::GetLogicalAlign(WritingMode aCBWM)
60
0
{
61
0
  int32_t intValue = NS_STYLE_TEXT_ALIGN_START;
62
0
  nsGenericHTMLElement* content = nsGenericHTMLElement::FromNode(mContent);
63
0
  if (content) {
64
0
    const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::align);
65
0
    if (attr && attr->Type() == nsAttrValue::eEnum) {
66
0
      intValue = attr->GetEnumValue();
67
0
      switch (intValue) {
68
0
        case NS_STYLE_TEXT_ALIGN_LEFT:
69
0
          intValue = aCBWM.IsBidiLTR() ? NS_STYLE_TEXT_ALIGN_START
70
0
                                       : NS_STYLE_TEXT_ALIGN_END;
71
0
          break;
72
0
        case NS_STYLE_TEXT_ALIGN_RIGHT:
73
0
          intValue = aCBWM.IsBidiLTR() ? NS_STYLE_TEXT_ALIGN_END
74
0
                                       : NS_STYLE_TEXT_ALIGN_START;
75
0
          break;
76
0
      }
77
0
    }
78
0
  }
79
0
  return intValue;
80
0
}
81
82
#ifdef DEBUG_FRAME_DUMP
83
nsresult
84
nsLegendFrame::GetFrameName(nsAString& aResult) const
85
{
86
  return MakeFrameName(NS_LITERAL_STRING("Legend"), aResult);
87
}
88
#endif