1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/mathml/nsMathMLmfencedFrame.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsMathMLmfencedFrame_h 1.10 +#define nsMathMLmfencedFrame_h 1.11 + 1.12 +#include "mozilla/Attributes.h" 1.13 +#include "nsMathMLContainerFrame.h" 1.14 + 1.15 +// 1.16 +// <mfenced> -- surround content with a pair of fences 1.17 +// 1.18 + 1.19 +class nsMathMLmfencedFrame : public nsMathMLContainerFrame { 1.20 +public: 1.21 + NS_DECL_FRAMEARENA_HELPERS 1.22 + 1.23 + friend nsIFrame* NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); 1.24 + 1.25 + virtual void 1.26 + SetAdditionalStyleContext(int32_t aIndex, 1.27 + nsStyleContext* aStyleContext) MOZ_OVERRIDE; 1.28 + virtual nsStyleContext* 1.29 + GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE; 1.30 + 1.31 + NS_IMETHOD 1.32 + InheritAutomaticData(nsIFrame* aParent) MOZ_OVERRIDE; 1.33 + 1.34 + virtual nsresult 1.35 + SetInitialChildList(ChildListID aListID, 1.36 + nsFrameList& aChildList) MOZ_OVERRIDE; 1.37 + 1.38 + virtual nsresult 1.39 + Reflow(nsPresContext* aPresContext, 1.40 + nsHTMLReflowMetrics& aDesiredSize, 1.41 + const nsHTMLReflowState& aReflowState, 1.42 + nsReflowStatus& aStatus) MOZ_OVERRIDE; 1.43 + 1.44 + virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, 1.45 + const nsRect& aDirtyRect, 1.46 + const nsDisplayListSet& aLists) MOZ_OVERRIDE; 1.47 + 1.48 + virtual void 1.49 + GetIntrinsicWidthMetrics(nsRenderingContext* aRenderingContext, 1.50 + nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; 1.51 + 1.52 + virtual nsresult 1.53 + AttributeChanged(int32_t aNameSpaceID, 1.54 + nsIAtom* aAttribute, 1.55 + int32_t aModType) MOZ_OVERRIDE; 1.56 + 1.57 + // override the base method because we must keep separators in sync 1.58 + virtual nsresult 1.59 + ChildListChanged(int32_t aModType) MOZ_OVERRIDE; 1.60 + 1.61 + // override the base method so that we can deal with fences and separators 1.62 + virtual nscoord 1.63 + FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; 1.64 + 1.65 + // helper routines to format the MathMLChars involved here 1.66 + static nsresult 1.67 + ReflowChar(nsPresContext* aPresContext, 1.68 + nsRenderingContext& aRenderingContext, 1.69 + nsMathMLChar* aMathMLChar, 1.70 + nsOperatorFlags aForm, 1.71 + int32_t aScriptLevel, 1.72 + nscoord axisHeight, 1.73 + nscoord leading, 1.74 + nscoord em, 1.75 + nsBoundingMetrics& aContainerSize, 1.76 + nscoord& aAscent, 1.77 + nscoord& aDescent, 1.78 + bool aRTL); 1.79 + 1.80 + static void 1.81 + PlaceChar(nsMathMLChar* aMathMLChar, 1.82 + nscoord aDesiredSize, 1.83 + nsBoundingMetrics& bm, 1.84 + nscoord& dx); 1.85 + 1.86 + virtual bool 1.87 + IsMrowLike() MOZ_OVERRIDE 1.88 + { 1.89 + // Always treated as an mrow with > 1 child as 1.90 + // <mfenced> <mo>%</mo> </mfenced> 1.91 + // renders equivalently to 1.92 + // <mrow> <mo> ( </mo> <mo>%</mo> <mo> ) </mo> </mrow> 1.93 + // This also holds with multiple children. (MathML3 3.3.8.1) 1.94 + return true; 1.95 + } 1.96 + 1.97 +protected: 1.98 + nsMathMLmfencedFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} 1.99 + virtual ~nsMathMLmfencedFrame(); 1.100 + 1.101 + nsMathMLChar* mOpenChar; 1.102 + nsMathMLChar* mCloseChar; 1.103 + nsMathMLChar* mSeparatorsChar; 1.104 + int32_t mSeparatorsCount; 1.105 + 1.106 + // clean up 1.107 + void 1.108 + RemoveFencesAndSeparators(); 1.109 + 1.110 + // add fences and separators when all child frames are known 1.111 + void 1.112 + CreateFencesAndSeparators(nsPresContext* aPresContext); 1.113 +}; 1.114 + 1.115 +#endif /* nsMathMLmfencedFrame_h */