LCOV - code coverage report
Current view: top level - dom/html - nsITextControlElement.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 nsITextControlElement_h___
       8             : #define nsITextControlElement_h___
       9             : 
      10             : #include "nsISupports.h"
      11             : #include "nsCOMPtr.h"
      12             : class nsIContent;
      13             : class nsAString;
      14             : class nsISelectionController;
      15             : class nsFrameSelection;
      16             : class nsTextControlFrame;
      17             : 
      18             : namespace mozilla {
      19             : 
      20             : class ErrorResult;
      21             : class TextEditor;
      22             : 
      23             : namespace dom {
      24             : class Element;
      25             : } // namespace dom
      26             : } // namespace mozilla
      27             : 
      28             : // IID for the nsITextControl interface
      29             : #define NS_ITEXTCONTROLELEMENT_IID    \
      30             : { 0x3df7db6d, 0xa548, 0x4e20, \
      31             :  { 0x97, 0xfd, 0x75, 0xa3, 0x31, 0xa2, 0xf3, 0xd4 } }
      32             : 
      33             : /**
      34             :  * This interface is used for the text control frame to get the editor and
      35             :  * selection controller objects, and some helper properties.
      36             :  */
      37           8 : class nsITextControlElement : public nsISupports {
      38             : public:
      39             : 
      40             :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXTCONTROLELEMENT_IID)
      41             : 
      42             :   /**
      43             :    * Tell the control that value has been deliberately changed (or not).
      44             :    */
      45             :   NS_IMETHOD SetValueChanged(bool changed) = 0;
      46             : 
      47             :   /**
      48             :    * Find out whether this is a single line text control.  (text or password)
      49             :    * @return whether this is a single line text control
      50             :    */
      51             :   NS_IMETHOD_(bool) IsSingleLineTextControl() const = 0;
      52             : 
      53             :   /**
      54             :    * Find out whether this control is a textarea.
      55             :    * @return whether this is a textarea text control
      56             :    */
      57             :   NS_IMETHOD_(bool) IsTextArea() const = 0;
      58             : 
      59             :   /**
      60             :    * Find out whether this control edits plain text.  (Currently always true.)
      61             :    * @return whether this is a plain text control
      62             :    */
      63             :   NS_IMETHOD_(bool) IsPlainTextControl() const = 0;
      64             : 
      65             :   /**
      66             :    * Find out whether this is a password control (input type=password)
      67             :    * @return whether this is a password ontrol
      68             :    */
      69             :   NS_IMETHOD_(bool) IsPasswordTextControl() const = 0;
      70             : 
      71             :   /**
      72             :    * Get the cols attribute (if textarea) or a default
      73             :    * @return the number of columns to use
      74             :    */
      75             :   NS_IMETHOD_(int32_t) GetCols() = 0;
      76             : 
      77             :   /**
      78             :    * Get the column index to wrap at, or -1 if we shouldn't wrap
      79             :    */
      80             :   NS_IMETHOD_(int32_t) GetWrapCols() = 0;
      81             : 
      82             :   /**
      83             :    * Get the rows attribute (if textarea) or a default
      84             :    * @return the number of rows to use
      85             :    */
      86             :   NS_IMETHOD_(int32_t) GetRows() = 0;
      87             : 
      88             :   /**
      89             :    * Get the default value of the text control
      90             :    */
      91             :   NS_IMETHOD_(void) GetDefaultValueFromContent(nsAString& aValue) = 0;
      92             : 
      93             :   /**
      94             :    * Return true if the value of the control has been changed.
      95             :    */
      96             :   NS_IMETHOD_(bool) ValueChanged() const = 0;
      97             : 
      98             :   /**
      99             :    * Get the current value of the text editor.
     100             :    *
     101             :    * @param aValue the buffer to retrieve the value in
     102             :    * @param aIgnoreWrap whether to ignore the text wrapping behavior specified
     103             :    * for the element.
     104             :    */
     105             :   NS_IMETHOD_(void) GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const = 0;
     106             : 
     107             :   /**
     108             :    * Get the editor object associated with the text editor.
     109             :    * The return value is null if the control does not support an editor
     110             :    * (for example, if it is a checkbox.)
     111             :    */
     112             :   NS_IMETHOD_(mozilla::TextEditor*) GetTextEditor() = 0;
     113             : 
     114             :   /**
     115             :    * Get the selection controller object associated with the text editor.
     116             :    * The return value is null if the control does not support an editor
     117             :    * (for example, if it is a checkbox.)
     118             :    */
     119             :   NS_IMETHOD_(nsISelectionController*) GetSelectionController() = 0;
     120             : 
     121             :   NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection() = 0;
     122             : 
     123             :   /**
     124             :    * Binds a frame to the text control.  This is performed when a frame
     125             :    * is created for the content node.
     126             :    */
     127             :   NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame) = 0;
     128             : 
     129             :   /**
     130             :    * Unbinds a frame from the text control.  This is performed when a frame
     131             :    * belonging to a content node is destroyed.
     132             :    */
     133             :   NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame) = 0;
     134             : 
     135             :   /**
     136             :    * Creates an editor for the text control.  This should happen when
     137             :    * a frame has been created for the text control element, but the created
     138             :    * editor may outlive the frame itself.
     139             :    */
     140             :   NS_IMETHOD CreateEditor() = 0;
     141             : 
     142             :   /**
     143             :    * Get the anonymous root node for the text control.
     144             :    */
     145             :   NS_IMETHOD_(mozilla::dom::Element*) GetRootEditorNode() = 0;
     146             : 
     147             :   /**
     148             :    * Create the placeholder anonymous node for the text control and returns it.
     149             :    */
     150             :   NS_IMETHOD_(mozilla::dom::Element*) CreatePlaceholderNode() = 0;
     151             : 
     152             :   /**
     153             :    * Get the placeholder anonymous node for the text control.
     154             :    */
     155             :   NS_IMETHOD_(mozilla::dom::Element*) GetPlaceholderNode() = 0;
     156             : 
     157             :   /**
     158             :    * Create the preview anonymous node for the text control and returns it.
     159             :    */
     160             :   NS_IMETHOD_(mozilla::dom::Element*) CreatePreviewNode() = 0;
     161             : 
     162             :   /**
     163             :    * Get the preview anonymous node for the text control.
     164             :    */
     165             :   NS_IMETHOD_(mozilla::dom::Element*) GetPreviewNode() = 0;
     166             : 
     167             :   /**
     168             :    * Update preview value for the text control.
     169             :    */
     170             :   NS_IMETHOD_(void) SetPreviewValue(const nsAString& aValue) = 0;
     171             : 
     172             :   /**
     173             :    * Get the current preview value for text control.
     174             :    */
     175             :   NS_IMETHOD_(void) GetPreviewValue(nsAString& aValue) = 0;
     176             : 
     177             :   /**
     178             :    * Enable preview for text control.
     179             :    */
     180             :   NS_IMETHOD_(void) EnablePreview() = 0;
     181             : 
     182             :   /**
     183             :    * Find out whether this control enables preview for form autofoll.
     184             :    */
     185             :   NS_IMETHOD_(bool) IsPreviewEnabled() = 0;
     186             : 
     187             :   /**
     188             :    * Initialize the keyboard event listeners.
     189             :    */
     190             :   NS_IMETHOD_(void) InitializeKeyboardEventListeners() = 0;
     191             : 
     192             :   /**
     193             :    * Update the visibility of both the placholder and preview text based on the element's state.
     194             :    */
     195             :   NS_IMETHOD_(void) UpdateOverlayTextVisibility(bool aNotify) = 0;
     196             : 
     197             :   /**
     198             :    * Returns the current expected placeholder visibility state.
     199             :    */
     200             :   NS_IMETHOD_(bool) GetPlaceholderVisibility() = 0;
     201             : 
     202             :   /**
     203             :    * Returns the current expected preview visibility state.
     204             :    */
     205             :   NS_IMETHOD_(bool) GetPreviewVisibility() = 0;
     206             : 
     207             :   /**
     208             :    * Callback called whenever the value is changed.
     209             :    */
     210             :   NS_IMETHOD_(void) OnValueChanged(bool aNotify, bool aWasInteractiveUserChange) = 0;
     211             : 
     212             :   /**
     213             :    * Helpers for value manipulation from SetRangeText.
     214             :    */
     215             :   virtual void GetValueFromSetRangeText(nsAString& aValue) = 0;
     216             :   virtual nsresult SetValueFromSetRangeText(const nsAString& aValue) = 0;
     217             : 
     218             :   static const int32_t DEFAULT_COLS = 20;
     219             :   static const int32_t DEFAULT_ROWS = 1;
     220             :   static const int32_t DEFAULT_ROWS_TEXTAREA = 2;
     221             :   static const int32_t DEFAULT_UNDO_CAP = 1000;
     222             : 
     223             :   // wrap can be one of these three values.
     224             :   typedef enum {
     225             :     eHTMLTextWrap_Off     = 1,    // "off"
     226             :     eHTMLTextWrap_Hard    = 2,    // "hard"
     227             :     eHTMLTextWrap_Soft    = 3     // the default
     228             :   } nsHTMLTextWrap;
     229             : 
     230             :   static bool
     231             :   GetWrapPropertyEnum(nsIContent* aContent, nsHTMLTextWrap& aWrapProp);
     232             : 
     233             :   /**
     234             :    * Does the editor have a selection cache?
     235             :    *
     236             :    * Note that this function has the side effect of making the editor for input
     237             :    * elements be initialized eagerly.
     238             :    */
     239             :   NS_IMETHOD_(bool) HasCachedSelection() = 0;
     240             : 
     241             :   static already_AddRefed<nsITextControlElement>
     242             :   GetTextControlElementFromEditingHost(nsIContent* aHost);
     243             : };
     244             : 
     245             : NS_DEFINE_STATIC_IID_ACCESSOR(nsITextControlElement,
     246             :                               NS_ITEXTCONTROLELEMENT_IID)
     247             : 
     248             : #endif // nsITextControlElement_h___
     249             : 

Generated by: LCOV version 1.13