tor-browser

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

ButtonControlFrame.cpp (2227B)


      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 "ButtonControlFrame.h"
      8 
      9 /* Abstract base class for special button frames (but not <button>) */
     10 
     11 using namespace mozilla;
     12 
     13 namespace mozilla {
     14 
     15 NS_QUERYFRAME_HEAD(ButtonControlFrame)
     16  NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
     17  NS_QUERYFRAME_ENTRY(ButtonControlFrame)
     18 NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
     19 
     20 void ButtonControlFrame::EnsureNonEmptyLabel(nsAString& aLabel) {
     21  if (aLabel.IsEmpty()) {
     22    // Have to use a space character of some sort for line-block-size
     23    // calculations to be right. Also, the space character must be zero-width in
     24    // order for the inline-size calculations to be consistent between
     25    // size-contained comboboxes vs. empty comboboxes.
     26    //
     27    // XXXdholbert Does this space need to be "non-breaking"? I'm not sure if it
     28    // matters, but we previously had a comment here (added in 2002) saying
     29    // "Have to use a non-breaking space for line-height calculations to be
     30    // right". So I'll stick with a non-breaking space for now...
     31    aLabel = u"\ufeff"_ns;
     32  }
     33 }
     34 
     35 nsresult ButtonControlFrame::HandleEvent(nsPresContext* aPresContext,
     36                                         WidgetGUIEvent* aEvent,
     37                                         nsEventStatus* aEventStatus) {
     38  // Override HandleEvent to prevent the inherited version from being called
     39  // when disabled.
     40  if (IsContentDisabled()) {
     41    return nsBlockFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
     42  }
     43  return NS_OK;
     44 }
     45 
     46 void ButtonControlFrame::Reflow(nsPresContext* aPc, ReflowOutput& aReflowOutput,
     47                                const ReflowInput& aReflowInput,
     48                                nsReflowStatus& aStatus) {
     49  nsBlockFrame::Reflow(aPc, aReflowOutput, aReflowInput, aStatus);
     50  // We're always complete and we don't support overflow containers
     51  // so we shouldn't have a next-in-flow ever.
     52  aStatus.Reset();
     53 }
     54 
     55 }  // namespace mozilla