2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
2008-12-29 15:07:38 +00:00
|
|
|
/* derived class of nsBlockFrame used for xul:label elements */
|
1998-12-18 17:54:54 +00:00
|
|
|
|
2014-04-01 04:09:23 +00:00
|
|
|
#include "mozilla/EventStateManager.h"
|
2008-12-29 15:07:38 +00:00
|
|
|
#include "nsXULLabelFrame.h"
|
|
|
|
#include "nsHTMLParts.h"
|
2014-02-27 23:04:46 +00:00
|
|
|
#include "nsNameSpaceManager.h"
|
2014-04-01 04:09:23 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
1998-12-18 17:54:54 +00:00
|
|
|
|
2005-10-26 21:46:39 +00:00
|
|
|
nsIFrame*
|
2009-01-19 18:31:33 +00:00
|
|
|
NS_NewXULLabelFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-12-18 17:54:54 +00:00
|
|
|
{
|
2008-12-29 15:07:38 +00:00
|
|
|
nsXULLabelFrame* it = new (aPresShell) nsXULLabelFrame(aContext);
|
2005-10-26 21:46:39 +00:00
|
|
|
|
2013-08-03 04:11:06 +00:00
|
|
|
it->SetFlags(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
|
2005-10-26 21:46:39 +00:00
|
|
|
|
|
|
|
return it;
|
1998-12-18 17:54:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsXULLabelFrame)
|
|
|
|
|
2002-02-21 13:39:39 +00:00
|
|
|
// If you make changes to this function, check its counterparts
|
|
|
|
// in nsBoxFrame and nsTextBoxFrame
|
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsXULLabelFrame::RegUnregAccessKey(bool aDoReg)
|
2002-02-21 13:39:39 +00:00
|
|
|
{
|
|
|
|
// if we have no content, we can't do anything
|
|
|
|
if (!mContent)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// 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 17:47:52 +00:00
|
|
|
if (!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::control))
|
2002-02-21 13:39:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsAutoString accessKey;
|
2006-12-26 17:47:52 +00:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
|
|
|
if (accessKey.IsEmpty())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// With a valid PresContext we can get the ESM
|
|
|
|
// and register the access key
|
2014-04-01 04:09:23 +00:00
|
|
|
EventStateManager* esm = PresContext()->EventStateManager();
|
2004-02-27 17:17:37 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t key = accessKey.First();
|
2004-02-27 17:17:37 +00:00
|
|
|
if (aDoReg)
|
2011-04-21 17:35:52 +00:00
|
|
|
esm->RegisterAccessKey(mContent, key);
|
2004-02-27 17:17:37 +00:00
|
|
|
else
|
2011-04-21 17:35:52 +00:00
|
|
|
esm->UnregisterAccessKey(mContent, key);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2011-04-21 17:35:52 +00:00
|
|
|
return NS_OK;
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
|
|
|
|
1998-12-18 17:54:54 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIFrame
|
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2008-12-29 15:07:38 +00:00
|
|
|
nsXULLabelFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2002-02-21 13:39:39 +00:00
|
|
|
{
|
2013-03-20 01:47:48 +00:00
|
|
|
nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
|
|
|
// register access key
|
2013-03-20 01:47:48 +00:00
|
|
|
RegUnregAccessKey(true);
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsXULLabelFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2002-02-21 13:39:39 +00:00
|
|
|
{
|
|
|
|
// unregister access key
|
2011-10-17 14:59:28 +00:00
|
|
|
RegUnregAccessKey(false);
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsXULLabelFrame::AttributeChanged(int32_t aNameSpaceID,
|
2008-12-29 15:07:38 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aModType)
|
2002-02-21 13:39:39 +00:00
|
|
|
{
|
2005-09-07 16:49:21 +00:00
|
|
|
nsresult rv = nsBlockFrame::AttributeChanged(aNameSpaceID,
|
2004-12-31 01:13:27 +00:00
|
|
|
aAttribute, aModType);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
|
|
|
// If the accesskey changed, register for the new value
|
|
|
|
// The old value has been unregistered in nsXULElement::SetAttr
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::accesskey || aAttribute == nsGkAtoms::control)
|
2011-10-17 14:59:28 +00:00
|
|
|
RegUnregAccessKey(true);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
2008-12-29 15:07:38 +00:00
|
|
|
nsXULLabelFrame::GetType() const
|
1999-02-14 03:47:33 +00:00
|
|
|
{
|
2008-12-29 15:07:38 +00:00
|
|
|
return nsGkAtoms::XULLabelFrame;
|
1999-02-14 03:47:33 +00:00
|
|
|
}
|
|
|
|
|
1998-12-18 17:54:54 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Diagnostics
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2008-12-29 15:07:38 +00:00
|
|
|
nsXULLabelFrame::GetFrameName(nsAString& aResult) const
|
1998-12-18 17:54:54 +00:00
|
|
|
{
|
2008-12-29 15:07:38 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("XULLabel"), aResult);
|
1998-12-18 17:54:54 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|