nsMathMLmrowFrame.cpp (2424B)
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 "nsMathMLmrowFrame.h" 8 9 #include "mozilla/PresShell.h" 10 #include "mozilla/gfx/2D.h" 11 12 using namespace mozilla; 13 14 // 15 // <mrow> -- horizontally group any number of subexpressions - implementation 16 // 17 18 nsIFrame* NS_NewMathMLmrowFrame(PresShell* aPresShell, ComputedStyle* aStyle) { 19 return new (aPresShell) 20 nsMathMLmrowFrame(aStyle, aPresShell->GetPresContext()); 21 } 22 23 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmrowFrame) 24 25 nsMathMLmrowFrame::~nsMathMLmrowFrame() = default; 26 27 NS_IMETHODIMP 28 nsMathMLmrowFrame::InheritAutomaticData(nsIFrame* aParent) { 29 // let the base class get the default from our parent 30 nsMathMLContainerFrame::InheritAutomaticData(aParent); 31 32 mPresentationData.flags += 33 MathMLPresentationFlag::StretchAllChildrenVertically; 34 35 return NS_OK; 36 } 37 38 nsresult nsMathMLmrowFrame::AttributeChanged(int32_t aNameSpaceID, 39 nsAtom* aAttribute, 40 AttrModType aModType) { 41 // Special for <mtable>: In the frame construction code, we also use 42 // this frame class as a wrapper for mtable. Hence, we should pass the 43 // notification to the real mtable 44 if (mContent->IsMathMLElement(nsGkAtoms::mtable)) { 45 nsIFrame* frame = mFrames.FirstChild(); 46 for (; frame; frame = frame->PrincipalChildList().FirstChild()) { 47 // drill down to the real mtable 48 if (frame->IsTableWrapperFrame()) { 49 return frame->AttributeChanged(aNameSpaceID, aAttribute, aModType); 50 } 51 } 52 MOZ_ASSERT_UNREACHABLE("mtable wrapper without the real table frame"); 53 } 54 55 return nsMathMLContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, 56 aModType); 57 } 58 59 /* virtual */ 60 MathMLFrameType nsMathMLmrowFrame::GetMathMLFrameType() { 61 if (!IsMrowLike()) { 62 nsIMathMLFrame* child = do_QueryFrame(mFrames.FirstChild()); 63 if (child) { 64 // We only have one child, so we return the frame type of that child as if 65 // we didn't exist. 66 return child->GetMathMLFrameType(); 67 } 68 } 69 return nsMathMLFrame::GetMathMLFrameType(); 70 }