| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 RefPtr<SearchFieldCancelButtonElement> element = adoptRef(new SearchFieldCan
celButtonElement(document)); | 208 RefPtr<SearchFieldCancelButtonElement> element = adoptRef(new SearchFieldCan
celButtonElement(document)); |
| 209 element->setShadowPseudoId(AtomicString("-webkit-search-cancel-button", Atom
icString::ConstructFromLiteral)); | 209 element->setShadowPseudoId(AtomicString("-webkit-search-cancel-button", Atom
icString::ConstructFromLiteral)); |
| 210 element->setAttribute(idAttr, ShadowElementNames::clearButton()); | 210 element->setAttribute(idAttr, ShadowElementNames::clearButton()); |
| 211 return element.release(); | 211 return element.release(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void SearchFieldCancelButtonElement::detach(const AttachContext& context) | 214 void SearchFieldCancelButtonElement::detach(const AttachContext& context) |
| 215 { | 215 { |
| 216 if (m_capturing) { | 216 if (m_capturing) { |
| 217 if (Frame* frame = document().frame()) | 217 if (Frame* frame = document().frame()) |
| 218 frame->eventHandler().setCapturingMouseEventsNode(0); | 218 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
| 219 } | 219 } |
| 220 HTMLDivElement::detach(context); | 220 HTMLDivElement::detach(context); |
| 221 } | 221 } |
| 222 | 222 |
| 223 | 223 |
| 224 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) | 224 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) |
| 225 { | 225 { |
| 226 // If the element is visible, on mouseup, clear the value, and set selection | 226 // If the element is visible, on mouseup, clear the value, and set selection |
| 227 RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowHost())); | 227 RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowHost())); |
| 228 if (!input || input->isDisabledOrReadOnly()) { | 228 if (!input || input->isDisabledOrReadOnly()) { |
| 229 if (!event->defaultHandled()) | 229 if (!event->defaultHandled()) |
| 230 HTMLDivElement::defaultEventHandler(event); | 230 HTMLDivElement::defaultEventHandler(event); |
| 231 return; | 231 return; |
| 232 } | 232 } |
| 233 | 233 |
| 234 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t
oMouseEvent(event)->button() == LeftButton) { | 234 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t
oMouseEvent(event)->button() == LeftButton) { |
| 235 if (renderer() && renderer()->visibleToHitTesting()) { | 235 if (renderer() && renderer()->visibleToHitTesting()) { |
| 236 if (Frame* frame = document().frame()) { | 236 if (Frame* frame = document().frame()) { |
| 237 frame->eventHandler().setCapturingMouseEventsNode(this); | 237 frame->eventHandler().setCapturingMouseEventsNode(this); |
| 238 m_capturing = true; | 238 m_capturing = true; |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 input->focus(); | 241 input->focus(); |
| 242 input->select(); | 242 input->select(); |
| 243 event->setDefaultHandled(); | 243 event->setDefaultHandled(); |
| 244 } | 244 } |
| 245 if (event->type() == EventTypeNames::mouseup && event->isMouseEvent() && toM
ouseEvent(event)->button() == LeftButton) { | 245 if (event->type() == EventTypeNames::mouseup && event->isMouseEvent() && toM
ouseEvent(event)->button() == LeftButton) { |
| 246 if (m_capturing) { | 246 if (m_capturing) { |
| 247 if (Frame* frame = document().frame()) { | 247 if (Frame* frame = document().frame()) { |
| 248 frame->eventHandler().setCapturingMouseEventsNode(0); | 248 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
| 249 m_capturing = false; | 249 m_capturing = false; |
| 250 } | 250 } |
| 251 if (hovered()) { | 251 if (hovered()) { |
| 252 String oldValue = input->value(); | 252 String oldValue = input->value(); |
| 253 input->setValueForUser(""); | 253 input->setValueForUser(""); |
| 254 input->onSearch(); | 254 input->onSearch(); |
| 255 event->setDefaultHandled(); | 255 event->setDefaultHandled(); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 } | 258 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 RefPtr<InputFieldSpeechButtonElement> holdRefButton(this); | 330 RefPtr<InputFieldSpeechButtonElement> holdRefButton(this); |
| 331 input->focus(); | 331 input->focus(); |
| 332 input->select(); | 332 input->select(); |
| 333 event->setDefaultHandled(); | 333 event->setDefaultHandled(); |
| 334 } | 334 } |
| 335 // On mouse up, release capture cleanly. | 335 // On mouse up, release capture cleanly. |
| 336 if (event->type() == EventTypeNames::mouseup && event->isMouseEvent() && toM
ouseEvent(event)->button() == LeftButton) { | 336 if (event->type() == EventTypeNames::mouseup && event->isMouseEvent() && toM
ouseEvent(event)->button() == LeftButton) { |
| 337 if (m_capturing && renderer() && renderer()->visibleToHitTesting()) { | 337 if (m_capturing && renderer() && renderer()->visibleToHitTesting()) { |
| 338 if (Frame* frame = document().frame()) { | 338 if (Frame* frame = document().frame()) { |
| 339 frame->eventHandler().setCapturingMouseEventsNode(0); | 339 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
| 340 m_capturing = false; | 340 m_capturing = false; |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 if (event->type() == EventTypeNames::click && m_listenerId) { | 345 if (event->type() == EventTypeNames::click && m_listenerId) { |
| 346 switch (m_state) { | 346 switch (m_state) { |
| 347 case Idle: | 347 case Idle: |
| 348 startSpeechInput(); | 348 startSpeechInput(); |
| 349 break; | 349 break; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 ASSERT(!m_listenerId); | 428 ASSERT(!m_listenerId); |
| 429 if (SpeechInput* input = SpeechInput::from(document().page())) | 429 if (SpeechInput* input = SpeechInput::from(document().page())) |
| 430 m_listenerId = input->registerListener(this); | 430 m_listenerId = input->registerListener(this); |
| 431 HTMLDivElement::attach(context); | 431 HTMLDivElement::attach(context); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void InputFieldSpeechButtonElement::detach(const AttachContext& context) | 434 void InputFieldSpeechButtonElement::detach(const AttachContext& context) |
| 435 { | 435 { |
| 436 if (m_capturing) { | 436 if (m_capturing) { |
| 437 if (Frame* frame = document().frame()) | 437 if (Frame* frame = document().frame()) |
| 438 frame->eventHandler().setCapturingMouseEventsNode(0); | 438 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
| 439 } | 439 } |
| 440 | 440 |
| 441 if (m_listenerId) { | 441 if (m_listenerId) { |
| 442 if (m_state != Idle) | 442 if (m_state != Idle) |
| 443 speechInput()->cancelRecognition(m_listenerId); | 443 speechInput()->cancelRecognition(m_listenerId); |
| 444 speechInput()->unregisterListener(m_listenerId); | 444 speechInput()->unregisterListener(m_listenerId); |
| 445 m_listenerId = 0; | 445 m_listenerId = 0; |
| 446 } | 446 } |
| 447 | 447 |
| 448 HTMLDivElement::detach(context); | 448 HTMLDivElement::detach(context); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 462 } | 462 } |
| 463 | 463 |
| 464 void InputFieldSpeechButtonElement::stopSpeechInput() | 464 void InputFieldSpeechButtonElement::stopSpeechInput() |
| 465 { | 465 { |
| 466 if (m_state == Recording) | 466 if (m_state == Recording) |
| 467 speechInput()->stopRecording(m_listenerId); | 467 speechInput()->stopRecording(m_listenerId); |
| 468 } | 468 } |
| 469 #endif // ENABLE(INPUT_SPEECH) | 469 #endif // ENABLE(INPUT_SPEECH) |
| 470 | 470 |
| 471 } | 471 } |
| OLD | NEW |