editor/libeditor/base/InsertTextTxn.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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/. */
     6 #ifndef InsertTextTxn_h__
     7 #define InsertTextTxn_h__
     9 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
    10 #include "nsCOMPtr.h"                   // for nsCOMPtr
    11 #include "nsCycleCollectionParticipant.h"
    12 #include "nsID.h"                       // for nsIID
    13 #include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
    14 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
    15 #include "nsString.h"                   // for nsString
    16 #include "nscore.h"                     // for NS_IMETHOD, nsAString
    18 class nsIEditor;
    19 class nsITransaction;
    22 #define INSERT_TEXT_TXN_CID \
    23 {/* 93276f00-ab2c-11d2-8f4b-006008159b0c*/ \
    24 0x93276f00, 0xab2c, 0x11d2, \
    25 {0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} }
    27 /**
    28   * A transaction that inserts text into a content node. 
    29   */
    30 class InsertTextTxn : public EditTxn
    31 {
    32 public:
    34   static const nsIID& GetCID() { static const nsIID iid = INSERT_TEXT_TXN_CID; return iid; }
    36   /** initialize the transaction
    37     * @param aElement the text content node
    38     * @param aOffset  the location in aElement to do the insertion
    39     * @param aString  the new text to insert
    40     * @param aPresShell used to get and set the selection
    41     */
    42   NS_IMETHOD Init(nsIDOMCharacterData *aElement,
    43                   uint32_t aOffset,
    44                   const nsAString& aString,
    45                   nsIEditor *aEditor);
    47   InsertTextTxn();
    49   NS_DECL_ISUPPORTS_INHERITED
    50   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTxn, EditTxn)
    52   NS_DECL_EDITTXN
    54   NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
    56   /** return the string data associated with this transaction */
    57   NS_IMETHOD GetData(nsString& aResult);
    59 protected:
    61   /** return true if aOtherTxn immediately follows this txn */
    62   virtual bool IsSequentialInsert(InsertTextTxn *aOtherTxn);
    64   /** the text element to operate upon */
    65   nsCOMPtr<nsIDOMCharacterData> mElement;
    67   /** the offset into mElement where the insertion is to take place */
    68   uint32_t mOffset;
    70   /** the text to insert into mElement at mOffset */
    71   nsString mStringToInsert;
    73   /** the editor, which we'll need to get the selection */
    74   nsIEditor *mEditor;   
    75 };
    77 #endif

mercurial