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

Side by Side Diff: Source/core/page/PagePopupClient.cpp

Issue 120513004: Don't expose DocumentWriter to embedding layer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/core/page/PagePopupClient.h ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/page/PagePopupClient.h" 32 #include "core/page/PagePopupClient.h"
33 33
34 #include "wtf/text/StringBuilder.h" 34 #include "wtf/text/StringBuilder.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 #define addLiteral(literal, writer) writer.addData(literal, sizeof(literal) - 1) 38 #define addLiteral(literal, data) data->append(literal, sizeof(literal) - 1)
39 39
40 void PagePopupClient::addJavaScriptString(const String& str, DocumentWriter& wri ter) 40 void PagePopupClient::addJavaScriptString(const String& str, SharedBuffer* data)
41 { 41 {
42 addLiteral("\"", writer); 42 addLiteral("\"", data);
43 StringBuilder builder; 43 StringBuilder builder;
44 builder.reserveCapacity(str.length()); 44 builder.reserveCapacity(str.length());
45 for (unsigned i = 0; i < str.length(); ++i) { 45 for (unsigned i = 0; i < str.length(); ++i) {
46 if (str[i] == '\\' || str[i] == '"') 46 if (str[i] == '\\' || str[i] == '"')
47 builder.append('\\'); 47 builder.append('\\');
48 builder.append(str[i]); 48 builder.append(str[i]);
49 } 49 }
50 addString(builder.toString(), writer); 50 addString(builder.toString(), data);
51 addLiteral("\"", writer); 51 addLiteral("\"", data);
52 } 52 }
53 53
54 void PagePopupClient::addProperty(const char* name, const String& value, Documen tWriter& writer) 54 void PagePopupClient::addProperty(const char* name, const String& value, SharedB uffer* data)
55 { 55 {
56 writer.addData(name, strlen(name)); 56 data->append(name, strlen(name));
57 addLiteral(": ", writer); 57 addLiteral(": ", data);
58 addJavaScriptString(value, writer); 58 addJavaScriptString(value, data);
59 addLiteral(",\n", writer); 59 addLiteral(",\n", data);
60 } 60 }
61 61
62 void PagePopupClient::addProperty(const char* name, int value, DocumentWriter& w riter) 62 void PagePopupClient::addProperty(const char* name, int value, SharedBuffer* dat a)
63 { 63 {
64 writer.addData(name, strlen(name)); 64 data->append(name, strlen(name));
65 addLiteral(": ", writer); 65 addLiteral(": ", data);
66 addString(String::number(value), writer); 66 addString(String::number(value), data);
67 addLiteral(",\n", writer); 67 addLiteral(",\n", data);
68 } 68 }
69 69
70 void PagePopupClient::addProperty(const char* name, unsigned value, DocumentWrit er& writer) 70 void PagePopupClient::addProperty(const char* name, unsigned value, SharedBuffer * data)
71 { 71 {
72 writer.addData(name, strlen(name)); 72 data->append(name, strlen(name));
73 addLiteral(": ", writer); 73 addLiteral(": ", data);
74 addString(String::number(value), writer); 74 addString(String::number(value), data);
75 addLiteral(",\n", writer); 75 addLiteral(",\n", data);
76 } 76 }
77 77
78 void PagePopupClient::addProperty(const char* name, bool value, DocumentWriter& writer) 78 void PagePopupClient::addProperty(const char* name, bool value, SharedBuffer* da ta)
79 { 79 {
80 writer.addData(name, strlen(name)); 80 data->append(name, strlen(name));
81 addLiteral(": ", writer); 81 addLiteral(": ", data);
82 if (value) 82 if (value)
83 addLiteral("true", writer); 83 addLiteral("true", data);
84 else 84 else
85 addLiteral("false", writer); 85 addLiteral("false", data);
86 addLiteral(",\n", writer); 86 addLiteral(",\n", data);
87 } 87 }
88 88
89 void PagePopupClient::addProperty(const char* name, const Vector<String>& values , DocumentWriter& writer) 89 void PagePopupClient::addProperty(const char* name, const Vector<String>& values , SharedBuffer* data)
90 { 90 {
91 writer.addData(name, strlen(name)); 91 data->append(name, strlen(name));
92 addLiteral(": [", writer); 92 addLiteral(": [", data);
93 for (unsigned i = 0; i < values.size(); ++i) { 93 for (unsigned i = 0; i < values.size(); ++i) {
94 if (i) 94 if (i)
95 addLiteral(",", writer); 95 addLiteral(",", data);
96 addJavaScriptString(values[i], writer); 96 addJavaScriptString(values[i], data);
97 } 97 }
98 addLiteral("],\n", writer); 98 addLiteral("],\n", data);
99 } 99 }
100 100
101 void PagePopupClient::addProperty(const char* name, const IntRect& rect, Documen tWriter& writer) 101 void PagePopupClient::addProperty(const char* name, const IntRect& rect, SharedB uffer* data)
102 { 102 {
103 writer.addData(name, strlen(name)); 103 data->append(name, strlen(name));
104 addLiteral(": {", writer); 104 addLiteral(": {", data);
105 addProperty("x", rect.x(), writer); 105 addProperty("x", rect.x(), data);
106 addProperty("y", rect.y(), writer); 106 addProperty("y", rect.y(), data);
107 addProperty("width", rect.width(), writer); 107 addProperty("width", rect.width(), data);
108 addProperty("height", rect.height(), writer); 108 addProperty("height", rect.height(), data);
109 addLiteral("},\n", writer); 109 addLiteral("},\n", data);
110 } 110 }
111 111
112 } // namespace WebCore 112 } // namespace WebCore
113 113
OLDNEW
« no previous file with comments | « Source/core/page/PagePopupClient.h ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698