WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
v5
bug-124325-20131204154155.patch (text/plain), 65.89 KB, created by
Brian Burg
on 2013-12-04 15:41:55 PST
(
hide
)
Description:
v5
Filename:
MIME Type:
Creator:
Brian Burg
Created:
2013-12-04 15:41:55 PST
Size:
65.89 KB
patch
obsolete
>Subversion Revision: 160115 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 34b6a1916721ad4da5377d2bcdf56eba786a0e7e..35287cec34c0ebb3b61261e7cf0d640cb9f4c0b1 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,61 @@ >+2013-12-04 Brian J. Burg <burg@cs.washington.edu> >+ >+ Consolidate various frame snapshot capabilities. >+ https://bugs.webkit.org/show_bug.cgi?id=124325 >+ >+ Reviewed by Darin Adler. >+ >+ 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-12-04 Daniel Bates <dabates@apple.com> > > Fix the Apple Windows build after <http://trac.webkit.org/changeset/160113> >diff --git a/Source/WebKit/ios/ChangeLog b/Source/WebKit/ios/ChangeLog >index 612af185c3c3d3d079026533e6f94045ea128c61..d59fa5b3d71df55a8abe61f45bc6eb538add6c53 100644 >--- a/Source/WebKit/ios/ChangeLog >+++ b/Source/WebKit/ios/ChangeLog >@@ -1,3 +1,12 @@ >+2013-12-04 Brian J. Burg <burg@cs.washington.edu> >+ >+ Consolidate various frame snapshot capabilities. >+ https://bugs.webkit.org/show_bug.cgi?id=124325 >+ >+ Reviewed by Darin Adler. >+ >+ * WebCoreSupport/WebFrameIOS.mm: use new header file. >+ > 2013-12-04 Andy Estes <aestes@apple.com> > > [iOS] Upstream build fixes in Source/WebKit/ios/ >diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog >index cababd357ba2efd15d8bdf09ce79aeb904bef8c0..a5e2270a697b5250aa646ee855b1f62a0275109a 100644 >--- a/Source/WebKit/mac/ChangeLog >+++ b/Source/WebKit/mac/ChangeLog >@@ -1,3 +1,16 @@ >+2013-12-04 Brian J. Burg <burg@cs.washington.edu> >+ >+ Consolidate various frame snapshot capabilities. >+ https://bugs.webkit.org/show_bug.cgi?id=124325 >+ >+ Reviewed by Darin Adler. >+ >+ Use new platform-independent methods instead of Mac methods. >+ >+ * WebView/WebHTMLView.mm: >+ (-[WebHTMLView _selectionDraggingImage]): >+ (-[WebHTMLView selectionImageForcingBlackText:]): >+ > 2013-12-04 Andy Estes <aestes@apple.com> > > [iOS] Build projects with $(ARCHS_STANDARD_32_64_BIT) >diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog >index 62602e377517c62f040d7013b634d5fa437f4000..2473f19b34c801f4a1a6d0a565ad501a6a53b36d 100644 >--- a/Source/WebKit/win/ChangeLog >+++ b/Source/WebKit/win/ChangeLog >@@ -1,3 +1,13 @@ >+2013-12-04 Brian J. Burg <burg@cs.washington.edu> >+ >+ Consolidate various frame snapshot capabilities. >+ https://bugs.webkit.org/show_bug.cgi?id=124325 >+ >+ Reviewed by Darin Adler. >+ >+ * DOMCoreClasses.cpp: >+ (DOMElement::renderedImage): use createDragImageForNode. >+ > 2013-12-03 Joseph Pecoraro <pecoraro@apple.com> > > Web Inspector: Push Remote Inspector debugging connection management into JavaScriptCore >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index b0299d857f43c939a6e95c4e7e1f40c6ff2a447d..74563699dc32c1d84c06a1327d8e9aef9bc936d6 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1732,6 +1732,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 >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 301cebedd32971da8d6546e311976e503c54a1b7..ca45001c3ca30ffb57e874943da348edaf5c6f1a 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -4131,6 +4131,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 \ >diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in >index aa369fbbf62c21b83f2ffbf5c36513fb07a28ac4..e7fc5e6f39df54b0cfff56358bed80e16ce7352d 100644 >--- a/Source/WebCore/WebCore.exp.in >+++ b/Source/WebCore/WebCore.exp.in >@@ -428,7 +428,6 @@ __ZN7WebCore14cookiesEnabledERKNS_21NetworkStorageSessionERKNS_3URLES5_ > __ZN7WebCore14decodeHostNameEP8NSString > __ZN7WebCore14encodeHostNameEP8NSString > __ZN7WebCore14endOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE >-__ZN7WebCore14selectionImageEPNS_5FrameEb > __ZN7WebCore14setMetadataURLERN3WTF6StringERKS1_S4_ > __ZN7WebCore15AffineTransform5flipYEv > __ZN7WebCore15AffineTransform5scaleEd >@@ -890,6 +889,7 @@ __ZN7WebCore27AuthenticationChallengeBaseC2Ev > __ZN7WebCore27CSSComputedStyleDeclarationC1EN3WTF10PassRefPtrINS_4NodeEEEbRKNS1_6StringE > __ZN7WebCore27DeviceOrientationClientMock14setOrientationEN3WTF10PassRefPtrINS_21DeviceOrientationDataEEE > __ZN7WebCore27DeviceOrientationClientMockC1Ev >+__ZN7WebCore27createDragImageForSelectionERNS_5FrameEb > __ZN7WebCore27protocolHostAndPortAreEqualERKNS_3URLES2_ > __ZN7WebCore27startObservingCookieChangesEPFvvE > __ZN7WebCore28DocumentStyleSheetCollection12addUserSheetEN3WTF7PassRefINS_18StyleSheetContentsEEE >@@ -2035,7 +2035,6 @@ __ZN7WebCore38contextMenuItemTagWritingDirectionMenuEv > __ZN7WebCore42contextMenuItemTagCheckGrammarWithSpellingEv > __ZN7WebCore42contextMenuItemTagCheckSpellingWhileTypingEv > __ZN7WebCore46contextMenuItemTagCorrectSpellingAutomaticallyEv >-__ZN7WebCore5Frame9nodeImageEPNS_4NodeE > __ZN7WebCore6Cursor8fromTypeENS0_4TypeE > __ZN7WebCore6CursorC1EPNS_5ImageERKNS_8IntPointE > __ZN7WebCore6CursorC1ERKS0_ >diff --git a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj >index 416556c26dc563739abd27a8b25b49f9455017ee..587ac4765abf31c538039f23b149c7bcb5b4ed8e 100644 >--- a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj >+++ b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj >@@ -6998,6 +6998,7 @@ > <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" /> >@@ -18853,6 +18854,7 @@ > <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" /> >diff --git a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters >index 97b8847f480b512e56338b26e08f7ff0c47a37b6..f0b026602442dddd01fa01280e1666cde47e6121 100644 >--- a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters >+++ b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters >@@ -720,6 +720,9 @@ > <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> >@@ -7641,6 +7644,9 @@ > <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> >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index cdc77b861b5cb1c252227e829da6375439a8cb5a..af822ff4124159f3a2387511196a4fb9750ca1f9 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2013,7 +2013,6 @@ > 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, ); }; }; >@@ -2218,8 +2217,6 @@ > 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 */; }; >@@ -5255,6 +5252,8 @@ > 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 */; }; >@@ -8779,7 +8778,6 @@ > 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>"; }; >@@ -9011,8 +9009,6 @@ > 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>"; }; >@@ -12319,6 +12315,8 @@ > 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>"; }; >@@ -15691,6 +15689,8 @@ > 65BF022A0974816300C43196 /* Frame.h */, > 974A862014B7ADBB003FDC76 /* FrameDestructionObserver.cpp */, > 974A862114B7ADBB003FDC76 /* FrameDestructionObserver.h */, >+ C4CD629818383766007EBAF1 /* FrameSnapshotting.cpp */, >+ C4CD629918383766007EBAF1 /* FrameSnapshotting.h */, > 65A21482097A3F5300B9050A /* FrameTree.cpp */, > 65A21483097A3F5300B9050A /* FrameTree.h */, > 65CBFEF70974F607001DAC25 /* FrameView.cpp */, >@@ -16607,9 +16607,6 @@ > 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 */, >@@ -22227,6 +22224,7 @@ > 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 */, >@@ -23089,7 +23087,6 @@ > 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 */, >@@ -26378,10 +26375,8 @@ > 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 */, >@@ -27892,6 +27887,7 @@ > 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 */, >diff --git a/Source/WebCore/bindings/objc/DOM.mm b/Source/WebCore/bindings/objc/DOM.mm >index cc0365526e316e05d5b15bb7444c3bb2bcfa9050..12864b90e66845ec3d8f70abd9ebebf575de2acc 100644 >--- a/Source/WebCore/bindings/objc/DOM.mm >+++ b/Source/WebCore/bindings/objc/DOM.mm >@@ -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" >@@ -289,7 +289,7 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget) > WebCore::Frame* frame = node->document().frame(); > if (!frame) > return nil; >- return frame->nodeImage(node).get(); >+ return [createDragImageForNode(*frame, *node).leakRef() autorelease]; > } > > - (NSArray *)textRects >@@ -335,7 +335,7 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget) > if (!frame) > return nil; > >- return WebCore::rangeImage(frame, range, forceBlackText); >+ return [createDragImageForRange(*frame, *range, forceBlackText).leakRef() autorelease]; > } > > - (NSArray *)textRects >diff --git a/Source/WebCore/dom/Clipboard.cpp b/Source/WebCore/dom/Clipboard.cpp >index 9d2e2752fdf2b7c6642a2424f88063ec8a71c7c8..307fcc15f7d0808fcded649a272ebc0cb6803573 100644 >--- a/Source/WebCore/dom/Clipboard.cpp >+++ b/Source/WebCore/dom/Clipboard.cpp >@@ -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 >diff --git a/Source/WebCore/dom/ClipboardMac.mm b/Source/WebCore/dom/ClipboardMac.mm >index 76ca6fca3e42407b5f8e7b35e658737c2113e8fb..a09b30a4a6683ba1fd7fb45fa89b2dbec00c324e 100644 >--- a/Source/WebCore/dom/ClipboardMac.mm >+++ b/Source/WebCore/dom/ClipboardMac.mm >@@ -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(); >diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp >index 41f3bfe826c8063741c74e3bda0254906a93d780..d032bff4cff9ca8e4fc0320d5336465545a5aa25 100644 >--- a/Source/WebCore/page/DragController.cpp >+++ b/Source/WebCore/page/DragController.cpp >@@ -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" >@@ -779,7 +780,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()); > } >diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp >index 3d861648826ec07331018182ab5f0837a3b6e266..49e187b7149a24d22958df0bafc8c39e95574fda 100644 >--- a/Source/WebCore/page/Frame.cpp >+++ b/Source/WebCore/page/Frame.cpp >@@ -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); >- >- std::unique_ptr<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); >- >- std::unique_ptr<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 >diff --git a/Source/WebCore/page/Frame.h b/Source/WebCore/page/Frame.h >index 8407e9e2bcf3eefeddbf0531be6ce9279457277c..5f1866fe202fcfea6442c0bbef820f56ed23e74d 100644 >--- a/Source/WebCore/page/Frame.h >+++ b/Source/WebCore/page/Frame.h >@@ -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 >index 0000000000000000000000000000000000000000..af45a3cd366b97733af868c401de84717ddac2d9 >--- /dev/null >+++ b/Source/WebCore/page/FrameSnapshotting.cpp >@@ -0,0 +1,130 @@ >+/* >+ * 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) >+ * Copyright (C) 2013 University of Washington. >+ * >+ * 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); >+ } >+ >+ const Frame& frame; >+ const Node* node; >+ const PaintBehavior paintBehavior; >+ const Color backgroundColor; >+}; >+ >+std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame& frame, const IntRect& imageRect, SnapshotOptions options) >+{ >+ if (!frame.page()) >+ return nullptr; >+ >+ frame.document()->updateLayout(); >+ >+ FrameView::SelectionInSnapshot shouldIncludeSelection = FrameView::IncludeSelection; >+ if (options & SnapshotOptionsExcludeSelectionHighlighting) >+ shouldIncludeSelection = FrameView::ExcludeSelection; >+ >+ FrameView::CoordinateSpaceForSnapshot coordinateSpace = FrameView::DocumentCoordinates; >+ if (options & SnapshotOptionsInViewCoordinates) >+ coordinateSpace = FrameView::ViewCoordinates; >+ >+ ScopedFramePaintingState state(frame, nullptr); >+ >+ PaintBehavior paintBehavior = state.paintBehavior; >+ if (options & SnapshotOptionsForceBlackText) >+ paintBehavior |= PaintBehaviorForceBlackText; >+ if (options & SnapshotOptionsPaintSelectionOnly) >+ paintBehavior |= PaintBehaviorSelectionOnly; >+ >+ // Other paint behaviors are set by paintContentsForSnapshot. >+ frame.view()->setPaintBehavior(paintBehavior); >+ >+ float deviceScaleFactor = frame.page()->deviceScaleFactor(); >+ IntRect usedRect(imageRect); >+ usedRect.scale(deviceScaleFactor); >+ >+ std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(usedRect.size(), deviceScaleFactor, ColorSpaceDeviceRGB); >+ 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; >+ >+ options |= SnapshotOptionsPaintSelectionOnly; >+ return snapshotFrameRect(frame, enclosingIntRect(frame.selection().bounds()), options); >+} >+ >+std::unique_ptr<ImageBuffer> snapshotNode(Frame& frame, Node& node) >+{ >+ if (!node.renderer()) >+ return nullptr; >+ >+ ScopedFramePaintingState state(frame, &node); >+ >+ frame.view()->setBaseBackgroundColor(Color::transparent); >+ frame.view()->setNodeToDraw(&node); >+ >+ LayoutRect topLevelRect; >+ return snapshotFrameRect(frame, pixelSnappedIntRect(node.renderer()->paintingRootRect(topLevelRect))); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/page/FrameSnapshotting.h b/Source/WebCore/page/FrameSnapshotting.h >new file mode 100644 >index 0000000000000000000000000000000000000000..f74767b28eb7fff871f0af4ac5a4981c0802c476 >--- /dev/null >+++ b/Source/WebCore/page/FrameSnapshotting.h >@@ -0,0 +1,57 @@ >+/* >+ * 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) >+ * Copyright (C) 2013 University of Washington. >+ * >+ * 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 <memory> >+ >+namespace WebCore { >+ >+class Frame; >+class IntRect; >+class ImageBuffer; >+class Node; >+ >+enum { >+ SnapshotOptionsNone = 0, >+ SnapshotOptionsExcludeSelectionHighlighting = 1 << 0, >+ SnapshotOptionsPaintSelectionOnly = 1 << 1, >+ SnapshotOptionsInViewCoordinates = 1 << 2, >+ SnapshotOptionsForceBlackText = 1 << 3, >+}; >+typedef unsigned 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 >index dafb1f91bcbd6f0627a61d1e94de9b714a8b5434..0000000000000000000000000000000000000000 >--- a/Source/WebCore/page/mac/FrameMac.mm >+++ /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 >index bfab67e765814ae6cbc901bad44afd153f862a22..0000000000000000000000000000000000000000 >--- a/Source/WebCore/page/mac/FrameSnapshottingMac.h >+++ /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 >index e92c2f23cb17bd03d4e8a5ee19514ac4391d19eb..0000000000000000000000000000000000000000 >--- a/Source/WebCore/page/mac/FrameSnapshottingMac.mm >+++ /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 >diff --git a/Source/WebCore/page/win/FrameWin.cpp b/Source/WebCore/page/win/FrameWin.cpp >index 5aaf3a678c9e543af683b37ad5b06cce06443b9f..9674f1768f5dd8425b60c7af16f0f1f7d6f7631e 100644 >--- a/Source/WebCore/page/win/FrameWin.cpp >+++ b/Source/WebCore/page/win/FrameWin.cpp >@@ -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 >diff --git a/Source/WebCore/page/win/FrameWin.h b/Source/WebCore/page/win/FrameWin.h >index 3a2723e63d6d7e7ec044cb12f2ea7bd06cfe659f..269725c1f9b9b80d5781484f931ab25dd3ae3317 100644 >--- a/Source/WebCore/page/win/FrameWin.h >+++ b/Source/WebCore/page/win/FrameWin.h >@@ -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 >diff --git a/Source/WebCore/platform/DragImage.cpp b/Source/WebCore/platform/DragImage.cpp >index b81afd579e8293eefa2ba93b9bb55c1f5076cf47..0652e9f321a16b562c117535fbc8e59b91add067 100644 >--- a/Source/WebCore/platform/DragImage.cpp >+++ b/Source/WebCore/platform/DragImage.cpp >@@ -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" >@@ -28,29 +28,37 @@ > > #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,147 @@ DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, c > scalex *= resizeRatio; > scaley *= resizeRatio; > } >- >+ > return scaleDragImage(image, FloatSize(scalex, scaley)); > } > >+struct ScopedNodeDragEnabler { >+ ScopedNodeDragEnabler(Frame& frame, Node& node) >+ : frame(frame) >+ , node(node) >+ { >+ if (node.renderer()) >+ node.renderer()->updateDragState(true); >+ frame.document()->updateLayout(); >+ } >+ >+ ~ScopedNodeDragEnabler() >+ { >+ if (node.renderer()) >+ node.renderer()->updateDragState(false); >+ } >+ >+ const Frame& frame; >+ const 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) >+{ >+ ScopedNodeDragEnabler enableDrag(frame, node); >+ return createDragImageFromSnapshot(snapshotNode(frame, node), &node); >+} >+ >+DragImageRef createDragImageForSelection(Frame& frame, bool forceBlackText) >+{ >+ SnapshotOptions options = forceBlackText ? SnapshotOptionsForceBlackText : SnapshotOptionsNone; >+ return createDragImageFromSnapshot(snapshotSelection(frame, options), 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); >+ } >+ >+ const 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 = SnapshotOptionsPaintSelectionOnly | (forceBlackText ? SnapshotOptionsForceBlackText : SnapshotOptionsNone); >+ view->setSelection(startRenderer, start.deprecatedEditingOffset(), endRenderer, end.deprecatedEditingOffset(), RenderView::RepaintNothing); >+ // We capture using snapshotFrameRect() because we fake up the selection using >+ // FrameView but snapshotSelection() uses the selection from the Frame itself. >+ return createDragImageFromSnapshot(snapshotFrameRect(frame, view->selectionBounds(), options), nullptr); >+} >+ >+DragImageRef createDragImageForImage(Frame& frame, Node& node, IntRect& imageRect, IntRect& elementRect) >+{ >+ ScopedNodeDragEnabler 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; >+ >+ return createDragImageFromSnapshot(snapshotNode(frame, node), &node); >+} >+ > #if !PLATFORM(MAC) && (!PLATFORM(WIN) || OS(WINCE)) > DragImageRef createDragImageForLink(URL&, const String&, FontRenderingMode) > { >- return 0; >+ return nullptr; > } > #endif > >diff --git a/Source/WebCore/platform/DragImage.h b/Source/WebCore/platform/DragImage.h >index d8f52bcfad44243f8accb8670a094af113c4b24d..d83696e3311cce5417352b6d04699a1033440f0e 100644 >--- a/Source/WebCore/platform/DragImage.h >+++ b/Source/WebCore/platform/DragImage.h >@@ -26,10 +26,11 @@ > #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 >diff --git a/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm b/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm >index 24d1603a8cf6dc292304cd6616a8bf17afa59080..6c96be7199702c6fbe34e82bca9983de650cc91e 100644 >--- a/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm >+++ b/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm >@@ -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> >diff --git a/Source/WebKit/mac/WebView/WebHTMLView.mm b/Source/WebKit/mac/WebView/WebHTMLView.mm >index bed2d8a24ab2f7e4e5f6394d1facc343b1e25797..35d0194d20259bfa8f33e36d880fe0409fb9f2e6 100644 >--- a/Source/WebKit/mac/WebView/WebHTMLView.mm >+++ b/Source/WebKit/mac/WebView/WebHTMLView.mm >@@ -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).leakRef() 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).leakRef() autorelease]; > } > > - (NSRect)selectionImageRect >diff --git a/Source/WebKit/win/DOMCoreClasses.cpp b/Source/WebKit/win/DOMCoreClasses.cpp >index ccbd71901e45579031b902ba56a894e6a8d79cb3..b81d4a7d73477adf8bdb783b251de1dc9ffd9307 100644 >--- a/Source/WebKit/win/DOMCoreClasses.cpp >+++ b/Source/WebKit/win/DOMCoreClasses.cpp >@@ -36,10 +36,10 @@ > #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; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 124325
:
216888
|
216938
|
216943
|
216956
|
217137
|
217138
|
217155
|
217157
|
217159
|
217162
|
217223
|
217767
|
217774
|
217916
|
217917
| 218467