Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: Source/core/html/shadow/SpinButtonElement.cpp

Issue 196933006: Do not dispatch 'change' events during pressing spin buttons for input[type=number]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed setFocus code from ShadowElement to InputElement Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/shadow/SpinButtonElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 20 matching lines...) Expand all
99 m_spinButtonOwner->focusAndSelectSpinButtonOwner(); 93 m_spinButtonOwner->focusAndSelectSpinButtonOwner();
100 if (renderer()) { 94 if (renderer()) {
101 if (m_upDownState != Indeterminate) { 95 if (m_upDownState != Indeterminate) {
102 // A JavaScript event handler called in doStepAction() below 96 // A JavaScript event handler called in doStepAction() below
103 // might change the element state and we might need to 97 // might change the element state and we might need to
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);
103 if (m_spinButtonOwner)
104 m_spinButtonOwner->spinButtonDidReleaseMouseCapture();
tkent 2014/04/07 04:31:17 Why pinButtonDidReleaseMouseCapture is called? We
Habib Virji 2014/04/07 07:33:18 Done.
109 } 105 }
110 } 106 }
111 event->setDefaultHandled(); 107 event->setDefaultHandled();
112 } 108 }
113 } else if (mouseEvent->type() == EventTypeNames::mouseup && mouseEvent->butt on() == LeftButton) { 109 } else if (mouseEvent->type() == EventTypeNames::mouseup && mouseEvent->butt on() == LeftButton) {
114 stopRepeatingTimer(); 110 releaseCapture();
115 } else if (event->type() == EventTypeNames::mousemove) { 111 } else if (event->type() == EventTypeNames::mousemove) {
116 if (box->pixelSnappedBorderBoxRect().contains(local)) { 112 if (box->pixelSnappedBorderBoxRect().contains(local)) {
117 if (!m_capturing) { 113 if (!m_capturing) {
118 if (LocalFrame* frame = document().frame()) { 114 if (LocalFrame* frame = document().frame()) {
119 frame->eventHandler().setCapturingMouseEventsNode(this); 115 frame->eventHandler().setCapturingMouseEventsNode(this);
120 m_capturing = true; 116 m_capturing = true;
121 if (Page* page = document().page()) 117 if (Page* page = document().page())
122 page->chrome().registerPopupOpeningObserver(this); 118 page->chrome().registerPopupOpeningObserver(this);
123 } 119 }
124 } 120 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 { 187 {
192 stopRepeatingTimer(); 188 stopRepeatingTimer();
193 if (m_capturing) { 189 if (m_capturing) {
194 if (LocalFrame* frame = document().frame()) { 190 if (LocalFrame* frame = document().frame()) {
195 frame->eventHandler().setCapturingMouseEventsNode(nullptr); 191 frame->eventHandler().setCapturingMouseEventsNode(nullptr);
196 m_capturing = false; 192 m_capturing = false;
197 if (Page* page = document().page()) 193 if (Page* page = document().page())
198 page->chrome().unregisterPopupOpeningObserver(this); 194 page->chrome().unregisterPopupOpeningObserver(this);
199 } 195 }
200 } 196 }
197 if (m_spinButtonOwner)
198 m_spinButtonOwner->spinButtonDidReleaseMouseCapture();
199
201 } 200 }
202 201
203 bool SpinButtonElement::matchesReadOnlyPseudoClass() const 202 bool SpinButtonElement::matchesReadOnlyPseudoClass() const
204 { 203 {
205 return shadowHost()->matchesReadOnlyPseudoClass(); 204 return shadowHost()->matchesReadOnlyPseudoClass();
206 } 205 }
207 206
208 bool SpinButtonElement::matchesReadWritePseudoClass() const 207 bool SpinButtonElement::matchesReadWritePseudoClass() const
209 { 208 {
210 return shadowHost()->matchesReadWritePseudoClass(); 209 return shadowHost()->matchesReadWritePseudoClass();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 m_upDownState = Indeterminate; 247 m_upDownState = Indeterminate;
249 HTMLDivElement::setHovered(flag); 248 HTMLDivElement::setHovered(flag);
250 } 249 }
251 250
252 bool SpinButtonElement::shouldRespondToMouseEvents() 251 bool SpinButtonElement::shouldRespondToMouseEvents()
253 { 252 {
254 return !m_spinButtonOwner || m_spinButtonOwner->shouldSpinButtonRespondToMou seEvents(); 253 return !m_spinButtonOwner || m_spinButtonOwner->shouldSpinButtonRespondToMou seEvents();
255 } 254 }
256 255
257 } 256 }
OLDNEW
« no previous file with comments | « Source/core/html/shadow/SpinButtonElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698