void InspectorOverlay::drawNodeHighlight() { if (!m_highlightNode) return; Highlight highlight; buildNodeHighlight(m_highlightNode.get(), m_nodeHighlightConfig, &highlight); if (m_eventTargetNode) { Highlight eventTargetHighlight; buildNodeHighlight(m_eventTargetNode.get(), m_nodeHighlightConfig, &eventTargetHighlight); highlight.quads.append(eventTargetHighlight.quads[1]); // Add border from eventTargetNode to highlight. } RefPtr<InspectorObject> highlightObject = buildObjectForHighlight(highlight); Node* node = m_highlightNode.get(); if (node->isElementNode() && m_nodeHighlightConfig.showInfo && node->renderer() && node->document()->frame()) { RefPtr<InspectorObject> elementInfo = InspectorObject::create(); Element* element = toElement(node); bool isXHTML = element->document()->isXHTMLDocument(); elementInfo->setString("tagName", isXHTML ? element->nodeName() : element->nodeName().lower()); elementInfo->setString("idValue", element->getIdAttribute()); HashSet<AtomicString> usedClassNames; if (element->hasClass() && element->isStyledElement()) { StringBuilder classNames; const SpaceSplitString& classNamesString = static_cast<StyledElement*>(element)->classNames(); size_t classNameCount = classNamesString.size(); for (size_t i = 0; i < classNameCount; ++i) { const AtomicString& className = classNamesString[i]; if (!usedClassNames.add(className).isNewEntry) continue; classNames.append('.'); classNames.append(className); } elementInfo->setString("className", classNames.toString()); } RenderObject* renderer = node->renderer(); Frame* containingFrame = node->document()->frame(); FrameView* containingView = containingFrame->view(); IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRootView(renderer->absoluteBoundingBoxRect())); RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRenderBoxModelObject(renderer) : 0; elementInfo->setString("nodeWidth", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), modelObject) : boundingBox.width())); elementInfo->setString("nodeHeight", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), modelObject) : boundingBox.height())); highlightObject->setObject("elementInfo", elementInfo.release()); } evaluateInOverlay("drawNodeHighlight", highlightObject); }
void InspectorOverlay::getHighlight(Highlight* highlight, InspectorOverlay::CoordinateSystem coordinateSystem) const { if (!m_highlightNode && !m_highlightQuad) return; highlight->type = HighlightTypeRects; if (m_highlightNode) buildNodeHighlight(m_highlightNode.get(), nullptr, m_nodeHighlightConfig, highlight, coordinateSystem); else buildQuadHighlight(*m_highlightQuad, m_quadHighlightConfig, highlight); }
void InspectorOverlay::getHighlight(Highlight* highlight) const { if (!m_highlightNode && !m_highlightQuad) return; highlight->type = HighlightTypeRects; if (m_highlightNode) buildNodeHighlight(m_highlightNode.get(), m_nodeHighlightConfig, highlight); else buildQuadHighlight(m_page, *m_highlightQuad, m_quadHighlightConfig, highlight); }