2007-05-06 23:16:51 +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/. */
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2001-02-02 17:27:38 +03:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "prprf.h" // For PR_snprintf()
|
|
|
|
|
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeOwner.h"
|
|
|
|
#include "nsIWebBrowserChrome.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2001-02-02 17:27:38 +03:00
|
|
|
#include "nsIDOMElement.h"
|
2012-07-02 03:45:59 +04:00
|
|
|
#include "nsTextFragment.h"
|
2001-02-02 17:27:38 +03:00
|
|
|
|
2007-05-14 13:11:38 +04:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
#include "nsMathMLmactionFrame.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// <maction> -- bind actions to a subexpression - implementation
|
|
|
|
//
|
|
|
|
|
2012-06-13 04:05:58 +04:00
|
|
|
enum nsMactionActionTypes {
|
|
|
|
NS_MATHML_ACTION_TYPE_CLASS_ERROR = 0x10,
|
|
|
|
NS_MATHML_ACTION_TYPE_CLASS_USE_SELECTION = 0x20,
|
|
|
|
NS_MATHML_ACTION_TYPE_CLASS_IGNORE_SELECTION = 0x40,
|
|
|
|
NS_MATHML_ACTION_TYPE_CLASS_BITMASK = 0xF0,
|
|
|
|
|
|
|
|
NS_MATHML_ACTION_TYPE_NONE = NS_MATHML_ACTION_TYPE_CLASS_ERROR|0x01,
|
|
|
|
|
|
|
|
NS_MATHML_ACTION_TYPE_TOGGLE = NS_MATHML_ACTION_TYPE_CLASS_USE_SELECTION|0x01,
|
|
|
|
NS_MATHML_ACTION_TYPE_UNKNOWN = NS_MATHML_ACTION_TYPE_CLASS_USE_SELECTION|0x02,
|
|
|
|
|
|
|
|
NS_MATHML_ACTION_TYPE_STATUSLINE = NS_MATHML_ACTION_TYPE_CLASS_IGNORE_SELECTION|0x01,
|
|
|
|
NS_MATHML_ACTION_TYPE_TOOLTIP = NS_MATHML_ACTION_TYPE_CLASS_IGNORE_SELECTION|0x02
|
|
|
|
};
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
|
2012-05-18 21:35:43 +04:00
|
|
|
// helper function to parse actiontype attribute
|
|
|
|
static PRInt32
|
|
|
|
GetActionType(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
nsAutoString value;
|
|
|
|
|
2012-06-13 04:05:58 +04:00
|
|
|
if (aContent) {
|
|
|
|
if (!aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::actiontype_, value))
|
|
|
|
return NS_MATHML_ACTION_TYPE_NONE;
|
|
|
|
}
|
2012-05-18 21:35:43 +04:00
|
|
|
|
|
|
|
if (value.EqualsLiteral("toggle"))
|
|
|
|
return NS_MATHML_ACTION_TYPE_TOGGLE;
|
|
|
|
if (value.EqualsLiteral("statusline"))
|
|
|
|
return NS_MATHML_ACTION_TYPE_STATUSLINE;
|
|
|
|
if (value.EqualsLiteral("tooltip"))
|
|
|
|
return NS_MATHML_ACTION_TYPE_TOOLTIP;
|
|
|
|
|
2012-06-13 04:05:58 +04:00
|
|
|
return NS_MATHML_ACTION_TYPE_UNKNOWN;
|
2012-05-18 21:35:43 +04:00
|
|
|
}
|
|
|
|
|
2005-11-11 05:36:29 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewMathMLmactionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2001-02-02 17:27:38 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsMathMLmactionFrame(aContext);
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmactionFrame)
|
|
|
|
|
2001-02-02 17:27:38 +03:00
|
|
|
nsMathMLmactionFrame::~nsMathMLmactionFrame()
|
|
|
|
{
|
|
|
|
// unregister us as a mouse event listener ...
|
2007-05-14 13:11:38 +04:00
|
|
|
// printf("maction:%p unregistering as mouse event listener ...\n", this);
|
2011-06-28 21:59:14 +04:00
|
|
|
if (mListener) {
|
2011-12-01 11:40:51 +04:00
|
|
|
mContent->RemoveSystemEventListener(NS_LITERAL_STRING("click"), mListener,
|
|
|
|
false);
|
|
|
|
mContent->RemoveSystemEventListener(NS_LITERAL_STRING("mouseover"), mListener,
|
|
|
|
false);
|
|
|
|
mContent->RemoveSystemEventListener(NS_LITERAL_STRING("mouseout"), mListener,
|
|
|
|
false);
|
2011-06-28 21:59:14 +04:00
|
|
|
}
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-03-09 21:55:21 +03:00
|
|
|
nsMathMLmactionFrame::Init(nsIContent* aContent,
|
2001-02-02 17:27:38 +03:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
// Init our local attributes
|
|
|
|
|
|
|
|
mChildCount = -1; // these will be updated in GetSelectedFrame()
|
|
|
|
mSelection = 0;
|
|
|
|
mSelectedFrame = nsnull;
|
2012-05-18 21:35:43 +04:00
|
|
|
mActionType = GetActionType(aContent);
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
// Let the base class do the rest
|
2006-03-27 01:30:36 +04:00
|
|
|
return nsMathMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
|
2011-03-25 06:38:59 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMathMLmactionFrame::TransmitAutomaticData() {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2006-01-09 03:36:46 +03:00
|
|
|
nsresult
|
|
|
|
nsMathMLmactionFrame::ChildListChanged(PRInt32 aModType)
|
|
|
|
{
|
|
|
|
// update cached values
|
|
|
|
mChildCount = -1;
|
|
|
|
mSelection = 0;
|
|
|
|
mSelectedFrame = nsnull;
|
|
|
|
GetSelectedFrame();
|
|
|
|
|
|
|
|
return nsMathMLContainerFrame::ChildListChanged(aModType);
|
|
|
|
}
|
|
|
|
|
2001-02-02 17:27:38 +03:00
|
|
|
// return the frame whose number is given by the attribute selection="number"
|
|
|
|
nsIFrame*
|
|
|
|
nsMathMLmactionFrame::GetSelectedFrame()
|
|
|
|
{
|
|
|
|
nsAutoString value;
|
|
|
|
PRInt32 selection;
|
|
|
|
|
2012-06-13 04:05:58 +04:00
|
|
|
if ((mActionType & NS_MATHML_ACTION_TYPE_CLASS_BITMASK) ==
|
|
|
|
NS_MATHML_ACTION_TYPE_CLASS_ERROR) {
|
|
|
|
// Mark mSelection as an error.
|
|
|
|
mSelection = -1;
|
|
|
|
mSelectedFrame = nsnull;
|
|
|
|
return mSelectedFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Selection is not applied to tooltip and statusline.
|
|
|
|
// Thereby return the first child.
|
|
|
|
if ((mActionType & NS_MATHML_ACTION_TYPE_CLASS_BITMASK) ==
|
|
|
|
NS_MATHML_ACTION_TYPE_CLASS_IGNORE_SELECTION) {
|
2012-04-25 03:49:59 +04:00
|
|
|
// We don't touch mChildCount here. It's incorrect to assign it 1,
|
|
|
|
// and it's inefficient to count the children. It's fine to leave
|
|
|
|
// it be equal -1 because it's not used with other actiontypes.
|
|
|
|
mSelection = 1;
|
|
|
|
mSelectedFrame = mFrames.FirstChild();
|
|
|
|
return mSelectedFrame;
|
|
|
|
}
|
|
|
|
|
2011-05-12 12:18:13 +04:00
|
|
|
GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::selection_,
|
|
|
|
value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2001-02-02 17:27:38 +03:00
|
|
|
PRInt32 errorCode;
|
|
|
|
selection = value.ToInteger(&errorCode);
|
|
|
|
if (NS_FAILED(errorCode))
|
|
|
|
selection = 1;
|
|
|
|
}
|
|
|
|
else selection = 1; // default is first frame
|
|
|
|
|
|
|
|
if (-1 != mChildCount) { // we have been in this function before...
|
|
|
|
// cater for invalid user-supplied selection
|
2012-06-13 04:05:58 +04:00
|
|
|
if (selection > mChildCount || selection < 1)
|
|
|
|
selection = -1;
|
2001-02-02 17:27:38 +03:00
|
|
|
// quick return if it is identical with our cache
|
|
|
|
if (selection == mSelection)
|
|
|
|
return mSelectedFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the selected child and cache new values...
|
|
|
|
PRInt32 count = 0;
|
|
|
|
nsIFrame* childFrame = mFrames.FirstChild();
|
|
|
|
while (childFrame) {
|
2001-02-23 19:10:51 +03:00
|
|
|
if (!mSelectedFrame)
|
|
|
|
mSelectedFrame = childFrame; // default is first child
|
|
|
|
if (++count == selection)
|
|
|
|
mSelectedFrame = childFrame;
|
|
|
|
|
2003-07-08 15:00:00 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
// cater for invalid user-supplied selection
|
2012-06-13 04:05:58 +04:00
|
|
|
if (selection > count || selection < 1)
|
|
|
|
selection = -1;
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
mChildCount = count;
|
|
|
|
mSelection = selection;
|
2012-04-28 19:02:22 +04:00
|
|
|
TransmitAutomaticData();
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
return mSelectedFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsMathMLmactionFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
2001-02-02 17:27:38 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsresult rv = nsMathMLContainerFrame::SetInitialChildList(aListID, aChildList);
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
// This very first call to GetSelectedFrame() will cause us to be marked as an
|
2001-05-19 16:09:41 +04:00
|
|
|
// embellished operator if the selected child is an embellished operator
|
|
|
|
if (!GetSelectedFrame()) {
|
|
|
|
mActionType = NS_MATHML_ACTION_TYPE_NONE;
|
|
|
|
}
|
|
|
|
else {
|
2009-11-04 01:43:39 +03:00
|
|
|
// create mouse event listener and register it
|
|
|
|
mListener = new nsMathMLmactionFrame::MouseListener(this);
|
2001-05-19 16:09:41 +04:00
|
|
|
// printf("maction:%p registering as mouse event listener ...\n", this);
|
2011-12-01 11:40:51 +04:00
|
|
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("click"), mListener,
|
|
|
|
false, false);
|
|
|
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("mouseover"), mListener,
|
|
|
|
false, false);
|
|
|
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("mouseout"), mListener,
|
|
|
|
false, false);
|
2001-05-19 16:09:41 +04:00
|
|
|
}
|
2001-02-02 17:27:38 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-05-18 21:35:43 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMathMLmactionFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType)
|
|
|
|
{
|
|
|
|
bool needsReflow = false;
|
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::actiontype_) {
|
|
|
|
// updating mActionType ...
|
|
|
|
PRInt32 oldActionType = mActionType;
|
|
|
|
mActionType = GetActionType(mContent);
|
|
|
|
|
2012-06-13 04:05:58 +04:00
|
|
|
// Initiate a reflow when actiontype classes are different.
|
|
|
|
if ((oldActionType & NS_MATHML_ACTION_TYPE_CLASS_BITMASK) !=
|
|
|
|
(mActionType & NS_MATHML_ACTION_TYPE_CLASS_BITMASK)) {
|
2012-05-18 21:35:43 +04:00
|
|
|
needsReflow = true;
|
|
|
|
}
|
|
|
|
} else if (aAttribute == nsGkAtoms::selection_) {
|
2012-06-13 04:05:58 +04:00
|
|
|
if ((mActionType & NS_MATHML_ACTION_TYPE_CLASS_BITMASK) ==
|
|
|
|
NS_MATHML_ACTION_TYPE_CLASS_USE_SELECTION) {
|
2012-05-18 21:35:43 +04:00
|
|
|
needsReflow = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// let the base class handle other attribute changes
|
|
|
|
return
|
|
|
|
nsMathMLContainerFrame::AttributeChanged(aNameSpaceID,
|
|
|
|
aAttribute, aModType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needsReflow) {
|
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-02 17:27:38 +03:00
|
|
|
// Only paint the selected child...
|
|
|
|
NS_IMETHODIMP
|
2006-01-26 05:29:17 +03:00
|
|
|
nsMathMLmactionFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2001-02-02 17:27:38 +03:00
|
|
|
{
|
2012-06-13 04:05:58 +04:00
|
|
|
// 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)) {
|
|
|
|
return nsMathMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
2006-01-26 05:29:17 +03:00
|
|
|
if (childFrame) {
|
|
|
|
// Put the child's background directly onto the content list
|
|
|
|
nsDisplayListSet set(aLists, aLists.Content());
|
|
|
|
// The children should be in content order
|
|
|
|
rv = BuildDisplayListForChild(aBuilder, childFrame, aDirtyRect, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2001-02-02 17:27:38 +03:00
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
2001-02-02 17:27:38 +03:00
|
|
|
// visual debug
|
2006-01-26 05:29:17 +03:00
|
|
|
rv = DisplayBoundingMetrics(aBuilder, this, mReference, mBoundingMetrics, aLists);
|
2001-02-02 17:27:38 +03:00
|
|
|
#endif
|
2006-01-26 05:29:17 +03:00
|
|
|
return rv;
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
|
2001-05-19 16:09:41 +04:00
|
|
|
// Only reflow the selected child ...
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmactionFrame::Reflow(nsPresContext* aPresContext,
|
2001-05-19 16:09:41 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2006-04-27 23:20:42 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-05-19 16:09:41 +04:00
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
2007-01-23 07:06:56 +03:00
|
|
|
aDesiredSize.ascent = 0;
|
2011-04-08 05:04:40 +04:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2001-05-19 16:09:41 +04:00
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
if (childFrame) {
|
2008-01-15 04:28:42 +03:00
|
|
|
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
childFrame, availSize);
|
2001-05-19 16:09:41 +04:00
|
|
|
rv = ReflowChild(childFrame, aPresContext, aDesiredSize,
|
|
|
|
childReflowState, aStatus);
|
2008-02-26 07:19:36 +03:00
|
|
|
SaveReflowAndBoundingMetricsFor(childFrame, aDesiredSize,
|
|
|
|
aDesiredSize.mBoundingMetrics);
|
2001-05-19 16:09:41 +04:00
|
|
|
mBoundingMetrics = aDesiredSize.mBoundingMetrics;
|
|
|
|
}
|
2006-01-21 05:53:10 +03:00
|
|
|
FinalizeReflow(*aReflowState.rendContext, aDesiredSize);
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2001-05-19 16:09:41 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-02-02 17:27:38 +03:00
|
|
|
// Only place the selected child ...
|
2008-03-18 07:52:48 +03:00
|
|
|
/* virtual */ nsresult
|
2011-04-08 05:04:40 +04:00
|
|
|
nsMathMLmactionFrame::Place(nsRenderingContext& aRenderingContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aPlaceOrigin,
|
2006-08-04 03:27:55 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
2001-02-02 17:27:38 +03:00
|
|
|
{
|
2012-06-13 04:05:58 +04:00
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
|
|
|
|
if (mSelection == -1) {
|
|
|
|
return ReflowError(aRenderingContext, aDesiredSize);
|
|
|
|
}
|
|
|
|
|
2001-02-02 17:27:38 +03:00
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
2007-01-23 07:06:56 +03:00
|
|
|
aDesiredSize.ascent = 0;
|
2011-04-08 05:04:40 +04:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2001-02-02 17:27:38 +03:00
|
|
|
if (childFrame) {
|
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, aDesiredSize, mBoundingMetrics);
|
|
|
|
if (aPlaceOrigin) {
|
2007-03-31 01:11:41 +04:00
|
|
|
FinishReflowChild(childFrame, PresContext(), nsnull, aDesiredSize, 0, 0, 0);
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
mReference.x = 0;
|
|
|
|
mReference.y = aDesiredSize.ascent;
|
|
|
|
}
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ################################################################
|
|
|
|
// Event handlers
|
|
|
|
// ################################################################
|
|
|
|
|
2011-06-28 21:59:14 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsMathMLmactionFrame::MouseListener,
|
|
|
|
nsIDOMEventListener)
|
2009-11-04 01:43:39 +03:00
|
|
|
|
|
|
|
|
2001-02-02 17:27:38 +03:00
|
|
|
// helper to show a msg on the status bar
|
|
|
|
// curled from nsObjectFrame.cpp ...
|
2009-11-04 01:43:39 +03:00
|
|
|
void
|
|
|
|
ShowStatus(nsPresContext* aPresContext, nsString& aStatusMsg)
|
2001-02-02 17:27:38 +03:00
|
|
|
{
|
2004-02-01 13:09:07 +03:00
|
|
|
nsCOMPtr<nsISupports> cont = aPresContext->GetContainer();
|
|
|
|
if (cont) {
|
2001-02-02 17:27:38 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
|
|
|
|
if (docShellItem) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShellItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
2001-04-30 02:20:35 +04:00
|
|
|
if (treeOwner) {
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
|
|
|
|
if (browserChrome) {
|
2001-06-30 15:02:25 +04:00
|
|
|
browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, aStatusMsg.get());
|
2001-04-30 02:20:35 +04:00
|
|
|
}
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-13 03:35:42 +04:00
|
|
|
NS_IMETHODIMP
|
2011-06-28 21:59:14 +04:00
|
|
|
nsMathMLmactionFrame::MouseListener::HandleEvent(nsIDOMEvent* aEvent)
|
2009-11-04 01:43:39 +03:00
|
|
|
{
|
2011-06-28 21:59:14 +04:00
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
|
|
|
if (eventType.EqualsLiteral("mouseover")) {
|
|
|
|
mOwner->MouseOver();
|
|
|
|
}
|
2011-08-31 16:16:13 +04:00
|
|
|
else if (eventType.EqualsLiteral("click")) {
|
2011-06-28 21:59:14 +04:00
|
|
|
mOwner->MouseClick();
|
|
|
|
}
|
|
|
|
else if (eventType.EqualsLiteral("mouseout")) {
|
|
|
|
mOwner->MouseOut();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ABORT();
|
|
|
|
}
|
|
|
|
|
2009-11-04 01:43:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsMathMLmactionFrame::MouseOver()
|
2001-02-02 17:27:38 +03:00
|
|
|
{
|
|
|
|
// see if we should display a status message
|
2001-04-30 02:20:35 +04:00
|
|
|
if (NS_MATHML_ACTION_TYPE_STATUSLINE == mActionType) {
|
2012-03-29 13:50:02 +04:00
|
|
|
// retrieve content from a second child if it exists
|
|
|
|
nsIFrame* childFrame = mFrames.FrameAt(1);
|
|
|
|
if (!childFrame) return;
|
|
|
|
|
|
|
|
nsIContent* content = childFrame->GetContent();
|
|
|
|
if (!content) return;
|
|
|
|
|
|
|
|
// check whether the content is mtext or not
|
|
|
|
if (content->GetNameSpaceID() == kNameSpaceID_MathML &&
|
|
|
|
content->Tag() == nsGkAtoms::mtext_) {
|
|
|
|
// get the text to be displayed
|
|
|
|
content = content->GetFirstChild();
|
|
|
|
if (!content) return;
|
|
|
|
|
|
|
|
const nsTextFragment* textFrg = content->GetText();
|
|
|
|
if (!textFrg) return;
|
|
|
|
|
|
|
|
nsAutoString text;
|
|
|
|
textFrg->AppendTo(text);
|
|
|
|
// collapse whitespaces as listed in REC, section 3.2.6.1
|
|
|
|
text.CompressWhitespace();
|
|
|
|
ShowStatus(PresContext(), text);
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-04 01:43:39 +03:00
|
|
|
void
|
|
|
|
nsMathMLmactionFrame::MouseOut()
|
|
|
|
{
|
2001-02-02 17:27:38 +03:00
|
|
|
// see if we should remove the status message
|
2001-04-30 02:20:35 +04:00
|
|
|
if (NS_MATHML_ACTION_TYPE_STATUSLINE == mActionType) {
|
2001-02-02 17:27:38 +03:00
|
|
|
nsAutoString value;
|
|
|
|
value.SetLength(0);
|
2007-03-31 01:11:41 +04:00
|
|
|
ShowStatus(PresContext(), value);
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-04 01:43:39 +03:00
|
|
|
void
|
|
|
|
nsMathMLmactionFrame::MouseClick()
|
2001-02-02 17:27:38 +03:00
|
|
|
{
|
2001-04-30 02:20:35 +04:00
|
|
|
if (NS_MATHML_ACTION_TYPE_TOGGLE == mActionType) {
|
2001-02-02 17:27:38 +03:00
|
|
|
if (mChildCount > 1) {
|
|
|
|
PRInt32 selection = (mSelection == mChildCount)? 1 : mSelection + 1;
|
2006-04-24 09:40:11 +04:00
|
|
|
nsAutoString value;
|
2001-02-02 17:27:38 +03:00
|
|
|
char cbuf[10];
|
|
|
|
PR_snprintf(cbuf, sizeof(cbuf), "%d", selection);
|
2004-07-25 16:18:04 +04:00
|
|
|
value.AssignASCII(cbuf);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool notify = false; // don't yet notify the document
|
2006-12-26 20:47:52 +03:00
|
|
|
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::selection_, value, notify);
|
2001-02-02 17:27:38 +03:00
|
|
|
|
|
|
|
// Now trigger a content-changed reflow...
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(mSelectedFrame, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2001-02-02 17:27:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|