2007-06-12 10:10:23 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-09-21 06:12:01 +04:00
|
|
|
|
|
|
|
#ifndef nsMathMLContainerFrame_h___
|
|
|
|
#define nsMathMLContainerFrame_h___
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
1999-10-12 08:38:21 +04:00
|
|
|
#include "nsBlockFrame.h"
|
|
|
|
#include "nsInlineFrame.h"
|
1999-09-21 06:12:01 +04:00
|
|
|
#include "nsMathMLOperators.h"
|
2001-02-23 19:10:51 +03:00
|
|
|
#include "nsMathMLFrame.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
1999-09-21 06:12:01 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Base class for MathML container frames. It acts like an inferred
|
|
|
|
* mrow. By default, this frame uses its Reflow() method to lay its
|
|
|
|
* children horizontally and ensure that their baselines are aligned.
|
1999-12-10 16:02:23 +03:00
|
|
|
* The Reflow() method relies upon Place() to position children.
|
|
|
|
* By overloading Place() in derived classes, it is therefore possible
|
|
|
|
* to position children in various customized ways.
|
1999-09-21 06:12:01 +04:00
|
|
|
*/
|
|
|
|
|
2002-01-02 08:32:33 +03:00
|
|
|
// Options for the preferred size at which to stretch our stretchy children
|
|
|
|
#define STRETCH_CONSIDER_ACTUAL_SIZE 0x00000001 // just use our current size
|
|
|
|
#define STRETCH_CONSIDER_EMBELLISHMENTS 0x00000002 // size calculations include embellishments
|
|
|
|
|
2011-12-28 00:18:48 +04:00
|
|
|
class nsMathMLContainerFrame : public nsContainerFrame,
|
2001-02-23 19:10:51 +03:00
|
|
|
public nsMathMLFrame {
|
2007-03-02 13:55:55 +03:00
|
|
|
friend class nsMathMLmfencedFrame;
|
1999-09-21 06:12:01 +04:00
|
|
|
public:
|
2015-03-05 04:30:07 +03:00
|
|
|
explicit nsMathMLContainerFrame(nsStyleContext* aContext)
|
|
|
|
: nsContainerFrame(aContext)
|
|
|
|
, mIntrinsicWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
|
2016-05-04 03:26:42 +03:00
|
|
|
, mBlockStartAscent(0)
|
2015-03-05 04:30:07 +03:00
|
|
|
{}
|
1999-09-21 06:12:01 +04:00
|
|
|
|
2013-11-25 18:20:20 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsMathMLContainerFrame)
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2015-11-04 12:57:35 +03:00
|
|
|
NS_DECL_ABSTRACT_FRAME(nsMathMLContainerFrame)
|
1999-12-10 16:02:23 +03:00
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Overloaded nsMathMLFrame methods -- see documentation in nsIMathMLFrame.h
|
2000-01-07 17:49:46 +03:00
|
|
|
|
1999-12-10 16:02:23 +03:00
|
|
|
NS_IMETHOD
|
2015-12-16 00:56:41 +03:00
|
|
|
Stretch(DrawTarget* aDrawTarget,
|
1999-12-10 16:02:23 +03:00
|
|
|
nsStretchDirection aStretchDirection,
|
2000-03-28 13:38:24 +04:00
|
|
|
nsBoundingMetrics& aContainerSize,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredStretchSize) override;
|
2001-02-23 19:10:51 +03:00
|
|
|
|
1999-12-10 16:02:23 +03:00
|
|
|
NS_IMETHOD
|
2012-08-22 19:56:38 +04:00
|
|
|
UpdatePresentationDataFromChildAt(int32_t aFirstIndex,
|
|
|
|
int32_t aLastIndex,
|
|
|
|
uint32_t aFlagsValues,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aFlagsToUpdate) override
|
2002-01-09 21:51:30 +03:00
|
|
|
{
|
2005-02-07 04:57:50 +03:00
|
|
|
PropagatePresentationDataFromChildAt(this, aFirstIndex, aLastIndex,
|
2008-01-09 12:38:28 +03:00
|
|
|
aFlagsValues, aFlagsToUpdate);
|
2002-01-09 21:51:30 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-01-09 12:38:28 +03:00
|
|
|
|
|
|
|
// helper to set the "increment script level" flag on the element belonging
|
|
|
|
// to a child frame given by aChildIndex.
|
|
|
|
// When this flag is set, the style system will increment the scriptlevel
|
|
|
|
// for the child element. This is needed for situations where the style system
|
|
|
|
// cannot itself determine the scriptlevel (mfrac, munder, mover, munderover).
|
|
|
|
// This should be called during reflow. We set the flag and if it changed,
|
|
|
|
// we request appropriate restyling and also queue a post-reflow callback
|
|
|
|
// to ensure that restyle and reflow happens immediately after the current
|
|
|
|
// reflow.
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
SetIncrementScriptLevel(int32_t aChildIndex, bool aIncrement);
|
1999-09-21 06:12:01 +04:00
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
// --------------------------------------------------------------------------
|
2011-12-28 00:18:48 +04:00
|
|
|
// Overloaded nsContainerFrame methods -- see documentation in nsIFrame.h
|
2002-02-01 18:10:50 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override
|
2007-02-24 21:33:33 +03:00
|
|
|
{
|
2007-10-12 12:30:54 +04:00
|
|
|
return !(aFlags & nsIFrame::eLineParticipant) &&
|
2011-12-28 00:18:48 +04:00
|
|
|
nsContainerFrame::IsFrameOfType(aFlags &
|
2008-07-14 02:41:18 +04:00
|
|
|
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
|
2007-02-24 21:33:33 +03:00
|
|
|
}
|
2001-02-02 12:37:14 +03:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
AppendFrames(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override;
|
2002-01-25 09:48:30 +03:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
InsertFrames(ChildListID aListID,
|
2002-01-25 09:48:30 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override;
|
2002-01-25 09:48:30 +03:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
RemoveFrame(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aOldFrame) override;
|
2002-01-25 09:48:30 +03:00
|
|
|
|
2008-02-27 13:45:36 +03:00
|
|
|
/**
|
2014-07-24 21:03:25 +04:00
|
|
|
* Both GetMinISize and GetPrefISize use the intrinsic width metrics
|
2013-11-25 18:20:20 +04:00
|
|
|
* returned by GetIntrinsicMetrics, including ink overflow.
|
2008-02-27 13:45:36 +03:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nscoord GetMinISize(nsRenderingContext* aRenderingContext) override;
|
|
|
|
virtual nscoord GetPrefISize(nsRenderingContext* aRenderingContext) override;
|
2008-02-27 13:45:36 +03:00
|
|
|
|
|
|
|
/**
|
2013-11-25 18:20:20 +04:00
|
|
|
* Return the intrinsic horizontal metrics of the frame's content area.
|
2008-02-27 13:45:36 +03:00
|
|
|
*/
|
2013-11-25 18:20:20 +04:00
|
|
|
virtual void
|
2014-07-24 21:03:26 +04:00
|
|
|
GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize);
|
2008-02-27 13:45:36 +03:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void
|
2004-08-01 03:15:21 +04:00
|
|
|
Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsReflowStatus& aStatus) override;
|
1999-09-21 06:12:01 +04:00
|
|
|
|
2014-05-13 04:47:53 +04:00
|
|
|
virtual void DidReflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput* aReflowInput,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsDidReflowStatus aStatus) override
|
1999-12-10 16:02:23 +03:00
|
|
|
|
|
|
|
{
|
2002-02-07 07:38:08 +03:00
|
|
|
mPresentationData.flags &= ~NS_MATHML_STRETCH_DONE;
|
2016-07-21 13:36:39 +03:00
|
|
|
return nsContainerFrame::DidReflow(aPresContext, aReflowInput, aStatus);
|
1999-12-10 16:02:23 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2002-02-04 00:06:51 +03:00
|
|
|
|
2016-05-04 03:27:43 +03:00
|
|
|
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
|
2011-06-16 01:03:49 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void MarkIntrinsicISizesDirty() override;
|
2015-03-05 04:30:07 +03:00
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
// Notification when an attribute is changed. The MathML module uses the
|
|
|
|
// following paradigm:
|
|
|
|
//
|
|
|
|
// 1. If the MathML frame class doesn't have any cached automatic data that
|
|
|
|
// depends on the attribute: we just reflow (e.g., this happens with <msub>,
|
|
|
|
// <msup>, <mmultiscripts>, etc). This is the default behavior implemented
|
|
|
|
// by this base class.
|
|
|
|
//
|
|
|
|
// 2. If the MathML frame class has cached automatic data that depends on
|
|
|
|
// the attribute:
|
|
|
|
// 2a. If the automatic data to update resides only within the descendants,
|
2007-05-06 23:16:51 +04:00
|
|
|
// we just re-layout them using ReLayoutChildren(this);
|
2002-02-07 07:38:08 +03:00
|
|
|
// (e.g., this happens with <ms>).
|
|
|
|
// 2b. If the automatic data to update affects us in some way, we ask our parent
|
2007-05-06 23:16:51 +04:00
|
|
|
// to re-layout its children using ReLayoutChildren(mParent);
|
2002-02-07 07:38:08 +03:00
|
|
|
// Therefore, there is an overhead here in that our siblings are re-laid
|
2014-01-15 19:07:45 +04:00
|
|
|
// too (e.g., this happens with <munder>, <mover>, <munderover>).
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
AttributeChanged(int32_t aNameSpaceID,
|
2001-02-23 19:10:51 +03:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
2001-02-23 19:10:51 +03:00
|
|
|
|
2010-01-05 13:22:31 +03:00
|
|
|
// helper function to apply mirroring to a horizontal coordinate, if needed.
|
|
|
|
nscoord
|
|
|
|
MirrorIfRTL(nscoord aParentWidth, nscoord aChildWidth, nscoord aChildLeading)
|
|
|
|
{
|
2013-05-30 03:26:40 +04:00
|
|
|
return (StyleVisibility()->mDirection ?
|
2010-01-05 13:22:31 +03:00
|
|
|
aParentWidth - aChildWidth - aChildLeading : aChildLeading);
|
|
|
|
}
|
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Additional methods
|
2000-01-18 07:35:37 +03:00
|
|
|
|
2008-03-18 07:52:48 +03:00
|
|
|
protected:
|
|
|
|
/* Place :
|
|
|
|
* This method is used to measure or position child frames and other
|
|
|
|
* elements. It may be called any number of times with aPlaceOrigin
|
|
|
|
* false to measure, and the final call of the Reflow process before
|
|
|
|
* returning from Reflow() or Stretch() will have aPlaceOrigin true
|
|
|
|
* to position the elements.
|
|
|
|
*
|
|
|
|
* IMPORTANT: This method uses GetReflowAndBoundingMetricsFor() which must
|
|
|
|
* have been set up with SaveReflowAndBoundingMetricsFor().
|
|
|
|
*
|
|
|
|
* The Place() method will use this information to compute the desired size
|
|
|
|
* of the frame.
|
|
|
|
*
|
|
|
|
* @param aPlaceOrigin [in]
|
|
|
|
* If aPlaceOrigin is false, compute your desired size using the
|
|
|
|
* information from GetReflowAndBoundingMetricsFor. However, child
|
|
|
|
* frames or other elements should not be repositioned.
|
|
|
|
*
|
|
|
|
* If aPlaceOrigin is true, reflow is finished. You should position
|
|
|
|
* all your children, and return your desired size. You should now
|
|
|
|
* use FinishReflowChild() on your children to complete post-reflow
|
|
|
|
* operations.
|
|
|
|
*
|
|
|
|
* @param aDesiredSize [out] parameter where you should return your desired
|
|
|
|
* size and your ascent/descent info. Compute your desired size using
|
|
|
|
* the information from GetReflowAndBoundingMetricsFor, and include
|
|
|
|
* any space you want for border/padding in the desired size you
|
|
|
|
* return.
|
|
|
|
*/
|
|
|
|
virtual nsresult
|
2015-12-16 00:56:41 +03:00
|
|
|
Place(DrawTarget* aDrawTarget,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aPlaceOrigin,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize);
|
2008-03-18 07:52:48 +03:00
|
|
|
|
2009-05-29 15:08:35 +04:00
|
|
|
// MeasureForWidth:
|
2008-03-18 08:06:23 +03:00
|
|
|
//
|
2014-07-24 21:03:26 +04:00
|
|
|
// A method used by nsMathMLContainerFrame::GetIntrinsicISize to get the
|
2008-03-18 08:06:23 +03:00
|
|
|
// width that a particular Place method desires. For most frames, this will
|
2009-05-29 15:08:35 +04:00
|
|
|
// just call the object's Place method. However <msqrt> and <menclose> use
|
2014-07-24 21:03:26 +04:00
|
|
|
// nsMathMLContainerFrame::GetIntrinsicISize to measure the child frames as
|
2009-05-29 15:08:35 +04:00
|
|
|
// if in an <mrow>, and so their frames implement MeasureForWidth to use
|
|
|
|
// nsMathMLContainerFrame::Place.
|
2008-03-18 08:06:23 +03:00
|
|
|
virtual nsresult
|
2015-12-16 00:56:41 +03:00
|
|
|
MeasureForWidth(DrawTarget* aDrawTarget,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize);
|
2008-03-18 08:06:23 +03:00
|
|
|
|
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
// helper to re-sync the automatic data in our children and notify our parent to
|
|
|
|
// reflow us when changes (e.g., append/insert/remove) happen in our child list
|
2002-02-01 18:10:50 +03:00
|
|
|
virtual nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
ChildListChanged(int32_t aModType);
|
2002-02-01 18:10:50 +03:00
|
|
|
|
2002-01-02 08:32:33 +03:00
|
|
|
// helper to get the preferred size that a container frame should use to fire
|
|
|
|
// the stretch on its stretchy child frames.
|
2008-03-18 07:52:48 +03:00
|
|
|
void
|
2015-12-16 00:56:41 +03:00
|
|
|
GetPreferredStretchSize(DrawTarget* aDrawTarget,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aOptions,
|
2002-01-02 08:32:33 +03:00
|
|
|
nsStretchDirection aStretchDirection,
|
|
|
|
nsBoundingMetrics& aPreferredStretchSize);
|
|
|
|
|
2011-03-25 06:38:59 +03:00
|
|
|
// helper used by mstyle, mphantom, mpadded and mrow in their implementation
|
|
|
|
// of TransmitAutomaticData() to determine whether they are space-like.
|
|
|
|
nsresult
|
|
|
|
TransmitAutomaticDataForMrowLikeElement();
|
|
|
|
|
2008-03-18 07:52:48 +03:00
|
|
|
public:
|
2002-02-01 18:10:50 +03:00
|
|
|
// error handlers to provide a visual feedback to the user when an error
|
|
|
|
// (typically invalid markup) was encountered during reflow.
|
2008-03-18 07:52:48 +03:00
|
|
|
nsresult
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowError(DrawTarget* aDrawTarget, ReflowOutput& aDesiredSize);
|
2012-12-27 20:12:05 +04:00
|
|
|
/*
|
|
|
|
* Helper to call ReportErrorToConsole for parse errors involving
|
|
|
|
* attribute/value pairs.
|
|
|
|
* @param aAttribute The attribute for which the parse error occured.
|
|
|
|
* @param aValue The value for which the parse error occured.
|
|
|
|
*/
|
|
|
|
nsresult
|
2014-01-04 19:02:17 +04:00
|
|
|
ReportParseError(const char16_t* aAttribute,
|
|
|
|
const char16_t* aValue);
|
2012-12-27 20:12:05 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper to call ReportErrorToConsole when certain tags
|
|
|
|
* have more than the expected amount of children.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
ReportChildCountError();
|
|
|
|
|
2013-08-19 17:09:34 +04:00
|
|
|
/*
|
|
|
|
* Helper to call ReportErrorToConsole when certain tags have
|
|
|
|
* invalid child tags
|
|
|
|
* @param aChildTag The tag which is forbidden in this context
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
ReportInvalidChildError(nsIAtom* aChildTag);
|
|
|
|
|
2012-12-27 20:12:05 +04:00
|
|
|
/*
|
|
|
|
* Helper to call ReportToConsole when an error occurs.
|
|
|
|
* @param aParams see nsContentUtils::ReportToConsole
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
ReportErrorToConsole(const char* aErrorMsgId,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t** aParams = nullptr,
|
2013-01-08 03:21:50 +04:00
|
|
|
uint32_t aParamCount = 0);
|
2000-03-28 13:38:24 +04:00
|
|
|
|
1999-12-10 16:02:23 +03:00
|
|
|
// helper method to reflow a child frame. We are inline frames, and we don't
|
1999-11-22 06:29:14 +03:00
|
|
|
// know our positions until reflow is finished. That's why we ask the
|
|
|
|
// base method not to worry about our position.
|
2014-05-13 04:47:53 +04:00
|
|
|
void
|
1999-11-22 06:29:14 +03:00
|
|
|
ReflowChild(nsIFrame* aKidFrame,
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2006-01-04 10:29:09 +03:00
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2008-03-18 07:52:48 +03:00
|
|
|
protected:
|
2001-02-23 19:10:51 +03:00
|
|
|
// helper to add the inter-spacing when <math> is the immediate parent.
|
|
|
|
// Since we don't (yet) handle the root <math> element ourselves, we need to
|
|
|
|
// take special care of the inter-frame spacing on elements for which <math>
|
|
|
|
// is the direct xml parent. This function will be repeatedly called from
|
|
|
|
// left to right on the childframes of <math>, and by so doing it will
|
|
|
|
// emulate the spacing that would have been done by a <mrow> container.
|
|
|
|
// e.g., it fixes <math> <mi>f</mi> <mo>q</mo> <mi>f</mi> <mo>I</mo> </math>
|
2005-09-16 04:39:27 +04:00
|
|
|
virtual nscoord
|
2016-07-21 13:36:38 +03:00
|
|
|
FixInterFrameSpacing(ReflowOutput& aDesiredSize);
|
2001-02-23 19:10:51 +03:00
|
|
|
|
2000-01-07 17:49:46 +03:00
|
|
|
// helper method to complete the post-reflow hook and ensure that embellished
|
1999-12-10 16:02:23 +03:00
|
|
|
// operators don't terminate their Reflow without receiving a Stretch command.
|
2000-03-28 13:38:24 +04:00
|
|
|
virtual nsresult
|
2016-07-21 13:36:38 +03:00
|
|
|
FinalizeReflow(DrawTarget* aDrawTarget, ReflowOutput& aDesiredSize);
|
1999-12-10 16:02:23 +03:00
|
|
|
|
2008-02-26 07:19:36 +03:00
|
|
|
// Record metrics of a child frame for recovery through the following method
|
|
|
|
static void
|
|
|
|
SaveReflowAndBoundingMetricsFor(nsIFrame* aFrame,
|
2016-07-21 13:36:38 +03:00
|
|
|
const ReflowOutput& aReflowMetrics,
|
2008-02-26 07:19:36 +03:00
|
|
|
const nsBoundingMetrics& aBoundingMetrics);
|
|
|
|
|
|
|
|
// helper method to facilitate getting the reflow and bounding metrics of a
|
|
|
|
// child frame. The argument aMathMLFrameType, when non null, will return
|
|
|
|
// the 'type' of the frame, which is used to determine the inter-frame
|
|
|
|
// spacing.
|
|
|
|
// IMPORTANT: This function is only meant to be called in Place() methods as
|
|
|
|
// the information is available only when set up with the above method
|
2014-07-24 21:03:25 +04:00
|
|
|
// during Reflow/Stretch() and GetPrefISize().
|
2000-01-18 07:35:37 +03:00
|
|
|
static void
|
|
|
|
GetReflowAndBoundingMetricsFor(nsIFrame* aFrame,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aReflowMetrics,
|
2006-08-15 08:49:43 +04:00
|
|
|
nsBoundingMetrics& aBoundingMetrics,
|
2012-07-30 18:20:58 +04:00
|
|
|
eMathMLFrameType* aMathMLFrameType = nullptr);
|
2000-01-07 17:49:46 +03:00
|
|
|
|
2008-02-26 07:19:36 +03:00
|
|
|
// helper method to clear metrics saved with
|
|
|
|
// SaveReflowAndBoundingMetricsFor() from all child frames.
|
|
|
|
void ClearSavedChildMetrics();
|
|
|
|
|
2002-01-09 21:51:30 +03:00
|
|
|
// helper to let the update of presentation data pass through
|
|
|
|
// a subtree that may contain non-MathML container frames
|
2000-03-28 13:38:24 +04:00
|
|
|
static void
|
2005-02-07 04:57:50 +03:00
|
|
|
PropagatePresentationDataFor(nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlagsValues,
|
|
|
|
uint32_t aFlagsToUpdate);
|
2000-04-17 08:23:03 +04:00
|
|
|
|
2008-03-18 07:52:48 +03:00
|
|
|
public:
|
2002-01-14 03:55:53 +03:00
|
|
|
static void
|
2005-02-07 04:57:50 +03:00
|
|
|
PropagatePresentationDataFromChildAt(nsIFrame* aParentFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aFirstChildIndex,
|
|
|
|
int32_t aLastChildIndex,
|
|
|
|
uint32_t aFlagsValues,
|
|
|
|
uint32_t aFlagsToUpdate);
|
2002-01-14 03:55:53 +03:00
|
|
|
|
2014-01-15 18:49:00 +04:00
|
|
|
// Sets flags on aFrame and all descendant frames
|
|
|
|
static void
|
|
|
|
PropagateFrameFlagFor(nsIFrame* aFrame,
|
2014-02-05 05:59:39 +04:00
|
|
|
nsFrameState aFlags);
|
2014-01-15 18:49:00 +04:00
|
|
|
|
2002-02-01 18:10:50 +03:00
|
|
|
// helper to let the rebuild of automatic data (presentation data
|
|
|
|
// and embellishement data) walk through a subtree that may contain
|
2002-02-07 07:38:08 +03:00
|
|
|
// non-MathML container frames. Note that this method re-builds the
|
|
|
|
// automatic data in the children -- not in aParentFrame itself (except
|
|
|
|
// for those particular operations that the parent frame may do in its
|
|
|
|
// TransmitAutomaticData()). The reason it works this way is because
|
|
|
|
// a container frame knows what it wants for its children, whereas children
|
|
|
|
// have no clue who their parent is. For example, it is <mfrac> who knows
|
|
|
|
// that its children have to be in scriptsizes, and has to transmit this
|
|
|
|
// information to them. Hence, when changes occur in a child frame, the child
|
|
|
|
// has to request the re-build from its parent. Unfortunately, the extra cost
|
|
|
|
// for this is that it will re-sync in the siblings of the child as well.
|
2002-02-01 18:10:50 +03:00
|
|
|
static void
|
2005-02-07 04:57:50 +03:00
|
|
|
RebuildAutomaticDataForChildren(nsIFrame* aParentFrame);
|
2002-02-01 18:10:50 +03:00
|
|
|
|
2002-02-04 00:06:51 +03:00
|
|
|
// helper to blow away the automatic data cached in a frame's subtree and
|
|
|
|
// re-layout its subtree to reflect changes that may have happen. In the
|
2002-02-07 07:38:08 +03:00
|
|
|
// event where aParentFrame isn't a MathML frame, it will first walk up to
|
|
|
|
// the ancestor that is a MathML frame, and re-layout from there -- this is
|
|
|
|
// to guarantee that automatic data will be rebuilt properly. Note that this
|
|
|
|
// method re-builds the automatic data in the children -- not in the parent
|
|
|
|
// frame itself (except for those particular operations that the parent frame
|
|
|
|
// may do do its TransmitAutomaticData()). @see RebuildAutomaticDataForChildren
|
2007-05-06 23:16:51 +04:00
|
|
|
//
|
|
|
|
// aBits are the bits to pass to FrameNeedsReflow() when we call it.
|
2002-02-04 00:06:51 +03:00
|
|
|
static nsresult
|
2009-02-11 01:05:27 +03:00
|
|
|
ReLayoutChildren(nsIFrame* aParentFrame);
|
2002-02-04 00:06:51 +03:00
|
|
|
|
1999-09-21 06:12:01 +04:00
|
|
|
protected:
|
2008-01-03 07:33:21 +03:00
|
|
|
// Helper method which positions child frames as an <mrow> on given baseline
|
|
|
|
// y = aBaseline starting from x = aOffsetX, calling FinishReflowChild()
|
|
|
|
// on the frames.
|
|
|
|
void
|
|
|
|
PositionRowChildFrames(nscoord aOffsetX, nscoord aBaseline);
|
|
|
|
|
2007-12-29 02:04:19 +03:00
|
|
|
// A variant on FinishAndStoreOverflow() that uses the union of child
|
|
|
|
// overflows, the frame bounds, and mBoundingMetrics to set and store the
|
|
|
|
// overflow.
|
2016-07-21 13:36:38 +03:00
|
|
|
void GatherAndStoreOverflow(ReflowOutput* aMetrics);
|
2007-12-29 02:04:19 +03:00
|
|
|
|
2007-03-02 13:55:55 +03:00
|
|
|
/**
|
|
|
|
* Call DidReflow() if the NS_FRAME_IN_REFLOW frame bit is set on aFirst and
|
|
|
|
* all its next siblings up to, but not including, aStop.
|
2012-07-30 18:20:58 +04:00
|
|
|
* aStop == nullptr meaning all next siblings with the bit set.
|
|
|
|
* The method does nothing if aFirst == nullptr.
|
2007-03-02 13:55:55 +03:00
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
static void DidReflowChildren(nsIFrame* aFirst, nsIFrame* aStop = nullptr);
|
2008-01-03 07:33:21 +03:00
|
|
|
|
2015-03-05 04:30:07 +03:00
|
|
|
/**
|
|
|
|
* Recompute mIntrinsicWidth if it's not already up to date.
|
|
|
|
*/
|
2015-03-05 07:22:26 +03:00
|
|
|
void UpdateIntrinsicWidth(nsRenderingContext* aRenderingContext);
|
2015-03-05 04:30:07 +03:00
|
|
|
|
|
|
|
nscoord mIntrinsicWidth;
|
|
|
|
|
2016-05-04 03:26:42 +03:00
|
|
|
nscoord mBlockStartAscent;
|
|
|
|
|
2008-01-03 07:33:21 +03:00
|
|
|
private:
|
|
|
|
class RowChildFrameIterator;
|
|
|
|
friend class RowChildFrameIterator;
|
1999-09-21 06:12:01 +04:00
|
|
|
};
|
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Currently, to benefit from line-breaking inside the <math> element, <math> is
|
|
|
|
// simply mapping to nsBlockFrame or nsInlineFrame.
|
|
|
|
// A separate implemention needs to provide:
|
|
|
|
// 1) line-breaking
|
|
|
|
// 2) proper inter-frame spacing
|
|
|
|
// 3) firing of Stretch() (in which case FinalizeReflow() would have to be cleaned)
|
|
|
|
// Issues: If/when mathml becomes a pluggable component, the separation will be needed.
|
|
|
|
class nsMathMLmathBlockFrame : public nsBlockFrame {
|
1999-11-17 03:49:37 +03:00
|
|
|
public:
|
2014-04-04 19:54:00 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsMathMLmathBlockFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2014-05-25 02:20:39 +04:00
|
|
|
friend nsContainerFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell,
|
2014-02-05 05:59:39 +04:00
|
|
|
nsStyleContext* aContext, nsFrameState aFlags);
|
1999-11-17 03:49:37 +03:00
|
|
|
|
2002-02-01 18:10:50 +03:00
|
|
|
// beware, mFrames is not set by nsBlockFrame
|
|
|
|
// cannot use mFrames{.FirstChild()|.etc} since the block code doesn't set mFrames
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
SetInitialChildList(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aChildList) override
|
2001-02-23 19:10:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBlockFrame::SetInitialChildList(aListID, aChildList);
|
2002-02-07 07:38:08 +03:00
|
|
|
// re-resolve our subtree to set any mathml-expected data
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLContainerFrame::RebuildAutomaticDataForChildren(this);
|
2001-02-23 19:10:51 +03:00
|
|
|
}
|
1999-11-17 03:49:37 +03:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
AppendFrames(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override
|
2002-02-04 00:06:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList || aListID == kNoReflowPrincipalList,
|
2007-11-09 11:19:45 +03:00
|
|
|
"unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBlockFrame::AppendFrames(aListID, aFrameList);
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(aListID == kPrincipalList))
|
2009-02-11 01:05:27 +03:00
|
|
|
nsMathMLContainerFrame::ReLayoutChildren(this);
|
2002-02-04 00:06:51 +03:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
InsertFrames(ChildListID aListID,
|
2002-02-04 00:06:51 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override
|
2002-02-04 00:06:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList || aListID == kNoReflowPrincipalList,
|
2007-11-09 11:19:45 +03:00
|
|
|
"unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBlockFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(aListID == kPrincipalList))
|
2009-02-11 01:05:27 +03:00
|
|
|
nsMathMLContainerFrame::ReLayoutChildren(this);
|
2002-02-04 00:06:51 +03:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
RemoveFrame(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aOldFrame) override
|
2002-02-04 00:06:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList || aListID == kNoReflowPrincipalList,
|
2007-11-09 11:19:45 +03:00
|
|
|
"unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBlockFrame::RemoveFrame(aListID, aOldFrame);
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(aListID == kPrincipalList))
|
2009-02-11 01:05:27 +03:00
|
|
|
nsMathMLContainerFrame::ReLayoutChildren(this);
|
2002-02-04 00:06:51 +03:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2008-07-14 02:41:18 +04:00
|
|
|
return nsBlockFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
|
2006-10-09 02:04:09 +04:00
|
|
|
}
|
|
|
|
|
2014-04-04 19:54:00 +04:00
|
|
|
// See nsIMathMLFrame.h
|
|
|
|
bool IsMrowLike() {
|
|
|
|
return mFrames.FirstChild() != mFrames.LastChild() ||
|
|
|
|
!mFrames.FirstChild();
|
|
|
|
}
|
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
protected:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsMathMLmathBlockFrame(nsStyleContext* aContext) : nsBlockFrame(aContext) {
|
2009-01-05 03:39:54 +03:00
|
|
|
// We should always have a float manager. Not that things can really try
|
2006-09-25 00:30:43 +04:00
|
|
|
// to float out of us anyway, but we need one for line layout.
|
2009-01-05 03:39:54 +03:00
|
|
|
AddStateBits(NS_BLOCK_FLOAT_MGR);
|
2006-09-25 00:30:43 +04:00
|
|
|
}
|
2001-02-23 19:10:51 +03:00
|
|
|
virtual ~nsMathMLmathBlockFrame() {}
|
|
|
|
};
|
1999-12-10 16:02:23 +03:00
|
|
|
|
2002-02-01 18:10:50 +03:00
|
|
|
// --------------
|
|
|
|
|
2014-04-04 19:54:00 +04:00
|
|
|
class nsMathMLmathInlineFrame : public nsInlineFrame,
|
|
|
|
public nsMathMLFrame {
|
2001-02-23 19:10:51 +03:00
|
|
|
public:
|
2014-04-04 19:54:00 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsMathMLmathInlineFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2014-05-25 02:20:39 +04:00
|
|
|
friend nsContainerFrame* NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2001-02-23 19:10:51 +03:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
SetInitialChildList(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aChildList) override
|
2001-02-23 19:10:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsInlineFrame::SetInitialChildList(aListID, aChildList);
|
2002-02-07 07:38:08 +03:00
|
|
|
// re-resolve our subtree to set any mathml-expected data
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLContainerFrame::RebuildAutomaticDataForChildren(this);
|
2001-02-23 19:10:51 +03:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
AppendFrames(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override
|
2002-02-04 00:06:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList || aListID == kNoReflowPrincipalList,
|
2007-11-09 11:19:45 +03:00
|
|
|
"unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsInlineFrame::AppendFrames(aListID, aFrameList);
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(aListID == kPrincipalList))
|
2009-02-11 01:05:27 +03:00
|
|
|
nsMathMLContainerFrame::ReLayoutChildren(this);
|
2002-02-04 00:06:51 +03:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
InsertFrames(ChildListID aListID,
|
2002-02-04 00:06:51 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override
|
2002-02-04 00:06:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList || aListID == kNoReflowPrincipalList,
|
2007-11-09 11:19:45 +03:00
|
|
|
"unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsInlineFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(aListID == kPrincipalList))
|
2009-02-11 01:05:27 +03:00
|
|
|
nsMathMLContainerFrame::ReLayoutChildren(this);
|
2002-02-04 00:06:51 +03:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void
|
2011-08-25 00:54:30 +04:00
|
|
|
RemoveFrame(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aOldFrame) override
|
2002-02-04 00:06:51 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList || aListID == kNoReflowPrincipalList,
|
2007-11-09 11:19:45 +03:00
|
|
|
"unexpected frame list");
|
2014-05-28 23:36:58 +04:00
|
|
|
nsInlineFrame::RemoveFrame(aListID, aOldFrame);
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(aListID == kPrincipalList))
|
2009-02-11 01:05:27 +03:00
|
|
|
nsMathMLContainerFrame::ReLayoutChildren(this);
|
2002-02-04 00:06:51 +03:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2008-07-14 02:41:18 +04:00
|
|
|
return nsInlineFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
|
2006-10-09 02:04:09 +04:00
|
|
|
}
|
|
|
|
|
2014-04-04 19:54:00 +04:00
|
|
|
bool
|
2015-03-21 19:28:04 +03:00
|
|
|
IsMrowLike() override {
|
2014-04-04 19:54:00 +04:00
|
|
|
return mFrames.FirstChild() != mFrames.LastChild() ||
|
|
|
|
!mFrames.FirstChild();
|
|
|
|
}
|
|
|
|
|
1999-11-17 03:49:37 +03:00
|
|
|
protected:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsMathMLmathInlineFrame(nsStyleContext* aContext) : nsInlineFrame(aContext) {}
|
2001-02-23 19:10:51 +03:00
|
|
|
virtual ~nsMathMLmathInlineFrame() {}
|
1999-11-17 03:49:37 +03:00
|
|
|
};
|
2002-02-01 18:10:50 +03:00
|
|
|
|
1999-09-21 06:12:01 +04:00
|
|
|
#endif /* nsMathMLContainerFrame_h___ */
|