/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */ #include "nsHTMLButtonControlFrame.h" #include "nsCOMPtr.h" #include "nsContainerFrame.h" #include "nsIFormControlFrame.h" #include "nsHTMLParts.h" #include "nsIFormControl.h" #include "nsPresContext.h" #include "nsIPresShell.h" #include "nsStyleContext.h" #include "nsLeafFrame.h" #include "nsCSSRendering.h" #include "nsISupports.h" #include "nsGkAtoms.h" #include "nsCSSAnonBoxes.h" #include "nsStyleConsts.h" #include "nsIComponentManager.h" #include "nsButtonFrameRenderer.h" #include "nsFormControlFrame.h" #include "nsFrameManager.h" #include "nsINameSpaceManager.h" #include "nsIServiceManager.h" #include "nsIDOMHTMLButtonElement.h" #include "nsIDOMHTMLInputElement.h" #include "nsStyleSet.h" #include "nsDisplayList.h" #include using namespace mozilla; nsIFrame* NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { return new (aPresShell) nsHTMLButtonControlFrame(aContext); } NS_IMPL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame) nsHTMLButtonControlFrame::nsHTMLButtonControlFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) { } nsHTMLButtonControlFrame::~nsHTMLButtonControlFrame() { } void nsHTMLButtonControlFrame::DestroyFrom(nsIFrame* aDestructRoot) { nsFormControlFrame::RegUnRegAccessKey(static_cast(this), false); nsContainerFrame::DestroyFrom(aDestructRoot); } NS_IMETHODIMP nsHTMLButtonControlFrame::Init( nsIContent* aContent, nsIFrame* aParent, nsIFrame* aPrevInFlow) { nsresult rv = nsContainerFrame::Init(aContent, aParent, aPrevInFlow); if (NS_SUCCEEDED(rv)) { mRenderer.SetFrame(this, PresContext()); } return rv; } NS_QUERYFRAME_HEAD(nsHTMLButtonControlFrame) NS_QUERYFRAME_ENTRY(nsIFormControlFrame) NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame) #ifdef ACCESSIBILITY a11y::AccType nsHTMLButtonControlFrame::AccessibleType() { return a11y::eHTMLButtonType; } #endif nsIAtom* nsHTMLButtonControlFrame::GetType() const { return nsGkAtoms::HTMLButtonControlFrame; } void nsHTMLButtonControlFrame::SetFocus(bool aOn, bool aRepaint) { } NS_IMETHODIMP nsHTMLButtonControlFrame::HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { // if disabled do nothing if (mRenderer.isDisabled()) { return NS_OK; } // mouse clicks are handled by content // we don't want our children to get any events. So just pass it to frame. return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus); } NS_IMETHODIMP nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { nsDisplayList onTop; if (IsVisibleForPainting(aBuilder)) { nsresult rv = mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop); NS_ENSURE_SUCCESS(rv, rv); } nsDisplayListCollection set; // Do not allow the child subtree to receive events. if (!aBuilder->IsForEventDelivery()) { nsresult rv = BuildDisplayListForChild(aBuilder, mFrames.FirstChild(), aDirtyRect, set, DISPLAY_CHILD_FORCE_PSEUDO_STACKING_CONTEXT); NS_ENSURE_SUCCESS(rv, rv); // That should put the display items in set.Content() } // Put the foreground outline and focus rects on top of the children set.Content()->AppendToTop(&onTop); // clips to our padding box for s but not