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

Side by Side Diff: Source/core/html/FormDataList.cpp

Issue 1312333005: Remove FormDataList::Entry. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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/html/FormDataList.h ('k') | no next file » | 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) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 20 matching lines...) Expand all
31 FormDataList::FormDataList(const WTF::TextEncoding& c) 31 FormDataList::FormDataList(const WTF::TextEncoding& c)
32 : m_encoding(c) 32 : m_encoding(c)
33 { 33 {
34 } 34 }
35 35
36 void FormDataList::appendItem(const FormDataList::Item& item) 36 void FormDataList::appendItem(const FormDataList::Item& item)
37 { 37 {
38 m_items.append(item); 38 m_items.append(item);
39 } 39 }
40 40
41 FormDataList::Entry FormDataList::getEntry(const String& key) const
42 {
43 const CString keyData = encodeAndNormalize(key);
44 for (const Item& item : items()) {
45 if (item.key() == keyData)
46 return itemsToEntry(item);
47 }
48 return Entry();
49 }
50
51 HeapVector<FormDataList::Entry> FormDataList::getAll(const String& key) const
52 {
53 HeapVector<FormDataList::Entry> matches;
54
55 const CString keyData = encodeAndNormalize(key);
56 for (const Item& item : items()) {
57 if (item.key() == keyData)
58 matches.append(itemsToEntry(item));
59 }
60
61 return matches;
62 }
63
64 FormDataList::Entry FormDataList::itemsToEntry(const FormDataList::Item& item) c onst
65 {
66 const CString nameData = item.key();
67 const String name = m_encoding.decode(nameData.data(), nameData.length());
68
69 if (!item.blob()) {
70 const CString valueData = item.data();
71 return Entry(name, m_encoding.decode(valueData.data(), valueData.length( )));
72 }
73 return Entry(name, item.file());
74 }
75
76 File* FormDataList::Item::file() const 41 File* FormDataList::Item::file() const
77 { 42 {
78 ASSERT(blob()); 43 ASSERT(blob());
79 // The spec uses the passed filename when inserting entries into the list. 44 // The spec uses the passed filename when inserting entries into the list.
80 // Here, we apply the filename (if present) as an override when extracting 45 // Here, we apply the filename (if present) as an override when extracting
81 // items. 46 // items.
82 // FIXME: Consider applying the name during insertion. 47 // FIXME: Consider applying the name during insertion.
83 48
84 if (blob()->isFile()) { 49 if (blob()->isFile()) {
85 File* file = toFile(blob()); 50 File* file = toFile(blob());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 { 152 {
188 CString encodedString = m_encoding.encode(string, WTF::EntitiesForUnencodabl es); 153 CString encodedString = m_encoding.encode(string, WTF::EntitiesForUnencodabl es);
189 return normalizeLineEndingsToCRLF(encodedString); 154 return normalizeLineEndingsToCRLF(encodedString);
190 } 155 }
191 156
192 DEFINE_TRACE(FormDataList) 157 DEFINE_TRACE(FormDataList)
193 { 158 {
194 visitor->trace(m_items); 159 visitor->trace(m_items);
195 } 160 }
196 161
197
198 DEFINE_TRACE(FormDataList::Entry)
199 {
200 visitor->trace(m_file);
201 }
202
203 DEFINE_TRACE(FormDataList::Item) 162 DEFINE_TRACE(FormDataList::Item)
204 { 163 {
205 visitor->trace(m_blob); 164 visitor->trace(m_blob);
206 } 165 }
207 166
208 } // namespace blink 167 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/FormDataList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698