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

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

Issue 144713007: Spinner elements not to dispatch change event on hover (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: SpinButton change event trigger Created 6 years, 10 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 29 matching lines...) Expand all
40 #include "platform/scroll/ScrollbarTheme.h" 40 #include "platform/scroll/ScrollbarTheme.h"
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 using namespace HTMLNames; 44 using namespace HTMLNames;
45 45
46 inline SpinButtonElement::SpinButtonElement(Document& document, SpinButtonOwner& spinButtonOwner) 46 inline SpinButtonElement::SpinButtonElement(Document& document, SpinButtonOwner& spinButtonOwner)
47 : HTMLDivElement(document) 47 : HTMLDivElement(document)
48 , m_spinButtonOwner(&spinButtonOwner) 48 , m_spinButtonOwner(&spinButtonOwner)
49 , m_capturing(false) 49 , m_capturing(false)
50 , m_isMouseEvent(false)
50 , m_upDownState(Indeterminate) 51 , m_upDownState(Indeterminate)
51 , m_pressStartingState(Indeterminate) 52 , m_pressStartingState(Indeterminate)
52 , m_repeatingTimer(this, &SpinButtonElement::repeatingTimerFired) 53 , m_repeatingTimer(this, &SpinButtonElement::repeatingTimerFired)
53 { 54 {
54 } 55 }
55 56
56 PassRefPtr<SpinButtonElement> SpinButtonElement::create(Document& document, Spin ButtonOwner& spinButtonOwner) 57 PassRefPtr<SpinButtonElement> SpinButtonElement::create(Document& document, Spin ButtonOwner& spinButtonOwner)
57 { 58 {
58 RefPtr<SpinButtonElement> element = adoptRef(new SpinButtonElement(document, spinButtonOwner)); 59 RefPtr<SpinButtonElement> element = adoptRef(new SpinButtonElement(document, spinButtonOwner));
59 element->setShadowPseudoId(AtomicString("-webkit-inner-spin-button", AtomicS tring::ConstructFromLiteral)); 60 element->setShadowPseudoId(AtomicString("-webkit-inner-spin-button", AtomicS tring::ConstructFromLiteral));
(...skipping 20 matching lines...) Expand all
80 if (!event->defaultHandled()) 81 if (!event->defaultHandled())
81 HTMLDivElement::defaultEventHandler(event); 82 HTMLDivElement::defaultEventHandler(event);
82 return; 83 return;
83 } 84 }
84 85
85 if (!shouldRespondToMouseEvents()) { 86 if (!shouldRespondToMouseEvents()) {
86 if (!event->defaultHandled()) 87 if (!event->defaultHandled())
87 HTMLDivElement::defaultEventHandler(event); 88 HTMLDivElement::defaultEventHandler(event);
88 return; 89 return;
89 } 90 }
90 91 m_isMouseEvent = true;
91 MouseEvent* mouseEvent = toMouseEvent(event); 92 MouseEvent* mouseEvent = toMouseEvent(event);
92 IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent->absoluteLo cation(), UseTransforms)); 93 IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent->absoluteLo cation(), UseTransforms));
93 if (mouseEvent->type() == EventTypeNames::mousedown && mouseEvent->button() == LeftButton) { 94 if (mouseEvent->type() == EventTypeNames::mousedown && mouseEvent->button() == LeftButton) {
94 if (box->pixelSnappedBorderBoxRect().contains(local)) { 95 if (box->pixelSnappedBorderBoxRect().contains(local)) {
95 // The following functions of HTMLInputElement may run JavaScript 96 // The following functions of HTMLInputElement may run JavaScript
96 // code which detaches this shadow node. We need to take a reference 97 // code which detaches this shadow node. We need to take a reference
97 // and check renderer() after such function calls. 98 // and check renderer() after such function calls.
98 RefPtr<Node> protector(this); 99 RefPtr<Node> protector(this);
99 if (m_spinButtonOwner) 100 if (m_spinButtonOwner)
100 m_spinButtonOwner->focusAndSelectSpinButtonOwner(); 101 m_spinButtonOwner->focusAndSelectSpinButtonOwner();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 void SpinButtonElement::releaseCapture() 192 void SpinButtonElement::releaseCapture()
192 { 193 {
193 stopRepeatingTimer(); 194 stopRepeatingTimer();
194 if (m_capturing) { 195 if (m_capturing) {
195 if (Frame* frame = document().frame()) { 196 if (Frame* frame = document().frame()) {
196 frame->eventHandler().setCapturingMouseEventsNode(0); 197 frame->eventHandler().setCapturingMouseEventsNode(0);
197 m_capturing = false; 198 m_capturing = false;
198 if (Page* page = document().page()) 199 if (Page* page = document().page())
199 page->chrome().unregisterPopupOpeningObserver(this); 200 page->chrome().unregisterPopupOpeningObserver(this);
200 } 201 }
201 if (m_spinButtonOwner) 202 }
202 m_spinButtonOwner->spinButtonDidReleaseMouseCapture(); 203 if (m_spinButtonOwner && m_isMouseEvent) {
204 m_spinButtonOwner->spinButtonDidReleaseMouseCapture();
205 m_isMouseEvent = false;
203 } 206 }
204 } 207 }
205 208
206 bool SpinButtonElement::matchesReadOnlyPseudoClass() const 209 bool SpinButtonElement::matchesReadOnlyPseudoClass() const
207 { 210 {
208 return shadowHost()->matchesReadOnlyPseudoClass(); 211 return shadowHost()->matchesReadOnlyPseudoClass();
209 } 212 }
210 213
211 bool SpinButtonElement::matchesReadWritePseudoClass() const 214 bool SpinButtonElement::matchesReadWritePseudoClass() const
212 { 215 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 m_upDownState = Indeterminate; 254 m_upDownState = Indeterminate;
252 HTMLDivElement::setHovered(flag); 255 HTMLDivElement::setHovered(flag);
253 } 256 }
254 257
255 bool SpinButtonElement::shouldRespondToMouseEvents() 258 bool SpinButtonElement::shouldRespondToMouseEvents()
256 { 259 {
257 return !m_spinButtonOwner || m_spinButtonOwner->shouldSpinButtonRespondToMou seEvents(); 260 return !m_spinButtonOwner || m_spinButtonOwner->shouldSpinButtonRespondToMou seEvents();
258 } 261 }
259 262
260 } 263 }
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