OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 { | 185 { |
186 return adoptRef(new SearchFieldCancelButtonElement(document)); | 186 return adoptRef(new SearchFieldCancelButtonElement(document)); |
187 } | 187 } |
188 | 188 |
189 const AtomicString& SearchFieldCancelButtonElement::shadowPseudoId() const | 189 const AtomicString& SearchFieldCancelButtonElement::shadowPseudoId() const |
190 { | 190 { |
191 DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-webkit-search-cancel-button",
AtomicString::ConstructFromLiteral)); | 191 DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-webkit-search-cancel-button",
AtomicString::ConstructFromLiteral)); |
192 return pseudoId; | 192 return pseudoId; |
193 } | 193 } |
194 | 194 |
195 void SearchFieldCancelButtonElement::detach() | 195 void SearchFieldCancelButtonElement::detach(const AttachContext& context) |
196 { | 196 { |
197 if (m_capturing) { | 197 if (m_capturing) { |
198 if (Frame* frame = document()->frame()) | 198 if (Frame* frame = document()->frame()) |
199 frame->eventHandler()->setCapturingMouseEventsNode(0); | 199 frame->eventHandler()->setCapturingMouseEventsNode(0); |
200 } | 200 } |
201 HTMLDivElement::detach(); | 201 HTMLDivElement::detach(context); |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) | 205 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) |
206 { | 206 { |
207 // If the element is visible, on mouseup, clear the value, and set selection | 207 // If the element is visible, on mouseup, clear the value, and set selection |
208 RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowHost())); | 208 RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowHost())); |
209 if (!input || input->isDisabledOrReadOnly()) { | 209 if (!input || input->isDisabledOrReadOnly()) { |
210 if (!event->defaultHandled()) | 210 if (!event->defaultHandled()) |
211 HTMLDivElement::defaultEventHandler(event); | 211 HTMLDivElement::defaultEventHandler(event); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // This event is sent after the text event so the website can perform action
s using the input field content immediately. | 394 // This event is sent after the text event so the website can perform action
s using the input field content immediately. |
395 // It provides alternative recognition hypotheses and notifies that the resu
lts come from speech input. | 395 // It provides alternative recognition hypotheses and notifies that the resu
lts come from speech input. |
396 input->dispatchEvent(SpeechInputEvent::create(eventNames().webkitspeechchang
eEvent, results)); | 396 input->dispatchEvent(SpeechInputEvent::create(eventNames().webkitspeechchang
eEvent, results)); |
397 | 397 |
398 // Check before accessing the renderer as the above event could have potenti
ally turned off | 398 // Check before accessing the renderer as the above event could have potenti
ally turned off |
399 // speech in the input element, hence removing this button and renderer from
the hierarchy. | 399 // speech in the input element, hence removing this button and renderer from
the hierarchy. |
400 if (renderer()) | 400 if (renderer()) |
401 renderer()->repaint(); | 401 renderer()->repaint(); |
402 } | 402 } |
403 | 403 |
404 void InputFieldSpeechButtonElement::attach() | 404 void InputFieldSpeechButtonElement::attach(const AttachContext& context) |
405 { | 405 { |
406 ASSERT(!m_listenerId); | 406 ASSERT(!m_listenerId); |
407 if (SpeechInput* input = SpeechInput::from(document()->page())) | 407 if (SpeechInput* input = SpeechInput::from(document()->page())) |
408 m_listenerId = input->registerListener(this); | 408 m_listenerId = input->registerListener(this); |
409 HTMLDivElement::attach(); | 409 HTMLDivElement::attach(context); |
410 } | 410 } |
411 | 411 |
412 void InputFieldSpeechButtonElement::detach() | 412 void InputFieldSpeechButtonElement::detach(const AttachContext& context) |
413 { | 413 { |
414 if (m_capturing) { | 414 if (m_capturing) { |
415 if (Frame* frame = document()->frame()) | 415 if (Frame* frame = document()->frame()) |
416 frame->eventHandler()->setCapturingMouseEventsNode(0); | 416 frame->eventHandler()->setCapturingMouseEventsNode(0); |
417 } | 417 } |
418 | 418 |
419 if (m_listenerId) { | 419 if (m_listenerId) { |
420 if (m_state != Idle) | 420 if (m_state != Idle) |
421 speechInput()->cancelRecognition(m_listenerId); | 421 speechInput()->cancelRecognition(m_listenerId); |
422 speechInput()->unregisterListener(m_listenerId); | 422 speechInput()->unregisterListener(m_listenerId); |
423 m_listenerId = 0; | 423 m_listenerId = 0; |
424 } | 424 } |
425 | 425 |
426 HTMLDivElement::detach(); | 426 HTMLDivElement::detach(context); |
427 } | 427 } |
428 | 428 |
429 void InputFieldSpeechButtonElement::startSpeechInput() | 429 void InputFieldSpeechButtonElement::startSpeechInput() |
430 { | 430 { |
431 if (m_state != Idle) | 431 if (m_state != Idle) |
432 return; | 432 return; |
433 | 433 |
434 RefPtr<HTMLInputElement> input = toHTMLInputElement(shadowHost()); | 434 RefPtr<HTMLInputElement> input = toHTMLInputElement(shadowHost()); |
435 AtomicString language = input->computeInheritedLanguage(); | 435 AtomicString language = input->computeInheritedLanguage(); |
436 String grammar = input->getAttribute(webkitgrammarAttr); | 436 String grammar = input->getAttribute(webkitgrammarAttr); |
(...skipping 10 matching lines...) Expand all Loading... |
447 | 447 |
448 const AtomicString& InputFieldSpeechButtonElement::shadowPseudoId() const | 448 const AtomicString& InputFieldSpeechButtonElement::shadowPseudoId() const |
449 { | 449 { |
450 DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-webkit-input-speech-button",
AtomicString::ConstructFromLiteral)); | 450 DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-webkit-input-speech-button",
AtomicString::ConstructFromLiteral)); |
451 return pseudoId; | 451 return pseudoId; |
452 } | 452 } |
453 | 453 |
454 #endif // ENABLE(INPUT_SPEECH) | 454 #endif // ENABLE(INPUT_SPEECH) |
455 | 455 |
456 } | 456 } |
OLD | NEW |