Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Side by Side Diff: Source/core/html/shadow/TextFieldDecorationElement.cpp

Issue 19510005: [oilpan] Completely move HTMLFormControlElement's hierarchy to the managed heap Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 TextFieldDecorationElement* TextFieldDecorationElement::fromShadowRoot(ShadowRoo t* shadowRoot) 73 TextFieldDecorationElement* TextFieldDecorationElement::fromShadowRoot(ShadowRoo t* shadowRoot)
74 { 74 {
75 if (!shadowRoot->firstChild() 75 if (!shadowRoot->firstChild()
76 || !shadowRoot->firstChild()->lastChild() 76 || !shadowRoot->firstChild()->lastChild()
77 || !shadowRoot->firstChild()->lastChild()->isElementNode() 77 || !shadowRoot->firstChild()->lastChild()->isElementNode()
78 || !toElement(shadowRoot->firstChild()->lastChild())->isTextFieldDecorat ion()) 78 || !toElement(shadowRoot->firstChild()->lastChild())->isTextFieldDecorat ion())
79 return 0; 79 return 0;
80 return toTextFieldDecorationElement(shadowRoot->firstChild()->lastChild()); 80 return toTextFieldDecorationElement(shadowRoot->firstChild()->lastChild());
81 } 81 }
82 82
83 static inline void getDecorationRootAndDecoratedRoot(HTMLInputElement* input, Sh adowRoot*& decorationRoot, ShadowRoot*& decoratedRoot) 83 static inline void getDecorationRootAndDecoratedRoot(Handle<HTMLInputElement> in put, ShadowRoot*& decorationRoot, ShadowRoot*& decoratedRoot)
84 { 84 {
85 ShadowRoot* existingRoot = input->youngestShadowRoot(); 85 ShadowRoot* existingRoot = input->youngestShadowRoot();
86 ShadowRoot* newRoot = 0; 86 ShadowRoot* newRoot = 0;
87 while (existingRoot->childNodeCount() == 1 && existingRoot->firstChild()->ha sTagName(shadowTag)) { 87 while (existingRoot->childNodeCount() == 1 && existingRoot->firstChild()->ha sTagName(shadowTag)) {
88 newRoot = existingRoot; 88 newRoot = existingRoot;
89 existingRoot = existingRoot->olderShadowRoot(); 89 existingRoot = existingRoot->olderShadowRoot();
90 ASSERT(existingRoot); 90 ASSERT(existingRoot);
91 } 91 }
92 if (newRoot) 92 if (newRoot)
93 newRoot->removeChild(newRoot->firstChild()); 93 newRoot->removeChild(newRoot->firstChild());
94 else { 94 else {
95 // FIXME: This interacts really badly with author shadow roots because n ow 95 // FIXME: This interacts really badly with author shadow roots because n ow
96 // we can interleave user agent and author shadow roots on the element m eaning 96 // we can interleave user agent and author shadow roots on the element m eaning
97 // input.shadowRoot may be inaccessible if the browser has decided to de corate 97 // input.shadowRoot may be inaccessible if the browser has decided to de corate
98 // the input. 98 // the input.
99 newRoot = input->ensureShadow()->addShadowRoot(input, ShadowRoot::UserAg entShadowRoot); 99 newRoot = input->ensureShadow()->addShadowRoot(input.raw(), ShadowRoot:: UserAgentShadowRoot);
100 } 100 }
101 decorationRoot = newRoot; 101 decorationRoot = newRoot;
102 decoratedRoot = existingRoot; 102 decoratedRoot = existingRoot;
103 } 103 }
104 104
105 void TextFieldDecorationElement::decorate(HTMLInputElement* input, bool visible) 105 void TextFieldDecorationElement::decorate(Handle<HTMLInputElement> input, bool v isible)
106 { 106 {
107 ASSERT(input); 107 ASSERT(input);
108 ShadowRoot* existingRoot; 108 ShadowRoot* existingRoot;
109 ShadowRoot* decorationRoot; 109 ShadowRoot* decorationRoot;
110 getDecorationRootAndDecoratedRoot(input, decorationRoot, existingRoot); 110 getDecorationRootAndDecoratedRoot(input, decorationRoot, existingRoot);
111 ASSERT(decorationRoot); 111 ASSERT(decorationRoot);
112 ASSERT(existingRoot); 112 ASSERT(existingRoot);
113 RefPtr<HTMLDivElement> box = HTMLDivElement::create(input->document()); 113 RefPtr<HTMLDivElement> box = HTMLDivElement::create(input->document());
114 decorationRoot->appendChild(box); 114 decorationRoot->appendChild(box);
115 box->setInlineStyleProperty(CSSPropertyDisplay, CSSValueWebkitFlex); 115 box->setInlineStyleProperty(CSSPropertyDisplay, CSSValueWebkitFlex);
116 box->setInlineStyleProperty(CSSPropertyWebkitAlignItems, CSSValueCenter); 116 box->setInlineStyleProperty(CSSPropertyWebkitAlignItems, CSSValueCenter);
117 ASSERT(existingRoot->childNodeCount() == 1); 117 ASSERT(existingRoot->childNodeCount() == 1);
118 toHTMLElement(existingRoot->firstChild())->setInlineStyleProperty(CSSPropert yWebkitFlexGrow, 1.0, CSSPrimitiveValue::CSS_NUMBER); 118 toHTMLElement(existingRoot->firstChild())->setInlineStyleProperty(CSSPropert yWebkitFlexGrow, 1.0, CSSPrimitiveValue::CSS_NUMBER);
119 box->appendChild(HTMLShadowElement::create(HTMLNames::shadowTag, input->docu ment())); 119 box->appendChild(HTMLShadowElement::create(HTMLNames::shadowTag, input->docu ment()));
120 setInlineStyleProperty(CSSPropertyDisplay, visible ? CSSValueBlock : CSSValu eNone); 120 setInlineStyleProperty(CSSPropertyDisplay, visible ? CSSValueBlock : CSSValu eNone);
121 box->appendChild(this); 121 box->appendChild(this);
122 } 122 }
123 123
124 inline HTMLInputElement* TextFieldDecorationElement::hostInput() 124 inline Result<HTMLInputElement> TextFieldDecorationElement::hostInput()
125 { 125 {
126 // TextFieldDecorationElement is created only by C++ code, and it is always 126 // TextFieldDecorationElement is created only by C++ code, and it is always
127 // in <input> shadow. 127 // in <input> shadow.
128 ASSERT_WITH_SECURITY_IMPLICATION(!shadowHost() || shadowHost()->hasTagName(i nputTag)); 128 ASSERT_WITH_SECURITY_IMPLICATION(!shadowHost() || shadowHost()->hasTagName(i nputTag));
129 return static_cast<HTMLInputElement*>(shadowHost()); 129 return Handle<HTMLInputElement>(static_cast<HTMLInputElement*>(shadowHost()) );
130 } 130 }
131 131
132 bool TextFieldDecorationElement::isTextFieldDecoration() const 132 bool TextFieldDecorationElement::isTextFieldDecoration() const
133 { 133 {
134 return true; 134 return true;
135 } 135 }
136 136
137 void TextFieldDecorationElement::updateImage() 137 void TextFieldDecorationElement::updateImage()
138 { 138 {
139 if (!renderer() || !renderer()->isImage()) 139 if (!renderer() || !renderer()->isImage())
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 HTMLDivElement::detach(); 183 HTMLDivElement::detach();
184 } 184 }
185 185
186 bool TextFieldDecorationElement::isMouseFocusable() const 186 bool TextFieldDecorationElement::isMouseFocusable() const
187 { 187 {
188 return false; 188 return false;
189 } 189 }
190 190
191 void TextFieldDecorationElement::defaultEventHandler(Event* event) 191 void TextFieldDecorationElement::defaultEventHandler(Event* event)
192 { 192 {
193 RefPtr<HTMLInputElement> input(hostInput()); 193 Handle<HTMLInputElement> input(hostInput());
194 if (!input || input->isDisabledOrReadOnly() || !event->isMouseEvent()) { 194 if (!input || input->isDisabledOrReadOnly() || !event->isMouseEvent()) {
195 if (!event->defaultHandled()) 195 if (!event->defaultHandled())
196 HTMLDivElement::defaultEventHandler(event); 196 HTMLDivElement::defaultEventHandler(event);
197 return; 197 return;
198 } 198 }
199 199
200 RefPtr<TextFieldDecorationElement> protector(this); 200 RefPtr<TextFieldDecorationElement> protector(this);
201 if (event->type() == eventNames().clickEvent) { 201 if (event->type() == eventNames().clickEvent) {
202 m_textFieldDecorator->handleClick(input.get()); 202 m_textFieldDecorator->handleClick(input);
203 event->setDefaultHandled(); 203 event->setDefaultHandled();
204 } 204 }
205 205
206 if (event->type() == eventNames().mouseoverEvent) { 206 if (event->type() == eventNames().mouseoverEvent) {
207 m_isInHoverState = true; 207 m_isInHoverState = true;
208 updateImage(); 208 updateImage();
209 } 209 }
210 210
211 if (event->type() == eventNames().mouseoutEvent) { 211 if (event->type() == eventNames().mouseoutEvent) {
212 m_isInHoverState = false; 212 m_isInHoverState = false;
213 updateImage(); 213 updateImage();
214 } 214 }
215 215
216 if (!event->defaultHandled()) 216 if (!event->defaultHandled())
217 HTMLDivElement::defaultEventHandler(event); 217 HTMLDivElement::defaultEventHandler(event);
218 } 218 }
219 219
220 bool TextFieldDecorationElement::willRespondToMouseMoveEvents() 220 bool TextFieldDecorationElement::willRespondToMouseMoveEvents()
221 { 221 {
222 const HTMLInputElement* input = hostInput(); 222 Handle<const HTMLInputElement> input = hostInput();
223 if (!input->isDisabledOrReadOnly()) 223 if (!input->isDisabledOrReadOnly())
224 return true; 224 return true;
225 225
226 return HTMLDivElement::willRespondToMouseMoveEvents(); 226 return HTMLDivElement::willRespondToMouseMoveEvents();
227 } 227 }
228 228
229 bool TextFieldDecorationElement::willRespondToMouseClickEvents() 229 bool TextFieldDecorationElement::willRespondToMouseClickEvents()
230 { 230 {
231 const HTMLInputElement* input = hostInput(); 231 Handle<const HTMLInputElement> input = hostInput();
232 if (!input->isDisabledOrReadOnly()) 232 if (!input->isDisabledOrReadOnly())
233 return true; 233 return true;
234 234
235 return HTMLDivElement::willRespondToMouseClickEvents(); 235 return HTMLDivElement::willRespondToMouseClickEvents();
236 } 236 }
237 237
238 } // namespace WebCore 238 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/shadow/TextFieldDecorationElement.h ('k') | Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698