Bug 1777562 [wpt PR 34663] - [FedCM] Rename FederatedCredential to IdentityCredential...
[gecko.git] / widget / nsPrimitiveHelpers.h
blob33e2163b08fdf210de1249a510a5faef6cd8420d
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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/. */
7 #ifndef nsPrimitiveHelpers_h___
8 #define nsPrimitiveHelpers_h___
10 #include "nsError.h"
11 #include "nscore.h"
12 #include "nsString.h"
14 class nsISupports;
16 class nsPrimitiveHelpers {
17 public:
18 // Given some data and the flavor it corresponds to, creates the appropriate
19 // nsISupports* wrapper for passing across IDL boundaries. The length
20 // parameter should not include the null if the data is null terminated.
21 static void CreatePrimitiveForData(const nsACString& aFlavor,
22 const void* aDataBuff, uint32_t aDataLen,
23 nsISupports** aPrimitive);
25 // A specific case of CreatePrimitive for windows CF_HTML handling in
26 // DataTransfer
27 static void CreatePrimitiveForCFHTML(const void* aDataBuff,
28 uint32_t* aDataLen,
29 nsISupports** aPrimitive);
31 // Given a nsISupports* primitive and the flavor it represents, creates a new
32 // data buffer with the data in it. This data will be null terminated, but the
33 // length parameter does not reflect that.
34 static void CreateDataFromPrimitive(const nsACString& aFlavor,
35 nsISupports* aPrimitive, void** aDataBuff,
36 uint32_t* aDataLen);
38 }; // class nsPrimitiveHelpers
40 class nsLinebreakHelpers {
41 public:
42 // Given some data, convert from the platform linebreaks into the LF expected
43 // by the DOM. This will attempt to convert the data in place, but the buffer
44 // may still need to be reallocated regardless (disposing the old buffer is
45 // taken care of internally, see the note below).
47 // NOTE: this assumes that it can use 'free' to dispose of the old buffer.
48 static nsresult ConvertPlatformToDOMLinebreaks(const nsACString& inFlavor,
49 void** ioData,
50 int32_t* ioLengthInBytes);
52 }; // class nsLinebreakHelpers
54 #endif // nsPrimitiveHelpers_h___