OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 function PromiseResolver() { | 4 function PromiseResolver() { |
5 this.resolve_; | 5 this.resolve_; |
6 this.reject_; | 6 this.reject_; |
7 this.promise_ = new Promise(function(resolve, reject) { | 7 this.promise_ = new Promise(function(resolve, reject) { |
8 this.resolve_ = resolve; | 8 this.resolve_ = resolve; |
9 this.reject_ = reject; | 9 this.reject_ = reject; |
10 }.bind(this)); | 10 }.bind(this)); |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 validKey = String(keyCode - 48); | 2006 validKey = String(keyCode - 48); |
2007 } else if (keyCode >= 96 && keyCode <= 105) { | 2007 } else if (keyCode >= 96 && keyCode <= 105) { |
2008 validKey = String(keyCode - 96); | 2008 validKey = String(keyCode - 96); |
2009 } else { | 2009 } else { |
2010 validKey = KEY_CODE[keyCode]; | 2010 validKey = KEY_CODE[keyCode]; |
2011 } | 2011 } |
2012 } | 2012 } |
2013 return validKey; | 2013 return validKey; |
2014 } | 2014 } |
2015 function normalizedKeyForEvent(keyEvent, noSpecialChars) { | 2015 function normalizedKeyForEvent(keyEvent, noSpecialChars) { |
2016 return transformKey(keyEvent.key, noSpecialChars) || transformKeyIdentifier(
keyEvent.keyIdentifier) || transformKeyCode(keyEvent.keyCode) || transformKey(ke
yEvent.detail ? keyEvent.detail.key : keyEvent.detail, noSpecialChars) || ''; | 2016 if (keyEvent.key) { |
| 2017 return transformKey(keyEvent.key, noSpecialChars); |
| 2018 } |
| 2019 if (keyEvent.detail && keyEvent.detail.key) { |
| 2020 return transformKey(keyEvent.detail.key, noSpecialChars); |
| 2021 } |
| 2022 return transformKeyIdentifier(keyEvent.keyIdentifier) || transformKeyCode(ke
yEvent.keyCode) || ''; |
2017 } | 2023 } |
2018 function keyComboMatchesEvent(keyCombo, event) { | 2024 function keyComboMatchesEvent(keyCombo, event) { |
2019 var keyEvent = normalizedKeyForEvent(event, keyCombo.hasModifiers); | 2025 var keyEvent = normalizedKeyForEvent(event, keyCombo.hasModifiers); |
2020 return keyEvent === keyCombo.key && (!keyCombo.hasModifiers || !!event.shift
Key === !!keyCombo.shiftKey && !!event.ctrlKey === !!keyCombo.ctrlKey && !!event
.altKey === !!keyCombo.altKey && !!event.metaKey === !!keyCombo.metaKey); | 2026 return keyEvent === keyCombo.key && (!keyCombo.hasModifiers || !!event.shift
Key === !!keyCombo.shiftKey && !!event.ctrlKey === !!keyCombo.ctrlKey && !!event
.altKey === !!keyCombo.altKey && !!event.metaKey === !!keyCombo.metaKey); |
2021 } | 2027 } |
2022 function parseKeyComboString(keyComboString) { | 2028 function parseKeyComboString(keyComboString) { |
2023 if (keyComboString.length === 1) { | 2029 if (keyComboString.length === 1) { |
2024 return { | 2030 return { |
2025 combo: keyComboString, | 2031 combo: keyComboString, |
2026 key: keyComboString, | 2032 key: keyComboString, |
(...skipping 3353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5380 } | 5386 } |
5381 }); | 5387 }); |
5382 | 5388 |
5383 // Copyright 2016 The Chromium Authors. All rights reserved. | 5389 // Copyright 2016 The Chromium Authors. All rights reserved. |
5384 // Use of this source code is governed by a BSD-style license that can be | 5390 // Use of this source code is governed by a BSD-style license that can be |
5385 // found in the LICENSE file. | 5391 // found in the LICENSE file. |
5386 Polymer({ | 5392 Polymer({ |
5387 is: 'cr-lazy-render', | 5393 is: 'cr-lazy-render', |
5388 "extends": 'template', | 5394 "extends": 'template', |
5389 behaviors: [ Polymer.Templatizer ], | 5395 behaviors: [ Polymer.Templatizer ], |
5390 _renderPromise: null, | 5396 renderPromise_: null, |
5391 _child: null, | 5397 child_: null, |
5392 get: function() { | 5398 get: function() { |
5393 if (!this._renderPromise) { | 5399 if (!this.renderPromise_) { |
5394 this._renderPromise = new Promise(function(resolve) { | 5400 this.renderPromise_ = new Promise(function(resolve) { |
5395 this._debounceTemplate(function() { | 5401 this._debounceTemplate(function() { |
5396 this._render(); | 5402 this.render_(); |
5397 this._renderPromise = null; | 5403 this.renderPromise_ = null; |
5398 resolve(this.getIfExists()); | 5404 resolve(this.getIfExists()); |
5399 }.bind(this)); | 5405 }.bind(this)); |
5400 }.bind(this)); | 5406 }.bind(this)); |
5401 } | 5407 } |
5402 return this._renderPromise; | 5408 return this.renderPromise_; |
5403 }, | 5409 }, |
5404 getIfExists: function() { | 5410 getIfExists: function() { |
5405 return this._child; | 5411 return this.child_; |
5406 }, | 5412 }, |
5407 _render: function() { | 5413 render_: function() { |
5408 if (!this.ctor) this.templatize(this); | 5414 if (!this.ctor) this.templatize(this); |
5409 var parentNode = this.parentNode; | 5415 var parentNode = this.parentNode; |
5410 if (parentNode && !this._child) { | 5416 if (parentNode && !this.child_) { |
5411 var instance = this.stamp({}); | 5417 var instance = this.stamp({}); |
5412 this._child = instance.root.querySelector('*'); | 5418 this.child_ = instance.root.firstElementChild; |
5413 parentNode.insertBefore(instance.root, this); | 5419 parentNode.insertBefore(instance.root, this); |
5414 } | 5420 } |
5415 }, | 5421 }, |
5416 _forwardParentProp: function(prop, value) { | 5422 _forwardParentProp: function(prop, value) { |
5417 if (this._child) this._child._templateInstance[prop] = value; | 5423 if (this.child_) this.child_._templateInstance[prop] = value; |
5418 }, | 5424 }, |
5419 _forwardParentPath: function(path, value) { | 5425 _forwardParentPath: function(path, value) { |
5420 if (this._child) this._child._templateInstance.notifyPath(path, value, true)
; | 5426 if (this.child_) this.child_._templateInstance.notifyPath(path, value, true)
; |
5421 } | 5427 } |
5422 }); | 5428 }); |
5423 | 5429 |
5424 (function() { | 5430 (function() { |
5425 'use strict'; | 5431 'use strict'; |
5426 Polymer.IronA11yAnnouncer = Polymer({ | 5432 Polymer.IronA11yAnnouncer = Polymer({ |
5427 is: 'iron-a11y-announcer', | 5433 is: 'iron-a11y-announcer', |
5428 properties: { | 5434 properties: { |
5429 mode: { | 5435 mode: { |
5430 type: String, | 5436 type: String, |
(...skipping 3254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8685 | 8691 |
8686 case HistoryRange.MONTH: | 8692 case HistoryRange.MONTH: |
8687 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; | 8693 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; |
8688 break; | 8694 break; |
8689 } | 8695 } |
8690 break; | 8696 break; |
8691 } | 8697 } |
8692 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); | 8698 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); |
8693 } | 8699 } |
8694 }); | 8700 }); |
OLD | NEW |