Bug 1879774 [wpt PR 44524] - WebKit export: Implement field-sizing support for input...
[gecko.git] / xpcom / ds / nsProperties.cpp
blob20949816349a396098aec7522dbfb775e18fe226
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/. */
7 #include "nsProperties.h"
9 ////////////////////////////////////////////////////////////////////////////////
11 NS_IMPL_ISUPPORTS(nsProperties, nsIProperties)
13 NS_IMETHODIMP
14 nsProperties::Get(const char* prop, const nsIID& uuid, void** result) {
15 if (NS_WARN_IF(!prop)) {
16 return NS_ERROR_INVALID_ARG;
19 nsCOMPtr<nsISupports> value;
20 if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value))) {
21 return NS_ERROR_FAILURE;
23 return (value) ? value->QueryInterface(uuid, result) : NS_ERROR_NO_INTERFACE;
26 NS_IMETHODIMP
27 nsProperties::Set(const char* prop, nsISupports* value) {
28 if (NS_WARN_IF(!prop)) {
29 return NS_ERROR_INVALID_ARG;
31 InsertOrUpdate(prop, value);
32 return NS_OK;
35 NS_IMETHODIMP
36 nsProperties::Undefine(const char* prop) {
37 if (NS_WARN_IF(!prop)) {
38 return NS_ERROR_INVALID_ARG;
41 return nsProperties_HashBase::Remove(prop) ? NS_OK : NS_ERROR_FAILURE;
44 NS_IMETHODIMP
45 nsProperties::Has(const char* prop, bool* result) {
46 if (NS_WARN_IF(!prop)) {
47 return NS_ERROR_INVALID_ARG;
50 *result = nsProperties_HashBase::Contains(prop);
51 return NS_OK;
54 NS_IMETHODIMP
55 nsProperties::GetKeys(nsTArray<nsCString>& aKeys) {
56 mozilla::AppendToArray(aKeys, this->Keys());
58 return NS_OK;
61 ////////////////////////////////////////////////////////////////////////////////