| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @constructor | 30 * @constructor |
| 31 * @extends {WebInspector.View} | 31 * @extends {WebInspector.SimpleView} |
| 32 * @param {string} mimeType | 32 * @param {string} mimeType |
| 33 * @param {!WebInspector.ContentProvider} contentProvider | 33 * @param {!WebInspector.ContentProvider} contentProvider |
| 34 */ | 34 */ |
| 35 WebInspector.FontView = function(mimeType, contentProvider) | 35 WebInspector.FontView = function(mimeType, contentProvider) |
| 36 { | 36 { |
| 37 WebInspector.View.call(this, WebInspector.UIString("Font")); | 37 WebInspector.SimpleView.call(this, WebInspector.UIString("Font")); |
| 38 this.registerRequiredCSS("source_frame/fontView.css"); | 38 this.registerRequiredCSS("source_frame/fontView.css"); |
| 39 this.element.classList.add("font-view"); | 39 this.element.classList.add("font-view"); |
| 40 this._url = contentProvider.contentURL(); | 40 this._url = contentProvider.contentURL(); |
| 41 this._mimeType = mimeType; | 41 this._mimeType = mimeType; |
| 42 this._contentProvider = contentProvider; | 42 this._contentProvider = contentProvider; |
| 43 this._mimeTypeLabel = new WebInspector.ToolbarText(mimeType); | 43 this._mimeTypeLabel = new WebInspector.ToolbarText(mimeType); |
| 44 } | 44 } |
| 45 | 45 |
| 46 WebInspector.FontView._fontPreviewLines = [ "ABCDEFGHIJKLM", "NOPQRSTUVWXYZ", "a
bcdefghijklm", "nopqrstuvwxyz", "1234567890" ]; | 46 WebInspector.FontView._fontPreviewLines = [ "ABCDEFGHIJKLM", "NOPQRSTUVWXYZ", "a
bcdefghijklm", "nopqrstuvwxyz", "1234567890" ]; |
| 47 | 47 |
| 48 WebInspector.FontView._fontId = 0; | 48 WebInspector.FontView._fontId = 0; |
| 49 | 49 |
| 50 WebInspector.FontView._measureFontSize = 50; | 50 WebInspector.FontView._measureFontSize = 50; |
| 51 | 51 |
| 52 WebInspector.FontView.prototype = { | 52 WebInspector.FontView.prototype = { |
| 53 /** | 53 /** |
| 54 * @override | 54 * @override |
| 55 * @return {!Array<!WebInspector.ToolbarItem>} | 55 * @return {!Array<!WebInspector.ToolbarItem>} |
| 56 */ | 56 */ |
| 57 toolbarItems: function() | 57 syncToolbarItems: function() |
| 58 { | 58 { |
| 59 return [this._mimeTypeLabel]; | 59 return [this._mimeTypeLabel]; |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @param {string} uniqueFontName | 63 * @param {string} uniqueFontName |
| 64 * @param {?string} content | 64 * @param {?string} content |
| 65 */ | 65 */ |
| 66 _onFontContentLoaded: function(uniqueFontName, content) | 66 _onFontContentLoaded: function(uniqueFontName, content) |
| 67 { | 67 { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 | 152 |
| 153 var widthRatio = containerWidth / width; | 153 var widthRatio = containerWidth / width; |
| 154 var heightRatio = containerHeight / height; | 154 var heightRatio = containerHeight / height; |
| 155 var finalFontSize = Math.floor(WebInspector.FontView._measureFontSize *
Math.min(widthRatio, heightRatio)) - 2; | 155 var finalFontSize = Math.floor(WebInspector.FontView._measureFontSize *
Math.min(widthRatio, heightRatio)) - 2; |
| 156 | 156 |
| 157 this.fontPreviewElement.style.setProperty("font-size", finalFontSize + "
px", null); | 157 this.fontPreviewElement.style.setProperty("font-size", finalFontSize + "
px", null); |
| 158 }, | 158 }, |
| 159 | 159 |
| 160 __proto__: WebInspector.View.prototype | 160 __proto__: WebInspector.SimpleView.prototype |
| 161 } | 161 } |
| OLD | NEW |