no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / forms / nsSearchControlFrame.cpp
blobe9249cca77bfd71efe5ea845adaef2943fac0f96
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsSearchControlFrame.h"
9 #include "HTMLInputElement.h"
10 #include "mozilla/PresShell.h"
11 #include "nsGkAtoms.h"
12 #include "nsNameSpaceManager.h"
13 #include "nsStyleConsts.h"
14 #include "nsContentUtils.h"
15 #include "nsContentCreatorFunctions.h"
16 #include "nsCSSPseudoElements.h"
17 #include "nsICSSDeclaration.h"
19 #ifdef ACCESSIBILITY
20 # include "mozilla/a11y/AccTypes.h"
21 #endif
23 using namespace mozilla;
24 using namespace mozilla::dom;
26 nsIFrame* NS_NewSearchControlFrame(PresShell* aPresShell,
27 ComputedStyle* aStyle) {
28 return new (aPresShell)
29 nsSearchControlFrame(aStyle, aPresShell->GetPresContext());
32 NS_IMPL_FRAMEARENA_HELPERS(nsSearchControlFrame)
34 NS_QUERYFRAME_HEAD(nsSearchControlFrame)
35 NS_QUERYFRAME_ENTRY(nsSearchControlFrame)
36 NS_QUERYFRAME_TAIL_INHERITING(nsTextControlFrame)
38 nsSearchControlFrame::nsSearchControlFrame(ComputedStyle* aStyle,
39 nsPresContext* aPresContext)
40 : nsTextControlFrame(aStyle, aPresContext, kClassID) {}
42 void nsSearchControlFrame::Destroy(DestroyContext& aContext) {
43 aContext.AddAnonymousContent(mClearButton.forget());
44 nsTextControlFrame::Destroy(aContext);
47 nsresult nsSearchControlFrame::CreateAnonymousContent(
48 nsTArray<ContentInfo>& aElements) {
49 // We create an anonymous tree for our input element that is structured as
50 // follows:
52 // input
53 // div - placeholder
54 // div - preview div
55 // div - editor root
56 // button - clear button
58 // If you change this, be careful to change the order of stuff in
59 // AppendAnonymousContentTo.
61 nsTextControlFrame::CreateAnonymousContent(aElements);
63 // FIXME: We could use nsTextControlFrame making the show password buttton
64 // code a bit more generic, or rename this frame and use it for password
65 // inputs.
67 // Create the ::-moz-search-clear-button pseudo-element:
68 mClearButton = MakeAnonElement(PseudoStyleType::mozSearchClearButton, nullptr,
69 nsGkAtoms::button);
71 aElements.AppendElement(mClearButton);
73 return NS_OK;
76 void nsSearchControlFrame::AppendAnonymousContentTo(
77 nsTArray<nsIContent*>& aElements, uint32_t aFilter) {
78 nsTextControlFrame::AppendAnonymousContentTo(aElements, aFilter);
79 if (mClearButton) {
80 aElements.AppendElement(mClearButton);