Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: Source/bindings/scripts/deprecated_code_generator_v8.pm

Issue 19457002: Make 'any'-typed attributes of events available in isolated worlds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 GenerateOverloadedConstructorCallback($interface); 2643 GenerateOverloadedConstructorCallback($interface);
2644 } 2644 }
2645 } 2645 }
2646 2646
2647 sub GenerateEventConstructor 2647 sub GenerateEventConstructor
2648 { 2648 {
2649 my $interface = shift; 2649 my $interface = shift;
2650 my $implClassName = GetImplName($interface); 2650 my $implClassName = GetImplName($interface);
2651 my $v8ClassName = GetV8ClassName($interface); 2651 my $v8ClassName = GetV8ClassName($interface);
2652 2652
2653 my @anyAttributeNames;
2654 foreach my $attribute (@{$interface->attributes}) {
2655 if ($attribute->type eq "any") {
2656 push(@anyAttributeNames, $attribute->name);
2657 }
2658 }
2659
2653 AddToImplIncludes("bindings/v8/Dictionary.h"); 2660 AddToImplIncludes("bindings/v8/Dictionary.h");
2654 $implementation{nameSpaceInternal}->add(<<END); 2661 $implementation{nameSpaceInternal}->add(<<END);
2655 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) 2662 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args)
2656 { 2663 {
2657 if (args.Length() < 1) { 2664 if (args.Length() < 1) {
2658 throwNotEnoughArgumentsError(args.GetIsolate()); 2665 throwNotEnoughArgumentsError(args.GetIsolate());
2659 return; 2666 return;
2660 } 2667 }
2661 2668
2662 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); 2669 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]);
2670 END
2671
2672 foreach my $attrName (@anyAttributeNames) {
2673 $implementation{nameSpaceInternal}->add(" v8::Local<v8::Value> ${attr Name};\n");
2674 }
2675
2676 $implementation{nameSpaceInternal}->add(<<END);
2663 ${implClassName}Init eventInit; 2677 ${implClassName}Init eventInit;
2664 if (args.Length() >= 2) { 2678 if (args.Length() >= 2) {
2665 V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate ())); 2679 V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate ()));
2666 if (!fill${implClassName}Init(eventInit, options)) 2680 if (!fill${implClassName}Init(eventInit, options))
2667 return; 2681 return;
2668 END 2682 END
2669 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 2683
2670 my $attribute = @{$interface->attributes}[$index]; 2684 # Store 'any'-typed properties on the wrapper to avoid leaking them between isolated worlds.
2671 if ($attribute->type eq "any") { 2685 foreach my $attrName (@anyAttributeNames) {
2672 my $attributeName = $attribute->name; 2686 $implementation{nameSpaceInternal}->add(<<END);
2673 $implementation{nameSpaceInternal}->add(<<END); 2687 options.get("${attrName}", ${attrName});
2674 v8::Local<v8::Value> ${attributeName}; 2688 if (!${attrName}.IsEmpty())
2675 options.get("${attributeName}", ${attributeName}); 2689 args.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(), $ {attrName});
2676 if (!${attributeName}.IsEmpty())
2677 args.Holder()->SetHiddenValue(V8HiddenPropertyName::${attributeName} (), ${attributeName});
2678 END 2690 END
2679 } 2691 }
2680 } 2692
2681 $implementation{nameSpaceInternal}->add(<<END); 2693 $implementation{nameSpaceInternal}->add(<<END);
2682 } 2694 }
2683 2695
2684 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); 2696 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit);
2697 END
2685 2698
2699 if (@anyAttributeNames) {
2700 # If we're in an isolated world, create a SerializedScriptValue and stor e it in the event for
2701 # later cloning if the property is accessed from another world.
2702 # The main world case is handled lazily (in Custom code).
2703 $implementation{nameSpaceInternal}->add(" if (isolatedWorldForIsolate (args.GetIsolate())) {\n");
2704 foreach my $attrName (@anyAttributeNames) {
2705 my $setter = "setSerialized" . FirstLetterToUpperCase($attrName);
2706 $implementation{nameSpaceInternal}->add(<<END);
2707 if (!${attrName}.IsEmpty())
2708 event->${setter}(SerializedScriptValue::createAndSwallowExceptions($ {attrName}, args.GetIsolate()));
2709 END
2710 }
2711 $implementation{nameSpaceInternal}->add(" }\n\n");
2712 }
2713
2714 $implementation{nameSpaceInternal}->add(<<END);
2686 v8::Handle<v8::Object> wrapper = args.Holder(); 2715 v8::Handle<v8::Object> wrapper = args.Holder();
2687 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent ); 2716 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent );
2688 v8SetReturnValue(args, wrapper); 2717 v8SetReturnValue(args, wrapper);
2689 } 2718 }
2690 END 2719 END
2691 2720
2692 my $code = ""; 2721 my $code = "";
2693 $code .= <<END; 2722 $code .= <<END;
2694 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options) 2723 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options)
2695 { 2724 {
2696 END 2725 END
2697 2726
2698 if ($interface->parent) { 2727 if ($interface->parent) {
2699 my $interfaceBase = $interface->parent; 2728 my $interfaceBase = $interface->parent;
2700 $code .= <<END; 2729 $code .= <<END;
2701 if (!fill${interfaceBase}Init(eventInit, options)) 2730 if (!fill${interfaceBase}Init(eventInit, options))
2702 return false; 2731 return false;
2703 2732
2704 END 2733 END
2705 } 2734 }
2706 2735
2707 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 2736 foreach my $attribute (@{$interface->attributes}) {
2708 my $attribute = @{$interface->attributes}[$index];
2709 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { 2737 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) {
2710 my $attributeName = $attribute->name; 2738 if ($attribute->type ne "any") {
2711 my $attributeType = $attribute->type; 2739 my $attributeName = $attribute->name;
2712 if (not ($attribute->type eq "any")) {
2713 $code .= " options.get(\"$attributeName\", eventInit.$attribu teName);\n"; 2740 $code .= " options.get(\"$attributeName\", eventInit.$attribu teName);\n";
2714 } 2741 }
2715 } 2742 }
2716 } 2743 }
2717 2744
2718 $code .= <<END; 2745 $code .= <<END;
2719 return true; 2746 return true;
2720 } 2747 }
2721 2748
2722 END 2749 END
(...skipping 3281 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6031 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6005 $found = 1; 6032 $found = 1;
6006 } 6033 }
6007 return 1 if $found; 6034 return 1 if $found;
6008 }, 0); 6035 }, 0);
6009 6036
6010 return $found; 6037 return $found;
6011 } 6038 }
6012 6039
6013 1; 6040 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698