1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla MathML Project.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * The University Of Queensland.
19 : * Portions created by the Initial Developer are Copyright (C) 1999
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Roger B. Sidje <rbs@maths.uq.edu.au>
24 : * David J. Fiddes <D.J.Fiddes@hw.ac.uk>
25 : * Frederic Wang <fred.wang@free.fr>
26 : *
27 : * Alternatively, the contents of this file may be used under the terms of
28 : * either of the GNU General Public License Version 2 or later (the "GPL"),
29 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 : * in which case the provisions of the GPL or the LGPL are applicable instead
31 : * of those above. If you wish to allow use of your version of this file only
32 : * under the terms of either the GPL or the LGPL, and not to allow others to
33 : * use your version of this file under the terms of the MPL, indicate your
34 : * decision by deleting the provisions above and replace them with the notice
35 : * and other provisions required by the GPL or the LGPL. If you do not delete
36 : * the provisions above, a recipient may use your version of this file under
37 : * the terms of any one of the MPL, the GPL or the LGPL.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 :
42 : #include "nsCOMPtr.h"
43 : #include "nsFrame.h"
44 : #include "nsStyleContext.h"
45 : #include "nsStyleConsts.h"
46 : #include "nsINameSpaceManager.h"
47 :
48 : #include "nsMathMLmstyleFrame.h"
49 :
50 : //
51 : // <mstyle> -- style change
52 : //
53 :
54 : nsIFrame*
55 0 : NS_NewMathMLmstyleFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
56 : {
57 0 : return new (aPresShell) nsMathMLmstyleFrame(aContext);
58 : }
59 :
60 0 : NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmstyleFrame)
61 :
62 0 : nsMathMLmstyleFrame::~nsMathMLmstyleFrame()
63 : {
64 0 : }
65 :
66 : // mstyle needs special care for its scriptlevel and displaystyle attributes
67 : NS_IMETHODIMP
68 0 : nsMathMLmstyleFrame::InheritAutomaticData(nsIFrame* aParent)
69 : {
70 : // let the base class get the default from our parent
71 0 : nsMathMLContainerFrame::InheritAutomaticData(aParent);
72 :
73 : // sync with our current state
74 0 : mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY;
75 0 : mPresentationData.mstyle = this;
76 :
77 : // see if the displaystyle attribute is there
78 0 : nsMathMLFrame::FindAttrDisplaystyle(mContent, mPresentationData);
79 :
80 : // see if the directionality attribute is there
81 0 : nsMathMLFrame::FindAttrDirectionality(mContent, mPresentationData);
82 :
83 0 : return NS_OK;
84 : }
85 :
86 : NS_IMETHODIMP
87 0 : nsMathMLmstyleFrame::TransmitAutomaticData()
88 : {
89 0 : return TransmitAutomaticDataForMrowLikeElement();
90 : }
91 :
92 : // displaystyle and scriptlevel are special in <mstyle>...
93 : // Since UpdatePresentation() and UpdatePresentationDataFromChildAt() can be called
94 : // by a parent, ensure that the explicit attributes of <mstyle> take precedence
95 : NS_IMETHODIMP
96 0 : nsMathMLmstyleFrame::UpdatePresentationData(PRUint32 aFlagsValues,
97 : PRUint32 aWhichFlags)
98 : {
99 0 : if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) {
100 : // our current state takes precedence, disallow updating the displastyle
101 0 : aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE;
102 0 : aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE;
103 : }
104 :
105 0 : return nsMathMLContainerFrame::UpdatePresentationData(aFlagsValues, aWhichFlags);
106 : }
107 :
108 : NS_IMETHODIMP
109 0 : nsMathMLmstyleFrame::UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex,
110 : PRInt32 aLastIndex,
111 : PRUint32 aFlagsValues,
112 : PRUint32 aWhichFlags)
113 : {
114 0 : if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) {
115 : // our current state takes precedence, disallow updating the displastyle
116 0 : aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE;
117 0 : aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE;
118 : }
119 :
120 : // let the base class worry about the update
121 : return
122 : nsMathMLContainerFrame::UpdatePresentationDataFromChildAt(
123 0 : aFirstIndex, aLastIndex, aFlagsValues, aWhichFlags);
124 : }
125 :
126 : NS_IMETHODIMP
127 0 : nsMathMLmstyleFrame::AttributeChanged(PRInt32 aNameSpaceID,
128 : nsIAtom* aAttribute,
129 : PRInt32 aModType)
130 : {
131 : // Other attributes can affect too many things, ask our parent to re-layout
132 : // its children so that we can pick up changes in our attributes & transmit
133 : // them in our subtree. However, our siblings will be re-laid too. We used
134 : // to have a more speedier but more verbose alternative that didn't re-layout
135 : // our siblings. See bug 114909 - attachment 67668.
136 0 : return ReLayoutChildren(mParent);
137 : }
|