editor/libeditor/base/SplitElementTxn.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 SplitElementTxn_h__
     7 #define SplitElementTxn_h__
     9 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
    10 #include "nsCOMPtr.h"                   // for nsCOMPtr
    11 #include "nsCycleCollectionParticipant.h"
    12 #include "nsIDOMNode.h"                 // for nsIDOMNode
    13 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
    14 #include "nscore.h"                     // for NS_IMETHOD
    16 class nsEditor;
    18 /**
    19  * A transaction that splits an element E into two identical nodes, E1 and E2
    20  * with the children of E divided between E1 and E2.
    21  */
    22 class SplitElementTxn : public EditTxn
    23 {
    24 public:
    25   /** initialize the transaction.
    26     * @param aEditor  the provider of core editing operations
    27     * @param aNode    the node to split
    28     * @param aOffset  the location within aNode to do the split.
    29     *                 aOffset may refer to children of aNode, or content of aNode.
    30     *                 The left node will have child|content 0..aOffset-1.
    31     */
    32   NS_IMETHOD Init (nsEditor   *aEditor,
    33                    nsIDOMNode *aNode,
    34                    int32_t     aOffset);
    36   SplitElementTxn();
    38   NS_DECL_ISUPPORTS_INHERITED
    39   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitElementTxn, EditTxn)
    41   NS_DECL_EDITTXN
    43   NS_IMETHOD RedoTransaction(void);
    45   NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
    47 protected:
    49   /** the element to operate upon */
    50   nsCOMPtr<nsIDOMNode> mExistingRightNode;
    52   /** the offset into mElement where the children of mElement are split.<BR>
    53     * mOffset is the index of the first child in the right node. 
    54     * -1 means the new node gets no children.
    55     */
    56   int32_t  mOffset;
    58   /** the element we create when splitting mElement */
    59   nsCOMPtr<nsIDOMNode> mNewLeftNode;
    61   /** the parent shared by mExistingRightNode and mNewLeftNode */
    62   nsCOMPtr<nsIDOMNode> mParent;
    63   nsEditor*  mEditor;
    64 };
    66 #endif

mercurial