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 11 matching lines...) Expand all Loading... |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/html/shadow/TextControlInnerElements.h" | 28 #include "core/html/shadow/TextControlInnerElements.h" |
29 | 29 |
30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
32 #include "core/dom/NodeLayoutStyle.h" | 32 #include "core/dom/NodeComputedStyle.h" |
33 #include "core/events/MouseEvent.h" | 33 #include "core/events/MouseEvent.h" |
34 #include "core/events/TextEvent.h" | 34 #include "core/events/TextEvent.h" |
35 #include "core/events/TextEventInputType.h" | 35 #include "core/events/TextEventInputType.h" |
36 #include "core/frame/LocalFrame.h" | 36 #include "core/frame/LocalFrame.h" |
37 #include "core/html/HTMLInputElement.h" | 37 #include "core/html/HTMLInputElement.h" |
38 #include "core/html/shadow/ShadowElementNames.h" | 38 #include "core/html/shadow/ShadowElementNames.h" |
39 #include "core/layout/LayoutTextControlSingleLine.h" | 39 #include "core/layout/LayoutTextControlSingleLine.h" |
40 #include "core/layout/LayoutView.h" | 40 #include "core/layout/LayoutView.h" |
41 #include "core/page/EventHandler.h" | 41 #include "core/page/EventHandler.h" |
42 #include "platform/UserGestureIndicator.h" | 42 #include "platform/UserGestureIndicator.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 using namespace HTMLNames; | 46 using namespace HTMLNames; |
47 | 47 |
48 TextControlInnerContainer::TextControlInnerContainer(Document& document) | 48 TextControlInnerContainer::TextControlInnerContainer(Document& document) |
49 : HTMLDivElement(document) | 49 : HTMLDivElement(document) |
50 { | 50 { |
51 } | 51 } |
52 | 52 |
53 PassRefPtrWillBeRawPtr<TextControlInnerContainer> TextControlInnerContainer::cre
ate(Document& document) | 53 PassRefPtrWillBeRawPtr<TextControlInnerContainer> TextControlInnerContainer::cre
ate(Document& document) |
54 { | 54 { |
55 RefPtrWillBeRawPtr<TextControlInnerContainer> element = adoptRefWillBeNoop(n
ew TextControlInnerContainer(document)); | 55 RefPtrWillBeRawPtr<TextControlInnerContainer> element = adoptRefWillBeNoop(n
ew TextControlInnerContainer(document)); |
56 element->setAttribute(idAttr, ShadowElementNames::textFieldContainer()); | 56 element->setAttribute(idAttr, ShadowElementNames::textFieldContainer()); |
57 return element.release(); | 57 return element.release(); |
58 } | 58 } |
59 | 59 |
60 LayoutObject* TextControlInnerContainer::createLayoutObject(const LayoutStyle&) | 60 LayoutObject* TextControlInnerContainer::createLayoutObject(const ComputedStyle&
) |
61 { | 61 { |
62 return new LayoutTextControlInnerContainer(this); | 62 return new LayoutTextControlInnerContainer(this); |
63 } | 63 } |
64 | 64 |
65 // --------------------------- | 65 // --------------------------- |
66 | 66 |
67 EditingViewPortElement::EditingViewPortElement(Document& document) | 67 EditingViewPortElement::EditingViewPortElement(Document& document) |
68 : HTMLDivElement(document) | 68 : HTMLDivElement(document) |
69 { | 69 { |
70 setHasCustomStyleCallbacks(); | 70 setHasCustomStyleCallbacks(); |
71 } | 71 } |
72 | 72 |
73 PassRefPtrWillBeRawPtr<EditingViewPortElement> EditingViewPortElement::create(Do
cument& document) | 73 PassRefPtrWillBeRawPtr<EditingViewPortElement> EditingViewPortElement::create(Do
cument& document) |
74 { | 74 { |
75 RefPtrWillBeRawPtr<EditingViewPortElement> element = adoptRefWillBeNoop(new
EditingViewPortElement(document)); | 75 RefPtrWillBeRawPtr<EditingViewPortElement> element = adoptRefWillBeNoop(new
EditingViewPortElement(document)); |
76 element->setAttribute(idAttr, ShadowElementNames::editingViewPort()); | 76 element->setAttribute(idAttr, ShadowElementNames::editingViewPort()); |
77 return element.release(); | 77 return element.release(); |
78 } | 78 } |
79 | 79 |
80 PassRefPtr<LayoutStyle> 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<LayoutStyle> style = LayoutStyle::create(); | 84 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
85 style->inheritFrom(shadowHost()->layoutStyleRef()); | 85 style->inheritFrom(shadowHost()->computedStyleRef()); |
86 | 86 |
87 style->setFlexGrow(1); | 87 style->setFlexGrow(1); |
88 style->setDisplay(BLOCK); | 88 style->setDisplay(BLOCK); |
89 style->setDirection(LTR); | 89 style->setDirection(LTR); |
90 | 90 |
91 // We don't want the shadow dom to be editable, so we set this block to | 91 // We don't want the shadow dom to be editable, so we set this block to |
92 // read-only in case the input itself is editable. | 92 // read-only in case the input itself is editable. |
93 style->setUserModify(READ_ONLY); | 93 style->setUserModify(READ_ONLY); |
94 style->setUnique(); | 94 style->setUnique(); |
95 | 95 |
(...skipping 27 matching lines...) Expand all Loading... |
123 // cause events to be sent to the TextControlInnerTextElement. To | 123 // cause events to be sent to the TextControlInnerTextElement. To |
124 // prevent an infinite loop, we must check for this case before sending | 124 // prevent an infinite loop, we must check for this case before sending |
125 // the event up the chain. | 125 // the event up the chain. |
126 if (shadowAncestor) | 126 if (shadowAncestor) |
127 shadowAncestor->defaultEventHandler(event); | 127 shadowAncestor->defaultEventHandler(event); |
128 } | 128 } |
129 if (!event->defaultHandled()) | 129 if (!event->defaultHandled()) |
130 HTMLDivElement::defaultEventHandler(event); | 130 HTMLDivElement::defaultEventHandler(event); |
131 } | 131 } |
132 | 132 |
133 LayoutObject* TextControlInnerEditorElement::createLayoutObject(const LayoutStyl
e&) | 133 LayoutObject* TextControlInnerEditorElement::createLayoutObject(const ComputedSt
yle&) |
134 { | 134 { |
135 return new LayoutTextControlInnerBlock(this); | 135 return new LayoutTextControlInnerBlock(this); |
136 } | 136 } |
137 | 137 |
138 PassRefPtr<LayoutStyle> TextControlInnerEditorElement::customStyleForLayoutObjec
t() | 138 PassRefPtr<ComputedStyle> TextControlInnerEditorElement::customStyleForLayoutObj
ect() |
139 { | 139 { |
140 LayoutObject* parentRenderer = shadowHost()->layoutObject(); | 140 LayoutObject* parentRenderer = shadowHost()->layoutObject(); |
141 if (!parentRenderer || !parentRenderer->isTextControl()) | 141 if (!parentRenderer || !parentRenderer->isTextControl()) |
142 return originalStyleForLayoutObject(); | 142 return originalStyleForLayoutObject(); |
143 LayoutTextControl* textControlRenderer = toLayoutTextControl(parentRenderer)
; | 143 LayoutTextControl* textControlRenderer = toLayoutTextControl(parentRenderer)
; |
144 return textControlRenderer->createInnerEditorStyle(textControlRenderer->styl
eRef()); | 144 return textControlRenderer->createInnerEditorStyle(textControlRenderer->styl
eRef()); |
145 } | 145 } |
146 | 146 |
147 // ---------------------------- | 147 // ---------------------------- |
148 | 148 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents() | 243 bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents() |
244 { | 244 { |
245 const HTMLInputElement* input = toHTMLInputElement(shadowHost()); | 245 const HTMLInputElement* input = toHTMLInputElement(shadowHost()); |
246 if (input && !input->isDisabledOrReadOnly()) | 246 if (input && !input->isDisabledOrReadOnly()) |
247 return true; | 247 return true; |
248 | 248 |
249 return HTMLDivElement::willRespondToMouseClickEvents(); | 249 return HTMLDivElement::willRespondToMouseClickEvents(); |
250 } | 250 } |
251 | 251 |
252 } | 252 } |
OLD | NEW |