| OLD | NEW |
| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 LayoutTextControlItem textControlLayoutItem = LayoutTextControlItem(toLayout
TextControl(parentLayoutObject)); | 144 LayoutTextControlItem textControlLayoutItem = LayoutTextControlItem(toLayout
TextControl(parentLayoutObject)); |
| 145 RefPtr<ComputedStyle> innerEditorStyle = textControlLayoutItem.createInnerEd
itorStyle(textControlLayoutItem.styleRef()); | 145 RefPtr<ComputedStyle> innerEditorStyle = textControlLayoutItem.createInnerEd
itorStyle(textControlLayoutItem.styleRef()); |
| 146 // Using StyleAdjuster::adjustComputedStyle updates unwanted style. We'd lik
e | 146 // Using StyleAdjuster::adjustComputedStyle updates unwanted style. We'd lik
e |
| 147 // to apply only editing-related. | 147 // to apply only editing-related. |
| 148 StyleAdjuster::adjustStyleForEditing(*innerEditorStyle); | 148 StyleAdjuster::adjustStyleForEditing(*innerEditorStyle); |
| 149 return innerEditorStyle.release(); | 149 return innerEditorStyle.release(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // ---------------------------- | 152 // ---------------------------- |
| 153 | 153 |
| 154 inline SearchFieldDecorationElement::SearchFieldDecorationElement(Document& docu
ment) | |
| 155 : HTMLDivElement(document) | |
| 156 { | |
| 157 } | |
| 158 | |
| 159 SearchFieldDecorationElement* SearchFieldDecorationElement::create(Document& doc
ument) | |
| 160 { | |
| 161 SearchFieldDecorationElement* element = new SearchFieldDecorationElement(doc
ument); | |
| 162 element->setAttribute(idAttr, ShadowElementNames::searchDecoration()); | |
| 163 return element; | |
| 164 } | |
| 165 | |
| 166 const AtomicString& SearchFieldDecorationElement::shadowPseudoId() const | |
| 167 { | |
| 168 DEFINE_STATIC_LOCAL(AtomicString, resultsDecorationId, ("-webkit-search-resu
lts-decoration")); | |
| 169 DEFINE_STATIC_LOCAL(AtomicString, decorationId, ("-webkit-search-decoration"
)); | |
| 170 Element* host = shadowHost(); | |
| 171 if (!host) | |
| 172 return resultsDecorationId; | |
| 173 if (isHTMLInputElement(*host)) { | |
| 174 if (toHTMLInputElement(host)->maxResults() < 0) | |
| 175 return decorationId; | |
| 176 return resultsDecorationId; | |
| 177 } | |
| 178 return resultsDecorationId; | |
| 179 } | |
| 180 | |
| 181 void SearchFieldDecorationElement::defaultEventHandler(Event* event) | |
| 182 { | |
| 183 // On mousedown, focus the search field | |
| 184 HTMLInputElement* input = toHTMLInputElement(shadowHost()); | |
| 185 if (input && event->type() == EventTypeNames::mousedown && event->isMouseEve
nt() && toMouseEvent(event)->button() == LeftButton) { | |
| 186 input->focus(); | |
| 187 input->select(NotDispatchSelectEvent); | |
| 188 event->setDefaultHandled(); | |
| 189 } | |
| 190 | |
| 191 if (!event->defaultHandled()) | |
| 192 HTMLDivElement::defaultEventHandler(event); | |
| 193 } | |
| 194 | |
| 195 bool SearchFieldDecorationElement::willRespondToMouseClickEvents() | |
| 196 { | |
| 197 return true; | |
| 198 } | |
| 199 | |
| 200 // ---------------------------- | |
| 201 | |
| 202 inline SearchFieldCancelButtonElement::SearchFieldCancelButtonElement(Document&
document) | 154 inline SearchFieldCancelButtonElement::SearchFieldCancelButtonElement(Document&
document) |
| 203 : HTMLDivElement(document) | 155 : HTMLDivElement(document) |
| 204 , m_capturing(false) | 156 , m_capturing(false) |
| 205 { | 157 { |
| 206 } | 158 } |
| 207 | 159 |
| 208 SearchFieldCancelButtonElement* SearchFieldCancelButtonElement::create(Document&
document) | 160 SearchFieldCancelButtonElement* SearchFieldCancelButtonElement::create(Document&
document) |
| 209 { | 161 { |
| 210 SearchFieldCancelButtonElement* element = new SearchFieldCancelButtonElement
(document); | 162 SearchFieldCancelButtonElement* element = new SearchFieldCancelButtonElement
(document); |
| 211 element->setShadowPseudoId(AtomicString("-webkit-search-cancel-button")); | 163 element->setShadowPseudoId(AtomicString("-webkit-search-cancel-button")); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents() | 200 bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents() |
| 249 { | 201 { |
| 250 const HTMLInputElement* input = toHTMLInputElement(shadowHost()); | 202 const HTMLInputElement* input = toHTMLInputElement(shadowHost()); |
| 251 if (input && !input->isDisabledOrReadOnly()) | 203 if (input && !input->isDisabledOrReadOnly()) |
| 252 return true; | 204 return true; |
| 253 | 205 |
| 254 return HTMLDivElement::willRespondToMouseClickEvents(); | 206 return HTMLDivElement::willRespondToMouseClickEvents(); |
| 255 } | 207 } |
| 256 | 208 |
| 257 } // namespace blink | 209 } // namespace blink |
| OLD | NEW |