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

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: Address comments from Kent; 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 double LocalFrame::devicePixelRatio() const 587 double LocalFrame::devicePixelRatio() const
587 { 588 {
588 if (!m_host) 589 if (!m_host)
589 return 0; 590 return 0;
590 591
591 double ratio = m_host->deviceScaleFactorDeprecated(); 592 double ratio = m_host->deviceScaleFactorDeprecated();
592 ratio *= pageZoomFactor(); 593 ratio *= pageZoomFactor();
593 return ratio; 594 return ratio;
594 } 595 }
595 596
596 PassOwnPtr<DragImage> LocalFrame::nodeImage(Node& node) 597 std::unique_ptr<DragImage> LocalFrame::nodeImage(Node& node)
597 { 598 {
598 m_view->updateAllLifecyclePhasesExceptPaint(); 599 m_view->updateAllLifecyclePhasesExceptPaint();
599 LayoutObject* layoutObject = node.layoutObject(); 600 LayoutObject* layoutObject = node.layoutObject();
600 if (!layoutObject) 601 if (!layoutObject)
601 return nullptr; 602 return nullptr;
602 603
603 // Paint starting at the nearest stacking context, clipped to the object its elf. 604 // Paint starting at the nearest stacking context, clipped to the object its elf.
604 // This will also paint the contents behind the object if the object contain s transparency 605 // This will also paint the contents behind the object if the object contain s transparency
605 // and there are other elements in the same stacking context which stacked b elow. 606 // and there are other elements in the same stacking context which stacked b elow.
606 PaintLayer* layer = layoutObject->enclosingLayer(); 607 PaintLayer* layer = layoutObject->enclosingLayer();
607 if (!layer->stackingNode()->isStackingContext()) 608 if (!layer->stackingNode()->isStackingContext())
608 layer = layer->stackingNode()->ancestorStackingContextNode()->layer(); 609 layer = layer->stackingNode()->ancestorStackingContextNode()->layer();
609 IntRect absoluteBoundingBox = layoutObject->absoluteBoundingBoxRectIncluding Descendants(); 610 IntRect absoluteBoundingBox = layoutObject->absoluteBoundingBoxRectIncluding Descendants();
610 FloatRect boundingBox = layer->layoutObject()->absoluteToLocalQuad(FloatQuad (absoluteBoundingBox), UseTransforms).boundingBox(); 611 FloatRect boundingBox = layer->layoutObject()->absoluteToLocalQuad(FloatQuad (absoluteBoundingBox), UseTransforms).boundingBox();
611 DragImageBuilder dragImageBuilder(this, boundingBox, &node); 612 DragImageBuilder dragImageBuilder(this, boundingBox, &node);
612 { 613 {
613 PaintLayerPaintingInfo paintingInfo(layer, LayoutRect(boundingBox), Glob alPaintFlattenCompositingLayers, LayoutSize()); 614 PaintLayerPaintingInfo paintingInfo(layer, LayoutRect(boundingBox), Glob alPaintFlattenCompositingLayers, LayoutSize());
614 PaintLayerFlags flags = PaintLayerHaveTransparency | PaintLayerAppliedTr ansform | PaintLayerUncachedClipRects; 615 PaintLayerFlags flags = PaintLayerHaveTransparency | PaintLayerAppliedTr ansform | PaintLayerUncachedClipRects;
615 PaintLayerPainter(*layer).paintLayer(dragImageBuilder.context(), paintin gInfo, flags); 616 PaintLayerPainter(*layer).paintLayer(dragImageBuilder.context(), paintin gInfo, flags);
616 } 617 }
617 return dragImageBuilder.createImage(); 618 return dragImageBuilder.createImage();
618 } 619 }
619 620
620 PassOwnPtr<DragImage> LocalFrame::dragImageForSelection(float opacity) 621 std::unique_ptr<DragImage> LocalFrame::dragImageForSelection(float opacity)
621 { 622 {
622 if (!selection().isRange()) 623 if (!selection().isRange())
623 return nullptr; 624 return nullptr;
624 625
625 m_view->updateAllLifecyclePhasesExceptPaint(); 626 m_view->updateAllLifecyclePhasesExceptPaint();
626 ASSERT(document()->isActive()); 627 ASSERT(document()->isActive());
627 628
628 FloatRect paintingRect = FloatRect(selection().bounds()); 629 FloatRect paintingRect = FloatRect(selection().bounds());
629 DragImageBuilder dragImageBuilder(this, paintingRect, nullptr, opacity); 630 DragImageBuilder dragImageBuilder(this, paintingRect, nullptr, opacity);
630 GlobalPaintFlags paintFlags = GlobalPaintSelectionOnly | GlobalPaintFlattenC ompositingLayers; 631 GlobalPaintFlags paintFlags = GlobalPaintSelectionOnly | GlobalPaintFlattenC ompositingLayers;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 m_frame->client()->frameBlameContext()->Enter(); 817 m_frame->client()->frameBlameContext()->Enter();
817 } 818 }
818 819
819 ScopedFrameBlamer::~ScopedFrameBlamer() 820 ScopedFrameBlamer::~ScopedFrameBlamer()
820 { 821 {
821 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 822 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
822 m_frame->client()->frameBlameContext()->Leave(); 823 m_frame->client()->frameBlameContext()->Leave();
823 } 824 }
824 825
825 } // namespace blink 826 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698