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

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

Issue 191293011: Value set in onblur should not keep element in focus (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review updates 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 DateTimeFieldElement::DateTimeFieldElement(Document& document, FieldOwner& field Owner) 49 DateTimeFieldElement::DateTimeFieldElement(Document& document, FieldOwner& field Owner)
50 : HTMLSpanElement(document) 50 : HTMLSpanElement(document)
51 , m_fieldOwner(&fieldOwner) 51 , m_fieldOwner(&fieldOwner)
52 { 52 {
53 } 53 }
54 54
55 void DateTimeFieldElement::defaultEventHandler(Event* event) 55 void DateTimeFieldElement::defaultEventHandler(Event* event)
56 { 56 {
57 if (event->type() == EventTypeNames::blur)
58 didBlur();
59
60 if (event->type() == EventTypeNames::focus)
61 didFocus();
62
63 if (event->isKeyboardEvent()) { 57 if (event->isKeyboardEvent()) {
64 KeyboardEvent* keyboardEvent = toKeyboardEvent(event); 58 KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
65 if (!isDisabled() && !isFieldOwnerDisabled() && !isFieldOwnerReadOnly()) { 59 if (!isDisabled() && !isFieldOwnerDisabled() && !isFieldOwnerReadOnly()) {
66 handleKeyboardEvent(keyboardEvent); 60 handleKeyboardEvent(keyboardEvent);
67 if (keyboardEvent->defaultHandled()) 61 if (keyboardEvent->defaultHandled())
68 return; 62 return;
69 } 63 }
70 defaultKeyboardEventHandler(keyboardEvent); 64 defaultKeyboardEventHandler(keyboardEvent);
71 if (keyboardEvent->defaultHandled()) 65 if (keyboardEvent->defaultHandled())
72 return; 66 return;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return; 116 return;
123 } 117 }
124 118
125 if (keyIdentifier == "U+0008" || keyIdentifier == "U+007F") { 119 if (keyIdentifier == "U+0008" || keyIdentifier == "U+007F") {
126 keyboardEvent->setDefaultHandled(); 120 keyboardEvent->setDefaultHandled();
127 setEmptyValue(DispatchEvent); 121 setEmptyValue(DispatchEvent);
128 return; 122 return;
129 } 123 }
130 } 124 }
131 125
132 void DateTimeFieldElement::didBlur() 126 void DateTimeFieldElement::setFocus(bool value)
133 { 127 {
134 if (m_fieldOwner) 128 if (m_fieldOwner)
135 m_fieldOwner->didBlurFromField(); 129 value ? m_fieldOwner->didFocusOnField() : m_fieldOwner->didBlurFromField ();
136 } 130 ContainerNode::setFocus(value);
137
138 void DateTimeFieldElement::didFocus()
139 {
140 if (m_fieldOwner)
141 m_fieldOwner->didFocusOnField();
142 } 131 }
143 132
144 void DateTimeFieldElement::focusOnNextField() 133 void DateTimeFieldElement::focusOnNextField()
145 { 134 {
146 if (!m_fieldOwner) 135 if (!m_fieldOwner)
147 return; 136 return;
148 m_fieldOwner->focusOnNextField(*this); 137 m_fieldOwner->focusOnNextField(*this);
149 } 138 }
150 139
151 void DateTimeFieldElement::initialize(const AtomicString& pseudo, const String& axHelpText, int axMinimum, int axMaximum) 140 void DateTimeFieldElement::initialize(const AtomicString& pseudo, const String& axHelpText, int axMinimum, int axMaximum)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 221 }
233 222
234 int DateTimeFieldElement::valueForARIAValueNow() const 223 int DateTimeFieldElement::valueForARIAValueNow() const
235 { 224 {
236 return valueAsInteger(); 225 return valueAsInteger();
237 } 226 }
238 227
239 } // namespace WebCore 228 } // namespace WebCore
240 229
241 #endif 230 #endif
OLDNEW
« no previous file with comments | « Source/core/html/shadow/DateTimeFieldElement.h ('k') | Source/core/html/shadow/DateTimeNumericFieldElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698