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

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

Issue 59693007: Get rid of custom code for HTMLDocument.write() / writeln() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Extend layout test 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
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 28 matching lines...) Expand all
39 #include "bindings/v8/ScriptController.h" 39 #include "bindings/v8/ScriptController.h"
40 #include "bindings/v8/V8Binding.h" 40 #include "bindings/v8/V8Binding.h"
41 #include "core/html/HTMLAllCollection.h" 41 #include "core/html/HTMLAllCollection.h"
42 #include "core/html/HTMLCollection.h" 42 #include "core/html/HTMLCollection.h"
43 #include "core/html/HTMLDocument.h" 43 #include "core/html/HTMLDocument.h"
44 #include "core/html/HTMLIFrameElement.h" 44 #include "core/html/HTMLIFrameElement.h"
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"
50 49
51 namespace WebCore { 50 namespace WebCore {
52 51
53 // HTMLDocument ---------------------------------------------------------------- 52 // HTMLDocument ----------------------------------------------------------------
54 53
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:
57 // document.write("a", "b", "c") --> document.write("abc")
58 // document.write() --> document.write("")
59 static String writeHelperGetString(const v8::FunctionCallbackInfo<v8::Value>& in fo)
60 {
61 StringBuilder builder;
62 for (int i = 0; i < info.Length(); ++i) {
63 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringArgumen t, info[i], String());
64 builder.append(stringArgument);
65 }
66 return builder.toString();
67 }
68
69 void V8HTMLDocument::writeMethodCustom(const v8::FunctionCallbackInfo<v8::Value> & info)
70 {
71 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
72 htmlDocument->write(writeHelperGetString(info), activeDOMWindow()->document( ));
73 }
74
75 void V8HTMLDocument::writelnMethodCustom(const v8::FunctionCallbackInfo<v8::Valu e>& info)
76 {
77 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
78 htmlDocument->writeln(writeHelperGetString(info), activeDOMWindow()->documen t());
79 }
80
81 void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) 54 void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
82 { 55 {
83 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder()); 56 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
84 57
85 if (info.Length() > 2) { 58 if (info.Length() > 2) {
86 if (RefPtr<Frame> frame = htmlDocument->frame()) { 59 if (RefPtr<Frame> frame = htmlDocument->frame()) {
87 // Fetch the global object for the frame. 60 // Fetch the global object for the frame.
88 v8::Local<v8::Context> context = frame->script().currentWorldContext (); 61 v8::Local<v8::Context> context = frame->script().currentWorldContext ();
89 // Bail out if we cannot get the context. 62 // Bail out if we cannot get the context.
90 if (context.IsEmpty()) 63 if (context.IsEmpty())
(...skipping 14 matching lines...) Expand all
105 v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Fu nction>::Cast(function), global, info.Length(), params.get())); 78 v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Fu nction>::Cast(function), global, info.Length(), params.get()));
106 return; 79 return;
107 } 80 }
108 } 81 }
109 82
110 htmlDocument->open(activeDOMWindow()->document()); 83 htmlDocument->open(activeDOMWindow()->document());
111 v8SetReturnValue(info, info.Holder()); 84 v8SetReturnValue(info, info.Holder());
112 } 85 }
113 86
114 } // namespace WebCore 87 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/HTMLDocument/document-write-variadic-expected.txt ('k') | Source/core/html/HTMLDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698