layout/forms/nsLegendFrame.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial