| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 NSImage* Frame::snapshotDragImage(Node* node, NSRect* imageRect, NSRect* element
Rect) const | 151 NSImage* Frame::snapshotDragImage(Node* node, NSRect* imageRect, NSRect* element
Rect) const |
| 152 { | 152 { |
| 153 RenderObject* renderer = node->renderer(); | 153 RenderObject* renderer = node->renderer(); |
| 154 if (!renderer) | 154 if (!renderer) |
| 155 return nil; | 155 return nil; |
| 156 | 156 |
| 157 renderer->updateDragState(true); // mark dragged nodes (so they pick up t
he right CSS) | 157 renderer->updateDragState(true); // mark dragged nodes (so they pick up t
he right CSS) |
| 158 m_doc->updateLayout(); // forces style recalc - needed since changing
the drag state might | 158 m_doc->updateLayout(); // forces style recalc - needed since changing
the drag state might |
| 159 // imply new styles, plus JS could have
changed other things | 159 // imply new styles, plus JS could have
changed other things |
| 160 |
| 161 |
| 162 // Document::updateLayout may have blown away the original RenderObject. |
| 163 renderer = node->renderer(); |
| 164 if (!renderer) |
| 165 return nil; |
| 166 |
| 160 LayoutRect topLevelRect; | 167 LayoutRect topLevelRect; |
| 161 NSRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLeve
lRect)); | 168 NSRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLeve
lRect)); |
| 162 | 169 |
| 163 m_view->setNodeToDraw(node); // invoke special sub-tree drawing
mode | 170 m_view->setNodeToDraw(node); // invoke special sub-tree drawing
mode |
| 164 NSImage* result = imageFromRect(paintingRect); | 171 NSImage* result = imageFromRect(paintingRect); |
| 165 renderer->updateDragState(false); | 172 renderer->updateDragState(false); |
| 166 m_doc->updateLayout(); | 173 m_doc->updateLayout(); |
| 167 m_view->setNodeToDraw(0); | 174 m_view->setNodeToDraw(0); |
| 168 | 175 |
| 169 if (elementRect) | 176 if (elementRect) |
| 170 *elementRect = pixelSnappedIntRect(topLevelRect); | 177 *elementRect = pixelSnappedIntRect(topLevelRect); |
| 171 if (imageRect) | 178 if (imageRect) |
| 172 *imageRect = paintingRect; | 179 *imageRect = paintingRect; |
| 173 return result; | 180 return result; |
| 174 } | 181 } |
| 175 | 182 |
| 176 DragImageRef Frame::nodeImage(Node* node) | 183 DragImageRef Frame::nodeImage(Node* node) |
| 177 { | 184 { |
| 185 m_doc->updateLayout(); // forces style recalc |
| 186 |
| 178 RenderObject* renderer = node->renderer(); | 187 RenderObject* renderer = node->renderer(); |
| 179 if (!renderer) | 188 if (!renderer) |
| 180 return nil; | 189 return nil; |
| 181 | |
| 182 m_doc->updateLayout(); // forces style recalc | |
| 183 | |
| 184 LayoutRect topLevelRect; | 190 LayoutRect topLevelRect; |
| 185 NSRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLeve
lRect)); | 191 NSRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLeve
lRect)); |
| 186 | 192 |
| 187 m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode | 193 m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode |
| 188 NSImage* result = imageFromRect(paintingRect); | 194 NSImage* result = imageFromRect(paintingRect); |
| 189 m_view->setNodeToDraw(0); | 195 m_view->setNodeToDraw(0); |
| 190 | 196 |
| 191 return result; | 197 return result; |
| 192 } | 198 } |
| 193 | 199 |
| 194 DragImageRef Frame::dragImageForSelection() | 200 DragImageRef Frame::dragImageForSelection() |
| 195 { | 201 { |
| 196 if (!selection()->isRange()) | 202 if (!selection()->isRange()) |
| 197 return nil; | 203 return nil; |
| 198 return selectionImage(); | 204 return selectionImage(); |
| 199 } | 205 } |
| 200 | 206 |
| 201 } // namespace WebCore | 207 } // namespace WebCore |
| OLD | NEW |