OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/inspector/InspectorDOMSnapshotAgent.h" | 5 #include "core/inspector/InspectorDOMSnapshotAgent.h" |
6 | 6 |
7 #include "core/InputTypeNames.h" | |
7 #include "core/css/CSSComputedStyleDeclaration.h" | 8 #include "core/css/CSSComputedStyleDeclaration.h" |
8 #include "core/dom/Attribute.h" | 9 #include "core/dom/Attribute.h" |
9 #include "core/dom/AttributeCollection.h" | 10 #include "core/dom/AttributeCollection.h" |
10 #include "core/dom/DOMNodeIds.h" | 11 #include "core/dom/DOMNodeIds.h" |
11 #include "core/dom/Document.h" | 12 #include "core/dom/Document.h" |
12 #include "core/dom/DocumentType.h" | 13 #include "core/dom/DocumentType.h" |
13 #include "core/dom/Element.h" | 14 #include "core/dom/Element.h" |
14 #include "core/dom/Node.h" | 15 #include "core/dom/Node.h" |
15 #include "core/dom/PseudoElement.h" | 16 #include "core/dom/PseudoElement.h" |
16 #include "core/dom/QualifiedName.h" | 17 #include "core/dom/QualifiedName.h" |
17 #include "core/frame/LocalFrame.h" | 18 #include "core/frame/LocalFrame.h" |
18 #include "core/html/HTMLFrameOwnerElement.h" | 19 #include "core/html/HTMLFrameOwnerElement.h" |
20 #include "core/html/HTMLInputElement.h" | |
19 #include "core/html/HTMLLinkElement.h" | 21 #include "core/html/HTMLLinkElement.h" |
22 #include "core/html/HTMLOptionElement.h" | |
20 #include "core/html/HTMLTemplateElement.h" | 23 #include "core/html/HTMLTemplateElement.h" |
24 #include "core/html/HTMLTextAreaElement.h" | |
21 #include "core/inspector/IdentifiersFactory.h" | 25 #include "core/inspector/IdentifiersFactory.h" |
22 #include "core/inspector/InspectedFrames.h" | 26 #include "core/inspector/InspectedFrames.h" |
23 #include "core/inspector/InspectorDOMAgent.h" | 27 #include "core/inspector/InspectorDOMAgent.h" |
24 #include "core/layout/LayoutObject.h" | 28 #include "core/layout/LayoutObject.h" |
25 #include "core/layout/LayoutText.h" | 29 #include "core/layout/LayoutText.h" |
26 #include "core/layout/line/InlineTextBox.h" | 30 #include "core/layout/line/InlineTextBox.h" |
27 #include "platform/wtf/PtrUtil.h" | 31 #include "platform/wtf/PtrUtil.h" |
28 | 32 |
29 namespace blink { | 33 namespace blink { |
30 | 34 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 value->setLayoutNodeIndex(layoutNodeIndex); | 171 value->setLayoutNodeIndex(layoutNodeIndex); |
168 | 172 |
169 if (node->WillRespondToMouseClickEvents()) | 173 if (node->WillRespondToMouseClickEvents()) |
170 value->setIsClickable(true); | 174 value->setIsClickable(true); |
171 | 175 |
172 if (node->IsElementNode()) { | 176 if (node->IsElementNode()) { |
173 Element* element = ToElement(node); | 177 Element* element = ToElement(node); |
174 value->setAttributes(BuildArrayForElementAttributes(element)); | 178 value->setAttributes(BuildArrayForElementAttributes(element)); |
175 | 179 |
176 if (node->IsFrameOwnerElement()) { | 180 if (node->IsFrameOwnerElement()) { |
177 HTMLFrameOwnerElement* frame_owner = ToHTMLFrameOwnerElement(node); | 181 const HTMLFrameOwnerElement* frame_owner = ToHTMLFrameOwnerElement(node); |
178 if (LocalFrame* frame = | 182 if (LocalFrame* frame = |
179 frame_owner->ContentFrame() && | 183 frame_owner->ContentFrame() && |
180 frame_owner->ContentFrame()->IsLocalFrame() | 184 frame_owner->ContentFrame()->IsLocalFrame() |
181 ? ToLocalFrame(frame_owner->ContentFrame()) | 185 ? ToLocalFrame(frame_owner->ContentFrame()) |
182 : nullptr) { | 186 : nullptr) { |
183 value->setFrameId(IdentifiersFactory::FrameId(frame)); | 187 value->setFrameId(IdentifiersFactory::FrameId(frame)); |
184 } | 188 } |
185 if (Document* doc = frame_owner->contentDocument()) { | 189 if (Document* doc = frame_owner->contentDocument()) { |
186 value->setContentDocumentIndex(VisitNode(doc)); | 190 value->setContentDocumentIndex(VisitNode(doc)); |
187 } | 191 } |
188 } | 192 } |
189 | 193 |
190 if (node->parentNode() && node->parentNode()->IsDocumentNode()) { | 194 if (node->parentNode() && node->parentNode()->IsDocumentNode()) { |
191 LocalFrame* frame = node->GetDocument().GetFrame(); | 195 LocalFrame* frame = node->GetDocument().GetFrame(); |
192 if (frame) | 196 if (frame) |
193 value->setFrameId(IdentifiersFactory::FrameId(frame)); | 197 value->setFrameId(IdentifiersFactory::FrameId(frame)); |
194 } | 198 } |
195 | 199 |
196 if (isHTMLLinkElement(*element)) { | 200 if (isHTMLLinkElement(*element)) { |
197 HTMLLinkElement& link_element = toHTMLLinkElement(*element); | 201 const HTMLLinkElement& link_element = toHTMLLinkElement(*element); |
198 if (link_element.IsImport() && link_element.import() && | 202 if (link_element.IsImport() && link_element.import() && |
199 InspectorDOMAgent::InnerParentNode(link_element.import()) == | 203 InspectorDOMAgent::InnerParentNode(link_element.import()) == |
200 link_element) { | 204 link_element) { |
201 value->setImportedDocumentIndex(VisitNode(link_element.import())); | 205 value->setImportedDocumentIndex(VisitNode(link_element.import())); |
202 } | 206 } |
203 } | 207 } |
204 | 208 |
205 if (isHTMLTemplateElement(*element)) { | 209 if (isHTMLTemplateElement(*element)) { |
206 value->setTemplateContentIndex( | 210 value->setTemplateContentIndex( |
207 VisitNode(toHTMLTemplateElement(*element).content())); | 211 VisitNode(toHTMLTemplateElement(*element).content())); |
208 } | 212 } |
209 | 213 |
214 if (isHTMLTextAreaElement(*element)) { | |
215 const HTMLTextAreaElement& text_area_element = | |
216 toHTMLTextAreaElement(*element); | |
217 if (!text_area_element.value().IsEmpty()) | |
pfeldman
2017/07/10 19:00:44
I think you should set it regardless, it can be im
dvallet
2017/07/11 00:26:07
Done.
| |
218 value->setTextValue(text_area_element.value()); | |
219 } | |
220 | |
221 if (isHTMLInputElement(*element)) { | |
222 const HTMLInputElement& input_element = toHTMLInputElement(*element); | |
223 if (!input_element.value().IsEmpty()) | |
224 value->setInputValue(input_element.value()); | |
pfeldman
2017/07/10 19:00:44
I would put it into the else branch and also not c
dvallet
2017/07/11 00:26:07
Radio and checkbox elements can have also values a
| |
225 if ((input_element.type() == InputTypeNames::radio) || | |
226 (input_element.type() == InputTypeNames::checkbox)) { | |
227 value->setInputChecked(input_element.checked()); | |
228 } | |
229 } | |
230 | |
231 if (isHTMLOptionElement(*element)) { | |
232 const HTMLOptionElement& option_element = toHTMLOptionElement(*element); | |
233 value->setInputSelected(option_element.Selected()); | |
234 } | |
235 | |
210 if (element->GetPseudoId()) { | 236 if (element->GetPseudoId()) { |
211 protocol::DOM::PseudoType pseudo_type; | 237 protocol::DOM::PseudoType pseudo_type; |
212 if (InspectorDOMAgent::GetPseudoElementType(element->GetPseudoId(), | 238 if (InspectorDOMAgent::GetPseudoElementType(element->GetPseudoId(), |
213 &pseudo_type)) { | 239 &pseudo_type)) { |
214 value->setPseudoType(pseudo_type); | 240 value->setPseudoType(pseudo_type); |
215 } | 241 } |
216 } else { | 242 } else { |
217 value->setPseudoElementIndexes(VisitPseudoElements(element)); | 243 value->setPseudoElementIndexes(VisitPseudoElements(element)); |
218 } | 244 } |
219 } else if (node->IsDocumentNode()) { | 245 } else if (node->IsDocumentNode()) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 computed_styles_map_->insert(std::move(style), index); | 402 computed_styles_map_->insert(std::move(style), index); |
377 return index; | 403 return index; |
378 } | 404 } |
379 | 405 |
380 DEFINE_TRACE(InspectorDOMSnapshotAgent) { | 406 DEFINE_TRACE(InspectorDOMSnapshotAgent) { |
381 visitor->Trace(inspected_frames_); | 407 visitor->Trace(inspected_frames_); |
382 InspectorBaseAgent::Trace(visitor); | 408 InspectorBaseAgent::Trace(visitor); |
383 } | 409 } |
384 | 410 |
385 } // namespace blink | 411 } // namespace blink |
OLD | NEW |