| OLD | NEW |
| 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. | 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. |
| 2 // limitations under the License. | 2 // limitations under the License. |
| 3 // See the License for the specific language governing permissions and | 3 // See the License for the specific language governing permissions and |
| 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 5 // distributed under the License is distributed on an "AS-IS" BASIS, | 5 // distributed under the License is distributed on an "AS-IS" BASIS, |
| 6 // Unless required by applicable law or agreed to in writing, software | 6 // Unless required by applicable law or agreed to in writing, software |
| 7 // | 7 // |
| 8 // http://www.apache.org/licenses/LICENSE-2.0 | 8 // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 // | 9 // |
| 10 // You may obtain a copy of the License at | 10 // You may obtain a copy of the License at |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 * @constructor | 40 * @constructor |
| 41 * @param {!Document=} opt_topDocument The top document for MOUSEUP event. | 41 * @param {!Document=} opt_topDocument The top document for MOUSEUP event. |
| 42 * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper. | 42 * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper. |
| 43 * @param {goog.events.EventTarget=} opt_eventTarget The event target. | 43 * @param {goog.events.EventTarget=} opt_eventTarget The event target. |
| 44 * @param {number=} opt_inkWidth The ink width. | 44 * @param {number=} opt_inkWidth The ink width. |
| 45 * @param {string=} opt_inkColor The ink color. | 45 * @param {string=} opt_inkColor The ink color. |
| 46 * @extends {goog.ui.Container} | 46 * @extends {goog.ui.Container} |
| 47 */ | 47 */ |
| 48 i18n.input.hwt.Canvas = function(opt_topDocument, opt_domHelper, | 48 i18n.input.hwt.Canvas = function(opt_topDocument, opt_domHelper, |
| 49 opt_eventTarget, opt_inkWidth, opt_inkColor) { | 49 opt_eventTarget, opt_inkWidth, opt_inkColor) { |
| 50 goog.base(this, undefined, undefined, opt_domHelper); | 50 i18n.input.hwt.Canvas.base(this, 'constructor', undefined, undefined, |
| 51 opt_domHelper); |
| 51 this.setParentEventTarget(opt_eventTarget || null); | 52 this.setParentEventTarget(opt_eventTarget || null); |
| 52 | 53 |
| 53 /** | 54 /** |
| 54 * The stroke handler. | 55 * The stroke handler. |
| 55 * | 56 * |
| 56 * @type {!i18n.input.hwt.StrokeHandler} | 57 * @type {!i18n.input.hwt.StrokeHandler} |
| 57 * @private | 58 * @private |
| 58 */ | 59 */ |
| 59 this.strokeHandler_; | 60 this.strokeHandler_; |
| 60 | 61 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 159 |
| 159 | 160 |
| 160 /** | 161 /** |
| 161 * @desc The hint on the canvas to indicate users they can draw here. | 162 * @desc The hint on the canvas to indicate users they can draw here. |
| 162 */ | 163 */ |
| 163 i18n.input.hwt.Canvas.MSG_HANDWRITING_HINT = goog.getMsg('Draw a symbol here'); | 164 i18n.input.hwt.Canvas.MSG_HANDWRITING_HINT = goog.getMsg('Draw a symbol here'); |
| 164 | 165 |
| 165 | 166 |
| 166 /** @override */ | 167 /** @override */ |
| 167 i18n.input.hwt.Canvas.prototype.createDom = function() { | 168 i18n.input.hwt.Canvas.prototype.createDom = function() { |
| 168 goog.base(this, 'createDom'); | 169 i18n.input.hwt.Canvas.base(this, 'createDom'); |
| 169 | 170 |
| 170 var dom = this.getDomHelper(); | 171 var dom = this.getDomHelper(); |
| 171 this.writingCanvas_ = dom.createDom(goog.dom.TagName.CANVAS, | 172 this.writingCanvas_ = dom.createDom(goog.dom.TagName.CANVAS, |
| 172 i18n.input.hwt.css.CANVAS); | 173 i18n.input.hwt.css.CANVAS); |
| 173 this.writingCanvas_.width = 425; | 174 this.writingCanvas_.width = 425; |
| 174 this.writingCanvas_.height = 194; | 175 this.writingCanvas_.height = 194; |
| 175 dom.appendChild(this.getElement(), this.writingCanvas_); | 176 dom.appendChild(this.getElement(), this.writingCanvas_); |
| 176 this.writingContext_ = this.writingCanvas_.getContext('2d'); | 177 this.writingContext_ = this.writingCanvas_.getContext('2d'); |
| 177 }; | 178 }; |
| 178 | 179 |
| 179 | 180 |
| 180 /** @override */ | 181 /** @override */ |
| 181 i18n.input.hwt.Canvas.prototype.enterDocument = function() { | 182 i18n.input.hwt.Canvas.prototype.enterDocument = function() { |
| 182 goog.base(this, 'enterDocument'); | 183 i18n.input.hwt.Canvas.base(this, 'enterDocument'); |
| 183 | 184 |
| 184 this.setFocusable(false); | 185 this.setFocusable(false); |
| 185 this.setFocusableChildrenAllowed(false); | 186 this.setFocusableChildrenAllowed(false); |
| 186 // Sets up stroke handler. | 187 // Sets up stroke handler. |
| 187 this.strokeHandler_ = new i18n.input.hwt.StrokeHandler(this.writingCanvas_, | 188 this.strokeHandler_ = new i18n.input.hwt.StrokeHandler(this.writingCanvas_, |
| 188 this.topDocument_); | 189 this.topDocument_); |
| 189 this.handler_. | 190 this.handler_. |
| 190 listen(this.strokeHandler_, | 191 listen(this.strokeHandler_, |
| 191 i18n.input.hwt.StrokeHandler.EventType.STROKE_START, | 192 i18n.input.hwt.StrokeHandler.EventType.STROKE_START, |
| 192 this.onStrokeStart_). | 193 this.onStrokeStart_). |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 0, 0, this.writingCanvas_.width, this.writingCanvas_.height); | 333 0, 0, this.writingCanvas_.width, this.writingCanvas_.height); |
| 333 this.strokeList = []; | 334 this.strokeList = []; |
| 334 this.stroke_ = []; | 335 this.stroke_ = []; |
| 335 this.strokeHandler_.reset(); | 336 this.strokeHandler_.reset(); |
| 336 }; | 337 }; |
| 337 | 338 |
| 338 | 339 |
| 339 /** @override */ | 340 /** @override */ |
| 340 i18n.input.hwt.Canvas.prototype.disposeInternal = function() { | 341 i18n.input.hwt.Canvas.prototype.disposeInternal = function() { |
| 341 goog.dispose(this.handler_); | 342 goog.dispose(this.handler_); |
| 342 goog.base(this, 'disposeInternal'); | 343 i18n.input.hwt.Canvas.base(this, 'disposeInternal'); |
| 343 }; | 344 }; |
| 344 | 345 |
| 345 | |
| 346 /** | 346 /** |
| 347 * Gets the width of the canvas. | 347 * Gets the width of the canvas. |
| 348 * | 348 * |
| 349 * @return {number} The width of the canvas. | 349 * @return {number} The width of the canvas. |
| 350 */ | 350 */ |
| 351 i18n.input.hwt.Canvas.prototype.getWidth = function() { | 351 i18n.input.hwt.Canvas.prototype.getWidth = function() { |
| 352 return this.writingCanvas_.width; | 352 return this.writingCanvas_.width; |
| 353 }; | 353 }; |
| 354 | 354 |
| 355 | 355 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 /** | 416 /** |
| 417 * Exports message to screen reader. | 417 * Exports message to screen reader. |
| 418 * | 418 * |
| 419 * @param {!goog.events.BrowserEvent} e . | 419 * @param {!goog.events.BrowserEvent} e . |
| 420 * @private | 420 * @private |
| 421 */ | 421 */ |
| 422 i18n.input.hwt.Canvas.prototype.onMouseOver_ = function(e) { | 422 i18n.input.hwt.Canvas.prototype.onMouseOver_ = function(e) { |
| 423 this.announcer_.say(i18n.input.hwt.Canvas.MSG_INPUTTOOLS_HWT_PANEL, | 423 this.announcer_.say(i18n.input.hwt.Canvas.MSG_INPUTTOOLS_HWT_PANEL, |
| 424 goog.a11y.aria.LivePriority.ASSERTIVE); | 424 goog.a11y.aria.LivePriority.ASSERTIVE); |
| 425 }; | 425 }; |
| OLD | NEW |