| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 { | 181 { |
| 182 } | 182 } |
| 183 | 183 |
| 184 PassRefPtr<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::creat
e(Document* document) | 184 PassRefPtr<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::creat
e(Document* document) |
| 185 { | 185 { |
| 186 RefPtr<SearchFieldCancelButtonElement> element = adoptRef(new SearchFieldCan
celButtonElement(document)); | 186 RefPtr<SearchFieldCancelButtonElement> element = adoptRef(new SearchFieldCan
celButtonElement(document)); |
| 187 element->setPseudo(AtomicString("-webkit-search-cancel-button", AtomicString
::ConstructFromLiteral)); | 187 element->setPseudo(AtomicString("-webkit-search-cancel-button", AtomicString
::ConstructFromLiteral)); |
| 188 return element.release(); | 188 return element.release(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void SearchFieldCancelButtonElement::detach() | 191 void SearchFieldCancelButtonElement::detach(const AttachContext& context) |
| 192 { | 192 { |
| 193 if (m_capturing) { | 193 if (m_capturing) { |
| 194 if (Frame* frame = document()->frame()) | 194 if (Frame* frame = document()->frame()) |
| 195 frame->eventHandler()->setCapturingMouseEventsNode(0); | 195 frame->eventHandler()->setCapturingMouseEventsNode(0); |
| 196 } | 196 } |
| 197 HTMLDivElement::detach(); | 197 HTMLDivElement::detach(context); |
| 198 } | 198 } |
| 199 | 199 |
| 200 | 200 |
| 201 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) | 201 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) |
| 202 { | 202 { |
| 203 // If the element is visible, on mouseup, clear the value, and set selection | 203 // If the element is visible, on mouseup, clear the value, and set selection |
| 204 RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowHost())); | 204 RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowHost())); |
| 205 if (!input || input->isDisabledOrReadOnly()) { | 205 if (!input || input->isDisabledOrReadOnly()) { |
| 206 if (!event->defaultHandled()) | 206 if (!event->defaultHandled()) |
| 207 HTMLDivElement::defaultEventHandler(event); | 207 HTMLDivElement::defaultEventHandler(event); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // This event is sent after the text event so the website can perform action
s using the input field content immediately. | 392 // This event is sent after the text event so the website can perform action
s using the input field content immediately. |
| 393 // It provides alternative recognition hypotheses and notifies that the resu
lts come from speech input. | 393 // It provides alternative recognition hypotheses and notifies that the resu
lts come from speech input. |
| 394 input->dispatchEvent(SpeechInputEvent::create(eventNames().webkitspeechchang
eEvent, results)); | 394 input->dispatchEvent(SpeechInputEvent::create(eventNames().webkitspeechchang
eEvent, results)); |
| 395 | 395 |
| 396 // Check before accessing the renderer as the above event could have potenti
ally turned off | 396 // Check before accessing the renderer as the above event could have potenti
ally turned off |
| 397 // speech in the input element, hence removing this button and renderer from
the hierarchy. | 397 // speech in the input element, hence removing this button and renderer from
the hierarchy. |
| 398 if (renderer()) | 398 if (renderer()) |
| 399 renderer()->repaint(); | 399 renderer()->repaint(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void InputFieldSpeechButtonElement::attach() | 402 void InputFieldSpeechButtonElement::attach(const AttachContext& context) |
| 403 { | 403 { |
| 404 ASSERT(!m_listenerId); | 404 ASSERT(!m_listenerId); |
| 405 if (SpeechInput* input = SpeechInput::from(document()->page())) | 405 if (SpeechInput* input = SpeechInput::from(document()->page())) |
| 406 m_listenerId = input->registerListener(this); | 406 m_listenerId = input->registerListener(this); |
| 407 HTMLDivElement::attach(); | 407 HTMLDivElement::attach(context); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void InputFieldSpeechButtonElement::detach() | 410 void InputFieldSpeechButtonElement::detach(const AttachContext& context) |
| 411 { | 411 { |
| 412 if (m_capturing) { | 412 if (m_capturing) { |
| 413 if (Frame* frame = document()->frame()) | 413 if (Frame* frame = document()->frame()) |
| 414 frame->eventHandler()->setCapturingMouseEventsNode(0); | 414 frame->eventHandler()->setCapturingMouseEventsNode(0); |
| 415 } | 415 } |
| 416 | 416 |
| 417 if (m_listenerId) { | 417 if (m_listenerId) { |
| 418 if (m_state != Idle) | 418 if (m_state != Idle) |
| 419 speechInput()->cancelRecognition(m_listenerId); | 419 speechInput()->cancelRecognition(m_listenerId); |
| 420 speechInput()->unregisterListener(m_listenerId); | 420 speechInput()->unregisterListener(m_listenerId); |
| 421 m_listenerId = 0; | 421 m_listenerId = 0; |
| 422 } | 422 } |
| 423 | 423 |
| 424 HTMLDivElement::detach(); | 424 HTMLDivElement::detach(context); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void InputFieldSpeechButtonElement::startSpeechInput() | 427 void InputFieldSpeechButtonElement::startSpeechInput() |
| 428 { | 428 { |
| 429 if (m_state != Idle) | 429 if (m_state != Idle) |
| 430 return; | 430 return; |
| 431 | 431 |
| 432 RefPtr<HTMLInputElement> input = toHTMLInputElement(shadowHost()); | 432 RefPtr<HTMLInputElement> input = toHTMLInputElement(shadowHost()); |
| 433 AtomicString language = input->computeInheritedLanguage(); | 433 AtomicString language = input->computeInheritedLanguage(); |
| 434 String grammar = input->getAttribute(webkitgrammarAttr); | 434 String grammar = input->getAttribute(webkitgrammarAttr); |
| 435 IntRect rect = document()->view()->contentsToRootView(pixelSnappedBoundingBo
x()); | 435 IntRect rect = document()->view()->contentsToRootView(pixelSnappedBoundingBo
x()); |
| 436 if (speechInput()->startRecognition(m_listenerId, rect, language, grammar, d
ocument()->securityOrigin())) | 436 if (speechInput()->startRecognition(m_listenerId, rect, language, grammar, d
ocument()->securityOrigin())) |
| 437 setState(Recording); | 437 setState(Recording); |
| 438 } | 438 } |
| 439 | 439 |
| 440 void InputFieldSpeechButtonElement::stopSpeechInput() | 440 void InputFieldSpeechButtonElement::stopSpeechInput() |
| 441 { | 441 { |
| 442 if (m_state == Recording) | 442 if (m_state == Recording) |
| 443 speechInput()->stopRecording(m_listenerId); | 443 speechInput()->stopRecording(m_listenerId); |
| 444 } | 444 } |
| 445 #endif // ENABLE(INPUT_SPEECH) | 445 #endif // ENABLE(INPUT_SPEECH) |
| 446 | 446 |
| 447 } | 447 } |
| OLD | NEW |