OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 | 4 |
5 var chrome; | 5 var chrome; |
6 if (!chrome) | 6 if (!chrome) |
7 chrome = {}; | 7 chrome = {}; |
8 if (!chrome.searchBox) { | 8 if (!chrome.searchBox) { |
9 chrome.searchBox = new function() { | 9 chrome.searchBox = new function() { |
10 var safeObjects = {}; | 10 var safeObjects = {}; |
11 chrome.searchBoxOnWindowReady = function() { | 11 chrome.searchBoxOnWindowReady = function() { |
12 // |searchBoxOnWindowReady| is used for initializing window context and | 12 // |searchBoxOnWindowReady| is used for initializing window context and |
13 // should be called only once per context. | 13 // should be called only once per context. |
14 safeObjects.ShadowRoot = window.WebKitShadowRoot; | 14 safeObjects.createShadowRoot = Element.prototype.webkitCreateShadowRoot; |
15 safeObjects.defineProperty = Object.defineProperty; | 15 safeObjects.defineProperty = Object.defineProperty; |
16 delete window.chrome.searchBoxOnWindowReady; | 16 delete window.chrome.searchBoxOnWindowReady; |
17 }; | 17 }; |
18 | 18 |
19 // ========================================================================= | 19 // ========================================================================= |
20 // Constants | 20 // Constants |
21 // ========================================================================= | 21 // ========================================================================= |
22 var MAX_CLIENT_SUGGESTIONS_TO_DEDUPE = 6; | 22 var MAX_CLIENT_SUGGESTIONS_TO_DEDUPE = 6; |
23 var MAX_ALLOWED_DEDUPE_ATTEMPTS = 5; | 23 var MAX_ALLOWED_DEDUPE_ATTEMPTS = 5; |
24 | 24 |
(...skipping 26 matching lines...) Expand all Loading... |
51 native function SetQuerySuggestionFromAutocompleteResult(); | 51 native function SetQuerySuggestionFromAutocompleteResult(); |
52 native function SetQuery(); | 52 native function SetQuery(); |
53 native function SetQueryFromAutocompleteResult(); | 53 native function SetQueryFromAutocompleteResult(); |
54 native function Show(); | 54 native function Show(); |
55 native function StartCapturingKeyStrokes(); | 55 native function StartCapturingKeyStrokes(); |
56 native function StopCapturingKeyStrokes(); | 56 native function StopCapturingKeyStrokes(); |
57 | 57 |
58 // Returns the |restrictedText| wrapped in a ShadowDOM. | 58 // Returns the |restrictedText| wrapped in a ShadowDOM. |
59 function SafeWrap(restrictedText) { | 59 function SafeWrap(restrictedText) { |
60 var node = document.createElement('div'); | 60 var node = document.createElement('div'); |
61 var nodeShadow = new safeObjects.ShadowRoot(node); | 61 var nodeShadow = safeObjects.createShadowRoot.apply(node); |
62 nodeShadow.applyAuthorStyles = true; | 62 nodeShadow.applyAuthorStyles = true; |
63 nodeShadow.innerHTML = | 63 nodeShadow.innerHTML = |
64 '<div style="width:700px!important;' + | 64 '<div style="width:700px!important;' + |
65 ' height:22px!important;' + | 65 ' height:22px!important;' + |
66 ' font-family:\'' + GetFont() + '\',\'Arial\'!important;' + | 66 ' font-family:\'' + GetFont() + '\',\'Arial\'!important;' + |
67 ' overflow:hidden!important;' + | 67 ' overflow:hidden!important;' + |
68 ' text-overflow:ellipsis!important">' + | 68 ' text-overflow:ellipsis!important">' + |
69 ' <nobr>' + restrictedText + '</nobr>' + | 69 ' <nobr>' + restrictedText + '</nobr>' + |
70 '</div>'; | 70 '</div>'; |
71 safeObjects.defineProperty(node, 'webkitShadowRoot', { value: null }); | 71 safeObjects.defineProperty(node, 'webkitShadowRoot', { value: null }); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 this.onchange = null; | 232 this.onchange = null; |
233 this.onsubmit = null; | 233 this.onsubmit = null; |
234 this.oncancel = null; | 234 this.oncancel = null; |
235 this.onresize = null; | 235 this.onresize = null; |
236 this.onautocompleteresults = null; | 236 this.onautocompleteresults = null; |
237 this.onkeypress = null; | 237 this.onkeypress = null; |
238 this.onkeycapturechange = null; | 238 this.onkeycapturechange = null; |
239 this.oncontextchange = null; | 239 this.oncontextchange = null; |
240 }; | 240 }; |
241 } | 241 } |
OLD | NEW |