2007-05-06 19:16:51 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2004-04-18 14:30:37 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-02-02 14:27:38 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2001-02-02 14:27:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla MathML Project.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* The University Of Queensland.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1999
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-02-02 14:27:38 +00:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Roger B. Sidje <rbs@maths.uq.edu.au>
|
2004-04-18 14:30:37 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-02-02 14:27:38 +00:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsFrame.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
2001-02-02 14:27:38 +00: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-05 21:28:38 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2001-02-02 14:27:38 +00:00
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
|
2007-05-14 09:11:38 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2001-02-02 14:27:38 +00:00
|
|
|
|
|
|
|
#include "nsMathMLmactionFrame.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 00:18:22 +00:00
|
|
|
#include "nsStyleSet.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2006-04-24 05:40:11 +00:00
|
|
|
#include "nsContentUtils.h"
|
2001-02-02 14:27:38 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// <maction> -- bind actions to a subexpression - implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
#define NS_MATHML_ACTION_TYPE_NONE 0
|
|
|
|
#define NS_MATHML_ACTION_TYPE_TOGGLE 1
|
|
|
|
#define NS_MATHML_ACTION_TYPE_STATUSLINE 2
|
|
|
|
#define NS_MATHML_ACTION_TYPE_TOOLTIP 3 // unsupported
|
|
|
|
|
|
|
|
|
2005-11-11 02:36:29 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewMathMLmactionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2001-02-02 14:27:38 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsMathMLmactionFrame(aContext);
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmactionFrame)
|
|
|
|
|
2001-02-02 14:27:38 +00:00
|
|
|
nsMathMLmactionFrame::~nsMathMLmactionFrame()
|
|
|
|
{
|
|
|
|
// unregister us as a mouse event listener ...
|
2007-05-14 09:11:38 +00:00
|
|
|
// printf("maction:%p unregistering as mouse event listener ...\n", this);
|
2011-06-28 17:59:14 +00:00
|
|
|
if (mListener) {
|
2011-12-01 07:40:51 +00: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 17:59:14 +00:00
|
|
|
}
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsMathMLmactionFrame::Init(nsIContent* aContent,
|
2001-02-02 14:27:38 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsAutoString value, prefix;
|
|
|
|
|
|
|
|
// Init our local attributes
|
|
|
|
|
|
|
|
mChildCount = -1; // these will be updated in GetSelectedFrame()
|
|
|
|
mSelection = 0;
|
|
|
|
mSelectedFrame = nsnull;
|
2003-02-22 00:32:13 +00:00
|
|
|
nsRefPtr<nsStyleContext> newStyleContext;
|
2001-02-02 14:27:38 +00:00
|
|
|
|
|
|
|
mActionType = NS_MATHML_ACTION_TYPE_NONE;
|
2006-12-26 17:47:52 +00:00
|
|
|
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::actiontype_, value);
|
2005-10-28 11:25:24 +00:00
|
|
|
if (!value.IsEmpty()) {
|
2004-04-30 13:23:43 +00:00
|
|
|
if (value.EqualsLiteral("toggle"))
|
2001-02-02 14:27:38 +00:00
|
|
|
mActionType = NS_MATHML_ACTION_TYPE_TOGGLE;
|
|
|
|
|
|
|
|
// XXX use goto to jump out of these if?
|
|
|
|
|
|
|
|
if (NS_MATHML_ACTION_TYPE_NONE == mActionType) {
|
|
|
|
// expected tooltip prefix (8ch)...
|
2001-04-29 22:20:35 +00:00
|
|
|
if (8 < value.Length() && 0 == value.Find("tooltip#"))
|
2001-02-02 14:27:38 +00:00
|
|
|
mActionType = NS_MATHML_ACTION_TYPE_TOOLTIP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_MATHML_ACTION_TYPE_NONE == mActionType) {
|
|
|
|
// expected statusline prefix (11ch)...
|
2001-04-29 22:20:35 +00:00
|
|
|
if (11 < value.Length() && 0 == value.Find("statusline#"))
|
2001-02-02 14:27:38 +00:00
|
|
|
mActionType = NS_MATHML_ACTION_TYPE_STATUSLINE;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Let the base class do the rest
|
2006-03-26 21:30:36 +00:00
|
|
|
return nsMathMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
|
2011-03-25 03:38:59 +00: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 00:36:46 +00:00
|
|
|
nsresult
|
|
|
|
nsMathMLmactionFrame::ChildListChanged(PRInt32 aModType)
|
|
|
|
{
|
|
|
|
// update cached values
|
|
|
|
mChildCount = -1;
|
|
|
|
mSelection = 0;
|
|
|
|
mSelectedFrame = nsnull;
|
|
|
|
GetSelectedFrame();
|
|
|
|
|
|
|
|
return nsMathMLContainerFrame::ChildListChanged(aModType);
|
|
|
|
}
|
|
|
|
|
2001-02-02 14:27:38 +00:00
|
|
|
// return the frame whose number is given by the attribute selection="number"
|
|
|
|
nsIFrame*
|
|
|
|
nsMathMLmactionFrame::GetSelectedFrame()
|
|
|
|
{
|
|
|
|
nsAutoString value;
|
|
|
|
PRInt32 selection;
|
|
|
|
|
2011-05-12 08:18:13 +00:00
|
|
|
GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::selection_,
|
|
|
|
value);
|
2005-10-28 11:25:24 +00:00
|
|
|
if (!value.IsEmpty()) {
|
2001-02-02 14:27:38 +00: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
|
|
|
|
if (selection > mChildCount || selection < 1)
|
|
|
|
selection = 1;
|
|
|
|
// 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 16:10:51 +00:00
|
|
|
if (!mSelectedFrame)
|
|
|
|
mSelectedFrame = childFrame; // default is first child
|
|
|
|
if (++count == selection)
|
|
|
|
mSelectedFrame = childFrame;
|
|
|
|
|
2003-07-08 11:00:00 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
// cater for invalid user-supplied selection
|
|
|
|
if (selection > count || selection < 1)
|
|
|
|
selection = 1;
|
|
|
|
|
|
|
|
mChildCount = count;
|
|
|
|
mSelection = selection;
|
|
|
|
|
|
|
|
return mSelectedFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsMathMLmactionFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
2001-02-02 14:27:38 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
nsresult rv = nsMathMLContainerFrame::SetInitialChildList(aListID, aChildList);
|
2001-02-02 14:27:38 +00:00
|
|
|
|
|
|
|
// This very first call to GetSelectedFrame() will cause us to be marked as an
|
2001-05-19 12:09:41 +00:00
|
|
|
// embellished operator if the selected child is an embellished operator
|
|
|
|
if (!GetSelectedFrame()) {
|
|
|
|
mActionType = NS_MATHML_ACTION_TYPE_NONE;
|
|
|
|
}
|
|
|
|
else {
|
2009-11-03 22:43:39 +00:00
|
|
|
// create mouse event listener and register it
|
|
|
|
mListener = new nsMathMLmactionFrame::MouseListener(this);
|
2001-05-19 12:09:41 +00:00
|
|
|
// printf("maction:%p registering as mouse event listener ...\n", this);
|
2011-12-01 07:40:51 +00: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 12:09:41 +00:00
|
|
|
}
|
2001-02-02 14:27:38 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only paint the selected child...
|
|
|
|
NS_IMETHODIMP
|
2006-01-26 02:29:17 +00:00
|
|
|
nsMathMLmactionFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2001-02-02 14:27:38 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-02-02 14:27:38 +00:00
|
|
|
|
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
2006-01-26 02:29:17 +00: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 14:27:38 +00:00
|
|
|
|
|
|
|
#if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX)
|
|
|
|
// visual debug
|
2006-01-26 02:29:17 +00:00
|
|
|
rv = DisplayBoundingMetrics(aBuilder, this, mReference, mBoundingMetrics, aLists);
|
2001-02-02 14:27:38 +00:00
|
|
|
#endif
|
2006-01-26 02:29:17 +00:00
|
|
|
return rv;
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
|
2001-05-19 12:09:41 +00:00
|
|
|
// Only reflow the selected child ...
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsMathMLmactionFrame::Reflow(nsPresContext* aPresContext,
|
2001-05-19 12:09:41 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2006-04-27 19:20:42 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-05-19 12:09:41 +00:00
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
2007-01-23 04:06:56 +00:00
|
|
|
aDesiredSize.ascent = 0;
|
2011-04-08 01:04:40 +00:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2001-05-19 12:09:41 +00:00
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
if (childFrame) {
|
2008-01-15 01:28:42 +00:00
|
|
|
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
2002-05-10 18:22:41 +00: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 05:38:33 +00:00
|
|
|
childFrame, availSize);
|
2001-05-19 12:09:41 +00:00
|
|
|
rv = ReflowChild(childFrame, aPresContext, aDesiredSize,
|
|
|
|
childReflowState, aStatus);
|
2008-02-26 04:19:36 +00:00
|
|
|
SaveReflowAndBoundingMetricsFor(childFrame, aDesiredSize,
|
|
|
|
aDesiredSize.mBoundingMetrics);
|
2001-05-19 12:09:41 +00:00
|
|
|
mBoundingMetrics = aDesiredSize.mBoundingMetrics;
|
|
|
|
}
|
2006-01-21 02:53:10 +00:00
|
|
|
FinalizeReflow(*aReflowState.rendContext, aDesiredSize);
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2001-05-19 12:09:41 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-02-02 14:27:38 +00:00
|
|
|
// Only place the selected child ...
|
2008-03-18 04:52:48 +00:00
|
|
|
/* virtual */ nsresult
|
2011-04-08 01:04:40 +00:00
|
|
|
nsMathMLmactionFrame::Place(nsRenderingContext& aRenderingContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aPlaceOrigin,
|
2006-08-03 23:27:55 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
2001-02-02 14:27:38 +00:00
|
|
|
{
|
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
2007-01-23 04:06:56 +00:00
|
|
|
aDesiredSize.ascent = 0;
|
2011-04-08 01:04:40 +00:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2001-02-02 14:27:38 +00:00
|
|
|
nsIFrame* childFrame = GetSelectedFrame();
|
|
|
|
if (childFrame) {
|
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, aDesiredSize, mBoundingMetrics);
|
|
|
|
if (aPlaceOrigin) {
|
2007-03-30 21:11:41 +00:00
|
|
|
FinishReflowChild(childFrame, PresContext(), nsnull, aDesiredSize, 0, 0, 0);
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
mReference.x = 0;
|
|
|
|
mReference.y = aDesiredSize.ascent;
|
|
|
|
}
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ################################################################
|
|
|
|
// Event handlers
|
|
|
|
// ################################################################
|
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
NS_IMPL_ISUPPORTS1(nsMathMLmactionFrame::MouseListener,
|
|
|
|
nsIDOMEventListener)
|
2009-11-03 22:43:39 +00:00
|
|
|
|
|
|
|
|
2001-02-02 14:27:38 +00:00
|
|
|
// helper to show a msg on the status bar
|
|
|
|
// curled from nsObjectFrame.cpp ...
|
2009-11-03 22:43:39 +00:00
|
|
|
void
|
|
|
|
ShowStatus(nsPresContext* aPresContext, nsString& aStatusMsg)
|
2001-02-02 14:27:38 +00:00
|
|
|
{
|
2004-02-01 10:09:07 +00:00
|
|
|
nsCOMPtr<nsISupports> cont = aPresContext->GetContainer();
|
|
|
|
if (cont) {
|
2001-02-02 14:27:38 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
|
|
|
|
if (docShellItem) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShellItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
2001-04-29 22:20:35 +00:00
|
|
|
if (treeOwner) {
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
|
|
|
|
if (browserChrome) {
|
2001-06-30 11:02:25 +00:00
|
|
|
browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, aStatusMsg.get());
|
2001-04-29 22:20:35 +00:00
|
|
|
}
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-12 23:35:42 +00:00
|
|
|
NS_IMETHODIMP
|
2011-06-28 17:59:14 +00:00
|
|
|
nsMathMLmactionFrame::MouseListener::HandleEvent(nsIDOMEvent* aEvent)
|
2009-11-03 22:43:39 +00:00
|
|
|
{
|
2011-06-28 17:59:14 +00:00
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
|
|
|
if (eventType.EqualsLiteral("mouseover")) {
|
|
|
|
mOwner->MouseOver();
|
|
|
|
}
|
2011-08-31 12:16:13 +00:00
|
|
|
else if (eventType.EqualsLiteral("click")) {
|
2011-06-28 17:59:14 +00:00
|
|
|
mOwner->MouseClick();
|
|
|
|
}
|
|
|
|
else if (eventType.EqualsLiteral("mouseout")) {
|
|
|
|
mOwner->MouseOut();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ABORT();
|
|
|
|
}
|
|
|
|
|
2009-11-03 22:43:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsMathMLmactionFrame::MouseOver()
|
2001-02-02 14:27:38 +00:00
|
|
|
{
|
|
|
|
// see if we should display a status message
|
2001-04-29 22:20:35 +00:00
|
|
|
if (NS_MATHML_ACTION_TYPE_STATUSLINE == mActionType) {
|
2001-02-02 14:27:38 +00:00
|
|
|
nsAutoString value;
|
2006-12-26 17:47:52 +00:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::actiontype_, value);
|
2005-10-28 11:25:24 +00:00
|
|
|
// expected statusline prefix (11ch)...
|
|
|
|
if (11 < value.Length() && 0 == value.Find("statusline#")) {
|
|
|
|
value.Cut(0, 11);
|
2007-03-30 21:11:41 +00:00
|
|
|
ShowStatus(PresContext(), value);
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 22:43:39 +00:00
|
|
|
void
|
|
|
|
nsMathMLmactionFrame::MouseOut()
|
|
|
|
{
|
2001-02-02 14:27:38 +00:00
|
|
|
// see if we should remove the status message
|
2001-04-29 22:20:35 +00:00
|
|
|
if (NS_MATHML_ACTION_TYPE_STATUSLINE == mActionType) {
|
2001-02-02 14:27:38 +00:00
|
|
|
nsAutoString value;
|
|
|
|
value.SetLength(0);
|
2007-03-30 21:11:41 +00:00
|
|
|
ShowStatus(PresContext(), value);
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 22:43:39 +00:00
|
|
|
void
|
|
|
|
nsMathMLmactionFrame::MouseClick()
|
2001-02-02 14:27:38 +00:00
|
|
|
{
|
2001-04-29 22:20:35 +00:00
|
|
|
if (NS_MATHML_ACTION_TYPE_TOGGLE == mActionType) {
|
2001-02-02 14:27:38 +00:00
|
|
|
if (mChildCount > 1) {
|
|
|
|
PRInt32 selection = (mSelection == mChildCount)? 1 : mSelection + 1;
|
2006-04-24 05:40:11 +00:00
|
|
|
nsAutoString value;
|
2001-02-02 14:27:38 +00:00
|
|
|
char cbuf[10];
|
|
|
|
PR_snprintf(cbuf, sizeof(cbuf), "%d", selection);
|
2004-07-25 12:18:04 +00:00
|
|
|
value.AssignASCII(cbuf);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool notify = false; // don't yet notify the document
|
2006-12-26 17:47:52 +00:00
|
|
|
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::selection_, value, notify);
|
2001-02-02 14:27:38 +00:00
|
|
|
|
|
|
|
// Now trigger a content-changed reflow...
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(mSelectedFrame, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2001-02-02 14:27:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|