| 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 value->setTextValue(text_area_element.value()); |
| 218 } |
| 219 |
| 220 if (isHTMLInputElement(*element)) { |
| 221 const HTMLInputElement& input_element = toHTMLInputElement(*element); |
| 222 value->setInputValue(input_element.value()); |
| 223 if ((input_element.type() == InputTypeNames::radio) || |
| 224 (input_element.type() == InputTypeNames::checkbox)) { |
| 225 value->setInputChecked(input_element.checked()); |
| 226 } |
| 227 } |
| 228 |
| 229 if (isHTMLOptionElement(*element)) { |
| 230 const HTMLOptionElement& option_element = toHTMLOptionElement(*element); |
| 231 value->setOptionSelected(option_element.Selected()); |
| 232 } |
| 233 |
| 210 if (element->GetPseudoId()) { | 234 if (element->GetPseudoId()) { |
| 211 protocol::DOM::PseudoType pseudo_type; | 235 protocol::DOM::PseudoType pseudo_type; |
| 212 if (InspectorDOMAgent::GetPseudoElementType(element->GetPseudoId(), | 236 if (InspectorDOMAgent::GetPseudoElementType(element->GetPseudoId(), |
| 213 &pseudo_type)) { | 237 &pseudo_type)) { |
| 214 value->setPseudoType(pseudo_type); | 238 value->setPseudoType(pseudo_type); |
| 215 } | 239 } |
| 216 } else { | 240 } else { |
| 217 value->setPseudoElementIndexes(VisitPseudoElements(element)); | 241 value->setPseudoElementIndexes(VisitPseudoElements(element)); |
| 218 } | 242 } |
| 219 } else if (node->IsDocumentNode()) { | 243 } 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); | 400 computed_styles_map_->insert(std::move(style), index); |
| 377 return index; | 401 return index; |
| 378 } | 402 } |
| 379 | 403 |
| 380 DEFINE_TRACE(InspectorDOMSnapshotAgent) { | 404 DEFINE_TRACE(InspectorDOMSnapshotAgent) { |
| 381 visitor->Trace(inspected_frames_); | 405 visitor->Trace(inspected_frames_); |
| 382 InspectorBaseAgent::Trace(visitor); | 406 InspectorBaseAgent::Trace(visitor); |
| 383 } | 407 } |
| 384 | 408 |
| 385 } // namespace blink | 409 } // namespace blink |
| OLD | NEW |