OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
6 * @fileoverview Defines the initial speech call. | 6 * @fileoverview Defines the initial speech call. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('cvox.InitialSpeech'); | 9 goog.provide('cvox.InitialSpeech'); |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 var title = document.title; | 41 var title = document.title; |
42 | 42 |
43 // Allow the web author to disable reading the page title on load | 43 // Allow the web author to disable reading the page title on load |
44 // by adding aria-hidden=true to the <title> element. | 44 // by adding aria-hidden=true to the <title> element. |
45 var titleElement = document.querySelector('head > title'); | 45 var titleElement = document.querySelector('head > title'); |
46 if (titleElement && titleElement.getAttribute('aria-hidden') == 'true') { | 46 if (titleElement && titleElement.getAttribute('aria-hidden') == 'true') { |
47 title = null; | 47 title = null; |
48 } | 48 } |
49 | 49 |
50 if (title && !disableSpeak) { | 50 if (title && !disableSpeak) { |
51 cvox.ChromeVox.tts.speak( | 51 cvox.ChromeVox.tts.speak(title, cvox.QueueMode.FLUSH); |
52 title, cvox.QueueMode.FLUSH); | |
53 } | 52 } |
54 cvox.BrailleOverlayWidget.getInstance().init(); | 53 cvox.BrailleOverlayWidget.getInstance().init(); |
55 } | 54 } |
56 | 55 |
57 // Initialize live regions and speak alerts. | 56 // Initialize live regions and speak alerts. |
58 cvox.LiveRegions.init( | 57 cvox.LiveRegions.init(new Date(), cvox.QueueMode.QUEUE, disableSpeak); |
59 new Date(), cvox.QueueMode.QUEUE, disableSpeak); | |
60 | 58 |
61 // If our activeElement is on body, try to sync to the first element. This | 59 // If our activeElement is on body, try to sync to the first element. This |
62 // actually happens inside of NavigationManager.reset, which doesn't get | 60 // actually happens inside of NavigationManager.reset, which doesn't get |
63 // called until AbstractHost.onPageLoad, but we need to speak and braille the | 61 // called until AbstractHost.onPageLoad, but we need to speak and braille the |
64 // initial node here. | 62 // initial node here. |
65 if (cvox.ChromeVox.documentHasFocus() && | 63 if (cvox.ChromeVox.documentHasFocus() && |
66 document.activeElement == document.body) { | 64 document.activeElement == document.body) { |
67 cvox.ChromeVox.navigationManager.syncToBeginning(); | 65 cvox.ChromeVox.navigationManager.syncToBeginning(); |
68 } | 66 } |
69 | 67 |
70 // If we had a previous position recorded, update to it. | 68 // If we had a previous position recorded, update to it. |
71 if (cvox.ChromeVox.position[document.location.href]) { | 69 if (cvox.ChromeVox.position[document.location.href]) { |
72 var pos = cvox.ChromeVox.position[document.location.href]; | 70 var pos = cvox.ChromeVox.position[document.location.href]; |
73 cvox.ChromeVox.navigationManager.updateSelToArbitraryNode( | 71 cvox.ChromeVox.navigationManager.updateSelToArbitraryNode( |
74 document.elementFromPoint(pos.x, pos.y)); | 72 document.elementFromPoint(pos.x, pos.y)); |
75 } | 73 } |
76 | 74 |
77 // If this iframe has focus, speak and braille the current focused element. | 75 // If this iframe has focus, speak and braille the current focused element. |
78 if (cvox.ChromeVox.documentHasFocus()) { | 76 if (cvox.ChromeVox.documentHasFocus()) { |
79 if (!disableSpeak) { | 77 if (!disableSpeak) { |
80 cvox.ChromeVoxEventSuspender.withSuspendedEvents(function() { | 78 cvox.ChromeVoxEventSuspender.withSuspendedEvents(function() { |
81 cvox.ChromeVox.navigationManager.finishNavCommand( | 79 cvox.ChromeVox.navigationManager.finishNavCommand( |
82 '', true, cvox.QueueMode.QUEUE); | 80 '', true, cvox.QueueMode.QUEUE); |
83 })(); | 81 })(); |
84 } | 82 } |
85 } | 83 } |
86 }; | 84 }; |
OLD | NEW |