| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 PassRefPtr<SpinButtonElement> SpinButtonElement::create(Document& document, Spin
ButtonOwner& spinButtonOwner) | 55 PassRefPtr<SpinButtonElement> SpinButtonElement::create(Document& document, Spin
ButtonOwner& spinButtonOwner) |
| 56 { | 56 { |
| 57 RefPtr<SpinButtonElement> element = adoptRef(new SpinButtonElement(document,
spinButtonOwner)); | 57 RefPtr<SpinButtonElement> element = adoptRef(new SpinButtonElement(document,
spinButtonOwner)); |
| 58 element->setShadowPseudoId(AtomicString("-webkit-inner-spin-button", AtomicS
tring::ConstructFromLiteral)); | 58 element->setShadowPseudoId(AtomicString("-webkit-inner-spin-button", AtomicS
tring::ConstructFromLiteral)); |
| 59 element->setAttribute(idAttr, ShadowElementNames::spinButton()); | 59 element->setAttribute(idAttr, ShadowElementNames::spinButton()); |
| 60 return element.release(); | 60 return element.release(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SpinButtonElement::detach(const AttachContext& context) | |
| 64 { | |
| 65 releaseCapture(); | |
| 66 HTMLDivElement::detach(context); | |
| 67 } | |
| 68 | |
| 69 void SpinButtonElement::defaultEventHandler(Event* event) | 63 void SpinButtonElement::defaultEventHandler(Event* event) |
| 70 { | 64 { |
| 71 if (!event->isMouseEvent()) { | 65 if (!event->isMouseEvent()) { |
| 72 if (!event->defaultHandled()) | 66 if (!event->defaultHandled()) |
| 73 HTMLDivElement::defaultEventHandler(event); | 67 HTMLDivElement::defaultEventHandler(event); |
| 74 return; | 68 return; |
| 75 } | 69 } |
| 76 | 70 |
| 77 RenderBox* box = renderBox(); | 71 RenderBox* box = renderBox(); |
| 78 if (!box) { | 72 if (!box) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 104 // cancel the repeating timer by the state change. If we | 98 // cancel the repeating timer by the state change. If we |
| 105 // started the timer after doStepAction(), we would have no | 99 // started the timer after doStepAction(), we would have no |
| 106 // chance to cancel the timer. | 100 // chance to cancel the timer. |
| 107 startRepeatingTimer(); | 101 startRepeatingTimer(); |
| 108 doStepAction(m_upDownState == Up ? 1 : -1); | 102 doStepAction(m_upDownState == Up ? 1 : -1); |
| 109 } | 103 } |
| 110 } | 104 } |
| 111 event->setDefaultHandled(); | 105 event->setDefaultHandled(); |
| 112 } | 106 } |
| 113 } else if (mouseEvent->type() == EventTypeNames::mouseup && mouseEvent->butt
on() == LeftButton) { | 107 } else if (mouseEvent->type() == EventTypeNames::mouseup && mouseEvent->butt
on() == LeftButton) { |
| 114 stopRepeatingTimer(); | 108 releaseCapture(); |
| 115 } else if (event->type() == EventTypeNames::mousemove) { | 109 } else if (event->type() == EventTypeNames::mousemove) { |
| 116 if (box->pixelSnappedBorderBoxRect().contains(local)) { | 110 if (box->pixelSnappedBorderBoxRect().contains(local)) { |
| 117 if (!m_capturing) { | 111 if (!m_capturing) { |
| 118 if (LocalFrame* frame = document().frame()) { | 112 if (LocalFrame* frame = document().frame()) { |
| 119 frame->eventHandler().setCapturingMouseEventsNode(this); | 113 frame->eventHandler().setCapturingMouseEventsNode(this); |
| 120 m_capturing = true; | 114 m_capturing = true; |
| 121 if (Page* page = document().page()) | 115 if (Page* page = document().page()) |
| 122 page->chrome().registerPopupOpeningObserver(this); | 116 page->chrome().registerPopupOpeningObserver(this); |
| 123 } | 117 } |
| 124 } | 118 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 { | 185 { |
| 192 stopRepeatingTimer(); | 186 stopRepeatingTimer(); |
| 193 if (m_capturing) { | 187 if (m_capturing) { |
| 194 if (LocalFrame* frame = document().frame()) { | 188 if (LocalFrame* frame = document().frame()) { |
| 195 frame->eventHandler().setCapturingMouseEventsNode(nullptr); | 189 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
| 196 m_capturing = false; | 190 m_capturing = false; |
| 197 if (Page* page = document().page()) | 191 if (Page* page = document().page()) |
| 198 page->chrome().unregisterPopupOpeningObserver(this); | 192 page->chrome().unregisterPopupOpeningObserver(this); |
| 199 } | 193 } |
| 200 } | 194 } |
| 195 if (m_spinButtonOwner) |
| 196 m_spinButtonOwner->spinButtonDidReleaseMouseCapture(); |
| 197 |
| 201 } | 198 } |
| 202 | 199 |
| 203 bool SpinButtonElement::matchesReadOnlyPseudoClass() const | 200 bool SpinButtonElement::matchesReadOnlyPseudoClass() const |
| 204 { | 201 { |
| 205 return shadowHost()->matchesReadOnlyPseudoClass(); | 202 return shadowHost()->matchesReadOnlyPseudoClass(); |
| 206 } | 203 } |
| 207 | 204 |
| 208 bool SpinButtonElement::matchesReadWritePseudoClass() const | 205 bool SpinButtonElement::matchesReadWritePseudoClass() const |
| 209 { | 206 { |
| 210 return shadowHost()->matchesReadWritePseudoClass(); | 207 return shadowHost()->matchesReadWritePseudoClass(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 m_upDownState = Indeterminate; | 245 m_upDownState = Indeterminate; |
| 249 HTMLDivElement::setHovered(flag); | 246 HTMLDivElement::setHovered(flag); |
| 250 } | 247 } |
| 251 | 248 |
| 252 bool SpinButtonElement::shouldRespondToMouseEvents() | 249 bool SpinButtonElement::shouldRespondToMouseEvents() |
| 253 { | 250 { |
| 254 return !m_spinButtonOwner || m_spinButtonOwner->shouldSpinButtonRespondToMou
seEvents(); | 251 return !m_spinButtonOwner || m_spinButtonOwner->shouldSpinButtonRespondToMou
seEvents(); |
| 255 } | 252 } |
| 256 | 253 |
| 257 } | 254 } |
| OLD | NEW |