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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 485 } |
486 | 486 |
487 static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size) | 487 static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size) |
488 { | 488 { |
489 RefPtr<JSONObject> result = JSONObject::create(); | 489 RefPtr<JSONObject> result = JSONObject::create(); |
490 result->setNumber("width", size.width()); | 490 result->setNumber("width", size.width()); |
491 result->setNumber("height", size.height()); | 491 result->setNumber("height", size.height()); |
492 return result.release(); | 492 return result.release(); |
493 } | 493 } |
494 | 494 |
| 495 struct PathApplyInfo { |
| 496 FrameView* rootView; |
| 497 FrameView* view; |
| 498 JSONArray* array; |
| 499 RenderObject* renderer; |
| 500 const ShapeOutsideInfo* shapeOutsideInfo; |
| 501 }; |
| 502 |
| 503 static void appendPathCommandAndPoints(PathApplyInfo* info, const String& comman
d, const FloatPoint points[], unsigned length) |
| 504 { |
| 505 FloatPoint point; |
| 506 info->array->pushString(command); |
| 507 for (unsigned i = 0; i < length; i++) { |
| 508 point = info->shapeOutsideInfo->shapeToRendererPoint(points[i]); |
| 509 point = info->view->contentsToRootView(roundedIntPoint(info->renderer->l
ocalToAbsolute(point))) + info->rootView->scrollOffset(); |
| 510 info->array->pushNumber(point.x()); |
| 511 info->array->pushNumber(point.y()); |
| 512 } |
| 513 } |
| 514 |
| 515 static void appendPathSegment(void* info, const PathElement* pathElement) |
| 516 { |
| 517 PathApplyInfo* pathApplyInfo = static_cast<PathApplyInfo*>(info); |
| 518 FloatPoint point; |
| 519 switch (pathElement->type) { |
| 520 // The points member will contain 1 value. |
| 521 case PathElementMoveToPoint: |
| 522 appendPathCommandAndPoints(pathApplyInfo, "M", pathElement->points, 1); |
| 523 break; |
| 524 // The points member will contain 1 value. |
| 525 case PathElementAddLineToPoint: |
| 526 appendPathCommandAndPoints(pathApplyInfo, "L", pathElement->points, 1); |
| 527 break; |
| 528 // The points member will contain 3 values. |
| 529 case PathElementAddCurveToPoint: |
| 530 appendPathCommandAndPoints(pathApplyInfo, "C", pathElement->points, 3); |
| 531 break; |
| 532 // The points member will contain 2 values. |
| 533 case PathElementAddQuadCurveToPoint: |
| 534 appendPathCommandAndPoints(pathApplyInfo, "Q", pathElement->points, 2); |
| 535 break; |
| 536 // The points member will contain no values. |
| 537 case PathElementCloseSubpath: |
| 538 appendPathCommandAndPoints(pathApplyInfo, "Z", 0, 0); |
| 539 break; |
| 540 } |
| 541 } |
| 542 |
| 543 PassRefPtr<JSONObject> InspectorOverlay::buildObjectForShapeOutside(LocalFrame*
containingFrame, RenderBox* renderer) |
| 544 { |
| 545 const ShapeOutsideInfo* shapeOutsideInfo = renderer->shapeOutsideInfo(); |
| 546 if (!shapeOutsideInfo) |
| 547 return nullptr; |
| 548 |
| 549 RefPtr<JSONObject> shapeObject = JSONObject::create(); |
| 550 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); |
| 551 FloatQuad shapeQuad = renderer->localToAbsoluteQuad(FloatRect(shapeBounds)); |
| 552 FrameView* mainView = containingFrame->page()->mainFrame()->view(); |
| 553 FrameView* containingView = containingFrame->view(); |
| 554 contentsQuadToPage(mainView, containingView, shapeQuad); |
| 555 shapeObject->setArray("bounds", buildArrayForQuad(shapeQuad)); |
| 556 |
| 557 Shape::DisplayPaths paths; |
| 558 shapeOutsideInfo->computedShape().buildDisplayPaths(paths); |
| 559 |
| 560 if (paths.shape.length()) { |
| 561 RefPtr<JSONArray> shapePath = JSONArray::create(); |
| 562 PathApplyInfo info; |
| 563 info.rootView = mainView; |
| 564 info.view = containingView; |
| 565 info.array = shapePath.get(); |
| 566 info.renderer = renderer; |
| 567 info.shapeOutsideInfo = shapeOutsideInfo; |
| 568 |
| 569 paths.shape.apply(&info, &appendPathSegment); |
| 570 |
| 571 shapeObject->setArray("shape", shapePath.release()); |
| 572 |
| 573 if (paths.marginShape.length()) { |
| 574 shapePath = JSONArray::create(); |
| 575 info.array = shapePath.get(); |
| 576 paths.marginShape.apply(&info, &appendPathSegment); |
| 577 shapeObject->setArray("marginShape", shapePath.release()); |
| 578 } |
| 579 } |
| 580 |
| 581 return shapeObject.release(); |
| 582 } |
| 583 |
495 void InspectorOverlay::drawNodeHighlight() | 584 void InspectorOverlay::drawNodeHighlight() |
496 { | 585 { |
497 if (!m_highlightNode) | 586 if (!m_highlightNode) |
498 return; | 587 return; |
499 | 588 |
500 Highlight highlight; | 589 Highlight highlight; |
501 buildNodeHighlight(m_highlightNode.get(), m_nodeHighlightConfig, &highlight)
; | 590 buildNodeHighlight(m_highlightNode.get(), m_nodeHighlightConfig, &highlight)
; |
502 if (m_eventTargetNode) { | 591 if (m_eventTargetNode) { |
503 Highlight eventTargetHighlight; | 592 Highlight eventTargetHighlight; |
504 buildNodeHighlight(m_eventTargetNode.get(), m_nodeHighlightConfig, &even
tTargetHighlight); | 593 buildNodeHighlight(m_eventTargetNode.get(), m_nodeHighlightConfig, &even
tTargetHighlight); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 if (!classNames.isEmpty()) | 630 if (!classNames.isEmpty()) |
542 elementInfo->setString("className", classNames.toString()); | 631 elementInfo->setString("className", classNames.toString()); |
543 | 632 |
544 RenderObject* renderer = node->renderer(); | 633 RenderObject* renderer = node->renderer(); |
545 LocalFrame* containingFrame = node->document().frame(); | 634 LocalFrame* containingFrame = node->document().frame(); |
546 FrameView* containingView = containingFrame->view(); | 635 FrameView* containingView = containingFrame->view(); |
547 IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRoot
View(renderer->absoluteBoundingBoxRect())); | 636 IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRoot
View(renderer->absoluteBoundingBoxRect())); |
548 RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRen
derBoxModelObject(renderer) : 0; | 637 RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRen
derBoxModelObject(renderer) : 0; |
549 elementInfo->setString("nodeWidth", String::number(modelObject ? adjustF
orAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), modelObject) : boundingBo
x.width())); | 638 elementInfo->setString("nodeWidth", String::number(modelObject ? adjustF
orAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), modelObject) : boundingBo
x.width())); |
550 elementInfo->setString("nodeHeight", String::number(modelObject ? adjust
ForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), modelObject) : bounding
Box.height())); | 639 elementInfo->setString("nodeHeight", String::number(modelObject ? adjust
ForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), modelObject) : bounding
Box.height())); |
| 640 if (renderer->isBox()) { |
| 641 RenderBox* renderBox = toRenderBox(renderer); |
| 642 if (RefPtr<JSONObject> shapeObject = buildObjectForShapeOutside(cont
ainingFrame, renderBox)) |
| 643 elementInfo->setObject("shapeOutsideInfo", shapeObject.release()
); |
| 644 } |
551 highlightObject->setObject("elementInfo", elementInfo.release()); | 645 highlightObject->setObject("elementInfo", elementInfo.release()); |
552 } | 646 } |
553 evaluateInOverlay("drawNodeHighlight", highlightObject); | 647 evaluateInOverlay("drawNodeHighlight", highlightObject); |
554 } | 648 } |
555 | 649 |
556 void InspectorOverlay::drawQuadHighlight() | 650 void InspectorOverlay::drawQuadHighlight() |
557 { | 651 { |
558 if (!m_highlightQuad) | 652 if (!m_highlightQuad) |
559 return; | 653 return; |
560 | 654 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 m_timer.stop(); | 779 m_timer.stop(); |
686 } | 780 } |
687 | 781 |
688 void InspectorOverlay::startedRecordingProfile() | 782 void InspectorOverlay::startedRecordingProfile() |
689 { | 783 { |
690 if (!m_activeProfilerCount++) | 784 if (!m_activeProfilerCount++) |
691 freePage(); | 785 freePage(); |
692 } | 786 } |
693 | 787 |
694 } // namespace WebCore | 788 } // namespace WebCore |
OLD | NEW |