Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
| 3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
| 4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
| 5 * 2000 Simon Hausmann <hausmann@kde.org> | 5 * 2000 Simon Hausmann <hausmann@kde.org> |
| 6 * 2000 Stefan Schimanski <1Stein@gmx.de> | 6 * 2000 Stefan Schimanski <1Stein@gmx.de> |
| 7 * 2001 George Staikos <staikos@kde.org> | 7 * 2001 George Staikos <staikos@kde.org> |
| 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. |
| 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> | 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
| 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 frame->view()->setBaseBackgroundColor(backgroundColor); | 651 frame->view()->setBaseBackgroundColor(backgroundColor); |
| 652 frame->view()->setNodeToDraw(0); | 652 frame->view()->setNodeToDraw(0); |
| 653 } | 653 } |
| 654 | 654 |
| 655 Frame* frame; | 655 Frame* frame; |
| 656 Node* node; | 656 Node* node; |
| 657 PaintBehavior paintBehavior; | 657 PaintBehavior paintBehavior; |
| 658 Color backgroundColor; | 658 Color backgroundColor; |
| 659 }; | 659 }; |
| 660 | 660 |
| 661 DragImageRef Frame::nodeImage(Node* node) | 661 PassOwnPtr<DragImage> Frame::nodeImage(Node* node) |
| 662 { | 662 { |
| 663 if (!node->renderer()) | 663 if (!node->renderer()) |
| 664 return 0; | 664 return PassOwnPtr<DragImage>(); |
|
jamesr
2013/06/17 17:51:00
return nullptr;
jbroman
2013/06/17 18:52:10
Done.
| |
| 665 | 665 |
| 666 const ScopedFramePaintingState state(this, node); | 666 const ScopedFramePaintingState state(this, node); |
| 667 | 667 |
| 668 m_view->setPaintBehavior(state.paintBehavior | PaintBehaviorFlattenCompositi ngLayers); | 668 m_view->setPaintBehavior(state.paintBehavior | PaintBehaviorFlattenCompositi ngLayers); |
| 669 | 669 |
| 670 // When generating the drag image for an element, ignore the document backgr ound. | 670 // When generating the drag image for an element, ignore the document backgr ound. |
| 671 m_view->setBaseBackgroundColor(Color::transparent); | 671 m_view->setBaseBackgroundColor(Color::transparent); |
| 672 document()->updateLayout(); | 672 document()->updateLayout(); |
| 673 m_view->setNodeToDraw(node); // Enable special sub-tree drawing mode. | 673 m_view->setNodeToDraw(node); // Enable special sub-tree drawing mode. |
| 674 | 674 |
| 675 // Document::updateLayout may have blown away the original RenderObject. | 675 // Document::updateLayout may have blown away the original RenderObject. |
| 676 RenderObject* renderer = node->renderer(); | 676 RenderObject* renderer = node->renderer(); |
| 677 if (!renderer) | 677 if (!renderer) |
| 678 return 0; | 678 return PassOwnPtr<DragImage>(); |
| 679 | 679 |
| 680 LayoutRect topLevelRect; | 680 LayoutRect topLevelRect; |
| 681 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect)); | 681 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect)); |
| 682 | 682 |
| 683 float deviceScaleFactor = 1; | 683 float deviceScaleFactor = 1; |
| 684 if (m_page) | 684 if (m_page) |
| 685 deviceScaleFactor = m_page->deviceScaleFactor(); | 685 deviceScaleFactor = m_page->deviceScaleFactor(); |
| 686 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); | 686 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); |
| 687 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); | 687 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); |
| 688 | 688 |
| 689 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); | 689 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); |
| 690 if (!buffer) | 690 if (!buffer) |
| 691 return 0; | 691 return PassOwnPtr<DragImage>(); |
| 692 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); | 692 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); |
| 693 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); | 693 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); |
| 694 | 694 |
| 695 m_view->paintContents(buffer->context(), paintingRect); | 695 m_view->paintContents(buffer->context(), paintingRect); |
| 696 | 696 |
| 697 RefPtr<Image> image = buffer->copyImage(); | 697 RefPtr<Image> image = buffer->copyImage(); |
| 698 return createDragImageFromImage(image.get(), renderer->shouldRespectImageOri entation()); | 698 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio n()); |
| 699 } | 699 } |
| 700 | 700 |
| 701 DragImageRef Frame::dragImageForSelection() | 701 PassOwnPtr<DragImage> Frame::dragImageForSelection() |
| 702 { | 702 { |
| 703 if (!selection()->isRange()) | 703 if (!selection()->isRange()) |
| 704 return 0; | 704 return PassOwnPtr<DragImage>(); |
| 705 | 705 |
| 706 const ScopedFramePaintingState state(this, 0); | 706 const ScopedFramePaintingState state(this, 0); |
| 707 m_view->setPaintBehavior(PaintBehaviorSelectionOnly); | 707 m_view->setPaintBehavior(PaintBehaviorSelectionOnly); |
| 708 document()->updateLayout(); | 708 document()->updateLayout(); |
| 709 | 709 |
| 710 IntRect paintingRect = enclosingIntRect(selection()->bounds()); | 710 IntRect paintingRect = enclosingIntRect(selection()->bounds()); |
| 711 | 711 |
| 712 float deviceScaleFactor = 1; | 712 float deviceScaleFactor = 1; |
| 713 if (m_page) | 713 if (m_page) |
| 714 deviceScaleFactor = m_page->deviceScaleFactor(); | 714 deviceScaleFactor = m_page->deviceScaleFactor(); |
| 715 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); | 715 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); |
| 716 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); | 716 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); |
| 717 | 717 |
| 718 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); | 718 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); |
| 719 if (!buffer) | 719 if (!buffer) |
| 720 return 0; | 720 return PassOwnPtr<DragImage>(); |
| 721 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); | 721 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); |
| 722 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); | 722 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); |
| 723 | 723 |
| 724 m_view->paintContents(buffer->context(), paintingRect); | 724 m_view->paintContents(buffer->context(), paintingRect); |
| 725 | 725 |
| 726 RefPtr<Image> image = buffer->copyImage(); | 726 RefPtr<Image> image = buffer->copyImage(); |
| 727 return createDragImageFromImage(image.get()); | 727 return DragImage::create(image.get()); |
| 728 } | 728 } |
| 729 | 729 |
| 730 } // namespace WebCore | 730 } // namespace WebCore |
| OLD | NEW |