tor-browser

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

MiddleCroppingBlockFrame.h (2184B)


      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 #ifndef mozilla_MiddleCroppingBlockFrame_h
      8 #define mozilla_MiddleCroppingBlockFrame_h
      9 
     10 #include "nsBlockFrame.h"
     11 #include "nsIAnonymousContentCreator.h"
     12 #include "nsQueryFrame.h"
     13 
     14 namespace mozilla {
     15 
     16 // A block frame that implements a simplistic version of middle-cropping. Note
     17 // that this is not fully l10n aware or complex-writing-system-friendly, so it's
     18 // generally mostly useful for filenames / urls / etc.
     19 class MiddleCroppingBlockFrame : public nsBlockFrame,
     20                                 public nsIAnonymousContentCreator {
     21 public:
     22  virtual void GetUncroppedValue(nsAString&) = 0;
     23  void UpdateDisplayedValueToUncroppedValue(bool aNotify);
     24 
     25  NS_DECL_QUERYFRAME_TARGET(MiddleCroppingBlockFrame)
     26  NS_DECL_QUERYFRAME
     27  NS_DECL_ABSTRACT_FRAME(MiddleCroppingBlockFrame)
     28 
     29 protected:
     30  MiddleCroppingBlockFrame(ComputedStyle*, nsPresContext*, ClassID);
     31 
     32  ~MiddleCroppingBlockFrame();
     33 
     34  void Reflow(nsPresContext*, ReflowOutput&, const ReflowInput&,
     35              nsReflowStatus&) override;
     36 
     37  nscoord IntrinsicISize(const IntrinsicSizeInput& aInput,
     38                         IntrinsicISizeType aType) override;
     39 
     40  /**
     41   * Crop aText to fit inside aWidth using the styles of aFrame.
     42   * @return true if aText was modified
     43   */
     44  bool CropTextToWidth(gfxContext& aRenderingContext, nscoord aWidth,
     45                       nsString& aText) const;
     46 
     47  nsresult CreateAnonymousContent(nsTArray<ContentInfo>&) override;
     48  void AppendAnonymousContentTo(nsTArray<nsIContent*>&,
     49                                uint32_t aFilter) override;
     50 
     51  /**
     52   * Updates the displayed value by using aValue.
     53   */
     54  void UpdateDisplayedValue(const nsAString& aValue, bool aIsCropped,
     55                            bool aNotify);
     56  void Destroy(DestroyContext&) override;
     57 
     58  RefPtr<dom::Text> mTextNode;
     59  bool mCropped = false;
     60 };
     61 
     62 }  // namespace mozilla
     63 
     64 #endif