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

Side by Side Diff: Source/modules/encoding/TextDecoder.cpp

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry 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
« no previous file with comments | « Source/modules/encoding/TextDecoder.h ('k') | Source/modules/encoding/TextEncoder.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 20 matching lines...) Expand all
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "modules/encoding/TextDecoder.h" 33 #include "modules/encoding/TextDecoder.h"
34 34
35 #include "bindings/v8/ExceptionState.h" 35 #include "bindings/v8/ExceptionState.h"
36 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
37 #include "wtf/text/TextEncodingRegistry.h" 37 #include "wtf/text/TextEncodingRegistry.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 PassRefPtr<TextDecoder> TextDecoder::create(const String& label, const Dictionar y& options, ExceptionState& es) 41 PassRefPtr<TextDecoder> TextDecoder::create(const String& label, const Dictionar y& options, ExceptionState& exceptionState)
42 { 42 {
43 const String& encodingLabel = label.isNull() ? String("utf-8") : label; 43 const String& encodingLabel = label.isNull() ? String("utf-8") : label;
44 44
45 WTF::TextEncoding encoding(encodingLabel); 45 WTF::TextEncoding encoding(encodingLabel);
46 if (!encoding.isValid()) { 46 if (!encoding.isValid()) {
47 es.throwUninformativeAndGenericTypeError(); 47 exceptionState.throwUninformativeAndGenericTypeError();
48 return 0; 48 return 0;
49 } 49 }
50 50
51 bool fatal = false; 51 bool fatal = false;
52 options.get("fatal", fatal); 52 options.get("fatal", fatal);
53 53
54 return adoptRef(new TextDecoder(encoding.name(), fatal)); 54 return adoptRef(new TextDecoder(encoding.name(), fatal));
55 } 55 }
56 56
57 57
(...skipping 12 matching lines...) Expand all
70 String TextDecoder::encoding() const 70 String TextDecoder::encoding() const
71 { 71 {
72 String name = String(m_encoding.name()).lower(); 72 String name = String(m_encoding.name()).lower();
73 // Where possible, encoding aliases should be handled by changes to Chromium 's ICU or Blink's WTF. 73 // Where possible, encoding aliases should be handled by changes to Chromium 's ICU or Blink's WTF.
74 // The same codec is used, but WTF maintains a different name/identity for t hese. 74 // The same codec is used, but WTF maintains a different name/identity for t hese.
75 if (name == "iso-8859-1" || name == "us-ascii") 75 if (name == "iso-8859-1" || name == "us-ascii")
76 return "windows-1252"; 76 return "windows-1252";
77 return name; 77 return name;
78 } 78 }
79 79
80 String TextDecoder::decode(ArrayBufferView* input, const Dictionary& options, Ex ceptionState& es) 80 String TextDecoder::decode(ArrayBufferView* input, const Dictionary& options, Ex ceptionState& exceptionState)
81 { 81 {
82 bool stream = false; 82 bool stream = false;
83 options.get("stream", stream); 83 options.get("stream", stream);
84 84
85 const char* start = input ? static_cast<const char*>(input->baseAddress()) : 0; 85 const char* start = input ? static_cast<const char*>(input->baseAddress()) : 0;
86 size_t length = input ? input->byteLength() : 0; 86 size_t length = input ? input->byteLength() : 0;
87 87
88 bool flush = !stream; 88 bool flush = !stream;
89 89
90 // FIXME: Not all TextCodec implementations handle |flush| - notably TextCod ecUTF16 90 // FIXME: Not all TextCodec implementations handle |flush| - notably TextCod ecUTF16
91 // ignores it and never flushes! 91 // ignores it and never flushes!
92 92
93 bool sawError = false; 93 bool sawError = false;
94 String s = m_codec->decode(start, length, flush, m_fatal, sawError); 94 String s = m_codec->decode(start, length, flush, m_fatal, sawError);
95 95
96 if (m_fatal && sawError) { 96 if (m_fatal && sawError) {
97 es.throwDOMException(EncodingError, "The encoded data was not valid."); 97 exceptionState.throwDOMException(EncodingError, "The encoded data was no t valid.");
98 return String(); 98 return String();
99 } 99 }
100 100
101 if (!m_bomSeen && !s.isEmpty()) { 101 if (!m_bomSeen && !s.isEmpty()) {
102 m_bomSeen = true; 102 m_bomSeen = true;
103 String name(m_encoding.name()); 103 String name(m_encoding.name());
104 if ((name == "UTF-8" || name == "UTF-16LE" || name == "UTF-16BE") && s[0 ] == 0xFEFF) 104 if ((name == "UTF-8" || name == "UTF-16LE" || name == "UTF-16BE") && s[0 ] == 0xFEFF)
105 s.remove(0); 105 s.remove(0);
106 } 106 }
107 107
108 if (flush) 108 if (flush)
109 m_bomSeen = false; 109 m_bomSeen = false;
110 110
111 return s; 111 return s;
112 } 112 }
113 113
114 } // namespace WebCore 114 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/encoding/TextDecoder.h ('k') | Source/modules/encoding/TextEncoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698