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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp

Issue 2413693002: Rename DOM.getLayoutTreeNodes to CSS.getLayoutTreeAndStyles (Closed)
Patch Set: Fix iframe path and drop font-family from test since it's different on mac Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 v8::Local<v8::Value> nodeV8Value(v8::Local<v8::Context> context, Node* node) { 132 v8::Local<v8::Value> nodeV8Value(v8::Local<v8::Context> context, Node* node) {
133 v8::Isolate* isolate = context->GetIsolate(); 133 v8::Isolate* isolate = context->GetIsolate();
134 if (!node || 134 if (!node ||
135 !BindingSecurity::shouldAllowAccessTo( 135 !BindingSecurity::shouldAllowAccessTo(
136 currentDOMWindow(isolate), node, 136 currentDOMWindow(isolate), node,
137 BindingSecurity::ErrorReportOption::DoNotReport)) 137 BindingSecurity::ErrorReportOption::DoNotReport))
138 return v8::Null(isolate); 138 return v8::Null(isolate);
139 return toV8(node, context->Global(), isolate); 139 return toV8(node, context->Global(), isolate);
140 } 140 }
141 141
142 std::unique_ptr<protocol::DOM::Rect> buildRectForFloatRect(
143 const FloatRect& rect) {
144 return protocol::DOM::Rect::create()
145 .setX(rect.x())
146 .setY(rect.y())
147 .setWidth(rect.width())
148 .setHeight(rect.height())
149 .build();
150 }
151
152 } // namespace 142 } // namespace
153 143
154 class InspectorRevalidateDOMTask final 144 class InspectorRevalidateDOMTask final
155 : public GarbageCollectedFinalized<InspectorRevalidateDOMTask> { 145 : public GarbageCollectedFinalized<InspectorRevalidateDOMTask> {
156 public: 146 public:
157 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*); 147 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*);
158 void scheduleStyleAttrRevalidationFor(Element*); 148 void scheduleStyleAttrRevalidationFor(Element*);
159 void reset() { m_timer.stop(); } 149 void reset() { m_timer.stop(); }
160 void onTimer(TimerBase*); 150 void onTimer(TimerBase*);
161 DECLARE_TRACE(); 151 DECLARE_TRACE();
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 524
535 int sanitizedDepth = depth.fromMaybe(2); 525 int sanitizedDepth = depth.fromMaybe(2);
536 if (sanitizedDepth == -1) 526 if (sanitizedDepth == -1)
537 sanitizedDepth = INT_MAX; 527 sanitizedDepth = INT_MAX;
538 528
539 *root = buildObjectForNode(m_document.get(), sanitizedDepth, 529 *root = buildObjectForNode(m_document.get(), sanitizedDepth,
540 traverseFrames.fromMaybe(false), 530 traverseFrames.fromMaybe(false),
541 m_documentNodeToIdMap.get()); 531 m_documentNodeToIdMap.get());
542 } 532 }
543 533
544 void InspectorDOMAgent::getLayoutTreeNodes(
545 ErrorString* errorString,
546 std::unique_ptr<protocol::Array<protocol::DOM::LayoutTreeNode>>*
547 layoutTreeNodes) {
548 layoutTreeNodes->reset(new protocol::Array<protocol::DOM::LayoutTreeNode>);
549 visitLayoutTreeNodes(m_document.get(), *layoutTreeNodes->get());
550 }
551
552 void InspectorDOMAgent::visitLayoutTreeNodes(
553 Node* node,
554 protocol::Array<protocol::DOM::LayoutTreeNode>& layoutTreeNodes) {
555 for (; node; node = NodeTraversal::next(*node)) {
556 // Visit shadow dom nodes.
557 if (node->isElementNode()) {
558 const Element* element = toElement(node);
559 ElementShadow* elementShadow = element->shadow();
560 if (elementShadow) {
561 visitLayoutTreeNodes(&elementShadow->youngestShadowRoot(),
562 layoutTreeNodes);
563 }
564 }
565
566 // Pierce iframe boundaries.
567 if (node->isFrameOwnerElement()) {
568 visitLayoutTreeNodes(
569 toHTMLFrameOwnerElement(node)->contentDocument()->documentElement(),
570 layoutTreeNodes);
571 }
572
573 LayoutObject* layoutObject = node->layoutObject();
574 if (!layoutObject)
575 continue;
576
577 int backendNodeId = DOMNodeIds::idForNode(node);
578 std::unique_ptr<protocol::DOM::LayoutTreeNode> layoutTreeNode =
579 protocol::DOM::LayoutTreeNode::create()
580 .setBackendNodeId(backendNodeId)
581 .setBoundingBox(buildRectForFloatRect(
582 node->isElementNode()
583 ? FloatRect(toElement(node)->boundsInViewport())
584 : layoutObject->absoluteBoundingBoxRect()))
585 .build();
586
587 if (layoutObject->isText()) {
588 LayoutText* layoutText = toLayoutText(layoutObject);
589 layoutTreeNode->setLayoutText(layoutText->text());
590 if (layoutText->hasTextBoxes()) {
591 std::unique_ptr<protocol::Array<protocol::DOM::InlineTextBox>>
592 inlineTextNodes(
593 new protocol::Array<protocol::DOM::InlineTextBox>());
594 for (const InlineTextBox* textBox = layoutText->firstTextBox(); textBox;
595 textBox = textBox->nextTextBox()) {
596 FloatRect localCoordsTextBoxRect(textBox->calculateBoundaries());
597 FloatRect absoluteCoordsTextBoxRect =
598 layoutObject->localToAbsoluteQuad(localCoordsTextBoxRect)
599 .boundingBox();
600 inlineTextNodes->addItem(protocol::DOM::InlineTextBox::create()
601 .setStartCharacterIndex(textBox->start())
602 .setNumCharacters(textBox->len())
603 .setBoundingBox(buildRectForFloatRect(
604 absoluteCoordsTextBoxRect))
605 .build());
606 }
607 layoutTreeNode->setInlineTextNodes(std::move(inlineTextNodes));
608 }
609 }
610
611 layoutTreeNodes.addItem(std::move(layoutTreeNode));
612 }
613 }
614
615 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, 534 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId,
616 int depth, 535 int depth,
617 bool traverseFrames) { 536 bool traverseFrames) {
618 Node* node = nodeForId(nodeId); 537 Node* node = nodeForId(nodeId);
619 if (!node || (!node->isElementNode() && !node->isDocumentNode() && 538 if (!node || (!node->isElementNode() && !node->isDocumentNode() &&
620 !node->isDocumentFragment())) 539 !node->isDocumentFragment()))
621 return; 540 return;
622 541
623 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); 542 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId);
624 543
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after
2391 visitor->trace(m_idToNodesMap); 2310 visitor->trace(m_idToNodesMap);
2392 visitor->trace(m_document); 2311 visitor->trace(m_document);
2393 visitor->trace(m_revalidateTask); 2312 visitor->trace(m_revalidateTask);
2394 visitor->trace(m_searchResults); 2313 visitor->trace(m_searchResults);
2395 visitor->trace(m_history); 2314 visitor->trace(m_history);
2396 visitor->trace(m_domEditor); 2315 visitor->trace(m_domEditor);
2397 InspectorBaseAgent::trace(visitor); 2316 InspectorBaseAgent::trace(visitor);
2398 } 2317 }
2399 2318
2400 } // namespace blink 2319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698