| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 namespace { | 91 namespace { |
| 92 | 92 |
| 93 // Convenience class for initializing a GraphicsContext to build a DragImage fro
m a specific | 93 // Convenience class for initializing a GraphicsContext to build a DragImage fro
m a specific |
| 94 // region specified by |bounds|. After painting the using context(), the DragIma
ge returned from | 94 // region specified by |bounds|. After painting the using context(), the DragIma
ge returned from |
| 95 // createImage() will only contain the content in |bounds| with the appropriate
device scale | 95 // createImage() will only contain the content in |bounds| with the appropriate
device scale |
| 96 // factor included. | 96 // factor included. |
| 97 class DragImageBuilder { | 97 class DragImageBuilder { |
| 98 STACK_ALLOCATED(); | 98 STACK_ALLOCATED(); |
| 99 public: | 99 public: |
| 100 DragImageBuilder(const LocalFrame* localFrame, const IntRect& bounds, Node*
draggedNode, float opacity = 1) | 100 DragImageBuilder(const LocalFrame* localFrame, const FloatRect& bounds, Node
* draggedNode, float opacity = 1) |
| 101 : m_localFrame(localFrame) | 101 : m_localFrame(localFrame) |
| 102 , m_draggedNode(draggedNode) | 102 , m_draggedNode(draggedNode) |
| 103 , m_bounds(bounds) | 103 , m_bounds(bounds) |
| 104 , m_opacity(opacity) | 104 , m_opacity(opacity) |
| 105 { | 105 { |
| 106 if (m_draggedNode && m_draggedNode->layoutObject()) | 106 if (m_draggedNode && m_draggedNode->layoutObject()) |
| 107 m_draggedNode->layoutObject()->updateDragState(true); | 107 m_draggedNode->layoutObject()->updateDragState(true); |
| 108 | 108 |
| 109 float deviceScaleFactor = m_localFrame->host()->deviceScaleFactor(); | 109 float deviceScaleFactor = m_localFrame->host()->deviceScaleFactor(); |
| 110 m_bounds.setWidth(m_bounds.width() * deviceScaleFactor); | 110 m_bounds.setWidth(m_bounds.width() * deviceScaleFactor); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 133 imageOrientation = LayoutObject::shouldRespectImageOrientation(m_dra
ggedNode->layoutObject()); | 133 imageOrientation = LayoutObject::shouldRespectImageOrientation(m_dra
ggedNode->layoutObject()); |
| 134 | 134 |
| 135 float screenDeviceScaleFactor = m_localFrame->page()->chromeClient().scr
eenInfo().deviceScaleFactor; | 135 float screenDeviceScaleFactor = m_localFrame->page()->chromeClient().scr
eenInfo().deviceScaleFactor; |
| 136 | 136 |
| 137 return DragImage::create(image.get(), imageOrientation, screenDeviceScal
eFactor, InterpolationHigh, m_opacity); | 137 return DragImage::create(image.get(), imageOrientation, screenDeviceScal
eFactor, InterpolationHigh, m_opacity); |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 RawPtrWillBeMember<const LocalFrame> m_localFrame; | 141 RawPtrWillBeMember<const LocalFrame> m_localFrame; |
| 142 RawPtrWillBeMember<Node> m_draggedNode; | 142 RawPtrWillBeMember<Node> m_draggedNode; |
| 143 IntRect m_bounds; | 143 FloatRect m_bounds; |
| 144 float m_opacity; | 144 float m_opacity; |
| 145 OwnPtr<SkPictureBuilder> m_pictureBuilder; | 145 OwnPtr<SkPictureBuilder> m_pictureBuilder; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 inline float parentPageZoomFactor(LocalFrame* frame) | 148 inline float parentPageZoomFactor(LocalFrame* frame) |
| 149 { | 149 { |
| 150 Frame* parent = frame->tree().parent(); | 150 Frame* parent = frame->tree().parent(); |
| 151 if (!parent || !parent->isLocalFrame()) | 151 if (!parent || !parent->isLocalFrame()) |
| 152 return 1; | 152 return 1; |
| 153 return toLocalFrame(parent)->pageZoomFactor(); | 153 return toLocalFrame(parent)->pageZoomFactor(); |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 double LocalFrame::devicePixelRatio() const | 624 double LocalFrame::devicePixelRatio() const |
| 625 { | 625 { |
| 626 if (!m_host) | 626 if (!m_host) |
| 627 return 0; | 627 return 0; |
| 628 | 628 |
| 629 double ratio = m_host->deviceScaleFactor(); | 629 double ratio = m_host->deviceScaleFactor(); |
| 630 ratio *= pageZoomFactor(); | 630 ratio *= pageZoomFactor(); |
| 631 return ratio; | 631 return ratio; |
| 632 } | 632 } |
| 633 | 633 |
| 634 PassOwnPtr<DragImage> LocalFrame::paintIntoDragImage(const GlobalPaintFlags glob
alPaintFlags, | |
| 635 IntRect paintingRect, Node* draggedNode, float opacity) | |
| 636 { | |
| 637 ASSERT(document()->isActive()); | |
| 638 // Not flattening compositing layers will result in a broken image being pai
nted. | |
| 639 ASSERT(globalPaintFlags & GlobalPaintFlattenCompositingLayers); | |
| 640 | |
| 641 DragImageBuilder dragImageBuilder(this, paintingRect, draggedNode, opacity); | |
| 642 m_view->paintContents(dragImageBuilder.context(), globalPaintFlags, painting
Rect); | |
| 643 return dragImageBuilder.createImage(); | |
| 644 } | |
| 645 | |
| 646 PassOwnPtr<DragImage> LocalFrame::nodeImage(Node& node) | 634 PassOwnPtr<DragImage> LocalFrame::nodeImage(Node& node) |
| 647 { | 635 { |
| 648 m_view->updateAllLifecyclePhases(); | 636 m_view->updateAllLifecyclePhases(); |
| 649 LayoutObject* layoutObject = node.layoutObject(); | 637 LayoutObject* layoutObject = node.layoutObject(); |
| 650 if (!layoutObject) | 638 if (!layoutObject) |
| 651 return nullptr; | 639 return nullptr; |
| 652 | 640 |
| 653 // Directly paint boxes as if they are a stacking context. | 641 // Paint starting at the nearest self painting layer, clipped to the object
itself. |
| 654 if (layoutObject->isBox() && layoutObject->container()) { | 642 // TODO(pdr): This will also paint the content behind the object if the obje
ct contains |
| 655 IntRect boundingBox = layoutObject->absoluteBoundingBoxRectIncludingDesc
endants(); | 643 // transparency but the layer is opaque. We could directly call layoutObject
->paint(...) |
| 656 LayoutPoint paintOffset = boundingBox.location() - layoutObject->offsetF
romContainer(layoutObject->container(), LayoutPoint()); | 644 // (see ObjectPainter::paintAsPseudoStackingContext) but this would skip sel
f-painting children. |
| 657 | 645 PaintLayer* layer = layoutObject->enclosingLayer()->enclosingSelfPaintingLay
er(); |
| 658 DragImageBuilder dragImageBuilder(this, boundingBox, &node); | 646 IntRect absoluteBoundingBox = layoutObject->absoluteBoundingBoxRectIncluding
Descendants(); |
| 659 { | 647 FloatRect boundingBox = layer->layoutObject()->absoluteToLocalQuad(FloatQuad
(absoluteBoundingBox), UseTransforms).boundingBox(); |
| 660 PaintInfo paintInfo(dragImageBuilder.context(), boundingBox, PaintPh
ase::PaintPhaseForeground, GlobalPaintFlattenCompositingLayers, 0); | 648 DragImageBuilder dragImageBuilder(this, boundingBox, &node); |
| 661 ObjectPainter(*layoutObject).paintAsPseudoStackingContext(paintInfo,
LayoutPoint(paintOffset)); | 649 { |
| 662 } | 650 PaintLayerPaintingInfo paintingInfo(layer, LayoutRect(boundingBox), Glob
alPaintFlattenCompositingLayers, LayoutSize(), 0); |
| 663 return dragImageBuilder.createImage(); | 651 PaintLayerFlags flags = PaintLayerHaveTransparency | PaintLayerAppliedTr
ansform | PaintLayerUncachedClipRects; |
| 652 PaintLayerPainter(*layer).paintLayer(dragImageBuilder.context(), paintin
gInfo, flags); |
| 664 } | 653 } |
| 665 | 654 return dragImageBuilder.createImage(); |
| 666 // TODO(pdr): This will also paint the background if the object contains tra
nsparency. We can | |
| 667 // directly call layoutObject->paint(...) (see: ObjectPainter::paintAsPseudo
StackingContext) but | |
| 668 // painters are inconsistent about which transform space they expect (see: s
vg, inlines, etc.) | |
| 669 return paintIntoDragImage(GlobalPaintFlattenCompositingLayers, layoutObject-
>absoluteBoundingBoxRectIncludingDescendants(), &node); | |
| 670 } | 655 } |
| 671 | 656 |
| 672 PassOwnPtr<DragImage> LocalFrame::dragImageForSelection(float opacity) | 657 PassOwnPtr<DragImage> LocalFrame::dragImageForSelection(float opacity) |
| 673 { | 658 { |
| 674 if (!selection().isRange()) | 659 if (!selection().isRange()) |
| 675 return nullptr; | 660 return nullptr; |
| 676 | 661 |
| 677 m_view->updateAllLifecyclePhases(); | 662 m_view->updateAllLifecyclePhases(); |
| 663 ASSERT(document()->isActive()); |
| 678 | 664 |
| 679 return paintIntoDragImage(GlobalPaintSelectionOnly | GlobalPaintFlattenCompo
sitingLayers, | 665 FloatRect paintingRect = FloatRect(selection().bounds()); |
| 680 enclosingIntRect(selection().bounds()), nullptr, opacity); | 666 DragImageBuilder dragImageBuilder(this, paintingRect, nullptr, opacity); |
| 667 GlobalPaintFlags paintFlags = GlobalPaintSelectionOnly | GlobalPaintFlattenC
ompositingLayers; |
| 668 m_view->paintContents(dragImageBuilder.context(), paintFlags, enclosingIntRe
ct(paintingRect)); |
| 669 return dragImageBuilder.createImage(); |
| 681 } | 670 } |
| 682 | 671 |
| 683 String LocalFrame::selectedText() const | 672 String LocalFrame::selectedText() const |
| 684 { | 673 { |
| 685 return selection().selectedText(); | 674 return selection().selectedText(); |
| 686 } | 675 } |
| 687 | 676 |
| 688 String LocalFrame::selectedTextForClipboard() const | 677 String LocalFrame::selectedTextForClipboard() const |
| 689 { | 678 { |
| 690 return selection().selectedTextForClipboard(); | 679 return selection().selectedTextForClipboard(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 { | 877 { |
| 889 m_frame->disableNavigation(); | 878 m_frame->disableNavigation(); |
| 890 } | 879 } |
| 891 | 880 |
| 892 FrameNavigationDisabler::~FrameNavigationDisabler() | 881 FrameNavigationDisabler::~FrameNavigationDisabler() |
| 893 { | 882 { |
| 894 m_frame->enableNavigation(); | 883 m_frame->enableNavigation(); |
| 895 } | 884 } |
| 896 | 885 |
| 897 } // namespace blink | 886 } // namespace blink |
| OLD | NEW |