tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsSearchControlFrame.cpp (2035B)


      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/. */
      6 
      7 #include "nsSearchControlFrame.h"
      8 
      9 #include "mozilla/PresShell.h"
     10 #include "nsContentUtils.h"
     11 #include "nsGkAtoms.h"
     12 
     13 using namespace mozilla;
     14 
     15 nsIFrame* NS_NewSearchControlFrame(PresShell* aPresShell,
     16                                   ComputedStyle* aStyle) {
     17  return new (aPresShell)
     18      nsSearchControlFrame(aStyle, aPresShell->GetPresContext());
     19 }
     20 
     21 NS_IMPL_FRAMEARENA_HELPERS(nsSearchControlFrame)
     22 
     23 NS_QUERYFRAME_HEAD(nsSearchControlFrame)
     24  NS_QUERYFRAME_ENTRY(nsSearchControlFrame)
     25 NS_QUERYFRAME_TAIL_INHERITING(nsTextControlFrame)
     26 
     27 nsSearchControlFrame::nsSearchControlFrame(ComputedStyle* aStyle,
     28                                           nsPresContext* aPresContext)
     29    : nsTextControlFrame(aStyle, aPresContext, kClassID) {}
     30 
     31 nsresult nsSearchControlFrame::CreateAnonymousContent(
     32    nsTArray<ContentInfo>& aElements) {
     33  // We create an anonymous tree for our input element that is structured as
     34  // follows:
     35  //
     36  // input
     37  //   div    - placeholder
     38  //   div    - preview div
     39  //   div    - editor root
     40  //   button - clear button
     41  //
     42  // If you change this, be careful to change the order of stuff in
     43  // AppendAnonymousContentTo.
     44 
     45  nsTextControlFrame::CreateAnonymousContent(aElements);
     46 
     47  // Create the ::-moz-search-clear-button pseudo-element:
     48  mButton = MakeAnonElement(PseudoStyleType::mozSearchClearButton, nullptr,
     49                            nsGkAtoms::button);
     50  mButton->SetAttr(kNameSpaceID_None, nsGkAtoms::tabindex, u"-1"_ns, false);
     51  mButton->SetAttr(kNameSpaceID_None, nsGkAtoms::aria_hidden, u"true"_ns,
     52                   false);
     53  mButton->SetAttr(kNameSpaceID_None, nsGkAtoms::title, u""_ns, false);
     54  aElements.AppendElement(mButton);
     55 
     56  return NS_OK;
     57 }