OLD | NEW |
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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 ASSERT(existingRoot->childNodeCount() == 1); | 109 ASSERT(existingRoot->childNodeCount() == 1); |
110 toHTMLElement(existingRoot->firstChild())->setInlineStyleProperty(CSSPropert
yWebkitBoxFlex, 1.0, CSSPrimitiveValue::CSS_NUMBER); | 110 toHTMLElement(existingRoot->firstChild())->setInlineStyleProperty(CSSPropert
yWebkitBoxFlex, 1.0, CSSPrimitiveValue::CSS_NUMBER); |
111 box->appendChild(HTMLShadowElement::create(HTMLNames::shadowTag, input->docu
ment())); | 111 box->appendChild(HTMLShadowElement::create(HTMLNames::shadowTag, input->docu
ment())); |
112 | 112 |
113 setInlineStyleProperty(CSSPropertyDisplay, visible ? CSSValueBlock : CSSValu
eNone); | 113 setInlineStyleProperty(CSSPropertyDisplay, visible ? CSSValueBlock : CSSValu
eNone); |
114 box->appendChild(this); | 114 box->appendChild(this); |
115 } | 115 } |
116 | 116 |
117 inline HTMLInputElement* TextFieldDecorationElement::hostInput() | 117 inline HTMLInputElement* TextFieldDecorationElement::hostInput() |
118 { | 118 { |
119 ASSERT(shadowAncestorNode()); | 119 // TextFieldDecorationElement is created only by C++ code, and it is always |
120 ASSERT(shadowAncestorNode()->hasTagName(inputTag)); | 120 // in <input> shadow. |
121 return static_cast<HTMLInputElement*>(shadowAncestorNode()); | 121 ASSERT(!shadowHost() || shadowHost()->hasTagName(inputTag)); |
| 122 return static_cast<HTMLInputElement*>(shadowHost()); |
122 } | 123 } |
123 | 124 |
124 bool TextFieldDecorationElement::isTextFieldDecoration() const | 125 bool TextFieldDecorationElement::isTextFieldDecoration() const |
125 { | 126 { |
126 return true; | 127 return true; |
127 } | 128 } |
128 | 129 |
129 void TextFieldDecorationElement::updateImage() | 130 void TextFieldDecorationElement::updateImage() |
130 { | 131 { |
131 if (!renderer() || !renderer()->isImage()) | 132 if (!renderer() || !renderer()->isImage()) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 175 } |
175 | 176 |
176 bool TextFieldDecorationElement::isMouseFocusable() const | 177 bool TextFieldDecorationElement::isMouseFocusable() const |
177 { | 178 { |
178 return false; | 179 return false; |
179 } | 180 } |
180 | 181 |
181 void TextFieldDecorationElement::defaultEventHandler(Event* event) | 182 void TextFieldDecorationElement::defaultEventHandler(Event* event) |
182 { | 183 { |
183 RefPtr<HTMLInputElement> input(hostInput()); | 184 RefPtr<HTMLInputElement> input(hostInput()); |
184 if (input->disabled() || input->readOnly() || !event->isMouseEvent()) { | 185 if (!input || input->disabled() || input->readOnly() || !event->isMouseEvent
()) { |
185 if (!event->defaultHandled()) | 186 if (!event->defaultHandled()) |
186 HTMLDivElement::defaultEventHandler(event); | 187 HTMLDivElement::defaultEventHandler(event); |
187 return; | 188 return; |
188 } | 189 } |
189 | 190 |
190 RefPtr<TextFieldDecorationElement> protector(this); | 191 RefPtr<TextFieldDecorationElement> protector(this); |
191 if (event->type() == eventNames().clickEvent) { | 192 if (event->type() == eventNames().clickEvent) { |
192 m_textFieldDecorator->handleClick(input.get()); | 193 m_textFieldDecorator->handleClick(input.get()); |
193 event->setDefaultHandled(); | 194 event->setDefaultHandled(); |
194 } | 195 } |
195 | 196 |
196 if (!event->defaultHandled()) | 197 if (!event->defaultHandled()) |
197 HTMLDivElement::defaultEventHandler(event); | 198 HTMLDivElement::defaultEventHandler(event); |
198 } | 199 } |
199 | 200 |
200 } // namespace WebCore | 201 } // namespace WebCore |
OLD | NEW |