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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 EditingViewPortElement* element = new EditingViewPortElement(document); | 75 EditingViewPortElement* element = new EditingViewPortElement(document); |
76 element->setAttribute(idAttr, ShadowElementNames::editingViewPort()); | 76 element->setAttribute(idAttr, ShadowElementNames::editingViewPort()); |
77 return element; | 77 return element; |
78 } | 78 } |
79 | 79 |
80 PassRefPtr<ComputedStyle> EditingViewPortElement::customStyleForLayoutObject() | 80 PassRefPtr<ComputedStyle> EditingViewPortElement::customStyleForLayoutObject() |
81 { | 81 { |
82 // FXIME: Move these styles to html.css. | 82 // FXIME: Move these styles to html.css. |
83 | 83 |
84 RefPtr<ComputedStyle> style = ComputedStyle::create(); | 84 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
85 style->inheritFrom(shadowHost()->computedStyleRef()); | 85 style->inheritFrom(ownerShadowHost()->computedStyleRef()); |
86 | 86 |
87 style->setFlexGrow(1); | 87 style->setFlexGrow(1); |
88 style->setMinWidth(Length(0, Fixed)); | 88 style->setMinWidth(Length(0, Fixed)); |
89 style->setDisplay(BLOCK); | 89 style->setDisplay(BLOCK); |
90 style->setDirection(LTR); | 90 style->setDirection(LTR); |
91 | 91 |
92 // We don't want the shadow dom to be editable, so we set this block to | 92 // We don't want the shadow dom to be editable, so we set this block to |
93 // read-only in case the input itself is editable. | 93 // read-only in case the input itself is editable. |
94 style->setUserModify(READ_ONLY); | 94 style->setUserModify(READ_ONLY); |
95 style->setUnique(); | 95 style->setUnique(); |
(...skipping 18 matching lines...) Expand all Loading... |
114 element->setAttribute(idAttr, ShadowElementNames::innerEditor()); | 114 element->setAttribute(idAttr, ShadowElementNames::innerEditor()); |
115 return element; | 115 return element; |
116 } | 116 } |
117 | 117 |
118 void TextControlInnerEditorElement::defaultEventHandler(Event* event) | 118 void TextControlInnerEditorElement::defaultEventHandler(Event* event) |
119 { | 119 { |
120 // FIXME: In the future, we should add a way to have default event listeners
. | 120 // FIXME: In the future, we should add a way to have default event listeners
. |
121 // Then we would add one to the text field's inner div, and we wouldn't need
this subclass. | 121 // Then we would add one to the text field's inner div, and we wouldn't need
this subclass. |
122 // Or possibly we could just use a normal event listener. | 122 // Or possibly we could just use a normal event listener. |
123 if (event->isBeforeTextInsertedEvent() || event->type() == EventTypeNames::w
ebkitEditableContentChanged) { | 123 if (event->isBeforeTextInsertedEvent() || event->type() == EventTypeNames::w
ebkitEditableContentChanged) { |
124 Element* shadowAncestor = shadowHost(); | 124 Element* shadowAncestor = ownerShadowHost(); |
125 // A TextControlInnerTextElement can have no host if its been detached, | 125 // A TextControlInnerTextElement can have no host if its been detached, |
126 // but kept alive by an EditCommand. In this case, an undo/redo can | 126 // but kept alive by an EditCommand. In this case, an undo/redo can |
127 // cause events to be sent to the TextControlInnerTextElement. To | 127 // cause events to be sent to the TextControlInnerTextElement. To |
128 // prevent an infinite loop, we must check for this case before sending | 128 // prevent an infinite loop, we must check for this case before sending |
129 // the event up the chain. | 129 // the event up the chain. |
130 if (shadowAncestor) | 130 if (shadowAncestor) |
131 shadowAncestor->defaultEventHandler(event); | 131 shadowAncestor->defaultEventHandler(event); |
132 } | 132 } |
133 if (!event->defaultHandled()) | 133 if (!event->defaultHandled()) |
134 HTMLDivElement::defaultEventHandler(event); | 134 HTMLDivElement::defaultEventHandler(event); |
135 } | 135 } |
136 | 136 |
137 LayoutObject* TextControlInnerEditorElement::createLayoutObject(const ComputedSt
yle&) | 137 LayoutObject* TextControlInnerEditorElement::createLayoutObject(const ComputedSt
yle&) |
138 { | 138 { |
139 return new LayoutTextControlInnerBlock(this); | 139 return new LayoutTextControlInnerBlock(this); |
140 } | 140 } |
141 | 141 |
142 PassRefPtr<ComputedStyle> TextControlInnerEditorElement::customStyleForLayoutObj
ect() | 142 PassRefPtr<ComputedStyle> TextControlInnerEditorElement::customStyleForLayoutObj
ect() |
143 { | 143 { |
144 LayoutObject* parentLayoutObject = shadowHost()->layoutObject(); | 144 LayoutObject* parentLayoutObject = ownerShadowHost()->layoutObject(); |
145 if (!parentLayoutObject || !parentLayoutObject->isTextControl()) | 145 if (!parentLayoutObject || !parentLayoutObject->isTextControl()) |
146 return originalStyleForLayoutObject(); | 146 return originalStyleForLayoutObject(); |
147 LayoutTextControlItem textControlLayoutItem = LayoutTextControlItem(toLayout
TextControl(parentLayoutObject)); | 147 LayoutTextControlItem textControlLayoutItem = LayoutTextControlItem(toLayout
TextControl(parentLayoutObject)); |
148 RefPtr<ComputedStyle> innerEditorStyle = textControlLayoutItem.createInnerEd
itorStyle(textControlLayoutItem.styleRef()); | 148 RefPtr<ComputedStyle> innerEditorStyle = textControlLayoutItem.createInnerEd
itorStyle(textControlLayoutItem.styleRef()); |
149 // Using StyleAdjuster::adjustComputedStyle updates unwanted style. We'd lik
e | 149 // Using StyleAdjuster::adjustComputedStyle updates unwanted style. We'd lik
e |
150 // to apply only editing-related and alignment-related. | 150 // to apply only editing-related and alignment-related. |
151 StyleAdjuster::adjustStyleForEditing(*innerEditorStyle); | 151 StyleAdjuster::adjustStyleForEditing(*innerEditorStyle); |
152 if (const ComputedStyle* parentStyle = parentComputedStyle()) | 152 if (const ComputedStyle* parentStyle = parentComputedStyle()) |
153 StyleAdjuster::adjustStyleForAlignment(*innerEditorStyle, *parentStyle); | 153 StyleAdjuster::adjustStyleForAlignment(*innerEditorStyle, *parentStyle); |
154 return innerEditorStyle.release(); | 154 return innerEditorStyle.release(); |
(...skipping 21 matching lines...) Expand all Loading... |
176 if (LocalFrame* frame = document().frame()) | 176 if (LocalFrame* frame = document().frame()) |
177 frame->eventHandler().setCapturingMouseEventsNode(nullptr); | 177 frame->eventHandler().setCapturingMouseEventsNode(nullptr); |
178 } | 178 } |
179 HTMLDivElement::detachLayoutTree(context); | 179 HTMLDivElement::detachLayoutTree(context); |
180 } | 180 } |
181 | 181 |
182 | 182 |
183 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) | 183 void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) |
184 { | 184 { |
185 // If the element is visible, on mouseup, clear the value, and set selection | 185 // If the element is visible, on mouseup, clear the value, and set selection |
186 HTMLInputElement* input(toHTMLInputElement(shadowHost())); | 186 HTMLInputElement* input(toHTMLInputElement(ownerShadowHost())); |
187 if (!input || input->isDisabledOrReadOnly()) { | 187 if (!input || input->isDisabledOrReadOnly()) { |
188 if (!event->defaultHandled()) | 188 if (!event->defaultHandled()) |
189 HTMLDivElement::defaultEventHandler(event); | 189 HTMLDivElement::defaultEventHandler(event); |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 | 193 |
194 if (event->type() == EventTypeNames::click && event->isMouseEvent() && toMou
seEvent(event)->button() == static_cast<short>(WebPointerProperties::Button::Lef
t)) { | 194 if (event->type() == EventTypeNames::click && event->isMouseEvent() && toMou
seEvent(event)->button() == static_cast<short>(WebPointerProperties::Button::Lef
t)) { |
195 input->setValueForUser(""); | 195 input->setValueForUser(""); |
196 input->setAutofilled(false); | 196 input->setAutofilled(false); |
197 input->onSearch(); | 197 input->onSearch(); |
198 event->setDefaultHandled(); | 198 event->setDefaultHandled(); |
199 } | 199 } |
200 | 200 |
201 if (!event->defaultHandled()) | 201 if (!event->defaultHandled()) |
202 HTMLDivElement::defaultEventHandler(event); | 202 HTMLDivElement::defaultEventHandler(event); |
203 } | 203 } |
204 | 204 |
205 bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents() | 205 bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents() |
206 { | 206 { |
207 const HTMLInputElement* input = toHTMLInputElement(shadowHost()); | 207 const HTMLInputElement* input = toHTMLInputElement(ownerShadowHost()); |
208 if (input && !input->isDisabledOrReadOnly()) | 208 if (input && !input->isDisabledOrReadOnly()) |
209 return true; | 209 return true; |
210 | 210 |
211 return HTMLDivElement::willRespondToMouseClickEvents(); | 211 return HTMLDivElement::willRespondToMouseClickEvents(); |
212 } | 212 } |
213 | 213 |
214 } // namespace blink | 214 } // namespace blink |
OLD | NEW |