Changeset 76566 in webkit
- Timestamp:
- Jan 24, 2011 8:36:26 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r76565 r76566 1 2011-01-24 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Some bugs of search cancel button and spin button about state change in 6 an event handler. 7 https://bugs.webkit.org/show_bug.cgi?id=46950 8 9 * fast/forms/input-number-change-type-on-focus-expected.txt: Added. 10 * fast/forms/input-number-change-type-on-focus.html: Added. 11 * fast/forms/search-hide-cancel-on-cancel-expected.txt: Added. 12 * fast/forms/search-hide-cancel-on-cancel.html: Added. 13 1 14 2011-01-24 Ryosuke Niwa <rniwa@webkit.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r76565 r76566 1 2011-01-24 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Some bugs of search cancel button and spin button about state change in 6 an event handler. 7 https://bugs.webkit.org/show_bug.cgi?id=46950 8 9 Fix the following problems: 10 * Type=search field didn't release event capturing 11 * Assertion failure when an input field with spin buttons was changed 12 to another type on focus event. 13 * A input field with spin button didn't release event capturing when it 14 was changed to another type on focus event. 15 16 Tests: fast/forms/input-number-change-type-on-focus.html 17 fast/forms/search-hide-cancel-on-cancel.html 18 19 * rendering/TextControlInnerElements.cpp: 20 (WebCore::SearchFieldCancelButtonElement::defaultEventHandler): 21 - Make the variable 'input' RefPtr. It makes the code simpler. 22 - Remove visibility check on mouseup event. We should release capturing 23 anyway because the cancel button may be invisible if JavaScript code 24 called by the focus event removes the input value. 25 (WebCore::SpinButtonElement::detach): 26 - Release capturing on detach because it is possible that a spin button 27 node is detached while it is capturing events. 28 (WebCore::SpinButtonElement::defaultEventHandler): 29 Take a reference to this and check renderer() after some functions which 30 may run JavaScript code. 31 (WebCore::InputFieldSpeechButtonElement::defaultEventHandler): 32 Make the variable 'input' RefPtr to align other functions in this file. 33 (WebCore::InputFieldSpeechButtonElement::setRecognitionResult): ditto. 34 * rendering/TextControlInnerElements.h: Declare SpinButtonElement::detach(). 35 1 36 2011-01-24 Ryosuke Niwa <rniwa@webkit.org> 2 37 -
trunk/Source/WebCore/rendering/TextControlInnerElements.cpp
r76494 r76566 220 220 { 221 221 // If the element is visible, on mouseup, clear the value, and set selection 222 HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());222 RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode())); 223 223 if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) { 224 224 if (renderer() && renderer()->visibleToHitTesting()) { … … 233 233 } 234 234 if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) { 235 if (m_capturing && renderer() && renderer()->visibleToHitTesting()) {235 if (m_capturing) { 236 236 if (Frame* frame = document()->frame()) { 237 237 frame->eventHandler()->setCapturingMouseEventsNode(0); … … 239 239 } 240 240 if (hovered()) { 241 RefPtr<HTMLInputElement> protector(input);242 241 String oldValue = input->value(); 243 242 input->setValue(""); … … 272 271 } 273 272 273 void SpinButtonElement::detach() 274 { 275 stopRepeatingTimer(); 276 if (m_capturing) { 277 if (Frame* frame = document()->frame()) { 278 frame->eventHandler()->setCapturingMouseEventsNode(0); 279 m_capturing = false; 280 } 281 } 282 TextControlInnerElement::detach(); 283 } 284 274 285 void SpinButtonElement::defaultEventHandler(Event* event) 275 286 { … … 287 298 } 288 299 289 HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());300 RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode())); 290 301 if (input->disabled() || input->isReadOnlyFormControl()) { 291 302 if (!event->defaultHandled()) … … 298 309 if (mouseEvent->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) { 299 310 if (box->borderBoxRect().contains(local)) { 300 RefPtr<Node> protector(input); 311 // The following functions of HTMLInputElement may run JavaScript 312 // code which detaches this shadow node. We need to take a reference 313 // and check renderer() after such function calls. 314 RefPtr<Node> protector(this); 301 315 input->focus(); 302 316 input->select(); 303 input->stepUpFromRenderer(m_upDownState == Up ? 1 : -1); 317 if (renderer()) { 318 input->stepUpFromRenderer(m_upDownState == Up ? 1 : -1); 319 if (renderer()) 320 startRepeatingTimer(); 321 } 304 322 event->setDefaultHandled(); 305 startRepeatingTimer();306 323 } 307 324 } else if (mouseEvent->type() == eventNames().mouseupEvent && mouseEvent->button() == LeftButton) … … 404 421 } 405 422 423 // The call to focus() below dispatches a focus event, and an event handler in the page might 424 // remove the input element from DOM. To make sure it remains valid until we finish our work 425 // here, we take a temporary reference. 426 RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode())); 427 406 428 // On mouse down, select the text and set focus. 407 HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());408 429 if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) { 409 430 if (renderer() && renderer()->visibleToHitTesting()) { … … 413 434 } 414 435 } 415 // The call to focus() below dispatches a focus event, and an event handler in the page might416 // remove the input element from DOM. To make sure it remains valid until we finish our work417 // here, we take a temporary reference.418 RefPtr<HTMLInputElement> holdRef(input);419 436 RefPtr<InputFieldSpeechButtonElement> holdRefButton(this); 420 437 input->focus(); … … 483 500 m_results = results; 484 501 485 HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());486 502 // The call to setValue() below dispatches an event, and an event handler in the page might 487 503 // remove the input element from DOM. To make sure it remains valid until we finish our work 488 504 // here, we take a temporary reference. 489 RefPtr<HTMLInputElement> holdRef(input);505 RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode())); 490 506 RefPtr<InputFieldSpeechButtonElement> holdRefButton(this); 491 507 input->setValue(results.isEmpty() ? "" : results[0]->utterance()); -
trunk/Source/WebCore/rendering/TextControlInnerElements.h
r76494 r76566 100 100 SpinButtonElement(HTMLElement*); 101 101 102 virtual void detach(); 102 103 virtual bool isSpinButtonElement() const { return true; } 103 104 // FIXME: shadowAncestorNode() should be const.
Note: See TracChangeset
for help on using the changeset viewer.