Consolidate various frame snapshot capabilities.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Nov 2013 22:10:33 +0000 (22:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Nov 2013 22:10:33 +0000 (22:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124325

Patch by Brian J. Burg <burg@cs.washington.edu> on 2013-11-18
Reviewed by Timothy Hatcher.

Source/WebCore:

Various snapshot creation methods had duplicated code and were split
between Frame, DragImage, and platform-specific implementationss.
This patch puts WebCore snapshot methods into FrameSnapshotting
and removes platform implementations where possible.

DragImage methods reuse snapshot methods where possible. Inspector
will be able to take snapshots without using drag images.

No new tests, this is a refactoring.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* bindings/objc/DOM.mm:
(-[DOMNode renderedImage]):
(-[DOMRange renderedImageForcingBlackText:]):
* dom/Clipboard.cpp:
(WebCore::Clipboard::createDragImage):
* dom/ClipboardMac.mm:
(WebCore::Clipboard::createDragImage):
* page/DragController.cpp:
(WebCore::DragController::startDrag):
* page/Frame.cpp:
* page/Frame.h:
* page/FrameSnapshotting.cpp: Added.
(WebCore::ScopedFramePaintingState::ScopedFramePaintingState):
(WebCore::ScopedFramePaintingState::~ScopedFramePaintingState):
(WebCore::snapshotFrameRect): Move most buffer logic to here.
(WebCore::snapshotSelection): Moved from Frame.
(WebCore::snapshotNode): Moved from Frame.
* page/FrameSnapshotting.h: Added.
* page/mac/FrameMac.mm: Removed.
* page/mac/FrameSnapshottingMac.h: Removed.
* page/mac/FrameSnapshottingMac.mm: Removed.
* page/win/FrameWin.cpp: remove duplicate implementation.
* page/win/FrameWin.h: Fix an incorrect parameter name.
* platform/DragImage.cpp:
(WebCore::ScopedNodeDragState::ScopedNodeDragState):
(WebCore::ScopedNodeDragState::~ScopedNodeDragState):
(WebCore::createDragImageFromSnapshot): Boilerplate buffer conversion.
(WebCore::createDragImageForNode):
(WebCore::createDragImageForSelection):
(WebCore::ScopedFrameSelectionState::ScopedFrameSelectionState):
(WebCore::ScopedFrameSelectionState::~ScopedFrameSelectionState):
(WebCore::createDragImageForRange): Moved from Frame.
(WebCore::createDragImageForImage): Moved from FrameSnapshottingMac.
(WebCore::createDragImageForLink): use nullptr.

Source/WebKit/ios:

* WebCoreSupport/WebFrameIOS.mm: use new header file.

Source/WebKit/mac:

Use new platform-independent methods instead of Mac methods.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _selectionDraggingImage]):
(-[WebHTMLView selectionImageForcingBlackText:]):

Source/WebKit/win:

* DOMCoreClasses.cpp:
(DOMElement::renderedImage): use createDragImageForNode.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159455 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/objc/DOM.mm
Source/WebCore/dom/Clipboard.cpp
Source/WebCore/dom/ClipboardMac.mm
Source/WebCore/page/DragController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/FrameSnapshotting.cpp [new file with mode: 0644]
Source/WebCore/page/FrameSnapshotting.h [new file with mode: 0644]
Source/WebCore/page/mac/FrameMac.mm [deleted file]
Source/WebCore/page/mac/FrameSnapshottingMac.h [deleted file]
Source/WebCore/page/mac/FrameSnapshottingMac.mm [deleted file]
Source/WebCore/page/win/FrameWin.cpp
Source/WebCore/page/win/FrameWin.h
Source/WebCore/platform/DragImage.cpp
Source/WebCore/platform/DragImage.h
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMCoreClasses.cpp

index 470df24..71ca326 100644 (file)
@@ -1726,6 +1726,7 @@ set(WebCore_SOURCES
     page/FocusController.cpp
     page/Frame.cpp
     page/FrameDestructionObserver.cpp
+    page/FrameSnapshotting.cpp
     page/FrameTree.cpp
     page/FrameView.cpp
     page/GestureTapHighlighter.cpp
index 630a69b..842dbf2 100644 (file)
@@ -1,3 +1,61 @@
+2013-11-18  Brian J. Burg  <burg@cs.washington.edu>
+
+        Consolidate various frame snapshot capabilities.
+        https://bugs.webkit.org/show_bug.cgi?id=124325
+
+        Reviewed by Timothy Hatcher.
+
+        Various snapshot creation methods had duplicated code and were split
+        between Frame, DragImage, and platform-specific implementationss.
+        This patch puts WebCore snapshot methods into FrameSnapshotting
+        and removes platform implementations where possible.
+
+        DragImage methods reuse snapshot methods where possible. Inspector
+        will be able to take snapshots without using drag images.
+
+        No new tests, this is a refactoring.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.exp.in:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/objc/DOM.mm:
+        (-[DOMNode renderedImage]):
+        (-[DOMRange renderedImageForcingBlackText:]):
+        * dom/Clipboard.cpp:
+        (WebCore::Clipboard::createDragImage):
+        * dom/ClipboardMac.mm:
+        (WebCore::Clipboard::createDragImage):
+        * page/DragController.cpp:
+        (WebCore::DragController::startDrag):
+        * page/Frame.cpp:
+        * page/Frame.h:
+        * page/FrameSnapshotting.cpp: Added.
+        (WebCore::ScopedFramePaintingState::ScopedFramePaintingState):
+        (WebCore::ScopedFramePaintingState::~ScopedFramePaintingState):
+        (WebCore::snapshotFrameRect): Move most buffer logic to here.
+        (WebCore::snapshotSelection): Moved from Frame.
+        (WebCore::snapshotNode): Moved from Frame.
+        * page/FrameSnapshotting.h: Added.
+        * page/mac/FrameMac.mm: Removed.
+        * page/mac/FrameSnapshottingMac.h: Removed.
+        * page/mac/FrameSnapshottingMac.mm: Removed.
+        * page/win/FrameWin.cpp: remove duplicate implementation.
+        * page/win/FrameWin.h: Fix an incorrect parameter name.
+        * platform/DragImage.cpp:
+        (WebCore::ScopedNodeDragState::ScopedNodeDragState):
+        (WebCore::ScopedNodeDragState::~ScopedNodeDragState):
+        (WebCore::createDragImageFromSnapshot): Boilerplate buffer conversion.
+        (WebCore::createDragImageForNode):
+        (WebCore::createDragImageForSelection):
+        (WebCore::ScopedFrameSelectionState::ScopedFrameSelectionState):
+        (WebCore::ScopedFrameSelectionState::~ScopedFrameSelectionState):
+        (WebCore::createDragImageForRange): Moved from Frame.
+        (WebCore::createDragImageForImage): Moved from FrameSnapshottingMac.
+        (WebCore::createDragImageForLink): use nullptr.
+
 2013-11-18  Brendan Long  <b.long@cablelabs.com>
 
         [GStreamer] Crash when using media source
index 23882a6..3da01ba 100644 (file)
@@ -4118,6 +4118,8 @@ webcore_sources += \
        Source/WebCore/page/Frame.h \
        Source/WebCore/page/FrameDestructionObserver.cpp \
        Source/WebCore/page/FrameDestructionObserver.h \
+       Source/WebCore/page/FrameSnapshotting.cpp \
+       Source/WebCore/page/FrameSnapshotting.h \
        Source/WebCore/page/FrameTree.cpp \
        Source/WebCore/page/FrameTree.h \
        Source/WebCore/page/FrameView.cpp \
index 14242b3..8cdd1ff 100644 (file)
@@ -427,7 +427,6 @@ __ZN7WebCore14cookiesEnabledERKNS_21NetworkStorageSessionERKNS_3URLES5_
 __ZN7WebCore14decodeHostNameEP8NSString
 __ZN7WebCore14encodeHostNameEP8NSString
 __ZN7WebCore14endOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
-__ZN7WebCore14selectionImageEPNS_5FrameEb
 __ZN7WebCore14setMetadataURLERN3WTF6StringERKS1_S4_
 __ZN7WebCore15AffineTransform5flipYEv
 __ZN7WebCore15AffineTransform5scaleEd
@@ -887,6 +886,7 @@ __ZN7WebCore27AuthenticationChallengeBaseC2Ev
 __ZN7WebCore27CSSComputedStyleDeclarationC1EN3WTF10PassRefPtrINS_4NodeEEEbRKNS1_6StringE
 __ZN7WebCore27DeviceOrientationClientMock14setOrientationEN3WTF10PassRefPtrINS_21DeviceOrientationDataEEE
 __ZN7WebCore27DeviceOrientationClientMockC1Ev
+__ZN7WebCore27createDragImageForSelectionERNS_5FrameEb
 __ZN7WebCore27protocolHostAndPortAreEqualERKNS_3URLES2_
 __ZN7WebCore27startObservingCookieChangesEPFvvE
 __ZN7WebCore28DocumentStyleSheetCollection12addUserSheetEN3WTF7PassRefINS_18StyleSheetContentsEEE
@@ -2032,7 +2032,6 @@ __ZN7WebCore38contextMenuItemTagWritingDirectionMenuEv
 __ZN7WebCore42contextMenuItemTagCheckGrammarWithSpellingEv
 __ZN7WebCore42contextMenuItemTagCheckSpellingWhileTypingEv
 __ZN7WebCore46contextMenuItemTagCorrectSpellingAutomaticallyEv
-__ZN7WebCore5Frame9nodeImageEPNS_4NodeE
 __ZN7WebCore6Cursor8fromTypeENS0_4TypeE
 __ZN7WebCore6CursorC1EPNS_5ImageERKNS_8IntPointE
 __ZN7WebCore6CursorC1ERKS0_
index 87ff6dd..2711e3d 100644 (file)
     <ClCompile Include="..\page\FocusController.cpp" />
     <ClCompile Include="..\page\Frame.cpp" />
     <ClCompile Include="..\page\FrameDestructionObserver.cpp" />
+    <ClCompile Include="..\page\FrameSnapshotting.cpp" />
     <ClCompile Include="..\page\FrameTree.cpp" />
     <ClCompile Include="..\page\FrameView.cpp" />
     <ClCompile Include="..\page\GroupSettings.cpp" />
     <ClInclude Include="..\page\FocusDirection.h" />
     <ClInclude Include="..\page\Frame.h" />
     <ClInclude Include="..\page\FrameDestructionObserver.h" />
+    <ClInclude Include="..\page\FrameSnapshotting.h" />
     <ClInclude Include="..\page\FrameTree.h" />
     <ClInclude Include="..\page\FrameView.h" />
     <ClInclude Include="..\page\GroupSettings.h" />
index a28f424..445c7d7 100644 (file)
     <ClCompile Include="..\page\FrameDestructionObserver.cpp">
       <Filter>page</Filter>
     </ClCompile>
+    <ClCompile Include="..\page\FrameSnapshotting.cpp">
+      <Filter>page</Filter>
+    </ClCompile>
     <ClCompile Include="..\page\FrameTree.cpp">
       <Filter>page</Filter>
     </ClCompile>
     <ClInclude Include="..\page\FrameDestructionObserver.h">
       <Filter>page</Filter>
     </ClInclude>
+    <ClInclude Include="..\page\FrameSnapshotting.h">
+      <Filter>page</Filter>
+    </ClInclude>
     <ClInclude Include="..\page\FrameTree.h">
       <Filter>page</Filter>
     </ClInclude>
index 4e24d2c..1ddd17e 100644 (file)
                65A21485097A3F5300B9050A /* FrameTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 65A21483097A3F5300B9050A /* FrameTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65BF022E0974816300C43196 /* Frame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65BF02290974816300C43196 /* Frame.cpp */; };
                65BF022F0974816300C43196 /* Frame.h in Headers */ = {isa = PBXBuildFile; fileRef = 65BF022A0974816300C43196 /* Frame.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               65BF02450974819000C43196 /* FrameMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65BF023C0974819000C43196 /* FrameMac.mm */; };
                65C97AF308EA908800ACD273 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C97AF208EA908800ACD273 /* config.h */; };
                65CBFEF90974F607001DAC25 /* FrameView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65CBFEF70974F607001DAC25 /* FrameView.cpp */; };
                65CBFEFA0974F607001DAC25 /* FrameView.h in Headers */ = {isa = PBXBuildFile; fileRef = 65CBFEF80974F607001DAC25 /* FrameView.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C5343FC17B74B63004232F0 /* JSMediaQueryListListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */; };
                7C5343FD17B74B63004232F0 /* JSMediaQueryListListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */; };
                7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
-               7CE30DA9171B63D200EC33E1 /* FrameSnapshottingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CE30DA7171B63D200EC33E1 /* FrameSnapshottingMac.mm */; };
-               7CE30DAA171B63D200EC33E1 /* FrameSnapshottingMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE30DA8171B63D200EC33E1 /* FrameSnapshottingMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7D741BDA177226AA00859170 /* CSSValueKeywords.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 6565814809D13043000E61D7 /* CSSValueKeywords.h */; };
                7E12E90F15FA5D3A005E4126 /* CustomFilterMeshGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E12E90D15FA5D3A005E4126 /* CustomFilterMeshGenerator.h */; };
                7E12E91015FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E12E90E15FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp */; };
                C3CF17A515B0063F00276D39 /* IdTargetObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = C3CF17A115B0063F00276D39 /* IdTargetObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C3CF17A215B0063F00276D39 /* IdTargetObserverRegistry.cpp */; };
                C3CF17A715B0063F00276D39 /* IdTargetObserverRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C3CF17A315B0063F00276D39 /* IdTargetObserverRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               C4CD629A18383766007EBAF1 /* FrameSnapshotting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C4CD629818383766007EBAF1 /* FrameSnapshotting.cpp */; };
+               C4CD629B18383766007EBAF1 /* FrameSnapshotting.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CD629918383766007EBAF1 /* FrameSnapshotting.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50B561412119D23008B46E0 /* GroupSettings.cpp */; };
                C50B561712119D23008B46E0 /* GroupSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = C50B561512119D23008B46E0 /* GroupSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C50D0E820FF4272900AC2644 /* StorageNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */; };
                65A640F00533BB1F0085E777 /* BlockExceptions.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = BlockExceptions.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                65BF02290974816300C43196 /* Frame.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Frame.cpp; sourceTree = "<group>"; };
                65BF022A0974816300C43196 /* Frame.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Frame.h; sourceTree = "<group>"; };
-               65BF023C0974819000C43196 /* FrameMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameMac.mm; sourceTree = "<group>"; };
                65C97AF208EA908800ACD273 /* config.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
                65CBFEF70974F607001DAC25 /* FrameView.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FrameView.cpp; sourceTree = "<group>"; };
                65CBFEF80974F607001DAC25 /* FrameView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameView.h; sourceTree = "<group>"; };
                7C6136F81710C35200FF4A57 /* InFilesParser.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = InFilesParser.pm; path = scripts/InFilesParser.pm; sourceTree = "<group>"; };
                7C6136F91710C35200FF4A57 /* StaticString.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = StaticString.pm; path = scripts/StaticString.pm; sourceTree = "<group>"; };
                7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = "<group>"; };
-               7CE30DA7171B63D200EC33E1 /* FrameSnapshottingMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameSnapshottingMac.mm; sourceTree = "<group>"; };
-               7CE30DA8171B63D200EC33E1 /* FrameSnapshottingMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameSnapshottingMac.h; sourceTree = "<group>"; };
                7E12E90D15FA5D3A005E4126 /* CustomFilterMeshGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterMeshGenerator.h; path = filters/CustomFilterMeshGenerator.h; sourceTree = "<group>"; };
                7E12E90E15FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterMeshGenerator.cpp; path = filters/CustomFilterMeshGenerator.cpp; sourceTree = "<group>"; };
                7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; };
                C3CF17A115B0063F00276D39 /* IdTargetObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IdTargetObserver.h; sourceTree = "<group>"; };
                C3CF17A215B0063F00276D39 /* IdTargetObserverRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IdTargetObserverRegistry.cpp; sourceTree = "<group>"; };
                C3CF17A315B0063F00276D39 /* IdTargetObserverRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IdTargetObserverRegistry.h; sourceTree = "<group>"; };
+               C4CD629818383766007EBAF1 /* FrameSnapshotting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameSnapshotting.cpp; sourceTree = "<group>"; };
+               C4CD629918383766007EBAF1 /* FrameSnapshotting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameSnapshotting.h; sourceTree = "<group>"; };
                C50B561412119D23008B46E0 /* GroupSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GroupSettings.cpp; sourceTree = "<group>"; };
                C50B561512119D23008B46E0 /* GroupSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupSettings.h; sourceTree = "<group>"; };
                C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageNamespace.cpp; sourceTree = "<group>"; };
                                65BF022A0974816300C43196 /* Frame.h */,
                                974A862014B7ADBB003FDC76 /* FrameDestructionObserver.cpp */,
                                974A862114B7ADBB003FDC76 /* FrameDestructionObserver.h */,
+                               C4CD629818383766007EBAF1 /* FrameSnapshotting.cpp */,
+                               C4CD629918383766007EBAF1 /* FrameSnapshotting.h */,
                                65A21482097A3F5300B9050A /* FrameTree.cpp */,
                                65A21483097A3F5300B9050A /* FrameTree.h */,
                                65CBFEF70974F607001DAC25 /* FrameView.cpp */,
                                ABAF22070C03B1C700B0BCF0 /* ChromeMac.mm */,
                                A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */,
                                93C09A7E0B064EEF005ABD4D /* EventHandlerMac.mm */,
-                               65BF023C0974819000C43196 /* FrameMac.mm */,
-                               7CE30DA8171B63D200EC33E1 /* FrameSnapshottingMac.h */,
-                               7CE30DA7171B63D200EC33E1 /* FrameSnapshottingMac.mm */,
                                1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */,
                                E1C2F2481533A2120083F974 /* SettingsMac.mm */,
                                F587854C02DE375901EA4122 /* WebCoreFrameView.h */,
                                1A569CF80D7E2B82007C3983 /* c_class.h in Headers */,
                                1A569CFA0D7E2B82007C3983 /* c_instance.h in Headers */,
                                1A569CFC0D7E2B82007C3983 /* c_runtime.h in Headers */,
+                               C4CD629B18383766007EBAF1 /* FrameSnapshotting.h in Headers */,
                                1A569CFE0D7E2B82007C3983 /* c_utility.h in Headers */,
                                BCB16C1A0979C3BD00467741 /* CachedCSSStyleSheet.h in Headers */,
                                BC64B4CC0CB4295D005F2B62 /* CachedFont.h in Headers */,
                                628D214E12131EF40055DCFC /* FrameNetworkingContext.h in Headers */,
                                E172AF70180F289500FBADB9 /* CryptoKeyUsage.h in Headers */,
                                93309E0E099E64920056E581 /* FrameSelection.h in Headers */,
-                               7CE30DAA171B63D200EC33E1 /* FrameSnapshottingMac.h in Headers */,
                                65A21485097A3F5300B9050A /* FrameTree.h in Headers */,
                                65CBFEFA0974F607001DAC25 /* FrameView.h in Headers */,
                                97205AB0123928CA00B17380 /* FTPDirectoryDocument.h in Headers */,
                                932E16090AF578340025F408 /* FrameLoader.cpp in Sources */,
                                D000EBA211BDAFD400C47726 /* FrameLoaderStateMachine.cpp in Sources */,
                                86BA766E166427A8005BE5D1 /* FrameLoadRequest.cpp in Sources */,
-                               65BF02450974819000C43196 /* FrameMac.mm in Sources */,
                                93309E0D099E64920056E581 /* FrameSelection.cpp in Sources */,
                                4A8C96EB0BE69032004EEFF0 /* FrameSelectionMac.mm in Sources */,
-                               7CE30DA9171B63D200EC33E1 /* FrameSnapshottingMac.mm in Sources */,
                                07969DAD17D14151007FF842 /* JSRTCDataChannelEvent.cpp in Sources */,
                                65A21484097A3F5300B9050A /* FrameTree.cpp in Sources */,
                                E4C91A101802343900A17F6D /* TextPaintStyle.cpp in Sources */,
                                51E0BB390DA5ACB600A9E417 /* StorageMap.cpp in Sources */,
                                07277E5217D018CC0015534D /* JSMediaStreamTrack.cpp in Sources */,
                                C50D0E820FF4272900AC2644 /* StorageNamespace.cpp in Sources */,
+                               C4CD629A18383766007EBAF1 /* FrameSnapshotting.cpp in Sources */,
                                C55E38C010040D5D00A56BDB /* StorageNamespaceImpl.cpp in Sources */,
                                1AB09DB416AF5F6C008538E7 /* StorageStrategy.cpp in Sources */,
                                C5102D950FD9AA2D00FAFF04 /* StorageSyncManager.cpp in Sources */,
index cc03655..a6ac399 100644 (file)
@@ -36,9 +36,9 @@
 #import "DOMNodeInternal.h"
 #import "DOMPrivate.h"
 #import "DOMRangeInternal.h"
+#import "DragImage.h"
 #import "Font.h"
 #import "Frame.h"
-#import "FrameSnapshottingMac.h"
 #import "HTMLElement.h"
 #import "HTMLNames.h"
 #import "HTMLParserIdioms.h"
@@ -287,9 +287,9 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget)
     // FIXME: Could we move this function to WebCore::Node and autogenerate?
     WebCore::Node* node = core(self);
     WebCore::Frame* frame = node->document().frame();
-    if (!frame)
+    if (!frame || !node)
         return nil;
-    return frame->nodeImage(node).get();
+    return [[createDragImageForNode(*frame, *node) retain] autorelease];
 }
 
 - (NSArray *)textRects
@@ -332,10 +332,10 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget)
 {
     WebCore::Range* range = core(self);
     WebCore::Frame* frame = range->ownerDocument().frame();
-    if (!frame)
+    if (!frame || !range)
         return nil;
 
-    return WebCore::rangeImage(frame, range, forceBlackText);
+    return [[createDragImageForRange(*frame, *range, forceBlackText) retain] autorelease];
 }
 
 - (NSArray *)textRects
index 9d2e275..307fcc1 100644 (file)
@@ -277,10 +277,11 @@ DragImageRef Clipboard::createDragImage(IntPoint& location) const
 
     if (m_dragImageElement) {
         if (Frame* frame = m_dragImageElement->document().frame())
-            return frame->nodeImage(m_dragImageElement.get());
+            return createDragImageForNode(*frame, *m_dragImageElement);
     }
 
-    return 0; // We do not have enough information to create a drag image, use the default icon.
+    // We do not have enough information to create a drag image, use the default icon.
+    return nullptr;
 }
 
 #endif
index 76ca6fc..a09b30a 100644 (file)
@@ -28,7 +28,7 @@
 
 #import "CachedImage.h"
 #import "Element.h"
-#import "FrameSnapshottingMac.h"
+#import "DragImage.h"
 
 namespace WebCore {
 
@@ -37,16 +37,16 @@ namespace WebCore {
 // Clipboard::dragImage in Clipboard.cpp does not handle correctly, so must resolve that as well.
 DragImageRef Clipboard::createDragImage(IntPoint& location) const
 {
-    NSImage *result = nil;
+    DragImageRef result = nil;
     if (m_dragImageElement) {
         if (Frame* frame = m_dragImageElement->document().frame()) {
-            NSRect imageRect;
-            NSRect elementRect;
-            result = snapshotDragImage(frame, m_dragImageElement.get(), &imageRect, &elementRect);
+            IntRect imageRect;
+            IntRect elementRect;
+            result = createDragImageForImage(*frame, *m_dragImageElement, imageRect, elementRect);
             // Client specifies point relative to element, not the whole image, which may include child
             // layers spread out all over the place.
-            location.setX(elementRect.origin.x - imageRect.origin.x + m_dragLocation.x());
-            location.setY(imageRect.size.height - (elementRect.origin.y - imageRect.origin.y + m_dragLocation.y()));
+            location.setX(elementRect.x() - imageRect.x() + m_dragLocation.x());
+            location.setY(imageRect.height() - (elementRect.y() - imageRect.y() + m_dragLocation.y()));
         }
     } else if (m_dragImage) {
         result = m_dragImage->image()->getNSImage();
index 7eb249d..f866dcf 100644 (file)
@@ -37,6 +37,7 @@
 #include "DragActions.h"
 #include "DragClient.h"
 #include "DragData.h"
+#include "DragImage.h"
 #include "DragSession.h"
 #include "DragState.h"
 #include "Editor.h"
@@ -780,7 +781,7 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
         }
         m_client.willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, clipboard);
         if (!dragImage) {
-            dragImage = dissolveDragImageToFraction(src.dragImageForSelection(), DragImageAlpha);
+            dragImage = dissolveDragImageToFraction(createDragImageForSelection(src), DragImageAlpha);
             dragLoc = dragLocForSelectionDrag(src);
             m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
         }
index 6241ee3..5c03611 100644 (file)
@@ -966,108 +966,4 @@ bool Frame::isURLAllowed(const URL& url) const
     return true;
 }
 
-#if !PLATFORM(MAC) && !PLATFORM(WIN)
-struct ScopedFramePaintingState {
-    ScopedFramePaintingState(Frame* frame, Node* node)
-        : frame(frame)
-        , node(node)
-        , paintBehavior(frame->view()->paintBehavior())
-        , backgroundColor(frame->view()->baseBackgroundColor())
-    {
-        ASSERT(!node || node->renderer());
-        if (node)
-            node->renderer()->updateDragState(true);
-    }
-
-    ~ScopedFramePaintingState()
-    {
-        if (node && node->renderer())
-            node->renderer()->updateDragState(false);
-        frame->view()->setPaintBehavior(paintBehavior);
-        frame->view()->setBaseBackgroundColor(backgroundColor);
-        frame->view()->setNodeToDraw(0);
-    }
-
-    Frame* frame;
-    Node* node;
-    PaintBehavior paintBehavior;
-    Color backgroundColor;
-};
-
-DragImageRef Frame::nodeImage(Node* node)
-{
-    if (!node->renderer())
-        return nullptr;
-
-    const ScopedFramePaintingState state(this, node);
-
-    m_view->setPaintBehavior(state.paintBehavior | PaintBehaviorFlattenCompositingLayers);
-
-    // When generating the drag image for an element, ignore the document background.
-    m_view->setBaseBackgroundColor(Color::transparent);
-    m_doc->updateLayout();
-    m_view->setNodeToDraw(node); // Enable special sub-tree drawing mode.
-
-    // Document::updateLayout may have blown away the original renderer.
-    auto renderer = node->renderer();
-    if (!renderer)
-        return nullptr;
-
-    LayoutRect topLevelRect;
-    IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
-
-    float deviceScaleFactor = 1;
-    if (m_page)
-        deviceScaleFactor = m_page->deviceScaleFactor();
-    paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
-    paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
-
-    OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceScaleFactor, ColorSpaceDeviceRGB));
-    if (!buffer)
-        return nullptr;
-    buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
-    buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
-
-    m_view->paintContents(buffer->context(), paintingRect);
-
-    RefPtr<Image> image = buffer->copyImage();
-
-    ImageOrientationDescription orientationDescription(renderer->shouldRespectImageOrientation());
-#if ENABLE(CSS_IMAGE_ORIENTATION)
-    orientationDescription.setImageOrientationEnum(renderer->style().imageOrientation());
-#endif
-    return createDragImageFromImage(image.get(), orientationDescription);
-}
-
-DragImageRef Frame::dragImageForSelection()
-{
-    if (!selection().isRange())
-        return 0;
-
-    const ScopedFramePaintingState state(this, 0);
-    m_view->setPaintBehavior(PaintBehaviorSelectionOnly);
-    m_doc->updateLayout();
-
-    IntRect paintingRect = enclosingIntRect(selection().bounds());
-
-    float deviceScaleFactor = 1;
-    if (m_page)
-        deviceScaleFactor = m_page->deviceScaleFactor();
-    paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
-    paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
-
-    OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceScaleFactor, ColorSpaceDeviceRGB));
-    if (!buffer)
-        return 0;
-    buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
-    buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
-
-    m_view->paintContents(buffer->context(), paintingRect);
-
-    RefPtr<Image> image = buffer->copyImage();
-    return createDragImageFromImage(image.get(), ImageOrientationDescription());
-}
-
-#endif
-
 } // namespace WebCore
index 8407e9e..5f1866f 100644 (file)
@@ -29,7 +29,6 @@
 #define Frame_h
 
 #include "AdjustViewSizeOrNot.h"
-#include "DragImage.h"
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "IntRect.h"
@@ -58,11 +57,13 @@ namespace WebCore {
     class Editor;
     class Element;
     class EventHandler;
+    class FloatSize;
     class FrameDestructionObserver;
     class FrameSelection;
     class FrameView;
     class HTMLFrameOwnerElement;
     class HTMLTableCellElement;
+    class ImageBuffer;
     class IntRect;
     class MainFrame;
     class Node;
@@ -177,9 +178,6 @@ namespace WebCore {
 
         String displayStringModifiedByEncoding(const String&) const;
 
-        DragImageRef nodeImage(Node*);
-        DragImageRef dragImageForSelection();
-
         VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
         Document* documentAtPoint(const IntPoint& windowPoint);
         PassRefPtr<Range> rangeForPoint(const IntPoint& framePoint);
diff --git a/Source/WebCore/page/FrameSnapshotting.cpp b/Source/WebCore/page/FrameSnapshotting.cpp
new file mode 100644 (file)
index 0000000..49a1eb9
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ *  Copyright (C) 2013 University of Washington. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+
+#include "FrameSnapshotting.h"
+
+#include "Document.h"
+#include "Frame.h"
+#include "FrameSelection.h"
+#include "FrameView.h"
+#include "ImageBuffer.h"
+#include "Page.h"
+#include "RenderObject.h"
+
+namespace WebCore {
+
+struct ScopedFramePaintingState {
+    ScopedFramePaintingState(Frame& frame, Node* node)
+    : frame(frame)
+    , node(node)
+    , paintBehavior(frame.view()->paintBehavior())
+    , backgroundColor(frame.view()->baseBackgroundColor())
+    {
+        ASSERT(!node || node->renderer());
+    }
+
+    ~ScopedFramePaintingState()
+    {
+        frame.view()->setPaintBehavior(paintBehavior);
+        frame.view()->setBaseBackgroundColor(backgroundColor);
+        frame.view()->setNodeToDraw(nullptr);
+    }
+
+    Frame& frame;
+    Node* node;
+    PaintBehavior paintBehavior;
+    Color backgroundColor;
+};
+
+std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame& frame, const IntRect& imageRect, SnapshotOptions options)
+{
+    FrameView::SelectionInSnapshot shouldIncludeSelection = FrameView::IncludeSelection;
+    if (options & SnapshotOptionsExcludeSelectionHighlighting)
+        shouldIncludeSelection = FrameView::ExcludeSelection;
+
+    FrameView::CoordinateSpaceForSnapshot coordinateSpace = FrameView::DocumentCoordinates;
+    if (options & SnapshotOptionsInViewCoordinates)
+        coordinateSpace = FrameView::ViewCoordinates;
+
+    PaintBehavior textPaintBehavior = 0;
+    if (options & SnapshotOptionsForceBlackText)
+        textPaintBehavior = PaintBehaviorForceBlackText;
+
+    const ScopedFramePaintingState state(frame, nullptr);
+
+    // Other paint behaviors are set by paintContentsForSnapshot.
+    PaintBehavior existingBehavior = frame.view()->paintBehavior();
+    frame.view()->setPaintBehavior(existingBehavior | textPaintBehavior);
+    frame.document()->updateLayout();
+
+    float deviceScaleFactor = frame.page() ? frame.page()->deviceScaleFactor() : 1;
+    IntRect usedRect(imageRect);
+    usedRect.scale(deviceScaleFactor);
+
+    std::unique_ptr<ImageBuffer> buffer = std::unique_ptr<ImageBuffer>(ImageBuffer::create(usedRect.size(), deviceScaleFactor, ColorSpaceDeviceRGB).leakPtr());
+    if (!buffer)
+        return nullptr;
+    buffer->context()->translate(-usedRect.x(), -usedRect.y());
+    buffer->context()->clip(FloatRect(0, 0, usedRect.maxX(), usedRect.maxY()));
+
+    frame.view()->paintContentsForSnapshot(buffer->context(), usedRect, shouldIncludeSelection, coordinateSpace);
+    return buffer;
+}
+
+std::unique_ptr<ImageBuffer> snapshotSelection(Frame& frame, SnapshotOptions options)
+{
+    if (!frame.selection().isRange())
+        return nullptr;
+
+    // Force selection highlighting to be included.
+    options &= ~SnapshotOptionsExcludeSelectionHighlighting;
+    IntRect selectionRect = enclosingIntRect(frame.selection().bounds());
+    return snapshotFrameRect(frame, selectionRect, options);
+}
+
+std::unique_ptr<ImageBuffer> snapshotNode(Frame& frame, Node& node)
+{
+    if (!node.renderer())
+        return nullptr;
+
+    const ScopedFramePaintingState state(frame, &node);
+
+    frame.view()->setBaseBackgroundColor(Color::transparent);
+    frame.document()->updateLayout();
+    frame.view()->setNodeToDraw(&node);
+
+    // Document::updateLayout may have blown away the original renderer.
+    RenderObject* renderer = node.renderer();
+    if (!renderer)
+        return nullptr;
+
+    LayoutRect topLevelRect;
+    IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
+    return snapshotFrameRect(frame, paintingRect);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/page/FrameSnapshotting.h b/Source/WebCore/page/FrameSnapshotting.h
new file mode 100644 (file)
index 0000000..b7893bd
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  Copyright (C) 2013 University of Washington. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FrameSnapshotting_h
+#define FrameSnapshotting_h
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class Frame;
+class IntRect;
+class ImageBuffer;
+class Node;
+
+enum {
+    SnapshotOptionsNone = 0,
+    SnapshotOptionsExcludeSelectionHighlighting = 1 << 0,
+    SnapshotOptionsInViewCoordinates = 1 << 1,
+    SnapshotOptionsForceBlackText = 1 << 2,
+};
+typedef uint32_t SnapshotOptions;
+
+std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame&, const IntRect&, SnapshotOptions = SnapshotOptionsNone);
+std::unique_ptr<ImageBuffer> snapshotNode(Frame&, Node&);
+std::unique_ptr<ImageBuffer> snapshotSelection(Frame&, SnapshotOptions = SnapshotOptionsNone);
+
+} // namespace WebCore
+
+#endif // FrameSnapshotting_h
diff --git a/Source/WebCore/page/mac/FrameMac.mm b/Source/WebCore/page/mac/FrameMac.mm
deleted file mode 100644 (file)
index dafb1f9..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "config.h"
-#import "Frame.h"
-
-#import "Document.h"
-#import "FrameLoaderClient.h"
-#import "FrameSelection.h"
-#import "FrameSnapshottingMac.h"
-#import "FrameView.h"
-#import "RenderObject.h"
-
-namespace WebCore {
-
-DragImageRef Frame::nodeImage(Node* node)
-{
-    m_doc->updateLayout(); // forces style recalc
-
-    RenderObject* renderer = node->renderer();
-    if (!renderer)
-        return nil;
-    LayoutRect topLevelRect;
-    NSRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
-
-    m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode
-    NSImage* result = imageFromRect(this, paintingRect);
-    m_view->setNodeToDraw(0);
-
-    return result;
-}
-
-DragImageRef Frame::dragImageForSelection()
-{
-    if (!selection().isRange())
-        return nil;
-    return selectionImage(this);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/page/mac/FrameSnapshottingMac.h b/Source/WebCore/page/mac/FrameSnapshottingMac.h
deleted file mode 100644 (file)
index bfab67e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FrameSnapshottingMac_h
-#define FrameSnapshottingMac_h
-
-OBJC_CLASS NSImage;
-
-namespace WebCore {
-
-class Frame;
-class Range;
-class Node;
-
-NSImage* selectionImage(Frame*, bool forceBlackText = false);
-NSImage* rangeImage(Frame*, Range*, bool forceBlackText = false);
-NSImage* snapshotDragImage(Frame*, Node*, NSRect* imageRect, NSRect* elementRect);
-NSImage* imageFromRect(Frame*, NSRect);
-
-}
-
-#endif // FrameSnapshottingMac_h
diff --git a/Source/WebCore/page/mac/FrameSnapshottingMac.mm b/Source/WebCore/page/mac/FrameSnapshottingMac.mm
deleted file mode 100644 (file)
index e92c2f2..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "config.h"
-#import "FrameSnapshottingMac.h"
-
-#import "BlockExceptions.h"
-#import "Document.h"
-#import "Frame.h"
-#import "FrameSelection.h"
-#import "FrameView.h"
-#import "GraphicsContext.h"
-#import "Range.h"
-#import "RenderView.h"
-
-namespace WebCore {
-
-NSImage* imageFromRect(Frame* frame, NSRect rect)
-{
-    PaintBehavior oldBehavior = frame->view()->paintBehavior();
-    frame->view()->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
-    
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    
-    NSImage* resultImage = [[[NSImage alloc] initWithSize:rect.size] autorelease];
-    
-    if (rect.size.width != 0 && rect.size.height != 0) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-        [resultImage setFlipped:YES];
-#pragma clang diagnostic pop
-        [resultImage lockFocus];
-
-        GraphicsContext graphicsContext((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]);        
-        graphicsContext.save();
-        graphicsContext.translate(-rect.origin.x, -rect.origin.y);
-        frame->view()->paintContents(&graphicsContext, IntRect(rect));
-        graphicsContext.restore();
-
-        [resultImage unlockFocus];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-        [resultImage setFlipped:NO];
-#pragma clang diagnostic pop
-    }
-    
-    frame->view()->setPaintBehavior(oldBehavior);
-    return resultImage;
-    
-    END_BLOCK_OBJC_EXCEPTIONS;
-    
-    frame->view()->setPaintBehavior(oldBehavior);
-    return nil;
-}
-
-NSImage* selectionImage(Frame* frame, bool forceBlackText)
-{
-    frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0));
-    frame->document()->updateLayout();
-    NSImage* result = imageFromRect(frame, frame->selection().bounds());
-    frame->view()->setPaintBehavior(PaintBehaviorNormal);
-    return result;
-}
-
-NSImage *rangeImage(Frame* frame, Range* range, bool forceBlackText)
-{
-    frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0));
-    frame->document()->updateLayout();
-    RenderView* view = frame->contentRenderer();
-    if (!view)
-        return nil;
-
-    Position start = range->startPosition();
-    Position candidate = start.downstream();
-    if (candidate.deprecatedNode() && candidate.deprecatedNode()->renderer())
-        start = candidate;
-
-    Position end = range->endPosition();
-    candidate = end.upstream();
-    if (candidate.deprecatedNode() && candidate.deprecatedNode()->renderer())
-        end = candidate;
-
-    if (start.isNull() || end.isNull() || start == end)
-        return nil;
-
-    RenderObject* savedStartRenderer;
-    int savedStartOffset;
-    RenderObject* savedEndRenderer;
-    int savedEndOffset;
-    view->getSelection(savedStartRenderer, savedStartOffset, savedEndRenderer, savedEndOffset);
-
-    RenderObject* startRenderer = start.deprecatedNode()->renderer();
-    if (!startRenderer)
-        return nil;
-
-    RenderObject* endRenderer = end.deprecatedNode()->renderer();
-    if (!endRenderer)
-        return nil;
-
-    view->setSelection(startRenderer, start.deprecatedEditingOffset(), endRenderer, end.deprecatedEditingOffset(), RenderView::RepaintNothing);
-    NSImage* result = imageFromRect(frame, view->selectionBounds());
-    view->setSelection(savedStartRenderer, savedStartOffset, savedEndRenderer, savedEndOffset, RenderView::RepaintNothing);
-
-    frame->view()->setPaintBehavior(PaintBehaviorNormal);
-    return result;
-}
-
-
-NSImage* snapshotDragImage(Frame* frame, Node* node, NSRect* imageRect, NSRect* elementRect)
-{
-    RenderObject* renderer = node->renderer();
-    if (!renderer)
-        return nil;
-    
-    renderer->updateDragState(true);    // mark dragged nodes (so they pick up the right CSS)
-    frame->document()->updateLayout();  // forces style recalc - needed since changing the drag state might
-                                        // imply new styles, plus JS could have changed other things
-
-
-    // Document::updateLayout may have blown away the original RenderElement.
-    renderer = node->renderer();
-    if (!renderer)
-        return nil;
-
-    LayoutRect topLevelRect;
-    NSRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
-
-    if (NSIsEmptyRect(paintingRect))
-        return nil;
-
-    frame->view()->setNodeToDraw(node); // invoke special sub-tree drawing mode
-    NSImage* result = imageFromRect(frame, paintingRect);
-    renderer->updateDragState(false);
-    frame->document()->updateLayout();
-    frame->view()->setNodeToDraw(0);
-
-    if (elementRect)
-        *elementRect = pixelSnappedIntRect(topLevelRect);
-    if (imageRect)
-        *imageRect = paintingRect;
-    return result;
-}
-
-} // namespace WebCore
index 5aaf3a6..9674f17 100644 (file)
@@ -57,30 +57,4 @@ GDIObject<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText)
     return image;
 }
 
-DragImageRef Frame::dragImageForSelection()
-{
-    if (selection().isRange())
-        return imageFromSelection(this, false).leak();
-
-    return 0;
-}
-
-DragImageRef Frame::nodeImage(Node* node)
-{
-    document()->updateLayout();
-
-    RenderObject* renderer = node->renderer();
-    if (!renderer)
-        return 0;
-
-    LayoutRect topLevelRect;
-    IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
-
-    m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode
-    GDIObject<HBITMAP> result = imageFromRect(this, paintingRect);
-    m_view->setNodeToDraw(0);
-
-    return result.leak();
-}
-
 } // namespace WebCore
index 3a2723e..269725c 100644 (file)
@@ -35,7 +35,7 @@ class Frame;
 class IntRect;
 
 GDIObject<HBITMAP> imageFromRect(const Frame*, IntRect&);
-GDIObject<HBITMAP> imageFromSelection(Frame*, bool forceWhiteText);
+GDIObject<HBITMAP> imageFromSelection(Frame*, bool forceBlackText);
 void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight);
 
 } // namespace WebCore
index b81afd5..7c46748 100644 (file)
@@ -20,7 +20,7 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
 
 #if ENABLE(DRAG_SUPPORT)
 
+#include "Frame.h"
+#include "FrameSnapshotting.h"
+#include "FrameView.h"
+#include "ImageBuffer.h"
+#include "Range.h"
+#include "RenderObject.h"
+#include "RenderView.h"
+
 namespace WebCore {
-    
+
 DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size)
 {
     float heightResizeRatio = 0.0f;
     float widthResizeRatio = 0.0f;
     float resizeRatio = -1.0f;
     IntSize originalSize = dragImageSize(image);
-    
+
     if (srcSize.width() > size.width()) {
         widthResizeRatio = size.width() / (float)srcSize.width();
         resizeRatio = widthResizeRatio;
     }
-    
+
     if (srcSize.height() > size.height()) {
         heightResizeRatio = size.height() / (float)srcSize.height();
         if ((resizeRatio < 0.0f) || (resizeRatio > heightResizeRatio))
             resizeRatio = heightResizeRatio;
     }
-    
+
     if (srcSize == originalSize)
         return resizeRatio > 0.0f ? scaleDragImage(image, FloatSize(resizeRatio, resizeRatio)) : image;
-    
+
     // The image was scaled in the webpage so at minimum we must account for that scaling
     float scalex = srcSize.width() / (float)originalSize.width();
     float scaley = srcSize.height() / (float)originalSize.height();
@@ -58,14 +66,151 @@ DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, c
         scalex *= resizeRatio;
         scaley *= resizeRatio;
     }
-    
+
     return scaleDragImage(image, FloatSize(scalex, scaley));
 }
 
+struct ScopedNodeDragState {
+    ScopedNodeDragState(Frame& frame, Node& node)
+    : frame(frame)
+    , node(node)
+    {
+        ASSERT(node.renderer());
+        node.renderer()->updateDragState(true);
+        frame.document()->updateLayout();
+    }
+
+    ~ScopedNodeDragState()
+    {
+        if (node.renderer()) {
+            node.renderer()->updateDragState(false);
+            frame.document()->updateLayout();
+        }
+    }
+
+    Frame& frame;
+    Node& node;
+};
+
+static DragImageRef createDragImageFromSnapshot(std::unique_ptr<ImageBuffer> snapshot, Node* node)
+{
+    if (!snapshot)
+        return nullptr;
+
+    ImageOrientationDescription orientation;
+#if ENABLE(CSS_IMAGE_ORIENTATION)
+    if (node) {
+        RenderObject* renderer = node->renderer();
+        if (!renderer)
+            return nullptr;
+
+        orientation.setRespectImageOrientation(renderer->shouldRespectImageOrientation());
+        orientation.setImageOrientationEnum(renderer->style().imageOrientation());
+    }
+#else
+    UNUSED_PARAM(node);
+#endif
+    RefPtr<Image> image = snapshot->copyImage(ImageBuffer::fastCopyImageMode());
+    if (!image)
+        return nullptr;
+    return createDragImageFromImage(image.get(), orientation);
+}
+
+DragImageRef createDragImageForNode(Frame& frame, Node& node)
+{
+    ScopedNodeDragState enableDrag(frame, node);
+    std::unique_ptr<ImageBuffer> snapshot = snapshotNode(frame, node);
+    return createDragImageFromSnapshot(std::move(snapshot), &node);
+}
+
+DragImageRef createDragImageForSelection(Frame& frame, bool forceBlackText)
+{
+    SnapshotOptions options = forceBlackText ? SnapshotOptionsForceBlackText : SnapshotOptionsNone;
+    std::unique_ptr<ImageBuffer> snapshot = snapshotSelection(frame, options);
+    return createDragImageFromSnapshot(std::move(snapshot), nullptr);
+}
+
+struct ScopedFrameSelectionState {
+    ScopedFrameSelectionState(Frame& frame)
+    : frame(frame)
+    {
+        if (RenderView* root = frame.contentRenderer())
+            root->getSelection(startRenderer, startOffset, endRenderer, endOffset);
+    }
+
+    ~ScopedFrameSelectionState()
+    {
+        if (RenderView* root = frame.contentRenderer())
+            root->setSelection(startRenderer, startOffset, endRenderer, endOffset, RenderView::RepaintNothing);
+    }
+
+    Frame& frame;
+    RenderObject* startRenderer;
+    RenderObject* endRenderer;
+    int startOffset;
+    int endOffset;
+};
+
+DragImageRef createDragImageForRange(Frame& frame, Range& range, bool forceBlackText)
+{
+    frame.document()->updateLayout();
+    RenderView* view = frame.contentRenderer();
+    if (!view)
+        return nullptr;
+
+    // To snapshot the range, temporarily select it and take selection snapshot.
+    Position start = range.startPosition();
+    Position candidate = start.downstream();
+    if (candidate.deprecatedNode() && candidate.deprecatedNode()->renderer())
+        start = candidate;
+
+    Position end = range.endPosition();
+    candidate = end.upstream();
+    if (candidate.deprecatedNode() && candidate.deprecatedNode()->renderer())
+        end = candidate;
+
+    if (start.isNull() || end.isNull() || start == end)
+        return nullptr;
+
+    const ScopedFrameSelectionState selectionState(frame);
+
+    RenderObject* startRenderer = start.deprecatedNode()->renderer();
+    RenderObject* endRenderer = end.deprecatedNode()->renderer();
+    if (!startRenderer || !endRenderer)
+        return nullptr;
+
+    SnapshotOptions options = forceBlackText ? SnapshotOptionsForceBlackText : SnapshotOptionsNone;
+    view->setSelection(startRenderer, start.deprecatedEditingOffset(), endRenderer, end.deprecatedEditingOffset(), RenderView::RepaintNothing);
+    std::unique_ptr<ImageBuffer> snapshot = snapshotSelection(frame, options);
+    return createDragImageFromSnapshot(std::move(snapshot), nullptr);
+}
+
+DragImageRef createDragImageForImage(Frame& frame, Node& node, IntRect& imageRect, IntRect& elementRect)
+{
+    ScopedNodeDragState enableDrag(frame, node);
+
+    RenderObject* renderer = node.renderer();
+    if (!renderer)
+        return nullptr;
+
+    // Calculate image and element metrics for the client, then create drag image.
+    LayoutRect topLevelRect;
+    IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
+
+    if (paintingRect.isEmpty())
+        return nullptr;
+
+    elementRect = pixelSnappedIntRect(topLevelRect);
+    imageRect = paintingRect;
+
+    std::unique_ptr<ImageBuffer> snapshot = snapshotNode(frame, node);
+    return createDragImageFromSnapshot(std::move(snapshot), &node);
+}
+
 #if !PLATFORM(MAC) && (!PLATFORM(WIN) || OS(WINCE))
 DragImageRef createDragImageForLink(URL&, const String&, FontRenderingMode)
 {
-    return 0;
+    return nullptr;
 }
 #endif
 
index d8f52bc..d83696e 100644 (file)
 #ifndef DragImage_h
 #define DragImage_h
 
+#include "FloatSize.h"
 #include "FontRenderingMode.h"
+#include "FrameSnapshotting.h"
 #include "ImageOrientation.h"
 #include "IntSize.h"
-#include "FloatSize.h"
 #include <wtf/Forward.h>
 
 #if PLATFORM(MAC)
@@ -41,38 +42,46 @@ typedef struct HBITMAP__* HBITMAP;
 typedef struct _cairo_surface cairo_surface_t;
 #endif
 
-//We need to #define YOffset as it needs to be shared with WebKit
+// We need to #define YOffset as it needs to be shared with WebKit
 #define DragLabelBorderYOffset 2
 
 namespace WebCore {
 
-    class Image;
-    class URL;
+class Frame;
+class Image;
+class IntRect;
+class Node;
+class Range;
+class URL;
 
 #if PLATFORM(MAC)
-    typedef RetainPtr<NSImage> DragImageRef;
+typedef RetainPtr<NSImage> DragImageRef;
 #elif PLATFORM(WIN)
-    typedef HBITMAP DragImageRef;
+typedef HBITMAP DragImageRef;
 #elif PLATFORM(GTK) || PLATFORM(NIX)
-    typedef cairo_surface_t* DragImageRef;
+typedef cairo_surface_t* DragImageRef;
 #elif PLATFORM(EFL) || PLATFORM(BLACKBERRY)
-    typedef void* DragImageRef;
+typedef void* DragImageRef;
 #endif
-    
-    IntSize dragImageSize(DragImageRef);
-    
-    //These functions should be memory neutral, eg. if they return a newly allocated image, 
-    //they should release the input image.  As a corollary these methods don't guarantee
-    //the input image ref will still be valid after they have been called
-    DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size);
-    DragImageRef scaleDragImage(DragImageRef, FloatSize scale);
-    DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta);
-    
-    DragImageRef createDragImageFromImage(Image*, ImageOrientationDescription);
-    DragImageRef createDragImageIconForCachedImageFilename(const String&);
-    DragImageRef createDragImageForLink(URL&, const String& label, FontRenderingMode);
-    void deleteDragImage(DragImageRef);
-}
 
+IntSize dragImageSize(DragImageRef);
+
+// These functions should be memory neutral, eg. if they return a newly allocated image,
+// they should release the input image. As a corollary these methods don't guarantee
+// the input image ref will still be valid after they have been called.
+DragImageRef fitDragImageToMaxSize(DragImageRef, const IntSize& srcSize, const IntSize& dstSize);
+DragImageRef scaleDragImage(DragImageRef, FloatSize scale);
+DragImageRef dissolveDragImageToFraction(DragImageRef, float delta);
+
+DragImageRef createDragImageFromImage(Image*, ImageOrientationDescription);
+DragImageRef createDragImageIconForCachedImageFilename(const String&);
+
+DragImageRef createDragImageForNode(Frame&, Node&);
+DragImageRef createDragImageForSelection(Frame&, bool forceBlackText = false);
+DragImageRef createDragImageForRange(Frame&, Range&, bool forceBlackText = false);
+DragImageRef createDragImageForImage(Frame&, Node&, IntRect& imageRect, IntRect& elementRect);
+DragImageRef createDragImageForLink(URL&, const String& label, FontRenderingMode);
+void deleteDragImage(DragImageRef);
+}
 
-#endif //!DragImage_h
+#endif // DragImage_h
index 1493c2b..d0a7896 100644 (file)
@@ -1,3 +1,12 @@
+2013-11-18  Brian J. Burg  <burg@cs.washington.edu>
+
+        Consolidate various frame snapshot capabilities.
+        https://bugs.webkit.org/show_bug.cgi?id=124325
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebFrameIOS.mm: use new header file.
+
 2013-11-07  Joseph Pecoraro  <pecoraro@apple.com>
 
         Remove a PLATFORM(IOS) from WebKit Private Header
index 5dff6f0..d562a16 100644 (file)
@@ -33,7 +33,7 @@
 #import <WebCore/FloatRect.h>
 #import <WebCore/Frame.h>
 #import <WebCore/FrameSelection.h>
-#import <WebCore/FrameSnapshottingMac.h>
+#import <WebCore/FrameSnapshotting.h>
 #import <WebCore/FrameView.h>
 #import <WebCore/HitTestResult.h>
 #import <WebCore/htmlediting.h>
index 5fc85b7..c0d8dfa 100644 (file)
@@ -1,3 +1,16 @@
+2013-11-18  Brian J. Burg  <burg@cs.washington.edu>
+
+        Consolidate various frame snapshot capabilities.
+        https://bugs.webkit.org/show_bug.cgi?id=124325
+
+        Reviewed by Timothy Hatcher.
+
+        Use new platform-independent methods instead of Mac methods.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _selectionDraggingImage]):
+        (-[WebHTMLView selectionImageForcingBlackText:]):
+
 2013-11-18  Anders Carlsson  <andersca@apple.com>
 
         Remove unnecessary COMPILER(CLANG) #ifdefs in Mac-only code
index 486280e..afbf8cc 100644 (file)
@@ -85,6 +85,7 @@
 #import <WebCore/DocumentFragment.h>
 #import <WebCore/DocumentMarkerController.h>
 #import <WebCore/DragController.h>
+#import <WebCore/DragImage.h>
 #import <WebCore/Editor.h>
 #import <WebCore/EditorDeleteAction.h>
 #import <WebCore/Element.h>
@@ -95,7 +96,6 @@
 #import <WebCore/Frame.h>
 #import <WebCore/FrameLoader.h>
 #import <WebCore/FrameSelection.h>
-#import <WebCore/FrameSnapshottingMac.h>
 #import <WebCore/FrameView.h>
 #import <WebCore/HTMLConverter.h>
 #import <WebCore/HTMLNames.h>
@@ -1820,7 +1820,12 @@ static bool mouseEventIsPartOfClickOrDrag(NSEvent *event)
 {
     if (![self _hasSelection])
         return nil;
-    NSImage *dragImage = selectionImage(core([self _frame]));
+
+    Frame* coreFrame = core([self _frame]);
+    if (!coreFrame)
+        return nil;
+
+    NSImage *dragImage = [[createDragImageForSelection(*coreFrame) retain] autorelease];
     [dragImage _web_dissolveToFraction:WebDragImageAlpha];
     return dragImage;
 }
@@ -5965,7 +5970,11 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
 {
     if (![self _hasSelection])
         return nil;
-    return selectionImage(core([self _frame]), forceBlackText);
+
+    Frame* coreFrame = core([self _frame]);
+    if (!coreFrame)
+        return nil;
+    return [[createDragImageForSelection(*coreFrame, forceBlackText) retain] autorelease];
 }
 
 - (NSRect)selectionImageRect
index 25a52af..4febeb8 100644 (file)
@@ -1,3 +1,13 @@
+2013-11-18  Brian J. Burg  <burg@cs.washington.edu>
+
+        Consolidate various frame snapshot capabilities.
+        https://bugs.webkit.org/show_bug.cgi?id=124325
+
+        Reviewed by Timothy Hatcher.
+
+        * DOMCoreClasses.cpp:
+        (DOMElement::renderedImage): use createDragImageForNode.
+
 2013-11-18  peavo@outlook.com  <peavo@outlook.com>
 
         [Win] Optimization, no need to erase background before paint.
index ccbd719..b81d4a7 100644 (file)
 #include <WebCore/COMPtr.h>
 #include <WebCore/DOMWindow.h>
 #include <WebCore/Document.h>
+#include <WebCore/DragImage.h>
 #include <WebCore/Element.h>
 #include <WebCore/Font.h>
 #include <WebCore/Frame.h>
-#include <WebCore/SimpleFontData.h>
 #include <WebCore/HTMLFormElement.h>
 #include <WebCore/HTMLInputElement.h>
 #include <WebCore/HTMLNames.h>
@@ -49,6 +49,7 @@
 #include <WebCore/NodeList.h>
 #include <WebCore/RenderElement.h>
 #include <WebCore/RenderTreeAsText.h>
+#include <WebCore/SimpleFontData.h>
 
 #include <initguid.h>
 // {3B0C0EFF-478B-4b0b-8290-D2321E08E23E}
@@ -1279,7 +1280,7 @@ HRESULT STDMETHODCALLTYPE DOMElement::renderedImage(HBITMAP* image)
     if (!frame)
         return E_FAIL;
 
-    *image = frame->nodeImage(m_element);
+    *image = createDragImageForNode(*frame, *m_element);
     if (!*image)
         return E_FAIL;