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 static FloatPoint localPointToRoot(RenderObject* renderer, const FrameView* main View, const FrameView* view, const FloatPoint& point) | |
496 { | |
497 FloatPoint result = renderer->localToAbsolute(point); | |
498 result = view->contentsToRootView(roundedIntPoint(result)); | |
499 result += mainView->scrollOffset(); | |
500 return result; | |
501 } | |
502 | |
503 struct PathApplyInfo { | |
504 FrameView* rootView; | |
505 FrameView* view; | |
506 JSONArray* array; | |
507 RenderObject* renderer; | |
508 const ShapeOutsideInfo* shapeOutsideInfo; | |
509 }; | |
510 | |
511 static void appendPathCommandAndPoints(PathApplyInfo* info, const String& comman d, const FloatPoint points[], unsigned length) | |
512 { | |
513 FloatPoint point; | |
514 info->array->pushString(command); | |
515 for (unsigned i = 0; i < length; i++) { | |
516 point = info->shapeOutsideInfo->shapeToRendererPoint(points[i]); | |
517 point = localPointToRoot(info->renderer, info->rootView, info->view, poi nt); | |
518 info->array->pushNumber(point.x()); | |
519 info->array->pushNumber(point.y()); | |
520 } | |
521 } | |
522 | |
523 static void appendPathSegment(void* info, const PathElement* pathElement) | |
524 { | |
525 PathApplyInfo* pathApplyInfo = static_cast<PathApplyInfo*>(info); | |
pfeldman
2014/04/15 11:59:09
Please don't reinterpret, call it using simple loo
Habib Virji
2014/04/17 15:43:47
Tried to remove but problem is paths.shape.apply(&
apavlov
2014/04/17 16:11:32
Well, the current code is along the lines of what
| |
526 FloatPoint point; | |
527 switch (pathElement->type) { | |
528 // The points member will contain 1 value. | |
529 case PathElementMoveToPoint: | |
530 appendPathCommandAndPoints(pathApplyInfo, ("M"), pathElement->points, 1) ; | |
apavlov
2014/04/17 16:11:32
The parentheses around strings are not needed?
| |
531 break; | |
532 // The points member will contain 1 value. | |
533 case PathElementAddLineToPoint: | |
534 appendPathCommandAndPoints(pathApplyInfo, ("L"), pathElement->points, 1) ; | |
535 break; | |
536 // The points member will contain 3 values. | |
537 case PathElementAddCurveToPoint: | |
538 appendPathCommandAndPoints(pathApplyInfo, ("C"), pathElement->points, 3) ; | |
539 break; | |
540 // The points member will contain 2 values. | |
541 case PathElementAddQuadCurveToPoint: | |
542 appendPathCommandAndPoints(pathApplyInfo, ("Q"), pathElement->points, 2) ; | |
543 break; | |
544 // The points member will contain no values. | |
545 case PathElementCloseSubpath: | |
546 appendPathCommandAndPoints(pathApplyInfo, ("Z"), 0, 0); | |
547 break; | |
548 } | |
549 } | |
550 | |
551 static PassRefPtr<JSONObject> buildObjectForShapeOutside(LocalFrame* containingF rame, RenderBox* renderer) | |
552 { | |
553 const ShapeOutsideInfo* shapeOutsideInfo = renderer->shapeOutsideInfo(); | |
554 if (!shapeOutsideInfo) | |
555 return nullptr; | |
556 | |
557 RefPtr<JSONObject> shapeObject = JSONObject::create(); | |
558 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox( ); | |
559 FloatQuad shapeQuad = renderer->localToAbsoluteQuad(FloatRect(shapeBounds)); | |
560 contentsQuadToPage(containingFrame->page()->mainFrame()->view(), containingF rame->view(), shapeQuad); | |
561 shapeObject->setArray("bounds", buildArrayForQuad(shapeQuad)); | |
562 | |
563 Shape::DisplayPaths paths; | |
564 shapeOutsideInfo->computedShape().buildDisplayPaths(paths); | |
565 | |
566 if (paths.shape.length()) { | |
567 RefPtr<JSONArray> shapePath = JSONArray::create(); | |
568 PathApplyInfo info; | |
569 info.rootView = containingFrame->page()->mainFrame()->view(); | |
pfeldman
2014/04/15 11:59:09
Extract FrameView* mainView above - you use it mul
Habib Virji
2014/04/17 15:43:47
Done.
| |
570 info.view = containingFrame->view(); | |
pfeldman
2014/04/15 11:59:09
FrameView* containingView
Habib Virji
2014/04/17 15:43:47
Done.
| |
571 info.array = shapePath.get(); | |
572 info.renderer = renderer; | |
573 info.shapeOutsideInfo = shapeOutsideInfo; | |
574 | |
575 paths.shape.apply(&info, &appendPathSegment); | |
576 | |
577 shapeObject->setArray("shape", shapePath.release()); | |
578 | |
579 if (paths.marginShape.length()) { | |
580 shapePath = JSONArray::create(); | |
581 info.array = shapePath.get(); | |
582 paths.marginShape.apply(&info, &appendPathSegment); | |
583 shapeObject->setArray("marginShape", shapePath.release()); | |
584 } | |
585 } | |
586 | |
587 return shapeObject.release(); | |
588 } | |
589 | |
495 void InspectorOverlay::drawNodeHighlight() | 590 void InspectorOverlay::drawNodeHighlight() |
496 { | 591 { |
497 if (!m_highlightNode) | 592 if (!m_highlightNode) |
498 return; | 593 return; |
499 | 594 |
500 Highlight highlight; | 595 Highlight highlight; |
501 buildNodeHighlight(m_highlightNode.get(), m_nodeHighlightConfig, &highlight) ; | 596 buildNodeHighlight(m_highlightNode.get(), m_nodeHighlightConfig, &highlight) ; |
502 if (m_eventTargetNode) { | 597 if (m_eventTargetNode) { |
503 Highlight eventTargetHighlight; | 598 Highlight eventTargetHighlight; |
504 buildNodeHighlight(m_eventTargetNode.get(), m_nodeHighlightConfig, &even tTargetHighlight); | 599 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()) | 636 if (!classNames.isEmpty()) |
542 elementInfo->setString("className", classNames.toString()); | 637 elementInfo->setString("className", classNames.toString()); |
543 | 638 |
544 RenderObject* renderer = node->renderer(); | 639 RenderObject* renderer = node->renderer(); |
545 LocalFrame* containingFrame = node->document().frame(); | 640 LocalFrame* containingFrame = node->document().frame(); |
546 FrameView* containingView = containingFrame->view(); | 641 FrameView* containingView = containingFrame->view(); |
547 IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRoot View(renderer->absoluteBoundingBoxRect())); | 642 IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRoot View(renderer->absoluteBoundingBoxRect())); |
548 RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRen derBoxModelObject(renderer) : 0; | 643 RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRen derBoxModelObject(renderer) : 0; |
549 elementInfo->setString("nodeWidth", String::number(modelObject ? adjustF orAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), modelObject) : boundingBo x.width())); | 644 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())); | 645 elementInfo->setString("nodeHeight", String::number(modelObject ? adjust ForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), modelObject) : bounding Box.height())); |
646 if (renderer->isBox()) { | |
647 RenderBox* renderBox = toRenderBox(renderer); | |
648 if (RefPtr<JSONObject> shapeObject = buildObjectForShapeOutside(cont ainingFrame, renderBox)) | |
649 elementInfo->setObject("shapeOutsideInfo", shapeObject.release() ); | |
650 } | |
551 highlightObject->setObject("elementInfo", elementInfo.release()); | 651 highlightObject->setObject("elementInfo", elementInfo.release()); |
552 } | 652 } |
553 evaluateInOverlay("drawNodeHighlight", highlightObject); | 653 evaluateInOverlay("drawNodeHighlight", highlightObject); |
554 } | 654 } |
555 | 655 |
556 void InspectorOverlay::drawQuadHighlight() | 656 void InspectorOverlay::drawQuadHighlight() |
557 { | 657 { |
558 if (!m_highlightQuad) | 658 if (!m_highlightQuad) |
559 return; | 659 return; |
560 | 660 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 m_timer.stop(); | 785 m_timer.stop(); |
686 } | 786 } |
687 | 787 |
688 void InspectorOverlay::startedRecordingProfile() | 788 void InspectorOverlay::startedRecordingProfile() |
689 { | 789 { |
690 if (!m_activeProfilerCount++) | 790 if (!m_activeProfilerCount++) |
691 freePage(); | 791 freePage(); |
692 } | 792 } |
693 | 793 |
694 } // namespace WebCore | 794 } // namespace WebCore |
OLD | NEW |