| 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 // TextFieldDecorationElement is created only by C++ code, and it is always | 119 ASSERT(shadowAncestorNode()); |
| 120 // in <input> shadow. | 120 ASSERT(shadowAncestorNode()->hasTagName(inputTag)); |
| 121 ASSERT(!shadowHost() || shadowHost()->hasTagName(inputTag)); | 121 return static_cast<HTMLInputElement*>(shadowAncestorNode()); |
| 122 return static_cast<HTMLInputElement*>(shadowHost()); | |
| 123 } | 122 } |
| 124 | 123 |
| 125 bool TextFieldDecorationElement::isTextFieldDecoration() const | 124 bool TextFieldDecorationElement::isTextFieldDecoration() const |
| 126 { | 125 { |
| 127 return true; | 126 return true; |
| 128 } | 127 } |
| 129 | 128 |
| 130 void TextFieldDecorationElement::updateImage() | 129 void TextFieldDecorationElement::updateImage() |
| 131 { | 130 { |
| 132 if (!renderer() || !renderer()->isImage()) | 131 if (!renderer() || !renderer()->isImage()) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 174 } |
| 176 | 175 |
| 177 bool TextFieldDecorationElement::isMouseFocusable() const | 176 bool TextFieldDecorationElement::isMouseFocusable() const |
| 178 { | 177 { |
| 179 return false; | 178 return false; |
| 180 } | 179 } |
| 181 | 180 |
| 182 void TextFieldDecorationElement::defaultEventHandler(Event* event) | 181 void TextFieldDecorationElement::defaultEventHandler(Event* event) |
| 183 { | 182 { |
| 184 RefPtr<HTMLInputElement> input(hostInput()); | 183 RefPtr<HTMLInputElement> input(hostInput()); |
| 185 if (!input || input->disabled() || input->readOnly() || !event->isMouseEvent
()) { | 184 if (input->disabled() || input->readOnly() || !event->isMouseEvent()) { |
| 186 if (!event->defaultHandled()) | 185 if (!event->defaultHandled()) |
| 187 HTMLDivElement::defaultEventHandler(event); | 186 HTMLDivElement::defaultEventHandler(event); |
| 188 return; | 187 return; |
| 189 } | 188 } |
| 190 | 189 |
| 191 RefPtr<TextFieldDecorationElement> protector(this); | 190 RefPtr<TextFieldDecorationElement> protector(this); |
| 192 if (event->type() == eventNames().clickEvent) { | 191 if (event->type() == eventNames().clickEvent) { |
| 193 m_textFieldDecorator->handleClick(input.get()); | 192 m_textFieldDecorator->handleClick(input.get()); |
| 194 event->setDefaultHandled(); | 193 event->setDefaultHandled(); |
| 195 } | 194 } |
| 196 | 195 |
| 197 if (!event->defaultHandled()) | 196 if (!event->defaultHandled()) |
| 198 HTMLDivElement::defaultEventHandler(event); | 197 HTMLDivElement::defaultEventHandler(event); |
| 199 } | 198 } |
| 200 | 199 |
| 201 } // namespace WebCore | 200 } // namespace WebCore |
| OLD | NEW |