forked from mirrors/gecko-dev
		
	 680815cd6e
			
		
	
	
		680815cd6e
		
	
	
	
	
		
			
			This patch was generated automatically by the "modeline.py" script, available here: https://github.com/amccreight/moz-source-tools/blob/master/modeline.py For every file that is modified in this patch, the changes are as follows: (1) The patch changes the file to use the exact C++ mode lines from the Mozilla coding style guide, available here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Mode_Line (2) The patch deletes any blank lines between the mode line & the MPL boilerplate comment. (3) If the file previously had the mode lines and MPL boilerplate in a single contiguous C++ comment, then the patch splits them into separate C++ comments, to match the boilerplate in the coding style. MozReview-Commit-ID: EuRsDue63tK --HG-- extra : rebase_source : 3356d4b80ff6213935192e87cdbc9103fec6084c
		
			
				
	
	
		
			177 lines
		
	
	
	
		
			6.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			177 lines
		
	
	
	
		
			6.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 | |
| /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 | |
| /* 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"
 | |
| 
 | |
| using namespace mozilla;
 | |
| 
 | |
| 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);
 | |
| }
 | |
| 
 | |
| void
 | |
| nsMathMLSelectedFrame::SetInitialChildList(ChildListID     aListID,
 | |
|                                            nsFrameList&    aChildList)
 | |
| {
 | |
|   nsMathMLContainerFrame::SetInitialChildList(aListID, aChildList);
 | |
|   // 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)) {
 | |
|     nsMathMLContainerFrame::BuildDisplayList(aBuilder, aLists);
 | |
|     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
 | |
|     BuildDisplayListForChild(aBuilder, childFrame, set);
 | |
|   }
 | |
| 
 | |
| #if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
 | |
|   // visual debug
 | |
|   DisplayBoundingMetrics(aBuilder, this, mReference, mBoundingMetrics, aLists);
 | |
| #endif
 | |
| }
 | |
| 
 | |
| /* virtual */
 | |
| LogicalSize
 | |
| nsMathMLSelectedFrame::ComputeSize(gfxContext *aRenderingContext,
 | |
|                                    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;
 | |
|     SizeComputationInput offsetState(childFrame, aRenderingContext, aWM,
 | |
|                                  availableISize);
 | |
|     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);
 | |
| }
 | |
| 
 | |
| // Only reflow the selected child ...
 | |
| void
 | |
| nsMathMLSelectedFrame::Reflow(nsPresContext*          aPresContext,
 | |
|                               ReflowOutput&     aDesiredSize,
 | |
|                               const ReflowInput& aReflowInput,
 | |
|                               nsReflowStatus&          aStatus)
 | |
| {
 | |
|   MarkInReflow();
 | |
|   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
 | |
| 
 | |
|   mPresentationData.flags &= ~NS_MATHML_ERROR;
 | |
|   aDesiredSize.ClearSize();
 | |
|   aDesiredSize.SetBlockStartAscent(0);
 | |
|   mBoundingMetrics = nsBoundingMetrics();
 | |
|   nsIFrame* childFrame = GetSelectedFrame();
 | |
|   if (childFrame) {
 | |
|     WritingMode wm = childFrame->GetWritingMode();
 | |
|     LogicalSize availSize = aReflowInput.ComputedSize(wm);
 | |
|     availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
 | |
|     ReflowInput childReflowInput(aPresContext, aReflowInput,
 | |
|                                        childFrame, availSize);
 | |
|     ReflowChild(childFrame, aPresContext, aDesiredSize,
 | |
|                 childReflowInput, aStatus);
 | |
|     SaveReflowAndBoundingMetricsFor(childFrame, aDesiredSize,
 | |
|                                     aDesiredSize.mBoundingMetrics);
 | |
|     mBoundingMetrics = aDesiredSize.mBoundingMetrics;
 | |
|   }
 | |
|   FinalizeReflow(aReflowInput.mRenderingContext->GetDrawTarget(), aDesiredSize);
 | |
|   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
 | |
| }
 | |
| 
 | |
| // Only place the selected child ...
 | |
| /* virtual */ nsresult
 | |
| nsMathMLSelectedFrame::Place(DrawTarget*          aDrawTarget,
 | |
|                              bool                 aPlaceOrigin,
 | |
|                              ReflowOutput& aDesiredSize)
 | |
| {
 | |
|   nsIFrame* childFrame = GetSelectedFrame();
 | |
| 
 | |
|   if (mInvalidMarkup) {
 | |
|     return ReflowError(aDrawTarget, aDesiredSize);
 | |
|   }
 | |
| 
 | |
|   aDesiredSize.ClearSize();
 | |
|   aDesiredSize.SetBlockStartAscent(0);
 | |
|   mBoundingMetrics = nsBoundingMetrics();
 | |
|   if (childFrame) {
 | |
|     GetReflowAndBoundingMetricsFor(childFrame, aDesiredSize, mBoundingMetrics);
 | |
|     if (aPlaceOrigin) {
 | |
|       FinishReflowChild(childFrame, PresContext(), aDesiredSize, nullptr, 0, 0, 0);
 | |
|     }
 | |
|     mReference.x = 0;
 | |
|     mReference.y = aDesiredSize.BlockStartAscent();
 | |
|   }
 | |
|   aDesiredSize.mBoundingMetrics = mBoundingMetrics;
 | |
|   return NS_OK;
 | |
| }
 |