mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium version 93.0.4577.0 (#902210)
This commit is contained in:
@ -243,8 +243,8 @@ bool CefValueImpl::GetBool() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
bool ret_value = false;
|
||||
if (value_)
|
||||
value_->GetAsBoolean(&ret_value);
|
||||
if (value_ && value_->is_bool())
|
||||
ret_value = value_->GetBool();
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@ -252,8 +252,8 @@ int CefValueImpl::GetInt() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
int ret_value = 0;
|
||||
if (value_)
|
||||
value_->GetAsInteger(&ret_value);
|
||||
if (value_ && value_->is_int())
|
||||
ret_value = value_->GetInt();
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@ -261,8 +261,8 @@ double CefValueImpl::GetDouble() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
double ret_value = 0;
|
||||
if (value_)
|
||||
value_->GetAsDouble(&ret_value);
|
||||
if (value_ && value_->is_double())
|
||||
ret_value = value_->GetDouble();
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@ -270,8 +270,8 @@ CefString CefValueImpl::GetString() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
std::string ret_value;
|
||||
if (value_)
|
||||
value_->GetAsString(&ret_value);
|
||||
if (value_ && value_->is_string())
|
||||
ret_value = value_->GetString();
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@ -691,7 +691,7 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::Copy(
|
||||
|
||||
size_t CefDictionaryValueImpl::GetSize() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||
return const_value().size();
|
||||
return const_value().DictSize();
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::Clear() {
|
||||
@ -700,7 +700,7 @@ bool CefDictionaryValueImpl::Clear() {
|
||||
// Detach any dependent values.
|
||||
controller()->RemoveDependencies(mutable_value());
|
||||
|
||||
mutable_value()->Clear();
|
||||
mutable_value()->DictClear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -728,10 +728,9 @@ bool CefDictionaryValueImpl::Remove(const CefString& key) {
|
||||
CefValueType CefDictionaryValueImpl::GetType(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, VTYPE_INVALID);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key),
|
||||
&out_value)) {
|
||||
switch (out_value->type()) {
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value) {
|
||||
switch (value->type()) {
|
||||
case base::Value::Type::NONE:
|
||||
return VTYPE_NULL;
|
||||
case base::Value::Type::BOOLEAN:
|
||||
@ -757,11 +756,10 @@ CefValueType CefDictionaryValueImpl::GetType(const CefString& key) {
|
||||
CefRefPtr<CefValue> CefDictionaryValueImpl::GetValue(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key),
|
||||
&out_value)) {
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value) {
|
||||
return CefValueImpl::GetOrCreateRefOrCopy(
|
||||
const_cast<base::Value*>(out_value),
|
||||
const_cast<base::Value*>(value),
|
||||
const_cast<base::DictionaryValue*>(&const_value()), read_only(),
|
||||
controller());
|
||||
}
|
||||
@ -772,11 +770,12 @@ CefRefPtr<CefValue> CefDictionaryValueImpl::GetValue(const CefString& key) {
|
||||
bool CefDictionaryValueImpl::GetBool(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
bool ret_value = false;
|
||||
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key), &out_value))
|
||||
out_value->GetAsBoolean(&ret_value);
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value && value->is_bool()) {
|
||||
ret_value = value->GetBool();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -784,11 +783,12 @@ bool CefDictionaryValueImpl::GetBool(const CefString& key) {
|
||||
int CefDictionaryValueImpl::GetInt(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
int ret_value = 0;
|
||||
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key), &out_value))
|
||||
out_value->GetAsInteger(&ret_value);
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value && value->is_int()) {
|
||||
ret_value = value->GetInt();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -796,11 +796,12 @@ int CefDictionaryValueImpl::GetInt(const CefString& key) {
|
||||
double CefDictionaryValueImpl::GetDouble(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
double ret_value = 0;
|
||||
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key), &out_value))
|
||||
out_value->GetAsDouble(&ret_value);
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value && value->is_double()) {
|
||||
ret_value = value->GetDouble();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -808,11 +809,12 @@ double CefDictionaryValueImpl::GetDouble(const CefString& key) {
|
||||
CefString CefDictionaryValueImpl::GetString(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
std::string ret_value;
|
||||
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key), &out_value))
|
||||
out_value->GetAsString(&ret_value);
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value && value->is_string()) {
|
||||
ret_value = value->GetString();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -821,12 +823,9 @@ CefRefPtr<CefBinaryValue> CefDictionaryValueImpl::GetBinary(
|
||||
const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key),
|
||||
&out_value) &&
|
||||
out_value->is_blob()) {
|
||||
base::Value* binary_value = const_cast<base::Value*>(out_value);
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value && value->is_blob()) {
|
||||
base::Value* binary_value = const_cast<base::Value*>(value);
|
||||
return CefBinaryValueImpl::GetOrCreateRef(
|
||||
binary_value, const_cast<base::DictionaryValue*>(&const_value()),
|
||||
controller());
|
||||
@ -839,13 +838,10 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::GetDictionary(
|
||||
const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key),
|
||||
&out_value) &&
|
||||
out_value->is_dict()) {
|
||||
base::DictionaryValue* dict_value = static_cast<base::DictionaryValue*>(
|
||||
const_cast<base::Value*>(out_value));
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value && value->is_dict()) {
|
||||
base::DictionaryValue* dict_value =
|
||||
static_cast<base::DictionaryValue*>(const_cast<base::Value*>(value));
|
||||
return CefDictionaryValueImpl::GetOrCreateRef(
|
||||
dict_value, const_cast<base::DictionaryValue*>(&const_value()),
|
||||
read_only(), controller());
|
||||
@ -857,13 +853,10 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::GetDictionary(
|
||||
CefRefPtr<CefListValue> CefDictionaryValueImpl::GetList(const CefString& key) {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
|
||||
const base::Value* out_value = nullptr;
|
||||
|
||||
if (const_value().GetWithoutPathExpansion(base::StringPiece(key),
|
||||
&out_value) &&
|
||||
out_value->is_list()) {
|
||||
const base::Value* value = const_value().FindKey(base::StringPiece(key));
|
||||
if (value && value->is_list()) {
|
||||
base::ListValue* list_value =
|
||||
static_cast<base::ListValue*>(const_cast<base::Value*>(out_value));
|
||||
static_cast<base::ListValue*>(const_cast<base::Value*>(value));
|
||||
return CefListValueImpl::GetOrCreateRef(
|
||||
list_value, const_cast<base::DictionaryValue*>(&const_value()),
|
||||
read_only(), controller());
|
||||
@ -952,18 +945,29 @@ bool CefDictionaryValueImpl::SetList(const CefString& key,
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::RemoveInternal(const CefString& key) {
|
||||
std::unique_ptr<base::Value> out_value;
|
||||
if (!mutable_value()->RemoveWithoutPathExpansion(base::StringPiece(key),
|
||||
&out_value)) {
|
||||
// The ExtractKey() call below which removes the Value from the dictionary
|
||||
// will return a new Value object with the moved contents of the Value that
|
||||
// exists in the implementation std::map. Consequently we use FindKey() to
|
||||
// retrieve the actual Value pointer as it current exists first, for later
|
||||
// comparison purposes.
|
||||
const base::Value* actual_value =
|
||||
const_value().FindKey(base::StringPiece(key));
|
||||
if (!actual_value)
|
||||
return false;
|
||||
|
||||
// |actual_value| is no longer valid after this call.
|
||||
absl::optional<base::Value> out_value =
|
||||
mutable_value()->ExtractKey(base::StringPiece(key));
|
||||
if (!out_value.has_value()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove the value.
|
||||
controller()->Remove(out_value.get(), true);
|
||||
controller()->Remove(const_cast<base::Value*>(actual_value), true);
|
||||
|
||||
// Only list and dictionary types may have dependencies.
|
||||
if (out_value->is_list() || out_value->is_dict()) {
|
||||
controller()->RemoveDependencies(out_value.get());
|
||||
controller()->RemoveDependencies(const_cast<base::Value*>(actual_value));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1126,7 +1130,7 @@ bool CefListValueImpl::Clear() {
|
||||
// Detach any dependent values.
|
||||
controller()->RemoveDependencies(mutable_value());
|
||||
|
||||
mutable_value()->Clear();
|
||||
mutable_value()->ClearList();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1183,8 +1187,9 @@ bool CefListValueImpl::GetBool(size_t index) {
|
||||
const base::Value* out_value = nullptr;
|
||||
bool ret_value = false;
|
||||
|
||||
if (const_value().Get(index, &out_value))
|
||||
out_value->GetAsBoolean(&ret_value);
|
||||
if (const_value().Get(index, &out_value) && out_value->is_bool()) {
|
||||
ret_value = out_value->GetBool();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -1195,8 +1200,9 @@ int CefListValueImpl::GetInt(size_t index) {
|
||||
const base::Value* out_value = nullptr;
|
||||
int ret_value = 0;
|
||||
|
||||
if (const_value().Get(index, &out_value))
|
||||
out_value->GetAsInteger(&ret_value);
|
||||
if (const_value().Get(index, &out_value) && out_value->is_int()) {
|
||||
ret_value = out_value->GetInt();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -1207,8 +1213,9 @@ double CefListValueImpl::GetDouble(size_t index) {
|
||||
const base::Value* out_value = nullptr;
|
||||
double ret_value = 0;
|
||||
|
||||
if (const_value().Get(index, &out_value))
|
||||
out_value->GetAsDouble(&ret_value);
|
||||
if (const_value().Get(index, &out_value) && out_value->is_double()) {
|
||||
ret_value = out_value->GetDouble();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -1219,8 +1226,9 @@ CefString CefListValueImpl::GetString(size_t index) {
|
||||
const base::Value* out_value = nullptr;
|
||||
std::string ret_value;
|
||||
|
||||
if (const_value().Get(index, &out_value))
|
||||
out_value->GetAsString(&ret_value);
|
||||
if (const_value().Get(index, &out_value) && out_value->is_string()) {
|
||||
ret_value = out_value->GetString();
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@ -1348,24 +1356,28 @@ bool CefListValueImpl::SetList(size_t index, CefRefPtr<CefListValue> value) {
|
||||
}
|
||||
|
||||
bool CefListValueImpl::RemoveInternal(size_t index) {
|
||||
// base::Value now uses move semantics which means that Remove() will return
|
||||
// a new base::Value object with the moved contents of the base::Value that
|
||||
// exists in the implementation std::vector. Consequently we use Get() to
|
||||
// retrieve the actual base::Value pointer as it exists in the std::vector.
|
||||
const base::Value* actual_value = nullptr;
|
||||
if (!const_value().Get(index, &actual_value))
|
||||
auto list = mutable_value()->GetList();
|
||||
if (index >= list.size())
|
||||
return false;
|
||||
DCHECK(actual_value);
|
||||
|
||||
std::unique_ptr<base::Value> out_value;
|
||||
if (!mutable_value()->Remove(index, &out_value))
|
||||
// The std::move() call below which removes the Value from the list will
|
||||
// return a new Value object with the moved contents of the Value that exists
|
||||
// in the implementation std::vector. Consequently we use Get() to retrieve
|
||||
// the actual Value pointer as it current exists first, for later comparison
|
||||
// purposes.
|
||||
const base::Value* actual_value = nullptr;
|
||||
if (!const_value().Get(index, &actual_value) || !actual_value)
|
||||
return false;
|
||||
|
||||
// |actual_value| is no longer valid after this call.
|
||||
auto out_value = std::move(list[index]);
|
||||
mutable_value()->EraseListIter(list.begin() + index);
|
||||
|
||||
// Remove the value.
|
||||
controller()->Remove(const_cast<base::Value*>(actual_value), true);
|
||||
|
||||
// Only list and dictionary types may have dependencies.
|
||||
if (out_value->is_list() || out_value->is_dict()) {
|
||||
if (out_value.is_list() || out_value.is_dict()) {
|
||||
controller()->RemoveDependencies(const_cast<base::Value*>(actual_value));
|
||||
}
|
||||
|
||||
@ -1375,10 +1387,13 @@ bool CefListValueImpl::RemoveInternal(size_t index) {
|
||||
base::Value* CefListValueImpl::SetInternal(size_t index, base::Value* value) {
|
||||
DCHECK(value);
|
||||
|
||||
if (RemoveInternal(index))
|
||||
mutable_value()->Insert(index, base::WrapUnique(value));
|
||||
else
|
||||
if (RemoveInternal(index)) {
|
||||
auto list = mutable_value()->GetList();
|
||||
CHECK_LE(index, list.size());
|
||||
mutable_value()->Insert(list.begin() + index, std::move(*value));
|
||||
} else {
|
||||
mutable_value()->Set(index, base::WrapUnique(value));
|
||||
}
|
||||
|
||||
// base::Value now uses move semantics which means that Insert()/Set() will
|
||||
// move the contents of the passed-in base::Value instead of keeping the same
|
||||
|
Reference in New Issue
Block a user