2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-05-10 16:40:44 +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/. */
|
|
|
|
|
|
|
|
#include "nsMathMLSelectedFrame.h"
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-05-10 16:40:44 +04:00
|
|
|
nsMathMLSelectedFrame::~nsMathMLSelectedFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMathMLSelectedFrame::TransmitAutomaticData()
|
|
|
|
{
|
|
|
|
// Note that to determine space-like and embellished op properties:
|
|
|
|
// - <semantics> behaves the same as <maction>
|
|
|
|
// - <annotation-xml> behaves the same as <mrow>
|
|
|
|
|
|
|
|
// The REC defines the following element to be space-like:
|
|
|
|
// * an maction element whose selected sub-expression exists and is
|
|
|
|
// space-like;
|
|
|
|
nsIMathMLFrame* mathMLFrame = do_QueryFrame(mSelectedFrame);
|
|
|
|
if (mathMLFrame && mathMLFrame->IsSpaceLike()) {
|
|
|
|
mPresentationData.flags |= NS_MATHML_SPACE_LIKE;
|
|
|
|
} else {
|
|
|
|
mPresentationData.flags &= ~NS_MATHML_SPACE_LIKE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The REC defines the following element to be an embellished operator:
|
|
|
|
// * an maction element whose selected sub-expression exists and is an
|
|
|
|
// embellished operator;
|
|
|
|
mPresentationData.baseFrame = mSelectedFrame;
|
|
|
|
GetEmbellishDataFrom(mSelectedFrame, mEmbellishData);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsMathMLSelectedFrame::ChildListChanged(int32_t aModType)
|
|
|
|
{
|
|
|
|
GetSelectedFrame();
|
|
|
|
return nsMathMLContainerFrame::ChildListChanged(aModType);
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2013-05-10 16:40:44 +04:00
|
|
|
nsMathMLSelectedFrame::SetInitialChildList(ChildListID aListID,
|
|
|
|
nsFrameList& aChildList)
|
|
|
|
{
|
2014-05-28 23:36:58 +04:00
|
|
|
nsMathMLContainerFrame::SetInitialChildList(aListID, aChildList);
|
2013-05-10 16:40:44 +04:00
|
|
|
// This very first call to GetSelectedFrame() will cause us to be marked as an
|
|
|
|
// embellished operator if the selected child is an embellished operator
|
|
|
|
GetSelectedFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only paint the selected child...
|
|
|
|
void
|
|
|
|
nsMathMLSelectedFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
// Report an error if something wrong was found in this frame.
|
|
|
|
// We can't call nsDisplayMathMLError from here,
|
|
|
|
// so ask nsMathMLContainerFrame to do the work for us.
|
|
|
|
if (NS_MATHML_HAS_ERROR(mPresentationData.flags)) {
|
2017-08-07 05:23:35 +03:00
|
|
|
nsMathMLContainerFrame::BuildDisplayList(aBuilder, aLists);
|
2013-05-10 16:40:44 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
|
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
if (childFrame) {
|
|
|
|
// Put the child's background directly onto the content list
|
|
|
|
nsDisplayListSet set(aLists, aLists.Content());
|
|
|
|
// The children should be in content order
|
2017-08-07 05:23:35 +03:00
|
|
|
BuildDisplayListForChild(aBuilder, childFrame, set);
|
2013-05-10 16:40:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
|
|
|
// visual debug
|
|
|
|
DisplayBoundingMetrics(aBuilder, this, mReference, mBoundingMetrics, aLists);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-03-05 07:06:32 +03:00
|
|
|
/* virtual */
|
|
|
|
LogicalSize
|
2017-06-09 22:14:53 +03:00
|
|
|
nsMathMLSelectedFrame::ComputeSize(gfxContext *aRenderingContext,
|
2015-03-05 07:06:32 +03:00
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder,
|
|
|
|
const LogicalSize& aPadding,
|
|
|
|
ComputeSizeFlags aFlags)
|
|
|
|
{
|
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
if (childFrame) {
|
|
|
|
// Delegate size computation to the child frame.
|
|
|
|
// Try to account for border/padding/margin on this frame and the child,
|
|
|
|
// though we don't really support them during reflow anyway...
|
|
|
|
nscoord availableISize = aAvailableISize - aBorder.ISize(aWM) -
|
|
|
|
aPadding.ISize(aWM) - aMargin.ISize(aWM);
|
|
|
|
LogicalSize cbSize = aCBSize - aBorder - aPadding - aMargin;
|
2016-07-21 13:36:35 +03:00
|
|
|
SizeComputationInput offsetState(childFrame, aRenderingContext, aWM,
|
2015-06-11 09:42:56 +03:00
|
|
|
availableISize);
|
2015-03-05 07:06:32 +03:00
|
|
|
LogicalSize size =
|
|
|
|
childFrame->ComputeSize(aRenderingContext, aWM, cbSize,
|
|
|
|
availableISize, offsetState.ComputedLogicalMargin().Size(aWM),
|
|
|
|
offsetState.ComputedLogicalBorderPadding().Size(aWM) -
|
|
|
|
offsetState.ComputedLogicalPadding().Size(aWM),
|
|
|
|
offsetState.ComputedLogicalPadding().Size(aWM),
|
|
|
|
aFlags);
|
|
|
|
return size + offsetState.ComputedLogicalBorderPadding().Size(aWM);
|
|
|
|
}
|
|
|
|
return LogicalSize(aWM);
|
|
|
|
}
|
|
|
|
|
2013-05-10 16:40:44 +04:00
|
|
|
// Only reflow the selected child ...
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2013-05-10 16:40:44 +04:00
|
|
|
nsMathMLSelectedFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2013-05-10 16:40:44 +04:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
2017-09-13 13:00:25 +03:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
|
|
|
|
2015-03-30 01:38:39 +03:00
|
|
|
mPresentationData.flags &= ~NS_MATHML_ERROR;
|
2014-07-24 12:30:07 +04:00
|
|
|
aDesiredSize.ClearSize();
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(0);
|
2013-05-10 16:40:44 +04:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
if (childFrame) {
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = childFrame->GetWritingMode();
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalSize availSize = aReflowInput.ComputedSize(wm);
|
2014-07-24 12:28:46 +04:00
|
|
|
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput childReflowInput(aPresContext, aReflowInput,
|
2013-05-10 16:40:44 +04:00
|
|
|
childFrame, availSize);
|
2014-05-13 04:47:52 +04:00
|
|
|
ReflowChild(childFrame, aPresContext, aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
childReflowInput, aStatus);
|
2013-05-10 16:40:44 +04:00
|
|
|
SaveReflowAndBoundingMetricsFor(childFrame, aDesiredSize,
|
|
|
|
aDesiredSize.mBoundingMetrics);
|
|
|
|
mBoundingMetrics = aDesiredSize.mBoundingMetrics;
|
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
FinalizeReflow(aReflowInput.mRenderingContext->GetDrawTarget(), aDesiredSize);
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
2013-05-10 16:40:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Only place the selected child ...
|
|
|
|
/* virtual */ nsresult
|
2015-12-16 00:56:41 +03:00
|
|
|
nsMathMLSelectedFrame::Place(DrawTarget* aDrawTarget,
|
2013-05-10 16:40:44 +04:00
|
|
|
bool aPlaceOrigin,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize)
|
2013-05-10 16:40:44 +04:00
|
|
|
{
|
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
|
|
|
|
if (mInvalidMarkup) {
|
2015-12-16 00:56:41 +03:00
|
|
|
return ReflowError(aDrawTarget, aDesiredSize);
|
2013-05-10 16:40:44 +04:00
|
|
|
}
|
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
aDesiredSize.ClearSize();
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(0);
|
2013-05-10 16:40:44 +04:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
|
|
|
if (childFrame) {
|
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, aDesiredSize, mBoundingMetrics);
|
|
|
|
if (aPlaceOrigin) {
|
2014-01-17 05:34:44 +04:00
|
|
|
FinishReflowChild(childFrame, PresContext(), aDesiredSize, nullptr, 0, 0, 0);
|
2013-05-10 16:40:44 +04:00
|
|
|
}
|
|
|
|
mReference.x = 0;
|
2014-06-11 13:45:31 +04:00
|
|
|
mReference.y = aDesiredSize.BlockStartAscent();
|
2013-05-10 16:40:44 +04:00
|
|
|
}
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
return NS_OK;
|
|
|
|
}
|