コード例 #1
0
ファイル: Pager.cpp プロジェクト: Doc-Ok/OpticalTracking
void Pager::requestResize(Widget* child,const Vector& newExteriorSize)
	{
	/* Just grant the request if nothing really changed: */
	if(!isManaged)
		{
		/* Just resize the child: */
		child->resize(Box(child->getExterior().origin,newExteriorSize));
		}
	else if(newExteriorSize[0]==child->getExterior().size[0]&&newExteriorSize[1]==child->getExterior().size[1])
		{
		/* Resize the child in its previous box: */
		child->resize(child->getExterior());
		
		/* Invalidate the visual representation: */
		update();
		}
	else
		{
		/* Calculate the new natural grid size: */
		
		/* Calculate the size of the page button box: */
		Vector buttonSize(0.0f,0.0f,0.0f);
		for(ButtonList::const_iterator pbIt=pageButtons.begin();pbIt!=pageButtons.end();++pbIt)
			{
			/* Get the button's size: */
			Vector s=*pbIt!=child?(*pbIt)->calcNaturalSize():newExteriorSize;
			
			/* Increment the box width: */
			buttonSize[0]+=s[0];
			
			/* Adjust the box height: */
			if(buttonSize[1]<s[1])
				buttonSize[1]=s[1];
			}
		
		/* Calculate the size of the child widget area: */
		Vector childSize(0.0f,0.0f,0.0f);
		for(WidgetList::const_iterator cIt=children.begin();cIt!=children.end();++cIt)
			{
			/* Get the child's size: */
			Vector s=*cIt!=child?(*cIt)->calcNaturalSize():newExteriorSize;
			
			/* Adjust the box width and height: */
			for(int i=0;i<2;++i)
				if(childSize[i]<s[i])
					childSize[i]=s[i];
			}
		
		/* Calcuate the new overall size: */
		Vector newSize=childSize;
		newSize[0]+=2.0f*marginWidth;
		newSize[1]+=2.0f*marginWidth;
		if(newSize[0]<buttonSize[0])
			newSize[0]=buttonSize[0];
		newSize[1]+=buttonSize[1];
		
		/* Try to resize the widget: */
		parent->requestResize(this,calcExteriorSize(newSize));
		}
	}
コード例 #2
0
void Box::Layout()
{
	if (m_children.size() == 0) return;

	PreferredSize();

	const Point boxSize = GetSize();

	Point::Component vc, fc;
	GetComponentsForOrient(m_orient == BOX_HORIZONTAL, vc, fc);

	// fast path. we know the exact size that everything wants, so just
	// loop and hand it out
	if (m_numVariable == 0) {
		Point childPos(0), childSize(0);
		for (std::list<Child>::iterator i = m_children.begin(); i != m_children.end(); ++i) {
			childSize[fc] = boxSize[fc];
			childSize[vc] = (*i).contribSize[vc];
			const Point actualSize(CalcSize((*i).widget, childSize));
			SetWidgetDimensions((*i).widget, childPos, actualSize);
			childPos[vc] += actualSize[vc] + m_spacing;
		}
	}

	// we have one or more children that have requested the maximum size
	// possible. each with a known size gets it, and any remaining space is
	// distributed evenly among the max-sized children. if there is no
	// remaining space, then we're already outside the bounds, so just give
	// them something
	else {
		const int sizeAvail = boxSize[vc];
		const int sizeMin = sizeAvail/10; // 10%, as good as anything

		const int amount = m_minAllocation < sizeAvail ? std::max((sizeAvail-m_minAllocation-m_spacing*(int(m_children.size())-1))/m_numVariable, sizeMin) : sizeMin;

		Point childPos(0), childSize(0);
		for (std::list<Child>::iterator i = m_children.begin(); i != m_children.end(); ++i) {
			childSize[fc] = boxSize[fc];
			childSize[vc] = (*i).contribSize[vc] == SIZE_EXPAND ? amount : (*i).contribSize[vc];
			const Point actualSize(CalcSize((*i).widget, childSize));
			SetWidgetDimensions((*i).widget, childPos, actualSize);
			childPos[vc] += actualSize[vc] + m_spacing;
		}
	}

	LayoutChildren();
}
コード例 #3
0
// For token elements, mBoundingMetrics is computed at the ReflowToken
// pass, it is not computed here because our children may be text frames
// that do not implement the GetBoundingMetrics() interface.
/* virtual */ nsresult
nsMathMLTokenFrame::Place(nsRenderingContext& aRenderingContext,
                          bool                 aPlaceOrigin,
                          nsHTMLReflowMetrics& aDesiredSize)
{
  mBoundingMetrics = nsBoundingMetrics();
  for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
       childFrame = childFrame->GetNextSibling()) {
    nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
    GetReflowAndBoundingMetricsFor(childFrame, childSize,
                                   childSize.mBoundingMetrics, nullptr);
    // compute and cache the bounding metrics
    mBoundingMetrics += childSize.mBoundingMetrics;
  }

  nsRefPtr<nsFontMetrics> fm;
  nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
  nscoord ascent = fm->MaxAscent();
  nscoord descent = fm->MaxDescent();

  aDesiredSize.mBoundingMetrics = mBoundingMetrics;
  aDesiredSize.Width() = mBoundingMetrics.width;
  aDesiredSize.SetTopAscent(std::max(mBoundingMetrics.ascent, ascent));
  aDesiredSize.Height() = aDesiredSize.TopAscent() +
                        std::max(mBoundingMetrics.descent, descent);

  if (aPlaceOrigin) {
    nscoord dy, dx = 0;
    for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
         childFrame = childFrame->GetNextSibling()) {
      nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
      GetReflowAndBoundingMetricsFor(childFrame, childSize,
                                     childSize.mBoundingMetrics);

      // place and size the child; (dx,0) makes the caret happy - bug 188146
      dy = childSize.Height() == 0 ? 0 : aDesiredSize.TopAscent() - childSize.TopAscent();
      FinishReflowChild(childFrame, PresContext(), childSize, nullptr, dx, dy, 0);
      dx += childSize.Width();
    }
  }

  SetReference(nsPoint(0, aDesiredSize.TopAscent()));

  return NS_OK;
}
コード例 #4
0
ファイル: knotebook.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KNoteBook::setSizes()
{
  //debug("setSizes");
  QSize childsize = childSize();

  int extra = 16;
  bool f = false;
  if(pnote->ok)
  {
    pnote->ok->adjustSize();
    f = true;
    extra += pnote->ok->height();
  }
  if(pnote->cancel)
  {
    pnote->cancel->adjustSize();
    if(!f)
    {
      f = true;
      extra += pnote->cancel->height();
    }
  }
  if(pnote->def)
  {
    pnote->def->adjustSize();
    if(!f)
    {
      f = true;
      extra += pnote->def->height();
    }
  }
  if(pnote->help)
  {
    pnote->help->adjustSize();
    if(!f)
      extra += pnote->help->height();
  }

  pnote->tabbar->adjustSize();
  int y = pnote->tabbar->height() + childsize.height() + extra;
  int x = 16 + childsize.width();
  setMinimumSize(x, y);
  resize(x, y);
  //debug("setSizes - done");
}
コード例 #5
0
ファイル: Pager.cpp プロジェクト: Doc-Ok/OpticalTracking
Vector Pager::calcNaturalSize(void) const
	{
	/* Calculate the size of the page button box: */
	Vector buttonSize(0.0f,0.0f,0.0f);
	for(ButtonList::const_iterator pbIt=pageButtons.begin();pbIt!=pageButtons.end();++pbIt)
		{
		/* Get the button's size: */
		Vector s=(*pbIt)->calcNaturalSize();
		
		/* Increment the box width: */
		buttonSize[0]+=s[0];
		
		/* Adjust the box height: */
		if(buttonSize[1]<s[1])
			buttonSize[1]=s[1];
		}
	
	/* Calculate the size of the child widget area: */
	Vector childSize(0.0f,0.0f,0.0f);
	for(WidgetList::const_iterator cIt=children.begin();cIt!=children.end();++cIt)
		{
		/* Get the child's size: */
		Vector s=(*cIt)->calcNaturalSize();
		
		/* Adjust the box width and height: */
		for(int i=0;i<2;++i)
			if(childSize[i]<s[i])
				childSize[i]=s[i];
		}
	
	/* Calcuate the total interior size: */
	Vector result=childSize;
	result[0]+=2.0f*marginWidth;
	result[1]+=2.0f*marginWidth;
	if(result[0]<buttonSize[0])
		result[0]=buttonSize[0];
	result[1]+=buttonSize[1];
	return calcExteriorSize(result);
	}
コード例 #6
0
//------------------------------------------------------------------------------
// void SaveChildPositionAndSize()
//------------------------------------------------------------------------------
void GmatMdiChildFrame::SaveChildPositionAndSize()
{
   if (mCanSaveLocation == false)
      return;

   if (IsIconized())
      return;
   
   // Get the position and size of the window first
   #ifdef __WXMAC__
      Integer screenWidth  = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
      Integer screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
   #else
      Integer screenWidth;
      Integer screenHeight;
      GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true);
      // Since GmatMainFrame::GetActualClientSize() subtracts one, add one here (LOJ: 2012.07.23)
      screenWidth++;
      screenHeight++;
   #endif

   bool isMinimized = IsIconized(), isMaximized = IsMaximized();
   if (isMinimized)	
	  Iconize(false);
   else if (isMaximized)
	  Maximize(false);

   int tmpX = -1, tmpY = -1;
   int tmpW = -1, tmpH = -1;
   GetPosition(&tmpX, &tmpY);
   GetSize(&tmpW, &tmpH);
   Rvector upperLeft(2, ((Real) tmpX /(Real)  screenWidth), ((Real) tmpY /(Real)  screenHeight));
   Rvector childSize(2,  ((Real) tmpW /(Real)  screenWidth), ((Real) tmpH /(Real)  screenHeight));

   if (isMinimized)	
	  Iconize();
   else if (isMaximized)
	  Maximize();


   #ifdef DEBUG_PERSISTENCE
   // ======================= begin temporary ==============================
   MessageInterface::ShowMessage("*** Size of SCREEN %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, screenWidth, screenHeight);
   MessageInterface::ShowMessage("Position of View plot %s is: x = %d, y = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpX, tmpY);
   MessageInterface::ShowMessage("Size of View plot %s is: width = %d, height = %d\n",
                                 mChildName.WX_TO_C_STRING, tmpW, tmpH);
   // ======================= end temporary ==============================
   #endif

   if ((mItemType == GmatTree::OUTPUT_REPORT)  ||
       (mItemType == GmatTree::OUTPUT_CCSDS_OEM_FILE ) ||
       (mItemType == GmatTree::OUTPUT_ORBIT_VIEW) ||
       (mItemType == GmatTree::OUTPUT_XY_PLOT) ||
       (mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT)
       // We'll want to add the event reports eventually, but they are not subscriber based
       //|| (mItemType == GmatTree::EVENT_REPORT)
       )
   {
      GmatBase *obj = theGuiInterpreter->GetConfiguredObject(mChildName.c_str());
      
      #ifdef DEBUG_FUNCTION
      // Check if child name is the configured object name
      MessageInterface::ShowMessage
         ("GmatMdiChildFrame::SaveChildPositionAndSize() the child '%s' %s a "
          "configured object, obj = <%p>[%s]'%s'\n", mChildName.WX_TO_C_STRING,
          obj ? "is" : "is not", obj, obj ? obj->GetTypeName().c_str() : "NULL",
          obj ? obj->GetName().c_str() : "NULL");
      #endif
      
      if (!obj)
      {
         // Just return if child is not a configured subscriber,ie,
         // plotting from GMAT function (LOJ: 2015.06.26)
         #ifdef DEBUG_FUNCTION
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "will not save position and size for unconfigured subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         return;
      }
      else if (!obj->IsOfType("Subscriber"))
      {
         #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage
            ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() "
             "cannot not save position and size for non-subscriber '%s'\n",
             mChildName.WX_TO_C_STRING);
         #endif
         SubscriberException se;
         se.SetDetails("Cannot set position and size for non-subscriber '%s'");
         throw se;
      }
      
      Subscriber *sub = (Subscriber*) obj;
      
      #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage("...... Now saving plot data to %s:\n", (sub->GetName()).c_str());
         MessageInterface::ShowMessage("       Upper left             = %12.10f   %12.10f\n", upperLeft[0], upperLeft[1]);
         MessageInterface::ShowMessage("       Size                   = %12.10f   %12.10f\n", childSize[0], childSize[1]);
         MessageInterface::ShowMessage("       RelativeZOrder         = %d\n", relativeZOrder);
      #endif
      sub->SetRvectorParameter(sub->GetParameterID("UpperLeft"), upperLeft);
      sub->SetRvectorParameter(sub->GetParameterID("Size"), childSize);
      sub->SetIntegerParameter(sub->GetParameterID("RelativeZOrder"), relativeZOrder);
      sub->SetBooleanParameter(sub->GetParameterID("Maximized"), isMaximized);
   }
   else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/MissionTree/UpperLeft", location.str().c_str());
      pConfig->Write("/MissionTree/Size", size.str().c_str());
      pConfig->Write("/MissionTree/IsMaximized", isMaximized);
      pConfig->Write("/MissionTree/IsMinimized", isMinimized);
   }
   else if (mItemType == GmatTree::SCRIPT_FILE)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      std::stringstream location("");
      location << upperLeft[0] << " " << upperLeft[1];
      std::stringstream size("");
      size << childSize[0] << " " << childSize[1];
      pConfig->Write("/ScriptEditor/UpperLeft", location.str().c_str());
      pConfig->Write("/ScriptEditor/Size", size.str().c_str());
      pConfig->Write("/ScriptEditor/IsMaximized", isMaximized);
      pConfig->Write("/ScriptEditor/IsMinimized", isMinimized);
   }
}
コード例 #7
0
//------------------------------------------------------------------------------
// void SaveChildPositionAndSize()
//------------------------------------------------------------------------------
void GmatMdiChildFrame::SaveChildPositionAndSize()
{
   if (mCanSaveLocation == false)
      return;

   // Get the position and size of the window first
   #ifdef __WXMAC__
      Integer screenWidth  = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
      Integer screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
   #else
      Integer screenWidth;
      Integer screenHeight;
      //theParent->GetClientSize(&screenWidth, &screenHeight);
      GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true);
   #endif

//   #ifdef DEBUG_PERSISTENCE
//   wxRect      wxR         = GetScreenRect();
//   wxPoint     wxP         = wxR.GetPosition();
//   wxSize      wxS         = wxR.GetSize();
//   Integer     x           = (Integer) wxP.x;
//   Integer     y           = (Integer) wxP.y;
//   Integer     w           = (Integer) wxS.GetWidth();
//   Integer     h           = (Integer) wxS.GetHeight();
//   MessageInterface::ShowMessage
//      (wxT("wxP.x = %d, wxP.y = %d, wxS.w = %d, wxS.h = %d\n"), x, y, w, h);
//   #endif

   int tmpX = -1, tmpY = -1;
   int tmpW = -1, tmpH = -1;
   GetPosition(&tmpX, &tmpY);
   GetSize(&tmpW, &tmpH);
   Rvector upperLeft(2, ((Real) tmpX /(Real)  screenWidth), ((Real) tmpY /(Real)  screenHeight));
   Rvector childSize(2,  ((Real) tmpW /(Real)  screenWidth), ((Real) tmpH /(Real)  screenHeight));

   #ifdef DEBUG_PERSISTENCE
   // ======================= begin temporary ==============================
   MessageInterface::ShowMessage(wxT("*** Size of SCREEN %s is: width = %d, height = %d\n"), mPlotName.c_str(), screenWidth, screenHeight);
   MessageInterface::ShowMessage(wxT("Position of View plot %s is: x = %d, y = %d\n"), mPlotName.c_str(), tmpX, tmpY);
   MessageInterface::ShowMessage(wxT("Size of View plot %s is: width = %d, height = %d\n"), mPlotName.c_str(), tmpW, tmpH);
//   MessageInterface::ShowMessage(wxT("Position of View plot %s in pixels rel. to parent window is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpX, (Integer) tmpY);
//   MessageInterface::ShowMessage(wxT("Size of View plot %s in pixels rel. to parent window is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpW, (Integer) tmpH);
//   wxPoint tmpPt = ScreenToClient(wxP);
//   MessageInterface::ShowMessage(wxT("--- Position of View plot %s in client coords is: x = %d, y = %d\n"),
//                                 mPlotName.c_str(), (Integer) tmpPt.x, (Integer) tmpPt.y);
   // ======================= end temporary ==============================
   #endif

   if ((mItemType == GmatTree::OUTPUT_REPORT)  || (mItemType == GmatTree::OUTPUT_ORBIT_VIEW) ||
       (mItemType == GmatTree::OUTPUT_XY_PLOT) || (mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT)
       // We'll want to add the event reports eventually, but they are not subscriber based
       //|| (mItemType == GmatTree::EVENT_REPORT)
       )
   {
      GmatBase *obj =
         (Subscriber*)theGuiInterpreter->GetConfiguredObject(mPlotName.c_str());
         
      if (!obj || !obj->IsOfType(wxT("Subscriber")))
      {
         wxString errmsg = wxT("Cannot find subscriber ");
         errmsg += mPlotName + wxT("\n");
         throw SubscriberException(errmsg);
      }
      Subscriber *sub = (Subscriber*) obj;

      #ifdef DEBUG_PERSISTENCE
         MessageInterface::ShowMessage("...... Now saving plot data to %s:\n", (sub->GetName()).c_str());
         MessageInterface::ShowMessage("       Upper left             = %12.10f   %12.10f\n", upperLeft[0], upperLeft[1]);
         MessageInterface::ShowMessage("       Size                   = %12.10f   %12.10f\n", childSize[0], childSize[1]);
         MessageInterface::ShowMessage("       RelativeZOrder         = %d\n", relativeZOrder);
      #endif
      sub->SetRvectorParameter(sub->GetParameterID(wxT("UpperLeft")), upperLeft);
      sub->SetRvectorParameter(sub->GetParameterID(wxT("Size")), childSize);
      sub->SetIntegerParameter(sub->GetParameterID(wxT("RelativeZOrder")), relativeZOrder);
   }
   else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED)
   {
      // get the config object
      wxFileConfig *pConfig;
      pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig();
      wxString location;
      location << upperLeft[0] << wxT(" ") << upperLeft[1];
      wxString size;
      size << childSize[0] << wxT(" ") << childSize[1];
      pConfig->Write(wxT("/MissionTree/UpperLeft"), location.c_str());
      pConfig->Write(wxT("/MissionTree/Size"), size.c_str());
   }
}
コード例 #8
0
nsresult
nsMathMLmfencedFrame::Reflow(nsPresContext*          aPresContext,
                             nsHTMLReflowMetrics&     aDesiredSize,
                             const nsHTMLReflowState& aReflowState,
                             nsReflowStatus&          aStatus)
{
  nsresult rv;
  aDesiredSize.Width() = aDesiredSize.Height() = 0;
  aDesiredSize.SetTopAscent(0);
  aDesiredSize.mBoundingMetrics = nsBoundingMetrics();

  int32_t i;
  const nsStyleFont* font = StyleFont();
  nsRefPtr<nsFontMetrics> fm;
  nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
  aReflowState.rendContext->SetFont(fm);
  nscoord axisHeight, em;
  GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
  GetEmHeight(fm, em);
  // leading to be left at the top and the bottom of stretched chars
  nscoord leading = NSToCoordRound(0.2f * em); 

  /////////////
  // Reflow children
  // Asking each child to cache its bounding metrics

  // Note that we don't use the base method nsMathMLContainerFrame::Reflow()
  // because we want to stretch our fences, separators and stretchy frames using
  // the *same* initial aDesiredSize.mBoundingMetrics. If we were to use the base
  // method here, our stretchy frames will be stretched and placed, and we may
  // end up stretching our fences/separators with a different aDesiredSize.
  // XXX The above decision was revisited in bug 121748 and this code can be
  // refactored to use nsMathMLContainerFrame::Reflow() at some stage.

  nsReflowStatus childStatus;
  nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
  nsIFrame* firstChild = GetFirstPrincipalChild();
  nsIFrame* childFrame = firstChild;
  nscoord ascent = 0, descent = 0;
  if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
    // We use the ASCII metrics to get our minimum height. This way,
    // if we have borders or a background, they will fit better with
    // other elements on the line.
    ascent = fm->MaxAscent();
    descent = fm->MaxDescent();
  }
  while (childFrame) {
    nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(),
                                         aDesiredSize.mFlags
                                         | NS_REFLOW_CALC_BOUNDING_METRICS);
    nsHTMLReflowState childReflowState(aPresContext, aReflowState,
                                       childFrame, availSize);
    rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
                     childReflowState, childStatus);
    //NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
    if (NS_FAILED(rv)) {
      // Call DidReflow() for the child frames we successfully did reflow.
      DidReflowChildren(firstChild, childFrame);
      return rv;
    }

    SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                    childDesiredSize.mBoundingMetrics);

    nscoord childDescent = childDesiredSize.Height() - childDesiredSize.TopAscent();
    if (descent < childDescent)
      descent = childDescent;
    if (ascent < childDesiredSize.TopAscent())
      ascent = childDesiredSize.TopAscent();

    childFrame = childFrame->GetNextSibling();
  }

  /////////////
  // Ask stretchy children to stretch themselves

  nsBoundingMetrics containerSize;
  nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;

  GetPreferredStretchSize(*aReflowState.rendContext,
                          0, /* i.e., without embellishments */
                          stretchDir, containerSize);
  childFrame = firstChild;
  while (childFrame) {
    nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
    if (mathmlChild) {
      nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode());
      // retrieve the metrics that was stored at the previous pass
      GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                     childDesiredSize.mBoundingMetrics);
      
      mathmlChild->Stretch(*aReflowState.rendContext, 
                           stretchDir, containerSize, childDesiredSize);
      // store the updated metrics
      SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                      childDesiredSize.mBoundingMetrics);
      
      nscoord childDescent = childDesiredSize.Height() - childDesiredSize.TopAscent();
      if (descent < childDescent)
        descent = childDescent;
      if (ascent < childDesiredSize.TopAscent())
        ascent = childDesiredSize.TopAscent();
    }
    childFrame = childFrame->GetNextSibling();
  }

  // bug 121748: for surrounding fences & separators, use a size that covers everything
  GetPreferredStretchSize(*aReflowState.rendContext,
                          STRETCH_CONSIDER_EMBELLISHMENTS,
                          stretchDir, containerSize);

  //////////////////////////////////////////
  // Prepare the opening fence, separators, and closing fence, and
  // adjust the origin of children.

  // we need to center around the axis
  nscoord delta = std::max(containerSize.ascent - axisHeight, 
                         containerSize.descent + axisHeight);
  containerSize.ascent = delta + axisHeight;
  containerSize.descent = delta - axisHeight;

  bool isRTL = StyleVisibility()->mDirection;

  /////////////////
  // opening fence ...
  ReflowChar(aPresContext, *aReflowState.rendContext, mOpenChar,
             NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, 
             axisHeight, leading, em, containerSize, ascent, descent, isRTL);
  /////////////////
  // separators ...
  for (i = 0; i < mSeparatorsCount; i++) {
    ReflowChar(aPresContext, *aReflowState.rendContext, &mSeparatorsChar[i],
               NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
               axisHeight, leading, em, containerSize, ascent, descent, isRTL);
  }
  /////////////////
  // closing fence ...
  ReflowChar(aPresContext, *aReflowState.rendContext, mCloseChar,
             NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
             axisHeight, leading, em, containerSize, ascent, descent, isRTL);

  //////////////////
  // Adjust the origins of each child.
  // and update our bounding metrics

  i = 0;
  nscoord dx = 0;
  nsBoundingMetrics bm;
  bool firstTime = true;
  nsMathMLChar *leftChar, *rightChar;
  if (isRTL) {
    leftChar = mCloseChar;
    rightChar = mOpenChar;
  } else {
    leftChar = mOpenChar;
    rightChar = mCloseChar;
  }

  if (leftChar) {
    PlaceChar(leftChar, ascent, bm, dx);
    aDesiredSize.mBoundingMetrics = bm;
    firstTime = false;
  }

  if (isRTL) {
    childFrame = this->GetLastChild(nsIFrame::kPrincipalList);
  } else {
    childFrame = firstChild;
  }
  while (childFrame) {
    nsHTMLReflowMetrics childSize(aReflowState.GetWritingMode());
    GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
    if (firstTime) {
      firstTime = false;
      aDesiredSize.mBoundingMetrics  = bm;
    }
    else  
      aDesiredSize.mBoundingMetrics += bm;

    FinishReflowChild(childFrame, aPresContext, childSize, nullptr,
                      dx, ascent - childSize.TopAscent(), 0);
    dx += childSize.Width();

    if (i < mSeparatorsCount) {
      PlaceChar(&mSeparatorsChar[isRTL ? mSeparatorsCount - 1 - i : i],
                ascent, bm, dx);
      aDesiredSize.mBoundingMetrics += bm;
    }
    i++;

    if (isRTL) {
      childFrame = childFrame->GetPrevSibling();
    } else {
      childFrame = childFrame->GetNextSibling();
    }
  }

  if (rightChar) {
    PlaceChar(rightChar, ascent, bm, dx);
    if (firstTime)
      aDesiredSize.mBoundingMetrics  = bm;
    else  
      aDesiredSize.mBoundingMetrics += bm;
  }

  aDesiredSize.Width() = aDesiredSize.mBoundingMetrics.width;
  aDesiredSize.Height() = ascent + descent;
  aDesiredSize.SetTopAscent(ascent);

  SetBoundingMetrics(aDesiredSize.mBoundingMetrics);
  SetReference(nsPoint(0, aDesiredSize.TopAscent()));

  // see if we should fix the spacing
  FixInterFrameSpacing(aDesiredSize);

  // Finished with these:
  ClearSavedChildMetrics();

  // Set our overflow area
  GatherAndStoreOverflow(&aDesiredSize);

  aStatus = NS_FRAME_COMPLETE;
  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
  return NS_OK;
}