Ejemplo n.º 1
0
void InspectorOverlay::drawNodeHighlight()
{
    if (!m_highlightNode)
        return;

    String selectors = m_nodeHighlightConfig.selectorList;
    RefPtrWillBeRawPtr<StaticElementList> elements = nullptr;
    TrackExceptionState exceptionState;
    ContainerNode* queryBase = m_highlightNode->containingShadowRoot();
    if (!queryBase)
        queryBase = m_highlightNode->ownerDocument();
    if (selectors.length())
        elements = queryBase->querySelectorAll(AtomicString(selectors), exceptionState);
    if (elements && !exceptionState.hadException()) {
        for (unsigned i = 0; i < elements->length(); ++i) {
            Element* element = elements->item(i);
            InspectorHighlight highlight(element, m_nodeHighlightConfig, false);
            RefPtr<JSONObject> highlightJSON = highlight.asJSONObject();
            evaluateInOverlay("drawHighlight", highlightJSON.release());
        }
    }

    bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highlightNode->document().frame();
    InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, appendElementInfo);
    if (m_eventTargetNode)
        highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighlightConfig);

    RefPtr<JSONObject> highlightJSON = highlight.asJSONObject();
    evaluateInOverlay("drawHighlight", highlightJSON.release());
}
Ejemplo n.º 2
0
void InspectorOverlay::drawNodeHighlight() {
  if (!m_highlightNode)
    return;

  String selectors = m_nodeHighlightConfig.selectorList;
  StaticElementList* elements = nullptr;
  DummyExceptionStateForTesting exceptionState;
  ContainerNode* queryBase = m_highlightNode->containingShadowRoot();
  if (!queryBase)
    queryBase = m_highlightNode->ownerDocument();
  if (selectors.length())
    elements =
        queryBase->querySelectorAll(AtomicString(selectors), exceptionState);
  if (elements && !exceptionState.hadException()) {
    for (unsigned i = 0; i < elements->length(); ++i) {
      Element* element = elements->item(i);
      InspectorHighlight highlight(element, m_nodeHighlightConfig, false);
      std::unique_ptr<protocol::DictionaryValue> highlightJSON =
          highlight.asProtocolValue();
      evaluateInOverlay("drawHighlight", std::move(highlightJSON));
    }
  }

  bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip &&
                           m_nodeHighlightConfig.showInfo &&
                           m_highlightNode->layoutObject() &&
                           m_highlightNode->document().frame();
  InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig,
                               appendElementInfo);
  if (m_eventTargetNode)
    highlight.appendEventTargetQuads(m_eventTargetNode.get(),
                                     m_nodeHighlightConfig);

  std::unique_ptr<protocol::DictionaryValue> highlightJSON =
      highlight.asProtocolValue();
  evaluateInOverlay("drawHighlight", std::move(highlightJSON));
}