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

Side by Side Diff: Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp

Issue 54283002: Rename |args| to |info| in V8 bindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "core/frame/Frame.h" 45 #include "core/frame/Frame.h"
46 #include "wtf/OwnPtr.h" 46 #include "wtf/OwnPtr.h"
47 #include "wtf/RefPtr.h" 47 #include "wtf/RefPtr.h"
48 #include "wtf/StdLibExtras.h" 48 #include "wtf/StdLibExtras.h"
49 #include "wtf/text/StringBuilder.h" 49 #include "wtf/text/StringBuilder.h"
50 50
51 namespace WebCore { 51 namespace WebCore {
52 52
53 // HTMLDocument ---------------------------------------------------------------- 53 // HTMLDocument ----------------------------------------------------------------
54 54
55 // Concatenates "args" to a string. If args is empty, returns empty string. 55 // Concatenates "info" to a string. If info is empty, returns empty string.
56 // Firefox/Safari/IE support non-standard arguments to document.write, ex: 56 // Firefox/Safari/IE support non-standard arguments to document.write, ex:
57 // document.write("a", "b", "c") --> document.write("abc") 57 // document.write("a", "b", "c") --> document.write("abc")
58 // document.write() --> document.write("") 58 // document.write() --> document.write("")
59 static String writeHelperGetString(const v8::FunctionCallbackInfo<v8::Value>& ar gs) 59 static String writeHelperGetString(const v8::FunctionCallbackInfo<v8::Value>& in fo)
60 { 60 {
61 StringBuilder builder; 61 StringBuilder builder;
62 for (int i = 0; i < args.Length(); ++i) { 62 for (int i = 0; i < info.Length(); ++i) {
63 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringArgumen t, args[i], String()); 63 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringArgumen t, info[i], String());
64 builder.append(stringArgument); 64 builder.append(stringArgument);
65 } 65 }
66 return builder.toString(); 66 return builder.toString();
67 } 67 }
68 68
69 void V8HTMLDocument::writeMethodCustom(const v8::FunctionCallbackInfo<v8::Value> & args) 69 void V8HTMLDocument::writeMethodCustom(const v8::FunctionCallbackInfo<v8::Value> & info)
70 { 70 {
71 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder()); 71 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
72 htmlDocument->write(writeHelperGetString(args), activeDOMWindow()->document( )); 72 htmlDocument->write(writeHelperGetString(info), activeDOMWindow()->document( ));
73 } 73 }
74 74
75 void V8HTMLDocument::writelnMethodCustom(const v8::FunctionCallbackInfo<v8::Valu e>& args) 75 void V8HTMLDocument::writelnMethodCustom(const v8::FunctionCallbackInfo<v8::Valu e>& info)
76 { 76 {
77 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder()); 77 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
78 htmlDocument->writeln(writeHelperGetString(args), activeDOMWindow()->documen t()); 78 htmlDocument->writeln(writeHelperGetString(info), activeDOMWindow()->documen t());
79 } 79 }
80 80
81 void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) 81 void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
82 { 82 {
83 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder()); 83 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
84 84
85 if (args.Length() > 2) { 85 if (info.Length() > 2) {
86 if (RefPtr<Frame> frame = htmlDocument->frame()) { 86 if (RefPtr<Frame> frame = htmlDocument->frame()) {
87 // Fetch the global object for the frame. 87 // Fetch the global object for the frame.
88 v8::Local<v8::Context> context = frame->script().currentWorldContext (); 88 v8::Local<v8::Context> context = frame->script().currentWorldContext ();
89 // Bail out if we cannot get the context. 89 // Bail out if we cannot get the context.
90 if (context.IsEmpty()) 90 if (context.IsEmpty())
91 return; 91 return;
92 v8::Local<v8::Object> global = context->Global(); 92 v8::Local<v8::Object> global = context->Global();
93 // Get the open property of the global object. 93 // Get the open property of the global object.
94 v8::Local<v8::Value> function = global->Get(v8::String::NewSymbol("o pen")); 94 v8::Local<v8::Value> function = global->Get(v8::String::NewSymbol("o pen"));
95 // If the open property is not a function throw a type error. 95 // If the open property is not a function throw a type error.
96 if (!function->IsFunction()) { 96 if (!function->IsFunction()) {
97 throwTypeError("open is not a function", args.GetIsolate()); 97 throwTypeError("open is not a function", info.GetIsolate());
98 return; 98 return;
99 } 99 }
100 // Wrap up the arguments and call the function. 100 // Wrap up the arguments and call the function.
101 OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local< v8::Value>[args.Length()]); 101 OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local< v8::Value>[info.Length()]);
102 for (int i = 0; i < args.Length(); i++) 102 for (int i = 0; i < info.Length(); i++)
103 params[i] = args[i]; 103 params[i] = info[i];
104 104
105 v8SetReturnValue(args, frame->script().callFunction(v8::Local<v8::Fu nction>::Cast(function), global, args.Length(), params.get())); 105 v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Fu nction>::Cast(function), global, info.Length(), params.get()));
106 return; 106 return;
107 } 107 }
108 } 108 }
109 109
110 htmlDocument->open(activeDOMWindow()->document()); 110 htmlDocument->open(activeDOMWindow()->document());
111 v8SetReturnValue(args, args.Holder()); 111 v8SetReturnValue(info, info.Holder());
112 } 112 }
113 113
114 } // namespace WebCore 114 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698