LCOV - code coverage report
Current view: top level - editor/libeditor - ChangeStyleTransaction.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef mozilla_ChangeStyleTransaction_h
       7             : #define mozilla_ChangeStyleTransaction_h
       8             : 
       9             : #include "mozilla/EditTransactionBase.h"  // base class
      10             : #include "nsCOMPtr.h"                     // nsCOMPtr members
      11             : #include "nsCycleCollectionParticipant.h" // various macros
      12             : #include "nsString.h"                     // nsString members
      13             : 
      14             : class nsAString;
      15             : class nsIAtom;
      16             : 
      17             : namespace mozilla {
      18             : 
      19             : namespace dom {
      20             : class Element;
      21             : } // namespace dom
      22             : 
      23             : /**
      24             :  * A transaction that changes the value of a CSS inline style of a content
      25             :  * node.  This transaction covers add, remove, and change a property's value.
      26             :  */
      27             : class ChangeStyleTransaction final : public EditTransactionBase
      28             : {
      29             : public:
      30           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeStyleTransaction,
      31             :                                            EditTransactionBase)
      32             : 
      33             :   NS_DECL_ISUPPORTS_INHERITED
      34             : 
      35             :   NS_DECL_EDITTRANSACTIONBASE
      36             : 
      37             :   NS_IMETHOD RedoTransaction() override;
      38             : 
      39             :   enum EChangeType { eSet, eRemove };
      40             : 
      41             :   /**
      42             :    * @param aNode           [IN] the node whose style attribute will be changed
      43             :    * @param aProperty       [IN] the name of the property to change
      44             :    * @param aValue          [IN] new value for aProperty, or value to remove
      45             :    * @param aChangeType     [IN] whether to set or remove
      46             :    */
      47             :   ChangeStyleTransaction(dom::Element& aElement,
      48             :                          nsIAtom& aProperty,
      49             :                          const nsAString& aValue,
      50             :                          EChangeType aChangeType);
      51             : 
      52             :   /**
      53             :    * Returns true if the list of white-space separated values contains aValue
      54             :    *
      55             :    * @param aValueList      [IN] a list of white-space separated values
      56             :    * @param aValue          [IN] the value to look for in the list
      57             :    * @return                true if the value is in the list of values
      58             :    */
      59             :   static bool ValueIncludes(const nsAString& aValueList,
      60             :                             const nsAString& aValue);
      61             : 
      62             : private:
      63             :   virtual ~ChangeStyleTransaction();
      64             : 
      65             :   /*
      66             :    * Adds the value aNewValue to list of white-space separated values aValues.
      67             :    *
      68             :    * @param aValues         [IN/OUT] a list of wite-space separated values
      69             :    * @param aNewValue       [IN] a value this code adds to aValues if it is not
      70             :    *                        already in
      71             :    */
      72             :   void AddValueToMultivalueProperty(nsAString& aValues,
      73             :                                     const nsAString& aNewValue);
      74             : 
      75             :   /**
      76             :    * Returns true if the property accepts more than one value.
      77             :    *
      78             :    * @param aCSSProperty    [IN] the CSS property
      79             :    * @return                true if the property accepts more than one value
      80             :    */
      81             :   bool AcceptsMoreThanOneValue(nsIAtom& aCSSProperty);
      82             : 
      83             :   /**
      84             :    * Remove a value from a list of white-space separated values.
      85             :    * @param aValues         [IN] a list of white-space separated values
      86             :    * @param aRemoveValue    [IN] the value to remove from the list
      87             :    */
      88             :   void RemoveValueFromListOfValues(nsAString& aValues,
      89             :                                    const nsAString& aRemoveValue);
      90             : 
      91             :   /**
      92             :    * If the boolean is true and if the value is not the empty string,
      93             :    * set the property in the transaction to that value; if the value
      94             :    * is empty, remove the property from element's styles. If the boolean
      95             :    * is false, just remove the style attribute.
      96             :    */
      97             :   nsresult SetStyle(bool aAttributeWasSet, nsAString& aValue);
      98             : 
      99             :   // The element to operate upon.
     100             :   nsCOMPtr<dom::Element> mElement;
     101             : 
     102             :   // The CSS property to change.
     103             :   nsCOMPtr<nsIAtom> mProperty;
     104             : 
     105             :   // The value to set the property to (ignored if mRemoveProperty==true).
     106             :   nsString mValue;
     107             : 
     108             :   // true if the operation is to remove mProperty from mElement.
     109             :   bool mRemoveProperty;
     110             : 
     111             :   // The value to set the property to for undo.
     112             :   nsString mUndoValue;
     113             :   // The value to set the property to for redo.
     114             :   nsString mRedoValue;
     115             :   // True if the style attribute was present and not empty before DoTransaction.
     116             :   bool mUndoAttributeWasSet;
     117             :   // True if the style attribute is present and not empty after DoTransaction.
     118             :   bool mRedoAttributeWasSet;
     119             : };
     120             : 
     121             : } // namespace mozilla
     122             : 
     123             : #endif // #ifndef mozilla_ChangeStyleTransaction_h

Generated by: LCOV version 1.13