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

Unified Diff: chrome/browser/resources/file_manager/js/image_editor/standalone_test.js

Issue 7453045: Moved ChromeOS Image Editor into an iframe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years, 5 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
Index: chrome/browser/resources/file_manager/js/image_editor/standalone_test.js
diff --git a/chrome/browser/resources/file_manager/js/image_editor/image_editor_test.js b/chrome/browser/resources/file_manager/js/image_editor/standalone_test.js
similarity index 66%
rename from chrome/browser/resources/file_manager/js/image_editor/image_editor_test.js
rename to chrome/browser/resources/file_manager/js/image_editor/standalone_test.js
index 4d19d9c777569c794d70a63f46ccc025a88cd7c4..889a09b8ac82f607a1db86979b5f7784aaccbe90 100644
--- a/chrome/browser/resources/file_manager/js/image_editor/image_editor_test.js
+++ b/chrome/browser/resources/file_manager/js/image_editor/standalone_test.js
@@ -2,37 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var editor;
+function load(source) {
+ var editorWindow =
+ document.getElementsByClassName('editor-frame')[0].contentWindow;
-function createEditor() {
- editor = new ImageEditor(document.getElementById('frame'), save, close);
- window.addEventListener('resize', resize);
- load(createTestGrid());
-}
+ // ImageEditor makes extensive use of Function.prototype.bind.
+ // Add it if it does not exist (as in Safari 5).
+ if (!editorWindow.Function.prototype.bind) {
+ editorWindow.Function.prototype.bind = bindToObject;
+ }
-function load(source) {
- editor.onModeCancel();
- editor.getBuffer().load(source);
+ editorWindow.ImageUtil.trace.bindToDOM(
+ document.getElementsByClassName('debug-output')[0]);
+
+ editorWindow.ImageEditor.open(save, close, source);
}
-function save(canvas) {
- var blob = ImageEncoder.getBlob(canvas, 'image/jpeg');
- console.log('Blob size: ' + blob.size + ' bytes');
+function save(blob) {
+ console.log('Saving ' + blob.size + ' bytes');
}
function close() {
document.body.innerHTML = 'Editor closed, hit reload';
}
-function resize() {
- var wrapper = document.getElementsByClassName('canvas-wrapper')[0];
- editor.getBuffer().resizeScreen(
- wrapper.clientWidth, wrapper.clientHeight, true);
-}
-
-
function getUrlField() {
- return document.getElementById('imageUrl');
+ return document.getElementsByClassName('image-url')[0];
}
function createTestGrid() {
@@ -59,9 +54,10 @@ function fillGradient(imageData) {
var maxX = width - 1;
var maxY = height - 1;
var maxDist = maxX + maxY;
- var values = ImageUtil.precomputeByteFunction( function(dist) {
- return Math.round(dist/maxDist*255);
- }, maxDist);
+ var values = [];
+ for (var i = 0; i <= maxDist; i++) {
+ values.push(Math.max(0, Math.min(0xFF, Math.round(i/maxDist*255))));
+ }
var index = 0;
for (var y = 0; y != height; y++)
@@ -88,9 +84,7 @@ function drawTestGrid(context) {
}
}
-// It is nice to be able to test on Safari.
-// Safari 5 does not have Function.bind, so we are adding that just in case.
-Function.prototype.bind = function(thisObject) {
+function bindToObject(thisObject) {
var func = this;
var args = Array.prototype.slice.call(arguments, 1);
function bound() {

Powered by Google App Engine
This is Rietveld 408576698