OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 contentsQuadToRootFrame(containingView, *content); | 296 contentsQuadToRootFrame(containingView, *content); |
297 contentsQuadToRootFrame(containingView, *padding); | 297 contentsQuadToRootFrame(containingView, *padding); |
298 contentsQuadToRootFrame(containingView, *border); | 298 contentsQuadToRootFrame(containingView, *border); |
299 contentsQuadToRootFrame(containingView, *margin); | 299 contentsQuadToRootFrame(containingView, *margin); |
300 | 300 |
301 return true; | 301 return true; |
302 } | 302 } |
303 | 303 |
304 static void buildNodeHighlight(Node& node, const HighlightConfig& highlightConfi
g, Highlight* highlight) | 304 static void buildNodeHighlight(Node& node, const HighlightConfig& highlightConfi
g, Highlight* highlight) |
305 { | 305 { |
306 LayoutObject* renderer = node.renderer(); | 306 LayoutObject* renderer = node.layoutObject(); |
307 if (!renderer) | 307 if (!renderer) |
308 return; | 308 return; |
309 | 309 |
310 highlight->setDataFromConfig(highlightConfig); | 310 highlight->setDataFromConfig(highlightConfig); |
311 | 311 |
312 // LayoutSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). | 312 // LayoutSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). |
313 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { | 313 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { |
314 Vector<FloatQuad> quads; | 314 Vector<FloatQuad> quads; |
315 renderer->absoluteQuads(quads); | 315 renderer->absoluteQuads(quads); |
316 FrameView* containingView = renderer->frameView(); | 316 FrameView* containingView = renderer->frameView(); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 array->addItem(quad.p2().y()); | 584 array->addItem(quad.p2().y()); |
585 array->addItem(quad.p3().x()); | 585 array->addItem(quad.p3().x()); |
586 array->addItem(quad.p3().y()); | 586 array->addItem(quad.p3().y()); |
587 array->addItem(quad.p4().x()); | 587 array->addItem(quad.p4().x()); |
588 array->addItem(quad.p4().y()); | 588 array->addItem(quad.p4().y()); |
589 return array.release(); | 589 return array.release(); |
590 } | 590 } |
591 | 591 |
592 static const ShapeOutsideInfo* shapeOutsideInfoForNode(Node* node, Shape::Displa
yPaths* paths, FloatQuad* bounds) | 592 static const ShapeOutsideInfo* shapeOutsideInfoForNode(Node* node, Shape::Displa
yPaths* paths, FloatQuad* bounds) |
593 { | 593 { |
594 LayoutObject* renderer = node->renderer(); | 594 LayoutObject* renderer = node->layoutObject(); |
595 if (!renderer || !renderer->isBox() || !toLayoutBox(renderer)->shapeOutsideI
nfo()) | 595 if (!renderer || !renderer->isBox() || !toLayoutBox(renderer)->shapeOutsideI
nfo()) |
596 return nullptr; | 596 return nullptr; |
597 | 597 |
598 FrameView* containingView = node->document().view(); | 598 FrameView* containingView = node->document().view(); |
599 LayoutBox* layoutBox = toLayoutBox(renderer); | 599 LayoutBox* layoutBox = toLayoutBox(renderer); |
600 const ShapeOutsideInfo* shapeOutsideInfo = layoutBox->shapeOutsideInfo(); | 600 const ShapeOutsideInfo* shapeOutsideInfo = layoutBox->shapeOutsideInfo(); |
601 | 601 |
602 shapeOutsideInfo->computedShape().buildDisplayPaths(*paths); | 602 shapeOutsideInfo->computedShape().buildDisplayPaths(*paths); |
603 | 603 |
604 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); | 604 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); |
(...skipping 10 matching lines...) Expand all Loading... |
615 | 615 |
616 const ShapeOutsideInfo* shapeOutsideInfo = shapeOutsideInfoForNode(node, &pa
ths, &boundsQuad); | 616 const ShapeOutsideInfo* shapeOutsideInfo = shapeOutsideInfoForNode(node, &pa
ths, &boundsQuad); |
617 if (!shapeOutsideInfo) | 617 if (!shapeOutsideInfo) |
618 return; | 618 return; |
619 | 619 |
620 if (!paths.shape.length()) { | 620 if (!paths.shape.length()) { |
621 highlight.appendQuad(boundsQuad, config.shape); | 621 highlight.appendQuad(boundsQuad, config.shape); |
622 return; | 622 return; |
623 } | 623 } |
624 | 624 |
625 highlight.appendPath(ShapePathBuilder::buildPath(*node->document().view(), *
node->renderer(), *shapeOutsideInfo, paths.shape), config.shape, Color::transpar
ent); | 625 highlight.appendPath(ShapePathBuilder::buildPath(*node->document().view(), *
node->layoutObject(), *shapeOutsideInfo, paths.shape), config.shape, Color::tran
sparent); |
626 if (paths.marginShape.length()) | 626 if (paths.marginShape.length()) |
627 highlight.appendPath(ShapePathBuilder::buildPath(*node->document().view(
), *node->renderer(), *shapeOutsideInfo, paths.marginShape), config.shapeMargin,
Color::transparent); | 627 highlight.appendPath(ShapePathBuilder::buildPath(*node->document().view(
), *node->layoutObject(), *shapeOutsideInfo, paths.marginShape), config.shapeMar
gin, Color::transparent); |
628 } | 628 } |
629 | 629 |
630 PassRefPtr<JSONObject> buildElementInfo(Element* element) | 630 PassRefPtr<JSONObject> buildElementInfo(Element* element) |
631 { | 631 { |
632 RefPtr<JSONObject> elementInfo = JSONObject::create(); | 632 RefPtr<JSONObject> elementInfo = JSONObject::create(); |
633 Element* realElement = element; | 633 Element* realElement = element; |
634 PseudoElement* pseudoElement = nullptr; | 634 PseudoElement* pseudoElement = nullptr; |
635 if (element->isPseudoElement()) { | 635 if (element->isPseudoElement()) { |
636 pseudoElement = toPseudoElement(element); | 636 pseudoElement = toPseudoElement(element); |
637 realElement = element->parentOrShadowHostElement(); | 637 realElement = element->parentOrShadowHostElement(); |
(...skipping 16 matching lines...) Expand all Loading... |
654 } | 654 } |
655 if (pseudoElement) { | 655 if (pseudoElement) { |
656 if (pseudoElement->pseudoId() == BEFORE) | 656 if (pseudoElement->pseudoId() == BEFORE) |
657 classNames.appendLiteral("::before"); | 657 classNames.appendLiteral("::before"); |
658 else if (pseudoElement->pseudoId() == AFTER) | 658 else if (pseudoElement->pseudoId() == AFTER) |
659 classNames.appendLiteral("::after"); | 659 classNames.appendLiteral("::after"); |
660 } | 660 } |
661 if (!classNames.isEmpty()) | 661 if (!classNames.isEmpty()) |
662 elementInfo->setString("className", classNames.toString()); | 662 elementInfo->setString("className", classNames.toString()); |
663 | 663 |
664 LayoutObject* renderer = element->renderer(); | 664 LayoutObject* renderer = element->layoutObject(); |
665 FrameView* containingView = element->document().view(); | 665 FrameView* containingView = element->document().view(); |
666 if (!renderer || !containingView) | 666 if (!renderer || !containingView) |
667 return elementInfo; | 667 return elementInfo; |
668 | 668 |
669 // Render the getBoundingClientRect() data in the tooltip | 669 // Render the getBoundingClientRect() data in the tooltip |
670 // to be consistent with the rulers (see http://crbug.com/262338). | 670 // to be consistent with the rulers (see http://crbug.com/262338). |
671 RefPtrWillBeRawPtr<ClientRect> boundingBox = element->getBoundingClientRect(
); | 671 RefPtrWillBeRawPtr<ClientRect> boundingBox = element->getBoundingClientRect(
); |
672 elementInfo->setString("nodeWidth", String::number(boundingBox->width())); | 672 elementInfo->setString("nodeWidth", String::number(boundingBox->width())); |
673 elementInfo->setString("nodeHeight", String::number(boundingBox->height())); | 673 elementInfo->setString("nodeHeight", String::number(boundingBox->height())); |
674 | 674 |
675 return elementInfo; | 675 return elementInfo; |
676 } | 676 } |
677 | 677 |
678 void InspectorOverlay::drawNodeHighlight() | 678 void InspectorOverlay::drawNodeHighlight() |
679 { | 679 { |
680 if (!m_highlightNode) | 680 if (!m_highlightNode) |
681 return; | 681 return; |
682 | 682 |
683 Highlight highlight; | 683 Highlight highlight; |
684 appendPathsForShapeOutside(highlight, m_nodeHighlightConfig, m_highlightNode
.get()); | 684 appendPathsForShapeOutside(highlight, m_nodeHighlightConfig, m_highlightNode
.get()); |
685 buildNodeHighlight(*m_highlightNode, m_nodeHighlightConfig, &highlight); | 685 buildNodeHighlight(*m_highlightNode, m_nodeHighlightConfig, &highlight); |
686 | 686 |
687 if (m_eventTargetNode && m_eventTargetNode->renderer()) { | 687 if (m_eventTargetNode && m_eventTargetNode->layoutObject()) { |
688 FloatQuad border, unused; | 688 FloatQuad border, unused; |
689 if (buildNodeQuads(m_eventTargetNode->renderer(), &unused, &unused, &bor
der, &unused)) | 689 if (buildNodeQuads(m_eventTargetNode->layoutObject(), &unused, &unused,
&border, &unused)) |
690 highlight.appendQuad(border, m_nodeHighlightConfig.eventTarget); | 690 highlight.appendQuad(border, m_nodeHighlightConfig.eventTarget); |
691 } | 691 } |
692 | 692 |
693 if (m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightCon
fig.showInfo && m_highlightNode->renderer() && m_highlightNode->document().frame
()) | 693 if (m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightCon
fig.showInfo && m_highlightNode->layoutObject() && m_highlightNode->document().f
rame()) |
694 highlight.setElementInfo(buildElementInfo(toElement(m_highlightNode.get(
)))); | 694 highlight.setElementInfo(buildElementInfo(toElement(m_highlightNode.get(
)))); |
695 | 695 |
696 evaluateInOverlay("drawHighlight", highlight.asJSONObject()); | 696 evaluateInOverlay("drawHighlight", highlight.asJSONObject()); |
697 } | 697 } |
698 | 698 |
699 void InspectorOverlay::drawQuadHighlight() | 699 void InspectorOverlay::drawQuadHighlight() |
700 { | 700 { |
701 if (!m_highlightQuad) | 701 if (!m_highlightQuad) |
702 return; | 702 return; |
703 | 703 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 } | 812 } |
813 | 813 |
814 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*) | 814 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*) |
815 { | 815 { |
816 m_drawViewSize = false; | 816 m_drawViewSize = false; |
817 update(); | 817 update(); |
818 } | 818 } |
819 | 819 |
820 bool InspectorOverlay::getBoxModel(Node* node, RefPtr<TypeBuilder::DOM::BoxModel
>& model) | 820 bool InspectorOverlay::getBoxModel(Node* node, RefPtr<TypeBuilder::DOM::BoxModel
>& model) |
821 { | 821 { |
822 LayoutObject* renderer = node->renderer(); | 822 LayoutObject* renderer = node->layoutObject(); |
823 FrameView* view = node->document().view(); | 823 FrameView* view = node->document().view(); |
824 if (!renderer || !view) | 824 if (!renderer || !view) |
825 return false; | 825 return false; |
826 | 826 |
827 FloatQuad content, padding, border, margin; | 827 FloatQuad content, padding, border, margin; |
828 if (!buildNodeQuads(node->renderer(), &content, &padding, &border, &margin)) | 828 if (!buildNodeQuads(node->layoutObject(), &content, &padding, &border, &marg
in)) |
829 return false; | 829 return false; |
830 | 830 |
831 IntRect boundingBox = view->contentsToRootFrame(renderer->absoluteBoundingBo
xRect()); | 831 IntRect boundingBox = view->contentsToRootFrame(renderer->absoluteBoundingBo
xRect()); |
832 LayoutBoxModelObject* modelObject = renderer->isBoxModelObject() ? toLayoutB
oxModelObject(renderer) : nullptr; | 832 LayoutBoxModelObject* modelObject = renderer->isBoxModelObject() ? toLayoutB
oxModelObject(renderer) : nullptr; |
833 | 833 |
834 model = TypeBuilder::DOM::BoxModel::create() | 834 model = TypeBuilder::DOM::BoxModel::create() |
835 .setContent(buildArrayForQuad(content)) | 835 .setContent(buildArrayForQuad(content)) |
836 .setPadding(buildArrayForQuad(padding)) | 836 .setPadding(buildArrayForQuad(padding)) |
837 .setBorder(buildArrayForQuad(border)) | 837 .setBorder(buildArrayForQuad(border)) |
838 .setMargin(buildArrayForQuad(margin)) | 838 .setMargin(buildArrayForQuad(margin)) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 hideHighlight(); | 887 hideHighlight(); |
888 } | 888 } |
889 | 889 |
890 void InspectorOverlay::startedRecordingProfile() | 890 void InspectorOverlay::startedRecordingProfile() |
891 { | 891 { |
892 if (!m_activeProfilerCount++) | 892 if (!m_activeProfilerCount++) |
893 freePage(); | 893 freePage(); |
894 } | 894 } |
895 | 895 |
896 } // namespace blink | 896 } // namespace blink |
OLD | NEW |