Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #include "platform/graphics/paint/PaintController.h" 78 #include "platform/graphics/paint/PaintController.h"
79 #include "platform/graphics/paint/SkPictureBuilder.h" 79 #include "platform/graphics/paint/SkPictureBuilder.h"
80 #include "platform/graphics/paint/TransformDisplayItem.h" 80 #include "platform/graphics/paint/TransformDisplayItem.h"
81 #include "platform/plugins/PluginData.h" 81 #include "platform/plugins/PluginData.h"
82 #include "platform/text/TextStream.h" 82 #include "platform/text/TextStream.h"
83 #include "public/platform/ServiceRegistry.h" 83 #include "public/platform/ServiceRegistry.h"
84 #include "public/platform/WebFrameScheduler.h" 84 #include "public/platform/WebFrameScheduler.h"
85 #include "public/platform/WebScreenInfo.h" 85 #include "public/platform/WebScreenInfo.h"
86 #include "public/platform/WebViewScheduler.h" 86 #include "public/platform/WebViewScheduler.h"
87 #include "third_party/skia/include/core/SkImage.h" 87 #include "third_party/skia/include/core/SkImage.h"
88 #include "wtf/PassOwnPtr.h" 88 #include "wtf/PtrUtil.h"
89 #include "wtf/StdLibExtras.h" 89 #include "wtf/StdLibExtras.h"
90 #include <memory>
90 91
91 namespace blink { 92 namespace blink {
92 93
93 using namespace HTMLNames; 94 using namespace HTMLNames;
94 95
95 namespace { 96 namespace {
96 97
97 // Convenience class for initializing a GraphicsContext to build a DragImage fro m a specific 98 // Convenience class for initializing a GraphicsContext to build a DragImage fro m a specific
98 // region specified by |bounds|. After painting the using context(), the DragIma ge returned from 99 // region specified by |bounds|. After painting the using context(), the DragIma ge returned from
99 // createImage() will only contain the content in |bounds| with the appropriate device scale 100 // createImage() will only contain the content in |bounds| with the appropriate device scale
100 // factor included. 101 // factor included.
101 class DragImageBuilder { 102 class DragImageBuilder {
102 STACK_ALLOCATED(); 103 STACK_ALLOCATED();
103 public: 104 public:
104 DragImageBuilder(const LocalFrame* localFrame, const FloatRect& bounds, Node * draggedNode, float opacity = 1) 105 DragImageBuilder(const LocalFrame* localFrame, const FloatRect& bounds, Node * draggedNode, float opacity = 1)
105 : m_localFrame(localFrame) 106 : m_localFrame(localFrame)
106 , m_draggedNode(draggedNode) 107 , m_draggedNode(draggedNode)
107 , m_bounds(bounds) 108 , m_bounds(bounds)
108 , m_opacity(opacity) 109 , m_opacity(opacity)
109 { 110 {
110 if (m_draggedNode && m_draggedNode->layoutObject()) 111 if (m_draggedNode && m_draggedNode->layoutObject())
111 m_draggedNode->layoutObject()->updateDragState(true); 112 m_draggedNode->layoutObject()->updateDragState(true);
112 float deviceScaleFactor = m_localFrame->host()->chromeClient().screenInf o().deviceScaleFactor; 113 float deviceScaleFactor = m_localFrame->host()->chromeClient().screenInf o().deviceScaleFactor;
113 114
114 m_bounds.setWidth(m_bounds.width() * deviceScaleFactor); 115 m_bounds.setWidth(m_bounds.width() * deviceScaleFactor);
115 m_bounds.setHeight(m_bounds.height() * deviceScaleFactor); 116 m_bounds.setHeight(m_bounds.height() * deviceScaleFactor);
116 m_pictureBuilder = adoptPtr(new SkPictureBuilder(SkRect::MakeIWH(m_bound s.width(), m_bounds.height()))); 117 m_pictureBuilder = wrapUnique(new SkPictureBuilder(SkRect::MakeIWH(m_bou nds.width(), m_bounds.height())));
117 118
118 AffineTransform transform; 119 AffineTransform transform;
119 transform.scale(deviceScaleFactor, deviceScaleFactor); 120 transform.scale(deviceScaleFactor, deviceScaleFactor);
120 transform.translate(-m_bounds.x(), -m_bounds.y()); 121 transform.translate(-m_bounds.x(), -m_bounds.y());
121 context().getPaintController().createAndAppend<BeginTransformDisplayItem >(*m_pictureBuilder, transform); 122 context().getPaintController().createAndAppend<BeginTransformDisplayItem >(*m_pictureBuilder, transform);
122 } 123 }
123 124
124 GraphicsContext& context() { return m_pictureBuilder->context(); } 125 GraphicsContext& context() { return m_pictureBuilder->context(); }
125 126
126 PassOwnPtr<DragImage> createImage() 127 std::unique_ptr<DragImage> createImage()
127 { 128 {
128 if (m_draggedNode && m_draggedNode->layoutObject()) 129 if (m_draggedNode && m_draggedNode->layoutObject())
129 m_draggedNode->layoutObject()->updateDragState(false); 130 m_draggedNode->layoutObject()->updateDragState(false);
130 context().getPaintController().endItem<EndTransformDisplayItem>(*m_pictu reBuilder); 131 context().getPaintController().endItem<EndTransformDisplayItem>(*m_pictu reBuilder);
131 RefPtr<const SkPicture> recording = m_pictureBuilder->endRecording(); 132 RefPtr<const SkPicture> recording = m_pictureBuilder->endRecording();
132 RefPtr<SkImage> skImage = adoptRef(SkImage::NewFromPicture(recording.get (), 133 RefPtr<SkImage> skImage = adoptRef(SkImage::NewFromPicture(recording.get (),
133 SkISize::Make(m_bounds.width(), m_bounds.height()), nullptr, nullptr )); 134 SkISize::Make(m_bounds.width(), m_bounds.height()), nullptr, nullptr ));
134 RefPtr<Image> image = StaticBitmapImage::create(skImage.release()); 135 RefPtr<Image> image = StaticBitmapImage::create(skImage.release());
135 RespectImageOrientationEnum imageOrientation = DoNotRespectImageOrientat ion; 136 RespectImageOrientationEnum imageOrientation = DoNotRespectImageOrientat ion;
136 if (m_draggedNode && m_draggedNode->layoutObject()) 137 if (m_draggedNode && m_draggedNode->layoutObject())
137 imageOrientation = LayoutObject::shouldRespectImageOrientation(m_dra ggedNode->layoutObject()); 138 imageOrientation = LayoutObject::shouldRespectImageOrientation(m_dra ggedNode->layoutObject());
138 139
139 float screenDeviceScaleFactor = m_localFrame->page()->chromeClient().scr eenInfo().deviceScaleFactor; 140 float screenDeviceScaleFactor = m_localFrame->page()->chromeClient().scr eenInfo().deviceScaleFactor;
140 141
141 return DragImage::create(image.get(), imageOrientation, screenDeviceScal eFactor, InterpolationHigh, m_opacity); 142 return DragImage::create(image.get(), imageOrientation, screenDeviceScal eFactor, InterpolationHigh, m_opacity);
142 } 143 }
143 144
144 private: 145 private:
145 Member<const LocalFrame> m_localFrame; 146 Member<const LocalFrame> m_localFrame;
146 Member<Node> m_draggedNode; 147 Member<Node> m_draggedNode;
147 FloatRect m_bounds; 148 FloatRect m_bounds;
148 float m_opacity; 149 float m_opacity;
149 OwnPtr<SkPictureBuilder> m_pictureBuilder; 150 std::unique_ptr<SkPictureBuilder> m_pictureBuilder;
150 }; 151 };
151 152
152 inline float parentPageZoomFactor(LocalFrame* frame) 153 inline float parentPageZoomFactor(LocalFrame* frame)
153 { 154 {
154 Frame* parent = frame->tree().parent(); 155 Frame* parent = frame->tree().parent();
155 if (!parent || !parent->isLocalFrame()) 156 if (!parent || !parent->isLocalFrame())
156 return 1; 157 return 1;
157 return toLocalFrame(parent)->pageZoomFactor(); 158 return toLocalFrame(parent)->pageZoomFactor();
158 } 159 }
159 160
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 double LocalFrame::devicePixelRatio() const 585 double LocalFrame::devicePixelRatio() const
585 { 586 {
586 if (!m_host) 587 if (!m_host)
587 return 0; 588 return 0;
588 589
589 double ratio = m_host->deviceScaleFactorDeprecated(); 590 double ratio = m_host->deviceScaleFactorDeprecated();
590 ratio *= pageZoomFactor(); 591 ratio *= pageZoomFactor();
591 return ratio; 592 return ratio;
592 } 593 }
593 594
594 PassOwnPtr<DragImage> LocalFrame::nodeImage(Node& node) 595 std::unique_ptr<DragImage> LocalFrame::nodeImage(Node& node)
595 { 596 {
596 m_view->updateAllLifecyclePhasesExceptPaint(); 597 m_view->updateAllLifecyclePhasesExceptPaint();
597 LayoutObject* layoutObject = node.layoutObject(); 598 LayoutObject* layoutObject = node.layoutObject();
598 if (!layoutObject) 599 if (!layoutObject)
599 return nullptr; 600 return nullptr;
600 601
601 // Paint starting at the nearest stacking context, clipped to the object its elf. 602 // Paint starting at the nearest stacking context, clipped to the object its elf.
602 // This will also paint the contents behind the object if the object contain s transparency 603 // This will also paint the contents behind the object if the object contain s transparency
603 // and there are other elements in the same stacking context which stacked b elow. 604 // and there are other elements in the same stacking context which stacked b elow.
604 PaintLayer* layer = layoutObject->enclosingLayer(); 605 PaintLayer* layer = layoutObject->enclosingLayer();
605 if (!layer->stackingNode()->isStackingContext()) 606 if (!layer->stackingNode()->isStackingContext())
606 layer = layer->stackingNode()->ancestorStackingContextNode()->layer(); 607 layer = layer->stackingNode()->ancestorStackingContextNode()->layer();
607 IntRect absoluteBoundingBox = layoutObject->absoluteBoundingBoxRectIncluding Descendants(); 608 IntRect absoluteBoundingBox = layoutObject->absoluteBoundingBoxRectIncluding Descendants();
608 FloatRect boundingBox = layer->layoutObject()->absoluteToLocalQuad(FloatQuad (absoluteBoundingBox), UseTransforms).boundingBox(); 609 FloatRect boundingBox = layer->layoutObject()->absoluteToLocalQuad(FloatQuad (absoluteBoundingBox), UseTransforms).boundingBox();
609 DragImageBuilder dragImageBuilder(this, boundingBox, &node); 610 DragImageBuilder dragImageBuilder(this, boundingBox, &node);
610 { 611 {
611 PaintLayerPaintingInfo paintingInfo(layer, LayoutRect(boundingBox), Glob alPaintFlattenCompositingLayers, LayoutSize()); 612 PaintLayerPaintingInfo paintingInfo(layer, LayoutRect(boundingBox), Glob alPaintFlattenCompositingLayers, LayoutSize());
612 PaintLayerFlags flags = PaintLayerHaveTransparency | PaintLayerAppliedTr ansform | PaintLayerUncachedClipRects; 613 PaintLayerFlags flags = PaintLayerHaveTransparency | PaintLayerAppliedTr ansform | PaintLayerUncachedClipRects;
613 PaintLayerPainter(*layer).paintLayer(dragImageBuilder.context(), paintin gInfo, flags); 614 PaintLayerPainter(*layer).paintLayer(dragImageBuilder.context(), paintin gInfo, flags);
614 } 615 }
615 return dragImageBuilder.createImage(); 616 return dragImageBuilder.createImage();
616 } 617 }
617 618
618 PassOwnPtr<DragImage> LocalFrame::dragImageForSelection(float opacity) 619 std::unique_ptr<DragImage> LocalFrame::dragImageForSelection(float opacity)
619 { 620 {
620 if (!selection().isRange()) 621 if (!selection().isRange())
621 return nullptr; 622 return nullptr;
622 623
623 m_view->updateAllLifecyclePhasesExceptPaint(); 624 m_view->updateAllLifecyclePhasesExceptPaint();
624 ASSERT(document()->isActive()); 625 ASSERT(document()->isActive());
625 626
626 FloatRect paintingRect = FloatRect(selection().bounds()); 627 FloatRect paintingRect = FloatRect(selection().bounds());
627 DragImageBuilder dragImageBuilder(this, paintingRect, nullptr, opacity); 628 DragImageBuilder dragImageBuilder(this, paintingRect, nullptr, opacity);
628 GlobalPaintFlags paintFlags = GlobalPaintSelectionOnly | GlobalPaintFlattenC ompositingLayers; 629 GlobalPaintFlags paintFlags = GlobalPaintSelectionOnly | GlobalPaintFlattenC ompositingLayers;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 m_frame->client()->frameBlameContext()->Enter(); 815 m_frame->client()->frameBlameContext()->Enter();
815 } 816 }
816 817
817 ScopedFrameBlamer::~ScopedFrameBlamer() 818 ScopedFrameBlamer::~ScopedFrameBlamer()
818 { 819 {
819 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 820 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
820 m_frame->client()->frameBlameContext()->Leave(); 821 m_frame->client()->frameBlameContext()->Leave();
821 } 822 }
822 823
823 } // namespace blink 824 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698