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

Unified Diff: Source/core/frame/WindowBase64.js

Issue 138223002: WIP: Implement binding layer for Blink-in-JavaScript 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/WindowBase64.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/WindowBase64.js
diff --git a/Source/core/svg/SVGLengthListTearOff.h b/Source/core/frame/WindowBase64.js
similarity index 56%
copy from Source/core/svg/SVGLengthListTearOff.h
copy to Source/core/frame/WindowBase64.js
index b28dc8c94e6171147890fb606b6d1c0e53bed86f..649dc26feb5aea12a7afb259c2ba2310051c270c 100644
--- a/Source/core/svg/SVGLengthListTearOff.h
+++ b/Source/core/frame/WindowBase64.js
@@ -28,31 +28,51 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SVGLengthListTearOff_h
-#define SVGLengthListTearOff_h
+"use strict";
-#include "core/svg/SVGLengthList.h"
-#include "core/svg/properties/NewSVGListPropertyTearOffHelper.h"
+installClass("WindowBase64", function() {
+ // FIXME: This base64 encoding/decoding implementation is just copied from http://tociyuki.flop.jp/archive/base64.js.
+ // Fix the implementation per the spec.
+ var base64list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
-namespace WebCore {
-
-class SVGLengthListTearOff FINAL :
- public NewSVGListPropertyTearOffHelper<SVGLengthListTearOff, SVGLengthList>,
- public ScriptWrappable {
-public:
- static PassRefPtr<SVGLengthListTearOff> create(PassRefPtr<SVGLengthList> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName = nullQName())
- {
- return adoptRef(new SVGLengthListTearOff(target, contextElement, propertyIsAnimVal, attributeName));
+ function atob(str) {
+ console.log(this === window);
+ var t = '', p = -6, a = 0, i = 0, v = 0, c;
+ while (i < str.length || p > -6) {
+ if (p < 0) {
+ if (i < str.length) {
+ c = str.charCodeAt(i++);
+ v += 8;
+ } else {
+ c = 0;
+ }
+ a = ((a & 255) << 8) | (c & 255);
+ p += 8;
+ }
+ t += base64list.charAt(v > 0 ? (a >> p) & 63 : 64);
+ p -= 6;
+ v -= 6;
}
+ return t;
+ }
-private:
- SVGLengthListTearOff(PassRefPtr<SVGLengthList> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName = nullQName())
- : NewSVGListPropertyTearOffHelper<SVGLengthListTearOff, SVGLengthList>(target, contextElement, propertyIsAnimVal, attributeName)
- {
- ScriptWrappable::init(this);
+ function btoa(str) {
+ console.log(this === window);
+ var t = '', p = -8, a = 0, c, d;
+ for(var i = 0; i < str.length; i++) {
+ if ((c = base64list.indexOf(str.charAt(i))) < 0)
+ continue;
+ a = (a << 6) | (c & 63);
+ if ((p += 6) >= 0) {
+ d = (a >> p) & 255;
+ if (c != 64)
+ t += String.fromCharCode(d);
+ a &= 63;
+ p -= 8;
+ }
}
-};
-
-} // namespace WebCore
+ return t;
+ }
-#endif // SVGLengthListTearOff_h_
+ return { atob: atob, btoa: btoa };
+});
« no previous file with comments | « Source/core/frame/WindowBase64.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698