Index: third_party/WebKit/Source/bindings/templates/methods.cpp |
diff --git a/third_party/WebKit/Source/bindings/templates/methods.cpp b/third_party/WebKit/Source/bindings/templates/methods.cpp |
index c58d89c7afe512e303515e5950aaa1c565c765bb..c9295cdb161dd59f47fef4cb27ac0742c9f17d09 100644 |
--- a/third_party/WebKit/Source/bindings/templates/methods.cpp |
+++ b/third_party/WebKit/Source/bindings/templates/methods.cpp |
@@ -28,12 +28,27 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const |
{% endif %} |
{# Security checks #} |
{% if method.is_check_security_for_receiver %} |
+ {% if interface_name == 'EventTarget' %} |
+ // Performance hack for EventTarget. Checking whether it's a Window or not |
+ // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30% |
+ // of speed performance on Android Nexus 7 as of Dec 2016. ALWAYS_INLINE |
+ // didn't work in this case. |
+ if (LocalDOMWindow* window = impl->toDOMWindow()) { |
+ if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), window, exceptionState)) { |
+ {% if not method.returns_promise %} |
+ exceptionState.throwIfNeeded(); |
+ {% endif %} |
+ return; |
+ } |
+ } |
+ {% else %}{# interface_name == 'EventTarget' #} |
if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl, exceptionState)) { |
{% if not method.returns_promise %} |
exceptionState.throwIfNeeded(); |
{% endif %} |
return; |
} |
+ {% endif %}{# interface_name == 'EventTarget' #} |
{% endif %} |
{% if method.is_check_security_for_return_value %} |
if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), {{method.cpp_value}}, exceptionState)) { |