Example #1
0
PassRefPtr<InspectorObject> InspectorPageAgent::buildObjectForFrameTree(Frame* frame)
{
    RefPtr<InspectorObject> result = InspectorObject::create();
    RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame);
    result->setObject("frame", frameObject);

    RefPtr<InspectorArray> subresources = InspectorArray::create();
    result->setArray("resources", subresources);

    Vector<CachedResource*> allResources = cachedResourcesForFrame(frame);
    for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) {
        CachedResource* cachedResource = *it;
        RefPtr<InspectorObject> resourceObject = InspectorObject::create();
        resourceObject->setString("url", cachedResource->url());
        resourceObject->setString("type", cachedResourceTypeString(*cachedResource));
        resourceObject->setString("mimeType", cachedResource->response().mimeType());
        subresources->pushValue(resourceObject);
    }

    RefPtr<InspectorArray> childrenArray;
    for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
        if (!childrenArray) {
            childrenArray = InspectorArray::create();
            result->setArray("childFrames", childrenArray);
        }
        childrenArray->pushObject(buildObjectForFrameTree(child));
    }
    return result;
}
Example #2
0
void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager)
{
    RefPtr<InspectorObject> jsonObj = InspectorObject::create();
    jsonObj->setString("source", messageSourceValue(m_source));
    // FIXME: only send out type for ConsoleAPI source messages.
    jsonObj->setString("type", messageTypeValue(m_type));
    jsonObj->setString("level", messageLevelValue(m_level));
    jsonObj->setNumber("line", static_cast<int>(m_line));
    jsonObj->setString("url", m_url);
    jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
    jsonObj->setString("text", m_message);
    if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
        jsonObj->setString("networkRequestId", m_requestId);
    if (m_arguments && m_arguments->argumentCount()) {
        InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
        if (!injectedScript.hasNoValue()) {
            RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
            for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
                RefPtr<InspectorValue> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console");
                if (!inspectorValue) {
                    ASSERT_NOT_REACHED();
                    return;
                }
                jsonArgs->pushValue(inspectorValue);
            }
            jsonObj->setArray("parameters", jsonArgs);
        }
    }
    if (m_callStack)
        jsonObj->setArray("stackTrace", m_callStack->buildInspectorArray());
    frontend->messageAdded(jsonObj);
}
Example #3
0
PassRefPtr<InspectorObject> HeapGraphSerializer::serialize()
{
    adjutEdgeTargets();
    RefPtr<InspectorArray> nodes = InspectorArray::create();
    for (size_t i = 0; i < m_nodes.size(); i++) {
        HeapGraphNode& node = m_nodes[i];
        nodes->pushInt(node.m_type);
        nodes->pushInt(node.m_size);
        nodes->pushInt(node.m_className);
        nodes->pushInt(node.m_name);
        nodes->pushInt(node.m_edgeCount);
    }
    RefPtr<InspectorArray> edges = InspectorArray::create();
    for (size_t i = 0; i < m_edges.size(); i++) {
        HeapGraphEdge& edge = m_edges[i];
        edges->pushInt(edge.m_type);
        edges->pushInt(edge.m_toIndex);
        edges->pushInt(edge.m_name);
    }
    RefPtr<InspectorArray> strings = InspectorArray::create();
    for (size_t i = 0; i < m_strings.size(); i++)
        strings->pushString(m_strings[i]);

    RefPtr<InspectorObject> graph = InspectorObject::create();
    graph->setArray("nodes", nodes);
    graph->setArray("edges", edges);
    graph->setArray("strings", strings);
    return graph.release();
}
Example #4
0
void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost)
{
    RefPtr<InspectorObject> jsonObj = InspectorObject::create();
    jsonObj->setNumber("source", static_cast<int>(m_source));
    jsonObj->setNumber("type", static_cast<int>(m_type));
    jsonObj->setNumber("level", static_cast<int>(m_level));
    jsonObj->setNumber("line", static_cast<int>(m_line));
    jsonObj->setString("url", m_url);
    jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
    jsonObj->setString("message", m_message);
    if (m_type == NetworkErrorMessageType) 
        jsonObj->setNumber("requestId", m_requestId);
    if (m_arguments && m_arguments->argumentCount()) {
        InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_arguments->globalState());
        if (!injectedScript.hasNoValue()) {
            RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
            for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
                RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments->argumentAt(i));
                if (!inspectorValue) {
                    ASSERT_NOT_REACHED();
                    return;
                }
                jsonArgs->pushValue(inspectorValue);
            }
            jsonObj->setArray("parameters", jsonArgs);
        }
    }
    if (m_callStack)
        jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject());
    frontend->addConsoleMessage(jsonObj);
}
static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame)
{
    RefPtr<InspectorObject> result = InspectorObject::create();
    RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame);
    result->setObject("frame", frameObject);

    RefPtr<InspectorArray> subresources = InspectorArray::create();
    result->setArray("resources", subresources);
    const CachedResourceLoader::DocumentResourceMap& allResources = frame->document()->cachedResourceLoader()->allCachedResources();
    CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
    for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
        CachedResource* cachedResource = it->second.get();
        RefPtr<InspectorObject> resourceObject = InspectorObject::create();
        resourceObject->setString("url", cachedResource->url());
        resourceObject->setString("type", cachedResourceTypeString(*cachedResource));
        subresources->pushValue(resourceObject);
    }

    RefPtr<InspectorArray> childrenArray;
    for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
        if (!childrenArray) {
            childrenArray = InspectorArray::create();
            result->setArray("childFrames", childrenArray);
        }
        childrenArray->pushObject(buildObjectForFrameTree(child));
    }
    return result;
}
void InspectorCSSAgent::getStylesForNode(long nodeId, RefPtr<InspectorValue>* result)
{
    Element* element = elementForId(nodeId);
    if (!element)
        return;

    RefPtr<InspectorObject> resultObject = InspectorObject::create();

    InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(element);
    if (styleSheet)
        resultObject->setObject("inlineStyle", styleSheet->buildObjectForStyle(element->style()));

    RefPtr<CSSComputedStyleDeclaration> computedStyleInfo = computedStyle(element, true); // Support the viewing of :visited information in computed style.
    RefPtr<InspectorStyle> computedInspectorStyle = InspectorStyle::create(InspectorCSSId(), computedStyleInfo, 0);
    resultObject->setObject("computedStyle", computedInspectorStyle->buildObjectForStyle());

    CSSStyleSelector* selector = element->ownerDocument()->styleSelector();
    RefPtr<CSSRuleList> matchedRules = selector->styleRulesForElement(element, false, true);
    resultObject->setArray("matchedCSSRules", buildArrayForRuleList(matchedRules.get()));

    resultObject->setObject("styleAttributes", buildObjectForAttributeStyles(element));

    RefPtr<InspectorArray> pseudoElements = InspectorArray::create();
    for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_INTERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) {
        RefPtr<CSSRuleList> matchedRules = selector->pseudoStyleRulesForElement(element, pseudoId, false, true);
        if (matchedRules && matchedRules->length()) {
            RefPtr<InspectorObject> pseudoStyles = InspectorObject::create();
            pseudoStyles->setNumber("pseudoId", static_cast<int>(pseudoId));
            pseudoStyles->setArray("rules", buildArrayForRuleList(matchedRules.get()));
            pseudoElements->pushObject(pseudoStyles.release());
        }
    }
    resultObject->setArray("pseudoElements", pseudoElements.release());

    RefPtr<InspectorArray> inheritedStyles = InspectorArray::create();
    Element* parentElement = element->parentElement();
    while (parentElement) {
        RefPtr<InspectorObject> parentStyle = InspectorObject::create();
        if (parentElement->style() && parentElement->style()->length()) {
            InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(parentElement);
            if (styleSheet)
                parentStyle->setObject("inlineStyle", styleSheet->buildObjectForStyle(styleSheet->styleForId(InspectorCSSId(styleSheet->id(), 0))));
        }

        CSSStyleSelector* parentSelector = parentElement->ownerDocument()->styleSelector();
        RefPtr<CSSRuleList> parentMatchedRules = parentSelector->styleRulesForElement(parentElement, false, true);
        parentStyle->setArray("matchedCSSRules", buildArrayForRuleList(parentMatchedRules.get()));
        inheritedStyles->pushObject(parentStyle.release());
        parentElement = parentElement->parentElement();
    }
    resultObject->setArray("inherited", inheritedStyles.release());

    *result = resultObject.release();
}
Example #7
0
void InspectorFrontend::Database::sqlTransactionSucceeded(int transactionId, PassRefPtr<InspectorArray> columnNames, PassRefPtr<InspectorArray> values)
{
    RefPtr<InspectorObject> sqlTransactionSucceededMessage = InspectorObject::create();
    sqlTransactionSucceededMessage->setString("method", "Database.sqlTransactionSucceeded");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setNumber("transactionId", transactionId);
    paramsObject->setArray("columnNames", columnNames);
    paramsObject->setArray("values", values);
    sqlTransactionSucceededMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(sqlTransactionSucceededMessage->toJSONString());
}
void LayoutEditor::rebuild()
{
    RefPtr<JSONObject> object = JSONObject::create();
    RefPtr<JSONArray> anchors = JSONArray::create();

    appendAnchorFor(anchors.get(), "padding", "padding-top");
    appendAnchorFor(anchors.get(), "padding", "padding-right");
    appendAnchorFor(anchors.get(), "padding", "padding-bottom");
    appendAnchorFor(anchors.get(), "padding", "padding-left");

    appendAnchorFor(anchors.get(), "margin", "margin-top");
    appendAnchorFor(anchors.get(), "margin", "margin-right");
    appendAnchorFor(anchors.get(), "margin", "margin-bottom");
    appendAnchorFor(anchors.get(), "margin", "margin-left");

    object->setArray("anchors", anchors.release());

    FloatQuad content, padding, border, margin;
    InspectorHighlight::buildNodeQuads(m_element.get(), &content, &padding, &border, &margin);
    object->setObject("contentQuad", quadToJSON(content));
    object->setObject("paddingQuad", quadToJSON(padding));
    object->setObject("marginQuad", quadToJSON(margin));
    object->setObject("borderQuad", quadToJSON(border));
    evaluateInOverlay("showLayoutEditor", object.release());
    editableSelectorUpdated(false);
}
Example #9
0
PassRefPtr<InspectorObject> InspectorResourceAgent::buildInitiatorObject(Document* document)
{
    RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
    if (stackTrace && stackTrace->size() > 0) {
        RefPtr<InspectorObject> initiatorObject = InspectorObject::create();
        initiatorObject->setString("type", "script");
        initiatorObject->setArray("stackTrace", stackTrace->buildInspectorArray());
        return initiatorObject;
    }

    if (document && document->scriptableDocumentParser()) {
        RefPtr<InspectorObject> initiatorObject = InspectorObject::create();
        initiatorObject->setString("type", "parser");
        initiatorObject->setString("url", document->url().string());
        initiatorObject->setNumber("lineNumber", document->scriptableDocumentParser()->lineNumber().oneBasedInt());
        return initiatorObject;
    }

    if (m_isRecalculatingStyle && m_styleRecalculationInitiator)
        return m_styleRecalculationInitiator;

    RefPtr<InspectorObject> initiatorObject = InspectorObject::create();
    initiatorObject->setString("type", "other");
    return initiatorObject;
}
Example #10
0
static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath)
{
    RefPtr<KeyPath> keyPath;
    switch (idbKeyPath.type()) {
    case IDBKeyPath::NullType:
        keyPath = KeyPath::create().setType(KeyPath::Type::Null);
        break;
    case IDBKeyPath::StringType:
        keyPath = KeyPath::create().setType(KeyPath::Type::String);
        keyPath->setString(idbKeyPath.string());
        break;
    case IDBKeyPath::ArrayType: {
        keyPath = KeyPath::create().setType(KeyPath::Type::Array);
        RefPtr<TypeBuilder::Array<String> > array = TypeBuilder::Array<String>::create();
        const Vector<String>& stringArray = idbKeyPath.array();
        for (size_t i = 0; i < stringArray.size(); ++i)
            array->addItem(stringArray[i]);
        keyPath->setArray(array);
        break;
    }
    default:
        ASSERT_NOT_REACHED();
    }

    return keyPath.release();
}
Example #11
0
void LoggingCanvas::didSetMatrix(const SkMatrix& matrix)
{
    AutoLogger logger(this);
    RefPtr<JSONObject> params = logger.logItemWithParams("setMatrix");
    params->setArray("matrix", arrayForSkMatrix(matrix));
    this->SkCanvas::didSetMatrix(matrix);
}
void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode errorCode, const String& errorMessage, PassRefPtr<InspectorArray> data) const
{
    static const int errorCodes[] = {
        -32700, // ParseError
        -32600, // InvalidRequest
        -32601, // MethodNotFound
        -32602, // InvalidParams
        -32603, // InternalError
        -32000, // ServerError
    };

    ASSERT(errorCode >= 0);
    ASSERT((unsigned)errorCode < WTF_ARRAY_LENGTH(errorCodes));
    ASSERT(errorCodes[errorCode]);

    if (!m_inspectorFrontendChannel)
        return;

    RefPtr<InspectorObject> error = InspectorObject::create();
    error->setNumber(ASCIILiteral("code"), errorCodes[errorCode]);
    error->setString(ASCIILiteral("message"), errorMessage);
    if (data)
        error->setArray(ASCIILiteral("data"), data);

    RefPtr<InspectorObject> message = InspectorObject::create();
    message->setObject(ASCIILiteral("error"), error.release());
    if (callId)
        message->setNumber(ASCIILiteral("id"), *callId);
    else
        message->setValue(ASCIILiteral("id"), InspectorValue::null());

    m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
}
Example #13
0
PassRefPtr<InspectorObject> InspectorOverlay::buildObjectForHighlightedNode() const
{
    if (!m_highlightNode)
        return nullptr;

    Node* node = m_highlightNode.get();
    RenderObject* renderer = node->renderer();
    if (!renderer)
        return nullptr;

    RefPtr<InspectorArray> highlightFragments = buildObjectForRendererFragments(renderer, m_nodeHighlightConfig);
    if (!highlightFragments)
        return nullptr;

    RefPtr<InspectorObject> highlightObject = InspectorObject::create();

    // The main view's scroll offset is shared across all quads.
    FrameView* mainView = m_page.mainFrame().view();
    highlightObject->setObject("scroll", buildObjectForPoint(!mainView->delegatesScrolling() ? mainView->visibleContentRect().location() : FloatPoint()));

    highlightObject->setArray("fragments", highlightFragments.release());

    if (m_nodeHighlightConfig.showInfo) {
        RefPtr<InspectorObject> elementInfo = buildObjectForElementInfo(node);
        if (elementInfo)
            highlightObject->setObject("elementInfo", elementInfo.release());
    }
        
    return highlightObject.release();
}
Example #14
0
static PassRefPtr<InspectorObject> buildObjectForHighlight(FrameView* mainView, const Highlight& highlight)
{
    RefPtr<InspectorObject> object = InspectorObject::create();
    RefPtr<InspectorArray> array = InspectorArray::create();
    for (size_t i = 0; i < highlight.quads.size(); ++i)
        array->pushArray(buildArrayForQuad(highlight.quads[i]));
    object->setArray("quads", array.release());
    object->setBoolean("showRulers", highlight.showRulers);
    object->setString("contentColor", highlight.contentColor.serialized());
    object->setString("contentOutlineColor", highlight.contentOutlineColor.serialized());
    object->setString("paddingColor", highlight.paddingColor.serialized());
    object->setString("borderColor", highlight.borderColor.serialized());
    object->setString("marginColor", highlight.marginColor.serialized());

    FloatRect visibleRect = mainView->visibleContentRect();
    if (!mainView->delegatesScrolling()) {
        object->setNumber("scrollX", visibleRect.x());
        object->setNumber("scrollY", visibleRect.y());
    } else {
        object->setNumber("scrollX", 0);
        object->setNumber("scrollY", 0);
    }

    return object.release();
}
Example #15
0
PassRefPtr<JSONObject> LoggingCanvas::objectForSkShader(const SkShader& shader)
{
    RefPtr<JSONObject> shaderItem = JSONObject::create();
    const SkMatrix localMatrix = shader.getLocalMatrix();
    if (!localMatrix.isIdentity())
        shaderItem->setArray("localMatrix", arrayForSkMatrix(localMatrix));
    return shaderItem.release();
}
Example #16
0
void LoggingCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint)
{
    AutoLogger logger(this);
    RefPtr<JSONObject> params = logger.logItemWithParams("drawPoints");
    params->setString("pointMode", pointModeName(mode));
    params->setArray("points", arrayForSkPoints(count, pts));
    params->setObject("paint", objectForSkPaint(paint));
    this->SkCanvas::onDrawPoints(mode, count, pts, paint);
}
void DevToolsHostFileSystem::upgradeDraggedFileSystemPermissions(DevToolsHost& host, DOMFileSystem* domFileSystem)
{
    RefPtr<JSONObject> message = JSONObject::create();
    message->setNumber("id", 0);
    message->setString("method", "upgradeDraggedFileSystemPermissions");
    RefPtr<JSONArray> params = JSONArray::create();
    message->setArray("params", params);
    params->pushString(domFileSystem->rootURL().string());
    host.sendMessageToEmbedder(message->toJSONString());
}
Example #18
0
void InspectorFrontend::DOM::inlineStyleInvalidated(PassRefPtr<InspectorArray> nodeIds)
{
    RefPtr<InspectorObject> inlineStyleInvalidatedMessage = InspectorObject::create();
    inlineStyleInvalidatedMessage->setString("method", "DOM.inlineStyleInvalidated");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setArray("nodeIds", nodeIds);
    inlineStyleInvalidatedMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(inlineStyleInvalidatedMessage->toJSONString());
}
PassRefPtr<JSONObject> InspectorHighlight::asJSONObject() const
{
    RefPtr<JSONObject> object = JSONObject::create();
    object->setArray("paths", m_highlightPaths);
    object->setBoolean("showRulers", m_showRulers);
    object->setBoolean("showExtensionLines", m_showExtensionLines);
    if (m_elementInfo)
        object->setObject("elementInfo", m_elementInfo);
    return object.release();
}
Example #20
0
void LoggingCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint& paint)
{
    AutoLogger logger(this);
    RefPtr<JSONObject> params = logger.logItemWithParams("drawPosText");
    params->setString("text", stringForText(text, byteLength, paint));
    size_t pointsCount = paint.countText(text, byteLength);
    params->setArray("pos", arrayForSkPoints(pointsCount, pos));
    params->setObject("paint", objectForSkPaint(paint));
    this->SkCanvas::onDrawPosText(text, byteLength, pos, paint);
}
Example #21
0
void LoggingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, const SkMatrix* matrix, const SkPaint& paint)
{
    AutoLogger logger(this);
    RefPtr<JSONObject> params = logger.logItemWithParams("drawTextOnPath");
    params->setString("text", stringForText(text, byteLength, paint));
    params->setObject("path", objectForSkPath(path));
    if (matrix)
        params->setArray("matrix", arrayForSkMatrix(*matrix));
    params->setObject("paint", objectForSkPaint(paint));
    this->SkCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint);
}
Example #22
0
String pictureAsDebugString(const SkPicture* picture)
{
    const SkIRect bounds = picture->cullRect().roundOut();
    LoggingCanvas canvas(bounds.width(), bounds.height());
    picture->playback(&canvas);
    RefPtr<JSONObject> pictureAsJSON = JSONObject::create();
    pictureAsJSON->setObject("cullRect", objectForSkRect(picture->cullRect()));
    pictureAsJSON->setArray("operations", canvas.log());
    RefPtr<JSONArray> operationsInJson = canvas.log();
    return pictureAsJSON->toPrettyJSONString();
}
Example #23
0
void InspectorFrontend::DOM::setChildNodes(int parentId, PassRefPtr<InspectorArray> nodes)
{
    RefPtr<InspectorObject> setChildNodesMessage = InspectorObject::create();
    setChildNodesMessage->setString("method", "DOM.setChildNodes");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setNumber("parentId", parentId);
    paramsObject->setArray("nodes", nodes);
    setChildNodesMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(setChildNodesMessage->toJSONString());
}
PassRefPtr<InspectorObject> InspectorApplicationCacheAgent::buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList& applicationCacheResources, const ApplicationCacheHost::CacheInfo& applicationCacheInfo)
{
    RefPtr<InspectorObject> value = InspectorObject::create();
    value->setNumber("size", applicationCacheInfo.m_size);
    value->setString("manifest", applicationCacheInfo.m_manifest.string());
    value->setString("lastPathComponent", applicationCacheInfo.m_manifest.lastPathComponent());
    value->setNumber("creationTime", applicationCacheInfo.m_creationTime);
    value->setNumber("updateTime", applicationCacheInfo.m_updateTime);
    value->setArray("resources", buildArrayForApplicationCacheResources(applicationCacheResources));
    return value;
}
Example #25
0
static PassRefPtr<InspectorObject> buildObjectForShapeOutside(Frame* containingFrame, RenderBox* renderer)
{
    const ShapeOutsideInfo* shapeOutsideInfo = renderer->shapeOutsideInfo();
    if (!shapeOutsideInfo)
        return nullptr;

    RefPtr<InspectorObject> shapeObject = InspectorObject::create();
    LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox();
    FloatQuad shapeQuad = renderer->localToAbsoluteQuad(FloatRect(shapeBounds));
    contentsQuadToPage(containingFrame->page()->mainFrame().view(), containingFrame->view(), shapeQuad);
    shapeObject->setArray(ASCIILiteral("bounds"), buildArrayForQuad(shapeQuad));

    Shape::DisplayPaths paths;
    shapeOutsideInfo->computedShape().buildDisplayPaths(paths);

    if (paths.shape.length()) {
        RefPtr<InspectorArray> shapePath = InspectorArray::create();
        PathApplyInfo info;
        info.rootView = containingFrame->page()->mainFrame().view();
        info.view = containingFrame->view();
        info.array = shapePath.get();
        info.renderer = renderer;
        info.shapeOutsideInfo = shapeOutsideInfo;

        paths.shape.apply(&info, &appendPathSegment);

        shapeObject->setArray(ASCIILiteral("shape"), shapePath.release());

        if (paths.marginShape.length()) {
            shapePath = InspectorArray::create();
            info.array = shapePath.get();

            paths.marginShape.apply(&info, &appendPathSegment);

            shapeObject->setArray(ASCIILiteral("marginShape"), shapePath.release());
        }
    }

    return shapeObject.release();
}
Example #26
0
static PassRefPtr<InspectorObject> buildObjectForRegionHighlight(FrameView* mainView, RenderRegion* region)
{
    FrameView* containingView = region->frame().view();
    if (!containingView)
        return nullptr;

    RenderBlockFlow* regionContainer = toRenderBlockFlow(region->parent());
    LayoutRect borderBox = regionContainer->borderBoxRect();
    borderBox.setWidth(borderBox.width() + regionContainer->verticalScrollbarWidth());
    borderBox.setHeight(borderBox.height() + regionContainer->horizontalScrollbarHeight());

    // Create incoming and outgoing boxes that we use to chain the regions toghether.
    const LayoutSize linkBoxSize(10, 10);
    const LayoutSize linkBoxMidpoint(linkBoxSize.width() / 2, linkBoxSize.height() / 2);
    
    LayoutRect incomingRectBox = LayoutRect(borderBox.location() - linkBoxMidpoint, linkBoxSize);
    LayoutRect outgoingRectBox = LayoutRect(borderBox.location() - linkBoxMidpoint + borderBox.size(), linkBoxSize);

    // Move the link boxes slightly inside the region border box.
    LayoutUnit maxUsableHeight = std::max(LayoutUnit(), borderBox.height() - linkBoxMidpoint.height());
    LayoutUnit linkBoxVerticalOffset = std::min(LayoutUnit::fromPixel(15), maxUsableHeight);
    incomingRectBox.move(0, linkBoxVerticalOffset);
    outgoingRectBox.move(0, -linkBoxVerticalOffset);

    FloatQuad borderRectQuad = regionContainer->localToAbsoluteQuad(FloatRect(borderBox));
    FloatQuad incomingRectQuad = regionContainer->localToAbsoluteQuad(FloatRect(incomingRectBox));
    FloatQuad outgoingRectQuad = regionContainer->localToAbsoluteQuad(FloatRect(outgoingRectBox));

    contentsQuadToPage(mainView, containingView, borderRectQuad);
    contentsQuadToPage(mainView, containingView, incomingRectQuad);
    contentsQuadToPage(mainView, containingView, outgoingRectQuad);

    RefPtr<InspectorObject> regionObject = InspectorObject::create();

    regionObject->setArray("borderQuad", buildArrayForQuad(borderRectQuad));
    regionObject->setArray("incomingQuad", buildArrayForQuad(incomingRectQuad));
    regionObject->setArray("outgoingQuad", buildArrayForQuad(outgoingRectQuad));

    return regionObject.release();
}
Example #27
0
PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorPaintEvent::data(RenderObject* renderer, const LayoutRect& clipRect, const GraphicsLayer* graphicsLayer)
{
    RefPtr<JSONObject> data = JSONObject::create();
    data->setString("frame", toHexString(renderer->frame()));
    FloatQuad quad;
    localToPageQuad(*renderer, clipRect, &quad);
    data->setArray("clip", createQuad(quad));
    int nodeId = InspectorNodeIds::idForNode(renderer->generatingNode());
    data->setNumber("nodeId", nodeId);
    int graphicsLayerId = graphicsLayer ? graphicsLayer->platformLayer()->id() : 0;
    data->setNumber("layerId", graphicsLayerId);
    return TracedValue::fromJSONValue(data);
}
Example #28
0
void InspectorFrontend::Debugger::paused(PassRefPtr<InspectorArray> callFrames, const String& reason, PassRefPtr<InspectorObject> data)
{
    RefPtr<InspectorObject> pausedMessage = InspectorObject::create();
    pausedMessage->setString("method", "Debugger.paused");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setArray("callFrames", callFrames);
    paramsObject->setString("reason", reason);
    if (data)
        paramsObject->setObject("data", data);
    pausedMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(pausedMessage->toJSONString());
}
Example #29
0
PassRefPtr<JSONObject> LayoutEditor::currentSelectorInfo(CSSStyleDeclaration* style) const
{
    RefPtr<JSONObject> object = JSONObject::create();
    CSSStyleRule* rule = style->parentRule() ? toCSSStyleRule(style->parentRule()) : nullptr;
    String currentSelectorText = rule ? rule->selectorText() : "element.style";
    object->setString("selector", currentSelectorText);

    Document* ownerDocument = m_element->ownerDocument();
    if (!ownerDocument->isActive() || !rule)
        return object.release();

    Vector<String> medias;
    buildMediaListChain(rule, medias);
    RefPtr<JSONArray> mediasJSONArray = JSONArray::create();
    for (size_t i = 0; i < medias.size(); ++i)
        mediasJSONArray->pushString(medias[i]);

    object->setArray("medias", mediasJSONArray.release());

    TrackExceptionState exceptionState;
    RefPtrWillBeRawPtr<StaticElementList> elements = ownerDocument->querySelectorAll(AtomicString(currentSelectorText), exceptionState);

    if (!elements || exceptionState.hadException())
        return object.release();

    RefPtr<JSONArray> highlights = JSONArray::create();
    InspectorHighlightConfig config = affectedNodesHighlightConfig();
    for (unsigned i = 0; i < elements->length(); ++i) {
        Element* element = elements->item(i);
        if (element == m_element)
            continue;

        InspectorHighlight highlight(element, config, false);
        highlights->pushObject(highlight.asJSONObject());
    }

    object->setArray("nodes", highlights.release());
    return object.release();
}
Example #30
0
static PassRefPtr<InspectorObject> buildObjectForHighlight(const Highlight& highlight)
{
    RefPtr<InspectorObject> object = InspectorObject::create();
    RefPtr<InspectorArray> array = InspectorArray::create();
    for (size_t i = 0; i < highlight.quads.size(); ++i)
        array->pushArray(buildArrayForQuad(highlight.quads[i]));
    object->setArray("quads", array.release());
    object->setString("contentColor", highlight.contentColor.serialized());
    object->setString("contentOutlineColor", highlight.contentOutlineColor.serialized());
    object->setString("paddingColor", highlight.paddingColor.serialized());
    object->setString("borderColor", highlight.borderColor.serialized());
    object->setString("marginColor", highlight.marginColor.serialized());
    return object.release();
}