mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibJS: Add PropertyLookupPhase enum to distinguish Object [[Get]] calls
We can now tell the difference between an own property access and a subsequent (automatic) prototype chain access. This will be used to implement caching of prototype chain accesses.
This commit is contained in:
parent
3945e1a82a
commit
493a04d5fe
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/awesomekling
Commit: 493a04d5fe
Pull-request: https://github.com/SerenityOS/serenity/pull/24206
Reviewed-by: https://github.com/kennethmyhra
17 changed files with 34 additions and 28 deletions
|
@ -409,15 +409,15 @@ JS::ThrowCompletionOr<bool> CSSStyleDeclaration::internal_has_property(JS::Prope
|
|||
return property_id_from_name(name.to_string()) != CSS::PropertyID::Invalid;
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> CSSStyleDeclaration::internal_get(JS::PropertyKey const& name, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata) const
|
||||
JS::ThrowCompletionOr<JS::Value> CSSStyleDeclaration::internal_get(JS::PropertyKey const& name, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata, PropertyLookupPhase phase) const
|
||||
{
|
||||
if (name.is_number())
|
||||
return { JS::PrimitiveString::create(vm(), item(name.as_number())) };
|
||||
if (!name.is_string())
|
||||
return Base::internal_get(name, receiver, cacheable_metadata);
|
||||
return Base::internal_get(name, receiver, cacheable_metadata, phase);
|
||||
auto property_id = property_id_from_name(name.to_string());
|
||||
if (property_id == CSS::PropertyID::Invalid)
|
||||
return Base::internal_get(name, receiver, cacheable_metadata);
|
||||
return Base::internal_get(name, receiver, cacheable_metadata, phase);
|
||||
if (auto maybe_property = property(property_id); maybe_property.has_value())
|
||||
return { JS::PrimitiveString::create(vm(), maybe_property->value->to_string()) };
|
||||
return { JS::PrimitiveString::create(vm(), String {}) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue