| 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 642 |
| 643 LayoutRect topLevelRect; | 643 LayoutRect topLevelRect; |
| 644 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev
elRect)); | 644 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev
elRect)); |
| 645 | 645 |
| 646 float deviceScaleFactor = 1; | 646 float deviceScaleFactor = 1; |
| 647 if (m_page) | 647 if (m_page) |
| 648 deviceScaleFactor = m_page->deviceScaleFactor(); | 648 deviceScaleFactor = m_page->deviceScaleFactor(); |
| 649 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); | 649 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); |
| 650 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); | 650 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); |
| 651 | 651 |
| 652 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc
aleFactor)); | 652 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size()); |
| 653 if (!buffer) | 653 if (!buffer) |
| 654 return nullptr; | 654 return nullptr; |
| 655 buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor)); |
| 655 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); | 656 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); |
| 656 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma
xY())); | 657 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma
xY())); |
| 657 | 658 |
| 658 m_view->paintContents(buffer->context(), paintingRect); | 659 m_view->paintContents(buffer->context(), paintingRect); |
| 659 | 660 |
| 660 RefPtr<Image> image = buffer->copyImage(); | 661 RefPtr<Image> image = buffer->copyImage(); |
| 661 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio
n()); | 662 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio
n()); |
| 662 } | 663 } |
| 663 | 664 |
| 664 PassOwnPtr<DragImage> Frame::dragImageForSelection() | 665 PassOwnPtr<DragImage> Frame::dragImageForSelection() |
| 665 { | 666 { |
| 666 if (!selection().isRange()) | 667 if (!selection().isRange()) |
| 667 return nullptr; | 668 return nullptr; |
| 668 | 669 |
| 669 const ScopedFramePaintingState state(this, 0); | 670 const ScopedFramePaintingState state(this, 0); |
| 670 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo
mpositingLayers); | 671 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo
mpositingLayers); |
| 671 document()->updateLayout(); | 672 document()->updateLayout(); |
| 672 | 673 |
| 673 IntRect paintingRect = enclosingIntRect(selection().bounds()); | 674 IntRect paintingRect = enclosingIntRect(selection().bounds()); |
| 674 | 675 |
| 675 float deviceScaleFactor = 1; | 676 float deviceScaleFactor = 1; |
| 676 if (m_page) | 677 if (m_page) |
| 677 deviceScaleFactor = m_page->deviceScaleFactor(); | 678 deviceScaleFactor = m_page->deviceScaleFactor(); |
| 678 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); | 679 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); |
| 679 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); | 680 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); |
| 680 | 681 |
| 681 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc
aleFactor)); | 682 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size()); |
| 682 if (!buffer) | 683 if (!buffer) |
| 683 return nullptr; | 684 return nullptr; |
| 685 buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor)); |
| 684 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); | 686 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); |
| 685 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma
xY())); | 687 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma
xY())); |
| 686 | 688 |
| 687 m_view->paintContents(buffer->context(), paintingRect); | 689 m_view->paintContents(buffer->context(), paintingRect); |
| 688 | 690 |
| 689 RefPtr<Image> image = buffer->copyImage(); | 691 RefPtr<Image> image = buffer->copyImage(); |
| 690 return DragImage::create(image.get()); | 692 return DragImage::create(image.get()); |
| 691 } | 693 } |
| 692 | 694 |
| 693 double Frame::devicePixelRatio() const | 695 double Frame::devicePixelRatio() const |
| 694 { | 696 { |
| 695 if (!m_page) | 697 if (!m_page) |
| 696 return 0; | 698 return 0; |
| 697 | 699 |
| 698 double ratio = m_page->deviceScaleFactor(); | 700 double ratio = m_page->deviceScaleFactor(); |
| 699 if (RuntimeEnabledFeatures::devicePixelRatioIncludesZoomEnabled()) | 701 if (RuntimeEnabledFeatures::devicePixelRatioIncludesZoomEnabled()) |
| 700 ratio *= pageZoomFactor(); | 702 ratio *= pageZoomFactor(); |
| 701 return ratio; | 703 return ratio; |
| 702 } | 704 } |
| 703 | 705 |
| 704 } // namespace WebCore | 706 } // namespace WebCore |
| OLD | NEW |