OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple 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 are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "core/html/FormDataList.h" | 37 #include "core/html/FormDataList.h" |
38 #include "core/html/HTMLInputElement.h" | 38 #include "core/html/HTMLInputElement.h" |
39 #include "core/html/forms/FormController.h" | 39 #include "core/html/forms/FormController.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 using namespace HTMLNames; | 43 using namespace HTMLNames; |
44 | 44 |
45 FormControlState BaseCheckableInputType::saveFormControlState() const | 45 FormControlState BaseCheckableInputType::saveFormControlState() const |
46 { | 46 { |
47 return FormControlState(element()->checked() ? "on" : "off"); | 47 return FormControlState(element().checked() ? "on" : "off"); |
48 } | 48 } |
49 | 49 |
50 void BaseCheckableInputType::restoreFormControlState(const FormControlState& sta
te) | 50 void BaseCheckableInputType::restoreFormControlState(const FormControlState& sta
te) |
51 { | 51 { |
52 element()->setChecked(state[0] == "on"); | 52 element().setChecked(state[0] == "on"); |
53 } | 53 } |
54 | 54 |
55 bool BaseCheckableInputType::appendFormData(FormDataList& encoding, bool) const | 55 bool BaseCheckableInputType::appendFormData(FormDataList& encoding, bool) const |
56 { | 56 { |
57 if (!element()->checked()) | 57 if (!element().checked()) |
58 return false; | 58 return false; |
59 encoding.appendData(element()->name(), element()->value()); | 59 encoding.appendData(element().name(), element().value()); |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 void BaseCheckableInputType::handleKeydownEvent(KeyboardEvent* event) | 63 void BaseCheckableInputType::handleKeydownEvent(KeyboardEvent* event) |
64 { | 64 { |
65 const String& key = event->keyIdentifier(); | 65 const String& key = event->keyIdentifier(); |
66 if (key == "U+0020") { | 66 if (key == "U+0020") { |
67 element()->setActive(true, true); | 67 element().setActive(true, true); |
68 // No setDefaultHandled(), because IE dispatches a keypress in this case | 68 // No setDefaultHandled(), because IE dispatches a keypress in this case |
69 // and the caller will only dispatch a keypress if we don't call setDefa
ultHandled(). | 69 // and the caller will only dispatch a keypress if we don't call setDefa
ultHandled(). |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 void BaseCheckableInputType::handleKeypressEvent(KeyboardEvent* event) | 73 void BaseCheckableInputType::handleKeypressEvent(KeyboardEvent* event) |
74 { | 74 { |
75 if (event->charCode() == ' ') { | 75 if (event->charCode() == ' ') { |
76 // Prevent scrolling down the page. | 76 // Prevent scrolling down the page. |
77 event->setDefaultHandled(); | 77 event->setDefaultHandled(); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 bool BaseCheckableInputType::canSetStringValue() const | 81 bool BaseCheckableInputType::canSetStringValue() const |
82 { | 82 { |
83 return false; | 83 return false; |
84 } | 84 } |
85 | 85 |
86 // FIXME: Could share this with BaseClickableWithKeyInputType and RangeInputType
if we had a common base class. | 86 // FIXME: Could share this with BaseClickableWithKeyInputType and RangeInputType
if we had a common base class. |
87 void BaseCheckableInputType::accessKeyAction(bool sendMouseEvents) | 87 void BaseCheckableInputType::accessKeyAction(bool sendMouseEvents) |
88 { | 88 { |
89 InputType::accessKeyAction(sendMouseEvents); | 89 InputType::accessKeyAction(sendMouseEvents); |
90 | 90 |
91 element()->dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents
: SendNoEvents); | 91 element().dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents
: SendNoEvents); |
92 } | 92 } |
93 | 93 |
94 String BaseCheckableInputType::fallbackValue() const | 94 String BaseCheckableInputType::fallbackValue() const |
95 { | 95 { |
96 return "on"; | 96 return "on"; |
97 } | 97 } |
98 | 98 |
99 bool BaseCheckableInputType::storesValueSeparateFromAttribute() | 99 bool BaseCheckableInputType::storesValueSeparateFromAttribute() |
100 { | 100 { |
101 return false; | 101 return false; |
102 } | 102 } |
103 | 103 |
104 void BaseCheckableInputType::setValue(const String& sanitizedValue, bool, TextFi
eldEventBehavior) | 104 void BaseCheckableInputType::setValue(const String& sanitizedValue, bool, TextFi
eldEventBehavior) |
105 { | 105 { |
106 element()->setAttribute(valueAttr, sanitizedValue); | 106 element().setAttribute(valueAttr, sanitizedValue); |
107 } | 107 } |
108 | 108 |
109 bool BaseCheckableInputType::isCheckable() | 109 bool BaseCheckableInputType::isCheckable() |
110 { | 110 { |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 } // namespace WebCore | 114 } // namespace WebCore |
OLD | NEW |