2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that the following conditions
5 * 1. Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * 2. Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
11 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
12 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
15 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
18 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
19 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include "FrameView.h"
28 #include "GraphicsContext.h"
30 #include "ImageBuffer.h"
32 #include "NotImplemented.h"
36 DragImageRef Frame::nodeImage(Node*)
42 DragImageRef Frame::dragImageForSelection()
44 if (!selection()->isRange())
47 m_doc->updateLayout();
49 IntRect paintingRect = enclosingIntRect(selection()->bounds());
50 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size()));
54 GraphicsContext* context = buffer->context();
55 context->translate(-paintingRect.x(), -paintingRect.y());
56 context->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
58 PaintBehavior previousPaintBehavior = m_view->paintBehavior();
59 m_view->setPaintBehavior(PaintBehaviorSelectionOnly);
60 m_view->paintContents(context, paintingRect);
61 m_view->setPaintBehavior(previousPaintBehavior);
63 RefPtr<Image> image = buffer->copyImage();
64 return createDragImageFromImage(image.get());