2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-12-18 20:54:54 +03:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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/
|
1998-12-18 20:54:54 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
1998-12-18 20:54:54 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* 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"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* derived class of nsBlockFrame; distinction barely relevant anymore */
|
|
|
|
|
1998-12-18 20:54:54 +03:00
|
|
|
#include "nsAreaFrame.h"
|
1999-04-10 21:30:46 +04:00
|
|
|
#include "nsBlockBandData.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-12-18 20:54:54 +03:00
|
|
|
#include "nsStyleConsts.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-11-19 04:20:56 +03:00
|
|
|
#include "nsINodeInfo.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-12-18 20:54:54 +03:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2002-02-21 16:39:39 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIEventStateManager.h"
|
|
|
|
#endif
|
|
|
|
|
1999-07-14 21:26:12 +04:00
|
|
|
#undef NOISY_MAX_ELEMENT_SIZE
|
1999-09-18 03:15:53 +04:00
|
|
|
#undef NOISY_FINAL_SIZE
|
1998-12-18 20:54:54 +03:00
|
|
|
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewAreaFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aFlags)
|
1998-12-18 20:54:54 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
nsAreaFrame* it = new (aPresShell) nsAreaFrame(aContext);
|
2005-10-27 01:46:39 +04:00
|
|
|
|
|
|
|
if (it != nsnull)
|
|
|
|
it->SetFlags(aFlags);
|
|
|
|
|
|
|
|
return it;
|
1998-12-18 20:54:54 +03:00
|
|
|
}
|
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// If you make changes to this function, check its counterparts
|
|
|
|
// in nsBoxFrame and nsTextBoxFrame
|
|
|
|
nsresult
|
2006-04-10 04:16:29 +04:00
|
|
|
nsAreaFrame::RegUnregAccessKey(PRBool aDoReg)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
|
|
|
// if we have no content, we can't do anything
|
|
|
|
if (!mContent)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// only support accesskeys for the following elements
|
2006-12-26 20:47:52 +03:00
|
|
|
if (!mContent->NodeInfo()->Equals(nsGkAtoms::label, kNameSpaceID_XUL))
|
2002-02-21 16:39:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// To filter out <label>s without a control attribute.
|
|
|
|
// XXXjag a side-effect is that we filter out anonymous <label>s
|
|
|
|
// in e.g. <menu>, <menuitem>, <button>. These <label>s inherit
|
|
|
|
// |accesskey| and would otherwise register themselves, overwriting
|
|
|
|
// the content we really meant to be registered.
|
2006-12-26 20:47:52 +03:00
|
|
|
if (!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::control))
|
2002-02-21 16:39:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsAutoString accessKey;
|
2006-12-26 20:47:52 +03:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
if (accessKey.IsEmpty())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// With a valid PresContext we can get the ESM
|
|
|
|
// and register the access key
|
2006-04-10 04:16:29 +04:00
|
|
|
nsIEventStateManager *esm = GetPresContext()->EventStateManager();
|
2004-02-27 20:17:37 +03:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
PRUint32 key = accessKey.First();
|
|
|
|
if (aDoReg)
|
|
|
|
rv = esm->RegisterAccessKey(mContent, key);
|
|
|
|
else
|
|
|
|
rv = esm->UnregisterAccessKey(mContent, key);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-12-18 20:54:54 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIFrame
|
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2002-02-21 16:39:39 +03:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 21:55:21 +03:00
|
|
|
nsAreaFrame::Init(nsIContent* aContent,
|
2002-02-21 16:39:39 +03:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
nsresult rv = nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
|
2002-02-21 16:39:39 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
// register access key
|
2006-04-10 04:16:29 +04:00
|
|
|
return RegUnregAccessKey(PR_TRUE);
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
|
|
|
nsAreaFrame::Destroy()
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
|
|
|
// unregister access key
|
2006-04-10 04:16:29 +04:00
|
|
|
RegUnregAccessKey(PR_FALSE);
|
|
|
|
nsBlockFrame::Destroy();
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-09-07 20:49:21 +04:00
|
|
|
nsAreaFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
2002-02-21 16:39:39 +03:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-12 01:16:12 +04:00
|
|
|
PRInt32 aModType)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
2005-09-07 20:49:21 +04:00
|
|
|
nsresult rv = nsBlockFrame::AttributeChanged(aNameSpaceID,
|
2004-12-31 04:13:27 +03:00
|
|
|
aAttribute, aModType);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// If the accesskey changed, register for the new value
|
|
|
|
// The old value has been unregistered in nsXULElement::SetAttr
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::accesskey || aAttribute == nsGkAtoms::control)
|
2006-04-10 04:16:29 +04:00
|
|
|
RegUnregAccessKey(PR_TRUE);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsAreaFrame::GetType() const
|
1999-02-14 06:47:33 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::areaFrame;
|
1999-02-14 06:47:33 +03:00
|
|
|
}
|
|
|
|
|
1998-12-18 20:54:54 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Diagnostics
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-12-18 20:54:54 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsAreaFrame::GetFrameName(nsAString& aResult) const
|
1998-12-18 20:54:54 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Area"), aResult);
|
1998-12-18 20:54:54 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|