diff options
Diffstat (limited to 'WebKit')
487 files changed, 52369 insertions, 4653 deletions
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog index 5006da7..90a6a28 100644 --- a/WebKit/ChangeLog +++ b/WebKit/ChangeLog @@ -1,3 +1,125 @@ +2009-11-30 Mark Rowe <mrowe@apple.com> + + Use the correct path to Info.plist to avoid creating an empty file at the top of the WebKit directory. + + * WebKit.xcodeproj/project.pbxproj: + +2009-11-24 Dmitry Titov <dimich@chromium.org> + + Reviewed by Eric Seidel. + + Add ENABLE_SHARED_SCRIPT feature define and flag for build-webkit + https://bugs.webkit.org/show_bug.cgi?id=31444 + + * chromium/features.gypi: + +2009-11-24 Mark Rowe <mrowe@apple.com> + + Fix production builds where the source tree may be read-only. + + * WebKit.xcodeproj/project.pbxproj: + +2009-11-20 Dave Hyatt <hyatt@apple.com> + + Reviewed by Oliver Hunt and Jon Honeycutt. + + Add support for WebSerializedJSValue to WebKit. This object wraps the SerializedScriptValue functionality in WebCore + and exposes the ability to do JS value serialization/deserialization to WebKit clients. + + * WebKit.xcodeproj/project.pbxproj: + +2009-11-20 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Beth Dakin. + + WAI-ARIA: add support for 'math' role + https://bugs.webkit.org/show_bug.cgi?id=31706 + + * English.lproj/Localizable.strings: + * StringsNotToBeLocalized.txt: + +2009-11-19 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/7035231> + Support closed caption in <video> element + + * English.lproj/Localizable.strings: + Add strings for toggle captions button. + +2009-11-18 Michelangelo De Simone <micdesim@gmail.com> + + Reviewed by Darin Adler. + + Fix for <https://bugs.webkit.org/show_bug.cgi?id=27959>. + Support for validationMessage attribute, as per HTML5 specs. + + * English.lproj/Localizable.strings: new localizable strings + +2009-11-18 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Make the Mac Geolocation API async. + + * WebKit.xcodeproj/project.pbxproj: Remove WebGeolocation. + +2009-11-13 Adam Roben <aroben@apple.com> + + Add WebFrameLoadDelegatePrivat.h to WebKit.xcodeproj + + Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when + window objects in isolated worlds are cleared + + Reviewed by Dave Hyatt. + + * WebKit.xcodeproj/project.pbxproj: Added + WebFrameLoadDelegatePrivate.h, which already existed. + +2009-11-12 Adam Roben <aroben@apple.com> + + Replace worldIDs with world objects + + Part of <http://webkit.org/b/31414> Implement new SPI for dealing with + user scripts/stylesheets and isolated worlds + + Reviewed by Sam Weinig. + + * WebKit.xcodeproj/project.pbxproj: Added WebScriptWorld to the project. + +2009-11-12 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Darin Adler. + + ARIA: add alert type roles + https://bugs.webkit.org/show_bug.cgi?id=31392 + + * English.lproj/Localizable.strings: + * StringsNotToBeLocalized.txt: + +2009-11-02 Eric Carlson <eric.carlson@apple.com> + + Reviewed by John Sullivan and Mark Rowe. + + <rdar://problem/7356733> Voiceover does not read correct media controller time values + + Fix localized strings for media controller time values. + + * English.lproj/Localizable.strings: + +2009-11-02 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Beth Dakin. + + Support ARIA "tab" roles + https://bugs.webkit.org/show_bug.cgi?id=30842 + + Add a localizable string for tab panel. + + * English.lproj/Localizable.strings: + * StringsNotToBeLocalized.txt: + 2009-10-27 Dan Bernstein <mitz@apple.com> Reviewed by Darin Adler. diff --git a/WebKit/English.lproj/Localizable.strings b/WebKit/English.lproj/Localizable.strings Binary files differindex e4a172b..fb857f5 100644 --- a/WebKit/English.lproj/Localizable.strings +++ b/WebKit/English.lproj/Localizable.strings diff --git a/WebKit/StringsNotToBeLocalized.txt b/WebKit/StringsNotToBeLocalized.txt index 3f1964d..90b29be 100644 --- a/WebKit/StringsNotToBeLocalized.txt +++ b/WebKit/StringsNotToBeLocalized.txt @@ -96,12 +96,16 @@ "@" "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-." "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+.-" +"ARIAApplicationAlert" +"ARIAApplicationAlertDialog" +"ARIAApplicationDialog" "ARIAApplicationLog" "ARIAApplicationMarquee" "ARIAApplicationStatus" "ARIAApplicationTimer" "ARIADocument" "ARIADocumentArticle" +"ARIADocumentMath" "ARIADocumentNote" "ARIADocumentRegion" "ARIALandmarkApplication" @@ -111,6 +115,7 @@ "ARIALandmarkMain" "ARIALandmarkNavigation" "ARIALandmarkSearch" +"ARIATabPanel" "ARIAUserInterfaceTooltip" "AXEnhancedUserInterface" "AccessibleBase" diff --git a/WebKit/WebKit.xcodeproj/project.pbxproj b/WebKit/WebKit.xcodeproj/project.pbxproj index a5a2e39..de8c687 100644 --- a/WebKit/WebKit.xcodeproj/project.pbxproj +++ b/WebKit/WebKit.xcodeproj/project.pbxproj @@ -326,6 +326,8 @@ ABDDF20D08EB0DDC001E1241 /* WebDownloadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */; }; B6CE5C24100BC5CE00219936 /* WebApplicationCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = B68049720FFBCEC1009F7F62 /* WebApplicationCache.mm */; }; B6CE5C25100BC5F500219936 /* WebApplicationCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B68049710FFBCEC1009F7F62 /* WebApplicationCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; + BC26C69E10B743F400B687ED /* WebSerializedJSValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC26C69D10B743F400B687ED /* WebSerializedJSValue.h */; settings = {ATTRIBUTES = (Private, ); }; }; + BC26C6A510B7447A00B687ED /* WebSerializedJSValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC26C6A410B7447A00B687ED /* WebSerializedJSValue.mm */; }; BC2E464D0FD8A96800A9D9DE /* WebViewData.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2E464B0FD8A96800A9D9DE /* WebViewData.h */; }; BC2E464E0FD8A96800A9D9DE /* WebViewData.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC2E464C0FD8A96800A9D9DE /* WebViewData.mm */; }; BC542C420FD7766F00D8AB5D /* WebDelegateImplementationCaching.h in Headers */ = {isa = PBXBuildFile; fileRef = BC542C400FD7766F00D8AB5D /* WebDelegateImplementationCaching.h */; }; @@ -333,6 +335,10 @@ BC97E7E210963D260010D361 /* WebViewEventHandling.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC97E7E110963D260010D361 /* WebViewEventHandling.mm */; }; C0167BF80D7F5DD00028696E /* WebScriptDebugger.h in Headers */ = {isa = PBXBuildFile; fileRef = C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */; }; C0167BF90D7F5DD00028696E /* WebScriptDebugger.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */; }; + C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */; settings = {ATTRIBUTES = (Private, ); }; }; + C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */; }; + C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */; }; + C0B88E8B10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */; }; DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; }; DD89682109AA87240097E7F0 /* WebElementDictionary.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD89681F09AA87240097E7F0 /* WebElementDictionary.mm */; }; @@ -344,9 +350,6 @@ EDE983810BCDF5FE00FDAE28 /* WebNSArrayExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = EDE9837F0BCDF5FE00FDAE28 /* WebNSArrayExtras.m */; }; F834AAD70E64B1C700E2737C /* WebTextIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = F834AAD50E64B1C700E2737C /* WebTextIterator.h */; settings = {ATTRIBUTES = (Private, ); }; }; F834AAD80E64B1C700E2737C /* WebTextIterator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F834AAD60E64B1C700E2737C /* WebTextIterator.mm */; }; - FEF52DFA0F6748F200FF70EE /* WebGeolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEF52DF70F6748F200FF70EE /* WebGeolocation.mm */; }; - FEF52DFB0F6748F200FF70EE /* WebGeolocationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = FEF52DF80F6748F200FF70EE /* WebGeolocationInternal.h */; }; - FEF52DFC0F6748F200FF70EE /* WebGeolocationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = FEF52DF90F6748F200FF70EE /* WebGeolocationPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -601,6 +604,8 @@ ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDownloadInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; B68049710FFBCEC1009F7F62 /* WebApplicationCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebApplicationCache.h; sourceTree = "<group>"; }; B68049720FFBCEC1009F7F62 /* WebApplicationCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebApplicationCache.mm; sourceTree = "<group>"; }; + BC26C69D10B743F400B687ED /* WebSerializedJSValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSerializedJSValue.h; sourceTree = "<group>"; }; + BC26C6A410B7447A00B687ED /* WebSerializedJSValue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSerializedJSValue.mm; sourceTree = "<group>"; }; BC2E464B0FD8A96800A9D9DE /* WebViewData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewData.h; sourceTree = "<group>"; }; BC2E464C0FD8A96800A9D9DE /* WebViewData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewData.mm; sourceTree = "<group>"; }; BC542C400FD7766F00D8AB5D /* WebDelegateImplementationCaching.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDelegateImplementationCaching.h; sourceTree = "<group>"; }; @@ -621,6 +626,10 @@ BEE52D4B0473032500CA289C /* WebKitSystemBits.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitSystemBits.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugger.h; sourceTree = "<group>"; }; C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptDebugger.mm; sourceTree = "<group>"; }; + C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorld.h; sourceTree = "<group>"; }; + C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptWorld.mm; sourceTree = "<group>"; }; + C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorldInternal.h; sourceTree = "<group>"; }; + C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFrameLoadDelegatePrivate.h; sourceTree = "<group>"; }; DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebTypesInternal.h; sourceTree = "<group>"; }; DD89681E09AA87240097E7F0 /* WebElementDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebElementDictionary.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; DD89681F09AA87240097E7F0 /* WebElementDictionary.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebElementDictionary.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; @@ -694,9 +703,6 @@ F834AAD60E64B1C700E2737C /* WebTextIterator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTextIterator.mm; sourceTree = "<group>"; }; F8CA15B5029A39D901000122 /* WebAuthenticationPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebAuthenticationPanel.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; F8CA15B6029A39D901000122 /* WebAuthenticationPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebAuthenticationPanel.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; - FEF52DF70F6748F200FF70EE /* WebGeolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGeolocation.mm; sourceTree = "<group>"; }; - FEF52DF80F6748F200FF70EE /* WebGeolocationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGeolocationInternal.h; sourceTree = "<group>"; }; - FEF52DF90F6748F200FF70EE /* WebGeolocationPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGeolocationPrivate.h; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1103,6 +1109,7 @@ F5143A370221DCCE01A80181 /* WebFrame.mm */, 930D02BD06275F710076701E /* WebFrameInternal.h */, 5152FAE5033FC52200CA2ACD /* WebFrameLoadDelegate.h */, + C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */, 9CF0E249021361B00ECA16EA /* WebFramePrivate.h */, 51A8B52E04282B5900CA2D3A /* WebFrameView.h */, 51A8B52F04282B5900CA2D3A /* WebFrameView.mm */, @@ -1130,6 +1137,11 @@ 7E6FEF0608985A7200C44C3F /* WebScriptDebugDelegate.mm */, C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */, C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */, + C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */, + C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */, + C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */, + BC26C6A410B7447A00B687ED /* WebSerializedJSValue.mm */, + BC26C69D10B743F400B687ED /* WebSerializedJSValue.h */, 936A2DE90FD2D08400D312DB /* WebTextCompletionController.h */, 936A2DE70FD2D08000D312DB /* WebTextCompletionController.mm */, F834AAD50E64B1C700E2737C /* WebTextIterator.h */, @@ -1203,9 +1215,6 @@ 4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */, 931633EA0AEDFF930062B92D /* WebFrameLoaderClient.h */, 931633EE0AEDFFAE0062B92D /* WebFrameLoaderClient.mm */, - FEF52DF70F6748F200FF70EE /* WebGeolocation.mm */, - FEF52DF80F6748F200FF70EE /* WebGeolocationInternal.h */, - FEF52DF90F6748F200FF70EE /* WebGeolocationPrivate.h */, 51494CD40C7EBDE0004178C5 /* WebIconDatabaseClient.h */, 51494CD50C7EBDE0004178C5 /* WebIconDatabaseClient.mm */, 9CE1F8A302A5C6F30ECA2ACD /* WebImageRendererFactory.m */, @@ -1384,8 +1393,6 @@ 9398106E0824BF01008DF038 /* WebFrameView.h in Headers */, 9398106F0824BF01008DF038 /* WebFrameViewInternal.h in Headers */, 939810AF0824BF01008DF038 /* WebFrameViewPrivate.h in Headers */, - FEF52DFB0F6748F200FF70EE /* WebGeolocationInternal.h in Headers */, - FEF52DFC0F6748F200FF70EE /* WebGeolocationPrivate.h in Headers */, 939810120824BF01008DF038 /* WebHistory.h in Headers */, 93FDE9330D79CAF30074F029 /* WebHistoryInternal.h in Headers */, 939810130824BF01008DF038 /* WebHistoryItem.h in Headers */, @@ -1513,6 +1520,10 @@ 0FD3B0F41076C3E900039B96 /* WebVideoFullscreenHUDWindowController.h in Headers */, 0FD3B0F81076C3F700039B96 /* WebWindowAnimation.h in Headers */, 0A2D87FD107AF52B00CDDEE3 /* WebPluginHalterClient.h in Headers */, + C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */, + C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */, + C0B88E8B10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h in Headers */, + BC26C69E10B743F400B687ED /* WebSerializedJSValue.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1650,7 +1661,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Touch Info.plist to let Xcode know it needs to copy it into the built product\ntouch \"$PROJECT_DIR/mac/Info.plist\"\n"; + shellScript = "# Touch Info.plist to let Xcode know it needs to copy it into the built product\nif [[ \"${CONFIGURATION}\" != \"Production\" ]]; then\n touch \"${PROJECT_DIR}/mac/Info.plist\";\nfi;\n"; }; 5DE6D18C0FCF231B002DE28C /* Symlink WebKitPluginHost in to place */ = { isa = PBXShellScriptBuildPhase; @@ -1764,7 +1775,6 @@ 939810F20824BF01008DF038 /* WebFrame.mm in Sources */, 931633EF0AEDFFAE0062B92D /* WebFrameLoaderClient.mm in Sources */, 939811060824BF01008DF038 /* WebFrameView.mm in Sources */, - FEF52DFA0F6748F200FF70EE /* WebGeolocation.mm in Sources */, 939811130824BF01008DF038 /* WebHistory.mm in Sources */, 939810BD0824BF01008DF038 /* WebHistoryItem.mm in Sources */, 1AAF5FC00EDE3A92008D883D /* WebHostedNetscapePluginView.mm in Sources */, @@ -1853,6 +1863,8 @@ 0FD3B0F91076C3F700039B96 /* WebWindowAnimation.m in Sources */, 0A2D87FE107AF52B00CDDEE3 /* WebPluginHalterClient.mm in Sources */, BC97E7E210963D260010D361 /* WebViewEventHandling.mm in Sources */, + C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */, + BC26C6A510B7447A00B687ED /* WebSerializedJSValue.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WebKit/cf/ChangeLog b/WebKit/cf/ChangeLog index 27caf1c..1d061fb 100644 --- a/WebKit/cf/ChangeLog +++ b/WebKit/cf/ChangeLog @@ -1,3 +1,15 @@ +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebCoreSupport/WebInspectorClientCF.cpp: + (WebInspectorClient::populateSetting): + (WebInspectorClient::storeSetting): + 2009-04-20 Steve Falkenburg <sfalken@apple.com> Separate JavaScriptCore.dll from WebKit.dll. diff --git a/WebKit/cf/WebCoreSupport/WebInspectorClientCF.cpp b/WebKit/cf/WebCoreSupport/WebInspectorClientCF.cpp index 600d58d..cb47205 100644 --- a/WebKit/cf/WebCoreSupport/WebInspectorClientCF.cpp +++ b/WebKit/cf/WebCoreSupport/WebInspectorClientCF.cpp @@ -64,7 +64,7 @@ static inline CFStringRef createKeyForPreferences(const String& key) return CFStringCreateWithFormat(0, 0, CFSTR("WebKit Web Inspector Setting - %@"), keyCFString.get()); } -void WebInspectorClient::populateSetting(const String& key, InspectorController::Setting& setting) +void WebInspectorClient::populateSetting(const String& key, String* setting) { RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key)); RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(preferencesKey.get(), kCFPreferencesCurrentApplication)); @@ -74,88 +74,19 @@ void WebInspectorClient::populateSetting(const String& key, InspectorController: CFTypeID type = CFGetTypeID(value.get()); if (type == CFStringGetTypeID()) - setting.set(static_cast<String>(static_cast<CFStringRef>(value.get()))); + *setting = static_cast<String>(static_cast<CFStringRef>(value.get())); else if (type == CFBooleanGetTypeID()) - setting.set(static_cast<bool>(CFBooleanGetValue(static_cast<CFBooleanRef>(value.get())))); - else if (type == CFNumberGetTypeID()) { - CFNumberRef number = static_cast<CFNumberRef>(value.get()); - if (CFNumberIsFloatType(number)) { - double doubleNumber = 0.0; - CFNumberGetValue(static_cast<CFNumberRef>(value.get()), kCFNumberDoubleType, &doubleNumber); - setting.set(doubleNumber); - } else { - long longNumber = 0; - CFNumberGetValue(static_cast<CFNumberRef>(value.get()), kCFNumberLongType, &longNumber); - setting.set(longNumber); - } - } else if (type == CFArrayGetTypeID()) { - Vector<String> strings; - - CFArrayRef array = static_cast<CFArrayRef>(value.get()); - unsigned length = CFArrayGetCount(array); - for (unsigned i = 0; i < length; ++i) { - CFStringRef string = static_cast<CFStringRef>(CFArrayGetValueAtIndex(array, i)); - if (CFGetTypeID(string) == CFStringGetTypeID()) - strings.append(static_cast<String>(static_cast<CFStringRef>(string))); - } - - setting.set(strings); - } else - ASSERT_NOT_REACHED(); + *setting = static_cast<bool>(CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()))) ? "true" : "false"; + else + *setting = ""; } -void WebInspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting) +void WebInspectorClient::storeSetting(const String& key, const String& setting) { RetainPtr<CFPropertyListRef> objectToStore; - - switch (setting.type()) { - default: - case InspectorController::Setting::NoType: - ASSERT_NOT_REACHED(); - break; - case InspectorController::Setting::StringType: - objectToStore.adoptCF(setting.string().createCFString()); - break; - case InspectorController::Setting::BooleanType: - objectToStore = (setting.booleanValue() ? kCFBooleanTrue : kCFBooleanFalse); - break; - - case InspectorController::Setting::DoubleType: { - double value = setting.doubleValue(); - objectToStore.adoptCF(CFNumberCreate(0, kCFNumberDoubleType, &value)); - break; - } - - case InspectorController::Setting::IntegerType: { - long value = setting.integerValue(); - objectToStore.adoptCF(CFNumberCreate(0, kCFNumberLongType, &value)); - break; - } - - case InspectorController::Setting::StringVectorType: { - const Vector<String>& strings = setting.stringVector(); - const unsigned length = strings.size(); - - RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, length, &kCFTypeArrayCallBacks)); - - for (unsigned i = 0; i < length; ++i) { - RetainPtr<CFStringRef> string(AdoptCF, strings[i].createCFString()); - CFArraySetValueAtIndex(array.get(), i, string.get()); - } - - objectToStore = array; - break; - } - } - + objectToStore.adoptCF(setting.createCFString()); ASSERT(objectToStore); RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key)); CFPreferencesSetAppValue(preferencesKey.get(), objectToStore.get(), kCFPreferencesCurrentApplication); } - -void WebInspectorClient::removeSetting(const String& key) -{ - RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key)); - CFPreferencesSetAppValue(preferencesKey.get(), 0, kCFPreferencesCurrentApplication); -} diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog new file mode 100644 index 0000000..d55548b --- /dev/null +++ b/WebKit/chromium/ChangeLog @@ -0,0 +1,3666 @@ +2009-12-10 Mike Belshe <mike@belshe.com> + + Unreviewed, build fix for chromium. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchWillSendRequest): + +2009-12-10 Kenneth Russell <kbr@google.com> + + Reviewed by Oliver Hunt. + + Changed WebGLRenderingContext to synthesize GL errors rather than + raising JavaScript exceptions. Removed internal getError() calls + after each graphics call. The GraphicsContext3D maintains the + synthetic exceptions because only it has complete information + about certain conditions requiring them to be raised. + + Based on idea from Ilmari Heikkinen, added create3DDebugContext() + to webgl-test.js and changed the WebGL layout tests expecting + error conditions to use it. Updated expected.txt files, which now + implicitly test the OpenGL error as it is part of the exception's + message. + + Added new targeted test covering aspects of synthetic errors as + well as regression tests for bugs uncovered during its development. + + Test: fast/canvas/webgl/error-reporting.html + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3DInternal::reshape): + (WebCore::GraphicsContext3DInternal::getError): + (WebCore::GraphicsContext3DInternal::synthesizeGLError): + (WebCore::GraphicsContext3D::getActiveAttrib): + (WebCore::GraphicsContext3D::getActiveUniform): + (WebCore::GraphicsContext3D::getError): + (WebCore::GraphicsContext3D::synthesizeGLError): + +2009-12-10 Mike Belshe <mike@belshe.com> + + Reviewed by Darin Fisher. + + Fix FrameLoader to use the new ResourceTypes properly. + + https://bugs.webkit.org/show_bug.cgi?id=32336 + + * public/WebURLRequest.h: + (WebKit::WebURLRequest::): + * src/FrameLoaderClientImpl.cpp: + (WebKit::setTargetTypeFromLoader): + (WebKit::FrameLoaderClientImpl::dispatchWillSendRequest): + +2009-12-10 Ilya Tikhonovsky <loislo@google.com> + + Reviewed by Pavel Feldman. + + Chromium: Expose devtools agent API for inspector layout tests. + + https://bugs.webkit.org/show_bug.cgi?id=32379 + + * public/WebDevToolsAgent.h: + (WebKit::WebDevToolsAgent::setTimelineProfilingEnabled): + (WebKit::WebDevToolsAgent::evaluateInWebInspector): + +2009-12-09 Yury Semikhatsky <yurys@chromium.org> + + Unreviewed, build fix. + + Change forward declaration of WebContextMenuData from class to + struct to match its definition. The bug was introduced by + http://trac.webkit.org/changeset/51874 + + * src/ContextMenuClientImpl.h: + +2009-12-09 Darin Fisher <darin@chromium.org> + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=32324 + [Chromium] Suppress WebFrameClient callbacks from a detached frame. + + This change means that we no longer need the ClientHandle class. + FrameLoaderClient::detachedFromParent3() is called on each frame + in the frame tree from within frameDetached(). + + Test: http/tests/loading/gmail-assert-on-load.html + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::detachedFromParent3): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::create): + (WebKit::WebFrameImpl::WebFrameImpl): + (WebKit::WebFrameImpl::createChildFrame): + * src/WebFrameImpl.h: + (WebKit::WebFrameImpl::client): + (WebKit::WebFrameImpl::dropClient): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::close): + +2009-12-08 Stuart Morgan <stuartmorgan@chromium.org> + + Reviewed by Darin Fisher. + + Include clickCount when doing MouseEvent -> WebMouseEvent conversion + in Chromium API. + + https://bugs.webkit.org/show_bug.cgi?id=32289 + + * src/WebInputEventConversion.cpp: + (WebKit::WebMouseEventBuilder::WebMouseEventBuilder): + +2009-12-09 Yury Semikhatsky <yurys@chromium.org> + + Unreviewed, build fix. + + Add return statement to default implementation of hostIdentifier method + introduced in http://trac.webkit.org/changeset/51897 + + * public/WebDevToolsAgentClient.h: + (WebKit::WebDevToolsAgentClient::hostIdentifier): + +2009-12-09 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Add declaration of static methods that allow to dispatch + DevTools messages on the IO thread and accept WebDevToolsMessageData + argument. + + https://bugs.webkit.org/show_bug.cgi?id=32314 + + * public/WebDevToolsAgent.h: + * public/WebDevToolsAgentClient.h: + +2009-12-09 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Introduce a class for devtools message data + + https://bugs.webkit.org/show_bug.cgi?id=32314 + + * WebKit.gyp: + * public/WebDevToolsAgent.h: + * public/WebDevToolsAgentClient.h: + (WebKit::WebDevToolsAgentClient::sendMessageToFrontend): + (WebKit::WebDevToolsAgentClient::forceRepaint): + (WebKit::WebDevToolsAgentClient::hostIdentifier): + (WebKit::WebDevToolsAgentClient::runtimeFeatureStateChanged): + * public/WebDevToolsFrontend.h: + * public/WebDevToolsFrontendClient.h: + (WebKit::WebDevToolsFrontendClient::sendMessageToAgent): + * public/WebDevToolsMessageData.h: Added. + +2009-12-08 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Darin Fisher. + + Chromium: support custom WebCore context menu items in Chromium port. + + https://bugs.webkit.org/show_bug.cgi?id=32277 + + * public/WebContextMenuData.h: + * public/WebPopupMenuInfo.h: + (WebKit::WebPopupMenuInfo::Item::): + * public/WebView.h: + * src/ContextMenuClientImpl.cpp: + (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::executeCustomContextMenuAction): + * src/WebViewImpl.h: + +2009-12-08 Albert J. Wong <ajwong@chromium.org> + + Not reviewed: Chromium build fix. + + r51859 changed the case for some of the ResourceRequest::TargetType + enums. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::determineTargetTypeFromLoader): + +2009-12-07 Zhe Su <suzhe@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] accesskey is not supported on Chromium Mac. + https://bugs.webkit.org/show_bug.cgi?id=32213 + + This change fixes (partially) the accesskey issue by decoupling the + code for handling accesskeys and system keys. Because on Mac, + the modifiers of accesskeys are ctrl+alt, which are not marked as + system keys. + In order to fully fix this issue, some changes in Chromium code is + also required. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::keyEvent): + (WebKit::WebViewImpl::charEvent): + +2009-12-07 Evan Martin <evan@chromium.org> + + Reviewed by Eric Seidel. + + Chromium: theme scrollbars to match GTK theme. + Add API to set the colors. + + Since the change is to the Chromium WebKit API layer, testing will + be in Chromium's test shell. + http://bugs.webkit.org/show_bug.cgi?id=32048 + + Patch from Markus Gutschke <markus@chromium.org>. + + * public/WebView.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setScrollbarColors): + * src/WebViewImpl.h: + +2009-12-07 Finnur Thorarinsson <finnur.webkit@gmail.com> + + Reviewed by Darin Fisher. + + A patch for Chromium to restrict the scope of the Gmail focus fix, + where we set the Selection to 0,0 for content-editable fields and + also make sure we set the selection end-state for find to select the + text found (when not focusing a link we found). + WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=32248 + + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::setFindEndstateFocusAndSelection): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setFocus): + +2009-12-07 Dmitry Titov <dimich@chromium.org> + + Rubber-stamped by Darin Adler. + + Remove ENABLE_SHARED_SCRIPT flags + https://bugs.webkit.org/show_bug.cgi?id=32245 + This patch was obtained by "git revert" command and then un-reverting of ChangeLog files. + + * features.gypi: + +2009-12-07 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Darin Fisher. + + fixes to build-webkit --chromium + https://bugs.webkit.org/show_bug.cgi?id=32179 + + * DEPS: + * WebKit.gyp: + * gyp_webkit: + +2009-12-07 Mikhail Naganov <mnaganov@chromium.org> + + Reviewed by Pavel Feldman. + + [Chromium] Add declarations for DevTools message dispatching on IO thread + (see http://codereview.chromium.org/460018) + + https://bugs.webkit.org/show_bug.cgi?id=32217 + + * public/WebDevToolsAgent.h: + * public/WebDevToolsAgentClient.h: + +2009-12-04 James Hawkins <jhawkins@chromium.org> + + Reviewed by Darin Fisher. + + https://bugs.webkit.org/show_bug.cgi?id=32095 + Implement WebRegularExpression, a WebKit API for accessing + WebCore::RegularExpression. + + * WebKit.gyp: + * public/WebRegularExpression.h: Added. + * public/WebTextCaseSensitivity.h: Added. + (WebKit::): + * src/AssertMatchingEnums.cpp: + * src/WebRegularExpression.cpp: Added. + (WebKit::WebRegularExpression::WebRegularExpression): + (WebKit::WebRegularExpression::~WebRegularExpression): + (WebKit::WebRegularExpression::match): + +2009-12-04 Peter Kasting <pkasting@google.com> + + Reviewed by Darin Fisher. + + [Chromium] Simplify zoom-related APIs and add a zoom level getter, + part two: Remove deprecated APIs. + https://bugs.webkit.org/show_bug.cgi?id=31893 + + * public/WebView.h: + * src/WebViewImpl.cpp: + * src/WebViewImpl.h: + +2009-12-03 Jonathan Dixon <joth@chromium.org> + + Reviewed by Dimitri Glazkov. + + Bug 32066 - Add enable geolocation flag to WebCore::Settings for Chromium + https://bugs.webkit.org/show_bug.cgi?id=32066 + + Add the plumbing to map WebSettings through to WebCore::Settings + + * features.gypi: + * public/WebSettings.h: Add setGeolocationEnabled API to interface + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setGeolocationEnabled): Calls through to WebCore::Settings::setGeolocationEnabled + * src/WebSettingsImpl.h: Add setGeolocationEnabled interface function + +2009-12-03 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7214236> and http://webkit.org/b/32052 - Implement HTML5 state object history API + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchDidPushStateWithinPage): + (WebKit::FrameLoaderClientImpl::dispatchDidReplaceStateWithinPage): + (WebKit::FrameLoaderClientImpl::dispatchDidPopStateWithinPage): + * src/FrameLoaderClientImpl.h: + +2009-12-03 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Chromium: Add support for settings containing ":" + + https://bugs.webkit.org/show_bug.cgi?id=32118 + + * src/InspectorClientImpl.cpp: + (WebKit::InspectorClientImpl::loadSettings): + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * src/InspectorClientImpl.cpp: + (WebKit::InspectorClientImpl::hiddenPanels): + (WebKit::InspectorClientImpl::populateSetting): + (WebKit::InspectorClientImpl::storeSetting): + (WebKit::InspectorClientImpl::loadSettings): + (WebKit::InspectorClientImpl::saveSettings): + * src/InspectorClientImpl.h: + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebKit::FrameLoaderClientImpl::dispatchDidRemoveBackForwardItem): ditto. + (WebKit::FrameLoaderClientImpl::dispatchDidChangeBackForwardIndex): dito. + * src/FrameLoaderClientImpl.h: + +2009-12-02 Yusuke Sato <yusukes@chromium.org> + + Reviewed by Eric Seidel. + + Sanitize web fonts using the OTS library + https://bugs.webkit.org/show_bug.cgi?id=31106 + + * DEPS: Added dependency to the OpenType sanitizer library. + * features.gypi: Added ENABLE_OPENTYPE_SANITIZER=1. + +2009-12-02 Evan Stade <estade@chromium.org> + + Reviewed by Darin Fisher. + + https://bugs.webkit.org/show_bug.cgi?id=32029 + Mousewheel event delta has reversed sign on Linux Chrome. + + No new tests (layout tests don't cover event conversion code). + Manual test: http://www.switchonthecode.com/tutorials/javascript-tutorial-the-scroll-wheel + + * src/gtk/WebInputEventFactory.cpp: + (WebKit::WebInputEventFactory::mouseWheelEvent): + +2009-12-02 Anton Muhin <antonm@chromium.org> + + Reviewed by Adam Barth. + + Allow to skip thread checks when accessing DOMDataStore for processes + which run V8 in single thread mode. + https://bugs.webkit.org/show_bug.cgi?id=31877 + + * src/WebScriptController.cpp: + (WebKit::WebScriptController::enableV8SingleThreadMode): + +2009-12-01 Peter Kasting <pkasting@google.com> + + Reviewed by Darin Fisher. + + [Chromium] Simplify zoom-related APIs and add a zoom level getter, + part one: Add new APIs. (Old APIs will be removed in a second pass.) + https://bugs.webkit.org/show_bug.cgi?id=31893 + + * public/WebView.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::zoomLevel): + (WebKit::WebViewImpl::setZoomLevel): + * src/WebViewImpl.h: + +2009-12-01 Xiyuan Xia <xiyuan@chromium.org> + + Reviewed by Darin Fisher. + + Only fire start/stop events when main frame is not loading. + + https://bugs.webkit.org/show_bug.cgi?id=31838 + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage): + +2009-11-27 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Add separate method for pause command to WebDevToolsAgent + and WebDevToolsFrontendClient interfaces so that pause command + can be processed on the IO thread. + + https://bugs.webkit.org/show_bug.cgi?id=31934 + + * public/WebDevToolsAgent.h: + * public/WebDevToolsFrontendClient.h: + (WebKit::WebDevToolsFrontendClient::sendDebuggerCommandToAgent): + (WebKit::WebDevToolsFrontendClient::sendDebuggerPauseScript): + (WebKit::WebDevToolsFrontendClient::activateWindow): + (WebKit::WebDevToolsFrontendClient::closeWindow): + (WebKit::WebDevToolsFrontendClient::dockWindow): + (WebKit::WebDevToolsFrontendClient::undockWindow): + +2009-11-27 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + WebCore part of the fix that allows to view plugin + resources loaded by plugins. Methods that for resource + loading notifications are exposed through WebDevToolsAgent + interface to the glue code to allow Chromium's plugin + implementation to notify InspectorController about resource + loading in plugins. + + https://bugs.webkit.org/show_bug.cgi?id=31832 + + * public/WebDevToolsAgent.h: + * public/WebView.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::createUniqueIdentifierForRequest): + * src/WebViewImpl.h: + +2009-11-26 Yury Semikhatsky <yurys@chromium.org> + + Not reviewed. Build fix: revert r51421. + + * public/WebDevToolsAgent.h: + * public/WebView.h: + * src/WebViewImpl.cpp: + * src/WebViewImpl.h: + +2009-11-25 Dimitri Glazkov <dglazkov@chromium.org> + + Reviewed by David Levin. + + [Chromium] Implement canSetValueAttribute in the API. + https://bugs.webkit.org/show_bug.cgi?id=31894 + + * public/WebAccessibilityObject.h: Added decl. + * src/WebAccessibilityCacheImpl.h: Cleaned up mis-include. + * src/WebAccessibilityObject.cpp: + (WebKit::WebAccessibilityObject::canSetValueAttribute): Added impl. + +2009-11-25 Dimitri Glazkov <dglazkov@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] Plumb setNeedsSiteSpecificQuirks throught WebKit API. + https://bugs.webkit.org/show_bug.cgi?id=31878 + + * public/WebSettings.h: Added decl. + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setNeedsSiteSpecificQuirks): Added impl. + * src/WebSettingsImpl.h: + +2009-11-24 Dmitry Titov <dimich@chromium.org> + + Reviewed by Eric Seidel. + + Add ENABLE_SHARED_SCRIPT feature define and flag for build-webkit + https://bugs.webkit.org/show_bug.cgi?id=31444 + + * features.gypi: + +2009-11-24 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Linux Chromium sends too many click events + https://bugs.webkit.org/show_bug.cgi?id=31841 + + Manually count number of clicks for double/triple click events. This + makes us match Firefox on http://www.quirksmode.org/js/events_mouse.html + Chromium side of this patch is here: + http://codereview.chromium.org/431031/show + + * src/gtk/WebInputEventFactory.cpp: + (WebKit::WebInputEventFactory::mouseEvent): + +2009-11-24 Darin Fisher <darin@chromium.org> + + Reviewed by Adam Barth. + + [Chromium] Renderer hang when using www.expedia.com + https://bugs.webkit.org/show_bug.cgi?id=31822 + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchWillSendRequest): + Assign ReturnCacheDataDontLoad cache policy at the last moment + to match Safari. This way the cache policy does not get stored + in DocumentLoader's originalRequest preventing it from being + inherited by subresource requests. + * src/ResourceHandle.cpp: + (WebCore::ResourceHandle::willLoadFromCache): Remove assignment + of ReturnCacheDataDontLoad cache policy so that it doesn't end + up applying to the DocumentLoader's originalRequest. + +2009-11-23 Kenneth Russell <kbr@google.com> + + Reviewed by Oliver Hunt. + + Change get... calls to latest spec + https://bugs.webkit.org/show_bug.cgi?id=30091 + + Removed old versions of get calls on WebGLRenderingContext and + added new ones per spec returning "any". New code simplifies + GraphicsContext3D and fixes previously unimplemented routines. + Added custom JS and V8 bindings. Added exhaustive test case + exercising all new code paths. Updated preexisting test cases for + new APIs. Fixed preexisting bugs in WebKit's and Chrome's WebGL + implementations. + + Ran WebGL layout tests in WebKit (clean) and Chrome (couple of + preexisting known failures) and manual WebGL tests in both + browsers. + + Test: fast/canvas/webgl/gl-object-get-calls.html + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3D::createFramebuffer): + (WebCore::GraphicsContext3D::createRenderbuffer): + (WebCore::GraphicsContext3D::deleteFramebuffer): + (WebCore::GraphicsContext3D::deleteRenderbuffer): + (WebCore::GraphicsContext3D::checkFramebufferStatus): + (WebCore::GraphicsContext3D::getBooleanv): + (WebCore::GraphicsContext3D::getBufferParameteriv): + (WebCore::GraphicsContext3D::getFloatv): + (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv): + (WebCore::GraphicsContext3D::getIntegerv): + (WebCore::GraphicsContext3D::getProgramiv): + (WebCore::GraphicsContext3D::getRenderbufferParameteriv): + (WebCore::GraphicsContext3D::getShaderiv): + (WebCore::GraphicsContext3D::getTexParameterfv): + (WebCore::GraphicsContext3D::getTexParameteriv): + (WebCore::GraphicsContext3D::getUniformfv): + (WebCore::GraphicsContext3D::getUniformiv): + (WebCore::GraphicsContext3D::getVertexAttribfv): + (WebCore::GraphicsContext3D::getVertexAttribiv): + (WebCore::GraphicsContext3D::isFramebuffer): + (WebCore::GraphicsContext3D::isRenderbuffer): + +2009-11-24 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Darin Fisher. + + Chromium: Expose method for reporting user stats + to the host. Also includes drive-by default implementation. + + https://bugs.webkit.org/show_bug.cgi?id=31830 + + * public/WebKitClient.h: + +2009-11-24 Adam Barth <abarth@webkit.org> + + Reviewed by Dimitri Glazkov. + + [Chromium] Fix DOM storage layout tests + https://bugs.webkit.org/show_bug.cgi?id=31833 + + The issue is, essentially, that this code assumes that + SecurityOrigin::createString can re-create a SecurityOrigin given + the string produced from SecurityOrigin::toString. This is a bogus + assumption in a number of corner cases (e.g., document.domain, + @sandbox). A recent patch (http://trac.webkit.org/changeset/51294) + make this assumption further invalid in the case of of file:// URLs. + + The correct fix is for this code to use WebSecurityOrigin objects + (and not strings) to represent SecurityOrigin objects. However, the + expert on this code is on vacation, and I don't want to do major + surgery here without his involvement. This patch is a temporary fix + to get these tests passing again. We'll do the right fix once + jorlow gets back from vacation. + + Tests: Covered by a number of existing DOM storage tests. + + * src/WebStorageNamespaceImpl.cpp: + (WebKit::WebStorageNamespaceImpl::createStorageArea): + +2009-11-23 Jian Li <jianli@chromium.org> + + Reviewed by NOBODY (Chromium build fix). + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3D::createShader): + +2009-11-20 Jian Li <jianli@chromium.org> + + Not reviewed. Fix chromium build. + + * public/WebAccessibilityRole.h: + (WebKit::): + * src/AssertMatchingEnums.cpp: + +2009-11-19 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Darin Fisher. + + Make chromium/webkit/glue/FormFieldValues use the WebKit API + + https://bugs.webkit.org/show_bug.cgi?id=31650 + + * public/WebElement.h: + * public/WebFormElement.h: + * public/WebInputElement.h: + (WebKit::WebInputElement::): + * public/WebNode.h: + * src/AssertMatchingEnums.cpp: + * src/DOMUtilitiesPrivate.cpp: + (WebKit::nameOfInputElement): + * src/DOMUtilitiesPrivate.h: + * src/EditorClientImpl.cpp: + (WebKit::EditorClientImpl::autofill): + (WebKit::EditorClientImpl::doAutofill): + * src/WebFormElement.cpp: + (WebKit::WebFormElement::name): + (WebKit::WebFormElement::method): + (WebKit::WebFormElement::getNamedElements): + (WebKit::WebFormElement::getInputElements): + * src/WebInputElement.cpp: + (WebKit::WebInputElement::isEnabledFormControl): + (WebKit::WebInputElement::inputType): + (WebKit::WebInputElement::formControlType): + (WebKit::WebInputElement::value): + (WebKit::WebInputElement::dispatchFormControlChangeEvent): + (WebKit::WebInputElement::setSelectionRange): + (WebKit::WebInputElement::name): + (WebKit::WebInputElement::nameForAutofill): + * src/WebNode.cpp: + (WebKit::WebNode::frame): + +2009-11-18 Michelangelo De Simone <micdesim@gmail.com> + + Reviewed by Darin Adler. + + Fix for <https://bugs.webkit.org/show_bug.cgi?id=27959>. + Support for validationMessage attribute, as per HTML5 specs. + + * src/LocalizedStrings.cpp: + (WebCore::validationMessageValueMissingText): + (WebCore::validationMessageTypeMismatchText): + (WebCore::validationMessagePatternMismatchText): + (WebCore::validationMessageTooLongText): + (WebCore::validationMessageRangeUnderflowText): + (WebCore::validationMessageRangeOverflowText): + (WebCore::validationMessageStepMismatchText): + +2009-11-18 Nate Chapin <japhet@chromium.org> + + Reviewed by Darin Fisher. + + Remove Chromium port's dependency on some dummy pthreads header + files that live in the Chromium repository. + + https://bugs.webkit.org/show_bug.cgi?id=31648 + + * DEPS: Remove reference to chromium svn's webkit/build/ directory. + +2009-11-18 Evan Stade <estade@chromium.org> + + Reviewed by Darin Fisher. + + Menu button shows wrong content in Chromium + https://bugs.webkit.org/show_bug.cgi?id=31448 + + Make context menu button (VK_APPS) show context menu for node that has + keyboard focus. This affects both the content and the positioning. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::sendContextMenuEvent): + +2009-11-17 Darin Fisher <darin@chromium.org> + + Reviewed by Dmitry Titov. + + Minor cleanup in WebKit API + https://bugs.webkit.org/show_bug.cgi?id=31616 + + * public/WebFormElement.h: Add missing WEBKIT_API prefix. + * public/WebNode.h: Add missing WEBKIT_API prefix. + * src/WebFormElement.cpp: + (WebKit::WebFormElement::action): Make action getter const. + * src/WebNode.cpp: + (WebKit::WebNode::frame): Utilize WebFrameImpl::fromFrame. + +2009-11-17 Nicolas Weber <thakis@chromium.org> + + Reviewed by Darin Fisher, Dmitry Titov. + + Revert r50887, it regressed handling of cmd-left when a text box is focused. + https://bugs.webkit.org/show_bug.cgi?id=31566 + + * src/mac/WebInputEventFactory.mm: + (WebKit::WebInputEventFactory::keyboardEvent): + +2009-11-16 Kenneth Russell <kbr@google.com> + + Reviewed by Oliver Hunt. + + Update API of WebGLArray and friends + https://bugs.webkit.org/show_bug.cgi?id=31175 + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3D::bufferData): + (WebCore::GraphicsContext3D::bufferSubData): + +2009-11-15 Dimitri Glazkov <dglazkov@chromium.org> + + Unreviewed, build fix. + + Correct an error in the previous commit + + * public/WebAccessibilityRole.h: It should be WebAccessibilityRoleDirectory, + not WebAccessibilityDirectoryRole. + +2009-11-15 Dimitri Glazkov <dglazkov@chromium.org> + + Unreviewed, build fix. + + Bring WebAccessibilityRole up to sync after + http://trac.webkit.org/changeset/51007. + + * public/WebAccessibilityRole.h: Added WebAccessibilityRoleDirectory. + * src/AssertMatchingEnums.cpp: Added a match between DirectoryRole and + WebAccessibilityRoleDirectory. + +2009-11-13 Dimitri Glazkov <dglazkov@chromium.org> + + Unreviewed, build fix. + + [Chromium] Rename windowObjectCleared to dispatchDidClearWindowObjectInWorld + to catch up http://trac.webkit.org/changeset/50973. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchDidClearWindowObjectInWorld): + * src/FrameLoaderClientImpl.h: + +2009-11-13 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Chromium WebKit Port to compile as dynamic lib + + https://bugs.webkit.org/show_bug.cgi?id=31478 + + * WebKit.gyp: + +2009-11-13 Aaron Boodman <aa@chromium.org> + + Reviewed by Eric Seidel. + + Adds a way to get the document element's scrollHeight, + which is sort of the moral equivalent to + RenderBox::minPrefWidth(). + + https://bugs.webkit.org/show_bug.cgi?id=31036 + + * public/WebFrame.h: Declare documentElementScrollHeight() + * src/WebFrameImpl.h: Ditto + * src/WebFrameImpl.cpp: Implement documentElementScrollHeight() + (WebKit::WebFrameImpl::documentElementScrollHeight): Return the + scroll height of the document element, or zero if there's no + documentElement. + +2009-11-12 Dumitru Daniliuc <dumi@chromium.org> + + Reviewed by Dimitri Glazkov. + + Adding Chromium's DatabaseTracker implementation. + + https://bugs.webkit.org/show_bug.cgi?id=31440 + + * WebKit.gyp: + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::exceededDatabaseQuota): + * src/DatabaseObserver.cpp: Added. + (WebCore::DatabaseObserver::databaseOpened): + (WebCore::DatabaseObserver::databaseModified): + (WebCore::DatabaseObserver::databaseClosed): + * src/WebDatabase.cpp: + (WebKit::WebDatabase::name): + (WebKit::WebDatabase::displayName): + (WebKit::WebDatabase::estimatedSize): + (WebKit::WebDatabase::securityOrigin): + (WebKit::WebDatabase::updateDatabaseSize): + * src/WebSecurityOrigin.cpp: + (WebKit::WebSecurityOrigin::toString): + (WebKit::WebSecurityOrigin::databaseIdentifier): + +2009-11-13 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Rolling Chromium dependencies to match Chromium revision 31834. + + https://bugs.webkit.org/show_bug.cgi?id=31445 + + * DEPS: + +2009-11-12 Dumitru Daniliuc <dumi@chromium.org> + + Reviewed by Dimitri Glazkov. + + Renaming some parameters passed to DB-related methods to better + indicate their purpose. + + https://bugs.webkit.org/show_bug.cgi?id=31449 + + * public/WebKitClient.h: + * src/ChromiumBridge.cpp: + (WebCore::ChromiumBridge::databaseOpenFile): + (WebCore::ChromiumBridge::databaseDeleteFile): + (WebCore::ChromiumBridge::databaseGetFileAttributes): + (WebCore::ChromiumBridge::databaseGetFileSize): + +2009-11-12 Adam Barth <abarth> + + Reviewed by Dimitri Glazkov. + + [Chromium] reload-subframe-object.html fails + https://bugs.webkit.org/show_bug.cgi?id=31398 + + More closely match FrameLoaderClient.mm. Turns out we don't want to + use MIMETypeRegistry::getMIMETypeForPath because we can't distinguish + between application/octet-stream and lack of knowledge of the MIME + type. + + Covered by reload-subframe-object.html. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::objectContentType): + +2009-11-12 Nate Chapin <japhet@chromium.org> + + Unreviewed, Chromium build fix. + + Add new accessibility enum values to Chromium enums from + http://trac.webkit.org/changeset/50865 and + http://trac.webkit.org/changeset/50883. + + https://bugs.webkit.org/show_bug.cgi?id=31424 + + * public/WebAccessibilityRole.h: + (WebKit::): + * src/AssertMatchingEnums.cpp: + +2009-11-12 Nicolas Weber <thakis@chromium.org> + + Reviewed by Dimitri Glazkov. + + Send |keypress()| events for keys with cmd down, like safari. + Test: Hit cmd-shift-a on unixpapa.com/js/testkey.html , should show a + keypress() event. + + * src/mac/WebInputEventFactory.mm: + (WebKit::WebInputEventFactory::keyboardEvent): + +2009-11-11 Jeremy Orlow <jorlow@chromium.org> + + Not reviewed. Build fix. Will be cleaned up in subsequent patch once we know exaclty what's going on. + + * src/WebBindings.cpp: + +2009-11-11 Drew Wilson <atwilson@chromium.org> + + Reviewed by Dimitri Glazkov. + + SharedWorkerRepository.connect() does not call WebSharedWorkerRepository + https://bugs.webkit.org/show_bug.cgi?id=31371 + + Test: Unit tests can be enabled downstream when this lands. + + * src/SharedWorkerRepository.cpp: + (WebCore::SharedWorkerRepository::connect): + Added missing call to WebSharedWorkerRepository.addSharedWorker(). + +2009-11-11 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Tiny path fixes in Chromium API includes. + + https://bugs.webkit.org/show_bug.cgi?id=31369 + + * public/linux/WebSandboxSupport.h: Fixed path. + * src/WebBindings.cpp: Fixed path. + +2009-11-11 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + http://trac.webkit.org/changeset/50811 removed some methods from + platform/network/SocketStreamHandleClient.h, so remove them + here too. + + https://bugs.webkit.org/show_bug.cgi?id=31360 + + * public/WebSocketStreamHandleClient.h: + * src/SocketStreamHandle.cpp: + (WebCore::SocketStreamHandleInternal::send): + +2009-11-11 Nate Chapin <japhet@chromium.org> + + Reviewed by Eric Seidel. + + Remove some additional references to dragSourceMovedTo() not + needed after http://trac.webkit.org/changeset/50786. + + https://bugs.webkit.org/show_bug.cgi?id=31354 + + * public/WebView.h: + * src/WebViewImpl.h: + +2009-11-11 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Remove WebViewImpl::dragSourceMovedTo(), as it is no longer + needed after http://trac.webkit.org/changeset/50786. + + https://bugs.webkit.org/show_bug.cgi?id=31354 + + * src/WebViewImpl.cpp: + +2009-11-10 Nate Chapin <japhet@chromium.org> + + Unreviewed, Chromium build fix for http://trac.webkit.org/changeset/50760. + + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::paint): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Modified WebKit.gyp to build the webkit api. + + https://bugs.webkit.org/show_bug.cgi?id=31320 + + * README: Added. + * WebKit.gyp: Added. + * webkit.gyp: Removed. + +2009-11-10 Nate Chapin <japhet@chromium.org> + + Reviewed by Eric Seidel. + + Update references to Canvas 3D classes to use the WebGL prefix + introduced in http://trac.webkit.org/changeset/50725. + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3DInternal::beginPaint): + (WebCore::GraphicsContext3DInternal::bindBuffer): + (WebCore::GraphicsContext3DInternal::bindTexture): + (WebCore::GraphicsContext3D::beginPaint): + (WebCore::GraphicsContext3D::bindAttribLocation): + (WebCore::GraphicsContext3D::bindBuffer): + (WebCore::GraphicsContext3D::bindTexture): + (WebCore::GraphicsContext3D::bufferData): + (WebCore::GraphicsContext3D::bufferSubData): + (WebCore::GraphicsContext3D::detachShader): + (WebCore::GraphicsContext3D::getActiveAttrib): + (WebCore::GraphicsContext3D::getActiveUniform): + (WebCore::GraphicsContext3D::getAttribLocation): + (WebCore::GraphicsContext3D::getBooleanv): + (WebCore::GraphicsContext3D::getBufferParameteriv): + (WebCore::GraphicsContext3D::getFloatv): + (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv): + (WebCore::GraphicsContext3D::getIntegerv): + (WebCore::GraphicsContext3D::getProgrami): + (WebCore::GraphicsContext3D::getProgramiv): + (WebCore::GraphicsContext3D::getProgramInfoLog): + (WebCore::GraphicsContext3D::getRenderbufferParameteriv): + (WebCore::GraphicsContext3D::getShaderi): + (WebCore::GraphicsContext3D::getShaderiv): + (WebCore::GraphicsContext3D::getShaderInfoLog): + (WebCore::GraphicsContext3D::getShaderSource): + (WebCore::GraphicsContext3D::getTexParameterfv): + (WebCore::GraphicsContext3D::getTexParameteriv): + (WebCore::GraphicsContext3D::getUniformf): + (WebCore::GraphicsContext3D::getUniformfv): + (WebCore::GraphicsContext3D::getUniformi): + (WebCore::GraphicsContext3D::getUniformiv): + (WebCore::GraphicsContext3D::getUniformLocation): + (WebCore::GraphicsContext3D::getVertexAttribfv): + (WebCore::GraphicsContext3D::getVertexAttribiv): + (WebCore::GraphicsContext3D::isBuffer): + (WebCore::GraphicsContext3D::isFramebuffer): + (WebCore::GraphicsContext3D::isProgram): + (WebCore::GraphicsContext3D::isRenderbuffer): + (WebCore::GraphicsContext3D::isShader): + (WebCore::GraphicsContext3D::isTexture): + (WebCore::GraphicsContext3D::readPixels): + (WebCore::GraphicsContext3D::shaderSource): + (WebCore::GraphicsContext3D::texImage2D): + (WebCore::GraphicsContext3D::texSubImage2D): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebWorker and friends. + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebWorkerBase.cpp: Added. + (WebKit::WorkerWebFrameClient::didCreateDataSource): + (WebKit::WorkerWebFrameClient::sharedInstance): + (WebKit::WorkerWebFrameClient::WorkerWebFrameClient): + (WebKit::initializeWebKitStaticValues): + (WebKit::WebWorkerBase::WebWorkerBase): + (WebKit::WebWorkerBase::~WebWorkerBase): + (WebKit::WebWorkerBase::stopWorkerThread): + (WebKit::WebWorkerBase::initializeLoader): + (WebKit::WebWorkerBase::dispatchTaskToMainThread): + (WebKit::WebWorkerBase::invokeTaskMethod): + (WebKit::WebWorkerBase::postMessageToWorkerObject): + (WebKit::WebWorkerBase::postMessageTask): + (WebKit::WebWorkerBase::postExceptionToWorkerObject): + (WebKit::WebWorkerBase::postExceptionTask): + (WebKit::WebWorkerBase::postConsoleMessageToWorkerObject): + (WebKit::WebWorkerBase::postConsoleMessageTask): + (WebKit::WebWorkerBase::confirmMessageFromWorkerObject): + (WebKit::WebWorkerBase::confirmMessageTask): + (WebKit::WebWorkerBase::reportPendingActivity): + (WebKit::WebWorkerBase::reportPendingActivityTask): + (WebKit::WebWorkerBase::workerContextClosed): + (WebKit::WebWorkerBase::workerContextClosedTask): + (WebKit::WebWorkerBase::workerContextDestroyed): + (WebKit::WebWorkerBase::workerContextDestroyedTask): + (WebKit::WebWorkerBase::postTaskToLoader): + (WebKit::WebWorkerBase::postTaskForModeToWorkerContext): + * src/WebWorkerBase.h: Added. + (WebKit::WebWorkerBase::setWorkerThread): + (WebKit::WebWorkerBase::workerThread): + * src/WebWorkerClientImpl.cpp: Added. + (WebKit::WebWorkerClientImpl::createWorkerContextProxy): + (WebKit::WebWorkerClientImpl::WebWorkerClientImpl): + (WebKit::WebWorkerClientImpl::~WebWorkerClientImpl): + (WebKit::WebWorkerClientImpl::setWebWorker): + (WebKit::WebWorkerClientImpl::startWorkerContext): + (WebKit::WebWorkerClientImpl::terminateWorkerContext): + (WebKit::WebWorkerClientImpl::postMessageToWorkerContext): + (WebKit::WebWorkerClientImpl::hasPendingActivity): + (WebKit::WebWorkerClientImpl::workerObjectDestroyed): + (WebKit::WebWorkerClientImpl::postMessageToWorkerObject): + (WebKit::WebWorkerClientImpl::postExceptionToWorkerObject): + (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObject): + (WebKit::WebWorkerClientImpl::confirmMessageFromWorkerObject): + (WebKit::WebWorkerClientImpl::reportPendingActivity): + (WebKit::WebWorkerClientImpl::workerContextDestroyed): + (WebKit::WebWorkerClientImpl::workerContextClosed): + (WebKit::WebWorkerClientImpl::startWorkerContextTask): + (WebKit::WebWorkerClientImpl::terminateWorkerContextTask): + (WebKit::WebWorkerClientImpl::postMessageToWorkerContextTask): + (WebKit::WebWorkerClientImpl::workerObjectDestroyedTask): + (WebKit::WebWorkerClientImpl::postMessageToWorkerObjectTask): + (WebKit::WebWorkerClientImpl::postExceptionToWorkerObjectTask): + (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask): + (WebKit::WebWorkerClientImpl::confirmMessageFromWorkerObjectTask): + (WebKit::WebWorkerClientImpl::reportPendingActivityTask): + * src/WebWorkerClientImpl.h: Added. + (WebKit::WebWorkerClientImpl::createWorker): + (WebKit::WebWorkerClientImpl::notificationPresenter): + * src/WebWorkerImpl.cpp: Added. + (WebKit::WebWorker::create): + (WebKit::WebWorkerImpl::WebWorkerImpl): + (WebKit::WebWorkerImpl::~WebWorkerImpl): + (WebKit::WebWorkerImpl::commonClient): + (WebKit::WebWorkerImpl::postMessageToWorkerContextTask): + (WebKit::WebWorkerImpl::startWorkerContext): + (WebKit::WebWorkerImpl::terminateWorkerContext): + (WebKit::WebWorkerImpl::postMessageToWorkerContext): + (WebKit::WebWorkerImpl::workerObjectDestroyed): + (WebKit::WebWorkerImpl::clientDestroyed): + * src/WebWorkerImpl.h: Added. + (WebKit::WebWorkerImpl::client): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: Platform specific files. + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/gtk/WebFontInfo.cpp: Added. + (WebKit::WebFontInfo::familyForChars): + * src/gtk/WebInputEventFactory.cpp: Added. + (WebKit::gdkEventTimeToWebEventTime): + (WebKit::gdkStateToWebEventModifiers): + (WebKit::gdkEventToWindowsKeyCode): + (WebKit::getControlCharacter): + (WebKit::WebInputEventFactory::keyboardEvent): + (WebKit::WebInputEventFactory::mouseEvent): + (WebKit::WebInputEventFactory::mouseWheelEvent): + * src/gtk/WebScreenInfoFactory.cpp: Added. + (WebKit::WebScreenInfoFactory::screenInfo): + * src/linux/WebFontRendering.cpp: Added. + (WebKit::WebFontRendering::setHinting): + (WebKit::WebFontRendering::setAntiAlias): + (WebKit::WebFontRendering::setSubpixelGlyphs): + (WebKit::WebFontRendering::setLCDOrder): + (WebKit::WebFontRendering::setLCDOrientation): + * src/mac/WebInputEventFactory.mm: Added. + (WebKit::isKeyUpEvent): + (WebKit::isKeypadEvent): + (WebKit::windowsKeyCodeForKeyEvent): + (WebKit::textFromEvent): + (WebKit::unmodifiedTextFromEvent): + (WebKit::keyIdentifierForKeyEvent): + (WebKit::modifiersFromEvent): + (WebKit::WebInputEventFactory::keyboardEvent): + (WebKit::WebInputEventFactory::mouseEvent): + (WebKit::WebInputEventFactory::mouseWheelEvent): + * src/mac/WebScreenInfoFactory.mm: Added. + (WebKit::screenForWindow): + (WebKit::toUserSpace): + (WebKit::WebScreenInfoFactory::screenInfo): + * src/win/WebInputEventFactory.cpp: Added. + (WebKit::isKeyPad): + (WebKit::WebInputEventFactory::keyboardEvent): + (WebKit::GetRelativeCursorPos): + (WebKit::WebInputEventFactory::resetLastClickState): + (WebKit::WebInputEventFactory::mouseEvent): + (WebKit::WebInputEventFactory::mouseWheelEvent): + * src/win/WebScreenInfoFactory.cpp: Added. + (WebKit::toWebRect): + (WebKit::WebScreenInfoFactory::screenInfo): + * src/x11/WebScreenInfoFactory.cpp: Added. + (WebKit::WebScreenInfoFactory::screenInfo): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Eric Seidel. + + Up-streaming Chromium API src files: WrapperResourceRequest and Response + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WrappedResourceRequest.h: Added. + (WebKit::WrappedResourceRequest::~WrappedResourceRequest): + (WebKit::WrappedResourceRequest::WrappedResourceRequest): + (WebKit::WrappedResourceRequest::bind): + (WebKit::WrappedResourceRequest::Handle::dispose): + * src/WrappedResourceResponse.h: Added. + (WebKit::WrappedResourceResponse::~WrappedResourceResponse): + (WebKit::WrappedResourceResponse::WrappedResourceResponse): + (WebKit::WrappedResourceResponse::bind): + (WebKit::WrappedResourceResponse::Handle::dispose): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: StorageStreamHandlers...StorageNamespaceProxy + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/SocketStreamHandle.cpp: Added. + (WebCore::SocketStreamHandleInternal::create): + (WebCore::SocketStreamHandleInternal::SocketStreamHandleInternal): + (WebCore::SocketStreamHandleInternal::~SocketStreamHandleInternal): + (WebCore::SocketStreamHandleInternal::connect): + (WebCore::SocketStreamHandleInternal::send): + (WebCore::SocketStreamHandleInternal::close): + (WebCore::SocketStreamHandleInternal::willOpenStream): + (WebCore::SocketStreamHandleInternal::didOpenStream): + (WebCore::SocketStreamHandleInternal::didSendData): + (WebCore::SocketStreamHandleInternal::didReceiveData): + (WebCore::SocketStreamHandleInternal::didClose): + (WebCore::SocketStreamHandleInternal::didFail): + (WebCore::SocketStreamHandle::SocketStreamHandle): + (WebCore::SocketStreamHandle::~SocketStreamHandle): + (WebCore::SocketStreamHandle::platformSend): + (WebCore::SocketStreamHandle::platformClose): + (WebCore::SocketStreamHandle::didReceiveAuthenticationChallenge): + (WebCore::SocketStreamHandle::receivedCredential): + (WebCore::SocketStreamHandle::receivedRequestToContinueWithoutCredential): + (WebCore::SocketStreamHandle::receivedCancellation): + * src/StorageAreaProxy.cpp: Added. + (WebCore::StorageAreaProxy::StorageAreaProxy): + (WebCore::StorageAreaProxy::~StorageAreaProxy): + (WebCore::StorageAreaProxy::length): + (WebCore::StorageAreaProxy::key): + (WebCore::StorageAreaProxy::getItem): + (WebCore::StorageAreaProxy::setItem): + (WebCore::StorageAreaProxy::removeItem): + (WebCore::StorageAreaProxy::clear): + (WebCore::StorageAreaProxy::contains): + * src/StorageAreaProxy.h: Added. + * src/StorageEventDispatcherChromium.cpp: Added. + (WebCore::StorageEventDispatcher::dispatch): + * src/StorageEventDispatcherImpl.cpp: Added. + (WebCore::StorageEventDispatcherImpl::StorageEventDispatcherImpl): + (WebCore::StorageEventDispatcherImpl::dispatchStorageEvent): + * src/StorageEventDispatcherImpl.h: Added. + * src/StorageNamespaceProxy.cpp: Added. + (WebCore::StorageNamespace::localStorageNamespace): + (WebCore::StorageNamespace::sessionStorageNamespace): + (WebCore::StorageNamespaceProxy::StorageNamespaceProxy): + (WebCore::StorageNamespaceProxy::~StorageNamespaceProxy): + (WebCore::StorageNamespaceProxy::copy): + (WebCore::StorageNamespaceProxy::storageArea): + (WebCore::StorageNamespaceProxy::close): + (WebCore::StorageNamespaceProxy::unlock): + * src/StorageNamespaceProxy.h: Added. + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: NotificationPresenterImpl...SharedWorkerRepository + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/NotificationPresenterImpl.cpp: Added. + (WebKit::VoidCallbackClient::VoidCallbackClient): + (WebKit::VoidCallbackClient::permissionRequestComplete): + (WebKit::NotificationPresenterImpl::initialize): + (WebKit::NotificationPresenterImpl::isInitialized): + (WebKit::NotificationPresenterImpl::show): + (WebKit::NotificationPresenterImpl::cancel): + (WebKit::NotificationPresenterImpl::notificationObjectDestroyed): + (WebKit::NotificationPresenterImpl::checkPermission): + (WebKit::NotificationPresenterImpl::requestPermission): + * src/NotificationPresenterImpl.h: Added. + (WebKit::NotificationPresenterImpl::NotificationPresenterImpl): + * src/PlatformMessagePortChannel.cpp: Added. + (WebCore::MessagePortChannel::create): + (WebCore::MessagePortChannel::createChannel): + (WebCore::MessagePortChannel::MessagePortChannel): + (WebCore::MessagePortChannel::~MessagePortChannel): + (WebCore::MessagePortChannel::entangleIfOpen): + (WebCore::MessagePortChannel::disentangle): + (WebCore::MessagePortChannel::postMessageToRemote): + (WebCore::MessagePortChannel::tryGetMessageFromRemote): + (WebCore::MessagePortChannel::close): + (WebCore::MessagePortChannel::isConnectedTo): + (WebCore::MessagePortChannel::hasPendingActivity): + (WebCore::MessagePortChannel::locallyEntangledPort): + (WebCore::PlatformMessagePortChannel::create): + (WebCore::PlatformMessagePortChannel::PlatformMessagePortChannel): + (WebCore::PlatformMessagePortChannel::~PlatformMessagePortChannel): + (WebCore::PlatformMessagePortChannel::createChannel): + (WebCore::PlatformMessagePortChannel::messageAvailable): + (WebCore::PlatformMessagePortChannel::entangleIfOpen): + (WebCore::PlatformMessagePortChannel::disentangle): + (WebCore::PlatformMessagePortChannel::postMessageToRemote): + (WebCore::PlatformMessagePortChannel::tryGetMessageFromRemote): + (WebCore::PlatformMessagePortChannel::close): + (WebCore::PlatformMessagePortChannel::isConnectedTo): + (WebCore::PlatformMessagePortChannel::hasPendingActivity): + (WebCore::PlatformMessagePortChannel::setEntangledChannel): + (WebCore::PlatformMessagePortChannel::webChannelRelease): + * src/PlatformMessagePortChannel.h: Added. + * src/ResourceHandle.cpp: Added. + (WebCore::ResourceHandleInternal::ResourceHandleInternal): + (WebCore::ResourceHandleInternal::start): + (WebCore::ResourceHandleInternal::cancel): + (WebCore::ResourceHandleInternal::setDefersLoading): + (WebCore::ResourceHandleInternal::allowStoredCredentials): + (WebCore::ResourceHandleInternal::willSendRequest): + (WebCore::ResourceHandleInternal::didSendData): + (WebCore::ResourceHandleInternal::didReceiveResponse): + (WebCore::ResourceHandleInternal::didReceiveData): + (WebCore::ResourceHandleInternal::didFinishLoading): + (WebCore::ResourceHandleInternal::didFail): + (WebCore::ResourceHandle::ResourceHandle): + (WebCore::ResourceHandle::create): + (WebCore::ResourceHandle::request): + (WebCore::ResourceHandle::client): + (WebCore::ResourceHandle::setClient): + (WebCore::ResourceHandle::setDefersLoading): + (WebCore::ResourceHandle::start): + (WebCore::ResourceHandle::clearAuthentication): + (WebCore::ResourceHandle::cancel): + (WebCore::ResourceHandle::~ResourceHandle): + (WebCore::ResourceHandle::bufferedData): + (WebCore::ResourceHandle::loadsBlocked): + (WebCore::ResourceHandle::supportsBufferedData): + (WebCore::ResourceHandle::loadResourceSynchronously): + (WebCore::ResourceHandle::willLoadFromCache): + * src/SharedWorkerRepository.cpp: Added. + (WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader): + (WebCore::SharedWorkerScriptLoader::load): + (WebCore::getWebPort): + (WebCore::SharedWorkerScriptLoader::notifyFinished): + (WebCore::SharedWorkerScriptLoader::sendConnect): + (WebCore::SharedWorkerScriptLoader::contextDestroyed): + (WebCore::SharedWorkerScriptLoader::connected): + (WebCore::SharedWorkerRepository::isAvailable): + (WebCore::getId): + (WebCore::SharedWorkerRepository::connect): + (WebCore::SharedWorkerRepository::documentDetached): + (WebCore::SharedWorkerRepository::hasSharedWorkers): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: GraphicContext3D...MediaPlaterPrivateChromium + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/GraphicsContext3D.cpp: Added. + (WebCore::GraphicsContext3DInternal::): + (WebCore::GraphicsContext3DInternal::VertexAttribPointerState::VertexAttribPointerState): + (WebCore::tryLoad): + (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::checkError): + (WebCore::GraphicsContext3DInternal::makeContextCurrent): + (WebCore::GraphicsContext3DInternal::platformGraphicsContext3D): + (WebCore::GraphicsContext3DInternal::platformTexture): + (WebCore::createTextureObject): + (WebCore::GraphicsContext3DInternal::reshape): + (WebCore::GraphicsContext3DInternal::flipVertically): + (WebCore::GraphicsContext3DInternal::beginPaint): + (WebCore::GraphicsContext3DInternal::validateTextureTarget): + (WebCore::GraphicsContext3DInternal::validateTextureParameter): + (WebCore::GraphicsContext3DInternal::activeTexture): + (WebCore::GraphicsContext3DInternal::bindBuffer): + (WebCore::GraphicsContext3DInternal::bindTexture): + (WebCore::GraphicsContext3DInternal::bufferDataImpl): + (WebCore::GraphicsContext3DInternal::disableVertexAttribArray): + (WebCore::GraphicsContext3DInternal::enableVertexAttribArray): + (WebCore::GraphicsContext3DInternal::vertexAttribPointer): + (WebCore::GraphicsContext3DInternal::viewportImpl): + (WebCore::GraphicsContext3D::create): + (WebCore::GraphicsContext3D::GraphicsContext3D): + (WebCore::GraphicsContext3D::~GraphicsContext3D): + (WebCore::GraphicsContext3D::platformGraphicsContext3D): + (WebCore::GraphicsContext3D::platformTexture): + (WebCore::GraphicsContext3D::checkError): + (WebCore::GraphicsContext3D::makeContextCurrent): + (WebCore::GraphicsContext3D::reshape): + (WebCore::GraphicsContext3D::beginPaint): + (WebCore::GraphicsContext3D::endPaint): + (WebCore::GraphicsContext3D::sizeInBytes): + (WebCore::GraphicsContext3D::createBuffer): + (WebCore::GraphicsContext3D::createFramebuffer): + (WebCore::GraphicsContext3D::createProgram): + (WebCore::GraphicsContext3D::createRenderbuffer): + (WebCore::GraphicsContext3D::createShader): + (WebCore::GraphicsContext3D::createTexture): + (WebCore::GraphicsContext3D::deleteBuffer): + (WebCore::GraphicsContext3D::deleteFramebuffer): + (WebCore::GraphicsContext3D::deleteProgram): + (WebCore::GraphicsContext3D::deleteRenderbuffer): + (WebCore::GraphicsContext3D::deleteShader): + (WebCore::GraphicsContext3D::deleteTexture): + (WebCore::GraphicsContext3D::activeTexture): + (WebCore::GraphicsContext3D::bindAttribLocation): + (WebCore::GraphicsContext3D::bindBuffer): + (WebCore::GraphicsContext3D::bindTexture): + (WebCore::GraphicsContext3D::bufferData): + (WebCore::GraphicsContext3D::bufferSubData): + (WebCore::GraphicsContext3D::checkFramebufferStatus): + (WebCore::GraphicsContext3D::detachShader): + (WebCore::GraphicsContext3D::disableVertexAttribArray): + (WebCore::GraphicsContext3D::drawArrays): + (WebCore::GraphicsContext3D::drawElements): + (WebCore::GraphicsContext3D::enableVertexAttribArray): + (WebCore::GraphicsContext3D::generateMipmap): + (WebCore::GraphicsContext3D::getActiveAttrib): + (WebCore::GraphicsContext3D::getActiveUniform): + (WebCore::GraphicsContext3D::getAttribLocation): + (WebCore::GraphicsContext3D::getBoolean): + (WebCore::GraphicsContext3D::getBooleanv): + (WebCore::GraphicsContext3D::getBufferParameteri): + (WebCore::GraphicsContext3D::getBufferParameteriv): + (WebCore::GraphicsContext3D::getError): + (WebCore::GraphicsContext3D::getFloat): + (WebCore::GraphicsContext3D::getFloatv): + (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteri): + (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv): + (WebCore::GraphicsContext3D::getInteger): + (WebCore::GraphicsContext3D::getIntegerv): + (WebCore::GraphicsContext3D::getProgrami): + (WebCore::GraphicsContext3D::getProgramiv): + (WebCore::GraphicsContext3D::getProgramInfoLog): + (WebCore::GraphicsContext3D::getRenderbufferParameteri): + (WebCore::GraphicsContext3D::getRenderbufferParameteriv): + (WebCore::GraphicsContext3D::getShaderi): + (WebCore::GraphicsContext3D::getShaderiv): + (WebCore::GraphicsContext3D::getShaderInfoLog): + (WebCore::GraphicsContext3D::getShaderSource): + (WebCore::GraphicsContext3D::getString): + (WebCore::GraphicsContext3D::getTexParameterf): + (WebCore::GraphicsContext3D::getTexParameterfv): + (WebCore::GraphicsContext3D::getTexParameteri): + (WebCore::GraphicsContext3D::getTexParameteriv): + (WebCore::GraphicsContext3D::getUniformf): + (WebCore::GraphicsContext3D::getUniformfv): + (WebCore::GraphicsContext3D::getUniformi): + (WebCore::GraphicsContext3D::getUniformiv): + (WebCore::GraphicsContext3D::getUniformLocation): + (WebCore::GraphicsContext3D::getVertexAttribf): + (WebCore::GraphicsContext3D::getVertexAttribfv): + (WebCore::GraphicsContext3D::getVertexAttribi): + (WebCore::GraphicsContext3D::getVertexAttribiv): + (WebCore::GraphicsContext3D::getVertexAttribOffset): + (WebCore::GraphicsContext3D::isBuffer): + (WebCore::GraphicsContext3D::isEnabled): + (WebCore::GraphicsContext3D::isFramebuffer): + (WebCore::GraphicsContext3D::isProgram): + (WebCore::GraphicsContext3D::isRenderbuffer): + (WebCore::GraphicsContext3D::isShader): + (WebCore::GraphicsContext3D::isTexture): + (WebCore::GraphicsContext3D::pixelStorei): + (WebCore::GraphicsContext3D::readPixels): + (WebCore::GraphicsContext3D::releaseShaderCompiler): + (WebCore::GraphicsContext3D::shaderSource): + (WebCore::GraphicsContext3D::texImage2D): + (WebCore::unmultiplyAlpha): + (WebCore::texImage2DHelper): + (WebCore::GraphicsContext3D::texSubImage2D): + (WebCore::GraphicsContext3D::uniform1fv): + (WebCore::GraphicsContext3D::uniform1iv): + (WebCore::GraphicsContext3D::uniform2fv): + (WebCore::GraphicsContext3D::uniform2iv): + (WebCore::GraphicsContext3D::uniform3fv): + (WebCore::GraphicsContext3D::uniform3iv): + (WebCore::GraphicsContext3D::uniform4fv): + (WebCore::GraphicsContext3D::uniform4iv): + (WebCore::GraphicsContext3D::uniformMatrix2fv): + (WebCore::GraphicsContext3D::uniformMatrix3fv): + (WebCore::GraphicsContext3D::uniformMatrix4fv): + (WebCore::GraphicsContext3D::vertexAttrib1fv): + (WebCore::GraphicsContext3D::vertexAttrib2fv): + (WebCore::GraphicsContext3D::vertexAttrib3fv): + (WebCore::GraphicsContext3D::vertexAttrib4fv): + (WebCore::GraphicsContext3D::vertexAttribPointer): + (WebCore::GraphicsContext3D::viewport): + * src/InspectorClientImpl.cpp: Added. + (WebKit::InspectorClientImpl::InspectorClientImpl): + (WebKit::InspectorClientImpl::~InspectorClientImpl): + (WebKit::InspectorClientImpl::inspectorDestroyed): + (WebKit::InspectorClientImpl::createPage): + (WebKit::InspectorClientImpl::showWindow): + (WebKit::InspectorClientImpl::closeWindow): + (WebKit::InspectorClientImpl::windowVisible): + (WebKit::InspectorClientImpl::attachWindow): + (WebKit::InspectorClientImpl::detachWindow): + (WebKit::InspectorClientImpl::setAttachedWindowHeight): + (WebKit::invalidateNodeBoundingRect): + (WebKit::InspectorClientImpl::highlight): + (WebKit::InspectorClientImpl::hideHighlight): + (WebKit::InspectorClientImpl::inspectedURLChanged): + (WebKit::InspectorClientImpl::localizedStringsURL): + (WebKit::InspectorClientImpl::hiddenPanels): + (WebKit::InspectorClientImpl::populateSetting): + (WebKit::InspectorClientImpl::storeSetting): + (WebKit::InspectorClientImpl::removeSetting): + (WebKit::InspectorClientImpl::inspectorWindowObjectCleared): + (WebKit::InspectorClientImpl::loadSettings): + (WebKit::InspectorClientImpl::saveSettings): + * src/InspectorClientImpl.h: Added. + * src/LocalizedStrings.cpp: Added. + (WebCore::query): + (WebCore::searchableIndexIntroduction): + (WebCore::submitButtonDefaultLabel): + (WebCore::inputElementAltText): + (WebCore::resetButtonDefaultLabel): + (WebCore::fileButtonChooseFileLabel): + (WebCore::fileButtonNoFileSelectedLabel): + (WebCore::searchMenuNoRecentSearchesText): + (WebCore::searchMenuRecentSearchesText): + (WebCore::searchMenuClearRecentSearchesText): + (WebCore::AXWebAreaText): + (WebCore::AXLinkText): + (WebCore::AXListMarkerText): + (WebCore::AXImageMapText): + (WebCore::AXHeadingText): + (WebCore::AXDefinitionListTermText): + (WebCore::AXDefinitionListDefinitionText): + (WebCore::AXButtonActionVerb): + (WebCore::AXRadioButtonActionVerb): + (WebCore::AXTextFieldActionVerb): + (WebCore::AXCheckedCheckBoxActionVerb): + (WebCore::AXUncheckedCheckBoxActionVerb): + (WebCore::AXLinkActionVerb): + (WebCore::multipleFileUploadText): + (WebCore::unknownFileSizeText): + (WebCore::keygenMenuHighGradeKeySize): + (WebCore::keygenMenuMediumGradeKeySize): + (WebCore::imageTitle): + (WebCore::contextMenuItemTagOpenLinkInNewWindow): + (WebCore::contextMenuItemTagDownloadLinkToDisk): + (WebCore::contextMenuItemTagCopyLinkToClipboard): + (WebCore::contextMenuItemTagOpenImageInNewWindow): + (WebCore::contextMenuItemTagDownloadImageToDisk): + (WebCore::contextMenuItemTagCopyImageToClipboard): + (WebCore::contextMenuItemTagOpenFrameInNewWindow): + (WebCore::contextMenuItemTagCopy): + (WebCore::contextMenuItemTagGoBack): + (WebCore::contextMenuItemTagGoForward): + (WebCore::contextMenuItemTagStop): + (WebCore::contextMenuItemTagReload): + (WebCore::contextMenuItemTagCut): + (WebCore::contextMenuItemTagPaste): + (WebCore::contextMenuItemTagNoGuessesFound): + (WebCore::contextMenuItemTagIgnoreSpelling): + (WebCore::contextMenuItemTagLearnSpelling): + (WebCore::contextMenuItemTagSearchWeb): + (WebCore::contextMenuItemTagLookUpInDictionary): + (WebCore::contextMenuItemTagOpenLink): + (WebCore::contextMenuItemTagIgnoreGrammar): + (WebCore::contextMenuItemTagSpellingMenu): + (WebCore::contextMenuItemTagCheckSpelling): + (WebCore::contextMenuItemTagCheckSpellingWhileTyping): + (WebCore::contextMenuItemTagCheckGrammarWithSpelling): + (WebCore::contextMenuItemTagFontMenu): + (WebCore::contextMenuItemTagBold): + (WebCore::contextMenuItemTagItalic): + (WebCore::contextMenuItemTagUnderline): + (WebCore::contextMenuItemTagOutline): + (WebCore::contextMenuItemTagWritingDirectionMenu): + (WebCore::contextMenuItemTagTextDirectionMenu): + (WebCore::contextMenuItemTagDefaultDirection): + (WebCore::contextMenuItemTagLeftToRight): + (WebCore::contextMenuItemTagRightToLeft): + (WebCore::contextMenuItemTagInspectElement): + (WebCore::contextMenuItemTagShowSpellingPanel): + (WebCore::mediaElementLiveBroadcastStateText): + (WebCore::mediaElementLoadingStateText): + (WebCore::localizedMediaControlElementString): + (WebCore::localizedMediaControlElementHelpText): + (WebCore::localizedMediaTimeDescription): + * src/MediaPlayerPrivateChromium.cpp: Added. + (WebCore::MediaPlayerPrivate::registerMediaEngine): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: DOMUtilities...FrameLoaderClientImpl + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/DOMUtilitiesPrivate.cpp: Added. + (WebCore::toHTMLElement): + (WebKit::toHTMLInputElement): + (WebKit::toHTMLLinkElement): + (WebKit::toHTMLMetaElement): + (WebKit::toHTMLOptionElement): + (WebKit::nameOfInputElement): + * src/DOMUtilitiesPrivate.h: Added. + * src/DragClientImpl.cpp: Added. + (WebKit::DragClientImpl::willPerformDragDestinationAction): + (WebKit::DragClientImpl::willPerformDragSourceAction): + (WebKit::DragClientImpl::actionMaskForDrag): + (WebKit::DragClientImpl::dragSourceActionMaskForPoint): + (WebKit::DragClientImpl::startDrag): + (WebKit::DragClientImpl::createDragImageForLink): + (WebKit::DragClientImpl::dragControllerDestroyed): + * src/DragClientImpl.h: Added. + (WebKit::DragClientImpl::DragClientImpl): + * src/EditorClientImpl.cpp: Added. + (WebKit::EditorClientImpl::EditorClientImpl): + (WebKit::EditorClientImpl::~EditorClientImpl): + (WebKit::EditorClientImpl::pageDestroyed): + (WebKit::EditorClientImpl::shouldShowDeleteInterface): + (WebKit::EditorClientImpl::smartInsertDeleteEnabled): + (WebKit::EditorClientImpl::isSelectTrailingWhitespaceEnabled): + (WebKit::EditorClientImpl::shouldSpellcheckByDefault): + (WebKit::EditorClientImpl::isContinuousSpellCheckingEnabled): + (WebKit::EditorClientImpl::toggleContinuousSpellChecking): + (WebKit::EditorClientImpl::isGrammarCheckingEnabled): + (WebKit::EditorClientImpl::toggleGrammarChecking): + (WebKit::EditorClientImpl::spellCheckerDocumentTag): + (WebKit::EditorClientImpl::isEditable): + (WebKit::EditorClientImpl::shouldBeginEditing): + (WebKit::EditorClientImpl::shouldEndEditing): + (WebKit::EditorClientImpl::shouldInsertNode): + (WebKit::EditorClientImpl::shouldInsertText): + (WebKit::EditorClientImpl::shouldDeleteRange): + (WebKit::EditorClientImpl::shouldChangeSelectedRange): + (WebKit::EditorClientImpl::shouldApplyStyle): + (WebKit::EditorClientImpl::shouldMoveRangeAfterDelete): + (WebKit::EditorClientImpl::didBeginEditing): + (WebKit::EditorClientImpl::respondToChangedSelection): + (WebKit::EditorClientImpl::respondToChangedContents): + (WebKit::EditorClientImpl::didEndEditing): + (WebKit::EditorClientImpl::didWriteSelectionToPasteboard): + (WebKit::EditorClientImpl::didSetSelectionTypesForPasteboard): + (WebKit::EditorClientImpl::registerCommandForUndo): + (WebKit::EditorClientImpl::registerCommandForRedo): + (WebKit::EditorClientImpl::clearUndoRedoOperations): + (WebKit::EditorClientImpl::canUndo): + (WebKit::EditorClientImpl::canRedo): + (WebKit::EditorClientImpl::undo): + (WebKit::EditorClientImpl::redo): + (WebKit::): + (WebKit::EditorClientImpl::interpretKeyEvent): + (WebKit::EditorClientImpl::handleEditingKeyboardEvent): + (WebKit::EditorClientImpl::handleKeyboardEvent): + (WebKit::EditorClientImpl::handleInputMethodKeydown): + (WebKit::EditorClientImpl::textFieldDidBeginEditing): + (WebKit::EditorClientImpl::textFieldDidEndEditing): + (WebKit::EditorClientImpl::textDidChangeInTextField): + (WebKit::EditorClientImpl::showFormAutofillForNode): + (WebKit::EditorClientImpl::autofill): + (WebKit::EditorClientImpl::doAutofill): + (WebKit::EditorClientImpl::cancelPendingAutofill): + (WebKit::EditorClientImpl::onAutofillSuggestionAccepted): + (WebKit::EditorClientImpl::doTextFieldCommandFromEvent): + (WebKit::EditorClientImpl::textWillBeDeletedInTextField): + (WebKit::EditorClientImpl::textDidChangeInTextArea): + (WebKit::EditorClientImpl::ignoreWordInSpellDocument): + (WebKit::EditorClientImpl::learnWord): + (WebKit::EditorClientImpl::checkSpellingOfString): + (WebKit::EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord): + (WebKit::EditorClientImpl::checkGrammarOfString): + (WebKit::EditorClientImpl::updateSpellingUIWithGrammarString): + (WebKit::EditorClientImpl::updateSpellingUIWithMisspelledWord): + (WebKit::EditorClientImpl::showSpellingUI): + (WebKit::EditorClientImpl::spellingUIIsShowing): + (WebKit::EditorClientImpl::getGuessesForWord): + (WebKit::EditorClientImpl::setInputMethodState): + * src/EditorClientImpl.h: Added. + (WebKit::EditorClientImpl::): + * src/FrameLoaderClientImpl.cpp: Added. + (WebKit::): + (WebKit::FrameLoaderClientImpl::FrameLoaderClientImpl): + (WebKit::FrameLoaderClientImpl::~FrameLoaderClientImpl): + (WebKit::FrameLoaderClientImpl::frameLoaderDestroyed): + (WebKit::FrameLoaderClientImpl::windowObjectCleared): + (WebKit::FrameLoaderClientImpl::documentElementAvailable): + (WebKit::FrameLoaderClientImpl::didCreateScriptContextForFrame): + (WebKit::FrameLoaderClientImpl::didDestroyScriptContextForFrame): + (WebKit::FrameLoaderClientImpl::didCreateIsolatedScriptContext): + (WebKit::FrameLoaderClientImpl::didPerformFirstNavigation): + (WebKit::FrameLoaderClientImpl::registerForIconNotification): + (WebKit::FrameLoaderClientImpl::didChangeScrollOffset): + (WebKit::FrameLoaderClientImpl::allowJavaScript): + (WebKit::FrameLoaderClientImpl::hasWebView): + (WebKit::FrameLoaderClientImpl::hasFrameView): + (WebKit::FrameLoaderClientImpl::makeDocumentView): + (WebKit::FrameLoaderClientImpl::makeRepresentation): + (WebKit::FrameLoaderClientImpl::forceLayout): + (WebKit::FrameLoaderClientImpl::forceLayoutForNonHTML): + (WebKit::FrameLoaderClientImpl::setCopiesOnScroll): + (WebKit::FrameLoaderClientImpl::detachedFromParent2): + (WebKit::FrameLoaderClientImpl::detachedFromParent3): + (WebKit::FrameLoaderClientImpl::assignIdentifierToInitialRequest): + (WebKit::determineTargetTypeFromLoader): + (WebKit::FrameLoaderClientImpl::dispatchWillSendRequest): + (WebKit::FrameLoaderClientImpl::shouldUseCredentialStorage): + (WebKit::FrameLoaderClientImpl::dispatchDidReceiveAuthenticationChallenge): + (WebKit::FrameLoaderClientImpl::dispatchDidCancelAuthenticationChallenge): + (WebKit::FrameLoaderClientImpl::dispatchDidReceiveResponse): + (WebKit::FrameLoaderClientImpl::dispatchDidReceiveContentLength): + (WebKit::FrameLoaderClientImpl::dispatchDidFinishLoading): + (WebKit::FrameLoaderClientImpl::dispatchDidFailLoading): + (WebKit::FrameLoaderClientImpl::dispatchDidFinishDocumentLoad): + (WebKit::FrameLoaderClientImpl::dispatchDidLoadResourceFromMemoryCache): + (WebKit::FrameLoaderClientImpl::dispatchDidLoadResourceByXMLHttpRequest): + (WebKit::FrameLoaderClientImpl::dispatchDidHandleOnloadEvents): + (WebKit::FrameLoaderClientImpl::dispatchDidReceiveServerRedirectForProvisionalLoad): + (WebKit::FrameLoaderClientImpl::dispatchDidCancelClientRedirect): + (WebKit::FrameLoaderClientImpl::dispatchWillPerformClientRedirect): + (WebKit::FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage): + (WebKit::FrameLoaderClientImpl::dispatchWillClose): + (WebKit::FrameLoaderClientImpl::dispatchDidReceiveIcon): + (WebKit::FrameLoaderClientImpl::dispatchDidStartProvisionalLoad): + (WebKit::FrameLoaderClientImpl::dispatchDidReceiveTitle): + (WebKit::FrameLoaderClientImpl::dispatchDidCommitLoad): + (WebKit::FrameLoaderClientImpl::dispatchDidFailProvisionalLoad): + (WebKit::FrameLoaderClientImpl::dispatchDidFailLoad): + (WebKit::FrameLoaderClientImpl::dispatchDidFinishLoad): + (WebKit::FrameLoaderClientImpl::dispatchDidFirstLayout): + (WebKit::FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout): + (WebKit::FrameLoaderClientImpl::dispatchCreatePage): + (WebKit::FrameLoaderClientImpl::dispatchShow): + (WebKit::shouldTreatAsAttachment): + (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForMIMEType): + (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNewWindowAction): + (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction): + (WebKit::FrameLoaderClientImpl::cancelPolicyCheck): + (WebKit::FrameLoaderClientImpl::dispatchUnableToImplementPolicy): + (WebKit::FrameLoaderClientImpl::dispatchWillSubmitForm): + (WebKit::FrameLoaderClientImpl::dispatchDidLoadMainResource): + (WebKit::FrameLoaderClientImpl::revertToProvisionalState): + (WebKit::FrameLoaderClientImpl::setMainDocumentError): + (WebKit::FrameLoaderClientImpl::postProgressStartedNotification): + (WebKit::FrameLoaderClientImpl::postProgressEstimateChangedNotification): + (WebKit::FrameLoaderClientImpl::postProgressFinishedNotification): + (WebKit::FrameLoaderClientImpl::setMainFrameDocumentReady): + (WebKit::FrameLoaderClientImpl::startDownload): + (WebKit::FrameLoaderClientImpl::willChangeTitle): + (WebKit::FrameLoaderClientImpl::didChangeTitle): + (WebKit::FrameLoaderClientImpl::committedLoad): + (WebKit::FrameLoaderClientImpl::finishedLoading): + (WebKit::FrameLoaderClientImpl::updateGlobalHistory): + (WebKit::FrameLoaderClientImpl::updateGlobalHistoryRedirectLinks): + (WebKit::FrameLoaderClientImpl::shouldGoToHistoryItem): + (WebKit::FrameLoaderClientImpl::didDisplayInsecureContent): + (WebKit::FrameLoaderClientImpl::didRunInsecureContent): + (WebKit::FrameLoaderClientImpl::blockedError): + (WebKit::FrameLoaderClientImpl::cancelledError): + (WebKit::FrameLoaderClientImpl::cannotShowURLError): + (WebKit::FrameLoaderClientImpl::interruptForPolicyChangeError): + (WebKit::FrameLoaderClientImpl::cannotShowMIMETypeError): + (WebKit::FrameLoaderClientImpl::fileDoesNotExistError): + (WebKit::FrameLoaderClientImpl::pluginWillHandleLoadError): + (WebKit::FrameLoaderClientImpl::shouldFallBack): + (WebKit::FrameLoaderClientImpl::canHandleRequest): + (WebKit::FrameLoaderClientImpl::canShowMIMEType): + (WebKit::FrameLoaderClientImpl::representationExistsForURLScheme): + (WebKit::FrameLoaderClientImpl::generatedMIMETypeForURLScheme): + (WebKit::FrameLoaderClientImpl::frameLoadCompleted): + (WebKit::FrameLoaderClientImpl::saveViewStateToItem): + (WebKit::FrameLoaderClientImpl::restoreViewState): + (WebKit::FrameLoaderClientImpl::provisionalLoadStarted): + (WebKit::FrameLoaderClientImpl::didFinishLoad): + (WebKit::FrameLoaderClientImpl::prepareForDataSourceReplacement): + (WebKit::FrameLoaderClientImpl::createDocumentLoader): + (WebKit::FrameLoaderClientImpl::setTitle): + (WebKit::FrameLoaderClientImpl::userAgent): + (WebKit::FrameLoaderClientImpl::savePlatformDataToCachedFrame): + (WebKit::FrameLoaderClientImpl::transitionToCommittedFromCachedFrame): + (WebKit::FrameLoaderClientImpl::transitionToCommittedForNewPage): + (WebKit::FrameLoaderClientImpl::canCachePage): + (WebKit::FrameLoaderClientImpl::download): + (WebKit::FrameLoaderClientImpl::createFrame): + (WebKit::FrameLoaderClientImpl::createPlugin): + (WebKit::FrameLoaderClientImpl::redirectDataToPlugin): + (WebKit::FrameLoaderClientImpl::createJavaAppletWidget): + (WebKit::FrameLoaderClientImpl::objectContentType): + (WebKit::FrameLoaderClientImpl::overrideMediaType): + (WebKit::FrameLoaderClientImpl::actionSpecifiesNavigationPolicy): + (WebKit::FrameLoaderClientImpl::handleBackForwardNavigation): + (WebKit::FrameLoaderClientImpl::pluginLoadObserver): + * src/FrameLoaderClientImpl.h: Added. + (WebKit::FrameLoaderClientImpl::webFrame): + (WebKit::FrameLoaderClientImpl::willChangeEstimatedProgress): + (WebKit::FrameLoaderClientImpl::didChangeEstimatedProgress): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: ChromeClientImpl...ContextMenuClientImpl + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/ChromeClientImpl.cpp: Added. + (WebKit::ChromeClientImpl::ChromeClientImpl): + (WebKit::ChromeClientImpl::~ChromeClientImpl): + (WebKit::ChromeClientImpl::chromeDestroyed): + (WebKit::ChromeClientImpl::setWindowRect): + (WebKit::ChromeClientImpl::windowRect): + (WebKit::ChromeClientImpl::pageRect): + (WebKit::ChromeClientImpl::scaleFactor): + (WebKit::ChromeClientImpl::focus): + (WebKit::ChromeClientImpl::unfocus): + (WebKit::ChromeClientImpl::canTakeFocus): + (WebKit::ChromeClientImpl::takeFocus): + (WebKit::ChromeClientImpl::focusedNodeChanged): + (WebKit::ChromeClientImpl::createWindow): + (WebKit::currentEventShouldCauseBackgroundTab): + (WebKit::ChromeClientImpl::show): + (WebKit::ChromeClientImpl::canRunModal): + (WebKit::ChromeClientImpl::runModal): + (WebKit::ChromeClientImpl::setToolbarsVisible): + (WebKit::ChromeClientImpl::toolbarsVisible): + (WebKit::ChromeClientImpl::setStatusbarVisible): + (WebKit::ChromeClientImpl::statusbarVisible): + (WebKit::ChromeClientImpl::setScrollbarsVisible): + (WebKit::ChromeClientImpl::scrollbarsVisible): + (WebKit::ChromeClientImpl::setMenubarVisible): + (WebKit::ChromeClientImpl::menubarVisible): + (WebKit::ChromeClientImpl::setResizable): + (WebKit::ChromeClientImpl::addMessageToConsole): + (WebKit::ChromeClientImpl::canRunBeforeUnloadConfirmPanel): + (WebKit::ChromeClientImpl::runBeforeUnloadConfirmPanel): + (WebKit::ChromeClientImpl::closeWindowSoon): + (WebKit::ChromeClientImpl::runJavaScriptAlert): + (WebKit::ChromeClientImpl::runJavaScriptConfirm): + (WebKit::ChromeClientImpl::runJavaScriptPrompt): + (WebKit::ChromeClientImpl::setStatusbarText): + (WebKit::ChromeClientImpl::shouldInterruptJavaScript): + (WebKit::ChromeClientImpl::tabsToLinks): + (WebKit::ChromeClientImpl::windowResizerRect): + (WebKit::ChromeClientImpl::repaint): + (WebKit::ChromeClientImpl::scroll): + (WebKit::ChromeClientImpl::screenToWindow): + (WebKit::ChromeClientImpl::windowToScreen): + (WebKit::ChromeClientImpl::contentsSizeChanged): + (WebKit::ChromeClientImpl::scrollbarsModeDidChange): + (WebKit::ChromeClientImpl::mouseDidMoveOverElement): + (WebKit::ChromeClientImpl::setToolTip): + (WebKit::ChromeClientImpl::print): + (WebKit::ChromeClientImpl::exceededDatabaseQuota): + (WebKit::ChromeClientImpl::reachedMaxAppCacheSize): + (WebKit::ChromeClientImpl::runOpenPanel): + (WebKit::ChromeClientImpl::popupOpened): + (WebKit::ChromeClientImpl::setCursor): + (WebKit::ChromeClientImpl::setCursorForPlugin): + (WebKit::ChromeClientImpl::formStateDidChange): + (WebKit::ChromeClientImpl::getPopupMenuInfo): + (WebKit::ChromeClientImpl::notificationPresenter): + * src/ChromeClientImpl.h: Added. + (WebKit::ChromeClientImpl::webView): + (WebKit::ChromeClientImpl::platformPageClient): + (WebKit::ChromeClientImpl::scrollRectIntoView): + (WebKit::ChromeClientImpl::requestGeolocationPermissionForFrame): + (WebKit::ChromeClientImpl::setCursor): + (WebKit::ChromeClientImpl::createHTMLParserQuirks): + * src/ChromiumBridge.cpp: Added. + (WebCore::toChromeClientImpl): + (WebCore::toWebWidgetClient): + (WebCore::ChromiumBridge::clipboardIsFormatAvailable): + (WebCore::ChromiumBridge::clipboardReadPlainText): + (WebCore::ChromiumBridge::clipboardReadHTML): + (WebCore::ChromiumBridge::clipboardWriteSelection): + (WebCore::ChromiumBridge::clipboardWritePlainText): + (WebCore::ChromiumBridge::clipboardWriteURL): + (WebCore::ChromiumBridge::clipboardWriteImage): + (WebCore::ChromiumBridge::setCookies): + (WebCore::ChromiumBridge::cookies): + (WebCore::ChromiumBridge::rawCookies): + (WebCore::ChromiumBridge::deleteCookie): + (WebCore::ChromiumBridge::prefetchDNS): + (WebCore::ChromiumBridge::fileExists): + (WebCore::ChromiumBridge::deleteFile): + (WebCore::ChromiumBridge::deleteEmptyDirectory): + (WebCore::ChromiumBridge::getFileSize): + (WebCore::ChromiumBridge::getFileModificationTime): + (WebCore::ChromiumBridge::directoryName): + (WebCore::ChromiumBridge::pathByAppendingComponent): + (WebCore::ChromiumBridge::makeAllDirectories): + (WebCore::ChromiumBridge::getAbsolutePath): + (WebCore::ChromiumBridge::isDirectory): + (WebCore::ChromiumBridge::filePathToURL): + (WebCore::ChromiumBridge::ensureFontLoaded): + (WebCore::ChromiumBridge::getFontFamilyForCharacters): + (WebCore::ChromiumBridge::databaseOpenFile): + (WebCore::ChromiumBridge::databaseDeleteFile): + (WebCore::ChromiumBridge::databaseGetFileAttributes): + (WebCore::ChromiumBridge::databaseGetFileSize): + (WebCore::ChromiumBridge::signedPublicKeyAndChallengeString): + (WebCore::ChromiumBridge::computedDefaultLanguage): + (WebCore::ChromiumBridge::layoutTestMode): + (WebCore::ChromiumBridge::isSupportedImageMIMEType): + (WebCore::ChromiumBridge::isSupportedJavaScriptMIMEType): + (WebCore::ChromiumBridge::isSupportedNonImageMIMEType): + (WebCore::ChromiumBridge::mimeTypeForExtension): + (WebCore::ChromiumBridge::mimeTypeFromFile): + (WebCore::ChromiumBridge::preferredExtensionForMIMEType): + (WebCore::ChromiumBridge::plugins): + (WebCore::ChromiumBridge::pluginScriptableObject): + (WebCore::ChromiumBridge::loadPlatformImageResource): + (WebCore::ChromiumBridge::sandboxEnabled): + (WebCore::ChromiumBridge::setSharedTimerFiredFunction): + (WebCore::ChromiumBridge::setSharedTimerFireTime): + (WebCore::ChromiumBridge::stopSharedTimer): + (WebCore::ChromiumBridge::decrementStatsCounter): + (WebCore::ChromiumBridge::incrementStatsCounter): + (WebCore::ChromiumBridge::suddenTerminationChanged): + (WebCore::ChromiumBridge::currentTime): + (WebCore::ChromiumBridge::paintButton): + (WebCore::ChromiumBridge::paintMenuList): + (WebCore::ChromiumBridge::paintScrollbarArrow): + (WebCore::ChromiumBridge::paintScrollbarThumb): + (WebCore::ChromiumBridge::paintScrollbarTrack): + (WebCore::ChromiumBridge::paintTextField): + (WebCore::ChromiumBridge::paintTrackbar): + (WebCore::ChromiumBridge::traceEventBegin): + (WebCore::ChromiumBridge::traceEventEnd): + (WebCore::ChromiumBridge::visitedLinkHash): + (WebCore::ChromiumBridge::isLinkVisited): + (WebCore::ChromiumBridge::notifyJSOutOfMemory): + (WebCore::ChromiumBridge::memoryUsageMB): + (WebCore::ChromiumBridge::screenDepth): + (WebCore::ChromiumBridge::screenDepthPerComponent): + (WebCore::ChromiumBridge::screenIsMonochrome): + (WebCore::ChromiumBridge::screenRect): + (WebCore::ChromiumBridge::screenAvailableRect): + (WebCore::ChromiumBridge::popupsAllowed): + (WebCore::ChromiumBridge::widgetSetCursor): + (WebCore::ChromiumBridge::widgetSetFocus): + (WebCore::WorkerContextProxy::create): + * src/ChromiumCurrentTime.cpp: Added. + (WTF::currentTime): + * src/ChromiumThreading.cpp: Added. + (WTF::ChromiumThreading::initializeMainThread): + (WTF::ChromiumThreading::scheduleDispatchFunctionsOnMainThread): + * src/ContextMenuClientImpl.cpp: Added. + (WebKit::urlFromFrame): + (WebKit::isASingleWord): + (WebKit::selectMisspelledWord): + (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): + * src/ContextMenuClientImpl.h: Added. + (WebKit::ContextMenuClientImpl::ContextMenuClientImpl): + (WebKit::ContextMenuClientImpl::~ContextMenuClientImpl): + (WebKit::ContextMenuClientImpl::copyImageToClipboard): + (WebKit::ContextMenuClientImpl::contextMenuDestroyed): + (WebKit::ContextMenuClientImpl::contextMenuItemSelected): + (WebKit::ContextMenuClientImpl::downloadURL): + (WebKit::ContextMenuClientImpl::isSpeaking): + (WebKit::ContextMenuClientImpl::lookUpInDictionary): + (WebKit::ContextMenuClientImpl::searchWithGoogle): + (WebKit::ContextMenuClientImpl::shouldIncludeInspectElementItem): + (WebKit::ContextMenuClientImpl::speak): + (WebKit::ContextMenuClientImpl::stopSpeaking): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: AppCach...BackForwardListClientImpl + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/ApplicationCacheHost.cpp: Added. + (WebCore::ApplicationCacheHostInternal::ApplicationCacheHostInternal): + (WebCore::ApplicationCacheHostInternal::notifyEventListener): + (WebCore::ApplicationCacheHost::ApplicationCacheHost): + (WebCore::ApplicationCacheHost::~ApplicationCacheHost): + (WebCore::ApplicationCacheHost::maybeLoadMainResource): + (WebCore::ApplicationCacheHost::selectCacheWithoutManifest): + (WebCore::ApplicationCacheHost::selectCacheWithManifest): + (WebCore::ApplicationCacheHost::maybeLoadFallbackForMainResponse): + (WebCore::ApplicationCacheHost::maybeLoadFallbackForMainError): + (WebCore::ApplicationCacheHost::mainResourceDataReceived): + (WebCore::ApplicationCacheHost::failedLoadingMainResource): + (WebCore::ApplicationCacheHost::finishedLoadingMainResource): + (WebCore::ApplicationCacheHost::maybeLoadResource): + (WebCore::ApplicationCacheHost::maybeLoadFallbackForRedirect): + (WebCore::ApplicationCacheHost::maybeLoadFallbackForResponse): + (WebCore::ApplicationCacheHost::maybeLoadFallbackForError): + (WebCore::ApplicationCacheHost::maybeLoadSynchronously): + (WebCore::ApplicationCacheHost::maybeLoadFallbackSynchronously): + (WebCore::ApplicationCacheHost::canCacheInPageCache): + (WebCore::ApplicationCacheHost::setDOMApplicationCache): + (WebCore::ApplicationCacheHost::notifyDOMApplicationCache): + (WebCore::ApplicationCacheHost::status): + (WebCore::ApplicationCacheHost::update): + (WebCore::ApplicationCacheHost::swapCache): + (WebCore::ApplicationCacheHost::isApplicationCacheEnabled): + * src/AssertMatchingEnums.cpp: Added. + * src/AutocompletePopupMenuClient.cpp: Added. + (WebKit::AutocompletePopupMenuClient::AutocompletePopupMenuClient): + (WebKit::AutocompletePopupMenuClient::~AutocompletePopupMenuClient): + (WebKit::AutocompletePopupMenuClient::initialize): + (WebKit::AutocompletePopupMenuClient::valueChanged): + (WebKit::AutocompletePopupMenuClient::itemText): + (WebKit::AutocompletePopupMenuClient::itemStyle): + (WebKit::AutocompletePopupMenuClient::menuStyle): + (WebKit::AutocompletePopupMenuClient::clientPaddingLeft): + (WebKit::AutocompletePopupMenuClient::clientPaddingRight): + (WebKit::AutocompletePopupMenuClient::popupDidHide): + (WebKit::AutocompletePopupMenuClient::setTextFromItem): + (WebKit::AutocompletePopupMenuClient::fontSelector): + (WebKit::AutocompletePopupMenuClient::hostWindow): + (WebKit::AutocompletePopupMenuClient::createScrollbar): + (WebKit::AutocompletePopupMenuClient::setSuggestions): + (WebKit::AutocompletePopupMenuClient::removeItemAtIndex): + (WebKit::AutocompletePopupMenuClient::textFieldStyle): + * src/AutocompletePopupMenuClient.h: Added. + (WebKit::AutocompletePopupMenuClient::textField): + (WebKit::AutocompletePopupMenuClient::itemToolTip): + (WebKit::AutocompletePopupMenuClient::itemIsEnabled): + (WebKit::AutocompletePopupMenuClient::clientInsetLeft): + (WebKit::AutocompletePopupMenuClient::clientInsetRight): + (WebKit::AutocompletePopupMenuClient::listSize): + (WebKit::AutocompletePopupMenuClient::selectedIndex): + (WebKit::AutocompletePopupMenuClient::itemIsSeparator): + (WebKit::AutocompletePopupMenuClient::itemIsLabel): + (WebKit::AutocompletePopupMenuClient::itemIsSelected): + (WebKit::AutocompletePopupMenuClient::shouldPopOver): + (WebKit::AutocompletePopupMenuClient::valueShouldChangeOnHotTrack): + * src/BackForwardListClientImpl.cpp: Added. + (WebKit::BackForwardListClientImpl::BackForwardListClientImpl): + (WebKit::BackForwardListClientImpl::~BackForwardListClientImpl): + (WebKit::BackForwardListClientImpl::setCurrentHistoryItem): + (WebKit::BackForwardListClientImpl::previousHistoryItem): + (WebKit::BackForwardListClientImpl::addItem): + (WebKit::BackForwardListClientImpl::goToItem): + (WebKit::BackForwardListClientImpl::currentItem): + (WebKit::BackForwardListClientImpl::itemAtIndex): + (WebKit::BackForwardListClientImpl::backListCount): + (WebKit::BackForwardListClientImpl::forwardListCount): + (WebKit::BackForwardListClientImpl::close): + * src/BackForwardListClientImpl.h: Added. + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebString...WebViewImpl + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebString.cpp: Added. + (WebKit::WebString::reset): + (WebKit::WebString::assign): + (WebKit::WebString::length): + (WebKit::WebString::data): + (WebKit::WebString::utf8): + (WebKit::WebString::fromUTF8): + (WebKit::WebString::WebString): + (WebKit::WebString::operator=): + (WebKit::WebString::operator WebCore::String): + (WebKit::WebString::operator WebCore::AtomicString): + * src/WebURL.cpp: Added. + (WebKit::WebURL::WebURL): + (WebKit::WebURL::operator=): + (WebKit::WebURL::operator WebCore::KURL): + * src/WebURLError.cpp: Added. + (WebKit::WebURLError::WebURLError): + (WebKit::WebURLError::operator=): + (WebKit::WebURLError::operator ResourceError): + * src/WebURLRequest.cpp: Added. + (WebKit::WebURLRequestPrivateImpl::WebURLRequestPrivateImpl): + (WebKit::WebURLRequestPrivateImpl::dispose): + (WebKit::WebURLRequest::initialize): + (WebKit::WebURLRequest::reset): + (WebKit::WebURLRequest::assign): + (WebKit::WebURLRequest::isNull): + (WebKit::WebURLRequest::url): + (WebKit::WebURLRequest::setURL): + (WebKit::WebURLRequest::firstPartyForCookies): + (WebKit::WebURLRequest::setFirstPartyForCookies): + (WebKit::WebURLRequest::allowCookies): + (WebKit::WebURLRequest::setAllowCookies): + (WebKit::WebURLRequest::allowStoredCredentials): + (WebKit::WebURLRequest::setAllowStoredCredentials): + (WebKit::WebURLRequest::cachePolicy): + (WebKit::WebURLRequest::setCachePolicy): + (WebKit::WebURLRequest::httpMethod): + (WebKit::WebURLRequest::setHTTPMethod): + (WebKit::WebURLRequest::httpHeaderField): + (WebKit::WebURLRequest::setHTTPHeaderField): + (WebKit::WebURLRequest::addHTTPHeaderField): + (WebKit::WebURLRequest::clearHTTPHeaderField): + (WebKit::WebURLRequest::visitHTTPHeaderFields): + (WebKit::WebURLRequest::httpBody): + (WebKit::WebURLRequest::setHTTPBody): + (WebKit::WebURLRequest::reportUploadProgress): + (WebKit::WebURLRequest::setReportUploadProgress): + (WebKit::WebURLRequest::targetType): + (WebKit::WebURLRequest::setTargetType): + (WebKit::WebURLRequest::requestorID): + (WebKit::WebURLRequest::setRequestorID): + (WebKit::WebURLRequest::requestorProcessID): + (WebKit::WebURLRequest::setRequestorProcessID): + (WebKit::WebURLRequest::appCacheHostID): + (WebKit::WebURLRequest::setAppCacheHostID): + (WebKit::WebURLRequest::toMutableResourceRequest): + (WebKit::WebURLRequest::toResourceRequest): + * src/WebURLRequestPrivate.h: Added. + (WebKit::WebURLRequestPrivate::WebURLRequestPrivate): + * src/WebURLResponse.cpp: Added. + (WebKit::WebURLResponsePrivateImpl::WebURLResponsePrivateImpl): + (WebKit::WebURLResponsePrivateImpl::dispose): + (WebKit::WebURLResponse::initialize): + (WebKit::WebURLResponse::reset): + (WebKit::WebURLResponse::assign): + (WebKit::WebURLResponse::isNull): + (WebKit::WebURLResponse::url): + (WebKit::WebURLResponse::setURL): + (WebKit::WebURLResponse::mimeType): + (WebKit::WebURLResponse::setMIMEType): + (WebKit::WebURLResponse::expectedContentLength): + (WebKit::WebURLResponse::setExpectedContentLength): + (WebKit::WebURLResponse::textEncodingName): + (WebKit::WebURLResponse::setTextEncodingName): + (WebKit::WebURLResponse::suggestedFileName): + (WebKit::WebURLResponse::setSuggestedFileName): + (WebKit::WebURLResponse::httpStatusCode): + (WebKit::WebURLResponse::setHTTPStatusCode): + (WebKit::WebURLResponse::httpStatusText): + (WebKit::WebURLResponse::setHTTPStatusText): + (WebKit::WebURLResponse::httpHeaderField): + (WebKit::WebURLResponse::setHTTPHeaderField): + (WebKit::WebURLResponse::addHTTPHeaderField): + (WebKit::WebURLResponse::clearHTTPHeaderField): + (WebKit::WebURLResponse::visitHTTPHeaderFields): + (WebKit::WebURLResponse::lastModifiedDate): + (WebKit::WebURLResponse::setLastModifiedDate): + (WebKit::WebURLResponse::isContentFiltered): + (WebKit::WebURLResponse::setIsContentFiltered): + (WebKit::WebURLResponse::appCacheID): + (WebKit::WebURLResponse::setAppCacheID): + (WebKit::WebURLResponse::appCacheManifestURL): + (WebKit::WebURLResponse::setAppCacheManifestURL): + (WebKit::WebURLResponse::securityInfo): + (WebKit::WebURLResponse::setSecurityInfo): + (WebKit::WebURLResponse::toMutableResourceResponse): + (WebKit::WebURLResponse::toResourceResponse): + * src/WebURLResponsePrivate.h: Added. + (WebKit::WebURLResponsePrivate::WebURLResponsePrivate): + * src/WebViewImpl.cpp: Added. + (WebKit::): + (WebKit::WebView::create): + (WebKit::WebView::updateVisitedLinkState): + (WebKit::WebView::resetVisitedLinkState): + (WebKit::WebViewImpl::initializeMainFrame): + (WebKit::WebViewImpl::WebViewImpl): + (WebKit::WebViewImpl::~WebViewImpl): + (WebKit::WebViewImpl::theme): + (WebKit::WebViewImpl::mainFrameImpl): + (WebKit::WebViewImpl::tabKeyCyclesThroughElements): + (WebKit::WebViewImpl::setTabKeyCyclesThroughElements): + (WebKit::WebViewImpl::mouseMove): + (WebKit::WebViewImpl::mouseLeave): + (WebKit::WebViewImpl::mouseDown): + (WebKit::WebViewImpl::mouseContextMenu): + (WebKit::WebViewImpl::mouseUp): + (WebKit::WebViewImpl::mouseWheel): + (WebKit::WebViewImpl::keyEvent): + (WebKit::WebViewImpl::autocompleteHandleKeyEvent): + (WebKit::WebViewImpl::charEvent): + (WebKit::WebViewImpl::sendContextMenuEvent): + (WebKit::WebViewImpl::keyEventDefault): + (WebKit::WebViewImpl::scrollViewWithKeyboard): + (WebKit::WebViewImpl::propagateScroll): + (WebKit::WebViewImpl::focusedWebCoreFrame): + (WebKit::WebViewImpl::fromPage): + (WebKit::WebViewImpl::close): + (WebKit::WebViewImpl::resize): + (WebKit::WebViewImpl::layout): + (WebKit::WebViewImpl::paint): + (WebKit::WebViewImpl::handleInputEvent): + (WebKit::WebViewImpl::mouseCaptureLost): + (WebKit::WebViewImpl::setFocus): + (WebKit::WebViewImpl::handleCompositionEvent): + (WebKit::WebViewImpl::queryCompositionStatus): + (WebKit::WebViewImpl::setTextDirection): + (WebKit::WebViewImpl::settings): + (WebKit::WebViewImpl::pageEncoding): + (WebKit::WebViewImpl::setPageEncoding): + (WebKit::WebViewImpl::dispatchBeforeUnloadEvent): + (WebKit::WebViewImpl::dispatchUnloadEvent): + (WebKit::WebViewImpl::mainFrame): + (WebKit::WebViewImpl::findFrameByName): + (WebKit::WebViewImpl::focusedFrame): + (WebKit::WebViewImpl::setFocusedFrame): + (WebKit::WebViewImpl::setInitialFocus): + (WebKit::WebViewImpl::clearFocusedNode): + (WebKit::WebViewImpl::zoomIn): + (WebKit::WebViewImpl::zoomOut): + (WebKit::WebViewImpl::zoomDefault): + (WebKit::WebViewImpl::performMediaPlayerAction): + (WebKit::WebViewImpl::copyImageAt): + (WebKit::WebViewImpl::dragSourceEndedAt): + (WebKit::WebViewImpl::dragSourceMovedTo): + (WebKit::WebViewImpl::dragSourceSystemDragEnded): + (WebKit::WebViewImpl::dragTargetDragEnter): + (WebKit::WebViewImpl::dragTargetDragOver): + (WebKit::WebViewImpl::dragTargetDragLeave): + (WebKit::WebViewImpl::dragTargetDrop): + (WebKit::WebViewImpl::dragIdentity): + (WebKit::WebViewImpl::inspectElementAt): + (WebKit::WebViewImpl::inspectorSettings): + (WebKit::WebViewImpl::setInspectorSettings): + (WebKit::WebViewImpl::devToolsAgent): + (WebKit::WebViewImpl::setDevToolsAgent): + (WebKit::WebViewImpl::accessibilityObject): + (WebKit::WebViewImpl::applyAutofillSuggestions): + (WebKit::WebViewImpl::hideAutofillPopup): + (WebKit::WebViewImpl::setDropEffect): + (WebKit::WebViewImpl::setIsTransparent): + (WebKit::WebViewImpl::isTransparent): + (WebKit::WebViewImpl::setIsActive): + (WebKit::WebViewImpl::isActive): + (WebKit::WebViewImpl::didCommitLoad): + (WebKit::WebViewImpl::navigationPolicyFromMouseEvent): + (WebKit::WebViewImpl::startDragging): + (WebKit::WebViewImpl::setCurrentHistoryItem): + (WebKit::WebViewImpl::previousHistoryItem): + (WebKit::WebViewImpl::observeNewNavigation): + (WebKit::WebViewImpl::hideAutoCompletePopup): + (WebKit::WebViewImpl::autoCompletePopupDidHide): + (WebKit::WebViewImpl::setIgnoreInputEvents): + (WebKit::WebViewImpl::notificationPresenterImpl): + (WebKit::WebViewImpl::refreshAutofillPopup): + (WebKit::WebViewImpl::focusedWebCoreNode): + (WebKit::WebViewImpl::hitTestResultForWindowPos): + (WebKit::WebViewImpl::setTabsToLinks): + (WebKit::WebViewImpl::tabsToLinks): + * src/WebViewImpl.h: Added. + (WebKit::WebViewImpl::size): + (WebKit::WebViewImpl::devToolsAgentPrivate): + (WebKit::WebViewImpl::lastMouseDownPoint): + (WebKit::WebViewImpl::client): + (WebKit::WebViewImpl::page): + (WebKit::WebViewImpl::contextMenuAllowed): + (WebKit::WebViewImpl::setInitialNavigationPolicy): + (WebKit::WebViewImpl::initialNavigationPolicy): + (WebKit::WebViewImpl::currentInputEvent): + (WebKit::WebViewImpl::): + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebScriptController...WebStorageNamespaceImpl + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebScriptController.cpp: Added. + (WebKit::WebScriptController::registerExtension): + (WebKit::WebScriptController::enableV8SingleThreadMode): + (WebKit::WebScriptController::flushConsoleMessages): + * src/WebSearchableFormData.cpp: Added. + (WebCore::GetFormEncoding): + (WebCore::IsHTTPFormSubmit): + (WebCore::GetButtonToActivate): + (WebCore::IsSelectInDefaultState): + (WebCore::IsInDefaultState): + (WebCore::HasSuitableTextElement): + (WebKit::WebSearchableFormData::WebSearchableFormData): + * src/WebSecurityOrigin.cpp: Added. + (WebKit::WebSecurityOrigin::reset): + (WebKit::WebSecurityOrigin::assign): + (WebKit::WebSecurityOrigin::protocol): + (WebKit::WebSecurityOrigin::host): + (WebKit::WebSecurityOrigin::port): + (WebKit::WebSecurityOrigin::isEmpty): + (WebKit::WebSecurityOrigin::toString): + (WebKit::WebSecurityOrigin::databaseIdentifier): + (WebKit::WebSecurityOrigin::WebSecurityOrigin): + (WebKit::WebSecurityOrigin::operator=): + (WebKit::WebSecurityOrigin::operator WTF::PassRefPtr<WebCore::SecurityOrigin>): + * src/WebSecurityPolicy.cpp: Added. + (WebKit::WebSecurityPolicy::registerURLSchemeAsLocal): + (WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess): + (WebKit::WebSecurityPolicy::whiteListAccessFromOrigin): + (WebKit::WebSecurityPolicy::resetOriginAccessWhiteLists): + * src/WebSettingsImpl.cpp: Added. + (WebKit::WebSettingsImpl::WebSettingsImpl): + (WebKit::WebSettingsImpl::setStandardFontFamily): + (WebKit::WebSettingsImpl::setFixedFontFamily): + (WebKit::WebSettingsImpl::setSerifFontFamily): + (WebKit::WebSettingsImpl::setSansSerifFontFamily): + (WebKit::WebSettingsImpl::setCursiveFontFamily): + (WebKit::WebSettingsImpl::setFantasyFontFamily): + (WebKit::WebSettingsImpl::setDefaultFontSize): + (WebKit::WebSettingsImpl::setDefaultFixedFontSize): + (WebKit::WebSettingsImpl::setMinimumFontSize): + (WebKit::WebSettingsImpl::setMinimumLogicalFontSize): + (WebKit::WebSettingsImpl::setDefaultTextEncodingName): + (WebKit::WebSettingsImpl::setJavaScriptEnabled): + (WebKit::WebSettingsImpl::setWebSecurityEnabled): + (WebKit::WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically): + (WebKit::WebSettingsImpl::setLoadsImagesAutomatically): + (WebKit::WebSettingsImpl::setPluginsEnabled): + (WebKit::WebSettingsImpl::setDOMPasteAllowed): + (WebKit::WebSettingsImpl::setDeveloperExtrasEnabled): + (WebKit::WebSettingsImpl::setShrinksStandaloneImagesToFit): + (WebKit::WebSettingsImpl::setUsesEncodingDetector): + (WebKit::WebSettingsImpl::setTextAreasAreResizable): + (WebKit::WebSettingsImpl::setJavaEnabled): + (WebKit::WebSettingsImpl::setAllowScriptsToCloseWindows): + (WebKit::WebSettingsImpl::setUserStyleSheetLocation): + (WebKit::WebSettingsImpl::setUsesPageCache): + (WebKit::WebSettingsImpl::setDownloadableBinaryFontsEnabled): + (WebKit::WebSettingsImpl::setXSSAuditorEnabled): + (WebKit::WebSettingsImpl::setLocalStorageEnabled): + (WebKit::WebSettingsImpl::setEditableLinkBehaviorNeverLive): + (WebKit::WebSettingsImpl::setFontRenderingModeNormal): + (WebKit::WebSettingsImpl::setShouldPaintCustomScrollbars): + (WebKit::WebSettingsImpl::setDatabasesEnabled): + (WebKit::WebSettingsImpl::setAllowUniversalAccessFromFileURLs): + (WebKit::WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded): + (WebKit::WebSettingsImpl::setOfflineWebApplicationCacheEnabled): + (WebKit::WebSettingsImpl::setExperimentalWebGLEnabled): + * src/WebSettingsImpl.h: Added. + (WebKit::WebSettingsImpl::~WebSettingsImpl): + * src/WebSharedWorkerImpl.cpp: Added. + (WebKit::WebSharedWorkerImpl::WebSharedWorkerImpl): + (WebKit::WebSharedWorkerImpl::~WebSharedWorkerImpl): + (WebKit::WebSharedWorkerImpl::isStarted): + (WebKit::WebSharedWorkerImpl::connect): + (WebKit::WebSharedWorkerImpl::connectTask): + (WebKit::WebSharedWorkerImpl::startWorkerContext): + (WebKit::WebSharedWorkerImpl::terminateWorkerContext): + (WebKit::WebSharedWorkerImpl::clientDestroyed): + (WebKit::WebSharedWorkerImpl::client): + (WebKit::WebSharedWorker::create): + * src/WebSharedWorkerImpl.h: Added. + (WebKit::WebSharedWorkerImpl::commonClient): + * src/WebStorageAreaImpl.cpp: Added. + (WebKit::WebStorageAreaImpl::WebStorageAreaImpl): + (WebKit::WebStorageAreaImpl::~WebStorageAreaImpl): + (WebKit::WebStorageAreaImpl::length): + (WebKit::WebStorageAreaImpl::key): + (WebKit::WebStorageAreaImpl::getItem): + (WebKit::WebStorageAreaImpl::setItem): + (WebKit::WebStorageAreaImpl::removeItem): + (WebKit::WebStorageAreaImpl::clear): + * src/WebStorageAreaImpl.h: Added. + (WebKit::WebStorageAreaImpl::currentStorageEventURL): + (WebKit::WebStorageAreaImpl::ScopedStorageEventURL::ScopedStorageEventURL): + (WebKit::WebStorageAreaImpl::ScopedStorageEventURL::~ScopedStorageEventURL): + * src/WebStorageEventDispatcherImpl.cpp: Added. + (WebKit::WebStorageEventDispatcher::create): + (WebKit::WebStorageEventDispatcherImpl::WebStorageEventDispatcherImpl): + (WebKit::WebStorageEventDispatcherImpl::dispatchStorageEvent): + * src/WebStorageEventDispatcherImpl.h: Added. + * src/WebStorageNamespaceImpl.cpp: Added. + (WebKit::WebStorageNamespace::createLocalStorageNamespace): + (WebKit::WebStorageNamespace::createSessionStorageNamespace): + (WebKit::WebStorageNamespaceImpl::WebStorageNamespaceImpl): + (WebKit::WebStorageNamespaceImpl::~WebStorageNamespaceImpl): + (WebKit::WebStorageNamespaceImpl::createStorageArea): + (WebKit::WebStorageNamespaceImpl::copy): + (WebKit::WebStorageNamespaceImpl::close): + * src/WebStorageNamespaceImpl.h: Added. + +2009-11-10 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebPasswordFormData...WebRuntimeFeatures + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebPasswordFormData.cpp: Added. + (WebKit::): + (WebKit::WebPasswordFormData::WebPasswordFormData): + * src/WebPasswordFormUtils.cpp: Added. + (WebKit::findPasswordFormFields): + * src/WebPasswordFormUtils.h: Added. + (WebKit::PasswordFormFields::PasswordFormFields): + * src/WebPluginContainerImpl.cpp: Added. + (WebKit::WebPluginContainerImpl::setFrameRect): + (WebKit::WebPluginContainerImpl::paint): + (WebKit::WebPluginContainerImpl::invalidateRect): + (WebKit::WebPluginContainerImpl::setFocus): + (WebKit::WebPluginContainerImpl::show): + (WebKit::WebPluginContainerImpl::hide): + (WebKit::WebPluginContainerImpl::handleEvent): + (WebKit::WebPluginContainerImpl::frameRectsChanged): + (WebKit::WebPluginContainerImpl::setParentVisible): + (WebKit::WebPluginContainerImpl::setParent): + (WebKit::WebPluginContainerImpl::invalidate): + (WebKit::WebPluginContainerImpl::reportGeometry): + (WebKit::WebPluginContainerImpl::clearScriptObjects): + (WebKit::WebPluginContainerImpl::scriptableObjectForElement): + (WebKit::WebPluginContainerImpl::executeScriptURL): + (WebKit::WebPluginContainerImpl::loadFrameRequest): + (WebKit::WebPluginContainerImpl::didReceiveResponse): + (WebKit::WebPluginContainerImpl::didReceiveData): + (WebKit::WebPluginContainerImpl::didFinishLoading): + (WebKit::WebPluginContainerImpl::didFailLoading): + (WebKit::WebPluginContainerImpl::scriptableObject): + (WebKit::WebPluginContainerImpl::willDestroyPluginLoadObserver): + (WebKit::WebPluginContainerImpl::~WebPluginContainerImpl): + (WebKit::WebPluginContainerImpl::handleMouseEvent): + (WebKit::WebPluginContainerImpl::handleKeyboardEvent): + (WebKit::WebPluginContainerImpl::calculateGeometry): + (WebKit::WebPluginContainerImpl::windowClipRect): + (WebKit::getObjectStack): + (WebKit::checkStackOnTop): + (WebKit::WebPluginContainerImpl::windowCutOutRects): + * src/WebPluginContainerImpl.h: Added. + (WebKit::WebPluginContainerImpl::create): + (WebKit::WebPluginContainerImpl::plugin): + (WebKit::WebPluginContainerImpl::WebPluginContainerImpl): + * src/WebPluginListBuilderImpl.cpp: Added. + (WebKit::WebPluginListBuilderImpl::addPlugin): + (WebKit::WebPluginListBuilderImpl::addMediaTypeToLastPlugin): + (WebKit::WebPluginListBuilderImpl::addFileExtensionToLastMediaType): + * src/WebPluginListBuilderImpl.h: Added. + (WebKit::WebPluginListBuilderImpl::WebPluginListBuilderImpl): + * src/WebPluginLoadObserver.cpp: Added. + (WebKit::WebPluginLoadObserver::~WebPluginLoadObserver): + (WebKit::WebPluginLoadObserver::didFinishLoading): + (WebKit::WebPluginLoadObserver::didFailLoading): + * src/WebPluginLoadObserver.h: Added. + (WebKit::WebPluginLoadObserver::WebPluginLoadObserver): + (WebKit::WebPluginLoadObserver::url): + (WebKit::WebPluginLoadObserver::clearPluginContainer): + * src/WebPopupMenuImpl.cpp: Added. + (WebKit::WebPopupMenu::create): + (WebKit::WebPopupMenuImpl::WebPopupMenuImpl): + (WebKit::WebPopupMenuImpl::~WebPopupMenuImpl): + (WebKit::WebPopupMenuImpl::Init): + (WebKit::WebPopupMenuImpl::MouseMove): + (WebKit::WebPopupMenuImpl::MouseLeave): + (WebKit::WebPopupMenuImpl::MouseDown): + (WebKit::WebPopupMenuImpl::MouseUp): + (WebKit::WebPopupMenuImpl::MouseWheel): + (WebKit::WebPopupMenuImpl::KeyEvent): + (WebKit::WebPopupMenuImpl::close): + (WebKit::WebPopupMenuImpl::resize): + (WebKit::WebPopupMenuImpl::layout): + (WebKit::WebPopupMenuImpl::paint): + (WebKit::WebPopupMenuImpl::handleInputEvent): + (WebKit::WebPopupMenuImpl::mouseCaptureLost): + (WebKit::WebPopupMenuImpl::setFocus): + (WebKit::WebPopupMenuImpl::handleCompositionEvent): + (WebKit::WebPopupMenuImpl::queryCompositionStatus): + (WebKit::WebPopupMenuImpl::setTextDirection): + (WebKit::WebPopupMenuImpl::repaint): + (WebKit::WebPopupMenuImpl::scroll): + (WebKit::WebPopupMenuImpl::screenToWindow): + (WebKit::WebPopupMenuImpl::windowToScreen): + (WebKit::WebPopupMenuImpl::scrollRectIntoView): + (WebKit::WebPopupMenuImpl::scrollbarsModeDidChange): + (WebKit::WebPopupMenuImpl::popupClosed): + * src/WebPopupMenuImpl.h: Added. + (WebKit::WebPopupMenuImpl::size): + (WebKit::WebPopupMenuImpl::client): + (WebKit::WebPopupMenuImpl::platformPageClient): + * src/WebRange.cpp: Added. + (WebKit::WebRange::reset): + (WebKit::WebRange::assign): + (WebKit::WebRange::startOffset): + (WebKit::WebRange::endOffset): + (WebKit::WebRange::startContainer): + (WebKit::WebRange::endContainer): + (WebKit::WebRange::toHTMLText): + (WebKit::WebRange::toPlainText): + (WebKit::WebRange::WebRange): + (WebKit::WebRange::operator=): + (WebKit::WebRange::operator WTF::PassRefPtr<WebCore::Range>): + * src/WebRuntimeFeatures.cpp: Added. + (WebKit::WebRuntimeFeatures::enableDatabase): + (WebKit::WebRuntimeFeatures::isDatabaseEnabled): + (WebKit::WebRuntimeFeatures::enableLocalStorage): + (WebKit::WebRuntimeFeatures::isLocalStorageEnabled): + (WebKit::WebRuntimeFeatures::enableSessionStorage): + (WebKit::WebRuntimeFeatures::isSessionStorageEnabled): + (WebKit::WebRuntimeFeatures::enableMediaPlayer): + (WebKit::WebRuntimeFeatures::isMediaPlayerEnabled): + (WebKit::WebRuntimeFeatures::enableSockets): + (WebKit::WebRuntimeFeatures::isSocketsEnabled): + (WebKit::WebRuntimeFeatures::enableNotifications): + (WebKit::WebRuntimeFeatures::isNotificationsEnabled): + (WebKit::WebRuntimeFeatures::enableApplicationCache): + (WebKit::WebRuntimeFeatures::isApplicationCacheEnabled): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebFileInputElement...WebNotifications + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebInputElement.cpp: Added. + (WebKit::WebInputElement::WebInputElement): + (WebKit::WebInputElement::operator=): + (WebKit::WebInputElement::operator WTF::PassRefPtr<HTMLInputElement>): + (WebKit::WebInputElement::setActivatedSubmit): + (WebKit::WebInputElement::setValue): + (WebKit::WebInputElement::value): + (WebKit::WebInputElement::setAutofilled): + (WebKit::WebInputElement::dispatchFormControlChangeEvent): + (WebKit::WebInputElement::setSelectionRange): + * src/WebInputEvent.cpp: Added. + (WebKit::staticKeyIdentifiers): + (WebKit::WebKeyboardEvent::setKeyIdentifierFromWindowsKeyCode): + * src/WebInputEventConversion.cpp: Added. + (WebKit::PlatformMouseEventBuilder::PlatformMouseEventBuilder): + (WebKit::PlatformWheelEventBuilder::PlatformWheelEventBuilder): + (WebKit::toPlatformKeyboardEventType): + (WebKit::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder): + (WebKit::PlatformKeyboardEventBuilder::setKeyType): + (WebKit::PlatformKeyboardEventBuilder::isCharacterKey): + (WebKit::getWebInputModifiers): + (WebKit::WebMouseEventBuilder::WebMouseEventBuilder): + (WebKit::WebKeyboardEventBuilder::WebKeyboardEventBuilder): + * src/WebInputEventConversion.h: Added. + * src/WebKit.cpp: Added. + (WebKit::initialize): + (WebKit::shutdown): + (WebKit::webKitClient): + (WebKit::setLayoutTestMode): + (WebKit::layoutTestMode): + (WebKit::resetPluginCache): + * src/WebMediaPlayerClientImpl.cpp: Added. + (WebKit::createWebMediaPlayer): + (WebKit::WebMediaPlayerClientImpl::isEnabled): + (WebKit::WebMediaPlayerClientImpl::setIsEnabled): + (WebKit::WebMediaPlayerClientImpl::registerSelf): + (WebKit::WebMediaPlayerClientImpl::networkStateChanged): + (WebKit::WebMediaPlayerClientImpl::readyStateChanged): + (WebKit::WebMediaPlayerClientImpl::volumeChanged): + (WebKit::WebMediaPlayerClientImpl::timeChanged): + (WebKit::WebMediaPlayerClientImpl::repaint): + (WebKit::WebMediaPlayerClientImpl::durationChanged): + (WebKit::WebMediaPlayerClientImpl::rateChanged): + (WebKit::WebMediaPlayerClientImpl::sizeChanged): + (WebKit::WebMediaPlayerClientImpl::sawUnsupportedTracks): + (WebKit::WebMediaPlayerClientImpl::load): + (WebKit::WebMediaPlayerClientImpl::cancelLoad): + (WebKit::WebMediaPlayerClientImpl::play): + (WebKit::WebMediaPlayerClientImpl::pause): + (WebKit::WebMediaPlayerClientImpl::naturalSize): + (WebKit::WebMediaPlayerClientImpl::hasVideo): + (WebKit::WebMediaPlayerClientImpl::hasAudio): + (WebKit::WebMediaPlayerClientImpl::setVisible): + (WebKit::WebMediaPlayerClientImpl::duration): + (WebKit::WebMediaPlayerClientImpl::currentTime): + (WebKit::WebMediaPlayerClientImpl::seek): + (WebKit::WebMediaPlayerClientImpl::seeking): + (WebKit::WebMediaPlayerClientImpl::setEndTime): + (WebKit::WebMediaPlayerClientImpl::setRate): + (WebKit::WebMediaPlayerClientImpl::paused): + (WebKit::WebMediaPlayerClientImpl::supportsFullscreen): + (WebKit::WebMediaPlayerClientImpl::supportsSave): + (WebKit::WebMediaPlayerClientImpl::setVolume): + (WebKit::WebMediaPlayerClientImpl::networkState): + (WebKit::WebMediaPlayerClientImpl::readyState): + (WebKit::WebMediaPlayerClientImpl::maxTimeSeekable): + (WebKit::WebMediaPlayerClientImpl::buffered): + (WebKit::WebMediaPlayerClientImpl::dataRate): + (WebKit::WebMediaPlayerClientImpl::totalBytesKnown): + (WebKit::WebMediaPlayerClientImpl::totalBytes): + (WebKit::WebMediaPlayerClientImpl::bytesLoaded): + (WebKit::WebMediaPlayerClientImpl::setSize): + (WebKit::WebMediaPlayerClientImpl::paint): + (WebKit::WebMediaPlayerClientImpl::setAutobuffer): + (WebKit::WebMediaPlayerClientImpl::hasSingleSecurityOrigin): + (WebKit::WebMediaPlayerClientImpl::movieLoadType): + (WebKit::WebMediaPlayerClientImpl::create): + (WebKit::WebMediaPlayerClientImpl::getSupportedTypes): + (WebKit::WebMediaPlayerClientImpl::supportsType): + (WebKit::WebMediaPlayerClientImpl::WebMediaPlayerClientImpl): + * src/WebMediaPlayerClientImpl.h: Added. + * src/WebNode.cpp: Added. + (WebKit::WebNode::reset): + (WebKit::WebNode::assign): + (WebKit::WebNode::parentNode): + (WebKit::WebNode::nodeName): + (WebKit::WebNode::WebNode): + (WebKit::WebNode::operator=): + (WebKit::WebNode::operator WTF::PassRefPtr<WebCore::Node>): + (WebKit::WebNode::frame): + * src/WebNotification.cpp: Added. + (WebKit::WebNotification::reset): + (WebKit::WebNotification::assign): + (WebKit::WebNotification::lessThan): + (WebKit::WebNotification::isHTML): + (WebKit::WebNotification::url): + (WebKit::WebNotification::icon): + (WebKit::WebNotification::title): + (WebKit::WebNotification::body): + (WebKit::WebNotification::dispatchDisplayEvent): + (WebKit::WebNotification::dispatchErrorEvent): + (WebKit::WebNotification::dispatchCloseEvent): + (WebKit::WebNotification::WebNotification): + (WebKit::WebNotification::operator=): + (WebKit::WebNotification::operator WTF::PassRefPtr<Notification>): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebFileChooser...WebImageSkia + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebFileChooserCompletionImpl.cpp: Added. + (WebKit::WebFileChooserCompletionImpl::WebFileChooserCompletionImpl): + (WebKit::WebFileChooserCompletionImpl::~WebFileChooserCompletionImpl): + (WebKit::WebFileChooserCompletionImpl::didChooseFile): + * src/WebFileChooserCompletionImpl.h: Added. + * src/WebFontCache.cpp: Added. + (WebKit::WebFontCache::fontDataCount): + (WebKit::WebFontCache::inactiveFontDataCount): + (WebKit::WebFontCache::clear): + * src/WebFormElement.cpp: Added. + (WebKit::WebFormElement::WebFormElement): + (WebKit::WebFormElement::operator=): + (WebKit::WebFormElement::operator WTF::PassRefPtr<WebCore::HTMLFormElement>): + (WebKit::WebFormElement::autoComplete): + (WebKit::WebFormElement::action): + (WebKit::WebFormElement::submit): + (WebKit::WebFormElement::getNamedElements): + * src/WebFrameImpl.cpp: Added. + (WebKit::frameContentAsPlainText): + (WebKit::ChromePrintContext::ChromePrintContext): + (WebKit::ChromePrintContext::begin): + (WebKit::ChromePrintContext::getPageShrink): + (WebKit::ChromePrintContext::spoolPage): + (WebKit::DataSourceForDocLoader): + (WebKit::WebFrameImpl::DeferredScopeStringMatches::DeferredScopeStringMatches): + (WebKit::WebFrameImpl::DeferredScopeStringMatches::doTimeout): + (WebKit::WebFrame::frameForEnteredContext): + (WebKit::WebFrame::frameForCurrentContext): + (WebKit::WebFrameImpl::name): + (WebKit::WebFrameImpl::url): + (WebKit::WebFrameImpl::favIconURL): + (WebKit::WebFrameImpl::openSearchDescriptionURL): + (WebKit::WebFrameImpl::scrollOffset): + (WebKit::WebFrameImpl::contentsSize): + (WebKit::WebFrameImpl::contentsPreferredWidth): + (WebKit::WebFrameImpl::hasVisibleContent): + (WebKit::WebFrameImpl::view): + (WebKit::WebFrameImpl::opener): + (WebKit::WebFrameImpl::parent): + (WebKit::WebFrameImpl::top): + (WebKit::WebFrameImpl::firstChild): + (WebKit::WebFrameImpl::lastChild): + (WebKit::WebFrameImpl::nextSibling): + (WebKit::WebFrameImpl::previousSibling): + (WebKit::WebFrameImpl::traverseNext): + (WebKit::WebFrameImpl::traversePrevious): + (WebKit::WebFrameImpl::findChildByName): + (WebKit::WebFrameImpl::findChildByExpression): + (WebKit::WebFrameImpl::forms): + (WebKit::WebFrameImpl::securityOrigin): + (WebKit::WebFrameImpl::grantUniversalAccess): + (WebKit::WebFrameImpl::windowObject): + (WebKit::WebFrameImpl::bindToWindowObject): + (WebKit::WebFrameImpl::executeScript): + (WebKit::WebFrameImpl::executeScriptInNewContext): + (WebKit::WebFrameImpl::executeScriptInIsolatedWorld): + (WebKit::WebFrameImpl::addMessageToConsole): + (WebKit::WebFrameImpl::collectGarbage): + (WebKit::WebFrameImpl::mainWorldScriptContext): + (WebKit::WebFrameImpl::insertStyleText): + (WebKit::WebFrameImpl::reload): + (WebKit::WebFrameImpl::loadRequest): + (WebKit::WebFrameImpl::loadHistoryItem): + (WebKit::WebFrameImpl::loadData): + (WebKit::WebFrameImpl::loadHTMLString): + (WebKit::WebFrameImpl::isLoading): + (WebKit::WebFrameImpl::stopLoading): + (WebKit::WebFrameImpl::provisionalDataSource): + (WebKit::WebFrameImpl::dataSource): + (WebKit::WebFrameImpl::previousHistoryItem): + (WebKit::WebFrameImpl::currentHistoryItem): + (WebKit::WebFrameImpl::enableViewSourceMode): + (WebKit::WebFrameImpl::isViewSourceModeEnabled): + (WebKit::WebFrameImpl::setReferrerForRequest): + (WebKit::WebFrameImpl::dispatchWillSendRequest): + (WebKit::WebFrameImpl::commitDocumentData): + (WebKit::WebFrameImpl::unloadListenerCount): + (WebKit::WebFrameImpl::isProcessingUserGesture): + (WebKit::WebFrameImpl::willSuppressOpenerInNewFrame): + (WebKit::WebFrameImpl::replaceSelection): + (WebKit::WebFrameImpl::insertText): + (WebKit::WebFrameImpl::setMarkedText): + (WebKit::WebFrameImpl::unmarkText): + (WebKit::WebFrameImpl::hasMarkedText): + (WebKit::WebFrameImpl::markedRange): + (WebKit::WebFrameImpl::executeCommand): + (WebKit::WebFrameImpl::isCommandEnabled): + (WebKit::WebFrameImpl::enableContinuousSpellChecking): + (WebKit::WebFrameImpl::isContinuousSpellCheckingEnabled): + (WebKit::WebFrameImpl::hasSelection): + (WebKit::WebFrameImpl::selectionRange): + (WebKit::WebFrameImpl::selectionAsText): + (WebKit::WebFrameImpl::selectionAsMarkup): + (WebKit::WebFrameImpl::printBegin): + (WebKit::WebFrameImpl::getPrintPageShrink): + (WebKit::WebFrameImpl::printPage): + (WebKit::WebFrameImpl::printEnd): + (WebKit::WebFrameImpl::find): + (WebKit::WebFrameImpl::stopFinding): + (WebKit::WebFrameImpl::scopeStringMatches): + (WebKit::WebFrameImpl::cancelPendingScopingEffort): + (WebKit::WebFrameImpl::increaseMatchCount): + (WebKit::WebFrameImpl::reportFindInPageSelection): + (WebKit::WebFrameImpl::resetMatchCount): + (WebKit::WebFrameImpl::completeURL): + (WebKit::WebFrameImpl::contentAsText): + (WebKit::WebFrameImpl::contentAsMarkup): + (WebKit::WebFrameImpl::create): + (WebKit::WebFrameImpl::WebFrameImpl): + (WebKit::WebFrameImpl::~WebFrameImpl): + (WebKit::WebFrameImpl::initializeAsMainFrame): + (WebKit::WebFrameImpl::createChildFrame): + (WebKit::WebFrameImpl::layout): + (WebKit::WebFrameImpl::paint): + (WebKit::WebFrameImpl::createFrameView): + (WebKit::WebFrameImpl::fromFrame): + (WebKit::WebFrameImpl::viewImpl): + (WebKit::WebFrameImpl::dataSourceImpl): + (WebKit::WebFrameImpl::provisionalDataSourceImpl): + (WebKit::WebFrameImpl::setFindEndstateFocusAndSelection): + (WebKit::WebFrameImpl::didFail): + (WebKit::WebFrameImpl::setAllowsScrolling): + (WebKit::WebFrameImpl::registerPasswordListener): + (WebKit::WebFrameImpl::getPasswordListener): + (WebKit::WebFrameImpl::closing): + (WebKit::WebFrameImpl::invalidateArea): + (WebKit::WebFrameImpl::addMarker): + (WebKit::WebFrameImpl::setMarkerActive): + (WebKit::WebFrameImpl::ordinalOfFirstMatchForFrame): + (WebKit::WebFrameImpl::shouldScopeMatches): + (WebKit::WebFrameImpl::scopeStringMatchesSoon): + (WebKit::WebFrameImpl::callScopeStringMatches): + (WebKit::WebFrameImpl::invalidateIfNecessary): + (WebKit::WebFrameImpl::clearPasswordListeners): + (WebKit::WebFrameImpl::loadJavaScriptURL): + * src/WebFrameImpl.h: Added. + (WebKit::WebFrameImpl::liveObjectCount): + (WebKit::WebFrameImpl::frame): + (WebKit::WebFrameImpl::frameView): + (WebKit::WebFrameImpl::activeMatchFrame): + (WebKit::WebFrameImpl::client): + (WebKit::WebFrameImpl::dropClient): + (WebKit::WebFrameImpl::ClientHandle::create): + (WebKit::WebFrameImpl::ClientHandle::client): + (WebKit::WebFrameImpl::ClientHandle::dropClient): + (WebKit::WebFrameImpl::ClientHandle::ClientHandle): + (WebKit::WebFrameImpl::): + * src/WebHTTPBody.cpp: Added. + (WebKit::WebHTTPBody::initialize): + (WebKit::WebHTTPBody::reset): + (WebKit::WebHTTPBody::assign): + (WebKit::WebHTTPBody::elementCount): + (WebKit::WebHTTPBody::elementAt): + (WebKit::WebHTTPBody::appendData): + (WebKit::WebHTTPBody::appendFile): + (WebKit::WebHTTPBody::identifier): + (WebKit::WebHTTPBody::setIdentifier): + (WebKit::WebHTTPBody::WebHTTPBody): + (WebKit::WebHTTPBody::operator=): + (WebKit::WebHTTPBody::operator PassRefPtr<FormData>): + (WebKit::WebHTTPBody::ensureMutable): + * src/WebHistoryItem.cpp: Added. + (WebKit::WebHistoryItem::initialize): + (WebKit::WebHistoryItem::reset): + (WebKit::WebHistoryItem::assign): + (WebKit::WebHistoryItem::urlString): + (WebKit::WebHistoryItem::setURLString): + (WebKit::WebHistoryItem::originalURLString): + (WebKit::WebHistoryItem::setOriginalURLString): + (WebKit::WebHistoryItem::referrer): + (WebKit::WebHistoryItem::setReferrer): + (WebKit::WebHistoryItem::target): + (WebKit::WebHistoryItem::setTarget): + (WebKit::WebHistoryItem::parent): + (WebKit::WebHistoryItem::setParent): + (WebKit::WebHistoryItem::title): + (WebKit::WebHistoryItem::setTitle): + (WebKit::WebHistoryItem::alternateTitle): + (WebKit::WebHistoryItem::setAlternateTitle): + (WebKit::WebHistoryItem::lastVisitedTime): + (WebKit::WebHistoryItem::setLastVisitedTime): + (WebKit::WebHistoryItem::scrollOffset): + (WebKit::WebHistoryItem::setScrollOffset): + (WebKit::WebHistoryItem::isTargetItem): + (WebKit::WebHistoryItem::setIsTargetItem): + (WebKit::WebHistoryItem::visitCount): + (WebKit::WebHistoryItem::setVisitCount): + (WebKit::WebHistoryItem::documentState): + (WebKit::WebHistoryItem::setDocumentState): + (WebKit::WebHistoryItem::httpContentType): + (WebKit::WebHistoryItem::setHTTPContentType): + (WebKit::WebHistoryItem::httpBody): + (WebKit::WebHistoryItem::setHTTPBody): + (WebKit::WebHistoryItem::children): + (WebKit::WebHistoryItem::setChildren): + (WebKit::WebHistoryItem::appendToChildren): + (WebKit::WebHistoryItem::WebHistoryItem): + (WebKit::WebHistoryItem::operator=): + (WebKit::WebHistoryItem::operator PassRefPtr<HistoryItem>): + (WebKit::WebHistoryItem::ensureMutable): + * src/WebImageCG.cpp: Added. + (WebKit::WebImage::fromData): + (WebKit::WebImage::reset): + (WebKit::WebImage::assign): + (WebKit::WebImage::isNull): + (WebKit::WebImage::size): + (WebKit::WebImage::WebImage): + (WebKit::WebImage::operator=): + * src/WebImageSkia.cpp: Added. + (WebKit::WebImage::fromData): + (WebKit::WebImage::reset): + (WebKit::WebImage::assign): + (WebKit::WebImage::isNull): + (WebKit::WebImage::size): + (WebKit::WebImage::WebImage): + (WebKit::WebImage::operator=): + +2009-11-09 Yaar Schnitman <yaar@chromium.src> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebData...WebElement + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebData.cpp: Added. + (WebKit::WebData::reset): + (WebKit::WebData::assign): + (WebKit::WebData::size): + (WebKit::WebData::data): + (WebKit::WebData::WebData): + (WebKit::WebData::operator=): + (WebKit::WebData::operator PassRefPtr<SharedBuffer>): + * src/WebDataSourceImpl.cpp: Added. + (WebKit::WebDataSourceImpl::create): + (WebKit::WebDataSourceImpl::originalRequest): + (WebKit::WebDataSourceImpl::request): + (WebKit::WebDataSourceImpl::response): + (WebKit::WebDataSourceImpl::hasUnreachableURL): + (WebKit::WebDataSourceImpl::unreachableURL): + (WebKit::WebDataSourceImpl::redirectChain): + (WebKit::WebDataSourceImpl::pageTitle): + (WebKit::WebDataSourceImpl::navigationType): + (WebKit::WebDataSourceImpl::triggeringEventTime): + (WebKit::WebDataSourceImpl::extraData): + (WebKit::WebDataSourceImpl::setExtraData): + (WebKit::WebDataSourceImpl::toWebNavigationType): + (WebKit::WebDataSourceImpl::endOfRedirectChain): + (WebKit::WebDataSourceImpl::clearRedirectChain): + (WebKit::WebDataSourceImpl::appendRedirect): + (WebKit::WebDataSourceImpl::setNextPluginLoadObserver): + (WebKit::WebDataSourceImpl::WebDataSourceImpl): + (WebKit::WebDataSourceImpl::~WebDataSourceImpl): + * src/WebDataSourceImpl.h: Added. + (WebKit::WebDataSourceImpl::fromDocumentLoader): + (WebKit::WebDataSourceImpl::hasRedirectChain): + (WebKit::WebDataSourceImpl::releasePluginLoadObserver): + * src/WebDatabase.cpp: Added. + (WebKit::WebDatabase::reset): + (WebKit::WebDatabase::assign): + (WebKit::WebDatabase::name): + (WebKit::WebDatabase::displayName): + (WebKit::WebDatabase::estimatedSize): + (WebKit::WebDatabase::securityOrigin): + (WebKit::WebDatabase::setObserver): + (WebKit::WebDatabase::observer): + (WebKit::WebDatabase::updateDatabaseSize): + (WebKit::WebDatabase::WebDatabase): + (WebKit::WebDatabase::operator=): + (WebKit::WebDatabase::operator WTF::PassRefPtr<Database>): + * src/WebDevToolsAgentPrivate.h: Added. + * src/WebDragData.cpp: Added. + (WebKit::WebDragData::initialize): + (WebKit::WebDragData::reset): + (WebKit::WebDragData::assign): + (WebKit::WebDragData::url): + (WebKit::WebDragData::setURL): + (WebKit::WebDragData::urlTitle): + (WebKit::WebDragData::setURLTitle): + (WebKit::WebDragData::fileExtension): + (WebKit::WebDragData::setFileExtension): + (WebKit::WebDragData::hasFileNames): + (WebKit::WebDragData::fileNames): + (WebKit::WebDragData::setFileNames): + (WebKit::WebDragData::appendToFileNames): + (WebKit::WebDragData::plainText): + (WebKit::WebDragData::setPlainText): + (WebKit::WebDragData::htmlText): + (WebKit::WebDragData::setHTMLText): + (WebKit::WebDragData::htmlBaseURL): + (WebKit::WebDragData::setHTMLBaseURL): + (WebKit::WebDragData::fileContentFileName): + (WebKit::WebDragData::setFileContentFileName): + (WebKit::WebDragData::fileContent): + (WebKit::WebDragData::setFileContent): + (WebKit::WebDragData::WebDragData): + (WebKit::WebDragData::operator=): + (WebKit::WebDragData::operator WTF::PassRefPtr<WebCore::ChromiumDataObject>): + (WebKit::WebDragData::ensureMutable): + * src/WebElement.cpp: Added. + (WebKit::WebElement::WebElement): + (WebKit::WebElement::operator=): + (WebKit::WebElement::operator WTF::PassRefPtr<Element>): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + WebPo*.h and WebRunetimeFeatures.h Chromium API headers. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebPoint.h: Added. + (WebKit::WebPoint::WebPoint): + (WebKit::WebPoint::operator=): + (WebKit::WebPoint::operator WebCore::IntPoint): + (WebKit::WebPoint::operator gfx::Point): + (WebKit::operator==): + (WebKit::operator!=): + * public/WebPopupMenu.h: Added. + * public/WebPopupMenuInfo.h: Added. + (WebKit::WebPopupMenuInfo::Item::): + * public/WebRuntimeFeatures.h: Added. + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + WebPa*.h and WebPl*.h Chromium API headers. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebPasswordAutocompleteListener.h: Added. + (WebKit::WebPasswordAutocompleteListener::~WebPasswordAutocompleteListener): + * public/WebPasswordFormData.h: Added. + (WebKit::WebPasswordFormData::isValid): + * public/WebPlugin.h: Added. + (WebKit::WebPlugin::~WebPlugin): + * public/WebPluginContainer.h: Added. + (WebKit::WebPluginContainer::~WebPluginContainer): + * public/WebPluginListBuilder.h: Added. + * public/WebPluginParams.h: Added. + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebBindging ... WebCursorInfo + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebBindings.cpp: Added. + (WebKit::WebBindings::construct): + (WebKit::WebBindings::createObject): + (WebKit::WebBindings::enumerate): + (WebKit::WebBindings::evaluate): + (WebKit::WebBindings::evaluateHelper): + (WebKit::WebBindings::getIntIdentifier): + (WebKit::WebBindings::getProperty): + (WebKit::WebBindings::getStringIdentifier): + (WebKit::WebBindings::getStringIdentifiers): + (WebKit::WebBindings::hasMethod): + (WebKit::WebBindings::hasProperty): + (WebKit::WebBindings::identifierIsString): + (WebKit::WebBindings::intFromIdentifier): + (WebKit::WebBindings::initializeVariantWithStringCopy): + (WebKit::WebBindings::invoke): + (WebKit::WebBindings::invokeDefault): + (WebKit::WebBindings::releaseObject): + (WebKit::WebBindings::releaseVariantValue): + (WebKit::WebBindings::removeProperty): + (WebKit::WebBindings::retainObject): + (WebKit::WebBindings::setException): + (WebKit::WebBindings::setProperty): + (WebKit::WebBindings::unregisterObject): + (WebKit::WebBindings::utf8FromIdentifier): + (WebKit::WebBindings::extractIdentifierData): + (WebKit::getEvent): + (WebKit::getDragDataImpl): + (WebKit::getRangeImpl): + (WebKit::WebBindings::getDragData): + (WebKit::WebBindings::isDragEvent): + (WebKit::WebBindings::getRange): + * src/WebCString.cpp: Added. + (WebKit::WebCString::reset): + (WebKit::WebCString::assign): + (WebKit::WebCString::length): + (WebKit::WebCString::data): + (WebKit::WebCString::utf16): + (WebKit::WebCString::fromUTF16): + (WebKit::WebCString::WebCString): + (WebKit::WebCString::operator=): + (WebKit::WebCString::operator WebCore::CString): + * src/WebCache.cpp: Added. + (WebKit::ToResourceTypeStat): + (WebKit::WebCache::setCapacities): + (WebKit::WebCache::clear): + (WebKit::WebCache::getUsageStats): + (WebKit::WebCache::getResourceTypeStats): + * src/WebColor.cpp: Added. + (WebKit::toCSSValueKeyword): + (WebKit::setNamedColors): + * src/WebCrossOriginPreflightResultCache.cpp: Added. + (WebKit::WebCrossOriginPreflightResultCache::clear): + * src/WebCursorInfo.cpp: Added. + (WebKit::WebCursorInfo::WebCursorInfo): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Up-streaming Chromium API src files: WebAccessibilty + + https://bugs.webkit.org/show_bug.cgi?id=31276 + + * src/WebAccessibilityCache.cpp: Added. + (WebKit::WebAccessibilityCache::enableAccessibility): + * src/WebAccessibilityCacheImpl.cpp: Added. + (WebKit::toAccessibilityObject): + (WebKit::WebAccessibilityCache::create): + (WebKit::WebAccessibilityCacheImpl::WeakHandle::create): + (WebKit::WebAccessibilityCacheImpl::WeakHandle::WeakHandle): + (WebKit::WebAccessibilityCacheImpl::WeakHandle::detach): + (WebKit::WebAccessibilityCacheImpl::WebAccessibilityCacheImpl): + (WebKit::WebAccessibilityCacheImpl::~WebAccessibilityCacheImpl): + (WebKit::WebAccessibilityCacheImpl::initialize): + (WebKit::WebAccessibilityCacheImpl::getObjectById): + (WebKit::WebAccessibilityCacheImpl::isValidId): + (WebKit::WebAccessibilityCacheImpl::remove): + (WebKit::WebAccessibilityCacheImpl::clear): + (WebKit::WebAccessibilityCacheImpl::addOrGetId): + * src/WebAccessibilityCacheImpl.h: Added. + (WebKit::WebAccessibilityCacheImpl::isInitialized): + * src/WebAccessibilityObject.cpp: Added. + (WebKit::WebAccessibilityObject::reset): + (WebKit::WebAccessibilityObject::assign): + (WebKit::WebAccessibilityObject::accessibilityDescription): + (WebKit::WebAccessibilityObject::actionVerb): + (WebKit::WebAccessibilityObject::canSetFocusAttribute): + (WebKit::WebAccessibilityObject::childCount): + (WebKit::WebAccessibilityObject::childAt): + (WebKit::WebAccessibilityObject::firstChild): + (WebKit::WebAccessibilityObject::focusedChild): + (WebKit::WebAccessibilityObject::lastChild): + (WebKit::WebAccessibilityObject::nextSibling): + (WebKit::WebAccessibilityObject::parentObject): + (WebKit::WebAccessibilityObject::previousSibling): + (WebKit::WebAccessibilityObject::isAnchor): + (WebKit::WebAccessibilityObject::isChecked): + (WebKit::WebAccessibilityObject::isFocused): + (WebKit::WebAccessibilityObject::isEnabled): + (WebKit::WebAccessibilityObject::isHovered): + (WebKit::WebAccessibilityObject::isIndeterminate): + (WebKit::WebAccessibilityObject::isMultiSelect): + (WebKit::WebAccessibilityObject::isOffScreen): + (WebKit::WebAccessibilityObject::isPasswordField): + (WebKit::WebAccessibilityObject::isPressed): + (WebKit::WebAccessibilityObject::isReadOnly): + (WebKit::WebAccessibilityObject::isVisited): + (WebKit::WebAccessibilityObject::boundingBoxRect): + (WebKit::WebAccessibilityObject::helpText): + (WebKit::WebAccessibilityObject::hitTest): + (WebKit::WebAccessibilityObject::keyboardShortcut): + (WebKit::WebAccessibilityObject::performDefaultAction): + (WebKit::WebAccessibilityObject::roleValue): + (WebKit::WebAccessibilityObject::stringValue): + (WebKit::WebAccessibilityObject::title): + (WebKit::WebAccessibilityObject::WebAccessibilityObject): + (WebKit::WebAccessibilityObject::operator=): + (WebKit::WebAccessibilityObject::operator WTF::PassRefPtr<WebCore::AccessibilityObject>): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstreaming Chromium API: Platform specific files + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/gtk/WebFontInfo.h: Added. + * public/gtk/WebInputEventFactory.h: Added. + * public/gtk/WebScreenInfoFactory.h: Added. + * public/linux/WebFontRendering.h: Added. + * public/linux/WebSandboxSupport.h: Added. + * public/mac/WebInputEventFactory.h: Added. + * public/mac/WebScreenInfoFactory.h: Added. + * public/win/WebInputEventFactory.h: Added. + * public/win/WebSandboxSupport.h: Added. + * public/win/WebScreenInfoFactory.h: Added. + * public/win/WebThemeEngine.h: Added. + * public/x11/WebScreenInfoFactory.h: Added. + +2009-11-09 David Levin <levin@chromium.org> + + Reviewed by Dmitry Titov. + + Change struct ResourceRequest to class ResourceRequest per + http://trac.webkit.org/changeset/50625. + + * public/WebURLRequest.h: + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream remaining Chromium API WebN*.h headers. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebNonCopyable.h: Added. + (WebKit::WebNonCopyable::WebNonCopyable): + (WebKit::WebNonCopyable::~WebNonCopyable): + * public/WebNotification.h: Added. + (WebKit::WebNotification::WebNotification): + (WebKit::WebNotification::~WebNotification): + (WebKit::WebNotification::operator=): + (WebKit::WebNotification::equals): + (WebKit::operator==): + (WebKit::operator!=): + (WebKit::operator<): + * public/WebNotificationPermissionCallback.h: Added. + (WebKit::WebNotificationPermissionCallback::~WebNotificationPermissionCallback): + * public/WebNotificationPresenter.h: Added. + (WebKit::WebNotificationPresenter::): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream Chromium API headers WebMessage through WebNavigation. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebMessagePortChannel.h: Added. + (WebKit::WebMessagePortChannel::~WebMessagePortChannel): + * public/WebMessagePortChannelClient.h: Added. + (WebKit::WebMessagePortChannelClient::~WebMessagePortChannelClient): + * public/WebMimeRegistry.h: Added. + (WebKit::WebMimeRegistry::): + (WebKit::WebMimeRegistry::~WebMimeRegistry): + * public/WebNavigationPolicy.h: Added. + (WebKit::): + * public/WebNavigationType.h: Added. + (WebKit::): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstreaming the Chromium WebKit API: WebScreenInfo to WebSharedWorkerRepo. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebScreenInfo.h: Added. + (WebKit::WebScreenInfo::WebScreenInfo): + * public/WebScriptController.h: Added. + * public/WebScriptSource.h: Added. + (WebKit::WebScriptSource::WebScriptSource): + * public/WebSearchableFormData.h: Added. + (WebKit::WebSearchableFormData::isValid): + (WebKit::WebSearchableFormData::url): + (WebKit::WebSearchableFormData::encoding): + * public/WebSecurityOrigin.h: Added. + (WebKit::WebSecurityOrigin::~WebSecurityOrigin): + (WebKit::WebSecurityOrigin::WebSecurityOrigin): + (WebKit::WebSecurityOrigin::operator=): + (WebKit::WebSecurityOrigin::isNull): + * public/WebSecurityPolicy.h: Added. + * public/WebSettings.h: Added. + (WebKit::WebSettings::~WebSettings): + * public/WebSharedWorker.h: Added. + (WebKit::WebSharedWorker::~WebSharedWorker): + * public/WebSharedWorkerRepository.h: Added. + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream Chromium API headers Webkit.h thru WebMediaPlayerClient.h. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebKit.h: Added. + * public/WebKitClient.h: Added. + (WebKit::WebKitClient::~WebKitClient): + * public/WebLocalizedString.h: Added. + (WebKit::WebLocalizedString::): + * public/WebMediaPlayer.h: Added. + (WebKit::WebTimeRange::WebTimeRange): + (WebKit::WebMediaPlayer::): + (WebKit::WebMediaPlayer::~WebMediaPlayer): + * public/WebMediaPlayerAction.h: Added. + (WebKit::WebMediaPlayerAction::): + (WebKit::WebMediaPlayerAction::WebMediaPlayerAction): + * public/WebMediaPlayerClient.h: Added. + (WebKit::WebMediaPlayerClient::~WebMediaPlayerClient): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream rest of WebH*.h and WebI*.h Chromium API headers. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebHTTPBody.h: Added. + (WebKit::WebHTTPBody::Element::): + (WebKit::WebHTTPBody::~WebHTTPBody): + (WebKit::WebHTTPBody::WebHTTPBody): + (WebKit::WebHTTPBody::operator=): + (WebKit::WebHTTPBody::isNull): + * public/WebHTTPHeaderVisitor.h: Added. + (WebKit::WebHTTPHeaderVisitor::~WebHTTPHeaderVisitor): + * public/WebHistoryItem.h: Added. + (WebKit::WebHistoryItem::~WebHistoryItem): + (WebKit::WebHistoryItem::WebHistoryItem): + (WebKit::WebHistoryItem::operator=): + (WebKit::WebHistoryItem::isNull): + * public/WebImage.h: Added. + (WebKit::WebImage::~WebImage): + (WebKit::WebImage::WebImage): + (WebKit::WebImage::operator=): + (WebKit::WebImage::getSkBitmap): + (WebKit::WebImage::init): + (WebKit::WebImage::getCGImageRef): + * public/WebInputEvent.h: Added. + (WebKit::WebInputEvent::WebInputEvent): + (WebKit::WebInputEvent::): + (WebKit::WebInputEvent::isKeyboardEventType): + (WebKit::WebKeyboardEvent::WebKeyboardEvent): + (WebKit::WebMouseEvent::): + (WebKit::WebMouseEvent::WebMouseEvent): + (WebKit::WebMouseWheelEvent::WebMouseWheelEvent): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Eric Seidel. + + Upstreaming the Chromium WebKit API: WebSockets and WebStorage. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebSocketStreamError.h: Added. + * public/WebSocketStreamHandle.h: Added. + (WebKit::WebSocketStreamHandle::~WebSocketStreamHandle): + * public/WebSocketStreamHandleClient.h: Added. + * public/WebStorageArea.h: Added. + (WebKit::WebStorageArea::~WebStorageArea): + * public/WebStorageEventDispatcher.h: Added. + (WebKit::WebStorageEventDispatcher::~WebStorageEventDispatcher): + * public/WebStorageNamespace.h: Added. + (WebKit::WebStorageNamespace::~WebStorageNamespace): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstreaming the Chromium WebKit API: WebString and other basic objects. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebRange.h: Added. + (WebKit::WebRange::~WebRange): + (WebKit::WebRange::WebRange): + (WebKit::WebRange::operator=): + (WebKit::WebRange::isNull): + * public/WebRect.h: Added. + (WebKit::WebRect::isEmpty): + (WebKit::WebRect::WebRect): + (WebKit::WebRect::operator=): + (WebKit::WebRect::operator WebCore::IntRect): + (WebKit::WebRect::operator gfx::Rect): + (WebKit::operator==): + (WebKit::operator!=): + * public/WebSize.h: Added. + (WebKit::WebSize::isEmpty): + (WebKit::WebSize::WebSize): + (WebKit::WebSize::operator=): + (WebKit::WebSize::operator WebCore::IntSize): + (WebKit::WebSize::operator gfx::Size): + (WebKit::operator==): + (WebKit::operator!=): + * public/WebString.h: Added. + (WebKit::WebString::~WebString): + (WebKit::WebString::WebString): + (WebKit::WebString::operator=): + (WebKit::WebString::isEmpty): + (WebKit::WebString::isNull): + (WebKit::WebString::operator string16): + (WebKit::WebString::operator NullableString16): + (WebKit::WebString::fromUTF8): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Eric Seidel. + + Upstreaming the Chromium WebKit API: WebText* + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebTextAffinity.h: Added. + (WebKit::): + * public/WebTextDirection.h: Added. + (WebKit::): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream remainder of WebE*.h and WebF*.h Chromium API headers. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebEditingAction.h: Added. + (WebKit::): + * public/WebFileChooserCompletion.h: Added. + (WebKit::WebFileChooserCompletion::~WebFileChooserCompletion): + * public/WebFindOptions.h: Added. + (WebKit::WebFindOptions::WebFindOptions): + * public/WebFontCache.h: Added. + * public/WebFrame.h: Added. + (WebKit::WebFrame::~WebFrame): + * public/WebFrameClient.h: Added. + (WebKit::WebFrameClient::createPlugin): + (WebKit::WebFrameClient::createWorker): + (WebKit::WebFrameClient::createSharedWorker): + (WebKit::WebFrameClient::createMediaPlayer): + (WebKit::WebFrameClient::willClose): + (WebKit::WebFrameClient::loadURLExternally): + (WebKit::WebFrameClient::decidePolicyForNavigation): + (WebKit::WebFrameClient::canHandleRequest): + (WebKit::WebFrameClient::cannotHandleRequestError): + (WebKit::WebFrameClient::cancelledError): + (WebKit::WebFrameClient::unableToImplementPolicyWithError): + (WebKit::WebFrameClient::willSubmitForm): + (WebKit::WebFrameClient::willPerformClientRedirect): + (WebKit::WebFrameClient::didCancelClientRedirect): + (WebKit::WebFrameClient::didCompleteClientRedirect): + (WebKit::WebFrameClient::didCreateDataSource): + (WebKit::WebFrameClient::didStartProvisionalLoad): + (WebKit::WebFrameClient::didReceiveServerRedirectForProvisionalLoad): + (WebKit::WebFrameClient::didFailProvisionalLoad): + (WebKit::WebFrameClient::didReceiveDocumentData): + (WebKit::WebFrameClient::didCommitProvisionalLoad): + (WebKit::WebFrameClient::didClearWindowObject): + (WebKit::WebFrameClient::didCreateDocumentElement): + (WebKit::WebFrameClient::didReceiveTitle): + (WebKit::WebFrameClient::didFinishDocumentLoad): + (WebKit::WebFrameClient::didHandleOnloadEvents): + (WebKit::WebFrameClient::didFailLoad): + (WebKit::WebFrameClient::didFinishLoad): + (WebKit::WebFrameClient::didChangeLocationWithinPage): + (WebKit::WebFrameClient::didUpdateCurrentHistoryItem): + (WebKit::WebFrameClient::assignIdentifierToRequest): + (WebKit::WebFrameClient::willSendRequest): + (WebKit::WebFrameClient::didReceiveResponse): + (WebKit::WebFrameClient::didFinishResourceLoad): + (WebKit::WebFrameClient::didFailResourceLoad): + (WebKit::WebFrameClient::didLoadResourceFromMemoryCache): + (WebKit::WebFrameClient::didDisplayInsecureContent): + (WebKit::WebFrameClient::didRunInsecureContent): + (WebKit::WebFrameClient::allowScript): + (WebKit::WebFrameClient::didExhaustMemoryAvailableForScript): + (WebKit::WebFrameClient::didCreateScriptContext): + (WebKit::WebFrameClient::didDestroyScriptContext): + (WebKit::WebFrameClient::didCreateIsolatedScriptContext): + (WebKit::WebFrameClient::didChangeContentsSize): + (WebKit::WebFrameClient::didChangeScrollOffset): + (WebKit::WebFrameClient::reportFindInPageMatchCount): + (WebKit::WebFrameClient::reportFindInPageSelection): + (WebKit::WebFrameClient::~WebFrameClient): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream WebDevTools*.h and WebDrag*.h Chromium API headers. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebDevToolsAgent.h: Added. + (WebKit::WebDevToolsAgent::~WebDevToolsAgent): + * public/WebDevToolsAgentClient.h: Added. + (WebKit::WebDevToolsAgentClient::~WebDevToolsAgentClient): + * public/WebDevToolsFrontend.h: Added. + (WebKit::WebDevToolsFrontend::~WebDevToolsFrontend): + * public/WebDevToolsFrontendClient.h: Added. + (WebKit::WebDevToolsFrontendClient::WebDevToolsFrontendClient): + (WebKit::WebDevToolsFrontendClient::~WebDevToolsFrontendClient): + * public/WebDragData.h: Added. + (WebKit::WebDragData::~WebDragData): + (WebKit::WebDragData::WebDragData): + (WebKit::WebDragData::operator=): + (WebKit::WebDragData::isNull): + * public/WebDragOperation.h: Added. + (WebKit::): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstreaming the Chromium WebKit API: WebURL and friends. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebURL.h: Added. + (WebKit::WebURL::~WebURL): + (WebKit::WebURL::WebURL): + (WebKit::WebURL::operator=): + (WebKit::WebURL::assign): + (WebKit::WebURL::spec): + (WebKit::WebURL::parsed): + (WebKit::WebURL::isValid): + (WebKit::WebURL::isEmpty): + (WebKit::WebURL::isNull): + (WebKit::WebURL::operator GURL): + * public/WebURLError.h: Added. + (WebKit::WebURLError::WebURLError): + * public/WebURLLoader.h: Added. + (WebKit::WebURLLoader::~WebURLLoader): + * public/WebURLLoaderClient.h: Added. + (WebKit::WebURLLoaderClient::~WebURLLoaderClient): + * public/WebURLRequest.h: Added. + (WebKit::WebURLRequest::): + (WebKit::WebURLRequest::~WebURLRequest): + (WebKit::WebURLRequest::WebURLRequest): + (WebKit::WebURLRequest::operator=): + * public/WebURLResponse.h: Added. + (WebKit::WebURLResponse::~WebURLResponse): + (WebKit::WebURLResponse::WebURLResponse): + (WebKit::WebURLResponse::operator=): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstreaming the Chromium WebKit API: WebVector to WebWorkerClient + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebVector.h: Added. + (WebKit::WebVector::~WebVector): + (WebKit::WebVector::WebVector): + (WebKit::WebVector::operator=): + (WebKit::WebVector::assign): + (WebKit::WebVector::size): + (WebKit::WebVector::isEmpty): + (WebKit::WebVector::operator[]): + (WebKit::WebVector::data): + (WebKit::WebVector::swap): + (WebKit::WebVector::initialize): + (WebKit::WebVector::initializeFrom): + (WebKit::WebVector::destroy): + * public/WebView.h: Added. + (WebKit::WebView::~WebView): + * public/WebViewClient.h: Added. + (WebKit::WebViewClient::createView): + (WebKit::WebViewClient::createPopupMenu): + (WebKit::WebViewClient::didAddMessageToConsole): + (WebKit::WebViewClient::printPage): + (WebKit::WebViewClient::notificationPresenter): + (WebKit::WebViewClient::didStartLoading): + (WebKit::WebViewClient::didStopLoading): + (WebKit::WebViewClient::shouldBeginEditing): + (WebKit::WebViewClient::shouldEndEditing): + (WebKit::WebViewClient::shouldInsertNode): + (WebKit::WebViewClient::shouldInsertText): + (WebKit::WebViewClient::shouldChangeSelectedRange): + (WebKit::WebViewClient::shouldDeleteRange): + (WebKit::WebViewClient::shouldApplyStyle): + (WebKit::WebViewClient::isSmartInsertDeleteEnabled): + (WebKit::WebViewClient::isSelectTrailingWhitespaceEnabled): + (WebKit::WebViewClient::setInputMethodEnabled): + (WebKit::WebViewClient::didBeginEditing): + (WebKit::WebViewClient::didChangeSelection): + (WebKit::WebViewClient::didChangeContents): + (WebKit::WebViewClient::didExecuteCommand): + (WebKit::WebViewClient::didEndEditing): + (WebKit::WebViewClient::handleCurrentKeyboardEvent): + (WebKit::WebViewClient::spellCheck): + (WebKit::WebViewClient::autoCorrectWord): + (WebKit::WebViewClient::showSpellingUI): + (WebKit::WebViewClient::isShowingSpellingUI): + (WebKit::WebViewClient::updateSpellingUIWithMisspelledWord): + (WebKit::WebViewClient::runFileChooser): + (WebKit::WebViewClient::runModalAlertDialog): + (WebKit::WebViewClient::runModalConfirmDialog): + (WebKit::WebViewClient::runModalPromptDialog): + (WebKit::WebViewClient::runModalBeforeUnloadDialog): + (WebKit::WebViewClient::setStatusText): + (WebKit::WebViewClient::setMouseOverURL): + (WebKit::WebViewClient::setKeyboardFocusURL): + (WebKit::WebViewClient::setToolTipText): + (WebKit::WebViewClient::showContextMenu): + (WebKit::WebViewClient::startDragging): + (WebKit::WebViewClient::acceptsLoadDrops): + (WebKit::WebViewClient::focusNext): + (WebKit::WebViewClient::focusPrevious): + (WebKit::WebViewClient::navigateBackForwardSoon): + (WebKit::WebViewClient::historyBackListCount): + (WebKit::WebViewClient::historyForwardListCount): + (WebKit::WebViewClient::didAddHistoryItem): + (WebKit::WebViewClient::focusAccessibilityObject): + (WebKit::WebViewClient::didUpdateInspectorSettings): + (WebKit::WebViewClient::queryAutofillSuggestions): + (WebKit::WebViewClient::removeAutofillSuggestions): + (WebKit::WebViewClient::~WebViewClient): + * public/WebWidget.h: Added. + (WebKit::WebWidget::~WebWidget): + * public/WebWidgetClient.h: Added. + (WebKit::WebWidgetClient::didInvalidateRect): + (WebKit::WebWidgetClient::didScrollRect): + (WebKit::WebWidgetClient::didFocus): + (WebKit::WebWidgetClient::didBlur): + (WebKit::WebWidgetClient::didChangeCursor): + (WebKit::WebWidgetClient::closeWidgetSoon): + (WebKit::WebWidgetClient::show): + (WebKit::WebWidgetClient::runModal): + (WebKit::WebWidgetClient::windowRect): + (WebKit::WebWidgetClient::setWindowRect): + (WebKit::WebWidgetClient::windowResizerRect): + (WebKit::WebWidgetClient::rootWindowRect): + (WebKit::WebWidgetClient::screenInfo): + (WebKit::WebWidgetClient::~WebWidgetClient): + * public/WebWorker.h: Added. + (WebKit::WebWorker::~WebWorker): + * public/WebWorkerClient.h: Added. + (WebKit::WebWorkerClient::~WebWorkerClient): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream WebData*.h Chromium API files. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebData.h: Added. + (WebKit::WebData::~WebData): + (WebKit::WebData::WebData): + (WebKit::WebData::operator=): + (WebKit::WebData::isEmpty): + (WebKit::WebData::isNull): + * public/WebDataSource.h: Added. + (WebKit::WebDataSource::ExtraData::~ExtraData): + (WebKit::WebDataSource::~WebDataSource): + * public/WebDatabase.h: Added. + (WebKit::WebDatabase::WebDatabase): + (WebKit::WebDatabase::~WebDatabase): + (WebKit::WebDatabase::operator=): + (WebKit::WebDatabase::isNull): + * public/WebDatabaseObserver.h: Added. + (WebKit::WebDatabaseObserver::~WebDatabaseObserver): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstream the last of the Chromium API WebC*.h files. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebConsoleMessage.h: Added. + (WebKit::WebConsoleMessage::): + (WebKit::WebConsoleMessage::WebConsoleMessage): + * public/WebContextMenuData.h: Added. + (WebKit::WebContextMenuData::): + * public/WebCookie.h: Added. + (WebKit::WebCookie::WebCookie): + * public/WebCrossOriginPreflightResultCache.h: Added. + * public/WebCursorInfo.h: Added. + (WebKit::WebCursorInfo::): + (WebKit::WebCursorInfo::WebCursorInfo): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + More WebC*.h upstreaming. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebCString.h: Added. + (WebKit::WebCString::~WebCString): + (WebKit::WebCString::WebCString): + (WebKit::WebCString::operator=): + (WebKit::WebCString::isEmpty): + (WebKit::WebCString::isNull): + (WebKit::WebCString::operator std::string): + (WebKit::WebCString::fromUTF16): + * public/WebColorName.h: Added. + (WebKit::): + * public/WebCommon.h: Added. + * public/WebCommonWorkerClient.h: Added. + (WebKit::WebCommonWorkerClient::~WebCommonWorkerClient): + * public/WebCompositionCommand.h: Added. + (WebKit::): + +2009-11-09 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Dimitri Glazkov. + + Upstreaming the Chromium WebKit API: WebNode.h and friends are thin wrappers around WebCore::Nodes + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * public/WebElement.h: Added. + (WebKit::WebElement::WebElement): + (WebKit::WebElement::operator=): + (WebKit::WebElement::assign): + * public/WebFormElement.h: Added. + (WebKit::WebFormElement::~WebFormElement): + (WebKit::WebFormElement::WebFormElement): + (WebKit::WebFormElement::operator=): + (WebKit::WebFormElement::assign): + * public/WebInputElement.h: Added. + (WebKit::WebInputElement::WebInputElement): + (WebKit::WebInputElement::operator=): + (WebKit::WebInputElement::assign): + * public/WebNode.h: Added. + (WebKit::WebNode::~WebNode): + (WebKit::WebNode::WebNode): + (WebKit::WebNode::operator=): + (WebKit::WebNode::isNull): + (WebKit::WebNode::toElement): + (WebKit::WebNode::unwrap): + (WebKit::WebNode::constUnwrap): + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + WebKit Chromium API upstreaming, WebBindings.h through WebColor.h. + + * public/WebBindings.h: Added. + * public/WebCache.h: Added. + * public/WebCanvas.h: Added. + * public/WebClipboard.h: Added. + (WebKit::WebClipboard::): + (WebKit::WebClipboard::~WebClipboard): + * public/WebColor.h: Added. + +2009-11-09 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Starting upstreaming the Chromium WebKit API. public/ contains header files only. + + https://bugs.webkit.org/show_bug.cgi?id=28394 + + * ChangeLog: First!! + * public: Added. + * public/WebAccessibilityCache.h: Added. + (WebKit::WebAccessibilityCache::WebAccessibilityCache): + (WebKit::WebAccessibilityCache::~WebAccessibilityCache): + * public/WebAccessibilityObject.h: Added. + (WebKit::WebAccessibilityObject::~WebAccessibilityObject): + (WebKit::WebAccessibilityObject::WebAccessibilityObject): + (WebKit::WebAccessibilityObject::operator=): + (WebKit::WebAccessibilityObject::isNull): + * public/WebAccessibilityRole.h: Added. + (WebKit::): + * public/WebApplicationCacheHost.h: Added. + (WebKit::WebApplicationCacheHost::): + (WebKit::WebApplicationCacheHost::~WebApplicationCacheHost): + * public/WebApplicationCacheHostClient.h: Added. + (WebKit::WebApplicationCacheHostClient::~WebApplicationCacheHostClient): diff --git a/WebKit/chromium/DEPS b/WebKit/chromium/DEPS index 5f5b9b8..fc90187 100644 --- a/WebKit/chromium/DEPS +++ b/WebKit/chromium/DEPS @@ -35,18 +35,19 @@ vars = { 'chromium_deps_svn': 'http://src.chromium.org/svn/trunk/deps/third_party', # Dependencies' revisions to use: - 'chromium_rev': '28710', - 'google-url_rev': '119', - 'gtest_rev': '329', - 'gyp_rev': '685', - 'icu_rev': '27687', + 'chromium_rev': '31834', + 'google-url_rev': '120', + 'gtest_rev': '336', + 'gyp_rev': '751', + 'icu_rev': '31724', 'openvcdiff_rev': '28', - 'skia_rev': '376', - 'v8_rev': '3030', + 'ots_rev': '19', + 'skia_rev': '424', + 'v8_rev': '3276', # Windows: 'cygwin_rev': '11984', - 'ffmpeg_ia32_rev': '28488', + 'ffmpeg_ia32_rev': '30374', 'pthreads-win32_rev': '26716', 'python_24_rev': '22967', } @@ -55,8 +56,6 @@ deps = { # build tools 'build': Var('chromium_svn')+'/build@'+Var('chromium_rev'), - 'webkit/build': - Var('chromium_svn')+'/webkit/build@'+Var('chromium_rev'), 'tools/gyp': 'http://gyp.googlecode.com/svn/trunk@'+Var('gyp_rev'), @@ -120,6 +119,9 @@ deps = { 'third_party/npapi': Var('chromium_svn')+'/third_party/npapi@'+Var('chromium_rev'), + 'third_party/ots': + 'http://ots.googlecode.com/svn/trunk@'+Var('ots_rev'), + 'third_party/sqlite': Var('chromium_svn')+'/third_party/sqlite@'+Var('chromium_rev'), @@ -141,6 +143,14 @@ deps_os = { 'third_party/pthreads-win32': Var('chromium_deps_svn')+'/pthreads-win32@'+Var('pthreads-win32_rev'), }, + 'unix': { + # Linux, actually. + 'third_party/harfbuzz': + Var('chromium_svn')+'/third_party/harfbuzz@'+Var('chromium_rev'), + + 'tools/xdisplaycheck': + Var('chromium_svn')+'/tools/xdisplaycheck@'+Var('chromium_rev'), + }, } skip_child_includes = [ diff --git a/WebKit/chromium/README b/WebKit/chromium/README new file mode 100644 index 0000000..9173454 --- /dev/null +++ b/WebKit/chromium/README @@ -0,0 +1,41 @@ +This directory contains the Chromium WebKit API. + + +OVERVIEW + + The Chromium WebKit API provides a stable interface to WebCore without + revealing any of the WebCore or WTF types to the consumer. + + The 'public' directory contains the API headers, and the 'src' directory + contains the API implementation. The API is intended to be used either as a + shared or static library. + + +COMPATIBILITY + + No attempt is made to support runtime compatibility in a shared library + build. Instead, the API is intended to support backwards compatibility at + build time. C++ symbols are allowed in other words. + + +DEFINES + + WEBKIT_IMPLEMENTATION is defined when building the 'src' directory. + Consumers should not define this macro. + + WEBKIT_DLL is defined when building as a shared library. This should be + defined when building the 'src' directory, and it should also be defined by + the consumer to ensure proper linkage to the shared library. + + +BASIC TYPES + + Use of STL is prohibited except in cases where it would be allowed in + WebCore. This includes non-allocating uses: algorithms, numeric limits, etc. + WTF container classes should be used in the implementation of this API. + + The API includes some usage of WebCore types when WEBKIT_IMPLEMENTATION is + defined. This is only done for the convenience to the implementation, and + should not be considered part of the Chromium WebKit API. Similarly, STL + types are assumed when WEBKIT_IMPLEMENTATION is not defined, which is done + for the convenience of the consumer. diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp new file mode 100644 index 0000000..c41bf5b --- /dev/null +++ b/WebKit/chromium/WebKit.gyp @@ -0,0 +1,403 @@ +# +# Copyright (C) 2009 Google 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: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * 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. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 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 +# OWNER 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. +# + +{ + 'includes': [ + 'features.gypi', + ], + 'variables': { + 'conditions': [ + # Location of the chromium src directory and target type is different + # if webkit is built inside chromium or as standalone project. + ['inside_chromium_build==0', { + # Webkit is being built outside of the full chromium project. + # e.g. via build-webkit --chromium + 'chromium_src_dir': '.', + # FIXME: To enable shared_library in linux all code (including + # dependencies) must be complied with -fPIC flag. That is + # pending on changes in gyp. + 'webkit_target_type': 'shared_library', + },{ + # WebKit is checked out in src/chromium/third_party/WebKit + 'chromium_src_dir': '../../../..', + 'webkit_target_type': 'static_library', + }], + # We can't turn on warnings on Windows and Linux until we upstream the + # WebKit API. + ['OS=="mac"', { + 'chromium_code': 1, + }], + # FIXME: To enable shared_library in linux all code (including + # dependencies) must be complied with -fPIC flag. That is + # pending on changes in gyp. + ['OS=="linux" or OS=="freebsd"', { + 'webkit_target_type': 'static_library', + }], + ], + }, + 'targets': [ + { + 'target_name': 'webkit', + 'type': '<(webkit_target_type)', + 'msvs_guid': '5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65', + 'dependencies': [ + '../../WebCore/WebCore.gyp/WebCore.gyp:webcore', + ], + 'include_dirs': [ + 'public', + 'src', + ], + 'defines': [ + 'WEBKIT_IMPLEMENTATION', + ], + 'sources': [ + 'public/gtk/WebInputEventFactory.h', + 'public/linux/WebFontRendering.h', + 'public/x11/WebScreenInfoFactory.h', + 'public/mac/WebInputEventFactory.h', + 'public/mac/WebScreenInfoFactory.h', + 'public/WebAccessibilityCache.h', + 'public/WebAccessibilityObject.h', + 'public/WebAccessibilityRole.h', + 'public/WebApplicationCacheHost.h', + 'public/WebApplicationCacheHostClient.h', + 'public/WebBindings.h', + 'public/WebCache.h', + 'public/WebCanvas.h', + 'public/WebClipboard.h', + 'public/WebColor.h', + 'public/WebColorName.h', + 'public/WebCommon.h', + 'public/WebCommonWorkerClient.h', + 'public/WebCompositionCommand.h', + 'public/WebConsoleMessage.h', + 'public/WebContextMenuData.h', + 'public/WebCookie.h', + 'public/WebCrossOriginPreflightResultCache.h', + 'public/WebCString.h', + 'public/WebCursorInfo.h', + 'public/WebData.h', + 'public/WebDatabase.h', + 'public/WebDatabaseObserver.h', + 'public/WebDataSource.h', + 'public/WebDevToolsAgent.h', + 'public/WebDevToolsAgentClient.h', + 'public/WebDevToolsFrontend.h', + 'public/WebDevToolsFrontendClient.h', + 'public/WebDevToolsMessageData.h', + 'public/WebDragData.h', + 'public/WebEditingAction.h', + 'public/WebElement.h', + 'public/WebFileChooserCompletion.h', + 'public/WebFindOptions.h', + 'public/WebFrame.h', + 'public/WebFrameClient.h', + 'public/WebFontCache.h', + 'public/WebFormElement.h', + 'public/WebHistoryItem.h', + 'public/WebHTTPBody.h', + 'public/WebImage.h', + 'public/WebInputElement.h', + 'public/WebInputEvent.h', + 'public/WebKit.h', + 'public/WebKitClient.h', + 'public/WebLocalizedString.h', + 'public/WebMediaPlayer.h', + 'public/WebMediaPlayerAction.h', + 'public/WebMediaPlayerClient.h', + 'public/WebMenuItemInfo.h', + 'public/WebMessagePortChannel.h', + 'public/WebMessagePortChannelClient.h', + 'public/WebMimeRegistry.h', + 'public/WebNavigationType.h', + 'public/WebNode.h', + 'public/WebNonCopyable.h', + 'public/WebNotification.h', + 'public/WebNotificationPresenter.h', + 'public/WebNotificationPermissionCallback.h', + 'public/WebPasswordAutocompleteListener.h', + 'public/WebPasswordFormData.h', + 'public/WebPlugin.h', + 'public/WebPluginContainer.h', + 'public/WebPluginListBuilder.h', + 'public/WebPoint.h', + 'public/WebPopupMenu.h', + 'public/WebPopupMenuInfo.h', + 'public/WebRange.h', + 'public/WebRect.h', + 'public/WebRegularExpression.h', + 'public/WebRuntimeFeatures.h', + 'public/WebScreenInfo.h', + 'public/WebScriptController.h', + 'public/WebScriptSource.h', + 'public/WebSearchableFormData.h', + 'public/WebSecurityOrigin.h', + 'public/WebSecurityPolicy.h', + 'public/WebSettings.h', + 'public/WebSharedWorker.h', + 'public/WebSharedWorkerRepository.h', + 'public/WebSize.h', + 'public/WebSocketStreamError.h', + 'public/WebSocketStreamHandle.h', + 'public/WebSocketStreamHandleClient.h', + 'public/WebStorageArea.h', + 'public/WebStorageEventDispatcher.h', + 'public/WebStorageNamespace.h', + 'public/WebString.h', + 'public/WebTextAffinity.h', + 'public/WebTextCaseSensitivity.h', + 'public/WebTextDirection.h', + 'public/WebURL.h', + 'public/WebURLError.h', + 'public/WebURLLoader.h', + 'public/WebURLLoaderClient.h', + 'public/WebURLRequest.h', + 'public/WebURLResponse.h', + 'public/WebVector.h', + 'public/WebView.h', + 'public/WebViewClient.h', + 'public/WebWidget.h', + 'public/WebWidgetClient.h', + 'public/WebWorker.h', + 'public/WebWorkerClient.h', + 'public/win/WebInputEventFactory.h', + 'public/win/WebSandboxSupport.h', + 'public/win/WebScreenInfoFactory.h', + 'public/win/WebScreenInfoFactory.h', + 'src/ApplicationCacheHost.cpp', + 'src/AssertMatchingEnums.cpp', + 'src/AutocompletePopupMenuClient.cpp', + 'src/AutocompletePopupMenuClient.h', + 'src/BackForwardListClientImpl.cpp', + 'src/BackForwardListClientImpl.h', + 'src/ChromeClientImpl.cpp', + 'src/ChromeClientImpl.h', + 'src/ChromiumBridge.cpp', + 'src/ChromiumCurrentTime.cpp', + 'src/ChromiumThreading.cpp', + 'src/ContextMenuClientImpl.cpp', + 'src/ContextMenuClientImpl.h', + 'src/DatabaseObserver.cpp', + 'src/DOMUtilitiesPrivate.cpp', + 'src/DOMUtilitiesPrivate.h', + 'src/DragClientImpl.cpp', + 'src/DragClientImpl.h', + 'src/EditorClientImpl.cpp', + 'src/EditorClientImpl.h', + 'src/FrameLoaderClientImpl.cpp', + 'src/FrameLoaderClientImpl.h', + 'src/gtk/WebFontInfo.cpp', + 'src/gtk/WebFontInfo.h', + 'src/gtk/WebInputEventFactory.cpp', + 'src/InspectorClientImpl.cpp', + 'src/InspectorClientImpl.h', + 'src/linux/WebFontRendering.cpp', + 'src/x11/WebScreenInfoFactory.cpp', + 'src/mac/WebInputEventFactory.mm', + 'src/mac/WebScreenInfoFactory.mm', + 'src/LocalizedStrings.cpp', + 'src/MediaPlayerPrivateChromium.cpp', + 'src/NotificationPresenterImpl.h', + 'src/NotificationPresenterImpl.cpp', + 'src/PlatformMessagePortChannel.cpp', + 'src/PlatformMessagePortChannel.h', + 'src/ResourceHandle.cpp', + 'src/SharedWorkerRepository.cpp', + 'src/SocketStreamHandle.cpp', + 'src/StorageAreaProxy.cpp', + 'src/StorageAreaProxy.h', + 'src/StorageEventDispatcherChromium.cpp', + 'src/StorageEventDispatcherImpl.cpp', + 'src/StorageEventDispatcherImpl.h', + 'src/StorageNamespaceProxy.cpp', + 'src/StorageNamespaceProxy.h', + 'src/TemporaryGlue.h', + 'src/WebAccessibilityCache.cpp', + 'src/WebAccessibilityCacheImpl.cpp', + 'src/WebAccessibilityCacheImpl.h', + 'src/WebAccessibilityObject.cpp', + 'src/WebBindings.cpp', + 'src/WebCache.cpp', + 'src/WebColor.cpp', + 'src/WebCrossOriginPreflightResultCache.cpp', + 'src/WebCString.cpp', + 'src/WebCursorInfo.cpp', + 'src/WebData.cpp', + 'src/WebDatabase.cpp', + 'src/WebDataSourceImpl.cpp', + 'src/WebDataSourceImpl.h', + 'src/WebDragData.cpp', + 'src/WebElement.cpp', + 'src/WebFileChooserCompletionImpl.cpp', + 'src/WebFileChooserCompletionImpl.h', + 'src/WebFontCache.cpp', + 'src/WebFormElement.cpp', + 'src/WebFrameImpl.cpp', + 'src/WebFrameImpl.h', + 'src/WebHistoryItem.cpp', + 'src/WebHTTPBody.cpp', + 'src/WebImageCG.cpp', + 'src/WebImageSkia.cpp', + 'src/WebInputElement.cpp', + 'src/WebInputEvent.cpp', + 'src/WebInputEventConversion.cpp', + 'src/WebInputEventConversion.h', + 'src/WebKit.cpp', + 'src/WebMediaPlayerClientImpl.cpp', + 'src/WebMediaPlayerClientImpl.h', + 'src/WebNode.cpp', + 'src/WebNotification.cpp', + 'src/WebPasswordFormData.cpp', + 'src/WebPasswordFormUtils.cpp', + 'src/WebPasswordFormUtils.h', + 'src/WebPluginContainerImpl.h', + 'src/WebPluginContainerImpl.cpp', + 'src/WebPluginListBuilderImpl.cpp', + 'src/WebPluginListBuilderImpl.h', + 'src/WebPluginLoadObserver.cpp', + 'src/WebPluginLoadObserver.h', + 'src/WebPopupMenuImpl.cpp', + 'src/WebPopupMenuImpl.h', + 'src/WebRange.cpp', + 'src/WebRegularExpression.cpp', + 'src/WebRuntimeFeatures.cpp', + 'src/WebScriptController.cpp', + 'src/WebSearchableFormData.cpp', + 'src/WebSecurityOrigin.cpp', + 'src/WebSecurityPolicy.cpp', + 'src/WebSettingsImpl.cpp', + 'src/WebSettingsImpl.h', + 'src/WebSharedWorkerImpl.cpp', + 'src/WebSharedWorkerImpl.h', + 'src/WebStorageAreaImpl.cpp', + 'src/WebStorageAreaImpl.h', + 'src/WebStorageEventDispatcherImpl.cpp', + 'src/WebStorageEventDispatcherImpl.h', + 'src/WebStorageNamespaceImpl.cpp', + 'src/WebStorageNamespaceImpl.h', + 'src/WebString.cpp', + 'src/WebURL.cpp', + 'src/WebURLRequest.cpp', + 'src/WebURLRequestPrivate.h', + 'src/WebURLResponse.cpp', + 'src/WebURLResponsePrivate.h', + 'src/WebURLError.cpp', + 'src/WebViewImpl.cpp', + 'src/WebViewImpl.h', + 'src/WebWorkerBase.cpp', + 'src/WebWorkerBase.h', + 'src/WebWorkerClientImpl.cpp', + 'src/WebWorkerClientImpl.h', + 'src/WebWorkerImpl.cpp', + 'src/WebWorkerImpl.h', + 'src/WrappedResourceRequest.h', + 'src/WrappedResourceResponse.h', + 'src/win/WebInputEventFactory.cpp', + 'src/win/WebScreenInfoFactory.cpp', + ], + 'conditions': [ + ['OS=="linux" or OS=="freebsd"', { + 'dependencies': [ + '<(chromium_src_dir)/build/linux/system.gyp:fontconfig', + '<(chromium_src_dir)/build/linux/system.gyp:gtk', + '<(chromium_src_dir)/build/linux/system.gyp:x11', + ], + 'include_dirs': [ + 'public/x11', + 'public/gtk', + 'public/linux', + ], + }, { # else: OS!="linux" and OS!="freebsd" + 'sources/': [ + ['exclude', '/gtk/'], + ['exclude', '/x11/'], + ['exclude', '/linux/'], + ], + }], + ['OS=="mac"', { + 'include_dirs': [ + 'public/mac', + ], + 'sources/': [ + ['exclude', 'Skia\\.cpp$'], + ], + }, { # else: OS!="mac" + 'sources/': [ + ['exclude', '/mac/'], + ['exclude', 'CG\\.cpp$'], + ], + }], + ['OS=="win"', { + 'include_dirs': [ + 'public/win', + ], + }, { # else: OS!="win" + 'sources/': [['exclude', '/win/']], + }], + ['"ENABLE_3D_CANVAS=1" in feature_defines', { + # Conditionally compile in GLEW and our GraphicsContext3D implementation. + 'sources+': [ + 'src/GraphicsContext3D.cpp', + '<(chromium_src_dir)/third_party/glew/src/glew.c' + ], + 'include_dirs+': [ + '<(chromium_src_dir)/third_party/glew/include' + ], + 'defines+': [ + 'GLEW_STATIC=1', + 'GLEW_NO_GLU=1', + ], + 'conditions': [ + ['OS=="win"', { + 'link_settings': { + 'libraries': [ + '-lopengl32.lib', + ], + }, + }], + ['OS=="mac"', { + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework', + ], + }, + }], + ], + }], + ], + }, + ], # targets +} + +# Local Variables: +# tab-width:2 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=2 shiftwidth=2: diff --git a/WebKit/chromium/features.gypi b/WebKit/chromium/features.gypi index e3bc7d3..8dd0d0d 100644 --- a/WebKit/chromium/features.gypi +++ b/WebKit/chromium/features.gypi @@ -46,10 +46,12 @@ 'ENABLE_OFFLINE_WEB_APPLICATIONS=1', 'ENABLE_DASHBOARD_SUPPORT=0', 'ENABLE_DOM_STORAGE=1', + 'ENABLE_GEOLOCATION=1', 'ENABLE_JAVASCRIPT_DEBUGGER=0', 'ENABLE_JSC_MULTIPLE_THREADS=0', 'ENABLE_ICONDATABASE=0', 'ENABLE_NOTIFICATIONS=1', + 'ENABLE_OPENTYPE_SANITIZER=1', 'ENABLE_ORIENTATION_EVENTS=0', 'ENABLE_XSLT=1', 'ENABLE_XPATH=1', @@ -61,7 +63,7 @@ 'ENABLE_SVG_FOREIGN_OBJECT=1', 'ENABLE_SVG_FONTS=1', 'ENABLE_VIDEO=1', - 'ENABLE_WEB_SOCKETS=1', + 'ENABLE_WEB_SOCKETS=1', 'ENABLE_WORKERS=1', ], }, diff --git a/WebKit/chromium/gyp_webkit b/WebKit/chromium/gyp_webkit index 810af54..ef18239 100644 --- a/WebKit/chromium/gyp_webkit +++ b/WebKit/chromium/gyp_webkit @@ -32,6 +32,7 @@ import glob import os +import platform import shlex import sys @@ -76,6 +77,10 @@ if __name__ == '__main__': # Add includes. args.extend(['-I' + i for i in additional_include_files(args)]) + # On linux, we want gyp to output a makefile (default is scons). + if (platform.system() == 'Linux'): + args.extend(['-fmake']) + # Other command args: args.extend([ # gyp variable defines. @@ -87,7 +92,7 @@ if __name__ == '__main__': '--depth=./', # gyp file to execute. - 'webkit.gyp']) + 'WebKit.gyp']) print 'Updating webkit projects from gyp files...' sys.stdout.flush() diff --git a/WebKit/chromium/public/WebAccessibilityCache.h b/WebKit/chromium/public/WebAccessibilityCache.h new file mode 100644 index 0000000..94704a0 --- /dev/null +++ b/WebKit/chromium/public/WebAccessibilityCache.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebAccessibilityCache_h +#define WebAccessibilityCache_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebView; +class WebAccessibilityObject; + +class WebAccessibilityCache { +public: + WebAccessibilityCache() {} + virtual ~WebAccessibilityCache() {} + + static WebAccessibilityCache* create(); + static void enableAccessibility(); + + virtual void initialize(WebView* view) = 0; + virtual bool isInitialized() const = 0; + + virtual WebAccessibilityObject getObjectById(int) = 0; + virtual bool isValidId(int) const = 0; + virtual int addOrGetId(const WebAccessibilityObject& object) = 0; + + virtual void remove(int) = 0; + virtual void clear() = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebAccessibilityObject.h b/WebKit/chromium/public/WebAccessibilityObject.h new file mode 100644 index 0000000..d32c548 --- /dev/null +++ b/WebKit/chromium/public/WebAccessibilityObject.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebAccessibilityObject_h +#define WebAccessibilityObject_h + +#include "WebAccessibilityRole.h" +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class AccessibilityObject; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebAccessibilityObjectPrivate; +class WebString; +struct WebPoint; +struct WebRect; + +// A container for passing around a reference to AccessibilityObject. +class WebAccessibilityObject { +public: + ~WebAccessibilityObject() { reset(); } + + WebAccessibilityObject() : m_private(0) { } + WebAccessibilityObject(const WebAccessibilityObject& o) : m_private(0) { assign(o); } + WebAccessibilityObject& operator=(const WebAccessibilityObject& o) + { + assign(o); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebAccessibilityObject&); + + bool isNull() const { return !m_private; } + + WebString accessibilityDescription() const; + WebString actionVerb() const; + bool canSetFocusAttribute() const; + bool canSetValueAttribute() const; + + unsigned childCount() const; + + WebAccessibilityObject childAt(unsigned) const; + WebAccessibilityObject firstChild() const; + WebAccessibilityObject focusedChild() const; + WebAccessibilityObject lastChild() const; + WebAccessibilityObject nextSibling() const; + WebAccessibilityObject parentObject() const; + WebAccessibilityObject previousSibling() const; + + bool isAnchor() const; + bool isChecked() const; + bool isFocused() const; + bool isEnabled() const; + bool isHovered() const; + bool isIndeterminate() const; + bool isMultiSelect() const; + bool isOffScreen() const; + bool isPasswordField() const; + bool isPressed() const; + bool isReadOnly() const; + bool isVisited() const; + + WebRect boundingBoxRect() const; + WebString helpText() const; + WebAccessibilityObject hitTest(const WebPoint&) const; + WebString keyboardShortcut() const; + bool performDefaultAction() const; + WebAccessibilityRole roleValue() const; + WebString stringValue() const; + WebString title() const; + +#if WEBKIT_IMPLEMENTATION + WebAccessibilityObject(const WTF::PassRefPtr<WebCore::AccessibilityObject>&); + WebAccessibilityObject& operator=(const WTF::PassRefPtr<WebCore::AccessibilityObject>&); + operator WTF::PassRefPtr<WebCore::AccessibilityObject>() const; +#endif + +private: + void assign(WebAccessibilityObjectPrivate*); + WebAccessibilityObjectPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebAccessibilityRole.h b/WebKit/chromium/public/WebAccessibilityRole.h new file mode 100644 index 0000000..e836c56 --- /dev/null +++ b/WebKit/chromium/public/WebAccessibilityRole.h @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebAccessibilityRole_h +#define WebAccessibilityRole_h + +#include "WebCommon.h" + +namespace WebKit { + +// These values must match WebCore::AccessibilityRole values +enum WebAccessibilityRole { + WebAccessibilityRoleUnknown = 1, + WebAccessibilityRoleButton, + WebAccessibilityRoleRadioButton, + WebAccessibilityRoleCheckBox, + WebAccessibilityRoleSlider, + WebAccessibilityRoleTabGroup, + WebAccessibilityRoleTextField, + WebAccessibilityRoleStaticText, + WebAccessibilityRoleTextArea, + WebAccessibilityRoleScrollArea, + WebAccessibilityRolePopUpButton, + WebAccessibilityRoleMenuButton, + WebAccessibilityRoleTable, + WebAccessibilityRoleApplication, + WebAccessibilityRoleGroup, + WebAccessibilityRoleRadioGroup, + WebAccessibilityRoleList, + WebAccessibilityRoleScrollBar, + WebAccessibilityRoleValueIndicator, + WebAccessibilityRoleImage, + WebAccessibilityRoleMenuBar, + WebAccessibilityRoleMenu, + WebAccessibilityRoleMenuItem, + WebAccessibilityRoleColumn, + WebAccessibilityRoleRow, + WebAccessibilityRoleToolbar, + WebAccessibilityRoleBusyIndicator, + WebAccessibilityRoleProgressIndicator, + WebAccessibilityRoleWindow, + WebAccessibilityRoleDrawer, + WebAccessibilityRoleSystemWide, + WebAccessibilityRoleOutline, + WebAccessibilityRoleIncrementor, + WebAccessibilityRoleBrowser, + WebAccessibilityRoleComboBox, + WebAccessibilityRoleSplitGroup, + WebAccessibilityRoleSplitter, + WebAccessibilityRoleColorWell, + WebAccessibilityRoleGrowArea, + WebAccessibilityRoleSheet, + WebAccessibilityRoleHelpTag, + WebAccessibilityRoleMatte, + WebAccessibilityRoleRuler, + WebAccessibilityRoleRulerMarker, + WebAccessibilityRoleLink, + WebAccessibilityRoleDisclosureTriangle, + WebAccessibilityRoleGrid, + WebAccessibilityRoleCell, + WebAccessibilityRoleColumnHeader, + WebAccessibilityRoleRowHeader, + + WebAccessibilityRoleWebCoreLink, + WebAccessibilityRoleImageMapLink, + WebAccessibilityRoleImageMap, + WebAccessibilityRoleListMarker, + WebAccessibilityRoleWebArea, + WebAccessibilityRoleHeading, + WebAccessibilityRoleListBox, + WebAccessibilityRoleListBoxOption, + WebAccessibilityRoleTableHeaderContainer, + WebAccessibilityRoleDefinitionListTerm, + WebAccessibilityRoleDefinitionListDefinition, + WebAccessibilityRoleAnnotation, + WebAccessibilityRoleSliderThumb, + WebAccessibilityRoleIgnored, + WebAccessibilityRoleTab, + WebAccessibilityRoleTabList, + WebAccessibilityRoleTabPanel, + WebAccessibilityRoleTreeRole, + WebAccessibilityRoleTreeItemRole, + WebAccessibilityRoleDirectory, + + WebAccessibilityRoleLandmarkApplication, + WebAccessibilityRoleLandmarkBanner, + WebAccessibilityRoleLandmarkComplementary, + WebAccessibilityRoleLandmarkContentInfo, + WebAccessibilityRoleLandmarkMain, + WebAccessibilityRoleLandmarkNavigation, + WebAccessibilityRoleLandmarkSearch, + + WebAccessibilityRoleApplicationAlert, + WebAccessibilityRoleApplicationAlertDialog, + WebAccessibilityRoleApplicationDialog, + WebAccessibilityRoleApplicationLog, + WebAccessibilityRoleApplicationMarquee, + WebAccessibilityRoleApplicationStatus, + WebAccessibilityRoleApplicationTimer, + + WebAccessibilityRoleDocument, + WebAccessibilityRoleDocumentArticle, + WebAccessibilityRoleDocumentMath, + WebAccessibilityRoleDocumentNote, + WebAccessibilityRoleDocumentRegion, + + WebAccessibilityRoleUserInterfaceTooltip +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebApplicationCacheHost.h b/WebKit/chromium/public/WebApplicationCacheHost.h new file mode 100644 index 0000000..7c5dafe --- /dev/null +++ b/WebKit/chromium/public/WebApplicationCacheHost.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebApplicationCacheHost_h +#define WebApplicationCacheHost_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebApplicationCacheHostClient; +class WebURL; +class WebURLRequest; +class WebURLResponse; +struct WebURLError; + +// This interface is used by webkit to call out to the embedder. Webkit uses +// the WebKitClient::createApplicationCacheHost method to create instances, +// and calls delete when the instance is no longer needed. +class WebApplicationCacheHost { +public: + // These values must match WebCore::ApplicationCacheHost::Status values + enum Status { + Uncached, + Idle, + Checking, + Downloading, + UpdateReady, + Obsolete + }; + + // These values must match WebCore::ApplicationCacheHost::EventID values + enum EventID { + CheckingEvent, + ErrorEvent, + NoUpdateEvent, + DownloadingEvent, + ProgressEvent, + UpdateReadyEvent, + CachedEvent, + ObsoleteEvent + }; + + virtual ~WebApplicationCacheHost() { } + + // Called for every request made within the context. + virtual void willStartMainResourceRequest(WebURLRequest&) = 0; + virtual void willStartSubResourceRequest(WebURLRequest&) = 0; + + // One or the other selectCache methods is called after having parsed the <html> tag. + // The latter returns false if the current document has been identified as a "foreign" + // entry, in which case the frame navigation will be restarted by webkit. + virtual void selectCacheWithoutManifest() = 0; + virtual bool selectCacheWithManifest(const WebURL& manifestURL) = 0; + + // Called as the main resource is retrieved. + virtual void didReceiveResponseForMainResource(const WebURLResponse&) = 0; + virtual void didReceiveDataForMainResource(const char* data, int len) = 0; + virtual void didFinishLoadingMainResource(bool success) = 0; + + // Called on behalf of the scriptable interface. + virtual Status status() = 0; + virtual bool startUpdate() = 0; + virtual bool swapCache() = 0; +}; + +} // namespace WebKit + +#endif // WebApplicationCacheHost_h + diff --git a/WebKit/chromium/public/WebApplicationCacheHostClient.h b/WebKit/chromium/public/WebApplicationCacheHostClient.h new file mode 100644 index 0000000..4e830e3 --- /dev/null +++ b/WebKit/chromium/public/WebApplicationCacheHostClient.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebApplicationCacheHostClient_h +#define WebApplicationCacheHostClient_h + +#include "WebApplicationCacheHost.h" +#include "WebCommon.h" + +namespace WebKit { + +// This interface is used by the embedder to call into webkit. +class WebApplicationCacheHostClient { +public: + // Called to fire the event in the scriptable interface. + virtual void notifyEventListener(WebApplicationCacheHost::EventID) = 0; + +protected: + // Should not be deleted by the embedder. + virtual ~WebApplicationCacheHostClient() { } +}; + +} // namespace WebKit + +#endif // WebApplicationCacheHostClient_h + diff --git a/WebKit/chromium/public/WebBindings.h b/WebKit/chromium/public/WebBindings.h new file mode 100644 index 0000000..4e66a8f --- /dev/null +++ b/WebKit/chromium/public/WebBindings.h @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebBindings_h +#define WebBindings_h + +#include "WebCommon.h" +#include <bindings/npruntime.h> + +namespace WebKit { + +class WebDragData; +class WebRange; + +// A haphazard collection of functions for dealing with plugins. +class WebBindings { +public: + // NPN Functions ------------------------------------------------------ + // These are all defined in npruntime.h and are well documented. + + // NPN_Construct + WEBKIT_API static bool construct(NPP, NPObject*, const NPVariant* args, uint32_t argCount, NPVariant* result); + + // NPN_CreateObject + WEBKIT_API static NPObject* createObject(NPP, NPClass*); + + // NPN_Enumerate + WEBKIT_API static bool enumerate(NPP, NPObject*, NPIdentifier**, uint32_t* count); + + // NPN_Evaluate + WEBKIT_API static bool evaluate(NPP, NPObject*, NPString* script, NPVariant* result); + + // NPN_EvaluateHelper + WEBKIT_API static bool evaluateHelper(NPP, bool popupsAllowed, NPObject*, NPString* script, NPVariant* result); + + // NPN_GetIntIdentifier + WEBKIT_API static NPIdentifier getIntIdentifier(int32_t number); + + // NPN_GetProperty + WEBKIT_API static bool getProperty(NPP, NPObject*, NPIdentifier propertyName, NPVariant *result); + + // NPN_GetStringIdentifier + WEBKIT_API static NPIdentifier getStringIdentifier(const NPUTF8* string); + + // NPN_GetStringIdentifiers + WEBKIT_API static void getStringIdentifiers(const NPUTF8** names, int32_t nameCount, NPIdentifier*); + + // NPN_HasMethod + WEBKIT_API static bool hasMethod(NPP, NPObject*, NPIdentifier methodName); + + // NPN_HasProperty + WEBKIT_API static bool hasProperty(NPP, NPObject*, NPIdentifier propertyName); + + // NPN_IdentifierIsString + WEBKIT_API static bool identifierIsString(NPIdentifier); + + // NPN_InitializeVariantWithStringCopy (though sometimes prefixed with an underscore) + WEBKIT_API static void initializeVariantWithStringCopy(NPVariant*, const NPString*); + + // NPN_IntFromIdentifier + WEBKIT_API static int32_t intFromIdentifier(NPIdentifier); + + // NPN_Invoke + WEBKIT_API static bool invoke(NPP, NPObject*, NPIdentifier methodName, const NPVariant* args, uint32_t count, NPVariant* result); + + // NPN_InvokeDefault + WEBKIT_API static bool invokeDefault(NPP, NPObject*, const NPVariant* args, uint32_t count, NPVariant* result); + + // NPN_ReleaseObject + WEBKIT_API static void releaseObject(NPObject*); + + // NPN_ReleaseVariantValue + WEBKIT_API static void releaseVariantValue(NPVariant*); + + // NPN_RemoveProperty + WEBKIT_API static bool removeProperty(NPP, NPObject*, NPIdentifier); + + // NPN_RetainObject + WEBKIT_API static NPObject* retainObject(NPObject*); + + // NPN_SetException + WEBKIT_API static void setException(NPObject*, const NPUTF8* message); + + // NPN_SetProperty + WEBKIT_API static bool setProperty(NPP, NPObject*, NPIdentifier, const NPVariant*); + + // _NPN_UnregisterObject + WEBKIT_API static void unregisterObject(NPObject*); + + // NPN_UTF8FromIdentifier + WEBKIT_API static NPUTF8* utf8FromIdentifier(NPIdentifier); + + // Miscellaneous utility functions ------------------------------------ + + // Complement to NPN_Get___Identifier functions. Extracts data from the NPIdentifier data + // structure. If isString is true upon return, string will be set but number's value is + // undefined. If iString is false, the opposite is true. + WEBKIT_API static void extractIdentifierData(const NPIdentifier&, const NPUTF8*& string, int32_t& number, bool& isString); + + // Return true (success) if the given npobj is the current drag event in browser dispatch, + // and is accessible based on context execution frames and their security origins and + // WebKit clipboard access policy. If so, return the event id and the clipboard data (WebDragData). + // This only works with V8. If compiled without V8, it'll always return false. + WEBKIT_API static bool getDragData(NPObject* event, int* eventId, WebDragData*); + + // Invoke the event access policy checks listed above with GetDragData(). No need for clipboard + // data or event_id outputs, just confirm the given npobj is the current & accessible drag event. + // This only works with V8. If compiled without V8, it'll always return false. + WEBKIT_API static bool isDragEvent(NPObject* event); + + // Return true (success) if the given npobj is a range object. + // If so, return that range as a WebRange object. + WEBKIT_API static bool getRange(NPObject* range, WebRange*); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCString.h b/WebKit/chromium/public/WebCString.h new file mode 100644 index 0000000..434cb06 --- /dev/null +++ b/WebKit/chromium/public/WebCString.h @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCString_h +#define WebCString_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class CString; } +#else +#include <string> +#endif + +namespace WebKit { + +class WebCStringPrivate; +class WebString; + +// A single-byte string container with unspecified encoding. It is +// inexpensive to copy a WebCString object. +// +// WARNING: It is not safe to pass a WebCString across threads!!! +// +class WebCString { +public: + ~WebCString() { reset(); } + + WebCString() : m_private(0) { } + + WebCString(const char* data, size_t len) : m_private(0) + { + assign(data, len); + } + + WebCString(const WebCString& s) : m_private(0) { assign(s); } + + WebCString& operator=(const WebCString& s) + { + assign(s); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebCString&); + WEBKIT_API void assign(const char* data, size_t len); + + WEBKIT_API size_t length() const; + WEBKIT_API const char* data() const; + + bool isEmpty() const { return !length(); } + bool isNull() const { return !m_private; } + + WEBKIT_API WebString utf16() const; + + WEBKIT_API static WebCString fromUTF16(const WebUChar* data, size_t length); + WEBKIT_API static WebCString fromUTF16(const WebUChar* data); + +#if WEBKIT_IMPLEMENTATION + WebCString(const WebCore::CString&); + WebCString& operator=(const WebCore::CString&); + operator WebCore::CString() const; +#else + WebCString(const std::string& s) : m_private(0) + { + assign(s.data(), s.length()); + } + + WebCString& operator=(const std::string& s) + { + assign(s.data(), s.length()); + return *this; + } + + operator std::string() const + { + size_t len = length(); + return len ? std::string(data(), len) : std::string(); + } + + template <class UTF16String> + static WebCString fromUTF16(const UTF16String& s) + { + return fromUTF16(s.data(), s.length()); + } +#endif + +private: + void assign(WebCStringPrivate*); + WebCStringPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCache.h b/WebKit/chromium/public/WebCache.h new file mode 100644 index 0000000..433eb1a --- /dev/null +++ b/WebKit/chromium/public/WebCache.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCache_h +#define WebCache_h + +#include "WebCommon.h" + +namespace WebKit { + +// An interface to query and configure WebKit's resource cache. +class WebCache { +public: + struct UsageStats { + // Capacities. + size_t minDeadCapacity; + size_t maxDeadCapacity; + size_t capacity; + // Utilization. + size_t liveSize; + size_t deadSize; + }; + + // A struct mirroring WebCore::Cache::TypeStatistic. + struct ResourceTypeStat { + size_t count; + size_t size; + size_t liveSize; + size_t decodedSize; + }; + + // A struct mirroring WebCore::Cache::Statistics. + struct ResourceTypeStats { + ResourceTypeStat images; + ResourceTypeStat cssStyleSheets; + ResourceTypeStat scripts; + ResourceTypeStat xslStyleSheets; + ResourceTypeStat fonts; + }; + + // Sets the capacities of the resource cache, evicting objects as necessary. + WEBKIT_API static void setCapacities(size_t minDeadCapacity, + size_t maxDeadCapacity, + size_t capacity); + + // Clears the cache (as much as possible; some resources may not be + // cleared if they are actively referenced). + WEBKIT_API static void clear(); + + // Gets the usage statistics from the resource cache. + WEBKIT_API static void getUsageStats(UsageStats*); + + // Get usage stats about the resource cache. + WEBKIT_API static void getResourceTypeStats(ResourceTypeStats*); + +private: + WebCache(); // Not intended to be instanced. +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCanvas.h b/WebKit/chromium/public/WebCanvas.h new file mode 100644 index 0000000..4675487 --- /dev/null +++ b/WebKit/chromium/public/WebCanvas.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCanvas_h +#define WebCanvas_h + +#include "WebCommon.h" + +#if WEBKIT_USING_SKIA +namespace skia { class PlatformCanvas; } +#elif WEBKIT_USING_CG +struct CGContext; +#endif + +namespace WebKit { + +#if WEBKIT_USING_SKIA +typedef skia::PlatformCanvas WebCanvas; +#elif WEBKIT_USING_CG +typedef struct CGContext WebCanvas; +#else +#error "Need to define WebCanvas" +#endif + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebClipboard.h b/WebKit/chromium/public/WebClipboard.h new file mode 100644 index 0000000..68e22b5 --- /dev/null +++ b/WebKit/chromium/public/WebClipboard.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebClipboard_h +#define WebClipboard_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebImage; +class WebString; +class WebURL; + +class WebClipboard { +public: + enum Format { + FormatHTML, + FormatBookmark, + FormatSmartPaste + }; + + enum Buffer { + BufferStandard, + // Used on platforms like the X Window System that treat selection + // as a type of clipboard. + BufferSelection + }; + + virtual bool isFormatAvailable(Format, Buffer) = 0; + + virtual WebString readPlainText(Buffer) = 0; + virtual WebString readHTML(Buffer, WebURL*) = 0; + + virtual void writePlainText(const WebString&) = 0; + virtual void writeHTML( + const WebString& htmlText, const WebURL&, + const WebString& plainText, bool writeSmartPaste) = 0; + virtual void writeURL( + const WebURL&, const WebString& title) = 0; + virtual void writeImage( + const WebImage&, const WebURL&, const WebString& title) = 0; + +protected: + ~WebClipboard() {} +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebColor.h b/WebKit/chromium/public/WebColor.h new file mode 100644 index 0000000..034f8db --- /dev/null +++ b/WebKit/chromium/public/WebColor.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebColor_h +#define WebColor_h + +#include "WebColorName.h" +#include "WebCommon.h" + +namespace WebKit { + +typedef unsigned WebColor; // RGBA quad. Equivalent to SkColor. + +// Sets the values of a set of named colors. +WEBKIT_API void setNamedColors(const WebColorName*, const WebColor*, size_t length); + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebColorName.h b/WebKit/chromium/public/WebColorName.h new file mode 100644 index 0000000..f97ed26 --- /dev/null +++ b/WebKit/chromium/public/WebColorName.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2009 Google 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: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * 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. +* * Neither the name of Google Inc. nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* 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 +* OWNER 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 WebColorName_h +#define WebColorName_h + +namespace WebKit { + +enum WebColorName { + WebColorActiveBorder, + WebColorActiveCaption, + WebColorAppworkspace, + WebColorBackground, + WebColorButtonFace, + WebColorButtonHighlight, + WebColorButtonShadow, + WebColorButtonText, + WebColorCaptionText, + WebColorGrayText, + WebColorHighlight, + WebColorHighlightText, + WebColorInactiveBorder, + WebColorInactiveCaption, + WebColorInactiveCaptionText, + WebColorInfoBackground, + WebColorInfoText, + WebColorMenu, + WebColorMenuText, + WebColorScrollbar, + WebColorText, + WebColorThreedDarkShadow, + WebColorThreedShadow, + WebColorThreedFace, + WebColorThreedHighlight, + WebColorThreedLightShadow, + WebColorWebkitFocusRingColor, + WebColorWindow, + WebColorWindowFrame, + WebColorWindowText +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCommon.h b/WebKit/chromium/public/WebCommon.h new file mode 100644 index 0000000..d347ea6 --- /dev/null +++ b/WebKit/chromium/public/WebCommon.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCommon_h +#define WebCommon_h + +// ----------------------------------------------------------------------------- +// Default configuration + +#if !defined(WEBKIT_IMPLEMENTATION) + #define WEBKIT_IMPLEMENTATION 0 +#endif + +#if !defined(WEBKIT_USING_SKIA) + #if !defined(__APPLE__) + #define WEBKIT_USING_SKIA 1 + #else + #define WEBKIT_USING_SKIA 0 + #endif +#endif + +#if !defined(WEBKIT_USING_CG) + #if defined(__APPLE__) + #define WEBKIT_USING_CG 1 + #else + #define WEBKIT_USING_CG 0 + #endif +#endif + +#if !defined(WEBKIT_USING_V8) + #define WEBKIT_USING_V8 1 +#endif + +#if !defined(WEBKIT_USING_JSC) + #define WEBKIT_USING_JSC 0 +#endif + +// ----------------------------------------------------------------------------- +// Exported symbols need to be annotated with WEBKIT_API + +#if defined(WIN32) && defined(WEBKIT_DLL) + #if defined(WEBKIT_IMPLEMENTATION) + #define WEBKIT_API __declspec(dllexport) + #else + #define WEBKIT_API __declspec(dllimport) + #endif +#else + #define WEBKIT_API +#endif + +// ----------------------------------------------------------------------------- +// Basic types + +#include <stddef.h> // For size_t + +namespace WebKit { + + // UTF-16 character type +#if defined(WIN32) +typedef wchar_t WebUChar; +#else +typedef unsigned short WebUChar; +#endif + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCommonWorkerClient.h b/WebKit/chromium/public/WebCommonWorkerClient.h new file mode 100644 index 0000000..771ffff --- /dev/null +++ b/WebKit/chromium/public/WebCommonWorkerClient.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCommonWorkerClient_h +#define WebCommonWorkerClient_h + +namespace WebKit { + +class WebNotificationPresenter; +class WebString; +class WebWorker; +class WebWorkerClient; + +// Provides an interface back to the in-page script object for a worker. +// This interface contains common APIs used by both shared and dedicated +// workers. +// All functions are expected to be called back on the thread that created +// the Worker object, unless noted. +class WebCommonWorkerClient { +public: + virtual void postExceptionToWorkerObject( + const WebString& errorString, int lineNumber, + const WebString& sourceURL) = 0; + + virtual void postConsoleMessageToWorkerObject( + int destinationIdentifier, + int sourceIdentifier, + int messageType, + int messageLevel, + const WebString& message, + int lineNumber, + const WebString& sourceURL) = 0; + + virtual void workerContextClosed() = 0; + virtual void workerContextDestroyed() = 0; + + // Returns the notification presenter for this worker context. Pointer + // is owned by the object implementing WebCommonWorkerClient. + virtual WebNotificationPresenter* notificationPresenter() = 0; + + // This can be called on any thread to create a nested WebWorker. + // WebSharedWorkers are not instantiated via this API - instead + // they are created via the WebSharedWorkerRepository. + virtual WebWorker* createWorker(WebWorkerClient* client) = 0; + +protected: + ~WebCommonWorkerClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCompositionCommand.h b/WebKit/chromium/public/WebCompositionCommand.h new file mode 100644 index 0000000..fa89529 --- /dev/null +++ b/WebKit/chromium/public/WebCompositionCommand.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCompositionCommand_h +#define WebCompositionCommand_h + +namespace WebKit { + +enum WebCompositionCommand { + WebCompositionCommandDiscard, + WebCompositionCommandSet, + WebCompositionCommandConfirm, +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebConsoleMessage.h b/WebKit/chromium/public/WebConsoleMessage.h new file mode 100644 index 0000000..d7a0ead --- /dev/null +++ b/WebKit/chromium/public/WebConsoleMessage.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebConsoleMessage_h +#define WebConsoleMessage_h + +#include "WebString.h" + +namespace WebKit { + +struct WebConsoleMessage { + enum Level { + LevelTip, + LevelLog, + LevelWarning, + LevelError + }; + + Level level; + WebString text; + + WebConsoleMessage() + : level(LevelLog) { } + WebConsoleMessage(Level level, const WebString& text) + : level(LevelLog) + , text(text) { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebContextMenuData.h b/WebKit/chromium/public/WebContextMenuData.h new file mode 100644 index 0000000..b4acb1c --- /dev/null +++ b/WebKit/chromium/public/WebContextMenuData.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebContextMenuData_h +#define WebContextMenuData_h + +#include "WebMenuItemInfo.h" +#include "WebPoint.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebVector.h" + +namespace WebKit { + +// This struct is passed to WebViewClient::ShowContextMenu. +struct WebContextMenuData { + enum MediaType { + // No special node is in context. + MediaTypeNone, + // An image node is selected. + MediaTypeImage, + // A video node is selected. + MediaTypeVideo, + // An audio node is selected. + MediaTypeAudio, + }; + // The type of media the context menu is being invoked on. + MediaType mediaType; + + // The x and y position of the mouse pointer (relative to the webview). + WebPoint mousePosition; + + // The absolute URL of the link that is in context. + WebURL linkURL; + + // The absolute URL of the image/video/audio that is in context. + WebURL srcURL; + + // The absolute URL of the page in context. + WebURL pageURL; + + // The absolute URL of the subframe in context. + WebURL frameURL; + + // The encoding for the frame in context. + WebString frameEncoding; + + enum MediaFlags { + MediaNone = 0x0, + MediaInError = 0x1, + MediaPaused = 0x2, + MediaMuted = 0x4, + MediaLoop = 0x8, + MediaCanSave = 0x10, + MediaHasAudio = 0x20, + }; + + // Extra attributes describing media elements. + int mediaFlags; + + // The raw text of the selection in context. + WebString selectedText; + + // Whether spell checking is enabled. + bool isSpellCheckingEnabled; + + // The editable (possibily) misspelled word. + WebString misspelledWord; + + // Whether context is editable. + bool isEditable; + + enum EditFlags { + CanDoNone = 0x0, + CanUndo = 0x1, + CanRedo = 0x2, + CanCut = 0x4, + CanCopy = 0x8, + CanPaste = 0x10, + CanDelete = 0x20, + CanSelectAll = 0x40, + }; + + // Which edit operations are available in the context. + int editFlags; + + // Security information for the context. + WebCString securityInfo; + + // Custom context menu items provided by the WebCore internals. + WebVector<WebMenuItemInfo> customItems; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCookie.h b/WebKit/chromium/public/WebCookie.h new file mode 100644 index 0000000..81cb361 --- /dev/null +++ b/WebKit/chromium/public/WebCookie.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCookie_h +#define WebCookie_h + +#include "WebCommon.h" +#include "WebString.h" + +namespace WebKit { + +class WebString; + +// A cookie. +// +struct WebCookie { + WebCookie() + : expires(0) + , httpOnly(false) + , secure(false) + , session(false) + { + } + + WebCookie(const WebString& name, const WebString& value, const WebString& domain, + const WebString& path, double expires, bool httpOnly, bool secure, bool session) + : name(name) + , value(value) + , domain(domain) + , path(path) + , expires(expires) + , httpOnly(httpOnly) + , secure(secure) + , session(session) + { + } + + WebString name; + WebString value; + WebString domain; + WebString path; + double expires; + bool httpOnly; + bool secure; + bool session; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCrossOriginPreflightResultCache.h b/WebKit/chromium/public/WebCrossOriginPreflightResultCache.h new file mode 100644 index 0000000..62827f7 --- /dev/null +++ b/WebKit/chromium/public/WebCrossOriginPreflightResultCache.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCrossOriginPreflightResultCache_h +#define WebCrossOriginPreflightResultCache_h + +#include "WebCommon.h" + +namespace WebKit { + +// An interface to configure WebKit's cross-origin preflight result cache. +class WebCrossOriginPreflightResultCache { +public: + // Clears the cache. + WEBKIT_API static void clear(); + +private: + WebCrossOriginPreflightResultCache(); // Not intended to be instanced. +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebCursorInfo.h b/WebKit/chromium/public/WebCursorInfo.h new file mode 100644 index 0000000..8926e5c --- /dev/null +++ b/WebKit/chromium/public/WebCursorInfo.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebCursorInfo_h +#define WebCursorInfo_h + +#include "WebImage.h" +#include "WebPoint.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Cursor; } +#endif + +#ifdef WIN32 +typedef struct HICON__* HICON; +typedef HICON HCURSOR; +#endif + +namespace WebKit { + +struct WebCursorInfo { + enum Type { + TypePointer, + TypeCross, + TypeHand, + TypeIBeam, + TypeWait, + TypeHelp, + TypeEastResize, + TypeNorthResize, + TypeNorthEastResize, + TypeNorthWestResize, + TypeSouthResize, + TypeSouthEastResize, + TypeSouthWestResize, + TypeWestResize, + TypeNorthSouthResize, + TypeEastWestResize, + TypeNorthEastSouthWestResize, + TypeNorthWestSouthEastResize, + TypeColumnResize, + TypeRowResize, + TypeMiddlePanning, + TypeEastPanning, + TypeNorthPanning, + TypeNorthEastPanning, + TypeNorthWestPanning, + TypeSouthPanning, + TypeSouthEastPanning, + TypeSouthWestPanning, + TypeWestPanning, + TypeMove, + TypeVerticalText, + TypeCell, + TypeContextMenu, + TypeAlias, + TypeProgress, + TypeNoDrop, + TypeCopy, + TypeNone, + TypeNotAllowed, + TypeZoomIn, + TypeZoomOut, + TypeCustom + }; + + Type type; + WebPoint hotSpot; + WebImage customImage; + +#ifdef WIN32 + // On Windows, TypeCustom may alternatively reference an externally + // defined HCURSOR. If type is TypeCustom and externalHandle is non- + // null, then customData should be ignored. The WebCursorInfo is not + // responsible for managing the lifetime of this cursor handle. + HCURSOR externalHandle; +#endif + + explicit WebCursorInfo(Type type = TypePointer) + : type(type) + { +#ifdef WIN32 + externalHandle = 0; +#endif + } + +#if WEBKIT_IMPLEMENTATION + explicit WebCursorInfo(const WebCore::Cursor&); +#endif +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebData.h b/WebKit/chromium/public/WebData.h new file mode 100644 index 0000000..5874bed --- /dev/null +++ b/WebKit/chromium/public/WebData.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebData_h +#define WebData_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class SharedBuffer; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebDataPrivate; + +// A container for raw bytes. It is inexpensive to copy a WebData object. +// +// WARNING: It is not safe to pass a WebData across threads!!! +// +class WebData { +public: + ~WebData() { reset(); } + + WebData() : m_private(0) { } + + WebData(const char* data, size_t size) : m_private(0) + { + assign(data, size); + } + + template <int N> + WebData(const char (&data)[N]) : m_private(0) + { + assign(data, N - 1); + } + + WebData(const WebData& d) : m_private(0) { assign(d); } + + WebData& operator=(const WebData& d) + { + assign(d); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebData&); + WEBKIT_API void assign(const char* data, size_t size); + + WEBKIT_API size_t size() const; + WEBKIT_API const char* data() const; + + bool isEmpty() const { return !size(); } + bool isNull() const { return !m_private; } + +#if WEBKIT_IMPLEMENTATION + WebData(const WTF::PassRefPtr<WebCore::SharedBuffer>&); + WebData& operator=(const WTF::PassRefPtr<WebCore::SharedBuffer>&); + operator WTF::PassRefPtr<WebCore::SharedBuffer>() const; +#else + template <class C> + WebData(const C& c) : m_private(0) + { + assign(c.data(), c.size()); + } + + template <class C> + WebData& operator=(const C& c) + { + assign(c.data(), c.size()); + return *this; + } +#endif + +private: + void assign(WebDataPrivate*); + WebDataPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDataSource.h b/WebKit/chromium/public/WebDataSource.h new file mode 100644 index 0000000..3a83341 --- /dev/null +++ b/WebKit/chromium/public/WebDataSource.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDataSource_h +#define WebDataSource_h + +#include "WebCommon.h" +#include "WebNavigationType.h" + +namespace WebKit { + +class WebString; +class WebURL; +class WebURLRequest; +class WebURLResponse; +template <typename T> class WebVector; + +class WebDataSource { +public: + class ExtraData { + public: + virtual ~ExtraData() { } + }; + + // Returns the original request that resulted in this datasource. + virtual const WebURLRequest& originalRequest() const = 0; + + // Returns the request corresponding to this datasource. It may + // include additional request headers added by WebKit that were not + // present in the original request. This request may also correspond + // to a location specified by a redirect that was followed. + virtual const WebURLRequest& request() const = 0; + + // Returns the response associated with this datasource. + virtual const WebURLResponse& response() const = 0; + + // When this datasource was created as a result of WebFrame::loadData, + // there may be an associated unreachableURL. + virtual bool hasUnreachableURL() const = 0; + virtual WebURL unreachableURL() const = 0; + + // Returns all redirects that occurred (both client and server) before + // at last committing the current page. This will contain one entry + // for each intermediate URL, and one entry for the last URL (so if + // there are no redirects, it will contain exactly the current URL, and + // if there is one redirect, it will contain the source and destination + // URL). + virtual void redirectChain(WebVector<WebURL>&) const = 0; + + // Returns the title for the current page. + virtual WebString pageTitle() const = 0; + + // The type of navigation that triggered the creation of this datasource. + virtual WebNavigationType navigationType() const = 0; + + // The time in seconds (since the epoch) of the event that triggered + // the creation of this datasource. Returns 0 if unknown. + virtual double triggeringEventTime() const = 0; + + // Extra data associated with this datasource. If non-null, the extra + // data pointer will be deleted when the datasource is destroyed. + // Setting the extra data pointer will cause any existing non-null + // extra data pointer to be deleted. + virtual ExtraData* extraData() const = 0; + virtual void setExtraData(ExtraData*) = 0; + +protected: + ~WebDataSource() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDatabase.h b/WebKit/chromium/public/WebDatabase.h new file mode 100644 index 0000000..179e828 --- /dev/null +++ b/WebKit/chromium/public/WebDatabase.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDatabase_h +#define WebDatabase_h + +#include "WebCommon.h" +#include "WebSecurityOrigin.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Database; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebDatabaseObserver; +class WebDatabasePrivate; +class WebString; + +class WebDatabase { +public: + WebDatabase() : m_private(0) { } + WebDatabase(const WebDatabase& d) : m_private(0) { assign(d); } + ~WebDatabase() { reset(); } + + WebDatabase& operator=(const WebDatabase& d) + { + assign(d); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebDatabase&); + bool isNull() const { return !m_private; } + + WEBKIT_API WebString name() const; + WEBKIT_API WebString displayName() const; + WEBKIT_API unsigned long estimatedSize() const; + WEBKIT_API WebSecurityOrigin securityOrigin() const; + + WEBKIT_API static void setObserver(WebDatabaseObserver*); + WEBKIT_API static WebDatabaseObserver* observer(); + + WEBKIT_API static void updateDatabaseSize( + const WebString& originIdentifier, const WebString& databaseName, + unsigned long long databaseSize, unsigned long long spaceAvailable); + +#if WEBKIT_IMPLEMENTATION + WebDatabase(const WTF::PassRefPtr<WebCore::Database>&); + WebDatabase& operator=(const WTF::PassRefPtr<WebCore::Database>&); + operator WTF::PassRefPtr<WebCore::Database>() const; +#endif + +private: + void assign(WebDatabasePrivate*); + + WebDatabasePrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDatabaseObserver.h b/WebKit/chromium/public/WebDatabaseObserver.h new file mode 100644 index 0000000..da85c93 --- /dev/null +++ b/WebKit/chromium/public/WebDatabaseObserver.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDatabaseObserver_h +#define WebDatabaseObserver_h + +namespace WebKit { +class WebDatabase; + +class WebDatabaseObserver { +public: + virtual void databaseOpened(const WebDatabase&) = 0; + virtual void databaseModified(const WebDatabase&) = 0; + virtual void databaseClosed(const WebDatabase&) = 0; +protected: + ~WebDatabaseObserver() {} +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDevToolsAgent.h b/WebKit/chromium/public/WebDevToolsAgent.h new file mode 100644 index 0000000..9c27628 --- /dev/null +++ b/WebKit/chromium/public/WebDevToolsAgent.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDevToolsAgent_h +#define WebDevToolsAgent_h + +#include "WebCommon.h" + +namespace WebKit { +class WebDevToolsAgentClient; +class WebFrame; +class WebString; +class WebURLRequest; +class WebURLResponse; +class WebView; +struct WebDevToolsMessageData; +struct WebPoint; +struct WebURLError; + +class WebDevToolsAgent { +public: + WEBKIT_API static WebDevToolsAgent* create(WebView*, WebDevToolsAgentClient*); + + virtual ~WebDevToolsAgent() {} + + virtual void attach() = 0; + virtual void detach() = 0; + + virtual void didNavigate() = 0; + + // TODO(32320): remove this method from API. + virtual void dispatchMessageFromFrontend(const WebString& className, + const WebString& methodName, + const WebString& param1, + const WebString& param2, + const WebString& param3) = 0; + virtual void dispatchMessageFromFrontend(const WebDevToolsMessageData&) = 0; + + virtual void inspectElementAt(const WebPoint&) = 0; + + virtual void setRuntimeFeatureEnabled(const WebString& feature, bool enabled) = 0; + + // Exposed for LayoutTestController. + virtual void evaluateInWebInspector(long callId, const WebString& script) = 0; + virtual void setTimelineProfilingEnabled(bool enabled) = 0; + + // Asynchronously executes debugger command in the render thread. + // |callerIdentifier| will be used for sending response. + WEBKIT_API static void executeDebuggerCommand( + const WebString& command, int callerIdentifier); + + // Asynchronously request debugger to pause immediately. + WEBKIT_API static void debuggerPauseScript(); + + // TODO(32320): remove this method from API. + WEBKIT_API static bool dispatchMessageFromFrontendOnIOThread(const WebString& className, + const WebString& methodName, + const WebString& param1, + const WebString& param2, + const WebString& param3); + WEBKIT_API static bool dispatchMessageFromFrontendOnIOThread(const WebDevToolsMessageData&); + + typedef void (*MessageLoopDispatchHandler)(); + + // Installs dispatch handle that is going to be called periodically + // while on a breakpoint. + WEBKIT_API static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler); + + virtual void identifierForInitialRequest(unsigned long resourceId, WebFrame*, const WebURLRequest&) = 0; + virtual void willSendRequest(unsigned long resourceId, const WebURLRequest&) = 0; + virtual void didReceiveData(unsigned long resourceId, int length) = 0; + virtual void didReceiveResponse(unsigned long resourceId, const WebURLResponse&) = 0; + virtual void didFinishLoading(unsigned long resourceId) = 0; + virtual void didFailLoading(unsigned long resourceId, const WebURLError&) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDevToolsAgentClient.h b/WebKit/chromium/public/WebDevToolsAgentClient.h new file mode 100644 index 0000000..ec51654 --- /dev/null +++ b/WebKit/chromium/public/WebDevToolsAgentClient.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDevToolsAgentClient_h +#define WebDevToolsAgentClient_h + +#include "WebCommon.h" + +namespace WebKit { +class WebString; +struct WebDevToolsMessageData; + +class WebDevToolsAgentClient { +public: + // TODO(32320): remove this method from API. + virtual void sendMessageToFrontend(const WebString& className, + const WebString& methodName, + const WebString& param1, + const WebString& param2, + const WebString& param3) {} + virtual void sendMessageToFrontend(const WebDevToolsMessageData&) { } + + // Invalidates widget which leads to the repaint. + virtual void forceRepaint() { } + + // Returns the identifier of the entity hosting this agent. + virtual int hostIdentifier() { return -1; } + + // Notifies host upon runtime feature being enabled/disabled. + virtual void runtimeFeatureStateChanged(const WebString& feature, bool enabled) { } + + // TODO(32320): remove this method from API. + WEBKIT_API static void sendMessageToFrontendOnIOThread(const WebString& className, + const WebString& methodName, + const WebString& param1, + const WebString& param2, + const WebString& param3); + WEBKIT_API static void sendMessageToFrontendOnIOThread(const WebDevToolsMessageData&); + +protected: + ~WebDevToolsAgentClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDevToolsFrontend.h b/WebKit/chromium/public/WebDevToolsFrontend.h new file mode 100644 index 0000000..b7d7189 --- /dev/null +++ b/WebKit/chromium/public/WebDevToolsFrontend.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDevToolsFrontend_h +#define WebDevToolsFrontend_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebDevToolsFrontendClient; +class WebString; +class WebView; +struct WebDevToolsMessageData; + +// WebDevToolsFrontend represents DevTools client sitting in the Glue. It provides +// direct and delegate Apis to the host. +class WebDevToolsFrontend { +public: + WEBKIT_API static WebDevToolsFrontend* create(WebView* view, + WebDevToolsFrontendClient* client, + const WebString& applicationLocale); + + virtual ~WebDevToolsFrontend() {} + + virtual void dispatchMessageFromAgent(const WebString& className, + const WebString& methodName, + const WebString& param1, + const WebString& param2, + const WebString& param3) = 0; + virtual void dispatchMessageFromAgent(const WebDevToolsMessageData&) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDevToolsFrontendClient.h b/WebKit/chromium/public/WebDevToolsFrontendClient.h new file mode 100644 index 0000000..2f74a8c --- /dev/null +++ b/WebKit/chromium/public/WebDevToolsFrontendClient.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDevToolsFrontendClient_h +#define WebDevToolsFrontendClient_h + +namespace WebKit { + +class WebString; +struct WebDevToolsMessageData; + +class WebDevToolsFrontendClient { +public: + WebDevToolsFrontendClient() {} + + virtual void sendMessageToAgent(const WebString& className, + const WebString& methodName, + const WebString& param1, + const WebString& param2, + const WebString& param3) {}; + virtual void sendMessageToAgent(const WebDevToolsMessageData&) {}; + virtual void sendDebuggerCommandToAgent(const WebString& command) {}; + virtual void sendDebuggerPauseScript() {} + + virtual void activateWindow() {}; + virtual void closeWindow() {}; + virtual void dockWindow() {}; + virtual void undockWindow() {}; + +protected: + virtual ~WebDevToolsFrontendClient() {} +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDevToolsMessageData.h b/WebKit/chromium/public/WebDevToolsMessageData.h new file mode 100644 index 0000000..9bf9acd --- /dev/null +++ b/WebKit/chromium/public/WebDevToolsMessageData.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDevToolsMessageData_h +#define WebDevToolsMessageData_h + +#include "WebCommon.h" +#include "WebString.h" +#include "WebVector.h" + +namespace WebKit { + +struct WebDevToolsMessageData { + WebString className; + WebString methodName; + WebVector<WebString> arguments; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDragData.h b/WebKit/chromium/public/WebDragData.h new file mode 100644 index 0000000..f7a165d --- /dev/null +++ b/WebKit/chromium/public/WebDragData.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDragData_h +#define WebDragData_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class ChromiumDataObject; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebData; +class WebDragDataPrivate; +class WebString; +class WebURL; +template <typename T> class WebVector; + +// Holds data that may be exchanged through a drag-n-drop operation. It is +// inexpensive to copy a WebDragData object. +class WebDragData { +public: + ~WebDragData() { reset(); } + + WebDragData() : m_private(0) { } + WebDragData(const WebDragData& d) : m_private(0) { assign(d); } + WebDragData& operator=(const WebDragData& d) + { + assign(d); + return *this; + } + + WEBKIT_API void initialize(); + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebDragData&); + + bool isNull() const { return !m_private; } + + WEBKIT_API WebURL url() const; + WEBKIT_API void setURL(const WebURL&); + + WEBKIT_API WebString urlTitle() const; + WEBKIT_API void setURLTitle(const WebString&); + + WEBKIT_API WebString fileExtension() const; + WEBKIT_API void setFileExtension(const WebString&); + + WEBKIT_API bool hasFileNames() const; + WEBKIT_API void fileNames(WebVector<WebString>&) const; + WEBKIT_API void setFileNames(const WebVector<WebString>&); + WEBKIT_API void appendToFileNames(const WebString&); + + WEBKIT_API WebString plainText() const; + WEBKIT_API void setPlainText(const WebString&); + + WEBKIT_API WebString htmlText() const; + WEBKIT_API void setHTMLText(const WebString&); + + WEBKIT_API WebURL htmlBaseURL() const; + WEBKIT_API void setHTMLBaseURL(const WebURL&); + + WEBKIT_API WebString fileContentFileName() const; + WEBKIT_API void setFileContentFileName(const WebString&); + + WEBKIT_API WebData fileContent() const; + WEBKIT_API void setFileContent(const WebData&); + +#if WEBKIT_IMPLEMENTATION + WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&); + WebDragData& operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&); + operator WTF::PassRefPtr<WebCore::ChromiumDataObject>() const; +#endif + +private: + void assign(WebDragDataPrivate*); + void ensureMutable(); + WebDragDataPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDragOperation.h b/WebKit/chromium/public/WebDragOperation.h new file mode 100644 index 0000000..050b74f --- /dev/null +++ b/WebKit/chromium/public/WebDragOperation.h @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2009 Google 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: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * 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. +* * Neither the name of Google Inc. nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* 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 +* OWNER 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 WebDragOperation_h +#define WebDragOperation_h + +#include <limits.h> + +namespace WebKit { + +// "Verb" of a drag-and-drop operation as negotiated between the source and +// destination. +// (These constants match their equivalents in WebCore's DragActions.h and +// should not be renumbered.) +enum WebDragOperation { + WebDragOperationNone = 0, + WebDragOperationCopy = 1, + WebDragOperationLink = 2, + WebDragOperationGeneric = 4, + WebDragOperationPrivate = 8, + WebDragOperationMove = 16, + WebDragOperationDelete = 32, + WebDragOperationEvery = UINT_MAX +}; + +// Alternate typedef to make it clear when this is being used as a mask +// with potentially multiple value bits set. +typedef WebDragOperation WebDragOperationsMask; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebEditingAction.h b/WebKit/chromium/public/WebEditingAction.h new file mode 100644 index 0000000..4e76100 --- /dev/null +++ b/WebKit/chromium/public/WebEditingAction.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebEditingAction_h +#define WebEditingAction_h + +namespace WebKit { + +enum WebEditingAction { + WebEditingActionTyped, + WebEditingActionPasted, + WebEditingActionDropped, +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebElement.h b/WebKit/chromium/public/WebElement.h new file mode 100644 index 0000000..d7a2cbf --- /dev/null +++ b/WebKit/chromium/public/WebElement.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebElement_h +#define WebElement_h + +#include "WebNode.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Element; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + + // Provides readonly access to some properties of a DOM element node. + class WebElement : public WebNode { + public: + WebElement() : WebNode() { } + WebElement(const WebElement& e) : WebNode(e) { } + + WebElement& operator=(const WebElement& e) { WebNode::assign(e); return *this; } + WEBKIT_API void assign(const WebElement& e) { WebNode::assign(e); } + +#if WEBKIT_IMPLEMENTATION + WebElement(const WTF::PassRefPtr<WebCore::Element>&); + WebElement& operator=(const WTF::PassRefPtr<WebCore::Element>&); + operator WTF::PassRefPtr<WebCore::Element>() const; +#endif + }; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFileChooserCompletion.h b/WebKit/chromium/public/WebFileChooserCompletion.h new file mode 100644 index 0000000..14bace4 --- /dev/null +++ b/WebKit/chromium/public/WebFileChooserCompletion.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFileChooserCompletion_h +#define WebFileChooserCompletion_h + +namespace WebKit { + +class WebString; +template <typename T> class WebVector; + +// Gets called back when WebViewClient finished choosing a file. +class WebFileChooserCompletion { +public: + // Called with zero or more file names. Zero-lengthed vector means that + // the user cancelled or that file choosing failed. The callback instance + // is destroyed when this method is called. + virtual void didChooseFile(const WebVector<WebString>& fileNames) = 0; +protected: + virtual ~WebFileChooserCompletion() {} +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFindOptions.h b/WebKit/chromium/public/WebFindOptions.h new file mode 100644 index 0000000..93d48d3 --- /dev/null +++ b/WebKit/chromium/public/WebFindOptions.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFindOptions_h +#define WebFindOptions_h + +#include "WebString.h" + +namespace WebKit { + +// Options used when performing a find-in-page query. +struct WebFindOptions { + // Whether to search forward or backward within the page. + bool forward; + + // Whether search should be case-sensitive. + bool matchCase; + + // Whether this operation is the first request or a follow-up. + bool findNext; + + WebFindOptions() + : forward(true) + , matchCase(false) + , findNext(false) { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFontCache.h b/WebKit/chromium/public/WebFontCache.h new file mode 100644 index 0000000..05aadc7 --- /dev/null +++ b/WebKit/chromium/public/WebFontCache.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFontCache_h +#define WebFontCache_h + +#include "WebCommon.h" + +namespace WebKit { + +// An interface to query and configure WebKit's font cache. +class WebFontCache { +public: + // Returns the number of items in the font data cache. + WEBKIT_API static size_t fontDataCount(); + + // Returns the number of inactive items in the font data cache. + WEBKIT_API static size_t inactiveFontDataCount(); + + // Clears the cache. + WEBKIT_API static void clear(); + +private: + WebFontCache(); // Not intended to be instanced. +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFormElement.h b/WebKit/chromium/public/WebFormElement.h new file mode 100644 index 0000000..27a1edb --- /dev/null +++ b/WebKit/chromium/public/WebFormElement.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFormElement_h +#define WebFormElement_h + +#include "WebElement.h" +#include "WebInputElement.h" +#include "WebVector.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class HTMLFormElement; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + // A container for passing around a reference to a form element. Provides + // some information about the form. + class WebFormElement : public WebElement { + public: + ~WebFormElement() { reset(); } + + WebFormElement() : WebElement() { } + WebFormElement(const WebFormElement& e) : WebElement(e) { } + + WebElement& operator=(const WebFormElement& e) { WebElement::assign(e); return *this; } + WEBKIT_API void assign(const WebFormElement& e) { WebElement::assign(e); } + +#if WEBKIT_IMPLEMENTATION + WebFormElement(const WTF::PassRefPtr<WebCore::HTMLFormElement>&); + WebFormElement& operator=(const WTF::PassRefPtr<WebCore::HTMLFormElement>&); + operator WTF::PassRefPtr<WebCore::HTMLFormElement>() const; +#endif + + WEBKIT_API bool autoComplete() const; + WEBKIT_API WebString action() const; + WEBKIT_API WebString name() const; + WEBKIT_API WebString method() const; + WEBKIT_API void submit(); + // FIXME: Deprecate and replace with WebVector<WebElement>. + WEBKIT_API void getNamedElements(const WebString&, WebVector<WebNode>&); + WEBKIT_API void getInputElements(WebVector<WebInputElement>&) const; + }; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFrame.h b/WebKit/chromium/public/WebFrame.h new file mode 100644 index 0000000..44b57aa --- /dev/null +++ b/WebKit/chromium/public/WebFrame.h @@ -0,0 +1,469 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFrame_h +#define WebFrame_h + +#include "WebCanvas.h" +#include "WebURL.h" + +struct NPObject; + +#if WEBKIT_USING_V8 +namespace v8 { +class Context; +template <class T> class Local; +} +#endif + +namespace WebKit { + +class WebData; +class WebDataSource; +class WebFormElement; +class WebHistoryItem; +class WebInputElement; +class WebPasswordAutocompleteListener; +class WebRange; +class WebSecurityOrigin; +class WebString; +class WebURL; +class WebURLRequest; +class WebView; +struct WebConsoleMessage; +struct WebFindOptions; +struct WebRect; +struct WebScriptSource; +struct WebSize; +template <typename T> class WebVector; + +class WebFrame { +public: + // The two functions below retrieve the WebFrame instances relating the + // currently executing JavaScript. Since JavaScript can make function + // calls across frames, though, we need to be more precise. + // + // For example, imagine that a JS function in frame A calls a function + // in frame B, which calls native code, which wants to know what the + // 'active' frame is. + // + // The 'entered context' is the context where execution first entered + // the script engine; the context that is at the bottom of the JS + // function stack. frameForEnteredContext() would return frame A in + // our example. + // + // The 'current context' is the context the JS engine is currently + // inside of; the context that is at the top of the JS function stack. + // frameForCurrentContext() would return frame B in our example. + WEBKIT_API static WebFrame* frameForEnteredContext(); + WEBKIT_API static WebFrame* frameForCurrentContext(); + + + // Basic properties --------------------------------------------------- + + // The name of this frame. + virtual WebString name() const = 0; + + // The url of the document loaded in this frame. This is equivalent to + // dataSource()->request().url(). + virtual WebURL url() const = 0; + + // The url of the favicon (if any) specified by the document loaded in + // this frame. + virtual WebURL favIconURL() const = 0; + + // The url of the OpenSearch Desription Document (if any) specified by + // the document loaded in this frame. + virtual WebURL openSearchDescriptionURL() const = 0; + + + // Geometry ----------------------------------------------------------- + + // NOTE: These routines do not force page layout so their results may + // not be accurate if the page layout is out-of-date. + + // The scroll offset from the top-left corner of the frame in pixels. + virtual WebSize scrollOffset() const = 0; + + // The size of the contents area. + virtual WebSize contentsSize() const = 0; + + // Returns the minimum preferred width of the content contained in the + // current document. + virtual int contentsPreferredWidth() const = 0; + + // Returns the scroll height of the document element. This is + // equivalent to the DOM property of the same name, and is the minimum + // height required to display the document without scrollbars. + virtual int documentElementScrollHeight() const = 0; + + // Returns true if the contents (minus scrollbars) has non-zero area. + virtual bool hasVisibleContent() const = 0; + + + // Hierarchy ---------------------------------------------------------- + + // Returns the containing view. + virtual WebView* view() const = 0; + + // Returns the frame that opened this frame or 0 if there is none. + virtual WebFrame* opener() const = 0; + + // Returns the parent frame or 0 if this is a top-most frame. + virtual WebFrame* parent() const = 0; + + // Returns the top-most frame in the hierarchy containing this frame. + virtual WebFrame* top() const = 0; + + // Returns the first/last child frame. + virtual WebFrame* firstChild() const = 0; + virtual WebFrame* lastChild() const = 0; + + // Returns the next/previous sibling frame. + virtual WebFrame* nextSibling() const = 0; + virtual WebFrame* previousSibling() const = 0; + + // Returns the next/previous frame in "frame traversal order" + // optionally wrapping around. + virtual WebFrame* traverseNext(bool wrap) const = 0; + virtual WebFrame* traversePrevious(bool wrap) const = 0; + + // Returns the child frame identified by the given name. + virtual WebFrame* findChildByName(const WebString& name) const = 0; + + // Returns the child frame identified by the given xpath expression. + virtual WebFrame* findChildByExpression(const WebString& xpath) const = 0; + + + // Content ------------------------------------------------------------ + + virtual void forms(WebVector<WebFormElement>&) const = 0; + + + // Scripting ---------------------------------------------------------- + + // Returns the security origin of the current document. + virtual WebSecurityOrigin securityOrigin() const = 0; + + // This grants the currently loaded document access to all security + // origins (including file URLs). Use with care. The access is + // revoked when a new document is loaded into this frame. + virtual void grantUniversalAccess() = 0; + + // Returns a NPObject corresponding to this frame's DOMWindow. + virtual NPObject* windowObject() const = 0; + + // Binds a NPObject as a property of this frame's DOMWindow. + virtual void bindToWindowObject(const WebString& name, NPObject*) = 0; + + // Executes script in the context of the current page. + virtual void executeScript(const WebScriptSource&) = 0; + + // Executes script in a new context associated with the frame. The + // script gets its own global scope and its own prototypes for + // intrinsic JS objects (String, Array, and so-on). It shares the + // wrappers for all DOM nodes and DOM constructors. extensionGroup is + // an embedder-provided specifier that controls which v8 extensions are + // loaded into the new context - see WebKit::registerExtension for the + // corresponding specifier. + virtual void executeScriptInNewContext(const WebScriptSource* sources, + unsigned numSources, + int extensionGroup) = 0; + + // Executes JavaScript in a new world associated with the web frame. + // The script gets its own global scope and its own prototypes for + // intrinsic JavaScript objects (String, Array, and so-on). It also + // gets its own wrappers for all DOM nodes and DOM constructors. + // extensionGroup is an embedder-provided specifier that controls which + // v8 extensions are loaded into the new context - see + // WebKit::registerExtension for the corresponding specifier. + virtual void executeScriptInIsolatedWorld( + int worldId, const WebScriptSource* sources, unsigned numSources, + int extensionGroup) = 0; + + // Logs to the console associated with this frame. + virtual void addMessageToConsole(const WebConsoleMessage&) = 0; + + // Calls window.gc() if it is defined. + virtual void collectGarbage() = 0; + +#if WEBKIT_USING_V8 + // Returns the V8 context for this frame, or an empty handle if there + // is none. + virtual v8::Local<v8::Context> mainWorldScriptContext() const = 0; +#endif + + + // Styling ------------------------------------------------------------- + + // Insert the given text as a STYLE element at the beginning of the + // document. |elementId| can be empty, but if specified then it is used + // as the id for the newly inserted element (replacing an existing one + // with the same id, if any). + virtual bool insertStyleText(const WebString& styleText, + const WebString& elementId) = 0; + + + // Navigation ---------------------------------------------------------- + + // Reload the current document. + virtual void reload() = 0; + + // Load the given URL. + virtual void loadRequest(const WebURLRequest&) = 0; + + // Load the given history state, corresponding to a back/forward + // navigation. + virtual void loadHistoryItem(const WebHistoryItem&) = 0; + + // Loads the given data with specific mime type and optional text + // encoding. For HTML data, baseURL indicates the security origin of + // the document and is used to resolve links. If specified, + // unreachableURL is reported via WebDataSource::unreachableURL. If + // replace is false, then this data will be loaded as a normal + // navigation. Otherwise, the current history item will be replaced. + virtual void loadData(const WebData& data, + const WebString& mimeType, + const WebString& textEncoding, + const WebURL& baseURL, + const WebURL& unreachableURL = WebURL(), + bool replace = false) = 0; + + // This method is short-hand for calling LoadData, where mime_type is + // "text/html" and text_encoding is "UTF-8". + virtual void loadHTMLString(const WebData& html, + const WebURL& baseURL, + const WebURL& unreachableURL = WebURL(), + bool replace = false) = 0; + + // Returns true if the current frame is busy loading content. + virtual bool isLoading() const = 0; + + // Stops any pending loads on the frame and its children. + virtual void stopLoading() = 0; + + // Returns the data source that is currently loading. May be null. + virtual WebDataSource* provisionalDataSource() const = 0; + + // Returns the data source that is currently loaded. + virtual WebDataSource* dataSource() const = 0; + + // Returns the previous history item. Check WebHistoryItem::isNull() + // before using. + virtual WebHistoryItem previousHistoryItem() const = 0; + + // Returns the current history item. Check WebHistoryItem::isNull() + // before using. + virtual WebHistoryItem currentHistoryItem() const = 0; + + // View-source rendering mode. Set this before loading an URL to cause + // it to be rendered in view-source mode. + virtual void enableViewSourceMode(bool) = 0; + virtual bool isViewSourceModeEnabled() const = 0; + + // Sets the referrer for the given request to be the specified URL or + // if that is null, then it sets the referrer to the referrer that the + // frame would use for subresources. NOTE: This method also filters + // out invalid referrers (e.g., it is invalid to send a HTTPS URL as + // the referrer for a HTTP request). + virtual void setReferrerForRequest(WebURLRequest&, const WebURL&) = 0; + + // Called to associate the WebURLRequest with this frame. The request + // will be modified to inherit parameters that allow it to be loaded. + // This method ends up triggering WebFrameClient::willSendRequest. + virtual void dispatchWillSendRequest(WebURLRequest&) = 0; + + // Called from within WebFrameClient::didReceiveDocumentData to commit + // data for the frame that will be used to construct the frame's + // document. + virtual void commitDocumentData(const char* data, size_t length) = 0; + + // Returns the number of registered unload listeners. + virtual unsigned unloadListenerCount() const = 0; + + // Returns true if a user gesture is currently being processed. + virtual bool isProcessingUserGesture() const = 0; + + // Returns true if this frame is in the process of opening a new frame + // with a suppressed opener. + virtual bool willSuppressOpenerInNewFrame() const = 0; + + + // Editing ------------------------------------------------------------- + + // Replaces the selection with the given text. + virtual void replaceSelection(const WebString& text) = 0; + + virtual void insertText(const WebString& text) = 0; + + virtual void setMarkedText(const WebString& text, unsigned location, unsigned length) = 0; + virtual void unmarkText() = 0; + virtual bool hasMarkedText() const = 0; + + virtual WebRange markedRange() const = 0; + + // Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll, + // Unselect, etc. See EditorCommand.cpp for the full list of supported + // commands. + virtual bool executeCommand(const WebString&) = 0; + virtual bool executeCommand(const WebString&, const WebString& value) = 0; + virtual bool isCommandEnabled(const WebString&) const = 0; + + // Spell-checking support. + virtual void enableContinuousSpellChecking(bool) = 0; + virtual bool isContinuousSpellCheckingEnabled() const = 0; + + + // Selection ----------------------------------------------------------- + + virtual bool hasSelection() const = 0; + + virtual WebRange selectionRange() const = 0; + + virtual WebString selectionAsText() const = 0; + virtual WebString selectionAsMarkup() const = 0; + + + // Printing ------------------------------------------------------------ + + // Reformats the WebFrame for printing. pageSize is the page size in + // pixels. Returns the number of pages that can be printed at the + // given page size. + virtual int printBegin(const WebSize& pageSize) = 0; + + // Returns the page shrinking factor calculated by webkit (usually + // between 1/1.25 and 1/2). Returns 0 if the page number is invalid or + // not in printing mode. + virtual float getPrintPageShrink(int page) = 0; + + // Prints one page, and returns the calculated page shrinking factor + // (usually between 1/1.25 and 1/2). Returns 0 if the page number is + // invalid or not in printing mode. + virtual float printPage(int pageToPrint, WebCanvas*) = 0; + + // Reformats the WebFrame for screen display. + virtual void printEnd() = 0; + + + // Find-in-page -------------------------------------------------------- + + // Searches a frame for a given string. + // + // If a match is found, this function will select it (scrolling down to + // make it visible if needed) and fill in selectionRect with the + // location of where the match was found (in window coordinates). + // + // If no match is found, this function clears all tickmarks and + // highlighting. + // + // Returns true if the search string was found, false otherwise. + virtual bool find(int identifier, + const WebString& searchText, + const WebFindOptions& options, + bool wrapWithinFrame, + WebRect* selectionRect) = 0; + + // Notifies the frame that we are no longer interested in searching. + // This will abort any asynchronous scoping effort already under way + // (see the function scopeStringMatches for details) and erase all + // tick-marks and highlighting from the previous search. If + // clearSelection is true, it will also make sure the end state for the + // find operation does not leave a selection. This can occur when the + // user clears the search string but does not close the find box. + virtual void stopFinding(bool clearSelection) = 0; + + // Counts how many times a particular string occurs within the frame. + // It also retrieves the location of the string and updates a vector in + // the frame so that tick-marks and highlighting can be drawn. This + // function does its work asynchronously, by running for a certain + // time-slice and then scheduling itself (co-operative multitasking) to + // be invoked later (repeating the process until all matches have been + // found). This allows multiple frames to be searched at the same time + // and provides a way to cancel at any time (see + // cancelPendingScopingEffort). The parameter searchText specifies + // what to look for and |reset| signals whether this is a brand new + // request or a continuation of the last scoping effort. + virtual void scopeStringMatches(int identifier, + const WebString& searchText, + const WebFindOptions& options, + bool reset) = 0; + + // Cancels any outstanding requests for scoping string matches on a frame. + virtual void cancelPendingScopingEffort() = 0; + + // This function is called on the main frame during the scoping effort + // to keep a running tally of the accumulated total match-count for all + // frames. After updating the count it will notify the WebViewClient + // about the new count. + virtual void increaseMatchCount(int count, int identifier) = 0; + + // This function is called on the main frame to reset the total number + // of matches found during the scoping effort. + virtual void resetMatchCount() = 0; + + // Password autocompletion --------------------------------------------- + + // Registers a listener for the specified user name input element. The + // listener will receive notifications for blur and when autocomplete + // should be triggered. + // The WebFrame becomes the owner of the passed listener. + virtual void registerPasswordListener( + WebInputElement, + WebPasswordAutocompleteListener*) = 0; + + // Utility ------------------------------------------------------------- + + // Given a relative URL, returns an absolute URL by resolving the URL + // relative to the base URL of the frame's document. This uses the + // same algorithm that WebKit uses to resolve hyperlinks found in a + // HTML document. + virtual WebURL completeURL(const WebString&) const = 0; + + // Returns the contents of this frame as a string. If the text is + // longer than maxChars, it will be clipped to that length. WARNING: + // This function may be slow depending on the number of characters + // retrieved and page complexity. For a typically sized page, expect + // it to take on the order of milliseconds. + // + // If there is room, subframe text will be recursively appended. Each + // frame will be separated by an empty line. + virtual WebString contentAsText(size_t maxChars) const = 0; + + // Returns HTML text for the contents of this frame. This is generated + // from the DOM. + virtual WebString contentAsMarkup() const = 0; + +protected: + ~WebFrame() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFrameClient.h b/WebKit/chromium/public/WebFrameClient.h new file mode 100644 index 0000000..297eb62 --- /dev/null +++ b/WebKit/chromium/public/WebFrameClient.h @@ -0,0 +1,290 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFrameClient_h +#define WebFrameClient_h + +#include "WebCommon.h" +#include "WebNavigationPolicy.h" +#include "WebNavigationType.h" +#include "WebURLError.h" + +namespace WebKit { + +class WebDataSource; +class WebFormElement; +class WebFrame; +class WebMediaPlayer; +class WebMediaPlayerClient; +class WebNode; +class WebPlugin; +class WebSecurityOrigin; +class WebSharedWorker; +class WebString; +class WebURL; +class WebURLRequest; +class WebURLResponse; +class WebWorker; +class WebWorkerClient; +struct WebPluginParams; +struct WebRect; +struct WebSize; +struct WebURLError; + +class WebFrameClient { +public: + // Factory methods ----------------------------------------------------- + + // May return null. + virtual WebPlugin* createPlugin(WebFrame*, const WebPluginParams&) { return 0; } + + // May return null. + virtual WebWorker* createWorker(WebFrame*, WebWorkerClient*) { return 0; } + + // May return null. + virtual WebSharedWorker* createSharedWorker(WebFrame*, const WebURL&, const WebString&, unsigned long long) { return 0; } + + // May return null. + virtual WebMediaPlayer* createMediaPlayer(WebFrame*, WebMediaPlayerClient*) { return 0; } + + + // General notifications ----------------------------------------------- + + // This frame is about to be closed. + virtual void willClose(WebFrame*) { } + + + // Load commands ------------------------------------------------------- + + // The client should handle the navigation externally. + virtual void loadURLExternally( + WebFrame*, const WebURLRequest&, WebNavigationPolicy) { } + + + // Navigational queries ------------------------------------------------ + + // The client may choose to alter the navigation policy. Otherwise, + // defaultPolicy should just be returned. + virtual WebNavigationPolicy decidePolicyForNavigation( + WebFrame*, const WebURLRequest&, WebNavigationType, + const WebNode& originatingNode, + WebNavigationPolicy defaultPolicy, bool isRedirect) { return defaultPolicy; } + + // Query if the specified request can be handled. + virtual bool canHandleRequest( + WebFrame*, const WebURLRequest& request) { return true; } + + // Returns an error corresponding to canHandledRequest() returning false. + virtual WebURLError cannotHandleRequestError( + WebFrame*, const WebURLRequest& request) { return WebURLError(); } + + // Returns an error corresponding to a user cancellation event. + virtual WebURLError cancelledError( + WebFrame*, const WebURLRequest& request) { return WebURLError(); } + + // Notify that a URL cannot be handled. + virtual void unableToImplementPolicyWithError( + WebFrame*, const WebURLError&) { } + + + // Navigational notifications ------------------------------------------ + + // A form submission is about to occur. + virtual void willSubmitForm(WebFrame*, const WebFormElement&) { } + + // A client-side redirect will occur. This may correspond to a <META + // refresh> or some script activity. + virtual void willPerformClientRedirect( + WebFrame*, const WebURL& from, const WebURL& to, + double interval, double fireTime) { } + + // A client-side redirect was cancelled. + virtual void didCancelClientRedirect(WebFrame*) { } + + // A client-side redirect completed. + virtual void didCompleteClientRedirect(WebFrame*, const WebURL& fromURL) { } + + // A datasource has been created for a new navigation. The given + // datasource will become the provisional datasource for the frame. + virtual void didCreateDataSource(WebFrame*, WebDataSource*) { } + + // A new provisional load has been started. + virtual void didStartProvisionalLoad(WebFrame*) { } + + // The provisional load was redirected via a HTTP 3xx response. + virtual void didReceiveServerRedirectForProvisionalLoad(WebFrame*) { } + + // The provisional load failed. + virtual void didFailProvisionalLoad(WebFrame*, const WebURLError&) { } + + // Notifies the client to commit data for the given frame. The client + // may optionally prevent default processing by setting preventDefault + // to true before returning. If default processing is prevented, then + // it is up to the client to manually call commitDocumentData on the + // WebFrame. It is only valid to call commitDocumentData within a call + // to didReceiveDocumentData. If commitDocumentData is not called, + // then an empty document will be loaded. + virtual void didReceiveDocumentData( + WebFrame*, const char* data, size_t length, bool& preventDefault) { } + + // The provisional datasource is now committed. The first part of the + // response body has been received, and the encoding of the response + // body is known. + virtual void didCommitProvisionalLoad(WebFrame*, bool isNewNavigation) { } + + // The window object for the frame has been cleared of any extra + // properties that may have been set by script from the previously + // loaded document. + virtual void didClearWindowObject(WebFrame*) { } + + // The document element has been created. + virtual void didCreateDocumentElement(WebFrame*) { } + + // The page title is available. + virtual void didReceiveTitle(WebFrame*, const WebString& title) { } + + // The frame's document finished loading. + virtual void didFinishDocumentLoad(WebFrame*) { } + + // The 'load' event was dispatched. + virtual void didHandleOnloadEvents(WebFrame*) { } + + // The frame's document or one of its subresources failed to load. + virtual void didFailLoad(WebFrame*, const WebURLError&) { } + + // The frame's document and all of its subresources succeeded to load. + virtual void didFinishLoad(WebFrame*) { } + + // The navigation resulted in scrolling the page to a named anchor instead + // of downloading a new document. + virtual void didChangeLocationWithinPage(WebFrame*, bool isNewNavigation) { } + + // Called upon update to scroll position, document state, and other + // non-navigational events related to the data held by WebHistoryItem. + // WARNING: This method may be called very frequently. + virtual void didUpdateCurrentHistoryItem(WebFrame*) { } + + + // Low-level resource notifications ------------------------------------ + + // An identifier was assigned to the specified request. The client + // should remember this association if interested in subsequent events. + virtual void assignIdentifierToRequest( + WebFrame*, unsigned identifier, const WebURLRequest&) { } + + // A request is about to be sent out, and the client may modify it. Request + // is writable, and changes to the URL, for example, will change the request + // made. If this request is the result of a redirect, then redirectResponse + // will be non-null and contain the response that triggered the redirect. + virtual void willSendRequest( + WebFrame*, unsigned identifier, WebURLRequest&, + const WebURLResponse& redirectResponse) { } + + // Response headers have been received for the resource request given + // by identifier. + virtual void didReceiveResponse( + WebFrame*, unsigned identifier, const WebURLResponse&) { } + + // The resource request given by identifier succeeded. + virtual void didFinishResourceLoad( + WebFrame*, unsigned identifier) { } + + // The resource request given by identifier failed. + virtual void didFailResourceLoad( + WebFrame*, unsigned identifier, const WebURLError&) { } + + // The specified request was satified from WebCore's memory cache. + virtual void didLoadResourceFromMemoryCache( + WebFrame*, const WebURLRequest&, const WebURLResponse&) { } + + // This frame has displayed inactive content (such as an image) from an + // insecure source. Inactive content cannot spread to other frames. + virtual void didDisplayInsecureContent(WebFrame*) { } + + // The indicated security origin has run active content (such as a + // script) from an insecure source. Note that the insecure content can + // spread to other frames in the same origin. + virtual void didRunInsecureContent(WebFrame*, const WebSecurityOrigin&) { } + + + // Script notifications ------------------------------------------------ + + // Controls whether scripts are allowed to execute for this frame. + virtual bool allowScript(WebFrame*, bool enabledPerSettings) { return enabledPerSettings; } + + // Script in the page tried to allocate too much memory. + virtual void didExhaustMemoryAvailableForScript(WebFrame*) { } + + // Notifies that a new script context has been created for this frame. + // This is similar to didClearWindowObject but only called once per + // frame context. + virtual void didCreateScriptContext(WebFrame*) { } + + // Notifies that this frame's script context has been destroyed. + virtual void didDestroyScriptContext(WebFrame*) { } + + // Notifies that a garbage-collected context was created - content + // scripts. + virtual void didCreateIsolatedScriptContext(WebFrame*) { } + + + // Geometry notifications ---------------------------------------------- + + // The size of the content area changed. + virtual void didChangeContentsSize(WebFrame*, const WebSize&) { } + + // The main frame scrolled. + virtual void didChangeScrollOffset(WebFrame*) { } + + + // Find-in-page notifications ------------------------------------------ + + // Notifies how many matches have been found so far, for a given + // identifier. |finalUpdate| specifies whether this is the last update + // (all frames have completed scoping). + virtual void reportFindInPageMatchCount( + int identifier, int count, bool finalUpdate) { } + + // Notifies what tick-mark rect is currently selected. The given + // identifier lets the client know which request this message belongs + // to, so that it can choose to ignore the message if it has moved on + // to other things. The selection rect is expected to have coordinates + // relative to the top left corner of the web page area and represent + // where on the screen the selection rect is currently located. + virtual void reportFindInPageSelection( + int identifier, int activeMatchOrdinal, const WebRect& selection) { } + +protected: + ~WebFrameClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebHTTPBody.h b/WebKit/chromium/public/WebHTTPBody.h new file mode 100644 index 0000000..43f51a6 --- /dev/null +++ b/WebKit/chromium/public/WebHTTPBody.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebHTTPBody_h +#define WebHTTPBody_h + +#include "WebData.h" +#include "WebNonCopyable.h" +#include "WebString.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class FormData; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebHTTPBodyPrivate; + +class WebHTTPBody { +public: + struct Element { + enum { TypeData, TypeFile } type; + WebData data; + WebString filePath; + }; + + ~WebHTTPBody() { reset(); } + + WebHTTPBody() : m_private(0) { } + WebHTTPBody(const WebHTTPBody& b) : m_private(0) { assign(b); } + WebHTTPBody& operator=(const WebHTTPBody& b) + { + assign(b); + return *this; + } + + WEBKIT_API void initialize(); + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebHTTPBody&); + + bool isNull() const { return !m_private; } + + // Returns the number of elements comprising the http body. + WEBKIT_API size_t elementCount() const; + + // Sets the values of the element at the given index. Returns false if + // index is out of bounds. + WEBKIT_API bool elementAt(size_t index, Element&) const; + + // Append to the list of elements. + WEBKIT_API void appendData(const WebData&); + WEBKIT_API void appendFile(const WebString&); + + // Identifies a particular form submission instance. A value of 0 is + // used to indicate an unspecified identifier. + WEBKIT_API long long identifier() const; + WEBKIT_API void setIdentifier(long long); + +#if WEBKIT_IMPLEMENTATION + WebHTTPBody(const WTF::PassRefPtr<WebCore::FormData>&); + WebHTTPBody& operator=(const WTF::PassRefPtr<WebCore::FormData>&); + operator WTF::PassRefPtr<WebCore::FormData>() const; +#endif + +private: + void assign(WebHTTPBodyPrivate*); + void ensureMutable(); + WebHTTPBodyPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebHTTPHeaderVisitor.h b/WebKit/chromium/public/WebHTTPHeaderVisitor.h new file mode 100644 index 0000000..2ca86c0 --- /dev/null +++ b/WebKit/chromium/public/WebHTTPHeaderVisitor.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebHTTPHeaderVisitor_h +#define WebHTTPHeaderVisitor_h + +namespace WebKit { + +class WebString; + +class WebHTTPHeaderVisitor { +public: + virtual void visitHeader(const WebString& name, const WebString& value) = 0; + +protected: + ~WebHTTPHeaderVisitor() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebHistoryItem.h b/WebKit/chromium/public/WebHistoryItem.h new file mode 100644 index 0000000..f15a62c --- /dev/null +++ b/WebKit/chromium/public/WebHistoryItem.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebHistoryItem_h +#define WebHistoryItem_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class HistoryItem; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebHistoryItemPrivate; +class WebHTTPBody; +class WebString; +struct WebPoint; +template <typename T> class WebVector; + +// Represents a frame-level navigation entry in session history. A +// WebHistoryItem is a node in a tree. +// +// Copying a WebHistoryItem is cheap. +// +class WebHistoryItem { +public: + ~WebHistoryItem() { reset(); } + + WebHistoryItem() : m_private(0) { } + WebHistoryItem(const WebHistoryItem& h) : m_private(0) { assign(h); } + WebHistoryItem& operator=(const WebHistoryItem& h) + { + assign(h); + return *this; + } + + WEBKIT_API void initialize(); + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebHistoryItem&); + + bool isNull() const { return !m_private; } + + WEBKIT_API WebString urlString() const; + WEBKIT_API void setURLString(const WebString&); + + WEBKIT_API WebString originalURLString() const; + WEBKIT_API void setOriginalURLString(const WebString&); + + WEBKIT_API WebString referrer() const; + WEBKIT_API void setReferrer(const WebString&); + + WEBKIT_API WebString target() const; + WEBKIT_API void setTarget(const WebString&); + + WEBKIT_API WebString parent() const; + WEBKIT_API void setParent(const WebString&); + + WEBKIT_API WebString title() const; + WEBKIT_API void setTitle(const WebString&); + + WEBKIT_API WebString alternateTitle() const; + WEBKIT_API void setAlternateTitle(const WebString&); + + WEBKIT_API double lastVisitedTime() const; + WEBKIT_API void setLastVisitedTime(double); + + WEBKIT_API WebPoint scrollOffset() const; + WEBKIT_API void setScrollOffset(const WebPoint&); + + WEBKIT_API bool isTargetItem() const; + WEBKIT_API void setIsTargetItem(bool); + + WEBKIT_API int visitCount() const; + WEBKIT_API void setVisitCount(int); + + WEBKIT_API WebVector<WebString> documentState() const; + WEBKIT_API void setDocumentState(const WebVector<WebString>&); + + WEBKIT_API WebString httpContentType() const; + WEBKIT_API void setHTTPContentType(const WebString&); + + WEBKIT_API WebHTTPBody httpBody() const; + WEBKIT_API void setHTTPBody(const WebHTTPBody&); + + WEBKIT_API WebVector<WebHistoryItem> children() const; + WEBKIT_API void setChildren(const WebVector<WebHistoryItem>&); + WEBKIT_API void appendToChildren(const WebHistoryItem&); + +#if WEBKIT_IMPLEMENTATION + WebHistoryItem(const WTF::PassRefPtr<WebCore::HistoryItem>&); + WebHistoryItem& operator=(const WTF::PassRefPtr<WebCore::HistoryItem>&); + operator WTF::PassRefPtr<WebCore::HistoryItem>() const; +#endif + +private: + void assign(WebHistoryItemPrivate*); + void ensureMutable(); + WebHistoryItemPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebImage.h b/WebKit/chromium/public/WebImage.h new file mode 100644 index 0000000..a7b6f8c --- /dev/null +++ b/WebKit/chromium/public/WebImage.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebImage_h +#define WebImage_h + +#include "WebCommon.h" + +#if WEBKIT_USING_SKIA +#include <SkBitmap.h> +#elif WEBKIT_USING_CG +typedef struct CGImage* CGImageRef; +#endif + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Image; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebData; +struct WebSize; + +// A container for an ARGB bitmap. +class WebImage { +public: + ~WebImage() { reset(); } + + WebImage() { init(); } + WebImage(const WebImage& image) + { + init(); + assign(image); + } + + WebImage& operator=(const WebImage& image) + { + assign(image); + return *this; + } + + // Decodes the given image data. If the image has multiple frames, + // then the frame whose size is desiredSize is returned. Otherwise, + // the first frame is returned. + WEBKIT_API static WebImage fromData(const WebData&, const WebSize& desiredSize); + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebImage&); + + WEBKIT_API bool isNull() const; + WEBKIT_API WebSize size() const; + +#if WEBKIT_IMPLEMENTATION + WebImage(const WTF::PassRefPtr<WebCore::Image>&); + WebImage& operator=(const WTF::PassRefPtr<WebCore::Image>&); +#endif + +#if WEBKIT_USING_SKIA + WebImage(const SkBitmap& bitmap) : m_bitmap(bitmap) { } + + WebImage& operator=(const SkBitmap& bitmap) + { + m_bitmap = bitmap; + return *this; + } + + SkBitmap& getSkBitmap() { return m_bitmap; } + const SkBitmap& getSkBitmap() const { return m_bitmap; } + +private: + void init() { } + SkBitmap m_bitmap; + +#elif WEBKIT_USING_CG + WebImage(CGImageRef imageRef) + { + init(); + assign(imageRef); + } + + WebImage& operator=(CGImageRef imageRef) + { + assign(imageRef); + return *this; + } + + CGImageRef getCGImageRef() const { return m_imageRef; } + +private: + void init() { m_imageRef = 0; } + void assign(CGImageRef); + CGImageRef m_imageRef; +#endif +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebInputElement.h b/WebKit/chromium/public/WebInputElement.h new file mode 100644 index 0000000..75e44b9 --- /dev/null +++ b/WebKit/chromium/public/WebInputElement.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebInputElement_h +#define WebInputElement_h + +#include "WebElement.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class HTMLInputElement; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + + // Provides readonly access to some properties of a DOM input element node. + class WebInputElement : public WebElement { + public: + WebInputElement() : WebElement() { } + WebInputElement(const WebInputElement& n) : WebElement(n) { } + + WebInputElement& operator=(const WebInputElement& n) { WebElement::assign(n); return *this; } + WEBKIT_API void assign(const WebInputElement& n) { WebElement::assign(n); } + +#if WEBKIT_IMPLEMENTATION + WebInputElement(const WTF::PassRefPtr<WebCore::HTMLInputElement>&); + WebInputElement& operator=(const WTF::PassRefPtr<WebCore::HTMLInputElement>&); + operator WTF::PassRefPtr<WebCore::HTMLInputElement>() const; +#endif + + enum InputType { + Text = 0, + Password, + IsIndex, + CheckBox, + Radio, + Submit, + Reset, + File, + Hidden, + Image, + Button, + Search, + Range, + Email, + Number, + Telephone, + URL, + Color, + Date, + DateTime, + DateTimeLocal, + Month, + Time, + Week + }; + + WEBKIT_API bool isEnabledFormControl() const; + WEBKIT_API InputType inputType() const; + WEBKIT_API WebString formControlType() const; + WEBKIT_API void setActivatedSubmit(bool); + WEBKIT_API void setValue(const WebString& value); + WEBKIT_API WebString value() const; + WEBKIT_API void setAutofilled(bool); + WEBKIT_API void dispatchFormControlChangeEvent(); + WEBKIT_API void setSelectionRange(int, int); + WEBKIT_API WebString name() const; + // Returns the name that should be used for the specified |element| when + // storing autofill data. This is either the field name or its id, an empty + // string if it has no name and no id. + WEBKIT_API WebString nameForAutofill() const; + + }; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebInputEvent.h b/WebKit/chromium/public/WebInputEvent.h new file mode 100644 index 0000000..983aa2a --- /dev/null +++ b/WebKit/chromium/public/WebInputEvent.h @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebInputEvent_h +#define WebInputEvent_h + +#include "WebCommon.h" + +#include <string.h> + +namespace WebKit { + +// The classes defined in this file are intended to be used with +// WebWidget's handleInputEvent method. These event types are cross- +// platform and correspond closely to WebCore's Platform*Event classes. +// +// WARNING! These classes must remain PODs (plain old data). They are +// intended to be "serializable" by copying their raw bytes, so they must +// not contain any non-bit-copyable member variables! + +// WebInputEvent -------------------------------------------------------------- + +class WebInputEvent { +public: + WebInputEvent(unsigned sizeParam = sizeof(WebInputEvent)) + : size(sizeParam) + , type(Undefined) + , modifiers(0) + , timeStampSeconds(0.0) { } + + // When we use an input method (or an input method editor), we receive + // two events for a keypress. The former event is a keydown, which + // provides a keycode, and the latter is a textinput, which provides + // a character processed by an input method. (The mapping from a + // keycode to a character code is not trivial for non-English + // keyboards.) + // To support input methods, Safari sends keydown events to WebKit for + // filtering. WebKit sends filtered keydown events back to Safari, + // which sends them to input methods. + // Unfortunately, it is hard to apply this design to Chrome because of + // our multiprocess architecture. An input method is running in a + // browser process. On the other hand, WebKit is running in a renderer + // process. So, this design results in increasing IPC messages. + // To support input methods without increasing IPC messages, Chrome + // handles keyboard events in a browser process and send asynchronous + // input events (to be translated to DOM events) to a renderer + // process. + // This design is mostly the same as the one of Windows and Mac Carbon. + // So, for what it's worth, our Linux and Mac front-ends emulate our + // Windows front-end. To emulate our Windows front-end, we can share + // our back-end code among Windows, Linux, and Mac. + // TODO(hbono): Issue 18064: remove the KeyDown type since it isn't + // used in Chrome any longer. + + enum Type { + Undefined = -1, + + // WebMouseEvent + MouseDown, + MouseUp, + MouseMove, + MouseEnter, + MouseLeave, + + // WebMouseWheelEvent + MouseWheel, + + // WebKeyboardEvent + RawKeyDown, + KeyDown, + KeyUp, + Char + }; + + enum Modifiers { + // modifiers for all events: + ShiftKey = 1 << 0, + ControlKey = 1 << 1, + AltKey = 1 << 2, + MetaKey = 1 << 3, + + // modifiers for keyboard events: + IsKeyPad = 1 << 4, + IsAutoRepeat = 1 << 5, + + // modifiers for mouse events: + LeftButtonDown = 1 << 6, + MiddleButtonDown = 1 << 7, + RightButtonDown = 1 << 8, + }; + + unsigned size; // The size of this structure, for serialization. + Type type; + int modifiers; + double timeStampSeconds; // Seconds since epoch. + + // Returns true if the WebInputEvent |type| is a keyboard event. + static bool isKeyboardEventType(int type) + { + return type == RawKeyDown + || type == KeyDown + || type == KeyUp + || type == Char; + } +}; + +// WebKeyboardEvent ----------------------------------------------------------- + +class WebKeyboardEvent : public WebInputEvent { +public: + // Caps on string lengths so we can make them static arrays and keep + // them PODs. + static const size_t textLengthCap = 4; + + // http://www.w3.org/TR/DOM-Level-3-Events/keyset.html lists the + // identifiers. The longest is 18 characters, so we round up to the + // next multiple of 4. + static const size_t keyIdentifierLengthCap = 20; + + // |windowsKeyCode| is the Windows key code associated with this key + // event. Sometimes it's direct from the event (i.e. on Windows), + // sometimes it's via a mapping function. If you want a list, see + // WebCore/platform/chromium/KeyboardCodes* . + int windowsKeyCode; + + // The actual key code genenerated by the platform. The DOM spec runs + // on Windows-equivalent codes (thus |windowsKeyCode| above) but it + // doesn't hurt to have this one around. + int nativeKeyCode; + + // |text| is the text generated by this keystroke. |unmodifiedText| is + // |text|, but unmodified by an concurrently-held modifiers (except + // shift). This is useful for working out shortcut keys. Linux and + // Windows guarantee one character per event. The Mac does not, but in + // reality that's all it ever gives. We're generous, and cap it a bit + // longer. + WebUChar text[textLengthCap]; + WebUChar unmodifiedText[textLengthCap]; + + // This is a string identifying the key pressed. + char keyIdentifier[keyIdentifierLengthCap]; + + // This identifies whether this event was tagged by the system as being + // a "system key" event (see + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for + // details). Other platforms don't have this concept, but it's just + // easier to leave it always false than ifdef. + // int is used instead of bool to ensure the size of this structure is + // strictly aligned to a factor of 4 bytes, otherwise memory check tools + // like valgrind may complain about uninitialized memory usage when + // transfering it over the wire. + int isSystemKey; + + WebKeyboardEvent(unsigned sizeParam = sizeof(WebKeyboardEvent)) + : WebInputEvent(sizeParam) + , windowsKeyCode(0) + , nativeKeyCode(0) + , isSystemKey(false) + { + memset(&text, 0, sizeof(text)); + memset(&unmodifiedText, 0, sizeof(unmodifiedText)); + memset(&keyIdentifier, 0, sizeof(keyIdentifier)); + } + + // Sets keyIdentifier based on the value of windowsKeyCode. This is + // handy for generating synthetic keyboard events. + WEBKIT_API void setKeyIdentifierFromWindowsKeyCode(); +}; + +// WebMouseEvent -------------------------------------------------------------- + +class WebMouseEvent : public WebInputEvent { +public: + // These values defined for WebCore::MouseButton + enum Button { + ButtonNone = -1, + ButtonLeft, + ButtonMiddle, + ButtonRight + }; + + Button button; + int x; + int y; + int windowX; + int windowY; + int globalX; + int globalY; + int clickCount; + + WebMouseEvent(unsigned sizeParam = sizeof(WebMouseEvent)) + : WebInputEvent(sizeParam) + , button(ButtonNone) + , x(0) + , y(0) + , windowX(0) + , windowY(0) + , globalX(0) + , globalY(0) + , clickCount(0) + { + } +}; + +// WebMouseWheelEvent --------------------------------------------------------- + +class WebMouseWheelEvent : public WebMouseEvent { +public: + float deltaX; + float deltaY; + float wheelTicksX; + float wheelTicksY; + + // int is used instead of bool to ensure the size of this structure is + // strictly aligned to a factor of 4 bytes, otherwise memory check tools + // like valgrind may complain about uninitialized memory usage when + // transfering it over the wire. + int scrollByPage; + + WebMouseWheelEvent(unsigned sizeParam = sizeof(WebMouseWheelEvent)) + : WebMouseEvent(sizeParam) + , deltaX(0.0f) + , deltaY(0.0f) + , wheelTicksX(0.0f) + , wheelTicksY(0.0f) + , scrollByPage(false) + { + } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebKit.h b/WebKit/chromium/public/WebKit.h new file mode 100644 index 0000000..b9e6407 --- /dev/null +++ b/WebKit/chromium/public/WebKit.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebKit_h +#define WebKit_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebKitClient; + +// Must be called on the thread that will be the main WebKit thread before +// using any other WebKit APIs. The provided WebKitClient must be non-null +// and must remain valid until the current thread calls shutdown. +WEBKIT_API void initialize(WebKitClient*); + +// Once shutdown, the WebKitClient passed to initialize will no longer be +// accessed. No other WebKit objects should be in use when this function +// is called. Any background threads created by WebKit are promised to be +// terminated by the time this function returns. +WEBKIT_API void shutdown(); + +// Returns the WebKitClient instance passed to initialize. +WEBKIT_API WebKitClient* webKitClient(); + +// Alters the rendering of content to conform to a fixed set of rules. +WEBKIT_API void setLayoutTestMode(bool); +WEBKIT_API bool layoutTestMode(); + +// Purge the plugin list cache. If |reloadPages| is true, any pages +// containing plugins will be reloaded after refreshing the plugin list. +WEBKIT_API void resetPluginCache(bool reloadPages); + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebKitClient.h b/WebKit/chromium/public/WebKitClient.h new file mode 100644 index 0000000..2a00a9a --- /dev/null +++ b/WebKit/chromium/public/WebKitClient.h @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebKitClient_h +#define WebKitClient_h + +#include "WebCommon.h" +#include "WebData.h" +#include "WebLocalizedString.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebVector.h" + +#include <time.h> + +#ifdef WIN32 +typedef void *HANDLE; +#endif + +namespace WebKit { + +class WebApplicationCacheHost; +class WebApplicationCacheHostClient; +class WebClipboard; +class WebMessagePortChannel; +class WebMimeRegistry; +class WebPluginListBuilder; +class WebSandboxSupport; +class WebSharedWorkerRepository; +class WebSocketStreamHandle; +class WebStorageNamespace; +class WebThemeEngine; +class WebURLLoader; +struct WebCookie; +struct WebPluginInfo; +template <typename T> class WebVector; + +class WebKitClient { +public: + // Must return non-null. + virtual WebClipboard* clipboard() { return 0; } + + // Must return non-null. + virtual WebMimeRegistry* mimeRegistry() { return 0; } + + // May return null if sandbox support is not necessary + virtual WebSandboxSupport* sandboxSupport() { return 0; } + + // May return null on some platforms. + virtual WebThemeEngine* themeEngine() { return 0; } + + + // Application Cache -------------------------------------------- + + // May return null if the process type doesn't involve appcaching. + virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) { return 0; } + + + // DOM Storage -------------------------------------------------- + + // Return a LocalStorage namespace that corresponds to the following path. + virtual WebStorageNamespace* createLocalStorageNamespace(const WebString& path, unsigned quota) { return 0; } + + // Return a new SessionStorage namespace. + virtual WebStorageNamespace* createSessionStorageNamespace() { return 0; } + + // Called when storage events fire. + virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue, + const WebString& newValue, const WebString& origin, + const WebURL& url, bool isLocalStorage) { } + + + // File ---------------------------------------------------------------- + + // Various file/directory related functions. These map 1:1 with + // functions in WebCore's FileSystem.h. + virtual bool fileExists(const WebString& path) { return false; } + virtual bool deleteFile(const WebString& path) { return false; } + virtual bool deleteEmptyDirectory(const WebString& path) { return false; } + virtual bool getFileSize(const WebString& path, long long& result) { return false; } + virtual bool getFileModificationTime(const WebString& path, time_t& result) { return false; } + virtual WebString directoryName(const WebString& path) { return WebString(); } + virtual WebString pathByAppendingComponent(const WebString& path, const WebString& component) { return WebString(); } + virtual bool makeAllDirectories(const WebString& path) { return false; } + virtual WebString getAbsolutePath(const WebString& path) { return WebString(); } + virtual bool isDirectory(const WebString& path) { return false; } + virtual WebURL filePathToURL(const WebString& path) { return WebURL(); } + + + // History ------------------------------------------------------------- + + // Returns the hash for the given canonicalized URL for use in visited + // link coloring. + virtual unsigned long long visitedLinkHash( + const char* canonicalURL, size_t length) { return 0; } + + // Returns whether the given link hash is in the user's history. The + // hash must have been generated by calling VisitedLinkHash(). + virtual bool isLinkVisited(unsigned long long linkHash) { return false; } + + + // Database ------------------------------------------------------------ + +#ifdef WIN32 + typedef HANDLE FileHandle; +#else + typedef int FileHandle; +#endif + + // Opens a database file; dirHandle should be 0 if the caller does not need + // a handle to the directory containing this file + virtual FileHandle databaseOpenFile( + const WebString& vfsFileName, int desiredFlags, FileHandle* dirHandle) { return FileHandle(); } + + // Deletes a database file and returns the error code + virtual int databaseDeleteFile(const WebString& vfsFileName, bool syncDir) { return 0; } + + // Returns the attributes of the given database file + virtual long databaseGetFileAttributes(const WebString& vfsFileName) { return 0; } + + // Returns the size of the given database file + virtual long long databaseGetFileSize(const WebString& vfsFileName) { return 0; } + + + // Keygen -------------------------------------------------------------- + + // Handle the <keygen> tag for generating client certificates + // Returns a base64 encoded signed copy of a public key from a newly + // generated key pair and the supplied challenge string. keySizeindex + // specifies the strength of the key. + virtual WebString signedPublicKeyAndChallengeString(unsigned keySizeIndex, + const WebKit::WebString& challenge, + const WebKit::WebURL& url) { return WebString(); } + + + + // Memory -------------------------------------------------------------- + + // Returns the current space allocated for the pagefile, in MB. + // That is committed size for Windows and virtual memory size for POSIX + virtual size_t memoryUsageMB() { return 0; } + + + // Message Ports ------------------------------------------------------- + + // Creates a Message Port Channel. This can be called on any thread. + // The returned object should only be used on the thread it was created on. + virtual WebMessagePortChannel* createMessagePortChannel() { return 0; } + + + // Network ------------------------------------------------------------- + + virtual void setCookies( + const WebURL& url, const WebURL& policyURL, const WebString& cookies) { } + virtual WebString cookies(const WebURL& url, const WebURL& policyURL) { return WebString(); } + virtual bool rawCookies(const WebURL& url, const WebURL& policyURL, WebVector<WebCookie>*) { return false; } + virtual void deleteCookie(const WebURL& url, const WebString& cookieName) { } + + // A suggestion to prefetch IP information for the given hostname. + virtual void prefetchHostName(const WebString&) { } + + // Returns a new WebURLLoader instance. + virtual WebURLLoader* createURLLoader() { return 0; } + + // Returns a new WebSocketStreamHandle instance. + virtual WebSocketStreamHandle* createSocketStreamHandle() { return 0; } + + // Returns the User-Agent string that should be used for the given URL. + virtual WebString userAgent(const WebURL&) { return WebString(); } + + + // Plugins ------------------------------------------------------------- + + // If refresh is true, then cached information should not be used to + // satisfy this call. + virtual void getPluginList(bool refresh, WebPluginListBuilder*) { }; + + + // Profiling ----------------------------------------------------------- + + virtual void decrementStatsCounter(const char* name) { }; + virtual void incrementStatsCounter(const char* name) { }; + + // An event is identified by the pair (name, id). The extra parameter + // specifies additional data to log with the event. + virtual void traceEventBegin(const char* name, void* id, const char* extra) { }; + virtual void traceEventEnd(const char* name, void* id, const char* extra) { }; + + // Generic callback for reporting histogram data. Range is identified by the min, max pair. + // By default, histogram is exponential, so that min=1, max=1000000, bucketCount=50 would do. Setting + // linear to true would require bucket count to cover whole min-max range. + virtual void histogramCounts(const WebString& name, int sample, int min, int max, int bucketCount, bool linear) { }; + + + // Resources ----------------------------------------------------------- + + // Returns a blob of data corresponding to the named resource. + virtual WebData loadResource(const char* name) { return WebData(); } + + // Returns a localized string resource (with an optional numeric + // parameter value). + virtual WebString queryLocalizedString(WebLocalizedString::Name) { return WebString(); } + virtual WebString queryLocalizedString(WebLocalizedString::Name, int numericValue) { return WebString(); } + + + // Sandbox ------------------------------------------------------------ + + // In some browsers, a "sandbox" restricts what operations a program + // is allowed to preform. Such operations are typically abstracted out + // via this API, but sometimes (like in HTML 5 database opening) WebKit + // needs to behave differently based on whether it's restricted or not. + // In these cases (and these cases only) you can call this function. + // It's OK for this value to be conservitive (i.e. true even if the + // sandbox isn't active). + virtual bool sandboxEnabled() { return false; } + + + // Shared Workers ------------------------------------------------------ + + virtual WebSharedWorkerRepository* sharedWorkerRepository() { return 0; } + + // Sudden Termination -------------------------------------------------- + + // Disable/Enable sudden termination. + virtual void suddenTerminationChanged(bool enabled) { } + + + // System -------------------------------------------------------------- + + // Returns a value such as "en-US". + virtual WebString defaultLocale() { return WebString(); } + + // Wall clock time in seconds since the epoch. + virtual double currentTime() { return 0; } + + // Delayed work is driven by a shared timer. + virtual void setSharedTimerFiredFunction(void (*func)()) { } + virtual void setSharedTimerFireTime(double fireTime) { } + virtual void stopSharedTimer() { } + + // Callable from a background WebKit thread. + virtual void callOnMainThread(void (*func)()) { } + +protected: + ~WebKitClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebLocalizedString.h b/WebKit/chromium/public/WebLocalizedString.h new file mode 100644 index 0000000..99a7d23 --- /dev/null +++ b/WebKit/chromium/public/WebLocalizedString.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebLocalizedString_h +#define WebLocalizedString_h + +namespace WebKit { + +struct WebLocalizedString { + enum Name { + SubmitButtonDefaultLabel, + InputElementAltText, + ResetButtonDefaultLabel, + FileButtonChooseFileLabel, + FileButtonNoFileSelectedLabel, + MultipleFileUploadText, + SearchableIndexIntroduction, + SearchMenuNoRecentSearchesText, + SearchMenuRecentSearchesText, + SearchMenuClearRecentSearchesText, + AXWebAreaText, + AXLinkText, + AXListMarkerText, + AXImageMapText, + AXHeadingText, + AXButtonActionVerb, + AXRadioButtonActionVerb, + AXTextFieldActionVerb, + AXCheckedCheckBoxActionVerb, + AXUncheckedCheckBoxActionVerb, + AXLinkActionVerb, + KeygenMenuHighGradeKeySize, + KeygenMenuMediumGradeKeySize, + }; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebMediaPlayer.h b/WebKit/chromium/public/WebMediaPlayer.h new file mode 100644 index 0000000..0b658f9 --- /dev/null +++ b/WebKit/chromium/public/WebMediaPlayer.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMediaPlayer_h +#define WebMediaPlayer_h + +#include "WebCanvas.h" +#include "WebVector.h" + +namespace WebKit { + +class WebMediaPlayerClient; +class WebURL; +struct WebRect; +struct WebSize; + +struct WebTimeRange { + WebTimeRange() : start(0), end(0) {} + WebTimeRange(float s, float e) : start(s), end(e) {} + + float start; + float end; +}; + +typedef WebVector<WebTimeRange> WebTimeRanges; + +class WebMediaPlayer { +public: + enum NetworkState { + Empty, + Idle, + Loading, + Loaded, + FormatError, + NetworkError, + DecodeError, + }; + + enum ReadyState { + HaveNothing, + HaveMetadata, + HaveCurrentData, + HaveFutureData, + HaveEnoughData, + }; + + enum MovieLoadType { + Unknown, + Download, + StoredStream, + LiveStream, + }; + + virtual ~WebMediaPlayer() {} + + virtual void load(const WebURL&) = 0; + virtual void cancelLoad() = 0; + + // Playback controls. + virtual void play() = 0; + virtual void pause() = 0; + virtual bool supportsFullscreen() const = 0; + virtual bool supportsSave() const = 0; + virtual void seek(float seconds) = 0; + virtual void setEndTime(float seconds) = 0; + virtual void setRate(float) = 0; + virtual void setVolume(float) = 0; + virtual void setVisible(bool) = 0; + virtual bool setAutoBuffer(bool) = 0; + virtual bool totalBytesKnown() = 0; + virtual const WebTimeRanges& buffered() const = 0; + virtual float maxTimeSeekable() const = 0; + + virtual void setSize(const WebSize&) = 0; + + virtual void paint(WebCanvas*, const WebRect&) = 0; + + // True if the loaded media has a playable video/audio track. + virtual bool hasVideo() const = 0; + virtual bool hasAudio() const = 0; + + // Dimension of the video. + virtual WebSize naturalSize() const = 0; + + // Getters of playback state. + virtual bool paused() const = 0; + virtual bool seeking() const = 0; + virtual float duration() const = 0; + virtual float currentTime() const = 0; + + // Get rate of loading the resource. + virtual int dataRate() const = 0; + + // Internal states of loading and network. + virtual NetworkState networkState() const = 0; + virtual ReadyState readyState() const = 0; + + virtual unsigned long long bytesLoaded() const = 0; + virtual unsigned long long totalBytes() const = 0; + + virtual bool hasSingleSecurityOrigin() const = 0; + virtual MovieLoadType movieLoadType() const = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebMediaPlayerAction.h b/WebKit/chromium/public/WebMediaPlayerAction.h new file mode 100644 index 0000000..3aede25 --- /dev/null +++ b/WebKit/chromium/public/WebMediaPlayerAction.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMediaPlayerAction_h +#define WebMediaPlayerAction_h + +namespace WebKit { + +struct WebMediaPlayerAction { + enum Type { + Unknown, + Play, + Mute, + Loop + }; + + Type type; + bool enable; + + WebMediaPlayerAction() + : type(Unknown), enable(false) { } + WebMediaPlayerAction(Type type, bool enable) + : type(type), enable(enable) { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebMediaPlayerClient.h b/WebKit/chromium/public/WebMediaPlayerClient.h new file mode 100644 index 0000000..558fb4a --- /dev/null +++ b/WebKit/chromium/public/WebMediaPlayerClient.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMediaPlayerClient_h +#define WebMediaPlayerClient_h + +namespace WebKit { + +class WebRequest; +class WebURL; + +class WebMediaPlayerClient { +public: + virtual void networkStateChanged() = 0; + virtual void readyStateChanged() = 0; + virtual void volumeChanged() = 0; + virtual void timeChanged() = 0; + virtual void repaint() = 0; + virtual void durationChanged() = 0; + virtual void rateChanged() = 0; + virtual void sizeChanged() = 0; + virtual void sawUnsupportedTracks() = 0; + +protected: + ~WebMediaPlayerClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebMenuItemInfo.h b/WebKit/chromium/public/WebMenuItemInfo.h new file mode 100644 index 0000000..d513e66 --- /dev/null +++ b/WebKit/chromium/public/WebMenuItemInfo.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMenuItemInfo_h +#define WebMenuItemInfo_h + +#include "WebCommon.h" +#include "WebString.h" +#include "WebVector.h" + +namespace WebKit { + +struct WebMenuItemInfo { + enum Type { + Option, + CheckableOption, + Group, + Separator, + }; + WebString label; + Type type; + unsigned action; + bool enabled; + bool checked; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebMessagePortChannel.h b/WebKit/chromium/public/WebMessagePortChannel.h new file mode 100644 index 0000000..288bd55 --- /dev/null +++ b/WebKit/chromium/public/WebMessagePortChannel.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMessagePortChannel_h +#define WebMessagePortChannel_h + +#include "WebCommon.h" +#include "WebVector.h" + +namespace WebKit { + +class WebMessagePortChannelClient; +class WebString; + +typedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray; + +// Provides an interface to a Message Port Channel implementation. The object owns itself and +// is signalled that its not needed anymore with the destroy() call. +class WebMessagePortChannel { +public: + virtual void setClient(WebMessagePortChannelClient*) = 0; + virtual void destroy() = 0; + // WebKit versions of WebCore::MessagePortChannel. + virtual void entangle(WebMessagePortChannel*) = 0; + // Callee receives ownership of the passed vector. + virtual void postMessage(const WebString&, WebMessagePortChannelArray*) = 0; + virtual bool tryGetMessage(WebString*, WebMessagePortChannelArray&) = 0; + +protected: + ~WebMessagePortChannel() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebMessagePortChannelClient.h b/WebKit/chromium/public/WebMessagePortChannelClient.h new file mode 100644 index 0000000..0b85bb3 --- /dev/null +++ b/WebKit/chromium/public/WebMessagePortChannelClient.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMessagePortChannelClient_h +#define WebMessagePortChannelClient_h + +namespace WebKit { + +// Provides an interface for users of WebMessagePortChannel to be notified +// when messages are available. +class WebMessagePortChannelClient { +public: + // Alerts that new messages have arrived, which are retrieved by calling + // WebMessagePortChannel::tryGetMessage. Note that this may be called + // on any thread. + virtual void messageAvailable() = 0; + +protected: + ~WebMessagePortChannelClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebMimeRegistry.h b/WebKit/chromium/public/WebMimeRegistry.h new file mode 100644 index 0000000..425753e --- /dev/null +++ b/WebKit/chromium/public/WebMimeRegistry.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMimeRegistry_h +#define WebMimeRegistry_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebString; + +class WebMimeRegistry { +public: + enum SupportsType { IsNotSupported, IsSupported, MayBeSupported }; + + virtual SupportsType supportsMIMEType(const WebString& mimeType) = 0; + virtual SupportsType supportsImageMIMEType(const WebString& mimeType) = 0; + virtual SupportsType supportsJavaScriptMIMEType(const WebString& mimeType) = 0; + virtual SupportsType supportsMediaMIMEType(const WebString& mimeType, + const WebString& codecs) = 0; + virtual SupportsType supportsNonImageMIMEType(const WebString& mimeType) = 0; + + virtual WebString mimeTypeForExtension(const WebString& fileExtension) = 0; + virtual WebString mimeTypeFromFile(const WebString& filePath) = 0; + virtual WebString preferredExtensionForMIMEType(const WebString& mimeType) = 0; + +protected: + ~WebMimeRegistry() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNavigationPolicy.h b/WebKit/chromium/public/WebNavigationPolicy.h new file mode 100644 index 0000000..54bee9d --- /dev/null +++ b/WebKit/chromium/public/WebNavigationPolicy.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebNavigationPolicy_h +#define WebNavigationPolicy_h + +namespace WebKit { + +enum WebNavigationPolicy { + WebNavigationPolicyIgnore, + WebNavigationPolicyDownload, + WebNavigationPolicyCurrentTab, + WebNavigationPolicyNewBackgroundTab, + WebNavigationPolicyNewForegroundTab, + WebNavigationPolicyNewWindow, + WebNavigationPolicyNewPopup, +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNavigationType.h b/WebKit/chromium/public/WebNavigationType.h new file mode 100644 index 0000000..8ca8dc6 --- /dev/null +++ b/WebKit/chromium/public/WebNavigationType.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebNavigationType_h +#define WebNavigationType_h + +namespace WebKit { + +enum WebNavigationType { + WebNavigationTypeLinkClicked, + WebNavigationTypeFormSubmitted, + WebNavigationTypeBackForward, + WebNavigationTypeReload, + WebNavigationTypeFormResubmitted, + WebNavigationTypeOther +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNode.h b/WebKit/chromium/public/WebNode.h new file mode 100644 index 0000000..03afa90 --- /dev/null +++ b/WebKit/chromium/public/WebNode.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebNode_h +#define WebNode_h + +#include "WebCommon.h" +#include "WebString.h" + +namespace WebCore { class Node; } +#if WEBKIT_IMPLEMENTATION +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { +class WebFrame; + +// Provides readonly access to some properties of a DOM node. +class WebNode { +public: + virtual ~WebNode() { reset(); } + + WebNode() : m_private(0) { } + WebNode(const WebNode& n) : m_private(0) { assign(n); } + WebNode& operator=(const WebNode& n) + { + assign(n); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebNode&); + + bool isNull() const { return !m_private; } + +#if WEBKIT_IMPLEMENTATION + WebNode(const WTF::PassRefPtr<WebCore::Node>&); + WebNode& operator=(const WTF::PassRefPtr<WebCore::Node>&); + operator WTF::PassRefPtr<WebCore::Node>() const; +#endif + + WEBKIT_API WebNode parentNode() const; + WEBKIT_API WebString nodeName() const; + WEBKIT_API WebFrame* frame() const; + + template<typename T> T toElement() + { + T res; + res.m_private = m_private; + return res; + } + +protected: + typedef WebCore::Node WebNodePrivate; + void assign(WebNodePrivate*); + WebNodePrivate* m_private; + + template<typename T> T* unwrap() + { + return static_cast<T*>(m_private); + } + + template<typename T> const T* constUnwrap() const + { + return static_cast<const T*>(m_private); + } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNonCopyable.h b/WebKit/chromium/public/WebNonCopyable.h new file mode 100644 index 0000000..b0bd456 --- /dev/null +++ b/WebKit/chromium/public/WebNonCopyable.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebNonCopyable_h +#define WebNonCopyable_h + +namespace WebKit { + +// A base class to extend from if you do not support copying. +class WebNonCopyable { +protected: + WebNonCopyable() { } + ~WebNonCopyable() { } + +private: + WebNonCopyable(const WebNonCopyable&); + WebNonCopyable& operator=(const WebNonCopyable&); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNotification.h b/WebKit/chromium/public/WebNotification.h new file mode 100644 index 0000000..1a41252 --- /dev/null +++ b/WebKit/chromium/public/WebNotification.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebNotification_h +#define WebNotification_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Notification; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebNotificationPrivate; +class WebURL; +class WebString; + +// Represents access to a desktop notification. +class WebNotification { +public: + WebNotification() : m_private(0) { } + WebNotification(const WebNotification& other) : m_private(0) { assign(other); } + + ~WebNotification() { reset(); } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebNotification&); + + WebNotification& operator=(const WebNotification& other) + { + assign(other); + return *this; + } + + // Operators required to put WebNotification in an ordered map. + bool equals(const WebNotification& other) const { return m_private == other.m_private; } + bool lessThan(const WebNotification& other) const; + + // Is the notification HTML vs. icon-title-text? + WEBKIT_API bool isHTML() const; + + // If HTML, the URL which contains the contents of the notification. + WEBKIT_API WebURL url() const; + + // If not HTML, the parameters for the icon-title-text notification. + WEBKIT_API WebString icon() const; + WEBKIT_API WebString title() const; + WEBKIT_API WebString body() const; + + // Called to indicate the notification has been displayed. + WEBKIT_API void dispatchDisplayEvent(); + + // Called to indicate an error has occurred with this notification. + WEBKIT_API void dispatchErrorEvent(const WebString& errorMessage); + + // Called to indicate the notification has been closed. If it was + // closed by the user (as opposed to automatically by the system), + // the byUser parameter will be true. + WEBKIT_API void dispatchCloseEvent(bool byUser); + +#if WEBKIT_IMPLEMENTATION + WebNotification(const WTF::PassRefPtr<WebCore::Notification>&); + WebNotification& operator=(const WTF::PassRefPtr<WebCore::Notification>&); + operator WTF::PassRefPtr<WebCore::Notification>() const; +#endif + +private: + void assign(WebNotificationPrivate*); + WebNotificationPrivate* m_private; +}; + +inline bool operator==(const WebNotification& a, const WebNotification& b) +{ + return a.equals(b); +} + +inline bool operator!=(const WebNotification& a, const WebNotification& b) +{ + return !a.equals(b); +} + +inline bool operator<(const WebNotification& a, const WebNotification& b) +{ + return a.lessThan(b); +} + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNotificationPermissionCallback.h b/WebKit/chromium/public/WebNotificationPermissionCallback.h new file mode 100644 index 0000000..07e85ee --- /dev/null +++ b/WebKit/chromium/public/WebNotificationPermissionCallback.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebNotificationPermissionCallback_h +#define WebNotificationPermissionCallback_h + +namespace WebKit { + +// Callback object used with WebNotificationPresenter. +class WebNotificationPermissionCallback { +public: + // Method to be invoked when the async permission request involving + // this object has been completed. + virtual void permissionRequestComplete() = 0; + +protected: + // This object is to be destroyed after the callback is invoked; + // it should not be directly destroyed. + ~WebNotificationPermissionCallback() {} +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNotificationPresenter.h b/WebKit/chromium/public/WebNotificationPresenter.h new file mode 100644 index 0000000..653b142 --- /dev/null +++ b/WebKit/chromium/public/WebNotificationPresenter.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebNotificationPresenter_h +#define WebNotificationPresenter_h + +#include "WebString.h" + +namespace WebKit { + +class WebNotification; +class WebNotificationPermissionCallback; + +// Provides the services to show desktop notifications to the user. +class WebNotificationPresenter { +public: + enum Permission { + PermissionAllowed, // User has allowed permission to the origin. + PermissionNotAllowed, // User has not taken an action on the origin (defaults to not allowed). + PermissionDenied // User has explicitly denied permission from the origin. + }; + + // Shows a notification. + virtual bool show(const WebNotification&) = 0; + + // Cancels a notification previously shown, and removes it if being shown. + virtual void cancel(const WebNotification&) = 0; + + // Indiciates that the notification object subscribed to events for a previously shown notification is + // being destroyed. Does _not_ remove the notification if being shown, but detaches it from receiving events. + virtual void objectDestroyed(const WebNotification&) = 0; + + // Checks the permission level of a given origin. + virtual Permission checkPermission(const WebString& origin) = 0; + + // Requests permission for a given origin. This operation is asynchronous and the callback provided + // will be invoked when the permission decision is made. Callback pointer must remain + // valid until called. + virtual void requestPermission(const WebString& origin, WebNotificationPermissionCallback* callback) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPasswordAutocompleteListener.h b/WebKit/chromium/public/WebPasswordAutocompleteListener.h new file mode 100644 index 0000000..db6589d --- /dev/null +++ b/WebKit/chromium/public/WebPasswordAutocompleteListener.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPasswordAutocompleteListener_h +#define WebPasswordAutocompleteListener_h + +namespace WebKit { +class WebString; + +class WebPasswordAutocompleteListener { +public: + virtual ~WebPasswordAutocompleteListener() {} + + virtual void didBlurInputElement( + const WebString& userInput) = 0; + + virtual void performInlineAutocomplete( + const WebString& userInput, + bool backSpaceOrDeletePressed, + bool showSuggestions) = 0; +}; + +} // namespace WebKit + + +#endif diff --git a/WebKit/chromium/public/WebPasswordFormData.h b/WebKit/chromium/public/WebPasswordFormData.h new file mode 100644 index 0000000..e1804d1 --- /dev/null +++ b/WebKit/chromium/public/WebPasswordFormData.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPasswordFormData_h +#define WebPasswordFormData_h + +#include "WebFormElement.h" +#include "WebString.h" +#include "WebURL.h" + +namespace WebKit { + +struct WebPasswordFormData { + // If the provided form is suitable for password completion, isValid() will + // return true; + WebPasswordFormData(const WebFormElement&); + + // If creation failed, return false. + bool isValid() const { return action.isValid(); } + + // The action target of the form. This is the primary data used by the + // PasswordManager for form autofill; that is, the action of the saved + // credentials must match the action of the form on the page to be autofilled. + // If this is empty / not available, it will result in a "restricted" + // IE-like autofill policy, where we wait for the user to type in his + // username before autofilling the password. In these cases, after successful + // login the action URL will automatically be assigned by the + // PasswordManager. + // + // When parsing an HTML form, this must always be set. + WebURL action; + + // The "Realm" for the sign-on (scheme, host, port for SCHEME_HTML, and + // contains the HTTP realm for dialog-based forms). + // The signon_realm is effectively the primary key used for retrieving + // data from the database, so it must not be empty. + WebString signonRealm; + + // The URL (minus query parameters) containing the form. This is the primary + // data used by the PasswordManager to decide (in longest matching prefix + // fashion) whether or not a given PasswordForm result from the database is a + // good fit for a particular form on a page, so it must not be empty. + WebURL origin; + + // The name of the submit button used. Optional; only used in scoring + // of PasswordForm results from the database to make matches as tight as + // possible. + // + // When parsing an HTML form, this must always be set. + WebString submitElement; + + // The name of the username input element. Optional (improves scoring). + // + // When parsing an HTML form, this must always be set. + WebString userNameElement; + + // The username. Optional. + // + // When parsing an HTML form, this is typically empty unless the site + // has implemented some form of autofill. + WebString userNameValue; + + // The name of the password input element, Optional (improves scoring). + // + // When parsing an HTML form, this must always be set. + WebString passwordElement; + + // The password. Required. + // + // When parsing an HTML form, this is typically empty. + WebString passwordValue; + + // If the form was a change password form, the name of the + // 'old password' input element. Optional. + WebString oldPasswordElement; + + // The old password. Optional. + WebString oldPasswordValue; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPlugin.h b/WebKit/chromium/public/WebPlugin.h new file mode 100644 index 0000000..5097265 --- /dev/null +++ b/WebKit/chromium/public/WebPlugin.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPlugin_h +#define WebPlugin_h + +#include "WebCanvas.h" + +struct NPObject; + +namespace WebKit { + +class WebDataSource; +class WebFrame; +class WebInputEvent; +class WebPluginContainer; +class WebURL; +class WebURLResponse; +struct WebCursorInfo; +struct WebPluginParams; +struct WebRect; +struct WebURLError; +template <typename T> class WebVector; + +class WebPlugin { +public: + virtual bool initialize(WebPluginContainer*) = 0; + virtual void destroy() = 0; + + virtual NPObject* scriptableObject() = 0; + + virtual void paint(WebCanvas*, const WebRect&) = 0; + + // Coordinates are relative to the containing window. + virtual void updateGeometry( + const WebRect& frameRect, const WebRect& clipRect, + const WebVector<WebRect>& cutOutsRects, bool isVisible) = 0; + + virtual void updateFocus(bool) = 0; + virtual void updateVisibility(bool) = 0; + + virtual bool acceptsInputEvents() = 0; + virtual bool handleInputEvent(const WebInputEvent&, WebCursorInfo&) = 0; + + virtual void didReceiveResponse(const WebURLResponse&) = 0; + virtual void didReceiveData(const char* data, int dataLength) = 0; + virtual void didFinishLoading() = 0; + virtual void didFailLoading(const WebURLError&) = 0; + + // Called in response to WebPluginContainer::loadFrameRequest + virtual void didFinishLoadingFrameRequest( + const WebURL&, void* notifyData) = 0; + virtual void didFailLoadingFrameRequest( + const WebURL&, void* notifyData, const WebURLError&) = 0; + +protected: + ~WebPlugin() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPluginContainer.h b/WebKit/chromium/public/WebPluginContainer.h new file mode 100644 index 0000000..41e304e --- /dev/null +++ b/WebKit/chromium/public/WebPluginContainer.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPluginContainer_h +#define WebPluginContainer_h + +struct NPObject; + +namespace WebKit { + +class WebString; +class WebURL; +class WebURLRequest; +struct WebRect; + +class WebPluginContainer { +public: + virtual void invalidate() = 0; + virtual void invalidateRect(const WebRect&) = 0; + + // Causes the container to report its current geometry via + // WebPlugin::updateGeometry. + virtual void reportGeometry() = 0; + + // Drop any references to script objects allocated by the plugin. + // These are objects derived from WebPlugin::scriptableObject. This is + // called when the plugin is being destroyed or if it needs to be + // re-initialized. + virtual void clearScriptObjects() = 0; + + // Returns the scriptable object associated with the DOM element + // containing the plugin. + virtual NPObject* scriptableObjectForElement() = 0; + + // Executes a "javascript:" URL on behalf of the plugin in the context + // of the frame containing the plugin. Returns the result of script + // execution, if any. + virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed) = 0; + + // Loads an URL in the specified frame (or the frame containing this + // plugin if target is empty). If notifyNeeded is true, then upon + // completion, WebPlugin::didFinishLoadingFrameRequest is called if the + // load was successful or WebPlugin::didFailLoadingFrameRequest is + // called if the load failed. The given notifyData is passed along to + // the callback. + virtual void loadFrameRequest( + const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData) = 0; + +protected: + ~WebPluginContainer() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPluginListBuilder.h b/WebKit/chromium/public/WebPluginListBuilder.h new file mode 100644 index 0000000..4bd427d --- /dev/null +++ b/WebKit/chromium/public/WebPluginListBuilder.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPluginListBuilder_h +#define WebPluginListBuilder_h + +namespace WebKit { + +class WebString; + +// An interface for building a list of known plugins. +class WebPluginListBuilder { +public: + virtual void addPlugin( + const WebString& name, const WebString& description, + const WebString& fileName) = 0; + + virtual void addMediaTypeToLastPlugin( + const WebString& name, const WebString& description) = 0; + + virtual void addFileExtensionToLastMediaType( + const WebString& fileExtension) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPluginParams.h b/WebKit/chromium/public/WebPluginParams.h new file mode 100644 index 0000000..5d03204 --- /dev/null +++ b/WebKit/chromium/public/WebPluginParams.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPluginParams_h +#define WebPluginParams_h + +#include "WebString.h" +#include "WebURL.h" +#include "WebVector.h" + +namespace WebKit { + +struct WebPluginParams { + WebURL url; + WebString mimeType; + WebVector<WebString> attributeNames; + WebVector<WebString> attributeValues; + bool loadManually; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPoint.h b/WebKit/chromium/public/WebPoint.h new file mode 100644 index 0000000..d1abe02 --- /dev/null +++ b/WebKit/chromium/public/WebPoint.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPoint_h +#define WebPoint_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +#include "IntPoint.h" +#else +#include <base/gfx/rect.h> +#endif + +namespace WebKit { + +struct WebPoint { + int x; + int y; + + WebPoint() + : x(0) + , y(0) + { + } + + WebPoint(int x, int y) + : x(x) + , y(y) + { + } + +#if WEBKIT_IMPLEMENTATION + WebPoint(const WebCore::IntPoint& p) + : x(p.x()) + , y(p.y()) + { + } + + WebPoint& operator=(const WebCore::IntPoint& p) + { + x = p.x(); + y = p.y(); + return *this; + } + + operator WebCore::IntPoint() const + { + return WebCore::IntPoint(x, y); + } +#else + WebPoint(const gfx::Point& p) + : x(p.x()) + , y(p.y()) + { + } + + WebPoint& operator=(const gfx::Point& p) + { + x = p.x(); + y = p.y(); + return *this; + } + + operator gfx::Point() const + { + return gfx::Point(x, y); + } +#endif +}; + +inline bool operator==(const WebPoint& a, const WebPoint& b) +{ + return a.x == b.x && a.y == b.y; +} + +inline bool operator!=(const WebPoint& a, const WebPoint& b) +{ + return !(a == b); +} + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPopupMenu.h b/WebKit/chromium/public/WebPopupMenu.h new file mode 100644 index 0000000..c2cdec3 --- /dev/null +++ b/WebKit/chromium/public/WebPopupMenu.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPopupMenu_h +#define WebPopupMenu_h + +#include "WebCommon.h" +#include "WebWidget.h" + +namespace WebKit { + +class WebWidgetClient; + +class WebPopupMenu : public WebWidget { +public: + WEBKIT_API static WebPopupMenu* create(WebWidgetClient*); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPopupMenuInfo.h b/WebKit/chromium/public/WebPopupMenuInfo.h new file mode 100644 index 0000000..876842d --- /dev/null +++ b/WebKit/chromium/public/WebPopupMenuInfo.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPopupMenuInfo_h +#define WebPopupMenuInfo_h + +#include "WebMenuItemInfo.h" +#include "WebVector.h" + +namespace WebKit { + +// Describes the contents of a popup menu. +struct WebPopupMenuInfo { + // FIXME: migrate clients to WebMenuItemInfo and remove this temporary Item typedef. + typedef WebMenuItemInfo Item; + int itemHeight; + int selectedIndex; + WebVector<WebMenuItemInfo> items; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebRange.h b/WebKit/chromium/public/WebRange.h new file mode 100644 index 0000000..89fc8f6 --- /dev/null +++ b/WebKit/chromium/public/WebRange.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebRange_h +#define WebRange_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Range; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebNode; +class WebRangePrivate; +class WebString; + +// Provides readonly access to some properties of a DOM range. +class WebRange { +public: + ~WebRange() { reset(); } + + WebRange() : m_private(0) { } + WebRange(const WebRange& r) : m_private(0) { assign(r); } + WebRange& operator=(const WebRange& r) + { + assign(r); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebRange&); + + bool isNull() const { return !m_private; } + + WEBKIT_API int startOffset() const; + WEBKIT_API int endOffset() const; + WEBKIT_API WebNode startContainer(int& exceptionCode) const; + WEBKIT_API WebNode endContainer(int& exceptionCode) const; + + WEBKIT_API WebString toHTMLText() const; + WEBKIT_API WebString toPlainText() const; + +#if WEBKIT_IMPLEMENTATION + WebRange(const WTF::PassRefPtr<WebCore::Range>&); + WebRange& operator=(const WTF::PassRefPtr<WebCore::Range>&); + operator WTF::PassRefPtr<WebCore::Range>() const; +#endif + +private: + void assign(WebRangePrivate*); + WebRangePrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebRect.h b/WebKit/chromium/public/WebRect.h new file mode 100644 index 0000000..ed5a7d1 --- /dev/null +++ b/WebKit/chromium/public/WebRect.h @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebRect_h +#define WebRect_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +#include "IntRect.h" +#else +#include <base/gfx/rect.h> +#endif + +namespace WebKit { + +struct WebRect { + int x; + int y; + int width; + int height; + + bool isEmpty() const { return width <= 0 || height <= 0; } + + WebRect() + : x(0) + , y(0) + , width(0) + , height(0) + { + } + + WebRect(int x, int y, int width, int height) + : x(x) + , y(y) + , width(width) + , height(height) + { + } + +#if WEBKIT_IMPLEMENTATION + WebRect(const WebCore::IntRect& r) + : x(r.x()) + , y(r.y()) + , width(r.width()) + , height(r.height()) + { + } + + WebRect& operator=(const WebCore::IntRect& r) + { + x = r.x(); + y = r.y(); + width = r.width(); + height = r.height(); + return *this; + } + + operator WebCore::IntRect() const + { + return WebCore::IntRect(x, y, width, height); + } +#else + WebRect(const gfx::Rect& r) + : x(r.x()) + , y(r.y()) + , width(r.width()) + , height(r.height()) + { + } + + WebRect& operator=(const gfx::Rect& r) + { + x = r.x(); + y = r.y(); + width = r.width(); + height = r.height(); + return *this; + } + + operator gfx::Rect() const + { + return gfx::Rect(x, y, width, height); + } +#endif +}; + +inline bool operator==(const WebRect& a, const WebRect& b) +{ + return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; +} + +inline bool operator!=(const WebRect& a, const WebRect& b) +{ + return !(a == b); +} + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebRegularExpression.h b/WebKit/chromium/public/WebRegularExpression.h new file mode 100644 index 0000000..bdf72d8 --- /dev/null +++ b/WebKit/chromium/public/WebRegularExpression.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebRegularExpression_h +#define WebRegularExpression_h + +#include "WebCommon.h" +#include "WebNonCopyable.h" +#include "WebTextCaseSensitivity.h" + +namespace WebKit { + +class WebRegularExpressionPrivate; +class WebString; + +class WebRegularExpression : public WebNonCopyable { +public: + WEBKIT_API WebRegularExpression(const WebString& pattern, WebTextCaseSensitivity); + WEBKIT_API ~WebRegularExpression(); + + WEBKIT_API int match(const WebString&, int startFrom = 0, int* matchLength = 0) const; + +private: + WebRegularExpressionPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebRuntimeFeatures.h b/WebKit/chromium/public/WebRuntimeFeatures.h new file mode 100644 index 0000000..eb6b2da --- /dev/null +++ b/WebKit/chromium/public/WebRuntimeFeatures.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebRuntimeFeatures_h +#define WebRuntimeFeatures_h + +#include "WebCommon.h" + +namespace WebKit { + +// This class is used to enable runtime features of WebKit. It is unspecified +// whether a feature is enabled by default. In the future, a feature may be +// promoted from disabled by default to enabled by default once it reaches a +// certain level of maturity. +class WebRuntimeFeatures { +public: + WEBKIT_API static void enableDatabase(bool); + WEBKIT_API static bool isDatabaseEnabled(); + + WEBKIT_API static void enableLocalStorage(bool); + WEBKIT_API static bool isLocalStorageEnabled(); + + WEBKIT_API static void enableSessionStorage(bool); + WEBKIT_API static bool isSessionStorageEnabled(); + + WEBKIT_API static void enableMediaPlayer(bool); + WEBKIT_API static bool isMediaPlayerEnabled(); + + WEBKIT_API static void enableSockets(bool); + WEBKIT_API static bool isSocketsEnabled(); + + WEBKIT_API static void enableNotifications(bool); + WEBKIT_API static bool isNotificationsEnabled(); + + WEBKIT_API static void enableApplicationCache(bool); + WEBKIT_API static bool isApplicationCacheEnabled(); + +private: + WebRuntimeFeatures(); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebScreenInfo.h b/WebKit/chromium/public/WebScreenInfo.h new file mode 100644 index 0000000..d3d268a --- /dev/null +++ b/WebKit/chromium/public/WebScreenInfo.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebScreenInfo_h +#define WebScreenInfo_h + +#include "WebRect.h" + +namespace WebKit { + +struct WebScreenInfo { + // The screen depth in bits per pixel + int depth; + + // The bits per colour component. This assumes that the colours are balanced + // equally. + int depthPerComponent; + + // This can be true for black and white printers + bool isMonochrome; + + // This is set from the rcMonitor member of MONITORINFOEX, to whit: + // "A RECT structure that specifies the display monitor rectangle, + // expressed in virtual-screen coordinates. Note that if the monitor + // is not the primary display monitor, some of the rectangle's + // coordinates may be negative values." + WebRect rect; + + // This is set from the rcWork member of MONITORINFOEX, to whit: + // "A RECT structure that specifies the work area rectangle of the + // display monitor that can be used by applications, expressed in + // virtual-screen coordinates. Windows uses this rectangle to + // maximize an application on the monitor. The rest of the area in + // rcMonitor contains system windows such as the task bar and side + // bars. Note that if the monitor is not the primary display monitor, + // some of the rectangle's coordinates may be negative values". + WebRect availableRect; + + WebScreenInfo() + : depth(0) + , depthPerComponent(0) + , isMonochrome(false) { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebScriptController.h b/WebKit/chromium/public/WebScriptController.h new file mode 100644 index 0000000..54bb08a --- /dev/null +++ b/WebKit/chromium/public/WebScriptController.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebScriptController_h +#define WebScriptController_h + +#include "WebCommon.h" + +namespace v8 { +class Extension; +} + +namespace WebKit { + +class WebString; + +class WebScriptController { +public: + // Registers a v8 extension to be available on webpages. The three forms + // offer various restrictions on what types of contexts the extension is + // loaded into. If a scheme is provided, only pages whose URL has the given + // scheme will match. If extensionGroup is provided, the extension will only + // be loaded into scripts run via WebFrame::ExecuteInNewWorld with the + // matching group. + // Will only affect v8 contexts initialized after this call. Takes ownership + // of the v8::Extension object passed. + WEBKIT_API static void registerExtension(v8::Extension*); + WEBKIT_API static void registerExtension(v8::Extension*, + const WebString& schemeRestriction); + WEBKIT_API static void registerExtension(v8::Extension*, int extensionGroup); + + // Enables special settings which are only applicable if V8 is executed + // in the single thread which must be the main thread. + // FIXME: make a try to dynamically detect when this condition is broken + // and automatically switch off single thread mode. + WEBKIT_API static void enableV8SingleThreadMode(); + + // Process any pending JavaScript console messages. + WEBKIT_API static void flushConsoleMessages(); + +private: + WebScriptController(); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebScriptSource.h b/WebKit/chromium/public/WebScriptSource.h new file mode 100644 index 0000000..344815b --- /dev/null +++ b/WebKit/chromium/public/WebScriptSource.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebScriptSource_h +#define WebScriptSource_h + +#include "WebString.h" +#include "WebURL.h" + +namespace WebKit { + +struct WebScriptSource { + WebString code; + WebURL url; + int startLine; + + WebScriptSource(const WebString& code) + : code(code), startLine(1) { } + WebScriptSource(const WebString& code, const WebURL& url) + : code(code), url(url), startLine(1) { } + WebScriptSource(const WebString& code, const WebURL& url, int startLine) + : code(code), url(url), startLine(startLine) { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSearchableFormData.h b/WebKit/chromium/public/WebSearchableFormData.h new file mode 100644 index 0000000..e453387 --- /dev/null +++ b/WebKit/chromium/public/WebSearchableFormData.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSearchableFormData_h +#define WebSearchableFormData_h + +#include "WebString.h" +#include "WebURL.h" + +namespace WebKit { +class WebFormElement; + +// SearchableFormData encapsulates a URL and encoding of an INPUT field that +// corresponds to a searchable form request. +class WebSearchableFormData { +public: + // If the provided form is suitable for automated searching, isValid() + // will return false. + WebSearchableFormData(const WebFormElement&); + + bool isValid() { return m_url.isValid(); } + + // URL for the searchable form request. + const WebURL& url() const + { + return m_url; + } + + // Encoding used to encode the form parameters; never empty. + const WebString& encoding() const + { + return m_encoding; + } + +private: + WebURL m_url; + WebString m_encoding; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSecurityOrigin.h b/WebKit/chromium/public/WebSecurityOrigin.h new file mode 100644 index 0000000..d04fbc6 --- /dev/null +++ b/WebKit/chromium/public/WebSecurityOrigin.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSecurityOrigin_h +#define WebSecurityOrigin_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class SecurityOrigin; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebSecurityOriginPrivate; +class WebString; + +class WebSecurityOrigin { +public: + ~WebSecurityOrigin() { reset(); } + + WebSecurityOrigin() : m_private(0) { } + WebSecurityOrigin(const WebSecurityOrigin& s) : m_private(0) { assign(s); } + WebSecurityOrigin& operator=(const WebSecurityOrigin& s) + { + assign(s); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebSecurityOrigin&); + + bool isNull() const { return !m_private; } + + WEBKIT_API WebString protocol() const; + WEBKIT_API WebString host() const; + WEBKIT_API unsigned short port() const; + + // The empty WebSecurityOrigin is the least privileged WebSecurityOrigin. + WEBKIT_API bool isEmpty() const; + + // Returns a string representation of the WebSecurityOrigin. The empty + // WebSecurityOrigin is represented by "null". The representation of a + // non-empty WebSecurityOrigin resembles a standard URL. + WEBKIT_API WebString toString() const; + + // Returns a string representation of this WebSecurityOrigin that can + // be used as a file. Should be used in storage APIs only. + WEBKIT_API WebString databaseIdentifier(); + +#if WEBKIT_IMPLEMENTATION + WebSecurityOrigin(const WTF::PassRefPtr<WebCore::SecurityOrigin>&); + WebSecurityOrigin& operator=(const WTF::PassRefPtr<WebCore::SecurityOrigin>&); + operator WTF::PassRefPtr<WebCore::SecurityOrigin>() const; +#endif + +private: + void assign(WebSecurityOriginPrivate*); + WebSecurityOriginPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSecurityPolicy.h b/WebKit/chromium/public/WebSecurityPolicy.h new file mode 100644 index 0000000..47dfe87 --- /dev/null +++ b/WebKit/chromium/public/WebSecurityPolicy.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSecurityPolicy_h +#define WebSecurityPolicy_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebString; +class WebURL; + +class WebSecurityPolicy { +public: + // Registers a URL scheme to be treated as a local scheme (i.e., with the + // same security rules as those applied to "file" URLs). This means that + // normal pages cannot link to or access URLs of this scheme. + WEBKIT_API static void registerURLSchemeAsLocal(const WebString&); + + // Registers a URL scheme to be treated as a noAccess scheme. This means + // that pages loaded with this URL scheme cannot access pages loaded with + // any other URL scheme. + WEBKIT_API static void registerURLSchemeAsNoAccess(const WebString&); + + // Support for whitelisting access to origins beyond the same-origin policy. + WEBKIT_API static void whiteListAccessFromOrigin( + const WebURL& sourceOrigin, const WebString& destinationProtocol, + const WebString& destinationHost, bool allowDestinationSubdomains); + WEBKIT_API static void resetOriginAccessWhiteLists(); + +private: + WebSecurityPolicy(); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSettings.h b/WebKit/chromium/public/WebSettings.h new file mode 100644 index 0000000..da36806 --- /dev/null +++ b/WebKit/chromium/public/WebSettings.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSettings_h +#define WebSettings_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebString; +class WebURL; + +// WebSettings is owned by the WebView and allows code to modify the settings for +// the WebView's page without any knowledge of WebCore itself. For the most part, +// these functions have a 1:1 mapping with the methods in WebCore/page/settings.h. +class WebSettings { +public: + virtual void setStandardFontFamily(const WebString&) = 0; + virtual void setFixedFontFamily(const WebString&) = 0; + virtual void setSerifFontFamily(const WebString&) = 0; + virtual void setSansSerifFontFamily(const WebString&) = 0; + virtual void setCursiveFontFamily(const WebString&) = 0; + virtual void setFantasyFontFamily(const WebString&) = 0; + virtual void setDefaultFontSize(int) = 0; + virtual void setDefaultFixedFontSize(int) = 0; + virtual void setMinimumFontSize(int) = 0; + virtual void setMinimumLogicalFontSize(int) = 0; + virtual void setDefaultTextEncodingName(const WebString&) = 0; + virtual void setJavaScriptEnabled(bool) = 0; + virtual void setWebSecurityEnabled(bool) = 0; + virtual void setJavaScriptCanOpenWindowsAutomatically(bool) = 0; + virtual void setLoadsImagesAutomatically(bool) = 0; + virtual void setPluginsEnabled(bool) = 0; + virtual void setDOMPasteAllowed(bool) = 0; + virtual void setDeveloperExtrasEnabled(bool) = 0; + virtual void setNeedsSiteSpecificQuirks(bool) = 0; + virtual void setShrinksStandaloneImagesToFit(bool) = 0; + virtual void setUsesEncodingDetector(bool) = 0; + virtual void setTextAreasAreResizable(bool) = 0; + virtual void setJavaEnabled(bool) = 0; + virtual void setAllowScriptsToCloseWindows(bool) = 0; + virtual void setUserStyleSheetLocation(const WebURL&) = 0; + virtual void setUsesPageCache(bool) = 0; + virtual void setDownloadableBinaryFontsEnabled(bool) = 0; + virtual void setXSSAuditorEnabled(bool) = 0; + virtual void setLocalStorageEnabled(bool) = 0; + virtual void setEditableLinkBehaviorNeverLive() = 0; + virtual void setFontRenderingModeNormal() = 0; + virtual void setShouldPaintCustomScrollbars(bool) = 0; + virtual void setDatabasesEnabled(bool) = 0; + virtual void setAllowUniversalAccessFromFileURLs(bool) = 0; + virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0; + virtual void setOfflineWebApplicationCacheEnabled(bool) = 0; + virtual void setExperimentalWebGLEnabled(bool) = 0; + virtual void setGeolocationEnabled(bool) = 0; + +protected: + ~WebSettings() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSharedWorker.h b/WebKit/chromium/public/WebSharedWorker.h new file mode 100644 index 0000000..4ac7639 --- /dev/null +++ b/WebKit/chromium/public/WebSharedWorker.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSharedWorker_h +#define WebSharedWorker_h + +#include "WebCommon.h" + +namespace WebCore { +class ScriptExecutionContext; +} + +namespace WebKit { + +class WebString; +class WebMessagePortChannel; +class WebCommonWorkerClient; +class WebURL; + +// This is the interface to a SharedWorker thread. +// Since SharedWorkers communicate entirely through MessagePorts this interface only contains APIs for starting up a SharedWorker. +class WebSharedWorker { +public: + // Invoked from the worker thread to instantiate a WebSharedWorker that interacts with the WebKit worker components. + WEBKIT_API static WebSharedWorker* create(WebCommonWorkerClient*); + + virtual ~WebSharedWorker() {}; + + // Returns false if the thread hasn't been started yet (script loading has not taken place). + // FIXME(atwilson): Remove this when we move the initial script loading into the worker process. + virtual bool isStarted() = 0; + + virtual void startWorkerContext(const WebURL& scriptURL, + const WebString& name, + const WebString& userAgent, + const WebString& sourceCode) = 0; + class ConnectListener { + public: + // Invoked once the connect event has been sent so the caller can free this object. + virtual void connected() = 0; + }; + + // Sends a connect event to the SharedWorker context. The listener is invoked when this async operation completes. + virtual void connect(WebMessagePortChannel*, ConnectListener*) = 0; + + // Invoked to shutdown the worker when there are no more associated documents. + virtual void terminateWorkerContext() = 0; + + // Notification when the WebCommonWorkerClient is destroyed. + virtual void clientDestroyed() = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSharedWorkerRepository.h b/WebKit/chromium/public/WebSharedWorkerRepository.h new file mode 100644 index 0000000..9fe6890 --- /dev/null +++ b/WebKit/chromium/public/WebSharedWorkerRepository.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSharedWorkerRepository_h +#define WebSharedWorkerRepository_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebString; +class WebSharedWorker; +class WebURL; + +class WebSharedWorkerRepository { +public: + // Unique identifier for the parent document of a worker (unique within a given process). + typedef unsigned long long DocumentID; + + // Tracks a newly-created SharedWorker via the repository. + virtual void addSharedWorker(WebSharedWorker*, DocumentID) = 0; + + // Invoked when a document has been detached. DocumentID can be re-used after documentDetached() is invoked. + virtual void documentDetached(DocumentID) = 0; + + // Returns true if the passed document is associated with any SharedWorkers. + virtual bool hasSharedWorkers(DocumentID) = 0; +}; + +} // namespace WebKit + +#endif // WebSharedWorkerRepository_h diff --git a/WebKit/chromium/public/WebSize.h b/WebKit/chromium/public/WebSize.h new file mode 100644 index 0000000..bb88633 --- /dev/null +++ b/WebKit/chromium/public/WebSize.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSize_h +#define WebSize_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +#include "IntSize.h" +#else +#include <base/gfx/rect.h> +#endif + +namespace WebKit { + +struct WebSize { + int width; + int height; + + bool isEmpty() const { return width <= 0 || height <= 0; } + + WebSize() + : width(0) + , height(0) + { + } + + WebSize(int width, int height) + : width(width) + , height(height) + { + } + +#if WEBKIT_IMPLEMENTATION + WebSize(const WebCore::IntSize& s) + : width(s.width()) + , height(s.height()) + { + } + + WebSize& operator=(const WebCore::IntSize& s) + { + width = s.width(); + height = s.height(); + return *this; + } + + operator WebCore::IntSize() const + { + return WebCore::IntSize(width, height); + } +#else + WebSize(const gfx::Size& s) + : width(s.width()) + , height(s.height()) + { + } + + WebSize& operator=(const gfx::Size& s) + { + width = s.width(); + height = s.height(); + return *this; + } + + operator gfx::Size() const + { + return gfx::Size(width, height); + } +#endif +}; + +inline bool operator==(const WebSize& a, const WebSize& b) +{ + return a.width == b.width && a.height == b.height; +} + +inline bool operator!=(const WebSize& a, const WebSize& b) +{ + return !(a == b); +} + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSocketStreamError.h b/WebKit/chromium/public/WebSocketStreamError.h new file mode 100644 index 0000000..f52869b --- /dev/null +++ b/WebKit/chromium/public/WebSocketStreamError.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSocketStreamError_h +#define WebSocketStreamError_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebSocketStreamError { +public: + // FIXME: Define SocketStream Error codes and accessor methods. +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSocketStreamHandle.h b/WebKit/chromium/public/WebSocketStreamHandle.h new file mode 100644 index 0000000..ededa0e --- /dev/null +++ b/WebKit/chromium/public/WebSocketStreamHandle.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSocketStreamHandle_h +#define WebSocketStreamHandle_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebData; +class WebSocketStreamHandleClient; +class WebURL; + +class WebSocketStreamHandle { +public: + virtual ~WebSocketStreamHandle() { } + + // Connect new socket stream asynchronously. + virtual void connect(const WebURL&, WebSocketStreamHandleClient*) = 0; + + // Send web socket frame data on the socket stream. + virtual bool send(const WebData&) = 0; + + // Close the socket stream. + virtual void close() = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebSocketStreamHandleClient.h b/WebKit/chromium/public/WebSocketStreamHandleClient.h new file mode 100644 index 0000000..82f328c --- /dev/null +++ b/WebKit/chromium/public/WebSocketStreamHandleClient.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSocketStreamHandleClient_h +#define WebSocketStreamHandleClient_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebData; +class WebSocketStreamError; +class WebSocketStreamHandle; +class WebURL; + +class WebSocketStreamHandleClient { +public: + + // Called when Socket Stream is opened. + virtual void didOpenStream(WebSocketStreamHandle*, int /* maxPendingSendAllowed */) = 0; + + // Called when |amountSent| bytes are sent. + virtual void didSendData(WebSocketStreamHandle*, int /* amountSent */) = 0; + + // Called when data are received. + virtual void didReceiveData(WebSocketStreamHandle*, const WebData&) = 0; + + // Called when Socket Stream is closed. + virtual void didClose(WebSocketStreamHandle*) = 0; + + // Called when Socket Stream has an error. + virtual void didFail(WebSocketStreamHandle*, const WebSocketStreamError&) = 0; + + // FIXME: auth challenge for proxy +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebStorageArea.h b/WebKit/chromium/public/WebStorageArea.h new file mode 100644 index 0000000..71dc7a5 --- /dev/null +++ b/WebKit/chromium/public/WebStorageArea.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebStorageArea_h +#define WebStorageArea_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebString; +class WebURL; + +// In WebCore, there's one distinct StorageArea per origin per StorageNamespace. This +// class wraps a StorageArea. All the methods have obvious connections to the spec: +// http://dev.w3.org/html5/webstorage/ +class WebStorageArea { +public: + virtual ~WebStorageArea() { } + + // The number of key/value pairs in the storage area. + virtual unsigned length() = 0; + + // Get a value for a specific key. Valid key indices are 0 through length() - 1. + // Indexes may change on any set/removeItem call. Will return null if the index + // provided is out of range. + virtual WebString key(unsigned index) = 0; + + // Get the value that corresponds to a specific key. This returns null if there is + // no entry for that key. + virtual WebString getItem(const WebString& key) = 0; + + // Set the value that corresponds to a specific key. QuotaException is set if we've + // the StorageArea would have exceeded its quota. The value is NOT set when there's + // an exception. url is the url that should be used if a storage event fires. + virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException) = 0; + + // Remove the value associated with a particular key. url is the url that should be used + // if a storage event fires. + virtual void removeItem(const WebString& key, const WebURL& url) = 0; + + // Clear all key/value pairs. url is the url that should be used if a storage event fires. + virtual void clear(const WebURL& url) = 0; +}; + +} // namespace WebKit + +#endif // WebStorageArea_h diff --git a/WebKit/chromium/public/WebStorageEventDispatcher.h b/WebKit/chromium/public/WebStorageEventDispatcher.h new file mode 100644 index 0000000..57750e8 --- /dev/null +++ b/WebKit/chromium/public/WebStorageEventDispatcher.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebStorageEventDispatcher_h +#define WebStorageEventDispatcher_h + +#include "WebString.h" + +namespace WebKit { + +class WebURL; + +// This is used to dispatch storage events to all pages. +// FIXME: Make this (or something) work for SessionStorage! +class WebStorageEventDispatcher { +public: + static WebStorageEventDispatcher* create(); + + virtual ~WebStorageEventDispatcher() { } + + // Dispatch the actual event. Doesn't yet work for SessionStorage. + virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue, + const WebString& newValue, const WebString& origin, + const WebURL& url, bool isLocalStorage) = 0; +}; + +} // namespace WebKit + +#endif // WebStorageEventDispatcher_h diff --git a/WebKit/chromium/public/WebStorageNamespace.h b/WebKit/chromium/public/WebStorageNamespace.h new file mode 100644 index 0000000..da92a77 --- /dev/null +++ b/WebKit/chromium/public/WebStorageNamespace.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebStorageNamespace_h +#define WebStorageNamespace_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebStorageArea; +class WebString; + +// WebStorageNamespace represents a collection of StorageAreas. Typically, you'll have +// multiple StorageNamespaces to represent the SessionStorage for each tab and a single +// StorageNamespace to represent LocalStorage for the entire browser. +class WebStorageNamespace { +public: + // Create a new WebStorageNamespace. LocalStorageNamespaces require a path to specify + // where the SQLite databases that make LocalStorage data persistent are located. + // If path is empty, data will not persist. You should call delete on the returned + // object when you're finished. + WEBKIT_API static WebStorageNamespace* createLocalStorageNamespace(const WebString& backingDirectoryPath, unsigned quota); + WEBKIT_API static WebStorageNamespace* createSessionStorageNamespace(); + + static const unsigned noQuota = UINT_MAX; + + virtual ~WebStorageNamespace() { } + + // Create a new WebStorageArea object. Two subsequent calls with the same origin + // will return two different WebStorageArea objects that share the same backing store. + // You should call delete on the returned object when you're finished. + virtual WebStorageArea* createStorageArea(const WebString& origin) = 0; + + // Copy a StorageNamespace. This only makes sense in the case of SessionStorage. + virtual WebStorageNamespace* copy() = 0; + + // Shutdown the StorageNamespace. Write all StorageArea's to disk and disallow new + // write activity. + virtual void close() = 0; +}; + +} // namespace WebKit + +#endif // WebStorageNamespace_h diff --git a/WebKit/chromium/public/WebString.h b/WebKit/chromium/public/WebString.h new file mode 100644 index 0000000..d9b66b2 --- /dev/null +++ b/WebKit/chromium/public/WebString.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebString_h +#define WebString_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { +class String; +class AtomicString; +} +#else +#include <base/nullable_string16.h> +#include <base/string16.h> +#endif + +namespace WebKit { + +class WebCString; +class WebStringPrivate; + +// A UTF-16 string container. It is inexpensive to copy a WebString +// object. +// +// WARNING: It is not safe to pass a WebString across threads!!! +// +class WebString { +public: + ~WebString() { reset(); } + + WebString() : m_private(0) { } + + WebString(const WebUChar* data, size_t len) : m_private(0) + { + assign(data, len); + } + + WebString(const WebString& s) : m_private(0) { assign(s); } + + WebString& operator=(const WebString& s) + { + assign(s); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebString&); + WEBKIT_API void assign(const WebUChar* data, size_t len); + + WEBKIT_API size_t length() const; + WEBKIT_API const WebUChar* data() const; + + bool isEmpty() const { return !length(); } + bool isNull() const { return !m_private; } + + WEBKIT_API WebCString utf8() const; + + WEBKIT_API static WebString fromUTF8(const char* data, size_t length); + WEBKIT_API static WebString fromUTF8(const char* data); + +#if WEBKIT_IMPLEMENTATION + WebString(const WebCore::String&); + WebString& operator=(const WebCore::String&); + operator WebCore::String() const; + + WebString(const WebCore::AtomicString&); + WebString& operator=(const WebCore::AtomicString&); + operator WebCore::AtomicString() const; +#else + WebString(const string16& s) : m_private(0) + { + assign(s.data(), s.length()); + } + + WebString& operator=(const string16& s) + { + assign(s.data(), s.length()); + return *this; + } + + operator string16() const + { + size_t len = length(); + return len ? string16(data(), len) : string16(); + } + + WebString(const NullableString16& s) : m_private(0) + { + if (s.is_null()) + assign(0); + else + assign(s.string().data(), s.string().length()); + } + + WebString& operator=(const NullableString16& s) + { + if (s.is_null()) + assign(0); + else + assign(s.string().data(), s.string().length()); + return *this; + } + + operator NullableString16() const + { + if (!m_private) + return NullableString16(string16(), true); + size_t len = length(); + return NullableString16(len ? string16(data(), len) : string16(), false); + } + + template <class UTF8String> + static WebString fromUTF8(const UTF8String& s) + { + return fromUTF8(s.data(), s.length()); + } +#endif + +private: + void assign(WebStringPrivate*); + WebStringPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebTextAffinity.h b/WebKit/chromium/public/WebTextAffinity.h new file mode 100644 index 0000000..1224f61 --- /dev/null +++ b/WebKit/chromium/public/WebTextAffinity.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebTextAffinity_h +#define WebTextAffinity_h + +namespace WebKit { + +// These constants specify the preferred direction of selection. +enum WebTextAffinity { + WebTextAffinityUpstream, // The selection is moving toward the top of the document. + WebTextAffinityDownstream, // The selection is moving toward the bottom of the document. +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebTextCaseSensitivity.h b/WebKit/chromium/public/WebTextCaseSensitivity.h new file mode 100644 index 0000000..ae5860c --- /dev/null +++ b/WebKit/chromium/public/WebTextCaseSensitivity.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebTextCaseSensitivity_h +#define WebTextCaseSensitivity_h + +namespace WebKit { + +// These constants specify the preferred case sensitivity. +enum WebTextCaseSensitivity { + WebTextCaseSensitive, // String matching is case-sensitive. + WebTextCaseInsensitive, // String matching is case-insensitive. +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebTextDirection.h b/WebKit/chromium/public/WebTextDirection.h new file mode 100644 index 0000000..3d51296 --- /dev/null +++ b/WebKit/chromium/public/WebTextDirection.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebTextDirection_h +#define WebTextDirection_h + +namespace WebKit { + +// Represents text directions (or writing directions) of a DOM node. +enum WebTextDirection { + WebTextDirectionDefault, // Natural writing direction ("inherit") + WebTextDirectionLeftToRight, + WebTextDirectionRightToLeft, +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebURL.h b/WebKit/chromium/public/WebURL.h new file mode 100644 index 0000000..78a16a8 --- /dev/null +++ b/WebKit/chromium/public/WebURL.h @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURL_h +#define WebURL_h + +#include "WebCString.h" +#include <googleurl/src/url_parse.h> + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class KURL; } +#else +#include <googleurl/src/gurl.h> +#endif + +namespace WebKit { + +class WebURL { +public: + ~WebURL() + { + } + + WebURL() : m_isValid(false) + { + } + + WebURL(const WebCString& spec, const url_parse::Parsed& parsed, bool isValid) + : m_spec(spec) + , m_parsed(parsed) + , m_isValid(isValid) + { + } + + WebURL(const WebURL& s) + : m_spec(s.m_spec) + , m_parsed(s.m_parsed) + , m_isValid(s.m_isValid) + { + } + + WebURL& operator=(const WebURL& s) + { + m_spec = s.m_spec; + m_parsed = s.m_parsed; + m_isValid = s.m_isValid; + return *this; + } + + void assign(const WebCString& spec, const url_parse::Parsed& parsed, bool isValid) + { + m_spec = spec; + m_parsed = parsed; + m_isValid = isValid; + } + + const WebCString& spec() const + { + return m_spec; + } + + const url_parse::Parsed& parsed() const + { + return m_parsed; + } + + bool isValid() const + { + return m_isValid; + } + + bool isEmpty() const + { + return m_spec.isEmpty(); + } + + bool isNull() const + { + return m_spec.isEmpty(); + } + +#if WEBKIT_IMPLEMENTATION + WebURL(const WebCore::KURL&); + WebURL& operator=(const WebCore::KURL&); + operator WebCore::KURL() const; +#else + WebURL(const GURL& g) + : m_spec(g.possibly_invalid_spec()) + , m_parsed(g.parsed_for_possibly_invalid_spec()) + , m_isValid(g.is_valid()) + { + } + + WebURL& operator=(const GURL& g) + { + m_spec = g.possibly_invalid_spec(); + m_parsed = g.parsed_for_possibly_invalid_spec(); + m_isValid = g.is_valid(); + return *this; + } + + operator GURL() const + { + return isNull() ? GURL() : GURL(m_spec.data(), m_spec.length(), m_parsed, m_isValid); + } +#endif + +private: + WebCString m_spec; // UTF-8 encoded + url_parse::Parsed m_parsed; + bool m_isValid; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebURLError.h b/WebKit/chromium/public/WebURLError.h new file mode 100644 index 0000000..de88e3e --- /dev/null +++ b/WebKit/chromium/public/WebURLError.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURLError_h +#define WebURLError_h + +#include "WebString.h" +#include "WebURL.h" + +#if defined(WEBKIT_IMPLEMENTATION) +namespace WebCore { class ResourceError; } +#endif + +namespace WebKit { + +struct WebURLError { + // A namespace for "reason" to support various layers generating + // resource errors. WebKit does not care about the value of this + // string as it will just be passed via callbacks to the consumer. + WebString domain; + + // A numeric error code detailing the reason for this error. A value + // of 0 means no error. WebKit does not interpret the meaning of other + // values and normally just forwards this error information back to the + // embedder (see for example WebFrameClient). + int reason; + + // The url that failed to load. + WebURL unreachableURL; + + WebURLError() : reason(0) { } + +#if defined(WEBKIT_IMPLEMENTATION) + WebURLError(const WebCore::ResourceError&); + WebURLError& operator=(const WebCore::ResourceError&); + operator WebCore::ResourceError() const; +#endif +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebURLLoader.h b/WebKit/chromium/public/WebURLLoader.h new file mode 100644 index 0000000..54d105e --- /dev/null +++ b/WebKit/chromium/public/WebURLLoader.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURLLoader_h +#define WebURLLoader_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebData; +class WebURLLoaderClient; +class WebURLRequest; +class WebURLResponse; +struct WebURLError; + +class WebURLLoader { +public: + // The WebURLLoader may be deleted in a call to its client. + virtual ~WebURLLoader() {} + + // Load the request synchronously, returning results directly to the + // caller upon completion. There is no mechanism to interrupt a + // synchronous load!! + virtual void loadSynchronously(const WebURLRequest&, + WebURLResponse&, WebURLError&, WebData& data) = 0; + + // Load the request asynchronously, sending notifications to the given + // client. The client will receive no further notifications if the + // loader is disposed before it completes its work. + virtual void loadAsynchronously(const WebURLRequest&, + WebURLLoaderClient*) = 0; + + // Cancels an asynchronous load. This will appear as a load error to + // the client. + virtual void cancel() = 0; + + // Suspends/resumes an asynchronous load. + virtual void setDefersLoading(bool) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebURLLoaderClient.h b/WebKit/chromium/public/WebURLLoaderClient.h new file mode 100644 index 0000000..03b2c54 --- /dev/null +++ b/WebKit/chromium/public/WebURLLoaderClient.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURLLoaderClient_h +#define WebURLLoaderClient_h + +namespace WebKit { + +class WebURLLoader; +class WebURLRequest; +class WebURLResponse; +struct WebURLError; + +class WebURLLoaderClient { +public: + // Called when following a redirect. |newRequest| contains the request + // generated by the redirect. The client may modify |newRequest|. + virtual void willSendRequest( + WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse) = 0; + + // Called to report upload progress. The bytes reported correspond to + // the HTTP message body. + virtual void didSendData( + WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) = 0; + + // Called when response headers are received. + virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&) = 0; + + // Called when a chunk of response data is received. + virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength) = 0; + + // Called when the load completes successfully. + virtual void didFinishLoading(WebURLLoader*) = 0; + + // Called when the load completes with an error. + virtual void didFail(WebURLLoader*, const WebURLError&) = 0; + +protected: + ~WebURLLoaderClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebURLRequest.h b/WebKit/chromium/public/WebURLRequest.h new file mode 100644 index 0000000..41443b4 --- /dev/null +++ b/WebKit/chromium/public/WebURLRequest.h @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURLRequest_h +#define WebURLRequest_h + +#include "WebCommon.h" +#include "WebHTTPBody.h" + +#if defined(WEBKIT_IMPLEMENTATION) +namespace WebCore { class ResourceRequest; } +#endif + +namespace WebKit { + +class WebCString; +class WebHTTPBody; +class WebHTTPHeaderVisitor; +class WebString; +class WebURL; +class WebURLRequestPrivate; + +class WebURLRequest { +public: + enum CachePolicy { + UseProtocolCachePolicy, // normal load + ReloadIgnoringCacheData, // reload + ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data + ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache + }; + + enum TargetType { + TargetIsMainFrame = 0, + TargetIsSubFrame = 1, // Temporary for backward compatibility. + TargetIsSubframe = 1, + TargetIsSubResource = 2, // Temporary for backward comptibility. + TargetIsSubresource = 2, + TargetIsStyleSheet = 3, + TargetIsScript = 4, + TargetIsFontResource = 5, + TargetIsImage = 6, + TargetIsObject = 7, + TargetIsMedia = 8 + }; + + ~WebURLRequest() { reset(); } + + WebURLRequest() : m_private(0) { } + WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); } + WebURLRequest& operator=(const WebURLRequest& r) + { + assign(r); + return *this; + } + + explicit WebURLRequest(const WebURL& url) : m_private(0) + { + initialize(); + setURL(url); + } + + WEBKIT_API void initialize(); + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebURLRequest&); + + WEBKIT_API bool isNull() const; + + WEBKIT_API WebURL url() const; + WEBKIT_API void setURL(const WebURL&); + + // Used to implement third-party cookie blocking. + WEBKIT_API WebURL firstPartyForCookies() const; + WEBKIT_API void setFirstPartyForCookies(const WebURL&); + + WEBKIT_API bool allowCookies() const; + WEBKIT_API void setAllowCookies(bool allowCookies); + + // Controls whether user name, password, and cookies may be sent with the + // request. (If false, this overrides allowCookies.) + WEBKIT_API bool allowStoredCredentials() const; + WEBKIT_API void setAllowStoredCredentials(bool allowStoredCredentials); + + WEBKIT_API CachePolicy cachePolicy() const; + WEBKIT_API void setCachePolicy(CachePolicy); + + WEBKIT_API WebString httpMethod() const; + WEBKIT_API void setHTTPMethod(const WebString&); + + WEBKIT_API WebString httpHeaderField(const WebString& name) const; + WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value); + WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value); + WEBKIT_API void clearHTTPHeaderField(const WebString& name); + WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const; + + WEBKIT_API WebHTTPBody httpBody() const; + WEBKIT_API void setHTTPBody(const WebHTTPBody&); + + // Controls whether upload progress events are generated when a request + // has a body. + WEBKIT_API bool reportUploadProgress() const; + WEBKIT_API void setReportUploadProgress(bool); + + WEBKIT_API TargetType targetType() const; + WEBKIT_API void setTargetType(TargetType); + + // A consumer controlled value intended to be used to identify the + // requestor. + WEBKIT_API int requestorID() const; + WEBKIT_API void setRequestorID(int); + + // A consumer controlled value intended to be used to identify the + // process of the requestor. + WEBKIT_API int requestorProcessID() const; + WEBKIT_API void setRequestorProcessID(int); + + // Allows the request to be matched up with its app cache host. + WEBKIT_API int appCacheHostID() const; + WEBKIT_API void setAppCacheHostID(int id); + +#if defined(WEBKIT_IMPLEMENTATION) + WebCore::ResourceRequest& toMutableResourceRequest(); + const WebCore::ResourceRequest& toResourceRequest() const; +#endif + +protected: + void assign(WebURLRequestPrivate*); + +private: + WebURLRequestPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebURLResponse.h b/WebKit/chromium/public/WebURLResponse.h new file mode 100644 index 0000000..cdac83c --- /dev/null +++ b/WebKit/chromium/public/WebURLResponse.h @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURLResponse_h +#define WebURLResponse_h + +#include "WebCommon.h" + +#if defined(WEBKIT_IMPLEMENTATION) +namespace WebCore { class ResourceResponse; } +#endif + +namespace WebKit { + +class WebCString; +class WebHTTPHeaderVisitor; +class WebString; +class WebURL; +class WebURLResponsePrivate; + +class WebURLResponse { +public: + ~WebURLResponse() { reset(); } + + WebURLResponse() : m_private(0) { } + WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); } + WebURLResponse& operator=(const WebURLResponse& r) + { + assign(r); + return *this; + } + + explicit WebURLResponse(const WebURL& url) : m_private(0) + { + initialize(); + setURL(url); + } + + WEBKIT_API void initialize(); + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebURLResponse&); + + WEBKIT_API bool isNull() const; + + WEBKIT_API WebURL url() const; + WEBKIT_API void setURL(const WebURL&); + + WEBKIT_API WebString mimeType() const; + WEBKIT_API void setMIMEType(const WebString&); + + WEBKIT_API long long expectedContentLength() const; + WEBKIT_API void setExpectedContentLength(long long); + + WEBKIT_API WebString textEncodingName() const; + WEBKIT_API void setTextEncodingName(const WebString&); + + WEBKIT_API WebString suggestedFileName() const; + WEBKIT_API void setSuggestedFileName(const WebString&); + + WEBKIT_API int httpStatusCode() const; + WEBKIT_API void setHTTPStatusCode(int); + + WEBKIT_API WebString httpStatusText() const; + WEBKIT_API void setHTTPStatusText(const WebString&); + + WEBKIT_API WebString httpHeaderField(const WebString& name) const; + WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value); + WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value); + WEBKIT_API void clearHTTPHeaderField(const WebString& name); + WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const; + + WEBKIT_API double lastModifiedDate() const; + WEBKIT_API void setLastModifiedDate(double); + + WEBKIT_API bool isContentFiltered() const; + WEBKIT_API void setIsContentFiltered(bool); + + WEBKIT_API long long appCacheID() const; + WEBKIT_API void setAppCacheID(long long); + + WEBKIT_API WebURL appCacheManifestURL() const; + WEBKIT_API void setAppCacheManifestURL(const WebURL&); + + // A consumer controlled value intended to be used to record opaque + // security info related to this request. + WEBKIT_API WebCString securityInfo() const; + WEBKIT_API void setSecurityInfo(const WebCString&); + +#if defined(WEBKIT_IMPLEMENTATION) + WebCore::ResourceResponse& toMutableResourceResponse(); + const WebCore::ResourceResponse& toResourceResponse() const; +#endif + +protected: + void assign(WebURLResponsePrivate*); + +private: + WebURLResponsePrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebVector.h b/WebKit/chromium/public/WebVector.h new file mode 100644 index 0000000..d1f99b4 --- /dev/null +++ b/WebKit/chromium/public/WebVector.h @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebVector_h +#define WebVector_h + +#include "WebCommon.h" + +#include <algorithm> + +namespace WebKit { + +// A simple vector class. +// +// Sample usage: +// +// void Foo(WebVector<int>& result) +// { +// WebVector<int> data(10); +// for (size_t i = 0; i < data.size(); ++i) +// data[i] = ... +// result.swap(data); +// } +// +// It is also possible to assign from other types of random access +// containers: +// +// void Foo(const std::vector<std::string>& input) +// { +// WebVector<WebCString> cstrings = input; +// ... +// } +// +template <typename T> +class WebVector { +public: + typedef T ValueType; + + ~WebVector() + { + destroy(); + } + + explicit WebVector(size_t size = 0) + { + initialize(size); + } + + WebVector(const WebVector<T>& other) + { + initializeFrom(other.m_ptr, other.m_size); + } + + template <typename C> + WebVector(const C& other) + { + initializeFrom(other.size() ? &other[0] : 0, other.size()); + } + + template <typename C> + WebVector<T>& operator=(const C& other) + { + if (this != reinterpret_cast<const WebVector<T>*>(&other)) + assign(other); + return *this; + } + + template <typename C> + void assign(const C& other) + { + assign(other.size() ? &other[0] : 0, other.size()); + } + + template <typename U> + void assign(const U* values, size_t size) + { + destroy(); + initializeFrom(values, size); + } + + size_t size() const { return m_size; } + bool isEmpty() const { return !m_size; } + + T& operator[](size_t i) { return m_ptr[i]; } + const T& operator[](size_t i) const { return m_ptr[i]; } + + T* data() { return m_ptr; } + const T* data() const { return m_ptr; } + + void swap(WebVector<T>& other) + { + std::swap(m_ptr, other.m_ptr); + std::swap(m_size, other.m_size); + } + +private: + void initialize(size_t size) + { + m_size = size; + if (!m_size) + m_ptr = 0; + else { + m_ptr = static_cast<T*>(::operator new(sizeof(T) * m_size)); + for (size_t i = 0; i < m_size; ++i) + new (&m_ptr[i]) T(); + } + } + + template <typename U> + void initializeFrom(const U* values, size_t size) + { + m_size = size; + if (!m_size) + m_ptr = 0; + else { + m_ptr = static_cast<T*>(::operator new(sizeof(T) * m_size)); + for (size_t i = 0; i < m_size; ++i) + new (&m_ptr[i]) T(values[i]); + } + } + + void destroy() + { + for (size_t i = 0; i < m_size; ++i) + m_ptr[i].~T(); + ::operator delete(m_ptr); + } + + T* m_ptr; + size_t m_size; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h new file mode 100644 index 0000000..5e1f15d --- /dev/null +++ b/WebKit/chromium/public/WebView.h @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebView_h +#define WebView_h + +#include "WebDragOperation.h" +#include "WebWidget.h" + +namespace WebKit { + +class WebAccessibilityObject; +class WebDevToolsAgent; +class WebDragData; +class WebFrame; +class WebFrameClient; +class WebNode; +class WebSettings; +class WebString; +class WebViewClient; +struct WebMediaPlayerAction; +struct WebPoint; +template <typename T> class WebVector; + +class WebView : public WebWidget { +public: + // Initialization ------------------------------------------------------ + + // Creates a WebView that is NOT yet initialized. You will need to + // call initializeMainFrame to finish the initialization. It is valid + // to pass a null WebViewClient pointer. + WEBKIT_API static WebView* create(WebViewClient*); + + // After creating a WebView, you should immediately call this method. + // You can optionally modify the settings before calling this method. + // The WebFrameClient will receive events for the main frame and any + // child frames. It is valid to pass a null WebFrameClient pointer. + virtual void initializeMainFrame(WebFrameClient*) = 0; + + + // Options ------------------------------------------------------------- + + // The returned pointer is valid for the lifetime of the WebView. + virtual WebSettings* settings() = 0; + + // Corresponds to the encoding of the main frame. Setting the page + // encoding may cause the main frame to reload. + virtual WebString pageEncoding() const = 0; + virtual void setPageEncoding(const WebString&) = 0; + + // Makes the WebView transparent. This is useful if you want to have + // some custom background rendered behind it. + virtual bool isTransparent() const = 0; + virtual void setIsTransparent(bool) = 0; + + // Controls whether pressing Tab key advances focus to links. + virtual bool tabsToLinks() const = 0; + virtual void setTabsToLinks(bool) = 0; + + // Method that controls whether pressing Tab key cycles through page + // elements or inserts a '\t' char in the focused text area. + virtual bool tabKeyCyclesThroughElements() const = 0; + virtual void setTabKeyCyclesThroughElements(bool) = 0; + + // Controls the WebView's active state, which may affect the rendering + // of elements on the page (i.e., tinting of input elements). + virtual bool isActive() const = 0; + virtual void setIsActive(bool) = 0; + + + // Closing ------------------------------------------------------------- + + // Runs beforeunload handlers for the current page, returning false if + // any handler suppressed unloading. + virtual bool dispatchBeforeUnloadEvent() = 0; + + // Runs unload handlers for the current page. + virtual void dispatchUnloadEvent() = 0; + + + // Frames -------------------------------------------------------------- + + virtual WebFrame* mainFrame() = 0; + + // Returns the frame identified by the given name. This method + // supports pseudo-names like _self, _top, and _blank. It traverses + // the entire frame tree containing this tree looking for a frame that + // matches the given name. If the optional relativeToFrame parameter + // is specified, then the search begins with the given frame and its + // children. + virtual WebFrame* findFrameByName( + const WebString& name, WebFrame* relativeToFrame = 0) = 0; + + + // Focus --------------------------------------------------------------- + + virtual WebFrame* focusedFrame() = 0; + virtual void setFocusedFrame(WebFrame*) = 0; + + // Focus the first (last if reverse is true) focusable node. + virtual void setInitialFocus(bool reverse) = 0; + + // Clears the focused node (and selection if a text field is focused) + // to ensure that a text field on the page is not eating keystrokes we + // send it. + virtual void clearFocusedNode() = 0; + + + // Zoom ---------------------------------------------------------------- + + // Returns the current zoom level. 0 is "original size", and each increment + // above or below represents zooming 20% larger or smaller to limits of 300% + // and 50% of original size, respectively. + virtual int zoomLevel() = 0; + + // Changes the zoom level to the specified level, clamping at the limits + // noted above, and returns the current zoom level after applying the + // change. + // + // If |textOnly| is set, only the text will be zoomed; otherwise the entire + // page will be zoomed. You can only have either text zoom or full page zoom + // at one time. Changing the mode while the page is zoomed will have odd + // effects. + virtual int setZoomLevel(bool textOnly, int zoomLevel) = 0; + + + // Media --------------------------------------------------------------- + + // Performs the specified action on the node at the given location. + virtual void performMediaPlayerAction( + const WebMediaPlayerAction&, const WebPoint& location) = 0; + + + // Data exchange ------------------------------------------------------- + + // Copy to the clipboard the image located at a particular point in the + // WebView (if there is such an image) + virtual void copyImageAt(const WebPoint&) = 0; + + // Notifies the WebView that a drag has terminated. + virtual void dragSourceEndedAt( + const WebPoint& clientPoint, const WebPoint& screenPoint, + WebDragOperation operation) = 0; + + // Notfies the WebView that the system drag and drop operation has ended. + virtual void dragSourceSystemDragEnded() = 0; + + // Callback methods when a drag-and-drop operation is trying to drop + // something on the WebView. + virtual WebDragOperation dragTargetDragEnter( + const WebDragData&, int identity, + const WebPoint& clientPoint, const WebPoint& screenPoint, + WebDragOperationsMask operationsAllowed) = 0; + virtual WebDragOperation dragTargetDragOver( + const WebPoint& clientPoint, const WebPoint& screenPoint, + WebDragOperationsMask operationsAllowed) = 0; + virtual void dragTargetDragLeave() = 0; + virtual void dragTargetDrop( + const WebPoint& clientPoint, const WebPoint& screenPoint) = 0; + + virtual int dragIdentity() = 0; + + // Helper method for drag and drop target operations: override the + // default drop effect with either a "copy" (accept true) or "none" + // (accept false) effect. Return true on success. + virtual bool setDropEffect(bool accept) = 0; + + + // Support for resource loading initiated by plugins ------------------- + + // Returns next unused request identifier which is unique within the + // parent Page. + virtual unsigned long createUniqueIdentifierForRequest() = 0; + + + // Developer tools ----------------------------------------------------- + + // Inspect a particular point in the WebView. (x = -1 || y = -1) is a + // special case, meaning inspect the current page and not a specific + // point. + virtual void inspectElementAt(const WebPoint&) = 0; + + // Settings used by the inspector. + virtual WebString inspectorSettings() const = 0; + virtual void setInspectorSettings(const WebString&) = 0; + + // The embedder may optionally engage a WebDevToolsAgent. This may only + // be set once per WebView. + virtual WebDevToolsAgent* devToolsAgent() = 0; + virtual void setDevToolsAgent(WebDevToolsAgent*) = 0; + + + // Accessibility ------------------------------------------------------- + + // Returns the accessibility object for this view. + virtual WebAccessibilityObject accessibilityObject() = 0; + + + // Autofill ------------------------------------------------------------ + + // Notifies the WebView that autofill suggestions are available for a node. + virtual void applyAutofillSuggestions( + const WebNode&, + const WebVector<WebString>& suggestions, + int defaultSuggestionIndex) = 0; + + // Hides the autofill popup if any are showing. + virtual void hideAutofillPopup() = 0; + + + // Context menu -------------------------------------------------------- + + virtual void performCustomContextMenuAction(unsigned action) = 0; + + + // Visited link state -------------------------------------------------- + + // Tells all WebView instances to update the visited link state for the + // specified hash. + WEBKIT_API static void updateVisitedLinkState(unsigned long long hash); + + // Tells all WebView instances to update the visited state for all + // their links. + WEBKIT_API static void resetVisitedLinkState(); + + + // Scrollbar colors ---------------------------------------------------- + virtual void setScrollbarColors(unsigned inactiveColor, + unsigned activeColor, + unsigned trackColor) = 0; + +protected: + ~WebView() {} +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebViewClient.h b/WebKit/chromium/public/WebViewClient.h new file mode 100644 index 0000000..2e2f953 --- /dev/null +++ b/WebKit/chromium/public/WebViewClient.h @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebViewClient_h +#define WebViewClient_h + +#include "WebDragOperation.h" +#include "WebEditingAction.h" +#include "WebFileChooserCompletion.h" +#include "WebString.h" +#include "WebTextAffinity.h" +#include "WebTextDirection.h" +#include "WebWidgetClient.h" + +namespace WebKit { + +class WebAccessibilityObject; +class WebDragData; +class WebFileChooserCompletion; +class WebFrame; +class WebNode; +class WebNotificationPresenter; +class WebRange; +class WebURL; +class WebView; +class WebWidget; +struct WebConsoleMessage; +struct WebContextMenuData; +struct WebPoint; +struct WebPopupMenuInfo; + +// Since a WebView is a WebWidget, a WebViewClient is a WebWidgetClient. +// Virtual inheritance allows an implementation of WebWidgetClient to be +// easily reused as part of an implementation of WebViewClient. +class WebViewClient : virtual public WebWidgetClient { +public: + // Factory methods ----------------------------------------------------- + + // Create a new related WebView. + virtual WebView* createView(WebFrame* creator) { return 0; } + + // Create a new WebPopupMenu. In the second form, the client is + // responsible for rendering the contents of the popup menu. + virtual WebWidget* createPopupMenu(bool activatable) { return 0; } + virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) { return 0; } + + + // Misc ---------------------------------------------------------------- + + // A new message was added to the console. + virtual void didAddMessageToConsole( + const WebConsoleMessage&, const WebString& sourceName, unsigned sourceLine) { } + + // Called when script in the page calls window.print(). If frame is + // non-null, then it selects a particular frame, including its + // children, to print. Otherwise, the main frame and its children + // should be printed. + virtual void printPage(WebFrame*) { } + + // Called to retrieve the provider of desktop notifications. + virtual WebNotificationPresenter* notificationPresenter() { return 0; } + + + // Navigational -------------------------------------------------------- + + // These notifications bracket any loading that occurs in the WebView. + virtual void didStartLoading() { } + virtual void didStopLoading() { } + + + // Editing ------------------------------------------------------------- + + // These methods allow the client to intercept and overrule editing + // operations. + virtual bool shouldBeginEditing(const WebRange&) { return true; } + virtual bool shouldEndEditing(const WebRange&) { return true; } + virtual bool shouldInsertNode( + const WebNode&, const WebRange&, WebEditingAction) { return true; } + virtual bool shouldInsertText( + const WebString&, const WebRange&, WebEditingAction) { return true; } + virtual bool shouldChangeSelectedRange( + const WebRange& from, const WebRange& to, WebTextAffinity, + bool stillSelecting) { return true; } + virtual bool shouldDeleteRange(const WebRange&) { return true; } + virtual bool shouldApplyStyle(const WebString& style, const WebRange&) { return true; } + + virtual bool isSmartInsertDeleteEnabled() { return true; } + virtual bool isSelectTrailingWhitespaceEnabled() { return true; } + virtual void setInputMethodEnabled(bool enabled) { } + + virtual void didBeginEditing() { } + virtual void didChangeSelection(bool isSelectionEmpty) { } + virtual void didChangeContents() { } + virtual void didExecuteCommand(const WebString& commandName) { } + virtual void didEndEditing() { } + + // This method is called in response to WebView's handleInputEvent() + // when the default action for the current keyboard event is not + // suppressed by the page, to give the embedder a chance to handle + // the keyboard event specially. + // + // Returns true if the keyboard event was handled by the embedder, + // indicating that the default action should be suppressed. + virtual bool handleCurrentKeyboardEvent() { return false; } + + + // Spellchecker -------------------------------------------------------- + + // The client should perform spell-checking on the given text. If the + // text contains a misspelled word, then upon return misspelledOffset + // will point to the start of the misspelled word, and misspelledLength + // will indicates its length. Otherwise, if there was not a spelling + // error, then upon return misspelledLength is 0. + virtual void spellCheck( + const WebString& text, int& misspelledOffset, int& misspelledLength) { } + + // Computes an auto-corrected replacement for a misspelled word. If no + // replacement is found, then an empty string is returned. + virtual WebString autoCorrectWord(const WebString& misspelledWord) { return WebString(); } + + // Show or hide the spelling UI. + virtual void showSpellingUI(bool show) { } + + // Returns true if the spelling UI is showing. + virtual bool isShowingSpellingUI() { return false; } + + // Update the spelling UI with the given word. + virtual void updateSpellingUIWithMisspelledWord(const WebString& word) { } + + + // Dialogs ------------------------------------------------------------- + + // This method returns immediately after showing the dialog. When the + // dialog is closed, it should call the WebFileChooserCompletion to + // pass the results of the dialog. Returns false if + // WebFileChooseCompletion will never be called. + virtual bool runFileChooser( + bool multiSelect, const WebString& title, + const WebString& initialValue, WebFileChooserCompletion*) { return false; } + + // Displays a modal alert dialog containing the given message. Returns + // once the user dismisses the dialog. + virtual void runModalAlertDialog( + WebFrame*, const WebString& message) { } + + // Displays a modal confirmation dialog with the given message as + // description and OK/Cancel choices. Returns true if the user selects + // 'OK' or false otherwise. + virtual bool runModalConfirmDialog( + WebFrame*, const WebString& message) { return false; } + + // Displays a modal input dialog with the given message as description + // and OK/Cancel choices. The input field is pre-filled with + // defaultValue. Returns true if the user selects 'OK' or false + // otherwise. Upon returning true, actualValue contains the value of + // the input field. + virtual bool runModalPromptDialog( + WebFrame*, const WebString& message, const WebString& defaultValue, + WebString* actualValue) { return false; } + + // Displays a modal confirmation dialog containing the given message as + // description and OK/Cancel choices, where 'OK' means that it is okay + // to proceed with closing the view. Returns true if the user selects + // 'OK' or false otherwise. + virtual bool runModalBeforeUnloadDialog( + WebFrame*, const WebString& message) { return true; } + + + // UI ------------------------------------------------------------------ + + // Called when script modifies window.status + virtual void setStatusText(const WebString&) { } + + // Called when hovering over an anchor with the given URL. + virtual void setMouseOverURL(const WebURL&) { } + + // Called when keyboard focus switches to an anchor with the given URL. + virtual void setKeyboardFocusURL(const WebURL&) { } + + // Called when a tooltip should be shown at the current cursor position. + virtual void setToolTipText(const WebString&, WebTextDirection hint) { } + + // Shows a context menu with commands relevant to a specific element on + // the given frame. Additional context data is supplied. + virtual void showContextMenu(WebFrame*, const WebContextMenuData&) { } + + // Called when a drag-n-drop operation should begin. + virtual void startDragging( + const WebPoint& from, const WebDragData&, WebDragOperationsMask) { } + + // Called to determine if drag-n-drop operations may initiate a page + // navigation. + virtual bool acceptsLoadDrops() { return true; } + + // Take focus away from the WebView by focusing an adjacent UI element + // in the containing window. + virtual void focusNext() { } + virtual void focusPrevious() { } + + + // Session history ----------------------------------------------------- + + // Tells the embedder to navigate back or forward in session history by + // the given offset (relative to the current position in session + // history). + virtual void navigateBackForwardSoon(int offset) { } + + // Returns the number of history items before/after the current + // history item. + virtual int historyBackListCount() { return 0; } + virtual int historyForwardListCount() { return 0; } + + // Called to notify the embedder when a new history item is added. + virtual void didAddHistoryItem() { } + + + // Accessibility ------------------------------------------------------- + + // Notifies embedder that the focus has changed to the given + // accessibility object. + virtual void focusAccessibilityObject(const WebAccessibilityObject&) { } + + + // Developer tools ----------------------------------------------------- + + // Called to notify the client that the inspector's settings were + // changed and should be saved. See WebView::inspectorSettings. + virtual void didUpdateInspectorSettings() { } + + + // Autofill ------------------------------------------------------------ + + // Queries the browser for suggestions to be shown for the form text + // field named |name|. |value| is the text entered by the user so + // far and the WebNode corresponds to the input field. + virtual void queryAutofillSuggestions(const WebNode&, + const WebString& name, + const WebString& value) { } + + // Instructs the browser to remove the autofill entry specified from + // its DB. + virtual void removeAutofillSuggestions(const WebString& name, + const WebString& value) { } + +protected: + ~WebViewClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebWidget.h b/WebKit/chromium/public/WebWidget.h new file mode 100644 index 0000000..9dfeefc --- /dev/null +++ b/WebKit/chromium/public/WebWidget.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebWidget_h +#define WebWidget_h + +#include "WebCanvas.h" +#include "WebCommon.h" +#include "WebCompositionCommand.h" +#include "WebTextDirection.h" + +namespace WebKit { + +class WebInputEvent; +class WebString; +struct WebRect; +struct WebSize; + +class WebWidget { +public: + // This method closes and deletes the WebWidget. + virtual void close() = 0; + + // Returns the current size of the WebWidget. + virtual WebSize size() = 0; + + // Called to resize the WebWidget. + virtual void resize(const WebSize&) = 0; + + // Called to layout the WebWidget. This MUST be called before Paint, + // and it may result in calls to WebWidgetClient::didInvalidateRect. + virtual void layout() = 0; + + // Called to paint the specified region of the WebWidget onto the given + // canvas. You MUST call Layout before calling this method. It is + // okay to call paint multiple times once layout has been called, + // assuming no other changes are made to the WebWidget (e.g., once + // events are processed, it should be assumed that another call to + // layout is warranted before painting again). + virtual void paint(WebCanvas*, const WebRect&) = 0; + + // Called to inform the WebWidget of an input event. Returns true if + // the event has been processed, false otherwise. + virtual bool handleInputEvent(const WebInputEvent&) = 0; + + // Called to inform the WebWidget that mouse capture was lost. + virtual void mouseCaptureLost() = 0; + + // Called to inform the WebWidget that it has gained or lost keyboard focus. + virtual void setFocus(bool) = 0; + + // Called to inform the WebWidget of a composition event. + virtual bool handleCompositionEvent(WebCompositionCommand command, + int cursorPosition, + int targetStart, + int targetEnd, + const WebString& text) = 0; + + // Retrieve the status of this WebWidget required by IME APIs. Upon + // success enabled and caretBounds are set. + virtual bool queryCompositionStatus(bool* enabled, WebRect* caretBounds) = 0; + + // Changes the text direction of the selected input node. + virtual void setTextDirection(WebTextDirection) = 0; + +protected: + ~WebWidget() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebWidgetClient.h b/WebKit/chromium/public/WebWidgetClient.h new file mode 100644 index 0000000..06d9eba --- /dev/null +++ b/WebKit/chromium/public/WebWidgetClient.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebWidgetClient_h +#define WebWidgetClient_h + +#include "WebCommon.h" +#include "WebNavigationPolicy.h" +#include "WebRect.h" +#include "WebScreenInfo.h" + +namespace WebKit { + +class WebWidget; +struct WebCursorInfo; + +class WebWidgetClient { +public: + // Called when a region of the WebWidget needs to be re-painted. + virtual void didInvalidateRect(const WebRect&) { } + + // Called when a region of the WebWidget, given by clipRect, should be + // scrolled by the specified dx and dy amounts. + virtual void didScrollRect(int dx, int dy, const WebRect& clipRect) { } + + // Called when the widget acquires or loses focus, respectively. + virtual void didFocus() { } + virtual void didBlur() { } + + // Called when the cursor for the widget changes. + virtual void didChangeCursor(const WebCursorInfo&) { } + + // Called when the widget should be closed. WebWidget::close() should + // be called asynchronously as a result of this notification. + virtual void closeWidgetSoon() { } + + // Called to show the widget according to the given policy. + virtual void show(WebNavigationPolicy) { } + + // Called to block execution of the current thread until the widget is + // closed. + virtual void runModal() { } + + // Called to get/set the position of the widget in screen coordinates. + virtual WebRect windowRect() { return WebRect(); } + virtual void setWindowRect(const WebRect&) { } + + // Called to get the position of the resizer rect in window coordinates. + virtual WebRect windowResizerRect() { return WebRect(); } + + // Called to get the position of the root window containing the widget + // in screen coordinates. + virtual WebRect rootWindowRect() { return WebRect(); } + + // Called to query information about the screen where this widget is + // displayed. + virtual WebScreenInfo screenInfo() { return WebScreenInfo(); } + +protected: + ~WebWidgetClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebWorker.h b/WebKit/chromium/public/WebWorker.h new file mode 100644 index 0000000..9397bcd --- /dev/null +++ b/WebKit/chromium/public/WebWorker.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebWorker_h +#define WebWorker_h + +#include "WebMessagePortChannel.h" + +namespace WebKit { + +class WebString; +class WebURL; +class WebWorkerClient; + +// Provides an interface to the script execution context for a worker. +class WebWorker { +public: + // Instantiates a built-in WebWorker. + WEBKIT_API static WebWorker* create(WebWorkerClient*); + + virtual ~WebWorker() { } + virtual void startWorkerContext(const WebURL& scriptURL, + const WebString& userAgent, + const WebString& sourceCode) = 0; + virtual void terminateWorkerContext() = 0; + virtual void postMessageToWorkerContext( + const WebString&, + const WebMessagePortChannelArray&) = 0; + virtual void workerObjectDestroyed() = 0; + virtual void clientDestroyed() = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebWorkerClient.h b/WebKit/chromium/public/WebWorkerClient.h new file mode 100644 index 0000000..eb2e63e --- /dev/null +++ b/WebKit/chromium/public/WebWorkerClient.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebWorkerClient_h +#define WebWorkerClient_h + +#include "WebCommonWorkerClient.h" +#include "WebMessagePortChannel.h" + +namespace WebKit { + +class WebNotificationPresenter; +class WebString; +class WebWorker; + +// Provides an interface back to the in-page script object for a worker. +// All functions are expected to be called back on the thread that created +// the Worker object, unless noted. +class WebWorkerClient : public WebCommonWorkerClient { +public: + virtual void postMessageToWorkerObject( + const WebString&, + const WebMessagePortChannelArray&) = 0; + + virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0; + virtual void reportPendingActivity(bool hasPendingActivity) = 0; + +protected: + ~WebWorkerClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/gtk/WebFontInfo.h b/WebKit/chromium/public/gtk/WebFontInfo.h new file mode 100644 index 0000000..ad37680 --- /dev/null +++ b/WebKit/chromium/public/gtk/WebFontInfo.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFontInfo_h +#define WebFontInfo_h + +#include "../WebCString.h" + +#include <string.h> +#include <unistd.h> + +namespace WebKit { + +class WebFontInfo { +public: + // Return a font family which provides glyphs for the Unicode code points + // specified by |utf16| + // characters: a native-endian UTF16 string + // numCharacters: the number of 16-bit words in |utf16| + // + // Returns: the font family or an empty string if the request could not be + // satisfied. + WEBKIT_API static WebCString familyForChars(const WebUChar* characters, size_t numCharacters); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/gtk/WebInputEventFactory.h b/WebKit/chromium/public/gtk/WebInputEventFactory.h new file mode 100644 index 0000000..463bd28 --- /dev/null +++ b/WebKit/chromium/public/gtk/WebInputEventFactory.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebInputEventFactory_h +#define WebInputEventFactory_h + +#include "../WebCommon.h" + +typedef struct _GdkEventButton GdkEventButton; +typedef struct _GdkEventMotion GdkEventMotion; +typedef struct _GdkEventCrossing GdkEventCrossing; +typedef struct _GdkEventScroll GdkEventScroll; +typedef struct _GdkEventKey GdkEventKey; + +namespace WebKit { + +class WebKeyboardEvent; +class WebMouseEvent; +class WebMouseWheelEvent; + +class WebInputEventFactory { +public: + WEBKIT_API static WebKeyboardEvent keyboardEvent(const GdkEventKey*); + WEBKIT_API static WebKeyboardEvent keyboardEvent(wchar_t character, int state, double timeStampSeconds); + WEBKIT_API static WebMouseEvent mouseEvent(const GdkEventButton*); + WEBKIT_API static WebMouseEvent mouseEvent(const GdkEventMotion*); + WEBKIT_API static WebMouseEvent mouseEvent(const GdkEventCrossing*); + WEBKIT_API static WebMouseWheelEvent mouseWheelEvent(const GdkEventScroll*); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/gtk/WebScreenInfoFactory.h b/WebKit/chromium/public/gtk/WebScreenInfoFactory.h new file mode 100644 index 0000000..c964741 --- /dev/null +++ b/WebKit/chromium/public/gtk/WebScreenInfoFactory.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebScreenInfoFactory_h +#define WebScreenInfoFactory_h + +#include "../WebCommon.h" + +typedef struct _GtkWidget GtkWidget; + +namespace WebKit { + +struct WebScreenInfo; + +class WebScreenInfoFactory { +public: + WEBKIT_API static WebScreenInfo screenInfo(GtkWidget*); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/linux/WebFontRendering.h b/WebKit/chromium/public/linux/WebFontRendering.h new file mode 100644 index 0000000..9b61bdc --- /dev/null +++ b/WebKit/chromium/public/linux/WebFontRendering.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFontRendering_h +#define WebFontRendering_h + +#include "../WebCommon.h" +#include <SkFontHost.h> +#include <SkPaint.h> + +namespace WebKit { + +class WebFontRendering { +public: + // Set global font renderering preferences. + + WEBKIT_API static void setHinting(SkPaint::Hinting); + WEBKIT_API static void setAntiAlias(bool on); + WEBKIT_API static void setSubpixelGlyphs(bool on); + WEBKIT_API static void setLCDOrder(SkFontHost::LCDOrder); + WEBKIT_API static void setLCDOrientation(SkFontHost::LCDOrientation); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/linux/WebSandboxSupport.h b/WebKit/chromium/public/linux/WebSandboxSupport.h new file mode 100644 index 0000000..5edceb2 --- /dev/null +++ b/WebKit/chromium/public/linux/WebSandboxSupport.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSandboxSupport_h +#define WebSandboxSupport_h + +#include "../WebCommon.h" +#include "../WebString.h" + +namespace WebKit { + +// Put methods here that are required due to sandbox restrictions. +class WebSandboxSupport { +public: + // Fonts --------------------------------------------------------------- + + // Get a font family which contains glyphs for the given Unicode + // code-points. + // characters: a UTF-16 encoded string + // numCharacters: the number of 16-bit words in |characters| + // + // Returns a string with the font family on an empty string if the + // request cannot be satisfied. + virtual WebString getFontFamilyForCharacters(const WebUChar* characters, size_t numCharacters) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/mac/WebInputEventFactory.h b/WebKit/chromium/public/mac/WebInputEventFactory.h new file mode 100644 index 0000000..cbf213c --- /dev/null +++ b/WebKit/chromium/public/mac/WebInputEventFactory.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebInputEventFactory_h +#define WebInputEventFactory_h + +#include "../WebCommon.h" + +#ifdef __OBJC__ +@class NSEvent; +@class NSView; +#else +class NSEvent; +class NSView; +#endif + +namespace WebKit { + +class WebKeyboardEvent; +class WebMouseEvent; +class WebMouseWheelEvent; + +class WebInputEventFactory { +public: + WEBKIT_API static WebKeyboardEvent keyboardEvent(NSEvent*); + WEBKIT_API static WebKeyboardEvent keyboardEvent(wchar_t character, int modifiers, double timeStampSeconds); + WEBKIT_API static WebMouseEvent mouseEvent(NSEvent*, NSView*); + WEBKIT_API static WebMouseWheelEvent mouseWheelEvent(NSEvent*, NSView*); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/mac/WebScreenInfoFactory.h b/WebKit/chromium/public/mac/WebScreenInfoFactory.h new file mode 100644 index 0000000..485e77f --- /dev/null +++ b/WebKit/chromium/public/mac/WebScreenInfoFactory.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebScreenInfoFactory_h +#define WebScreenInfoFactory_h + +#include "../WebCommon.h" + +#ifdef __OBJC__ +@class NSView; +#else +class NSView; +#endif + +namespace WebKit { + +struct WebScreenInfo; + +class WebScreenInfoFactory { +public: + WEBKIT_API static WebScreenInfo screenInfo(NSView*); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/win/WebInputEventFactory.h b/WebKit/chromium/public/win/WebInputEventFactory.h new file mode 100644 index 0000000..ae02464 --- /dev/null +++ b/WebKit/chromium/public/win/WebInputEventFactory.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebInputEventFactory_h +#define WebInputEventFactory_h + +#include "../WebCommon.h" + +#include <windows.h> + +namespace WebKit { + +class WebKeyboardEvent; +class WebMouseEvent; +class WebMouseWheelEvent; + +class WebInputEventFactory { +public: + WEBKIT_API static WebKeyboardEvent keyboardEvent(HWND, UINT, WPARAM, LPARAM); + WEBKIT_API static WebMouseEvent mouseEvent(HWND, UINT, WPARAM, LPARAM); + WEBKIT_API static WebMouseWheelEvent mouseWheelEvent(HWND, UINT, WPARAM, LPARAM); + + // Windows only provides information on whether a click was a single or + // double click, while we need to know the click count past two. The + // WebInputEventFactory keeps internal state to allow it to synthesize + // that information. In some cases, like fast-running tests, that + // information is known to be stale and needs to be reset; that is the + // function of resetLastClickState(). + WEBKIT_API static void resetLastClickState(); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/win/WebSandboxSupport.h b/WebKit/chromium/public/win/WebSandboxSupport.h new file mode 100644 index 0000000..88d5362 --- /dev/null +++ b/WebKit/chromium/public/win/WebSandboxSupport.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSandboxSupport_h +#define WebSandboxSupport_h + +typedef struct HFONT__* HFONT; + +namespace WebKit { + +// Put methods here that are required due to sandbox restrictions. +class WebSandboxSupport { +public: + // Sometimes a Win32 API call will fail because a font is not loaded, + // and due to sandbox restrictions, the current process may be unable + // to access the filesystem to load the font. So, this call serves as + // a failover to ask the embedder to try some other way to load the + // font (usually by delegating to an empowered process to have it load + // the font). Returns true if the font was successfully loaded. + virtual bool ensureFontLoaded(HFONT) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/win/WebScreenInfoFactory.h b/WebKit/chromium/public/win/WebScreenInfoFactory.h new file mode 100644 index 0000000..a7040ea --- /dev/null +++ b/WebKit/chromium/public/win/WebScreenInfoFactory.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebScreenInfoFactory_h +#define WebScreenInfoFactory_h + +#include "../WebCommon.h" + +typedef struct HWND__* HWND; + +namespace WebKit { + +struct WebScreenInfo; + +class WebScreenInfoFactory { +public: + WEBKIT_API static WebScreenInfo screenInfo(HWND); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/win/WebThemeEngine.h b/WebKit/chromium/public/win/WebThemeEngine.h new file mode 100644 index 0000000..b563608 --- /dev/null +++ b/WebKit/chromium/public/win/WebThemeEngine.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebThemeEngine_h +#define WebThemeEngine_h + +#include "../WebCanvas.h" +#include "../WebColor.h" + +namespace WebKit { + +struct WebRect; + +// The part and state parameters correspond to values defined by the +// Windows Theme API (see +// http://msdn.microsoft.com/en-us/library/bb773187(VS.85).aspx ). +// The classicState parameter corresponds to the uState +// parameter of the Windows DrawFrameControl() function. +// See the definitions in <vsstyle.h> and <winuser.h>. +class WebThemeEngine { +public: + virtual void paintButton( + WebCanvas*, int part, int state, int classicState, + const WebRect&) = 0; + + virtual void paintMenuList( + WebCanvas*, int part, int state, int classicState, + const WebRect&) = 0; + + virtual void paintScrollbarArrow( + WebCanvas*, int state, int classicState, + const WebRect&) = 0; + + virtual void paintScrollbarThumb( + WebCanvas*, int part, int state, int classicState, + const WebRect&) = 0; + + virtual void paintScrollbarTrack( + WebCanvas*, int part, int state, int classicState, + const WebRect&, const WebRect& alignRect) = 0; + + virtual void paintTextField( + WebCanvas*, int part, int state, int classicState, + const WebRect&, WebColor, bool fillContentArea, bool drawEdges) = 0; + + virtual void paintTrackbar( + WebCanvas*, int part, int state, int classicState, + const WebRect&) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/x11/WebScreenInfoFactory.h b/WebKit/chromium/public/x11/WebScreenInfoFactory.h new file mode 100644 index 0000000..5e30da8 --- /dev/null +++ b/WebKit/chromium/public/x11/WebScreenInfoFactory.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebScreenInfoFactory_h +#define WebScreenInfoFactory_h + +#include "../WebCommon.h" + +typedef struct _XDisplay Display; + +namespace WebKit { + +struct WebScreenInfo; + +class WebScreenInfoFactory { +public: + WEBKIT_API static WebScreenInfo screenInfo(Display*, int screenNumber); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/ApplicationCacheHost.cpp b/WebKit/chromium/src/ApplicationCacheHost.cpp new file mode 100644 index 0000000..ef8f860 --- /dev/null +++ b/WebKit/chromium/src/ApplicationCacheHost.cpp @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "ApplicationCacheHost.h" + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + +#include "DocumentLoader.h" +#include "DOMApplicationCache.h" +#include "Frame.h" +#include "Settings.h" +#include "WebApplicationCacheHost.h" +#include "WebApplicationCacheHostClient.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebURL.h" +#include "WebURLError.h" +#include "WebURLResponse.h" +#include "WrappedResourceRequest.h" +#include "WrappedResourceResponse.h" + +using namespace WebKit; + +namespace WebCore { + +// ApplicationCacheHostInternal ----------------------------------------------- + +class ApplicationCacheHostInternal : public WebApplicationCacheHostClient { +public: + ApplicationCacheHostInternal(ApplicationCacheHost* host) + : m_innerHost(host) + { + m_outerHost.set(WebKit::webKitClient()->createApplicationCacheHost(this)); + } + + virtual void notifyEventListener(WebApplicationCacheHost::EventID eventID) + { + m_innerHost->notifyDOMApplicationCache( + static_cast<ApplicationCacheHost::EventID>(eventID)); + } + + ApplicationCacheHost* m_innerHost; + OwnPtr<WebApplicationCacheHost> m_outerHost; +}; + +// ApplicationCacheHost ------------------------------------------------------- +// We provide a custom implementation of this class that calls out to the +// embedding application instead of using WebCore's built in appcache system. +// This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build. + +ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* documentLoader) + : m_domApplicationCache(0) + , m_documentLoader(documentLoader) +{ + ASSERT(m_documentLoader); +} + +ApplicationCacheHost::~ApplicationCacheHost() +{ +} + +void ApplicationCacheHost::maybeLoadMainResource(ResourceRequest& request, SubstituteData&) +{ + // We defer creating the outer host object to avoid spurious creation/destruction + // around creating empty documents. At this point, we're initiating a main resource + // load for the document, so its for real. + + if (!isApplicationCacheEnabled()) + return; + + m_internal.set(new ApplicationCacheHostInternal(this)); + if (m_internal->m_outerHost) { + WrappedResourceRequest wrapped(request); + m_internal->m_outerHost->willStartMainResourceRequest(wrapped); + } else + m_internal.clear(); + + // NOTE: The semantics of this method, and others in this interface, are subtly different + // than the method names would suggest. For example, in this method never returns an appcached + // response in the SubstituteData out argument, instead we return the appcached response thru + // the usual resource loading pipeline. +} + +void ApplicationCacheHost::selectCacheWithoutManifest() +{ + if (m_internal) + m_internal->m_outerHost->selectCacheWithoutManifest(); +} + +void ApplicationCacheHost::selectCacheWithManifest(const KURL& manifestURL) +{ + if (m_internal) { + if (!m_internal->m_outerHost->selectCacheWithManifest(manifestURL)) { + // It's a foreign entry, restart the current navigation from the top + // of the navigation algorithm. The navigation will not result in the + // same resource being loaded, because "foreign" entries are never picked + // during navigation. + // see WebCore::ApplicationCacheGroup::selectCache() + const KURL& docURL = m_documentLoader->frame()->document()->url(); + String referrer = m_documentLoader->frameLoader()->referrer(); + m_documentLoader->frame()->redirectScheduler()->scheduleLocationChange(docURL, referrer); + } + } +} + +bool ApplicationCacheHost::maybeLoadFallbackForMainResponse(const ResourceRequest&, const ResourceResponse& response) +{ + if (m_internal) { + WrappedResourceResponse wrapped(response); + m_internal->m_outerHost->didReceiveResponseForMainResource(wrapped); + } + return false; +} + +bool ApplicationCacheHost::maybeLoadFallbackForMainError(const ResourceRequest&, const ResourceError& error) +{ + // N/A to the chromium port + return false; +} + +void ApplicationCacheHost::mainResourceDataReceived(const char* data, int length, long long, bool) +{ + if (m_internal) + m_internal->m_outerHost->didReceiveDataForMainResource(data, length); +} + +void ApplicationCacheHost::failedLoadingMainResource() +{ + if (m_internal) + m_internal->m_outerHost->didFinishLoadingMainResource(false); +} + +void ApplicationCacheHost::finishedLoadingMainResource() +{ + if (m_internal) + m_internal->m_outerHost->didFinishLoadingMainResource(true); +} + +bool ApplicationCacheHost::maybeLoadResource(ResourceLoader*, ResourceRequest& request, const KURL&) +{ + // FIXME: look into the purpose of the unused KURL& originalURL parameter + if (m_internal) { + WrappedResourceRequest wrapped(request); + m_internal->m_outerHost->willStartSubResourceRequest(wrapped); + } + return false; +} + +bool ApplicationCacheHost::maybeLoadFallbackForRedirect(ResourceLoader*, ResourceRequest&, const ResourceResponse&) +{ + // N/A to the chromium port + return false; +} + +bool ApplicationCacheHost::maybeLoadFallbackForResponse(ResourceLoader*, const ResourceResponse&) +{ + // N/A to the chromium port + return false; +} + +bool ApplicationCacheHost::maybeLoadFallbackForError(ResourceLoader*, const ResourceError&) +{ + // N/A to the chromium port + return false; +} + +bool ApplicationCacheHost::maybeLoadSynchronously(ResourceRequest& request, ResourceError&, ResourceResponse&, Vector<char>&) +{ + if (m_internal) { + WrappedResourceRequest wrapped(request); + m_internal->m_outerHost->willStartSubResourceRequest(wrapped); + } + return false; +} + +void ApplicationCacheHost::maybeLoadFallbackSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>&) +{ + // N/A to the chromium port +} + +bool ApplicationCacheHost::canCacheInPageCache() const +{ + // N/A to the chromium port which doesn't use the page cache. + return false; +} + +void ApplicationCacheHost::setDOMApplicationCache(DOMApplicationCache* domApplicationCache) +{ + ASSERT(!m_domApplicationCache || !domApplicationCache); + m_domApplicationCache = domApplicationCache; +} + +void ApplicationCacheHost::notifyDOMApplicationCache(EventID id) +{ + if (m_domApplicationCache) { + ExceptionCode ec = 0; + m_domApplicationCache->dispatchEvent( + Event::create(DOMApplicationCache::toEventType(id), false, false), + ec); + ASSERT(!ec); + } +} + +ApplicationCacheHost::Status ApplicationCacheHost::status() const +{ + return m_internal ? static_cast<Status>(m_internal->m_outerHost->status()) : UNCACHED; +} + +bool ApplicationCacheHost::update() +{ + return m_internal ? m_internal->m_outerHost->startUpdate() : false; +} + +bool ApplicationCacheHost::swapCache() +{ + return m_internal ? m_internal->m_outerHost->swapCache() : false; +} + +bool ApplicationCacheHost::isApplicationCacheEnabled() +{ + ASSERT(m_documentLoader->frame()); + return m_documentLoader->frame()->settings() + && m_documentLoader->frame()->settings()->offlineWebApplicationCacheEnabled(); +} + +} // namespace WebCore + +#endif // ENABLE(OFFLINE_WEB_APPLICATIONS) diff --git a/WebKit/chromium/src/AssertMatchingEnums.cpp b/WebKit/chromium/src/AssertMatchingEnums.cpp new file mode 100644 index 0000000..35e2057 --- /dev/null +++ b/WebKit/chromium/src/AssertMatchingEnums.cpp @@ -0,0 +1,279 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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. + */ + +// Use this file to assert that various WebKit API enum values continue +// matching WebCore defined enum values. + +#include "config.h" + +#include "AccessibilityObject.h" +#include "ApplicationCacheHost.h" +#include "EditorInsertAction.h" +#include "HTMLInputElement.h" +#include "MediaPlayer.h" +#include "NotificationPresenter.h" +#include "PasteboardPrivate.h" +#include "PlatformCursor.h" +#include "StringImpl.h" +#include "TextAffinity.h" +#include "WebAccessibilityObject.h" +#include "WebApplicationCacheHost.h" +#include "WebClipboard.h" +#include "WebCursorInfo.h" +#include "WebEditingAction.h" +#include "WebInputElement.h" +#include "WebMediaPlayer.h" +#include "WebNotificationPresenter.h" +#include "WebTextAffinity.h" +#include "WebTextCaseSensitivity.h" +#include <wtf/Assertions.h> + +#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \ + COMPILE_ASSERT(int(WebKit::webkit_name) == int(WebCore::webcore_name), mismatching_enums) + +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleUnknown, UnknownRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleButton, ButtonRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRadioButton, RadioButtonRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleCheckBox, CheckBoxRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSlider, SliderRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabGroup, TabGroupRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTextField, TextFieldRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleStaticText, StaticTextRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTextArea, TextAreaRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleScrollArea, ScrollAreaRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRolePopUpButton, PopUpButtonRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuButton, MenuButtonRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTable, TableRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplication, ApplicationRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleGroup, GroupRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRadioGroup, RadioGroupRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleList, ListRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleScrollBar, ScrollBarRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleValueIndicator, ValueIndicatorRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleImage, ImageRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuBar, MenuBarRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenu, MenuRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuItem, MenuItemRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleColumn, ColumnRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRow, RowRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleToolbar, ToolbarRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleBusyIndicator, BusyIndicatorRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleProgressIndicator, ProgressIndicatorRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWindow, WindowRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDrawer, DrawerRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSystemWide, SystemWideRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleOutline, OutlineRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleIncrementor, IncrementorRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleBrowser, BrowserRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleComboBox, ComboBoxRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSplitGroup, SplitGroupRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSplitter, SplitterRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleColorWell, ColorWellRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleGrowArea, GrowAreaRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSheet, SheetRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleHelpTag, HelpTagRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMatte, MatteRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRuler, RulerRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRulerMarker, RulerMarkerRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLink, LinkRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDisclosureTriangle, DisclosureTriangleRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleGrid, GridRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleCell, CellRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleColumnHeader, ColumnHeaderRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRowHeader, RowHeaderRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWebCoreLink, WebCoreLinkRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleImageMapLink, ImageMapLinkRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleImageMap, ImageMapRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListMarker, ListMarkerRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWebArea, WebAreaRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleHeading, HeadingRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListBox, ListBoxRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListBoxOption, ListBoxOptionRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTableHeaderContainer, TableHeaderContainerRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDefinitionListTerm, DefinitionListTermRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDefinitionListDefinition, DefinitionListDefinitionRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleAnnotation, AnnotationRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSliderThumb, SliderThumbRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleIgnored, IgnoredRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTab, TabRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabList, TabListRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabPanel, TabPanelRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeRole, TreeRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeItemRole, TreeItemRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDirectory, DirectoryRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkApplication, LandmarkApplicationRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkBanner, LandmarkBannerRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkComplementary, LandmarkComplementaryRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkContentInfo, LandmarkContentInfoRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkMain, LandmarkMainRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkNavigation, LandmarkNavigationRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkSearch, LandmarkSearchRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationAlert, ApplicationAlertRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationAlertDialog, ApplicationAlertDialogRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationDialog, ApplicationDialogRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationLog, ApplicationLogRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationMarquee, ApplicationMarqueeRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationStatus, ApplicationStatusRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationTimer, ApplicationTimerRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocument, DocumentRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentArticle, DocumentArticleRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentMath, DocumentMathRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentNote, DocumentNoteRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentRegion, DocumentRegionRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleUserInterfaceTooltip, UserInterfaceTooltipRole); + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Uncached, ApplicationCacheHost::UNCACHED); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Idle, ApplicationCacheHost::IDLE); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Checking, ApplicationCacheHost::CHECKING); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Downloading, ApplicationCacheHost::DOWNLOADING); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::UpdateReady, ApplicationCacheHost::UPDATEREADY); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Obsolete, ApplicationCacheHost::OBSOLETE); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::CheckingEvent, ApplicationCacheHost::CHECKING_EVENT); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::ErrorEvent, ApplicationCacheHost::ERROR_EVENT); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::NoUpdateEvent, ApplicationCacheHost::NOUPDATE_EVENT); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::DownloadingEvent, ApplicationCacheHost::DOWNLOADING_EVENT); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::ProgressEvent, ApplicationCacheHost::PROGRESS_EVENT); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::UpdateReadyEvent, ApplicationCacheHost::UPDATEREADY_EVENT); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::CachedEvent, ApplicationCacheHost::CACHED_EVENT); +COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::ObsoleteEvent, ApplicationCacheHost::OBSOLETE_EVENT); +#endif + +COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::FormatHTML, PasteboardPrivate::HTMLFormat); +COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::FormatBookmark, PasteboardPrivate::BookmarkFormat); +COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::FormatSmartPaste, PasteboardPrivate::WebSmartPasteFormat); + +COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::BufferStandard, PasteboardPrivate::StandardBuffer); +COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::BufferSelection, PasteboardPrivate::SelectionBuffer); + +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypePointer, PlatformCursor::TypePointer); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCross, PlatformCursor::TypeCross); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeHand, PlatformCursor::TypeHand); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeIBeam, PlatformCursor::TypeIBeam); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWait, PlatformCursor::TypeWait); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeHelp, PlatformCursor::TypeHelp); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastResize, PlatformCursor::TypeEastResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthResize, PlatformCursor::TypeNorthResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastResize, PlatformCursor::TypeNorthEastResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestResize, PlatformCursor::TypeNorthWestResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthResize, PlatformCursor::TypeSouthResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthEastResize, PlatformCursor::TypeSouthEastResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthWestResize, PlatformCursor::TypeSouthWestResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWestResize, PlatformCursor::TypeWestResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthSouthResize, PlatformCursor::TypeNorthSouthResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastWestResize, PlatformCursor::TypeEastWestResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastSouthWestResize, PlatformCursor::TypeNorthEastSouthWestResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestSouthEastResize, PlatformCursor::TypeNorthWestSouthEastResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeColumnResize, PlatformCursor::TypeColumnResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeRowResize, PlatformCursor::TypeRowResize); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeMiddlePanning, PlatformCursor::TypeMiddlePanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastPanning, PlatformCursor::TypeEastPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthPanning, PlatformCursor::TypeNorthPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastPanning, PlatformCursor::TypeNorthEastPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestPanning, PlatformCursor::TypeNorthWestPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthPanning, PlatformCursor::TypeSouthPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthEastPanning, PlatformCursor::TypeSouthEastPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthWestPanning, PlatformCursor::TypeSouthWestPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWestPanning, PlatformCursor::TypeWestPanning); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeMove, PlatformCursor::TypeMove); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeVerticalText, PlatformCursor::TypeVerticalText); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCell, PlatformCursor::TypeCell); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeContextMenu, PlatformCursor::TypeContextMenu); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeAlias, PlatformCursor::TypeAlias); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeProgress, PlatformCursor::TypeProgress); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNoDrop, PlatformCursor::TypeNoDrop); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCopy, PlatformCursor::TypeCopy); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNone, PlatformCursor::TypeNone); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNotAllowed, PlatformCursor::TypeNotAllowed); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeZoomIn, PlatformCursor::TypeZoomIn); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeZoomOut, PlatformCursor::TypeZoomOut); +COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCustom, PlatformCursor::TypeCustom); + +COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionTyped, EditorInsertActionTyped); +COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionPasted, EditorInsertActionPasted); +COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped); + +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Text, HTMLInputElement::TEXT); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Password, HTMLInputElement::PASSWORD); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::IsIndex, HTMLInputElement::ISINDEX); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::CheckBox, HTMLInputElement::CHECKBOX); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Radio, HTMLInputElement::RADIO); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Submit, HTMLInputElement::SUBMIT); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Reset, HTMLInputElement::RESET); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::File, HTMLInputElement::FILE); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Hidden, HTMLInputElement::HIDDEN); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Image, HTMLInputElement::IMAGE); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Button, HTMLInputElement::BUTTON); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Search, HTMLInputElement::SEARCH); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Range, HTMLInputElement::RANGE); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Email, HTMLInputElement::EMAIL); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Number, HTMLInputElement::NUMBER); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Telephone, HTMLInputElement::TELEPHONE); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::URL, HTMLInputElement::URL); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Color, HTMLInputElement::COLOR); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Date, HTMLInputElement::DATE); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::DateTime, HTMLInputElement::DATETIME); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::DateTimeLocal, HTMLInputElement::DATETIMELOCAL); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Month, HTMLInputElement::MONTH); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Time, HTMLInputElement::TIME); +COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Week, HTMLInputElement::WEEK); + +#if ENABLE(VIDEO) +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Empty, MediaPlayer::Empty); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Idle, MediaPlayer::Idle); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Loading, MediaPlayer::Loading); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Loaded, MediaPlayer::Loaded); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::FormatError, MediaPlayer::FormatError); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkError, MediaPlayer::NetworkError); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::DecodeError, MediaPlayer::DecodeError); + +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveNothing, MediaPlayer::HaveNothing); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveMetadata, MediaPlayer::HaveMetadata); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveCurrentData, MediaPlayer::HaveCurrentData); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveFutureData, MediaPlayer::HaveFutureData); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveEnoughData, MediaPlayer::HaveEnoughData); + +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Unknown, MediaPlayer::Unknown); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Download, MediaPlayer::Download); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::StoredStream, MediaPlayer::StoredStream); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::LiveStream, MediaPlayer::LiveStream); +#endif + +#if ENABLE(NOTIFICATIONS) +COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionAllowed, NotificationPresenter::PermissionAllowed); +COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionNotAllowed, NotificationPresenter::PermissionNotAllowed); +COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionDenied, NotificationPresenter::PermissionDenied); +#endif + +COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityUpstream, UPSTREAM); +COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityDownstream, DOWNSTREAM); + +COMPILE_ASSERT_MATCHING_ENUM(WebTextCaseSensitive, TextCaseSensitive); +COMPILE_ASSERT_MATCHING_ENUM(WebTextCaseInsensitive, TextCaseInsensitive); diff --git a/WebKit/chromium/src/AutocompletePopupMenuClient.cpp b/WebKit/chromium/src/AutocompletePopupMenuClient.cpp new file mode 100644 index 0000000..62d4dff --- /dev/null +++ b/WebKit/chromium/src/AutocompletePopupMenuClient.cpp @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "AutocompletePopupMenuClient.h" + +#include "CSSStyleSelector.h" +#include "CSSValueKeywords.h" +#include "FrameView.h" +#include "HTMLInputElement.h" +#include "RenderTheme.h" +#include "WebVector.h" +#include "WebViewImpl.h" + +using namespace WebCore; + +namespace WebKit { + +AutocompletePopupMenuClient::AutocompletePopupMenuClient(WebViewImpl* webView) + : m_textField(0) + , m_selectedIndex(0) + , m_webView(webView) +{ +} + +AutocompletePopupMenuClient::~AutocompletePopupMenuClient() +{ +} + +void AutocompletePopupMenuClient::initialize( + HTMLInputElement* textField, + const WebVector<WebString>& suggestions, + int defaultSuggestionIndex) +{ + ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); + m_textField = textField; + m_selectedIndex = defaultSuggestionIndex; + setSuggestions(suggestions); + + FontDescription fontDescription; + m_webView->theme()->systemFont(CSSValueWebkitControl, fontDescription); + // Use a smaller font size to match IE/Firefox. + // FIXME: http://crbug.com/7376 use the system size instead of a + // fixed font size value. + fontDescription.setComputedSize(12.0); + Font font(fontDescription, 0, 0); + font.update(textField->document()->styleSelector()->fontSelector()); + // The direction of text in popup menu is set the same as the direction of + // the input element: textField. + m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true, + Length(WebCore::Fixed), + textField->renderer()->style()->direction())); +} + +void AutocompletePopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents) +{ + m_textField->setValue(m_suggestions[listIndex]); + EditorClientImpl* editor = + static_cast<EditorClientImpl*>(m_webView->page()->editorClient()); + ASSERT(editor); + editor->onAutofillSuggestionAccepted( + static_cast<HTMLInputElement*>(m_textField.get())); +} + +String AutocompletePopupMenuClient::itemText(unsigned listIndex) const +{ + return m_suggestions[listIndex]; +} + +PopupMenuStyle AutocompletePopupMenuClient::itemStyle(unsigned listIndex) const +{ + return *m_style; +} + +PopupMenuStyle AutocompletePopupMenuClient::menuStyle() const +{ + return *m_style; +} + +int AutocompletePopupMenuClient::clientPaddingLeft() const +{ + // Bug http://crbug.com/7708 seems to indicate the style can be 0. + RenderStyle* style = textFieldStyle(); + return style ? m_webView->theme()->popupInternalPaddingLeft(style) : 0; +} + +int AutocompletePopupMenuClient::clientPaddingRight() const +{ + // Bug http://crbug.com/7708 seems to indicate the style can be 0. + RenderStyle* style = textFieldStyle(); + return style ? m_webView->theme()->popupInternalPaddingRight(style) : 0; +} + +void AutocompletePopupMenuClient::popupDidHide() +{ + m_webView->autoCompletePopupDidHide(); +} + +void AutocompletePopupMenuClient::setTextFromItem(unsigned listIndex) +{ + m_textField->setValue(m_suggestions[listIndex]); +} + +FontSelector* AutocompletePopupMenuClient::fontSelector() const +{ + return m_textField->document()->styleSelector()->fontSelector(); +} + +HostWindow* AutocompletePopupMenuClient::hostWindow() const +{ + return m_textField->document()->view()->hostWindow(); +} + +PassRefPtr<Scrollbar> AutocompletePopupMenuClient::createScrollbar( + ScrollbarClient* client, + ScrollbarOrientation orientation, + ScrollbarControlSize size) +{ + return Scrollbar::createNativeScrollbar(client, orientation, size); +} + +void AutocompletePopupMenuClient::setSuggestions(const WebVector<WebString>& suggestions) +{ + m_suggestions.clear(); + for (size_t i = 0; i < suggestions.size(); ++i) + m_suggestions.append(suggestions[i]); + // Try to preserve selection if possible. + if (m_selectedIndex >= static_cast<int>(suggestions.size())) + m_selectedIndex = -1; +} + +void AutocompletePopupMenuClient::removeItemAtIndex(int index) +{ + ASSERT(index >= 0 && index < static_cast<int>(m_suggestions.size())); + m_suggestions.remove(index); +} + +RenderStyle* AutocompletePopupMenuClient::textFieldStyle() const +{ + RenderStyle* style = m_textField->computedStyle(); + if (!style) { + // It seems we can only have a 0 style in a TextField if the + // node is detached, in which case we the popup shoud not be + // showing. Please report this in http://crbug.com/7708 and + // include the page you were visiting. + ASSERT_NOT_REACHED(); + } + return style; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/AutocompletePopupMenuClient.h b/WebKit/chromium/src/AutocompletePopupMenuClient.h new file mode 100644 index 0000000..ad24e54 --- /dev/null +++ b/WebKit/chromium/src/AutocompletePopupMenuClient.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "PopupMenuClient.h" + +namespace WebCore { +class HTMLInputElement; +class PopupMenuStyle; +class RenderStyle; +} + +namespace WebKit { +class WebString; +class WebViewImpl; +template <typename T> class WebVector; + +// AutocompletePopupMenuClient +class AutocompletePopupMenuClient : public WebCore::PopupMenuClient { +public: + AutocompletePopupMenuClient(WebViewImpl* webview); + ~AutocompletePopupMenuClient(); + + void initialize(WebCore::HTMLInputElement*, + const WebVector<WebString>& suggestions, + int defaultSuggestionIndex); + + WebCore::HTMLInputElement* textField() const { return m_textField.get(); } + + void setSuggestions(const WebVector<WebString>&); + void removeItemAtIndex(int index); + + // WebCore::PopupMenuClient methods: + virtual void valueChanged(unsigned listIndex, bool fireEvents = true); + virtual WebCore::String itemText(unsigned listIndex) const; + virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); } + virtual bool itemIsEnabled(unsigned listIndex) const { return true; } + virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const; + virtual WebCore::PopupMenuStyle menuStyle() const; + virtual int clientInsetLeft() const { return 0; } + virtual int clientInsetRight() const { return 0; } + virtual int clientPaddingLeft() const; + virtual int clientPaddingRight() const; + virtual int listSize() const { return m_suggestions.size(); } + virtual int selectedIndex() const { return m_selectedIndex; } + virtual void popupDidHide(); + virtual bool itemIsSeparator(unsigned listIndex) const { return false; } + virtual bool itemIsLabel(unsigned listIndex) const { return false; } + virtual bool itemIsSelected(unsigned listIndex) const { return false; } + virtual bool shouldPopOver() const { return false; } + virtual bool valueShouldChangeOnHotTrack() const { return false; } + virtual void setTextFromItem(unsigned listIndex); + virtual WebCore::FontSelector* fontSelector() const; + virtual WebCore::HostWindow* hostWindow() const; + virtual PassRefPtr<WebCore::Scrollbar> createScrollbar( + WebCore::ScrollbarClient* client, + WebCore::ScrollbarOrientation orientation, + WebCore::ScrollbarControlSize size); + +private: + WebCore::RenderStyle* textFieldStyle() const; + + RefPtr<WebCore::HTMLInputElement> m_textField; + Vector<WebCore::String> m_suggestions; + int m_selectedIndex; + WebViewImpl* m_webView; + OwnPtr<WebCore::PopupMenuStyle> m_style; +}; + +} // namespace WebKit diff --git a/WebKit/chromium/src/BackForwardListClientImpl.cpp b/WebKit/chromium/src/BackForwardListClientImpl.cpp new file mode 100644 index 0000000..8feae32 --- /dev/null +++ b/WebKit/chromium/src/BackForwardListClientImpl.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "BackForwardListClientImpl.h" + +#include "HistoryItem.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" + +using namespace WebCore; + +namespace WebKit { + +const char backForwardNavigationScheme[] = "chrome-back-forward"; + +BackForwardListClientImpl::BackForwardListClientImpl(WebViewImpl* webView) + : m_webView(webView) +{ +} + +BackForwardListClientImpl::~BackForwardListClientImpl() +{ +} + +void BackForwardListClientImpl::setCurrentHistoryItem(HistoryItem* item) +{ + m_previousItem = m_currentItem; + m_currentItem = item; +} + +HistoryItem* BackForwardListClientImpl::previousHistoryItem() const +{ + return m_previousItem.get(); +} + +void BackForwardListClientImpl::addItem(PassRefPtr<HistoryItem> item) +{ + m_previousItem = m_currentItem; + m_currentItem = item; + + // If WebCore adds a new HistoryItem, it means this is a new navigation (ie, + // not a reload or back/forward). + m_webView->observeNewNavigation(); + + if (m_webView->client()) + m_webView->client()->didAddHistoryItem(); +} + +void BackForwardListClientImpl::goToItem(HistoryItem* item) +{ + m_previousItem = m_currentItem; + m_currentItem = item; + + if (m_pendingHistoryItem == item) + m_pendingHistoryItem = 0; +} + +HistoryItem* BackForwardListClientImpl::currentItem() +{ + return m_currentItem.get(); +} + +HistoryItem* BackForwardListClientImpl::itemAtIndex(int index) +{ + if (!m_webView->client()) + return 0; + + // Since we don't keep the entire back/forward list, we have no way to + // properly implement this method. We return a dummy entry instead that we + // intercept in our FrameLoaderClient implementation in case WebCore asks + // to navigate to this HistoryItem. + + // FIXME: We should change WebCore to handle history.{back,forward,go} + // differently. It should perhaps just ask the FrameLoaderClient to + // perform those navigations. + + String url_string = String::format( + "%s://go/%d", backForwardNavigationScheme, index); + + m_pendingHistoryItem = + HistoryItem::create(url_string, String(), 0.0); + return m_pendingHistoryItem.get(); +} + +int BackForwardListClientImpl::backListCount() +{ + if (!m_webView->client()) + return 0; + + return m_webView->client()->historyBackListCount(); +} + +int BackForwardListClientImpl::forwardListCount() +{ + if (!m_webView->client()) + return 0; + + return m_webView->client()->historyForwardListCount(); +} + +void BackForwardListClientImpl::close() +{ + m_currentItem = 0; + m_previousItem = 0; + m_pendingHistoryItem = 0; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/BackForwardListClientImpl.h b/WebKit/chromium/src/BackForwardListClientImpl.h new file mode 100644 index 0000000..1d8beb0 --- /dev/null +++ b/WebKit/chromium/src/BackForwardListClientImpl.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 BackForwardListClientImpl_h +#define BackForwardListClientImpl_h + +#include "BackForwardList.h" + +namespace WebKit { +class WebViewImpl; + +extern const char backForwardNavigationScheme[]; + +class BackForwardListClientImpl : public WebCore::BackForwardListClient { +public: + BackForwardListClientImpl(WebViewImpl* webview); + ~BackForwardListClientImpl(); + + void setCurrentHistoryItem(WebCore::HistoryItem* item); + WebCore::HistoryItem* previousHistoryItem() const; + +private: + // WebCore::BackForwardListClient methods: + virtual void addItem(PassRefPtr<WebCore::HistoryItem>); + virtual void goToItem(WebCore::HistoryItem*); + virtual WebCore::HistoryItem* currentItem(); + virtual WebCore::HistoryItem* itemAtIndex(int index); + virtual int backListCount(); + virtual int forwardListCount(); + virtual void close(); + + WebViewImpl* m_webView; + + RefPtr<WebCore::HistoryItem> m_previousItem; + RefPtr<WebCore::HistoryItem> m_currentItem; + + // The last history item that was accessed via itemAtIndex(). We keep track + // of this until goToItem() is called, so we can track the navigation. + RefPtr<WebCore::HistoryItem> m_pendingHistoryItem; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/ChromeClientImpl.cpp b/WebKit/chromium/src/ChromeClientImpl.cpp new file mode 100644 index 0000000..4e20124 --- /dev/null +++ b/WebKit/chromium/src/ChromeClientImpl.cpp @@ -0,0 +1,671 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "ChromeClientImpl.h" + +#include "AccessibilityObject.h" +#include "AXObjectCache.h" +#include "CharacterNames.h" +#include "Console.h" +#include "Cursor.h" +#include "DatabaseTracker.h" +#include "Document.h" +#include "DocumentLoader.h" +#include "FileChooser.h" +#include "FloatRect.h" +#include "FrameLoadRequest.h" +#include "FrameView.h" +#include "HitTestResult.h" +#include "IntRect.h" +#include "Node.h" +#include "NotificationPresenterImpl.h" +#include "Page.h" +#include "PopupMenuChromium.h" +#include "ScriptController.h" +#if USE(V8) +#include "V8Proxy.h" +#endif +#include "WebAccessibilityObject.h" +#include "WebConsoleMessage.h" +#include "WebCursorInfo.h" +#include "WebFileChooserCompletionImpl.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" +#include "WebInputEvent.h" +#include "WebKit.h" +#include "WebPopupMenuImpl.h" +#include "WebPopupMenuInfo.h" +#include "WebRect.h" +#include "WebTextDirection.h" +#include "WebURLRequest.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" +#include "WindowFeatures.h" +#include "WrappedResourceRequest.h" + +using namespace WebCore; + +namespace WebKit { + +ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView) + : m_webView(webView) + , m_toolbarsVisible(true) + , m_statusbarVisible(true) + , m_scrollbarsVisible(true) + , m_menubarVisible(true) + , m_resizable(true) + , m_ignoreNextSetCursor(false) +{ +} + +ChromeClientImpl::~ChromeClientImpl() +{ +} + +void ChromeClientImpl::chromeDestroyed() +{ + // Our lifetime is bound to the WebViewImpl. +} + +void ChromeClientImpl::setWindowRect(const FloatRect& r) +{ + if (m_webView->client()) + m_webView->client()->setWindowRect(IntRect(r)); +} + +FloatRect ChromeClientImpl::windowRect() +{ + WebRect rect; + if (m_webView->client()) + rect = m_webView->client()->rootWindowRect(); + else { + // These numbers will be fairly wrong. The window's x/y coordinates will + // be the top left corner of the screen and the size will be the content + // size instead of the window size. + rect.width = m_webView->size().width; + rect.height = m_webView->size().height; + } + return FloatRect(rect); +} + +FloatRect ChromeClientImpl::pageRect() +{ + // We hide the details of the window's border thickness from the web page by + // simple re-using the window position here. So, from the point-of-view of + // the web page, the window has no border. + return windowRect(); +} + +float ChromeClientImpl::scaleFactor() +{ + // This is supposed to return the scale factor of the web page. It looks like + // the implementor of the graphics layer is responsible for doing most of the + // operations associated with scaling. However, this value is used ins some + // cases by WebCore. For example, this is used as a scaling factor in canvas + // so that things drawn in it are scaled just like the web page is. + // + // We don't currently implement scaling, so just return 1.0 (no scaling). + return 1.0; +} + +void ChromeClientImpl::focus() +{ + if (!m_webView->client()) + return; + + m_webView->client()->didFocus(); + + // If accessibility is enabled, we should notify assistive technology that + // the active AccessibilityObject changed. + const Frame* frame = m_webView->focusedWebCoreFrame(); + if (!frame) + return; + + Document* doc = frame->document(); + + if (doc && doc->axObjectCache()->accessibilityEnabled()) { + Node* focusedNode = m_webView->focusedWebCoreNode(); + + if (!focusedNode) { + // Could not retrieve focused Node. + return; + } + + // Retrieve the focused AccessibilityObject. + AccessibilityObject* focusedAccObj = + doc->axObjectCache()->getOrCreate(focusedNode->renderer()); + + // Alert assistive technology that focus changed. + if (focusedAccObj) + m_webView->client()->focusAccessibilityObject(WebAccessibilityObject(focusedAccObj)); + } +} + +void ChromeClientImpl::unfocus() +{ + if (m_webView->client()) + m_webView->client()->didBlur(); +} + +bool ChromeClientImpl::canTakeFocus(FocusDirection) +{ + // For now the browser can always take focus if we're not running layout + // tests. + return !layoutTestMode(); +} + +void ChromeClientImpl::takeFocus(FocusDirection direction) +{ + if (!m_webView->client()) + return; + if (direction == FocusDirectionBackward) + m_webView->client()->focusPrevious(); + else + m_webView->client()->focusNext(); +} + +void ChromeClientImpl::focusedNodeChanged(Node* node) +{ + WebURL focus_url; + if (node && node->isLink()) { + // This HitTestResult hack is the easiest way to get a link URL out of a + // WebCore::Node. + HitTestResult hit_test(IntPoint(0, 0)); + // This cast must be valid because of the isLink() check. + hit_test.setURLElement(reinterpret_cast<Element*>(node)); + if (hit_test.isLiveLink()) + focus_url = hit_test.absoluteLinkURL(); + } + m_webView->client()->setKeyboardFocusURL(focus_url); +} + +Page* ChromeClientImpl::createWindow( + Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features) +{ + if (!m_webView->client()) + return 0; + + WebViewImpl* newView = static_cast<WebViewImpl*>( + m_webView->client()->createView(WebFrameImpl::fromFrame(frame))); + if (!newView) + return 0; + + // The request is empty when we are just being asked to open a blank window. + // This corresponds to window.open(""), for example. + if (!r.resourceRequest().isEmpty()) { + WrappedResourceRequest request(r.resourceRequest()); + newView->mainFrame()->loadRequest(request); + } + + return newView->page(); +} + +static inline bool currentEventShouldCauseBackgroundTab(const WebInputEvent* inputEvent) +{ + if (!inputEvent) + return false; + + if (inputEvent->type != WebInputEvent::MouseUp) + return false; + + const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent); + + WebNavigationPolicy policy; + unsigned short buttonNumber; + switch (mouseEvent->button) { + case WebMouseEvent::ButtonLeft: + buttonNumber = 0; + break; + case WebMouseEvent::ButtonMiddle: + buttonNumber = 1; + break; + case WebMouseEvent::ButtonRight: + buttonNumber = 2; + break; + default: + return false; + } + bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey; + bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey; + bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey; + bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; + + if (!WebViewImpl::navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &policy)) + return false; + + return policy == WebNavigationPolicyNewBackgroundTab; +} + +void ChromeClientImpl::show() +{ + if (!m_webView->client()) + return; + + // If our default configuration was modified by a script or wasn't + // created by a user gesture, then show as a popup. Else, let this + // new window be opened as a toplevel window. + bool asPopup = !m_toolbarsVisible + || !m_statusbarVisible + || !m_scrollbarsVisible + || !m_menubarVisible + || !m_resizable; + + WebNavigationPolicy policy = WebNavigationPolicyNewForegroundTab; + if (asPopup) + policy = WebNavigationPolicyNewPopup; + if (currentEventShouldCauseBackgroundTab(WebViewImpl::currentInputEvent())) + policy = WebNavigationPolicyNewBackgroundTab; + + m_webView->client()->show(policy); +} + +bool ChromeClientImpl::canRunModal() +{ + return !!m_webView->client(); +} + +void ChromeClientImpl::runModal() +{ + if (m_webView->client()) + m_webView->client()->runModal(); +} + +void ChromeClientImpl::setToolbarsVisible(bool value) +{ + m_toolbarsVisible = value; +} + +bool ChromeClientImpl::toolbarsVisible() +{ + return m_toolbarsVisible; +} + +void ChromeClientImpl::setStatusbarVisible(bool value) +{ + m_statusbarVisible = value; +} + +bool ChromeClientImpl::statusbarVisible() +{ + return m_statusbarVisible; +} + +void ChromeClientImpl::setScrollbarsVisible(bool value) +{ + m_scrollbarsVisible = value; + WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(m_webView->mainFrame()); + if (web_frame) + web_frame->setAllowsScrolling(value); +} + +bool ChromeClientImpl::scrollbarsVisible() +{ + return m_scrollbarsVisible; +} + +void ChromeClientImpl::setMenubarVisible(bool value) +{ + m_menubarVisible = value; +} + +bool ChromeClientImpl::menubarVisible() +{ + return m_menubarVisible; +} + +void ChromeClientImpl::setResizable(bool value) +{ + m_resizable = value; +} + +void ChromeClientImpl::addMessageToConsole(MessageSource source, + MessageType type, + MessageLevel level, + const String& message, + unsigned lineNumber, + const String& sourceID) +{ + if (m_webView->client()) { + m_webView->client()->didAddMessageToConsole( + WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message), + sourceID, + lineNumber); + } +} + +bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() +{ + return !!m_webView->client(); +} + +bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, Frame* frame) +{ + if (m_webView->client()) { + return m_webView->client()->runModalBeforeUnloadDialog( + WebFrameImpl::fromFrame(frame), message); + } + return false; +} + +void ChromeClientImpl::closeWindowSoon() +{ + // Make sure this Page can no longer be found by JS. + m_webView->page()->setGroupName(String()); + + // Make sure that all loading is stopped. Ensures that JS stops executing! + m_webView->mainFrame()->stopLoading(); + + if (m_webView->client()) + m_webView->client()->closeWidgetSoon(); +} + +// Although a Frame is passed in, we don't actually use it, since we +// already know our own m_webView. +void ChromeClientImpl::runJavaScriptAlert(Frame* frame, const String& message) +{ + if (m_webView->client()) { +#if USE(V8) + // Before showing the JavaScript dialog, we give the proxy implementation + // a chance to process any pending console messages. + V8Proxy::processConsoleMessages(); +#endif + m_webView->client()->runModalAlertDialog( + WebFrameImpl::fromFrame(frame), message); + } +} + +// See comments for runJavaScriptAlert(). +bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message) +{ + if (m_webView->client()) { + return m_webView->client()->runModalConfirmDialog( + WebFrameImpl::fromFrame(frame), message); + } + return false; +} + +// See comments for runJavaScriptAlert(). +bool ChromeClientImpl::runJavaScriptPrompt(Frame* frame, + const String& message, + const String& defaultValue, + String& result) +{ + if (m_webView->client()) { + WebString actualValue; + bool ok = m_webView->client()->runModalPromptDialog( + WebFrameImpl::fromFrame(frame), + message, + defaultValue, + &actualValue); + if (ok) + result = actualValue; + return ok; + } + return false; +} + +void ChromeClientImpl::setStatusbarText(const String& message) +{ + if (m_webView->client()) + m_webView->client()->setStatusText(message); +} + +bool ChromeClientImpl::shouldInterruptJavaScript() +{ + // FIXME: implement me + return false; +} + +bool ChromeClientImpl::tabsToLinks() const +{ + // Returns true if anchors should accept keyboard focus with the tab key. + // This method is used in a convoluted fashion by EventHandler::tabsToLinks. + // It's a twisted path (self-evident, but more complicated than seems + // necessary), but the net result is that returning true from here, on a + // platform other than MAC or QT, lets anchors get keyboard focus. + return m_webView->tabsToLinks(); +} + +IntRect ChromeClientImpl::windowResizerRect() const +{ + IntRect result; + if (m_webView->client()) + result = m_webView->client()->windowResizerRect(); + return result; +} + +void ChromeClientImpl::repaint( + const IntRect& paintRect, bool contentChanged, bool immediate, + bool repaintContentOnly) +{ + // Ignore spurious calls. + if (!contentChanged || paintRect.isEmpty()) + return; + if (m_webView->client()) + m_webView->client()->didInvalidateRect(paintRect); +} + +void ChromeClientImpl::scroll( + const IntSize& scrollDelta, const IntRect& scrollRect, + const IntRect& clipRect) +{ + if (m_webView->client()) { + int dx = scrollDelta.width(); + int dy = scrollDelta.height(); + m_webView->client()->didScrollRect(dx, dy, clipRect); + } +} + +IntPoint ChromeClientImpl::screenToWindow(const IntPoint&) const +{ + notImplemented(); + return IntPoint(); +} + +IntRect ChromeClientImpl::windowToScreen(const IntRect& rect) const +{ + IntRect screenRect(rect); + + if (m_webView->client()) { + WebRect windowRect = m_webView->client()->windowRect(); + screenRect.move(windowRect.x, windowRect.y); + } + + return screenRect; +} + +void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const +{ + WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame); + if (webframe->client()) + webframe->client()->didChangeContentsSize(webframe, size); +} + +void ChromeClientImpl::scrollbarsModeDidChange() const +{ +} + +void ChromeClientImpl::mouseDidMoveOverElement( + const HitTestResult& result, unsigned modifierFlags) +{ + if (!m_webView->client()) + return; + // Find out if the mouse is over a link, and if so, let our UI know... + if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) + m_webView->client()->setMouseOverURL(result.absoluteLinkURL()); + else + m_webView->client()->setMouseOverURL(WebURL()); +} + +void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir) +{ + if (!m_webView->client()) + return; + WebTextDirection textDirection = (dir == RTL) ? + WebTextDirectionRightToLeft : + WebTextDirectionLeftToRight; + m_webView->client()->setToolTipText( + tooltipText, textDirection); +} + +void ChromeClientImpl::print(Frame* frame) +{ + if (m_webView->client()) + m_webView->client()->printPage(WebFrameImpl::fromFrame(frame)); +} + +void ChromeClientImpl::exceededDatabaseQuota(Frame* frame, const String& databaseName) +{ + // Chromium users cannot currently change the default quota +} + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) +void ChromeClientImpl::reachedMaxAppCacheSize(int64_t spaceNeeded) +{ + ASSERT_NOT_REACHED(); +} +#endif + +void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser) +{ + WebViewClient* client = m_webView->client(); + if (!client) + return; + + bool multipleFiles = fileChooser->allowsMultipleFiles(); + + WebString suggestion; + if (fileChooser->filenames().size() > 0) + suggestion = fileChooser->filenames()[0]; + + WebFileChooserCompletionImpl* chooserCompletion = + new WebFileChooserCompletionImpl(fileChooser); + bool ok = client->runFileChooser(multipleFiles, + WebString(), + suggestion, + chooserCompletion); + if (!ok) { + // Choosing failed, so do callback with an empty list. + chooserCompletion->didChooseFile(WebVector<WebString>()); + } +} + +void ChromeClientImpl::popupOpened(PopupContainer* popupContainer, + const IntRect& bounds, + bool activatable, + bool handleExternally) +{ + if (!m_webView->client()) + return; + + WebWidget* webwidget; + if (handleExternally) { + WebPopupMenuInfo popupInfo; + getPopupMenuInfo(popupContainer, &popupInfo); + webwidget = m_webView->client()->createPopupMenu(popupInfo); + } else + webwidget = m_webView->client()->createPopupMenu(activatable); + + static_cast<WebPopupMenuImpl*>(webwidget)->Init(popupContainer, bounds); +} + +void ChromeClientImpl::setCursor(const WebCursorInfo& cursor) +{ + if (m_ignoreNextSetCursor) { + m_ignoreNextSetCursor = false; + return; + } + + if (m_webView->client()) + m_webView->client()->didChangeCursor(cursor); +} + +void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor) +{ + setCursor(cursor); + + // Currently, Widget::setCursor is always called after this function in + // EventHandler.cpp and since we don't want that we set a flag indicating + // that the next SetCursor call is to be ignored. + m_ignoreNextSetCursor = true; +} + +void ChromeClientImpl::formStateDidChange(const Node* node) +{ + // The current history item is not updated yet. That happens lazily when + // WebFrame::currentHistoryItem is requested. + WebFrameImpl* webframe = WebFrameImpl::fromFrame(node->document()->frame()); + if (webframe->client()) + webframe->client()->didUpdateCurrentHistoryItem(webframe); +} + +void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer, + WebPopupMenuInfo* info) +{ + const Vector<PopupItem*>& inputItems = popupContainer->popupData(); + + WebVector<WebPopupMenuInfo::Item> outputItems(inputItems.size()); + + for (size_t i = 0; i < inputItems.size(); ++i) { + const PopupItem& inputItem = *inputItems[i]; + WebPopupMenuInfo::Item& outputItem = outputItems[i]; + + outputItem.label = inputItem.label; + outputItem.enabled = inputItem.enabled; + + switch (inputItem.type) { + case PopupItem::TypeOption: + outputItem.type = WebPopupMenuInfo::Item::Option; + break; + case PopupItem::TypeGroup: + outputItem.type = WebPopupMenuInfo::Item::Group; + break; + case PopupItem::TypeSeparator: + outputItem.type = WebPopupMenuInfo::Item::Separator; + break; + default: + ASSERT_NOT_REACHED(); + } + } + + info->itemHeight = popupContainer->menuItemHeight(); + info->selectedIndex = popupContainer->selectedIndex(); + info->items.swap(outputItems); +} + +#if ENABLE(NOTIFICATIONS) +NotificationPresenter* ChromeClientImpl::notificationPresenter() const +{ + return m_webView->notificationPresenterImpl(); +} +#endif + +} // namespace WebKit diff --git a/WebKit/chromium/src/ChromeClientImpl.h b/WebKit/chromium/src/ChromeClientImpl.h new file mode 100644 index 0000000..5a1e9cc --- /dev/null +++ b/WebKit/chromium/src/ChromeClientImpl.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 ChromeClientImpl_h +#define ChromeClientImpl_h + +#include "ChromeClientChromium.h" + +namespace WebCore { +class HTMLParserQuirks; +class PopupContainer; +class SecurityOrigin; +struct WindowFeatures; +} + +namespace WebKit { +class WebViewImpl; +struct WebCursorInfo; +struct WebPopupMenuInfo; + +// Handles window-level notifications from WebCore on behalf of a WebView. +class ChromeClientImpl : public WebCore::ChromeClientChromium { +public: + explicit ChromeClientImpl(WebViewImpl* webView); + virtual ~ChromeClientImpl(); + + WebViewImpl* webView() const { return m_webView; } + + // ChromeClient methods: + virtual void chromeDestroyed(); + virtual void setWindowRect(const WebCore::FloatRect&); + virtual WebCore::FloatRect windowRect(); + virtual WebCore::FloatRect pageRect(); + virtual float scaleFactor(); + virtual void focus(); + virtual void unfocus(); + virtual bool canTakeFocus(WebCore::FocusDirection); + virtual void takeFocus(WebCore::FocusDirection); + virtual void focusedNodeChanged(WebCore::Node*); + virtual WebCore::Page* createWindow( + WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&); + virtual void show(); + virtual bool canRunModal(); + virtual void runModal(); + virtual void setToolbarsVisible(bool); + virtual bool toolbarsVisible(); + virtual void setStatusbarVisible(bool); + virtual bool statusbarVisible(); + virtual void setScrollbarsVisible(bool); + virtual bool scrollbarsVisible(); + virtual void setMenubarVisible(bool); + virtual bool menubarVisible(); + virtual void setResizable(bool); + virtual void addMessageToConsole( + WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel, + const WebCore::String& message, unsigned lineNumber, + const WebCore::String& sourceID); + virtual bool canRunBeforeUnloadConfirmPanel(); + virtual bool runBeforeUnloadConfirmPanel( + const WebCore::String& message, WebCore::Frame*); + virtual void closeWindowSoon(); + virtual void runJavaScriptAlert(WebCore::Frame*, const WebCore::String&); + virtual bool runJavaScriptConfirm(WebCore::Frame*, const WebCore::String&); + virtual bool runJavaScriptPrompt( + WebCore::Frame*, const WebCore::String& message, + const WebCore::String& defaultValue, WebCore::String& result); + virtual void setStatusbarText(const WebCore::String& message); + virtual bool shouldInterruptJavaScript(); + virtual bool tabsToLinks() const; + virtual WebCore::IntRect windowResizerRect() const; + virtual void repaint( + const WebCore::IntRect&, bool contentChanged, bool immediate = false, + bool repaintContentOnly = false); + virtual void scroll( + const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, + const WebCore::IntRect& clipRect); + virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; + virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; + virtual PlatformPageClient platformPageClient() const { return 0; } + virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; + virtual void scrollRectIntoView( + const WebCore::IntRect&, const WebCore::ScrollView*) const { } + virtual void scrollbarsModeDidChange() const; + virtual void mouseDidMoveOverElement( + const WebCore::HitTestResult& result, unsigned modifierFlags); + virtual void setToolTip(const WebCore::String& tooltipText, WebCore::TextDirection); + virtual void print(WebCore::Frame*); + virtual void exceededDatabaseQuota( + WebCore::Frame*, const WebCore::String& databaseName); +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); +#endif +#if ENABLE(NOTIFICATIONS) + virtual WebCore::NotificationPresenter* notificationPresenter() const; +#endif + virtual void requestGeolocationPermissionForFrame( + WebCore::Frame*, WebCore::Geolocation*) { } + virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); + virtual bool setCursor(WebCore::PlatformCursorHandle) { return false; } + virtual void formStateDidChange(const WebCore::Node*); + virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; } + + // ChromeClientChromium methods: + virtual void popupOpened(WebCore::PopupContainer* popupContainer, + const WebCore::IntRect& bounds, + bool activatable, + bool handleExternally); + + // ChromeClientImpl: + void setCursor(const WebCursorInfo& cursor); + void setCursorForPlugin(const WebCursorInfo& cursor); + +private: + void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*); + + WebViewImpl* m_webView; // weak pointer + bool m_toolbarsVisible; + bool m_statusbarVisible; + bool m_scrollbarsVisible; + bool m_menubarVisible; + bool m_resizable; + // Set to true if the next SetCursor is to be ignored. + bool m_ignoreNextSetCursor; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/ChromiumBridge.cpp b/WebKit/chromium/src/ChromiumBridge.cpp new file mode 100644 index 0000000..93d92ba --- /dev/null +++ b/WebKit/chromium/src/ChromiumBridge.cpp @@ -0,0 +1,689 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "ChromiumBridge.h" + +#include <googleurl/src/url_util.h> + +#include "ChromeClientImpl.h" +#include "WebClipboard.h" +#include "WebCookie.h" +#include "WebCursorInfo.h" +#include "WebData.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" +#include "WebImage.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebMimeRegistry.h" +#include "WebPluginContainerImpl.h" +#include "WebPluginListBuilderImpl.h" +#include "WebScreenInfo.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebVector.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" +#include "WebWorkerClientImpl.h" + +#if PLATFORM(WIN_OS) +#include "WebRect.h" +#include "WebSandboxSupport.h" +#include "WebThemeEngine.h" +#endif + +#if PLATFORM(LINUX) +#include "WebSandboxSupport.h" +#include "WebFontInfo.h" +#endif + +#if WEBKIT_USING_SKIA +#include "NativeImageSkia.h" +#endif + +#include "BitmapImage.h" +#include "Cookie.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "KURL.h" +#include "NotImplemented.h" +#include "PlatformContextSkia.h" +#include "PluginData.h" +#include "Worker.h" +#include "WorkerContextProxy.h" +#include <wtf/Assertions.h> + +// We are part of the WebKit implementation. +using namespace WebKit; + +namespace WebCore { + +static ChromeClientImpl* toChromeClientImpl(Widget* widget) +{ + FrameView* view; + if (widget->isFrameView()) + view = static_cast<FrameView*>(widget); + else if (widget->parent() && widget->parent()->isFrameView()) + view = static_cast<FrameView*>(widget->parent()); + else + return 0; + + Page* page = view->frame() ? view->frame()->page() : 0; + if (!page) + return 0; + + return static_cast<ChromeClientImpl*>(page->chrome()->client()); +} + +static WebWidgetClient* toWebWidgetClient(Widget* widget) +{ + ChromeClientImpl* chromeClientImpl = toChromeClientImpl(widget); + if (!chromeClientImpl || !chromeClientImpl->webView()) + return 0; + return chromeClientImpl->webView()->client(); +} + +// Clipboard ------------------------------------------------------------------ + +bool ChromiumBridge::clipboardIsFormatAvailable( + PasteboardPrivate::ClipboardFormat format, + PasteboardPrivate::ClipboardBuffer buffer) +{ + return webKitClient()->clipboard()->isFormatAvailable( + static_cast<WebClipboard::Format>(format), + static_cast<WebClipboard::Buffer>(buffer)); +} + +String ChromiumBridge::clipboardReadPlainText( + PasteboardPrivate::ClipboardBuffer buffer) +{ + return webKitClient()->clipboard()->readPlainText( + static_cast<WebClipboard::Buffer>(buffer)); +} + +void ChromiumBridge::clipboardReadHTML( + PasteboardPrivate::ClipboardBuffer buffer, + String* htmlText, KURL* sourceURL) +{ + WebURL url; + *htmlText = webKitClient()->clipboard()->readHTML( + static_cast<WebClipboard::Buffer>(buffer), &url); + *sourceURL = url; +} + +void ChromiumBridge::clipboardWriteSelection(const String& htmlText, + const KURL& sourceURL, + const String& plainText, + bool writeSmartPaste) +{ + webKitClient()->clipboard()->writeHTML( + htmlText, sourceURL, plainText, writeSmartPaste); +} + +void ChromiumBridge::clipboardWritePlainText(const String& plainText) +{ + webKitClient()->clipboard()->writePlainText(plainText); +} + +void ChromiumBridge::clipboardWriteURL(const KURL& url, const String& title) +{ + webKitClient()->clipboard()->writeURL(url, title); +} + +void ChromiumBridge::clipboardWriteImage(NativeImagePtr image, + const KURL& sourceURL, + const String& title) +{ +#if WEBKIT_USING_SKIA + WebImage webImage(*image); +#else + WebImage webImage(image); +#endif + webKitClient()->clipboard()->writeImage(webImage, sourceURL, title); +} + +// Cookies -------------------------------------------------------------------- + +void ChromiumBridge::setCookies(const KURL& url, + const KURL& firstPartyForCookies, + const String& cookie) +{ + webKitClient()->setCookies(url, firstPartyForCookies, cookie); +} + +String ChromiumBridge::cookies(const KURL& url, + const KURL& firstPartyForCookies) +{ + return webKitClient()->cookies(url, firstPartyForCookies); +} + +bool ChromiumBridge::rawCookies(const KURL& url, const KURL& firstPartyForCookies, Vector<Cookie>* rawCookies) +{ + rawCookies->clear(); + WebVector<WebCookie> webCookies; + if (!webKitClient()->rawCookies(url, firstPartyForCookies, &webCookies)) + return false; + + for (unsigned i = 0; i < webCookies.size(); ++i) { + const WebCookie& webCookie = webCookies[i]; + Cookie cookie(webCookie.name, + webCookie.value, + webCookie.domain, + webCookie.path, + webCookie.expires, + webCookie.httpOnly, + webCookie.secure, + webCookie.session); + rawCookies->append(cookie); + } + return true; +} + +void ChromiumBridge::deleteCookie(const KURL& url, const String& cookieName) +{ + webKitClient()->deleteCookie(url, cookieName); +} + +// DNS ------------------------------------------------------------------------ + +void ChromiumBridge::prefetchDNS(const String& hostname) +{ + webKitClient()->prefetchHostName(hostname); +} + +// File ------------------------------------------------------------------------ + +bool ChromiumBridge::fileExists(const String& path) +{ + return webKitClient()->fileExists(path); +} + +bool ChromiumBridge::deleteFile(const String& path) +{ + return webKitClient()->deleteFile(path); +} + +bool ChromiumBridge::deleteEmptyDirectory(const String& path) +{ + return webKitClient()->deleteEmptyDirectory(path); +} + +bool ChromiumBridge::getFileSize(const String& path, long long& result) +{ + return webKitClient()->getFileSize(path, result); +} + +bool ChromiumBridge::getFileModificationTime(const String& path, time_t& result) +{ + return webKitClient()->getFileModificationTime(path, result); +} + +String ChromiumBridge::directoryName(const String& path) +{ + return webKitClient()->directoryName(path); +} + +String ChromiumBridge::pathByAppendingComponent(const String& path, const String& component) +{ + return webKitClient()->pathByAppendingComponent(path, component); +} + +bool ChromiumBridge::makeAllDirectories(const String& path) +{ + return webKitClient()->makeAllDirectories(path); +} + +String ChromiumBridge::getAbsolutePath(const String& path) +{ + return webKitClient()->getAbsolutePath(path); +} + +bool ChromiumBridge::isDirectory(const String& path) +{ + return webKitClient()->isDirectory(path); +} + +KURL ChromiumBridge::filePathToURL(const String& path) +{ + return webKitClient()->filePathToURL(path); +} + +// Font ----------------------------------------------------------------------- + +#if PLATFORM(WIN_OS) +bool ChromiumBridge::ensureFontLoaded(HFONT font) +{ + WebSandboxSupport* ss = webKitClient()->sandboxSupport(); + + // if there is no sandbox, then we can assume the font + // was able to be loaded successfully already + return ss ? ss->ensureFontLoaded(font) : true; +} +#endif + +#if PLATFORM(LINUX) +String ChromiumBridge::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters) +{ + if (webKitClient()->sandboxSupport()) + return webKitClient()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters); + + WebCString family = WebFontInfo::familyForChars(characters, numCharacters); + if (family.data()) + return WebString::fromUTF8(family.data()); + + return WebString(); +} +#endif + +// HTML5 DB ------------------------------------------------------------------- + +#if ENABLE(DATABASE) +PlatformFileHandle ChromiumBridge::databaseOpenFile(const String& vfsFileName, int desiredFlags, PlatformFileHandle* dirHandle) +{ + return webKitClient()->databaseOpenFile(WebString(vfsFileName), desiredFlags, dirHandle); +} + +int ChromiumBridge::databaseDeleteFile(const String& vfsFileName, bool syncDir) +{ + return webKitClient()->databaseDeleteFile(WebString(vfsFileName), syncDir); +} + +long ChromiumBridge::databaseGetFileAttributes(const String& vfsFileName) +{ + return webKitClient()->databaseGetFileAttributes(WebString(vfsFileName)); +} + +long long ChromiumBridge::databaseGetFileSize(const String& vfsFileName) +{ + return webKitClient()->databaseGetFileSize(WebString(vfsFileName)); +} +#endif + +// Keygen --------------------------------------------------------------------- + +String ChromiumBridge::signedPublicKeyAndChallengeString( + unsigned keySizeIndex, const String& challenge, const KURL& url) +{ + return webKitClient()->signedPublicKeyAndChallengeString(keySizeIndex, + WebString(challenge), + WebURL(url)); +} + +// Language ------------------------------------------------------------------- + +String ChromiumBridge::computedDefaultLanguage() +{ + return webKitClient()->defaultLocale(); +} + +// LayoutTestMode ------------------------------------------------------------- + +bool ChromiumBridge::layoutTestMode() +{ + return WebKit::layoutTestMode(); +} + +// MimeType ------------------------------------------------------------------- + +bool ChromiumBridge::isSupportedImageMIMEType(const String& mimeType) +{ + return webKitClient()->mimeRegistry()->supportsImageMIMEType(mimeType) + != WebMimeRegistry::IsNotSupported; +} + +bool ChromiumBridge::isSupportedJavaScriptMIMEType(const String& mimeType) +{ + return webKitClient()->mimeRegistry()->supportsJavaScriptMIMEType(mimeType) + != WebMimeRegistry::IsNotSupported; +} + +bool ChromiumBridge::isSupportedNonImageMIMEType(const String& mimeType) +{ + return webKitClient()->mimeRegistry()->supportsNonImageMIMEType(mimeType) + != WebMimeRegistry::IsNotSupported; +} + +String ChromiumBridge::mimeTypeForExtension(const String& extension) +{ + return webKitClient()->mimeRegistry()->mimeTypeForExtension(extension); +} + +String ChromiumBridge::mimeTypeFromFile(const String& path) +{ + return webKitClient()->mimeRegistry()->mimeTypeFromFile(path); +} + +String ChromiumBridge::preferredExtensionForMIMEType(const String& mimeType) +{ + return webKitClient()->mimeRegistry()->preferredExtensionForMIMEType(mimeType); +} + +// Plugin --------------------------------------------------------------------- + +bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results) +{ + WebPluginListBuilderImpl builder(results); + webKitClient()->getPluginList(refresh, &builder); + return true; // FIXME: There is no need for this function to return a value. +} + +NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget) +{ + if (!widget) + return 0; + + ASSERT(!widget->isFrameView()); + + // NOTE: We have to trust that the widget passed to us here is a + // WebPluginContainerImpl. There isn't a way to dynamically verify it, + // since the derived class (Widget) has no identifier. + return static_cast<WebPluginContainerImpl*>(widget)->scriptableObject(); +} + +// Resources ------------------------------------------------------------------ + +PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) +{ + const WebData& resource = webKitClient()->loadResource(name); + if (resource.isEmpty()) + return Image::nullImage(); + + RefPtr<Image> image = BitmapImage::create(); + image->setData(resource, true); + return image; +} + +// Sandbox -------------------------------------------------------------------- + +bool ChromiumBridge::sandboxEnabled() +{ + return webKitClient()->sandboxEnabled(); +} + +// SharedTimers --------------------------------------------------------------- + +void ChromiumBridge::setSharedTimerFiredFunction(void (*func)()) +{ + webKitClient()->setSharedTimerFiredFunction(func); +} + +void ChromiumBridge::setSharedTimerFireTime(double fireTime) +{ + webKitClient()->setSharedTimerFireTime(fireTime); +} + +void ChromiumBridge::stopSharedTimer() +{ + webKitClient()->stopSharedTimer(); +} + +// StatsCounters -------------------------------------------------------------- + +void ChromiumBridge::decrementStatsCounter(const char* name) +{ + webKitClient()->decrementStatsCounter(name); +} + +void ChromiumBridge::incrementStatsCounter(const char* name) +{ + webKitClient()->incrementStatsCounter(name); +} + +// Sudden Termination --------------------------------------------------------- + +void ChromiumBridge::suddenTerminationChanged(bool enabled) +{ + webKitClient()->suddenTerminationChanged(enabled); +} + +// SystemTime ----------------------------------------------------------------- + +double ChromiumBridge::currentTime() +{ + return webKitClient()->currentTime(); +} + +// Theming -------------------------------------------------------------------- + +#if PLATFORM(WIN_OS) + +void ChromiumBridge::paintButton( + GraphicsContext* gc, int part, int state, int classicState, + const IntRect& rect) +{ + webKitClient()->themeEngine()->paintButton( + gc->platformContext()->canvas(), part, state, classicState, rect); +} + +void ChromiumBridge::paintMenuList( + GraphicsContext* gc, int part, int state, int classicState, + const IntRect& rect) +{ + webKitClient()->themeEngine()->paintMenuList( + gc->platformContext()->canvas(), part, state, classicState, rect); +} + +void ChromiumBridge::paintScrollbarArrow( + GraphicsContext* gc, int state, int classicState, + const IntRect& rect) +{ + webKitClient()->themeEngine()->paintScrollbarArrow( + gc->platformContext()->canvas(), state, classicState, rect); +} + +void ChromiumBridge::paintScrollbarThumb( + GraphicsContext* gc, int part, int state, int classicState, + const IntRect& rect) +{ + webKitClient()->themeEngine()->paintScrollbarThumb( + gc->platformContext()->canvas(), part, state, classicState, rect); +} + +void ChromiumBridge::paintScrollbarTrack( + GraphicsContext* gc, int part, int state, int classicState, + const IntRect& rect, const IntRect& alignRect) +{ + webKitClient()->themeEngine()->paintScrollbarTrack( + gc->platformContext()->canvas(), part, state, classicState, rect, + alignRect); +} + +void ChromiumBridge::paintTextField( + GraphicsContext* gc, int part, int state, int classicState, + const IntRect& rect, const Color& color, bool fillContentArea, + bool drawEdges) +{ + // Fallback to white when |color| is invalid. + RGBA32 backgroundColor = color.isValid() ? color.rgb() : Color::white; + + webKitClient()->themeEngine()->paintTextField( + gc->platformContext()->canvas(), part, state, classicState, rect, + backgroundColor, fillContentArea, drawEdges); +} + +void ChromiumBridge::paintTrackbar( + GraphicsContext* gc, int part, int state, int classicState, + const IntRect& rect) +{ + webKitClient()->themeEngine()->paintTrackbar( + gc->platformContext()->canvas(), part, state, classicState, rect); +} + +#endif + +// Trace Event ---------------------------------------------------------------- + +void ChromiumBridge::traceEventBegin(const char* name, void* id, const char* extra) +{ + webKitClient()->traceEventBegin(name, id, extra); +} + +void ChromiumBridge::traceEventEnd(const char* name, void* id, const char* extra) +{ + webKitClient()->traceEventEnd(name, id, extra); +} + +// Visited Links -------------------------------------------------------------- + +LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, unsigned length) +{ + url_canon::RawCanonOutput<2048> buffer; + url_parse::Parsed parsed; + if (!url_util::Canonicalize(url, length, 0, &buffer, &parsed)) + return 0; // Invalid URLs are unvisited. + return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); +} + +LinkHash ChromiumBridge::visitedLinkHash(const KURL& base, + const AtomicString& attributeURL) +{ + // Resolve the relative URL using googleurl and pass the absolute URL up to + // the embedder. We could create a GURL object from the base and resolve + // the relative URL that way, but calling the lower-level functions + // directly saves us the string allocation in most cases. + url_canon::RawCanonOutput<2048> buffer; + url_parse::Parsed parsed; + +#if USE(GOOGLEURL) + const CString& cstr = base.utf8String(); + const char* data = cstr.data(); + int length = cstr.length(); + const url_parse::Parsed& srcParsed = base.parsed(); +#else + // When we're not using GoogleURL, first canonicalize it so we can resolve it + // below. + url_canon::RawCanonOutput<2048> srcCanon; + url_parse::Parsed srcParsed; + String str = base.string(); + if (!url_util::Canonicalize(str.characters(), str.length(), 0, &srcCanon, &srcParsed)) + return 0; + const char* data = srcCanon.data(); + int length = srcCanon.length(); +#endif + + if (!url_util::ResolveRelative(data, length, srcParsed, attributeURL.characters(), + attributeURL.length(), 0, &buffer, &parsed)) + return 0; // Invalid resolved URL. + + return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); +} + +bool ChromiumBridge::isLinkVisited(LinkHash visitedLinkHash) +{ + return webKitClient()->isLinkVisited(visitedLinkHash); +} + +// These are temporary methods that the WebKit layer can use to call to the +// Glue layer. Once the Glue layer moves entirely into the WebKit layer, these +// methods will be deleted. + +void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) +{ + if (!frame) + return; + + WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); + if (!webFrame->client()) + return; + webFrame->client()->didExhaustMemoryAvailableForScript(webFrame); +} + +int ChromiumBridge::memoryUsageMB() +{ + return static_cast<int>(webKitClient()->memoryUsageMB()); +} + +int ChromiumBridge::screenDepth(Widget* widget) +{ + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().depth; +} + +int ChromiumBridge::screenDepthPerComponent(Widget* widget) +{ + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().depthPerComponent; +} + +bool ChromiumBridge::screenIsMonochrome(Widget* widget) +{ + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().isMonochrome; +} + +IntRect ChromiumBridge::screenRect(Widget* widget) +{ + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return IntRect(); + return client->screenInfo().rect; +} + +IntRect ChromiumBridge::screenAvailableRect(Widget* widget) +{ + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return IntRect(); + return client->screenInfo().availableRect; +} + +bool ChromiumBridge::popupsAllowed(NPP npp) +{ + // FIXME: Give the embedder a way to control this. + return false; +} + +void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) +{ + ChromeClientImpl* client = toChromeClientImpl(widget); + if (client) + client->setCursor(WebCursorInfo(cursor)); +} + +void ChromiumBridge::widgetSetFocus(Widget* widget) +{ + ChromeClientImpl* client = toChromeClientImpl(widget); + if (client) + client->focus(); +} + +WorkerContextProxy* WorkerContextProxy::create(Worker* worker) +{ + return WebWorkerClientImpl::createWorkerContextProxy(worker); +} + +} // namespace WebCore diff --git a/WebKit/chromium/src/ChromiumCurrentTime.cpp b/WebKit/chromium/src/ChromiumCurrentTime.cpp new file mode 100644 index 0000000..1eccc41 --- /dev/null +++ b/WebKit/chromium/src/ChromiumCurrentTime.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 <wtf/CurrentTime.h> + +#include "WebKit.h" +#include "WebKitClient.h" + +namespace WTF { + +double currentTime() +{ + return WebKit::webKitClient()->currentTime(); +} + +} // namespace WTF diff --git a/WebKit/chromium/src/ChromiumThreading.cpp b/WebKit/chromium/src/ChromiumThreading.cpp new file mode 100644 index 0000000..902a433 --- /dev/null +++ b/WebKit/chromium/src/ChromiumThreading.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 <wtf/chromium/ChromiumThreading.h> + +#include "WebKit.h" +#include "WebKitClient.h" + +#include <wtf/MainThread.h> + +namespace WTF { + +void ChromiumThreading::initializeMainThread() +{ +} + +void ChromiumThreading::scheduleDispatchFunctionsOnMainThread() +{ + WebKit::webKitClient()->callOnMainThread(&WTF::dispatchFunctionsFromMainThread); +} + +} // namespace WTF diff --git a/WebKit/chromium/src/ContextMenuClientImpl.cpp b/WebKit/chromium/src/ContextMenuClientImpl.cpp new file mode 100644 index 0000000..f23919e --- /dev/null +++ b/WebKit/chromium/src/ContextMenuClientImpl.cpp @@ -0,0 +1,279 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "ContextMenuClientImpl.h" + +#include "ContextMenu.h" +#include "Document.h" +#include "DocumentLoader.h" +#include "Editor.h" +#include "EventHandler.h" +#include "FrameLoader.h" +#include "FrameView.h" +#include "HitTestResult.h" +#include "HTMLMediaElement.h" +#include "HTMLNames.h" +#include "KURL.h" +#include "MediaError.h" +#include "PlatformString.h" +#include "TextBreakIterator.h" +#include "Widget.h" + +#include "WebContextMenuData.h" +#include "WebDataSourceImpl.h" +#include "WebFrameImpl.h" +#include "WebMenuItemInfo.h" +#include "WebPoint.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebURLResponse.h" +#include "WebVector.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" + +using namespace WebCore; + +namespace WebKit { + +// Figure out the URL of a page or subframe. Returns |page_type| as the type, +// which indicates page or subframe, or ContextNodeType::NONE if the URL could not +// be determined for some reason. +static WebURL urlFromFrame(Frame* frame) +{ + if (frame) { + DocumentLoader* dl = frame->loader()->documentLoader(); + if (dl) { + WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); + if (ds) + return ds->hasUnreachableURL() ? ds->unreachableURL() : ds->request().url(); + } + } + return WebURL(); +} + +// Helper function to determine whether text is a single word or a sentence. +static bool isASingleWord(const String& text) +{ + TextBreakIterator* it = characterBreakIterator(text.characters(), text.length()); + return it && textBreakNext(it) == TextBreakDone; +} + +// Helper function to get misspelled word on which context menu +// is to be evolked. This function also sets the word on which context menu +// has been evoked to be the selected word, as required. This function changes +// the selection only when there were no selected characters. +static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame) +{ + // First select from selectedText to check for multiple word selection. + String misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); + + // If some texts were already selected, we don't change the selection. + if (!misspelledWord.isEmpty()) { + // Don't provide suggestions for multiple words. + if (!isASingleWord(misspelledWord)) + return String(); + return misspelledWord; + } + + // Selection is empty, so change the selection to the word under the cursor. + HitTestResult hitTestResult = selectedFrame->eventHandler()-> + hitTestResultAtPoint(defaultMenu->hitTestResult().point(), true); + Node* innerNode = hitTestResult.innerNode(); + VisiblePosition pos(innerNode->renderer()->positionForPoint( + hitTestResult.localPoint())); + + VisibleSelection selection; + if (pos.isNotNull()) { + selection = VisibleSelection(pos); + selection.expandUsingGranularity(WordGranularity); + } + + if (selection.isRange()) + selectedFrame->setSelectionGranularity(WordGranularity); + + if (selectedFrame->shouldChangeSelection(selection)) + selectedFrame->selection()->setSelection(selection); + + misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); + + // If misspelled word is still empty, then that portion should not be + // selected. Set the selection to that position only, and do not expand. + if (misspelledWord.isEmpty()) { + selection = VisibleSelection(pos); + selectedFrame->selection()->setSelection(selection); + } + + return misspelledWord; +} + +PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( + ContextMenu* defaultMenu) +{ + // Displaying the context menu in this function is a big hack as we don't + // have context, i.e. whether this is being invoked via a script or in + // response to user input (Mouse event WM_RBUTTONDOWN, + // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked + // in response to the above input events before popping up the context menu. + if (!m_webView->contextMenuAllowed()) + return 0; + + HitTestResult r = defaultMenu->hitTestResult(); + Frame* selectedFrame = r.innerNonSharedNode()->document()->frame(); + + WebContextMenuData data; + data.mousePosition = selectedFrame->view()->contentsToWindow(r.point()); + + // Links, Images, Media tags, and Image/Media-Links take preference over + // all else. + data.linkURL = r.absoluteLinkURL(); + + data.mediaType = WebContextMenuData::MediaTypeNone; + data.mediaFlags = WebContextMenuData::MediaNone; + + if (!r.absoluteImageURL().isEmpty()) { + data.srcURL = r.absoluteImageURL(); + data.mediaType = WebContextMenuData::MediaTypeImage; + } else if (!r.absoluteMediaURL().isEmpty()) { + data.srcURL = r.absoluteMediaURL(); + + // We know that if absoluteMediaURL() is not empty, then this + // is a media element. + HTMLMediaElement* mediaElement = + static_cast<HTMLMediaElement*>(r.innerNonSharedNode()); + if (mediaElement->hasTagName(HTMLNames::videoTag)) + data.mediaType = WebContextMenuData::MediaTypeVideo; + else if (mediaElement->hasTagName(HTMLNames::audioTag)) + data.mediaType = WebContextMenuData::MediaTypeAudio; + + if (mediaElement->error()) + data.mediaFlags |= WebContextMenuData::MediaInError; + if (mediaElement->paused()) + data.mediaFlags |= WebContextMenuData::MediaPaused; + if (mediaElement->muted()) + data.mediaFlags |= WebContextMenuData::MediaMuted; + if (mediaElement->loop()) + data.mediaFlags |= WebContextMenuData::MediaLoop; + if (mediaElement->supportsSave()) + data.mediaFlags |= WebContextMenuData::MediaCanSave; + if (mediaElement->hasAudio()) + data.mediaFlags |= WebContextMenuData::MediaHasAudio; + } + // If it's not a link, an image, a media element, or an image/media link, + // show a selection menu or a more generic page menu. + data.frameEncoding = selectedFrame->loader()->encoding(); + + // Send the frame and page URLs in any case. + data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame()); + if (selectedFrame != m_webView->mainFrameImpl()->frame()) + data.frameURL = urlFromFrame(selectedFrame); + + if (r.isSelected()) + data.selectedText = selectedFrame->selectedText().stripWhiteSpace(); + + data.isEditable = false; + if (r.isContentEditable()) { + data.isEditable = true; + if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) { + data.isSpellCheckingEnabled = true; + data.misspelledWord = selectMisspelledWord(defaultMenu, selectedFrame); + } + } + + // Now retrieve the security info. + DocumentLoader* dl = selectedFrame->loader()->documentLoader(); + WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); + if (ds) + data.securityInfo = ds->response().securityInfo(); + + // Compute edit flags. + data.editFlags = WebContextMenuData::CanDoNone; + if (m_webView->focusedWebCoreFrame()->editor()->canUndo()) + data.editFlags |= WebContextMenuData::CanUndo; + if (m_webView->focusedWebCoreFrame()->editor()->canRedo()) + data.editFlags |= WebContextMenuData::CanRedo; + if (m_webView->focusedWebCoreFrame()->editor()->canCut()) + data.editFlags |= WebContextMenuData::CanCut; + if (m_webView->focusedWebCoreFrame()->editor()->canCopy()) + data.editFlags |= WebContextMenuData::CanCopy; + if (m_webView->focusedWebCoreFrame()->editor()->canPaste()) + data.editFlags |= WebContextMenuData::CanPaste; + if (m_webView->focusedWebCoreFrame()->editor()->canDelete()) + data.editFlags |= WebContextMenuData::CanDelete; + // We can always select all... + data.editFlags |= WebContextMenuData::CanSelectAll; + + // Filter out custom menu elements and add them into the data. + populateCustomMenuItems(defaultMenu, &data); + + WebFrame* selected_web_frame = WebFrameImpl::fromFrame(selectedFrame); + if (m_webView->client()) + m_webView->client()->showContextMenu(selected_web_frame, data); + + return 0; +} + +void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) +{ + Vector<WebMenuItemInfo> customItems; + for (size_t i = 0; i < defaultMenu->itemCount(); ++i) { + ContextMenuItem* inputItem = defaultMenu->itemAtIndex(i, defaultMenu->platformDescription()); + if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() >= ContextMenuItemBaseApplicationTag) + continue; + + WebMenuItemInfo outputItem; + outputItem.label = inputItem->title(); + outputItem.enabled = inputItem->enabled(); + outputItem.checked = inputItem->checked(); + outputItem.action = static_cast<unsigned>(inputItem->action() - ContextMenuItemBaseCustomTag); + switch (inputItem->type()) { + case ActionType: + outputItem.type = WebMenuItemInfo::Option; + break; + case CheckableActionType: + outputItem.type = WebMenuItemInfo::CheckableOption; + break; + case SeparatorType: + outputItem.type = WebMenuItemInfo::Separator; + break; + case SubmenuType: + outputItem.type = WebMenuItemInfo::Group; + break; + } + customItems.append(outputItem); + } + + WebVector<WebMenuItemInfo> outputItems(customItems.size()); + for (size_t i = 0; i < customItems.size(); ++i) + outputItems[i] = customItems[i]; + data->customItems.swap(outputItems); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/ContextMenuClientImpl.h b/WebKit/chromium/src/ContextMenuClientImpl.h new file mode 100644 index 0000000..4191fad --- /dev/null +++ b/WebKit/chromium/src/ContextMenuClientImpl.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 ContextMenuClientImpl_h +#define ContextMenuClientImpl_h + +#include "ContextMenuClient.h" + +namespace WebKit { + +class WebViewImpl; +struct WebContextMenuData; + +class ContextMenuClientImpl : public WebCore::ContextMenuClient { +public: + ContextMenuClientImpl(WebViewImpl* webView) : m_webView(webView) {} + virtual ~ContextMenuClientImpl() {} + virtual void copyImageToClipboard(const WebCore::HitTestResult&) {} + virtual void contextMenuDestroyed() {} + virtual void contextMenuItemSelected(WebCore::ContextMenuItem*, const WebCore::ContextMenu*) {} + virtual void downloadURL(const WebCore::KURL&) {} + virtual WebCore::PlatformMenuDescription getCustomMenuFromDefaultItems(WebCore::ContextMenu*); + virtual bool isSpeaking() { return false; } + virtual void lookUpInDictionary(WebCore::Frame*) {} + virtual void searchWithGoogle(const WebCore::Frame*) {} + virtual bool shouldIncludeInspectElementItem() { return false; } + virtual void speak(const WebCore::String&) {} + virtual void stopSpeaking() {} +private: + void populateCustomMenuItems(WebCore::ContextMenu*, WebContextMenuData*); + WebViewImpl* m_webView; +}; + +} // namespace WebKit + +#endif // ContextMenuClientImpl_h diff --git a/WebKit/chromium/src/DOMUtilitiesPrivate.cpp b/WebKit/chromium/src/DOMUtilitiesPrivate.cpp new file mode 100644 index 0000000..ffdd85d --- /dev/null +++ b/WebKit/chromium/src/DOMUtilitiesPrivate.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "DOMUtilitiesPrivate.h" + +#include "Element.h" +#include "HTMLInputElement.h" +#include "HTMLLinkElement.h" +#include "HTMLMetaElement.h" +#include "HTMLNames.h" +#include "HTMLOptionElement.h" +#include "Node.h" + +#include "WebInputElement.h" + +using namespace WebCore; + +namespace { + +template <class HTMLNodeType> +HTMLNodeType* toHTMLElement(Node* node, const QualifiedName& name) +{ + if (node->isHTMLElement() + && static_cast<HTMLElement*>(node)->hasTagName(name)) { + return static_cast<HTMLNodeType*>(node); + } + return 0; +} + +} // namespace + +namespace WebKit { + +HTMLInputElement* toHTMLInputElement(Node* node) +{ + return toHTMLElement<HTMLInputElement>(node, HTMLNames::inputTag); +} + +HTMLLinkElement* toHTMLLinkElement(Node* node) +{ + return toHTMLElement<HTMLLinkElement>(node, HTMLNames::linkTag); +} + +HTMLMetaElement* toHTMLMetaElement(Node* node) +{ + return toHTMLElement<HTMLMetaElement>(node, HTMLNames::metaTag); +} + +HTMLOptionElement* toHTMLOptionElement(Node* node) +{ + return toHTMLElement<HTMLOptionElement>(node, HTMLNames::optionTag); +} + +String nameOfInputElement(HTMLInputElement* element) +{ + return WebInputElement(element).nameForAutofill(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/DOMUtilitiesPrivate.h b/WebKit/chromium/src/DOMUtilitiesPrivate.h new file mode 100644 index 0000000..c02bf84 --- /dev/null +++ b/WebKit/chromium/src/DOMUtilitiesPrivate.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 DOMUtilitiesPrivate_h +#define DOMUtilitiesPrivate_h + +namespace WebCore { +class HTMLInputElement; +class HTMLLinkElement; +class HTMLMetaElement; +class HTMLOptionElement; +class Node; +class String; +} + +// This file is an aggregate of useful WebCore operations. +namespace WebKit { + +// If node is an HTML node with a tag name of name it is casted and returned. +// If node is not an HTML node or the tag name is not name, 0 is returned. +WebCore::HTMLInputElement* toHTMLInputElement(WebCore::Node*); +WebCore::HTMLLinkElement* toHTMLLinkElement(WebCore::Node*); +WebCore::HTMLMetaElement* toHTMLMetaElement(WebCore::Node*); +WebCore::HTMLOptionElement* toHTMLOptionElement(WebCore::Node*); + +// FIXME: Deprecate. Use WebInputElement::nameForAutofill instead. +WebCore::String nameOfInputElement(WebCore::HTMLInputElement*); + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/DatabaseObserver.cpp b/WebKit/chromium/src/DatabaseObserver.cpp new file mode 100644 index 0000000..54e93e1 --- /dev/null +++ b/WebKit/chromium/src/DatabaseObserver.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "DatabaseObserver.h" + +#include "Database.h" +#include "WebDatabase.h" +#include "WebDatabaseObserver.h" + +using namespace WebKit; + +namespace WebCore { + +void DatabaseObserver::databaseOpened(Database* database) +{ + ASSERT(isMainThread()); + WebDatabase::observer()->databaseOpened(WebDatabase(database)); +} + +void DatabaseObserver::databaseModified(Database* database) +{ + ASSERT(isMainThread()); + WebDatabase::observer()->databaseModified(WebDatabase(database)); +} + +void DatabaseObserver::databaseClosed(Database* database) +{ + ASSERT(isMainThread()); + WebDatabase::observer()->databaseClosed(WebDatabase(database)); +} + +} // namespace WebCore diff --git a/WebKit/chromium/src/DragClientImpl.cpp b/WebKit/chromium/src/DragClientImpl.cpp new file mode 100644 index 0000000..5d8a9c3 --- /dev/null +++ b/WebKit/chromium/src/DragClientImpl.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "DragClientImpl.h" + +#include "ChromiumDataObject.h" +#include "ClipboardChromium.h" +#include "Frame.h" +#include "WebDragData.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" + +using namespace WebCore; + +namespace WebKit { + +void DragClientImpl::willPerformDragDestinationAction(DragDestinationAction, DragData*) +{ + // FIXME +} + +void DragClientImpl::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) +{ + // FIXME +} + +DragDestinationAction DragClientImpl::actionMaskForDrag(DragData*) +{ + if (m_webView->client() && m_webView->client()->acceptsLoadDrops()) + return DragDestinationActionAny; + + return static_cast<DragDestinationAction>( + DragDestinationActionDHTML | DragDestinationActionEdit); +} + +DragSourceAction DragClientImpl::dragSourceActionMaskForPoint(const IntPoint& windowPoint) +{ + // We want to handle drag operations for all source types. + return DragSourceActionAny; +} + +void DragClientImpl::startDrag(DragImageRef dragImage, + const IntPoint& dragImageOrigin, + const IntPoint& eventPos, + Clipboard* clipboard, + Frame* frame, + bool isLinkDrag) +{ + // Add a ref to the frame just in case a load occurs mid-drag. + RefPtr<Frame> frameProtector = frame; + + WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject(); + + DragOperation dragOperationMask; + if (!clipboard->sourceOperation(dragOperationMask)) + dragOperationMask = DragOperationEvery; + + m_webView->startDragging( + eventPos, dragData, static_cast<WebDragOperationsMask>(dragOperationMask)); +} + +DragImageRef DragClientImpl::createDragImageForLink(KURL&, const String& label, Frame*) +{ + // FIXME + return 0; +} + +void DragClientImpl::dragControllerDestroyed() +{ + // Our lifetime is bound to the WebViewImpl. +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/DragClientImpl.h b/WebKit/chromium/src/DragClientImpl.h new file mode 100644 index 0000000..fc4c608 --- /dev/null +++ b/WebKit/chromium/src/DragClientImpl.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 DragClientImpl_h +#define DragClientImpl_h + +#include "DragActions.h" +#include "DragClient.h" + +namespace WebCore { +class ClipBoard; +class DragData; +class IntPoint; +class KURL; +} + +namespace WebKit { +class WebViewImpl; + +class DragClientImpl : public WebCore::DragClient { +public: + DragClientImpl(WebViewImpl* webView) : m_webView(webView) { } + + virtual void willPerformDragDestinationAction( + WebCore::DragDestinationAction, WebCore::DragData*); + virtual void willPerformDragSourceAction( + WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*); + virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*); + virtual WebCore::DragSourceAction dragSourceActionMaskForPoint( + const WebCore::IntPoint& windowPoint); + virtual void startDrag( + WebCore::DragImageRef dragImage, + const WebCore::IntPoint& dragImageOrigin, + const WebCore::IntPoint& eventPos, + WebCore::Clipboard* clipboard, + WebCore::Frame* frame, + bool isLinkDrag = false); + virtual WebCore::DragImageRef createDragImageForLink( + WebCore::KURL&, const WebCore::String& label, WebCore::Frame*); + virtual void dragControllerDestroyed(); + +private: + WebViewImpl* m_webView; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/EditorClientImpl.cpp b/WebKit/chromium/src/EditorClientImpl.cpp new file mode 100644 index 0000000..5db8ff7 --- /dev/null +++ b/WebKit/chromium/src/EditorClientImpl.cpp @@ -0,0 +1,922 @@ +/* + * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. + * Copyright (C) 2009 Google, 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. + */ + +#include "config.h" +#include "EditorClientImpl.h" + +#include "Document.h" +#include "EditCommand.h" +#include "Editor.h" +#include "EventHandler.h" +#include "EventNames.h" +#include "Frame.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "KeyboardCodes.h" +#include "KeyboardEvent.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformString.h" +#include "RenderObject.h" + +#include "DOMUtilitiesPrivate.h" +#include "WebEditingAction.h" +#include "WebFrameImpl.h" +#include "WebKit.h" +#include "WebInputElement.h" +#include "WebNode.h" +#include "WebPasswordAutocompleteListener.h" +#include "WebRange.h" +#include "WebTextAffinity.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" + +using namespace WebCore; + +namespace WebKit { + +// Arbitrary depth limit for the undo stack, to keep it from using +// unbounded memory. This is the maximum number of distinct undoable +// actions -- unbroken stretches of typed characters are coalesced +// into a single action. +static const size_t maximumUndoStackDepth = 1000; + +// The size above which we stop triggering autofill for an input text field +// (so to avoid sending long strings through IPC). +static const size_t maximumTextSizeForAutofill = 1000; + +EditorClientImpl::EditorClientImpl(WebViewImpl* webview) + : m_webView(webview) + , m_inRedo(false) + , m_backspaceOrDeletePressed(false) + , m_spellCheckThisFieldStatus(SpellCheckAutomatic) + , m_autofillTimer(this, &EditorClientImpl::doAutofill) +{ +} + +EditorClientImpl::~EditorClientImpl() +{ +} + +void EditorClientImpl::pageDestroyed() +{ + // Our lifetime is bound to the WebViewImpl. +} + +bool EditorClientImpl::shouldShowDeleteInterface(HTMLElement* elem) +{ + // Normally, we don't care to show WebCore's deletion UI, so we only enable + // it if in testing mode and the test specifically requests it by using this + // magic class name. + return WebKit::layoutTestMode() + && elem->getAttribute(HTMLNames::classAttr) == "needsDeletionUI"; +} + +bool EditorClientImpl::smartInsertDeleteEnabled() +{ + if (m_webView->client()) + return m_webView->client()->isSmartInsertDeleteEnabled(); + return true; +} + +bool EditorClientImpl::isSelectTrailingWhitespaceEnabled() +{ + if (m_webView->client()) + return m_webView->client()->isSelectTrailingWhitespaceEnabled(); +#if PLATFORM(WIN_OS) + return true; +#else + return false; +#endif +} + +bool EditorClientImpl::shouldSpellcheckByDefault() +{ + // Spellcheck should be enabled for all editable areas (such as textareas, + // contentEditable regions, and designMode docs), except text inputs. + const Frame* frame = m_webView->focusedWebCoreFrame(); + if (!frame) + return false; + const Editor* editor = frame->editor(); + if (!editor) + return false; + if (editor->spellCheckingEnabledInFocusedNode()) + return true; + const Document* document = frame->document(); + if (!document) + return false; + const Node* node = document->focusedNode(); + // If |node| is null, we default to allowing spellchecking. This is done in + // order to mitigate the issue when the user clicks outside the textbox, as a + // result of which |node| becomes null, resulting in all the spell check + // markers being deleted. Also, the Frame will decide not to do spellchecking + // if the user can't edit - so returning true here will not cause any problems + // to the Frame's behavior. + if (!node) + return true; + const RenderObject* renderer = node->renderer(); + if (!renderer) + return false; + + return !renderer->isTextField(); +} + +bool EditorClientImpl::isContinuousSpellCheckingEnabled() +{ + if (m_spellCheckThisFieldStatus == SpellCheckForcedOff) + return false; + if (m_spellCheckThisFieldStatus == SpellCheckForcedOn) + return true; + return shouldSpellcheckByDefault(); +} + +void EditorClientImpl::toggleContinuousSpellChecking() +{ + if (isContinuousSpellCheckingEnabled()) + m_spellCheckThisFieldStatus = SpellCheckForcedOff; + else + m_spellCheckThisFieldStatus = SpellCheckForcedOn; +} + +bool EditorClientImpl::isGrammarCheckingEnabled() +{ + return false; +} + +void EditorClientImpl::toggleGrammarChecking() +{ + notImplemented(); +} + +int EditorClientImpl::spellCheckerDocumentTag() +{ + ASSERT_NOT_REACHED(); + return 0; +} + +bool EditorClientImpl::isEditable() +{ + return false; +} + +bool EditorClientImpl::shouldBeginEditing(Range* range) +{ + if (m_webView->client()) + return m_webView->client()->shouldBeginEditing(WebRange(range)); + return true; +} + +bool EditorClientImpl::shouldEndEditing(Range* range) +{ + if (m_webView->client()) + return m_webView->client()->shouldEndEditing(WebRange(range)); + return true; +} + +bool EditorClientImpl::shouldInsertNode(Node* node, + Range* range, + EditorInsertAction action) +{ + if (m_webView->client()) { + return m_webView->client()->shouldInsertNode(WebNode(node), + WebRange(range), + static_cast<WebEditingAction>(action)); + } + return true; +} + +bool EditorClientImpl::shouldInsertText(const String& text, + Range* range, + EditorInsertAction action) +{ + if (m_webView->client()) { + return m_webView->client()->shouldInsertText(WebString(text), + WebRange(range), + static_cast<WebEditingAction>(action)); + } + return true; +} + + +bool EditorClientImpl::shouldDeleteRange(Range* range) +{ + if (m_webView->client()) + return m_webView->client()->shouldDeleteRange(WebRange(range)); + return true; +} + +bool EditorClientImpl::shouldChangeSelectedRange(Range* fromRange, + Range* toRange, + EAffinity affinity, + bool stillSelecting) +{ + if (m_webView->client()) { + return m_webView->client()->shouldChangeSelectedRange(WebRange(fromRange), + WebRange(toRange), + static_cast<WebTextAffinity>(affinity), + stillSelecting); + } + return true; +} + +bool EditorClientImpl::shouldApplyStyle(CSSStyleDeclaration* style, + Range* range) +{ + if (m_webView->client()) { + // FIXME: Pass a reference to the CSSStyleDeclaration somehow. + return m_webView->client()->shouldApplyStyle(WebString(), + WebRange(range)); + } + return true; +} + +bool EditorClientImpl::shouldMoveRangeAfterDelete(Range* range, + Range* rangeToBeReplaced) +{ + return true; +} + +void EditorClientImpl::didBeginEditing() +{ + if (m_webView->client()) + m_webView->client()->didBeginEditing(); +} + +void EditorClientImpl::respondToChangedSelection() +{ + if (m_webView->client()) { + Frame* frame = m_webView->focusedWebCoreFrame(); + if (frame) + m_webView->client()->didChangeSelection(!frame->selection()->isRange()); + } +} + +void EditorClientImpl::respondToChangedContents() +{ + if (m_webView->client()) + m_webView->client()->didChangeContents(); +} + +void EditorClientImpl::didEndEditing() +{ + if (m_webView->client()) + m_webView->client()->didEndEditing(); +} + +void EditorClientImpl::didWriteSelectionToPasteboard() +{ +} + +void EditorClientImpl::didSetSelectionTypesForPasteboard() +{ +} + +void EditorClientImpl::registerCommandForUndo(PassRefPtr<EditCommand> command) +{ + if (m_undoStack.size() == maximumUndoStackDepth) + m_undoStack.removeFirst(); // drop oldest item off the far end + if (!m_inRedo) + m_redoStack.clear(); + m_undoStack.append(command); +} + +void EditorClientImpl::registerCommandForRedo(PassRefPtr<EditCommand> command) +{ + m_redoStack.append(command); +} + +void EditorClientImpl::clearUndoRedoOperations() +{ + m_undoStack.clear(); + m_redoStack.clear(); +} + +bool EditorClientImpl::canUndo() const +{ + return !m_undoStack.isEmpty(); +} + +bool EditorClientImpl::canRedo() const +{ + return !m_redoStack.isEmpty(); +} + +void EditorClientImpl::undo() +{ + if (canUndo()) { + EditCommandStack::iterator back = --m_undoStack.end(); + RefPtr<EditCommand> command(*back); + m_undoStack.remove(back); + command->unapply(); + // unapply will call us back to push this command onto the redo stack. + } +} + +void EditorClientImpl::redo() +{ + if (canRedo()) { + EditCommandStack::iterator back = --m_redoStack.end(); + RefPtr<EditCommand> command(*back); + m_redoStack.remove(back); + + ASSERT(!m_inRedo); + m_inRedo = true; + command->reapply(); + // reapply will call us back to push this command onto the undo stack. + m_inRedo = false; + } +} + +// +// The below code was adapted from the WebKit file webview.cpp +// + +static const unsigned CtrlKey = 1 << 0; +static const unsigned AltKey = 1 << 1; +static const unsigned ShiftKey = 1 << 2; +static const unsigned MetaKey = 1 << 3; +#if PLATFORM(DARWIN) +// Aliases for the generic key defintions to make kbd shortcuts definitions more +// readable on OS X. +static const unsigned OptionKey = AltKey; + +// Do not use this constant for anything but cursor movement commands. Keys +// with cmd set have their |isSystemKey| bit set, so chances are the shortcut +// will not be executed. Another, less important, reason is that shortcuts +// defined in the renderer do not blink the menu item that they triggered. See +// http://crbug.com/25856 and the bugs linked from there for details. +static const unsigned CommandKey = MetaKey; +#endif + +// Keys with special meaning. These will be delegated to the editor using +// the execCommand() method +struct KeyDownEntry { + unsigned virtualKey; + unsigned modifiers; + const char* name; +}; + +struct KeyPressEntry { + unsigned charCode; + unsigned modifiers; + const char* name; +}; + +static const KeyDownEntry keyDownEntries[] = { + { VKEY_LEFT, 0, "MoveLeft" }, + { VKEY_LEFT, ShiftKey, "MoveLeftAndModifySelection" }, +#if PLATFORM(DARWIN) + { VKEY_LEFT, OptionKey, "MoveWordLeft" }, + { VKEY_LEFT, OptionKey | ShiftKey, + "MoveWordLeftAndModifySelection" }, +#else + { VKEY_LEFT, CtrlKey, "MoveWordLeft" }, + { VKEY_LEFT, CtrlKey | ShiftKey, + "MoveWordLeftAndModifySelection" }, +#endif + { VKEY_RIGHT, 0, "MoveRight" }, + { VKEY_RIGHT, ShiftKey, "MoveRightAndModifySelection" }, +#if PLATFORM(DARWIN) + { VKEY_RIGHT, OptionKey, "MoveWordRight" }, + { VKEY_RIGHT, OptionKey | ShiftKey, + "MoveWordRightAndModifySelection" }, +#else + { VKEY_RIGHT, CtrlKey, "MoveWordRight" }, + { VKEY_RIGHT, CtrlKey | ShiftKey, + "MoveWordRightAndModifySelection" }, +#endif + { VKEY_UP, 0, "MoveUp" }, + { VKEY_UP, ShiftKey, "MoveUpAndModifySelection" }, + { VKEY_PRIOR, ShiftKey, "MovePageUpAndModifySelection" }, + { VKEY_DOWN, 0, "MoveDown" }, + { VKEY_DOWN, ShiftKey, "MoveDownAndModifySelection" }, + { VKEY_NEXT, ShiftKey, "MovePageDownAndModifySelection" }, + { VKEY_PRIOR, 0, "MovePageUp" }, + { VKEY_NEXT, 0, "MovePageDown" }, + { VKEY_HOME, 0, "MoveToBeginningOfLine" }, + { VKEY_HOME, ShiftKey, + "MoveToBeginningOfLineAndModifySelection" }, +#if PLATFORM(DARWIN) + { VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" }, + { VKEY_LEFT, CommandKey | ShiftKey, + "MoveToBeginningOfLineAndModifySelection" }, +#endif +#if PLATFORM(DARWIN) + { VKEY_UP, CommandKey, "MoveToBeginningOfDocument" }, + { VKEY_UP, CommandKey | ShiftKey, + "MoveToBeginningOfDocumentAndModifySelection" }, +#else + { VKEY_HOME, CtrlKey, "MoveToBeginningOfDocument" }, + { VKEY_HOME, CtrlKey | ShiftKey, + "MoveToBeginningOfDocumentAndModifySelection" }, +#endif + { VKEY_END, 0, "MoveToEndOfLine" }, + { VKEY_END, ShiftKey, "MoveToEndOfLineAndModifySelection" }, +#if PLATFORM(DARWIN) + { VKEY_DOWN, CommandKey, "MoveToEndOfDocument" }, + { VKEY_DOWN, CommandKey | ShiftKey, + "MoveToEndOfDocumentAndModifySelection" }, +#else + { VKEY_END, CtrlKey, "MoveToEndOfDocument" }, + { VKEY_END, CtrlKey | ShiftKey, + "MoveToEndOfDocumentAndModifySelection" }, +#endif +#if PLATFORM(DARWIN) + { VKEY_RIGHT, CommandKey, "MoveToEndOfLine" }, + { VKEY_RIGHT, CommandKey | ShiftKey, + "MoveToEndOfLineAndModifySelection" }, +#endif + { VKEY_BACK, 0, "DeleteBackward" }, + { VKEY_BACK, ShiftKey, "DeleteBackward" }, + { VKEY_DELETE, 0, "DeleteForward" }, +#if PLATFORM(DARWIN) + { VKEY_BACK, OptionKey, "DeleteWordBackward" }, + { VKEY_DELETE, OptionKey, "DeleteWordForward" }, +#else + { VKEY_BACK, CtrlKey, "DeleteWordBackward" }, + { VKEY_DELETE, CtrlKey, "DeleteWordForward" }, +#endif + { 'B', CtrlKey, "ToggleBold" }, + { 'I', CtrlKey, "ToggleItalic" }, + { 'U', CtrlKey, "ToggleUnderline" }, + { VKEY_ESCAPE, 0, "Cancel" }, + { VKEY_OEM_PERIOD, CtrlKey, "Cancel" }, + { VKEY_TAB, 0, "InsertTab" }, + { VKEY_TAB, ShiftKey, "InsertBacktab" }, + { VKEY_RETURN, 0, "InsertNewline" }, + { VKEY_RETURN, CtrlKey, "InsertNewline" }, + { VKEY_RETURN, AltKey, "InsertNewline" }, + { VKEY_RETURN, AltKey | ShiftKey, "InsertNewline" }, + { VKEY_RETURN, ShiftKey, "InsertLineBreak" }, + { VKEY_INSERT, CtrlKey, "Copy" }, + { VKEY_INSERT, ShiftKey, "Paste" }, + { VKEY_DELETE, ShiftKey, "Cut" }, +#if !PLATFORM(DARWIN) + // On OS X, we pipe these back to the browser, so that it can do menu item + // blinking. + { 'C', CtrlKey, "Copy" }, + { 'V', CtrlKey, "Paste" }, + { 'V', CtrlKey | ShiftKey, "PasteAndMatchStyle" }, + { 'X', CtrlKey, "Cut" }, + { 'A', CtrlKey, "SelectAll" }, + { 'Z', CtrlKey, "Undo" }, + { 'Z', CtrlKey | ShiftKey, "Redo" }, + { 'Y', CtrlKey, "Redo" }, +#endif +}; + +static const KeyPressEntry keyPressEntries[] = { + { '\t', 0, "InsertTab" }, + { '\t', ShiftKey, "InsertBacktab" }, + { '\r', 0, "InsertNewline" }, + { '\r', CtrlKey, "InsertNewline" }, + { '\r', ShiftKey, "InsertLineBreak" }, + { '\r', AltKey, "InsertNewline" }, + { '\r', AltKey | ShiftKey, "InsertNewline" }, +}; + +const char* EditorClientImpl::interpretKeyEvent(const KeyboardEvent* evt) +{ + const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); + if (!keyEvent) + return ""; + + static HashMap<int, const char*>* keyDownCommandsMap = 0; + static HashMap<int, const char*>* keyPressCommandsMap = 0; + + if (!keyDownCommandsMap) { + keyDownCommandsMap = new HashMap<int, const char*>; + keyPressCommandsMap = new HashMap<int, const char*>; + + for (unsigned i = 0; i < arraysize(keyDownEntries); i++) { + keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey, + keyDownEntries[i].name); + } + + for (unsigned i = 0; i < arraysize(keyPressEntries); i++) { + keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode, + keyPressEntries[i].name); + } + } + + unsigned modifiers = 0; + if (keyEvent->shiftKey()) + modifiers |= ShiftKey; + if (keyEvent->altKey()) + modifiers |= AltKey; + if (keyEvent->ctrlKey()) + modifiers |= CtrlKey; + if (keyEvent->metaKey()) + modifiers |= MetaKey; + + if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) { + int mapKey = modifiers << 16 | evt->keyCode(); + return mapKey ? keyDownCommandsMap->get(mapKey) : 0; + } + + int mapKey = modifiers << 16 | evt->charCode(); + return mapKey ? keyPressCommandsMap->get(mapKey) : 0; +} + +bool EditorClientImpl::handleEditingKeyboardEvent(KeyboardEvent* evt) +{ + const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); + // do not treat this as text input if it's a system key event + if (!keyEvent || keyEvent->isSystemKey()) + return false; + + Frame* frame = evt->target()->toNode()->document()->frame(); + if (!frame) + return false; + + String commandName = interpretKeyEvent(evt); + Editor::Command command = frame->editor()->command(commandName); + + if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) { + // WebKit doesn't have enough information about mode to decide how + // commands that just insert text if executed via Editor should be treated, + // so we leave it upon WebCore to either handle them immediately + // (e.g. Tab that changes focus) or let a keypress event be generated + // (e.g. Tab that inserts a Tab character, or Enter). + if (command.isTextInsertion() || commandName.isEmpty()) + return false; + if (command.execute(evt)) { + if (m_webView->client()) + m_webView->client()->didExecuteCommand(WebString(commandName)); + return true; + } + return false; + } + + if (command.execute(evt)) { + if (m_webView->client()) + m_webView->client()->didExecuteCommand(WebString(commandName)); + return true; + } + + // Here we need to filter key events. + // On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>. + // In Webkit, EditorClient::handleKeyboardEvent in + // WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events. + // On Mac, it emits key events with ASCII text and meta on for Command-<x>. + // These key events should not emit text insert event. + // Alt key would be used to insert alternative character, so we should let + // through. Also note that Ctrl-Alt combination equals to AltGr key which is + // also used to insert alternative character. + // http://code.google.com/p/chromium/issues/detail?id=10846 + // Windows sets both alt and meta are on when "Alt" key pressed. + // http://code.google.com/p/chromium/issues/detail?id=2215 + // Also, we should not rely on an assumption that keyboards don't + // send ASCII characters when pressing a control key on Windows, + // which may be configured to do it so by user. + // See also http://en.wikipedia.org/wiki/Keyboard_Layout + // FIXME(ukai): investigate more detail for various keyboard layout. + if (evt->keyEvent()->text().length() == 1) { + UChar ch = evt->keyEvent()->text()[0U]; + + // Don't insert null or control characters as they can result in + // unexpected behaviour + if (ch < ' ') + return false; +#if !PLATFORM(WIN_OS) + // Don't insert ASCII character if ctrl w/o alt or meta is on. + // On Mac, we should ignore events when meta is on (Command-<x>). + if (ch < 0x80) { + if (evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey()) + return false; +#if PLATFORM(DARWIN) + if (evt->keyEvent()->metaKey()) + return false; +#endif + } +#endif + } + + if (!frame->editor()->canEdit()) + return false; + + return frame->editor()->insertText(evt->keyEvent()->text(), evt); +} + +void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt) +{ + if (evt->keyCode() == VKEY_DOWN + || evt->keyCode() == VKEY_UP) { + ASSERT(evt->target()->toNode()); + showFormAutofillForNode(evt->target()->toNode()); + } + + // Give the embedder a chance to handle the keyboard event. + if ((m_webView->client() + && m_webView->client()->handleCurrentKeyboardEvent()) + || handleEditingKeyboardEvent(evt)) + evt->setDefaultHandled(); +} + +void EditorClientImpl::handleInputMethodKeydown(KeyboardEvent* keyEvent) +{ + // We handle IME within chrome. +} + +void EditorClientImpl::textFieldDidBeginEditing(Element*) +{ +} + +void EditorClientImpl::textFieldDidEndEditing(Element* element) +{ + // Notification that focus was lost. Be careful with this, it's also sent + // when the page is being closed. + + // Cancel any pending DoAutofill call. + m_autofillArgs.clear(); + m_autofillTimer.stop(); + + // Hide any showing popup. + m_webView->hideAutoCompletePopup(); + + if (!m_webView->client()) + return; // The page is getting closed, don't fill the password. + + // Notify any password-listener of the focus change. + HTMLInputElement* inputElement = WebKit::toHTMLInputElement(element); + if (!inputElement) + return; + + WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame()); + if (!webframe) + return; + + WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement); + if (!listener) + return; + + listener->didBlurInputElement(inputElement->value()); +} + +void EditorClientImpl::textDidChangeInTextField(Element* element) +{ + ASSERT(element->hasLocalName(HTMLNames::inputTag)); + // Note that we only show the autofill popup in this case if the caret is at + // the end. This matches FireFox and Safari but not IE. + autofill(static_cast<HTMLInputElement*>(element), false, false, + true); +} + +bool EditorClientImpl::showFormAutofillForNode(Node* node) +{ + HTMLInputElement* inputElement = WebKit::toHTMLInputElement(node); + if (inputElement) + return autofill(inputElement, true, true, false); + return false; +} + +bool EditorClientImpl::autofill(HTMLInputElement* inputElement, + bool autofillFormOnly, + bool autofillOnEmptyValue, + bool requireCaretAtEnd) +{ + // Cancel any pending DoAutofill call. + m_autofillArgs.clear(); + m_autofillTimer.stop(); + + // Let's try to trigger autofill for that field, if applicable. + if (!inputElement->isEnabledFormControl() || !inputElement->isTextField() + || inputElement->isPasswordField() + || !inputElement->autoComplete()) + return false; + + WebString name = WebInputElement(inputElement).nameForAutofill(); + if (name.isEmpty()) // If the field has no name, then we won't have values. + return false; + + // Don't attempt to autofill with values that are too large. + if (inputElement->value().length() > maximumTextSizeForAutofill) + return false; + + m_autofillArgs = new AutofillArgs(); + m_autofillArgs->inputElement = inputElement; + m_autofillArgs->autofillFormOnly = autofillFormOnly; + m_autofillArgs->autofillOnEmptyValue = autofillOnEmptyValue; + m_autofillArgs->requireCaretAtEnd = requireCaretAtEnd; + m_autofillArgs->backspaceOrDeletePressed = m_backspaceOrDeletePressed; + + if (!requireCaretAtEnd) + doAutofill(0); + else { + // We post a task for doing the autofill as the caret position is not set + // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) + // and we need it to determine whether or not to trigger autofill. + m_autofillTimer.startOneShot(0.0); + } + return true; +} + +void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer) +{ + OwnPtr<AutofillArgs> args(m_autofillArgs.release()); + HTMLInputElement* inputElement = args->inputElement.get(); + + const String& value = inputElement->value(); + + // Enforce autofill_on_empty_value and caret_at_end. + + bool isCaretAtEnd = true; + if (args->requireCaretAtEnd) + isCaretAtEnd = inputElement->selectionStart() == inputElement->selectionEnd() + && inputElement->selectionEnd() == static_cast<int>(value.length()); + + if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) { + m_webView->hideAutoCompletePopup(); + return; + } + + // First let's see if there is a password listener for that element. + // We won't trigger form autofill in that case, as having both behavior on + // a node would be confusing. + WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame()); + if (!webframe) + return; + WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement); + if (listener) { + if (args->autofillFormOnly) + return; + + listener->performInlineAutocomplete(value, + args->backspaceOrDeletePressed, + true); + return; + } + + // Then trigger form autofill. + WebString name = WebInputElement(inputElement).nameForAutofill(); + ASSERT(static_cast<int>(name.length()) > 0); + + if (m_webView->client()) + m_webView->client()->queryAutofillSuggestions(WebNode(inputElement), + name, WebString(value)); +} + +void EditorClientImpl::cancelPendingAutofill() +{ + m_autofillArgs.clear(); + m_autofillTimer.stop(); +} + +void EditorClientImpl::onAutofillSuggestionAccepted(HTMLInputElement* textField) +{ + WebFrameImpl* webframe = WebFrameImpl::fromFrame(textField->document()->frame()); + if (!webframe) + return; + + WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(textField); + // Password listeners need to autocomplete other fields that depend on the + // input element with autofill suggestions. + if (listener) + listener->performInlineAutocomplete(textField->value(), false, false); +} + +bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element, + KeyboardEvent* event) +{ + // Remember if backspace was pressed for the autofill. It is not clear how to + // find if backspace was pressed from textFieldDidBeginEditing and + // textDidChangeInTextField as when these methods are called the value of the + // input element already contains the type character. + m_backspaceOrDeletePressed = event->keyCode() == VKEY_BACK || event->keyCode() == VKEY_DELETE; + + // The Mac code appears to use this method as a hook to implement special + // keyboard commands specific to Safari's auto-fill implementation. We + // just return false to allow the default action. + return false; +} + +void EditorClientImpl::textWillBeDeletedInTextField(Element*) +{ +} + +void EditorClientImpl::textDidChangeInTextArea(Element*) +{ +} + +void EditorClientImpl::ignoreWordInSpellDocument(const String&) +{ + notImplemented(); +} + +void EditorClientImpl::learnWord(const String&) +{ + notImplemented(); +} + +void EditorClientImpl::checkSpellingOfString(const UChar* text, int length, + int* misspellingLocation, + int* misspellingLength) +{ + // SpellCheckWord will write (0, 0) into the output vars, which is what our + // caller expects if the word is spelled correctly. + int spellLocation = -1; + int spellLength = 0; + + // Check to see if the provided text is spelled correctly. + if (isContinuousSpellCheckingEnabled() && m_webView->client()) + m_webView->client()->spellCheck(WebString(text, length), spellLocation, spellLength); + else { + spellLocation = 0; + spellLength = 0; + } + + // Note: the Mac code checks if the pointers are null before writing to them, + // so we do too. + if (misspellingLocation) + *misspellingLocation = spellLocation; + if (misspellingLength) + *misspellingLength = spellLength; +} + +String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) +{ + if (!(isContinuousSpellCheckingEnabled() && m_webView->client())) + return String(); + + // Do not autocorrect words with capital letters in it except the + // first letter. This will remove cases changing "IMB" to "IBM". + for (size_t i = 1; i < misspelledWord.length(); i++) { + if (u_isupper(static_cast<UChar32>(misspelledWord[i]))) + return String(); + } + + return m_webView->client()->autoCorrectWord(WebString(misspelledWord)); +} + +void EditorClientImpl::checkGrammarOfString(const UChar*, int length, + WTF::Vector<GrammarDetail>&, + int* badGrammarLocation, + int* badGrammarLength) +{ + notImplemented(); + if (badGrammarLocation) + *badGrammarLocation = 0; + if (badGrammarLength) + *badGrammarLength = 0; +} + +void EditorClientImpl::updateSpellingUIWithGrammarString(const String&, + const GrammarDetail& detail) +{ + notImplemented(); +} + +void EditorClientImpl::updateSpellingUIWithMisspelledWord(const String& misspelledWord) +{ + if (m_webView->client()) + m_webView->client()->updateSpellingUIWithMisspelledWord(WebString(misspelledWord)); +} + +void EditorClientImpl::showSpellingUI(bool show) +{ + if (m_webView->client()) + m_webView->client()->showSpellingUI(show); +} + +bool EditorClientImpl::spellingUIIsShowing() +{ + if (m_webView->client()) + return m_webView->client()->isShowingSpellingUI(); + return false; +} + +void EditorClientImpl::getGuessesForWord(const String&, + WTF::Vector<String>& guesses) +{ + notImplemented(); +} + +void EditorClientImpl::setInputMethodState(bool enabled) +{ + if (m_webView->client()) + m_webView->client()->setInputMethodEnabled(enabled); +} + +} // namesace WebKit diff --git a/WebKit/chromium/src/EditorClientImpl.h b/WebKit/chromium/src/EditorClientImpl.h new file mode 100644 index 0000000..fd08b4d --- /dev/null +++ b/WebKit/chromium/src/EditorClientImpl.h @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 EditorClientImpl_h +#define EditorClientImpl_h + +#include "EditorClient.h" +#include "Timer.h" +#include <wtf/Deque.h> + +namespace WebCore { +class HTMLInputElement; +} + +namespace WebKit { +class WebViewImpl; + +class EditorClientImpl : public WebCore::EditorClient { +public: + EditorClientImpl(WebViewImpl* webView); + + virtual ~EditorClientImpl(); + virtual void pageDestroyed(); + + virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*); + virtual bool smartInsertDeleteEnabled(); + virtual bool isSelectTrailingWhitespaceEnabled(); + virtual bool isContinuousSpellCheckingEnabled(); + virtual void toggleContinuousSpellChecking(); + virtual bool isGrammarCheckingEnabled(); + virtual void toggleGrammarChecking(); + virtual int spellCheckerDocumentTag(); + virtual bool isEditable(); + virtual bool shouldBeginEditing(WebCore::Range*); + virtual bool shouldEndEditing(WebCore::Range*); + virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction); + virtual bool shouldInsertText(const WebCore::String&, WebCore::Range*, WebCore::EditorInsertAction); + virtual bool shouldDeleteRange(WebCore::Range*); + virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, + WebCore::Range* toRange, + WebCore::EAffinity, + bool stillSelecting); + virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*); + virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*); + virtual void didBeginEditing(); + virtual void respondToChangedContents(); + virtual void respondToChangedSelection(); + virtual void didEndEditing(); + virtual void didWriteSelectionToPasteboard(); + virtual void didSetSelectionTypesForPasteboard(); + virtual void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>); + virtual void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>); + virtual void clearUndoRedoOperations(); + virtual bool canUndo() const; + virtual bool canRedo() const; + virtual void undo(); + virtual void redo(); + virtual const char* interpretKeyEvent(const WebCore::KeyboardEvent*); + virtual bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*); + virtual void handleKeyboardEvent(WebCore::KeyboardEvent*); + virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*); + virtual void textFieldDidBeginEditing(WebCore::Element*); + virtual void textFieldDidEndEditing(WebCore::Element*); + virtual void textDidChangeInTextField(WebCore::Element*); + virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*); + virtual void textWillBeDeletedInTextField(WebCore::Element*); + virtual void textDidChangeInTextArea(WebCore::Element*); + virtual void ignoreWordInSpellDocument(const WebCore::String&); + virtual void learnWord(const WebCore::String&); + virtual void checkSpellingOfString(const UChar*, int length, + int* misspellingLocation, + int* misspellingLength); + virtual void checkGrammarOfString(const UChar*, int length, + WTF::Vector<WebCore::GrammarDetail>&, + int* badGrammarLocation, + int* badGrammarLength); + virtual WebCore::String getAutoCorrectSuggestionForMisspelledWord(const WebCore::String&); + virtual void updateSpellingUIWithGrammarString(const WebCore::String&, const WebCore::GrammarDetail&); + virtual void updateSpellingUIWithMisspelledWord(const WebCore::String&); + virtual void showSpellingUI(bool show); + virtual bool spellingUIIsShowing(); + virtual void getGuessesForWord(const WebCore::String& word, + WTF::Vector<WebCore::String>& guesses); + virtual void setInputMethodState(bool enabled); + + // Shows the form autofill popup for |node| if it is an HTMLInputElement and + // it is empty. This is called when you press the up or down arrow in a + // text-field or when clicking an already focused text-field. + // Returns true if the autofill popup has been scheduled to be shown, false + // otherwise. + virtual bool showFormAutofillForNode(WebCore::Node*); + + // Notification that the text changed due to acceptance of a suggestion + // provided by an autofill popup. Having a separate callback in this case + // is a simple way to break the cycle that would otherwise occur if + // textDidChangeInTextField was called. + virtual void onAutofillSuggestionAccepted(WebCore::HTMLInputElement*); + +private: + void modifySelection(WebCore::Frame*, WebCore::KeyboardEvent*); + + // Triggers autofill for an input element if applicable. This can be form + // autofill (via a popup-menu) or password autofill depending on the + // input element. If |formAutofillOnly| is true, password autofill is not + // triggered. + // |autofillOnEmptyValue| indicates whether the autofill should be shown + // when the text-field is empty. + // If |requiresCaretAtEnd| is true, the autofill popup is only shown if the + // caret is located at the end of the entered text. + // Returns true if the autofill popup has been scheduled to be shown, false + // otherwise. + bool autofill(WebCore::HTMLInputElement*, + bool formAutofillOnly, bool autofillOnEmptyValue, + bool requiresCaretAtEnd); + + // Called to process the autofill described by m_autofillArgs. + // This method is invoked asynchronously if the caret position is not + // reflecting the last text change yet, and we need it to decide whether or + // not to show the autofill popup. + void doAutofill(WebCore::Timer<EditorClientImpl>*); + + void cancelPendingAutofill(); + + // Returns whether or not the focused control needs spell-checking. + // Currently, this function just retrieves the focused node and determines + // whether or not it is a <textarea> element or an element whose + // contenteditable attribute is true. + // FIXME: Bug 740540: This code just implements the default behavior + // proposed in this issue. We should also retrieve "spellcheck" attributes + // for text fields and create a flag to over-write the default behavior. + bool shouldSpellcheckByDefault(); + + WebViewImpl* m_webView; + bool m_inRedo; + + typedef Deque<RefPtr<WebCore::EditCommand> > EditCommandStack; + EditCommandStack m_undoStack; + EditCommandStack m_redoStack; + + // Whether the last entered key was a backspace. + bool m_backspaceOrDeletePressed; + + // This flag is set to false if spell check for this editor is manually + // turned off. The default setting is SpellCheckAutomatic. + enum { + SpellCheckAutomatic, + SpellCheckForcedOn, + SpellCheckForcedOff + }; + int m_spellCheckThisFieldStatus; + + // Used to delay autofill processing. + WebCore::Timer<EditorClientImpl> m_autofillTimer; + + struct AutofillArgs { + RefPtr<WebCore::HTMLInputElement> inputElement; + bool autofillFormOnly; + bool autofillOnEmptyValue; + bool requireCaretAtEnd; + bool backspaceOrDeletePressed; + }; + OwnPtr<AutofillArgs> m_autofillArgs; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/WebKit/chromium/src/FrameLoaderClientImpl.cpp new file mode 100644 index 0000000..3ca8e8d --- /dev/null +++ b/WebKit/chromium/src/FrameLoaderClientImpl.cpp @@ -0,0 +1,1469 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "FrameLoaderClientImpl.h" + +#include "Chrome.h" +#include "CString.h" +#include "Document.h" +#include "DocumentLoader.h" +#include "FormState.h" +#include "FrameLoader.h" +#include "FrameLoadRequest.h" +#include "HitTestResult.h" +#include "HTMLAppletElement.h" +#include "HTMLFormElement.h" // needed by FormState.h +#include "HTMLNames.h" +#include "MIMETypeRegistry.h" +#include "MouseEvent.h" +#include "Page.h" +#include "PlatformString.h" +#include "PluginData.h" +#include "PluginDataChromium.h" +#include "StringExtras.h" +#include "WebDataSourceImpl.h" +#include "WebDevToolsAgentPrivate.h" +#include "WebFormElement.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebMimeRegistry.h" +#include "WebNode.h" +#include "WebPlugin.h" +#include "WebPluginContainerImpl.h" +#include "WebPluginLoadObserver.h" +#include "WebPluginParams.h" +#include "WebSecurityOrigin.h" +#include "WebURL.h" +#include "WebURLError.h" +#include "WebVector.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" +#include "WindowFeatures.h" +#include "WrappedResourceRequest.h" +#include "WrappedResourceResponse.h" + +using namespace WebCore; + +namespace WebKit { + +// Domain for internal error codes. +static const char internalErrorDomain[] = "WebKit"; + +// An internal error code. Used to note a policy change error resulting from +// dispatchDecidePolicyForMIMEType not passing the PolicyUse option. +enum { + PolicyChangeError = -10000, +}; + +FrameLoaderClientImpl::FrameLoaderClientImpl(WebFrameImpl* frame) + : m_webFrame(frame) + , m_hasRepresentation(false) + , m_sentInitialResponseToPlugin(false) + , m_nextNavigationPolicy(WebNavigationPolicyIgnore) +{ +} + +FrameLoaderClientImpl::~FrameLoaderClientImpl() +{ +} + +void FrameLoaderClientImpl::frameLoaderDestroyed() +{ + // When the WebFrame was created, it had an extra reference given to it on + // behalf of the Frame. Since the WebFrame owns us, this extra ref also + // serves to keep us alive until the FrameLoader is done with us. The + // FrameLoader calls this method when it's going away. Therefore, we balance + // out that extra reference, which may cause 'this' to be deleted. + m_webFrame->closing(); + m_webFrame->deref(); +} + +void FrameLoaderClientImpl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) +{ + if (m_webFrame->client()) + m_webFrame->client()->didClearWindowObject(m_webFrame); + + WebViewImpl* webview = m_webFrame->viewImpl(); + if (webview->devToolsAgentPrivate()) + webview->devToolsAgentPrivate()->didClearWindowObject(m_webFrame); +} + +void FrameLoaderClientImpl::documentElementAvailable() +{ + if (m_webFrame->client()) + m_webFrame->client()->didCreateDocumentElement(m_webFrame); +} + +void FrameLoaderClientImpl::didCreateScriptContextForFrame() +{ + if (m_webFrame->client()) + m_webFrame->client()->didCreateScriptContext(m_webFrame); +} + +void FrameLoaderClientImpl::didDestroyScriptContextForFrame() +{ + if (m_webFrame->client()) + m_webFrame->client()->didDestroyScriptContext(m_webFrame); +} + +void FrameLoaderClientImpl::didCreateIsolatedScriptContext() +{ + if (m_webFrame->client()) + m_webFrame->client()->didCreateIsolatedScriptContext(m_webFrame); +} + +void FrameLoaderClientImpl::didPerformFirstNavigation() const +{ +} + +void FrameLoaderClientImpl::registerForIconNotification(bool) +{ +} + +void FrameLoaderClientImpl::didChangeScrollOffset() +{ + if (m_webFrame->client()) + m_webFrame->client()->didChangeScrollOffset(m_webFrame); +} + +bool FrameLoaderClientImpl::allowJavaScript(bool enabledPerSettings) +{ + if (m_webFrame->client()) + return m_webFrame->client()->allowScript(m_webFrame, enabledPerSettings); + + return enabledPerSettings; +} + +bool FrameLoaderClientImpl::hasWebView() const +{ + return m_webFrame->viewImpl(); +} + +bool FrameLoaderClientImpl::hasFrameView() const +{ + // The Mac port has this notion of a WebFrameView, which seems to be + // some wrapper around an NSView. Since our equivalent is HWND, I guess + // we have a "frameview" whenever we have the toplevel HWND. + return m_webFrame->viewImpl(); +} + +void FrameLoaderClientImpl::makeDocumentView() +{ + m_webFrame->createFrameView(); +} + +void FrameLoaderClientImpl::makeRepresentation(DocumentLoader*) +{ + m_hasRepresentation = true; +} + +void FrameLoaderClientImpl::forceLayout() +{ + // FIXME +} + +void FrameLoaderClientImpl::forceLayoutForNonHTML() +{ + // FIXME +} + +void FrameLoaderClientImpl::setCopiesOnScroll() +{ + // FIXME +} + +void FrameLoaderClientImpl::detachedFromParent2() +{ + // Nothing to do here. +} + +void FrameLoaderClientImpl::detachedFromParent3() +{ + // Close down the proxy. The purpose of this change is to make the + // call to ScriptController::clearWindowShell a no-op when called from + // Frame::pageDestroyed. Without this change, this call to clearWindowShell + // will cause a crash. If you remove/modify this, just ensure that you can + // go to a page and then navigate to a new page without getting any asserts + // or crashes. + m_webFrame->frame()->script()->proxy()->clearForClose(); + + // Stop communicating with the WebFrameClient at this point since we are no + // longer associated with the Page. + m_webFrame->dropClient(); +} + +// This function is responsible for associating the |identifier| with a given +// subresource load. The following functions that accept an |identifier| are +// called for each subresource, so they should not be dispatched to the +// WebFrame. +void FrameLoaderClientImpl::assignIdentifierToInitialRequest( + unsigned long identifier, DocumentLoader* loader, + const ResourceRequest& request) +{ + if (m_webFrame->client()) { + WrappedResourceRequest webreq(request); + m_webFrame->client()->assignIdentifierToRequest( + m_webFrame, identifier, webreq); + } +} + +// If the request being loaded by |loader| is a frame, update the ResourceType. +// A subresource in this context is anything other than a frame -- +// this includes images and xmlhttp requests. It is important to note that a +// subresource is NOT limited to stuff loaded through the frame's subresource +// loader. Synchronous xmlhttp requests for example, do not go through the +// subresource loader, but we still label them as TargetIsSubResource. +// +// The important edge cases to consider when modifying this function are +// how synchronous resource loads are treated during load/unload threshold. +static void setTargetTypeFromLoader(ResourceRequest& request, DocumentLoader* loader) +{ + if (loader == loader->frameLoader()->provisionalDocumentLoader()) { + ResourceRequest::TargetType type; + if (loader->frameLoader()->isLoadingMainFrame()) + type = ResourceRequest::TargetIsMainFrame; + else + type = ResourceRequest::TargetIsSubframe; + request.setTargetType(type); + } +} + +void FrameLoaderClientImpl::dispatchWillSendRequest( + DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, + const ResourceResponse& redirectResponse) +{ + if (loader) { + // We want to distinguish between a request for a document to be loaded into + // the main frame, a sub-frame, or the sub-objects in that document. + setTargetTypeFromLoader(request, loader); + + // Avoid repeating a form submission when navigating back or forward. + if (loader == loader->frameLoader()->provisionalDocumentLoader() + && request.httpMethod() == "POST" + && isBackForwardLoadType(loader->frameLoader()->loadType())) + request.setCachePolicy(ReturnCacheDataDontLoad); + } + + // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document + // with no URL. We don't like that, so we'll rename it to about:blank. + if (request.url().isEmpty()) + request.setURL(KURL(ParsedURLString, "about:blank")); + if (request.firstPartyForCookies().isEmpty()) + request.setFirstPartyForCookies(KURL(ParsedURLString, "about:blank")); + + // Give the WebFrameClient a crack at the request. + if (m_webFrame->client()) { + WrappedResourceRequest webreq(request); + WrappedResourceResponse webresp(redirectResponse); + m_webFrame->client()->willSendRequest( + m_webFrame, identifier, webreq, webresp); + } +} + +bool FrameLoaderClientImpl::shouldUseCredentialStorage( + DocumentLoader*, unsigned long identifier) +{ + // FIXME + // Intended to pass through to a method on the resource load delegate. + // If implemented, that method controls whether the browser should ask the + // networking layer for a stored default credential for the page (say from + // the Mac OS keychain). If the method returns false, the user should be + // presented with an authentication challenge whether or not the networking + // layer has a credential stored. + // This returns true for backward compatibility: the ability to override the + // system credential store is new. (Actually, not yet fully implemented in + // WebKit, as of this writing.) + return true; +} + +void FrameLoaderClientImpl::dispatchDidReceiveAuthenticationChallenge( + DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) +{ + // FIXME +} + +void FrameLoaderClientImpl::dispatchDidCancelAuthenticationChallenge( + DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) +{ + // FIXME +} + +void FrameLoaderClientImpl::dispatchDidReceiveResponse(DocumentLoader* loader, + unsigned long identifier, + const ResourceResponse& response) +{ + if (m_webFrame->client()) { + WrappedResourceResponse webresp(response); + m_webFrame->client()->didReceiveResponse(m_webFrame, identifier, webresp); + } +} + +void FrameLoaderClientImpl::dispatchDidReceiveContentLength( + DocumentLoader* loader, + unsigned long identifier, + int lengthReceived) +{ +} + +// Called when a particular resource load completes +void FrameLoaderClientImpl::dispatchDidFinishLoading(DocumentLoader* loader, + unsigned long identifier) +{ + if (m_webFrame->client()) + m_webFrame->client()->didFinishResourceLoad(m_webFrame, identifier); +} + +void FrameLoaderClientImpl::dispatchDidFailLoading(DocumentLoader* loader, + unsigned long identifier, + const ResourceError& error) +{ + if (m_webFrame->client()) + m_webFrame->client()->didFailResourceLoad(m_webFrame, identifier, error); +} + +void FrameLoaderClientImpl::dispatchDidFinishDocumentLoad() +{ + // A frame may be reused. This call ensures we don't hold on to our password + // listeners and their associated HTMLInputElements. + m_webFrame->clearPasswordListeners(); + + if (m_webFrame->client()) + m_webFrame->client()->didFinishDocumentLoad(m_webFrame); +} + +bool FrameLoaderClientImpl::dispatchDidLoadResourceFromMemoryCache( + DocumentLoader* loader, + const ResourceRequest& request, + const ResourceResponse& response, + int length) +{ + if (m_webFrame->client()) { + WrappedResourceRequest webreq(request); + WrappedResourceResponse webresp(response); + m_webFrame->client()->didLoadResourceFromMemoryCache( + m_webFrame, webreq, webresp); + } + return false; // Do not suppress remaining notifications +} + +void FrameLoaderClientImpl::dispatchDidLoadResourceByXMLHttpRequest( + unsigned long identifier, + const ScriptString& source) +{ +} + +void FrameLoaderClientImpl::dispatchDidHandleOnloadEvents() +{ + if (m_webFrame->client()) + m_webFrame->client()->didHandleOnloadEvents(m_webFrame); +} + +// Redirect Tracking +// ================= +// We want to keep track of the chain of redirects that occur during page +// loading. There are two types of redirects, server redirects which are HTTP +// response codes, and client redirects which are document.location= and meta +// refreshes. +// +// This outlines the callbacks that we get in different redirect situations, +// and how each call modifies the redirect chain. +// +// Normal page load +// ---------------- +// dispatchDidStartProvisionalLoad() -> adds URL to the redirect list +// dispatchDidCommitLoad() -> DISPATCHES & clears list +// +// Server redirect (success) +// ------------------------- +// dispatchDidStartProvisionalLoad() -> adds source URL +// dispatchDidReceiveServerRedirectForProvisionalLoad() -> adds dest URL +// dispatchDidCommitLoad() -> DISPATCHES +// +// Client redirect (success) +// ------------------------- +// (on page) +// dispatchWillPerformClientRedirect() -> saves expected redirect +// dispatchDidStartProvisionalLoad() -> appends redirect source (since +// it matches the expected redirect) +// and the current page as the dest) +// dispatchDidCancelClientRedirect() -> clears expected redirect +// dispatchDidCommitLoad() -> DISPATCHES +// +// Client redirect (cancelled) +// (e.g meta-refresh trumped by manual doc.location change, or just cancelled +// because a link was clicked that requires the meta refresh to be rescheduled +// (the SOURCE URL may have changed). +// --------------------------- +// dispatchDidCancelClientRedirect() -> clears expected redirect +// dispatchDidStartProvisionalLoad() -> adds only URL to redirect list +// dispatchDidCommitLoad() -> DISPATCHES & clears list +// rescheduled ? dispatchWillPerformClientRedirect() -> saves expected redirect +// : nothing + +// Client redirect (failure) +// ------------------------- +// (on page) +// dispatchWillPerformClientRedirect() -> saves expected redirect +// dispatchDidStartProvisionalLoad() -> appends redirect source (since +// it matches the expected redirect) +// and the current page as the dest) +// dispatchDidCancelClientRedirect() +// dispatchDidFailProvisionalLoad() +// +// Load 1 -> Server redirect to 2 -> client redirect to 3 -> server redirect to 4 +// ------------------------------------------------------------------------------ +// dispatchDidStartProvisionalLoad() -> adds source URL 1 +// dispatchDidReceiveServerRedirectForProvisionalLoad() -> adds dest URL 2 +// dispatchDidCommitLoad() -> DISPATCHES 1+2 +// -- begin client redirect and NEW DATA SOURCE +// dispatchWillPerformClientRedirect() -> saves expected redirect +// dispatchDidStartProvisionalLoad() -> appends URL 2 and URL 3 +// dispatchDidReceiveServerRedirectForProvisionalLoad() -> appends destination URL 4 +// dispatchDidCancelClientRedirect() -> clears expected redirect +// dispatchDidCommitLoad() -> DISPATCHES +// +// Interesting case with multiple location changes involving anchors. +// Load page 1 containing future client-redirect (back to 1, e.g meta refresh) > Click +// on a link back to the same page (i.e an anchor href) > +// client-redirect finally fires (with new source, set to 1#anchor) +// ----------------------------------------------------------------------------- +// dispatchWillPerformClientRedirect(non-zero 'interval' param) -> saves expected redirect +// -- click on anchor href +// dispatchDidCancelClientRedirect() -> clears expected redirect +// dispatchDidStartProvisionalLoad() -> adds 1#anchor source +// dispatchDidCommitLoad() -> DISPATCHES 1#anchor +// dispatchWillPerformClientRedirect() -> saves exp. source (1#anchor) +// -- redirect timer fires +// dispatchDidStartProvisionalLoad() -> appends 1#anchor (src) and 1 (dest) +// dispatchDidCancelClientRedirect() -> clears expected redirect +// dispatchDidCommitLoad() -> DISPATCHES 1#anchor + 1 +// +void FrameLoaderClientImpl::dispatchDidReceiveServerRedirectForProvisionalLoad() +{ + WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl(); + if (!ds) { + // Got a server redirect when there is no provisional DS! + ASSERT_NOT_REACHED(); + return; + } + + // The server redirect may have been blocked. + if (ds->request().isNull()) + return; + + // A provisional load should have started already, which should have put an + // entry in our redirect chain. + ASSERT(ds->hasRedirectChain()); + + // The URL of the destination is on the provisional data source. We also need + // to update the redirect chain to account for this addition (we do this + // before the callback so the callback can look at the redirect chain to see + // what happened). + ds->appendRedirect(ds->request().url()); + + if (m_webFrame->client()) + m_webFrame->client()->didReceiveServerRedirectForProvisionalLoad(m_webFrame); +} + +// Called on both success and failure of a client redirect. +void FrameLoaderClientImpl::dispatchDidCancelClientRedirect() +{ + // No longer expecting a client redirect. + if (m_webFrame->client()) { + m_expectedClientRedirectSrc = KURL(); + m_expectedClientRedirectDest = KURL(); + m_webFrame->client()->didCancelClientRedirect(m_webFrame); + } + + // No need to clear the redirect chain, since that data source has already + // been deleted by the time this function is called. +} + +void FrameLoaderClientImpl::dispatchWillPerformClientRedirect( + const KURL& url, + double interval, + double fireDate) +{ + // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a + // redirect and the source item should be added as the start of the chain. + m_expectedClientRedirectSrc = m_webFrame->url(); + m_expectedClientRedirectDest = url; + + // FIXME: bug 1135512. Webkit does not properly notify us of cancelling + // http > file client redirects. Since the FrameLoader's policy is to never + // carry out such a navigation anyway, the best thing we can do for now to + // not get confused is ignore this notification. + if (m_expectedClientRedirectDest.isLocalFile() + && m_expectedClientRedirectSrc.protocolInHTTPFamily()) { + m_expectedClientRedirectSrc = KURL(); + m_expectedClientRedirectDest = KURL(); + return; + } + + if (m_webFrame->client()) { + m_webFrame->client()->willPerformClientRedirect( + m_webFrame, + m_expectedClientRedirectSrc, + m_expectedClientRedirectDest, + static_cast<unsigned int>(interval), + static_cast<unsigned int>(fireDate)); + } +} + +void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage() +{ + // Anchor fragment navigations are not normal loads, so we need to synthesize + // some events for our delegate. + WebViewImpl* webView = m_webFrame->viewImpl(); + + // Flag of whether frame loader is completed. Generate didStartLoading and + // didStopLoading only when loader is completed so that we don't fire + // them for fragment redirection that happens in window.onload handler. + // See https://bugs.webkit.org/show_bug.cgi?id=31838 + bool loaderCompleted = + !m_webFrame->frame()->page()->mainFrame()->loader()->isLoading(); + + // Generate didStartLoading if loader is completed. + if (webView->client() && loaderCompleted) + webView->client()->didStartLoading(); + + WebDataSourceImpl* ds = m_webFrame->dataSourceImpl(); + ASSERT(ds); // Should not be null when navigating to a reference fragment! + if (ds) { + KURL url = ds->request().url(); + KURL chainEnd; + if (ds->hasRedirectChain()) { + chainEnd = ds->endOfRedirectChain(); + ds->clearRedirectChain(); + } + + // Figure out if this location change is because of a JS-initiated + // client redirect (e.g onload/setTimeout document.location.href=). + // FIXME: (bugs 1085325, 1046841) We don't get proper redirect + // performed/cancelled notifications across anchor navigations, so the + // other redirect-tracking code in this class (see + // dispatch*ClientRedirect() and dispatchDidStartProvisionalLoad) is + // insufficient to catch and properly flag these transitions. Once a + // proper fix for this bug is identified and applied the following + // block may no longer be required. + bool wasClientRedirect = + (url == m_expectedClientRedirectDest && chainEnd == m_expectedClientRedirectSrc) + || !m_webFrame->isProcessingUserGesture(); + + if (wasClientRedirect) { + if (m_webFrame->client()) + m_webFrame->client()->didCompleteClientRedirect(m_webFrame, chainEnd); + ds->appendRedirect(chainEnd); + // Make sure we clear the expected redirect since we just effectively + // completed it. + m_expectedClientRedirectSrc = KURL(); + m_expectedClientRedirectDest = KURL(); + } + + // Regardless of how we got here, we are navigating to a URL so we need to + // add it to the redirect chain. + ds->appendRedirect(url); + } + + bool isNewNavigation; + webView->didCommitLoad(&isNewNavigation); + if (m_webFrame->client()) + m_webFrame->client()->didChangeLocationWithinPage(m_webFrame, isNewNavigation); + + // Generate didStopLoading if loader is completed. + if (webView->client() && loaderCompleted) + webView->client()->didStopLoading(); +} + +void FrameLoaderClientImpl::dispatchDidPushStateWithinPage() +{ + // FIXME +} + +void FrameLoaderClientImpl::dispatchDidReplaceStateWithinPage() +{ + // FIXME +} + +void FrameLoaderClientImpl::dispatchDidPopStateWithinPage() +{ + // FIXME +} + +void FrameLoaderClientImpl::dispatchWillClose() +{ + if (m_webFrame->client()) + m_webFrame->client()->willClose(m_webFrame); +} + +void FrameLoaderClientImpl::dispatchDidReceiveIcon() +{ + // The icon database is disabled, so this should never be called. + ASSERT_NOT_REACHED(); +} + +void FrameLoaderClientImpl::dispatchDidStartProvisionalLoad() +{ + // In case a redirect occurs, we need this to be set so that the redirect + // handling code can tell where the redirect came from. Server redirects + // will occur on the provisional load, so we need to keep track of the most + // recent provisional load URL. + // See dispatchDidReceiveServerRedirectForProvisionalLoad. + WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl(); + if (!ds) { + ASSERT_NOT_REACHED(); + return; + } + KURL url = ds->request().url(); + + // Since the provisional load just started, we should have not gotten + // any redirects yet. + ASSERT(!ds->hasRedirectChain()); + + // If this load is what we expected from a client redirect, treat it as a + // redirect from that original page. The expected redirect urls will be + // cleared by DidCancelClientRedirect. + bool completingClientRedirect = false; + if (m_expectedClientRedirectSrc.isValid()) { + // m_expectedClientRedirectDest could be something like + // "javascript:history.go(-1)" thus we need to exclude url starts with + // "javascript:". See bug: 1080873 + ASSERT(m_expectedClientRedirectDest.protocolIs("javascript") + || m_expectedClientRedirectDest == url); + ds->appendRedirect(m_expectedClientRedirectSrc); + completingClientRedirect = true; + } + ds->appendRedirect(url); + + if (m_webFrame->client()) { + // Whatever information didCompleteClientRedirect contains should only + // be considered relevant until the next provisional load has started. + // So we first tell the client that the load started, and then tell it + // about the client redirect the load is responsible for completing. + m_webFrame->client()->didStartProvisionalLoad(m_webFrame); + if (completingClientRedirect) { + m_webFrame->client()->didCompleteClientRedirect( + m_webFrame, m_expectedClientRedirectSrc); + } + } +} + +void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title) +{ + if (m_webFrame->client()) + m_webFrame->client()->didReceiveTitle(m_webFrame, title); +} + +void FrameLoaderClientImpl::dispatchDidCommitLoad() +{ + WebViewImpl* webview = m_webFrame->viewImpl(); + bool isNewNavigation; + webview->didCommitLoad(&isNewNavigation); + + if (m_webFrame->client()) + m_webFrame->client()->didCommitProvisionalLoad(m_webFrame, isNewNavigation); + + if (webview->devToolsAgentPrivate()) + webview->devToolsAgentPrivate()->didCommitProvisionalLoad(m_webFrame, isNewNavigation); +} + +void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad( + const ResourceError& error) +{ + + // If a policy change occured, then we do not want to inform the plugin + // delegate. See http://b/907789 for details. FIXME: This means the + // plugin won't receive NPP_URLNotify, which seems like it could result in + // a memory leak in the plugin!! + if (error.domain() == internalErrorDomain + && error.errorCode() == PolicyChangeError) { + m_webFrame->didFail(cancelledError(error.failingURL()), true); + return; + } + + OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver(); + m_webFrame->didFail(error, true); + if (observer) + observer->didFailLoading(error); +} + +void FrameLoaderClientImpl::dispatchDidFailLoad(const ResourceError& error) +{ + OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver(); + m_webFrame->didFail(error, false); + if (observer) + observer->didFailLoading(error); + + // Don't clear the redirect chain, this will happen in the middle of client + // redirects, and we need the context. The chain will be cleared when the + // provisional load succeeds or fails, not the "real" one. +} + +void FrameLoaderClientImpl::dispatchDidFinishLoad() +{ + OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver(); + + if (m_webFrame->client()) + m_webFrame->client()->didFinishLoad(m_webFrame); + + if (observer) + observer->didFinishLoading(); + + // Don't clear the redirect chain, this will happen in the middle of client + // redirects, and we need the context. The chain will be cleared when the + // provisional load succeeds or fails, not the "real" one. +} + +void FrameLoaderClientImpl::dispatchDidFirstLayout() +{ +} + +void FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout() +{ + // FIXME: called when webkit finished layout of a page that was visually non-empty. + // All resources have not necessarily finished loading. +} + +Frame* FrameLoaderClientImpl::dispatchCreatePage() +{ + struct WindowFeatures features; + Page* newPage = m_webFrame->frame()->page()->chrome()->createWindow( + m_webFrame->frame(), FrameLoadRequest(), features); + + // Make sure that we have a valid disposition. This should have been set in + // the preceeding call to dispatchDecidePolicyForNewWindowAction. + ASSERT(m_nextNavigationPolicy != WebNavigationPolicyIgnore); + WebNavigationPolicy policy = m_nextNavigationPolicy; + m_nextNavigationPolicy = WebNavigationPolicyIgnore; + + // createWindow can return null (e.g., popup blocker denies the window). + if (!newPage) + return 0; + + WebViewImpl::fromPage(newPage)->setInitialNavigationPolicy(policy); + return newPage->mainFrame(); +} + +void FrameLoaderClientImpl::dispatchShow() +{ + WebViewImpl* webView = m_webFrame->viewImpl(); + if (webView && webView->client()) + webView->client()->show(webView->initialNavigationPolicy()); +} + +static bool shouldTreatAsAttachment(const ResourceResponse& response) +{ + const String& contentDisposition = + response.httpHeaderField("Content-Disposition"); + if (contentDisposition.isEmpty()) + return false; + + // Some broken sites just send + // Content-Disposition: ; filename="file" + // screen those out here. + if (contentDisposition.startsWith(";")) + return false; + + if (contentDisposition.startsWith("inline", false)) + return false; + + // Some broken sites just send + // Content-Disposition: filename="file" + // without a disposition token... screen those out. + if (contentDisposition.startsWith("filename", false)) + return false; + + // Also in use is Content-Disposition: name="file" + if (contentDisposition.startsWith("name", false)) + return false; + + // We have a content-disposition of "attachment" or unknown. + // RFC 2183, section 2.8 says that an unknown disposition + // value should be treated as "attachment" + return true; +} + +void FrameLoaderClientImpl::dispatchDecidePolicyForMIMEType( + FramePolicyFunction function, + const String& mimeType, + const ResourceRequest&) +{ + const ResourceResponse& response = + m_webFrame->frame()->loader()->activeDocumentLoader()->response(); + + PolicyAction action; + + int statusCode = response.httpStatusCode(); + if (statusCode == 204 || statusCode == 205) { + // The server does not want us to replace the page contents. + action = PolicyIgnore; + } else if (shouldTreatAsAttachment(response)) { + // The server wants us to download instead of replacing the page contents. + // Downloading is handled by the embedder, but we still get the initial + // response so that we can ignore it and clean up properly. + action = PolicyIgnore; + } else if (!canShowMIMEType(mimeType)) { + // Make sure that we can actually handle this type internally. + action = PolicyIgnore; + } else { + // OK, we will render this page. + action = PolicyUse; + } + + // NOTE: PolicyChangeError will be generated when action is not PolicyUse. + (m_webFrame->frame()->loader()->policyChecker()->*function)(action); +} + +void FrameLoaderClientImpl::dispatchDecidePolicyForNewWindowAction( + FramePolicyFunction function, + const NavigationAction& action, + const ResourceRequest& request, + PassRefPtr<FormState> formState, + const String& frameName) +{ + WebNavigationPolicy navigationPolicy; + if (!actionSpecifiesNavigationPolicy(action, &navigationPolicy)) + navigationPolicy = WebNavigationPolicyNewForegroundTab; + + PolicyAction policyAction; + if (navigationPolicy == WebNavigationPolicyDownload) + policyAction = PolicyDownload; + else { + policyAction = PolicyUse; + + // Remember the disposition for when dispatchCreatePage is called. It is + // unfortunate that WebCore does not provide us with any context when + // creating or showing the new window that would allow us to avoid having + // to keep this state. + m_nextNavigationPolicy = navigationPolicy; + } + (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction); +} + +void FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction( + FramePolicyFunction function, + const NavigationAction& action, + const ResourceRequest& request, + PassRefPtr<FormState> formState) { + PolicyAction policyAction = PolicyIgnore; + + // It is valid for this function to be invoked in code paths where the + // the webview is closed. + // The null check here is to fix a crash that seems strange + // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). + if (m_webFrame->client() && !request.url().isNull()) { + WebNavigationPolicy navigationPolicy = WebNavigationPolicyCurrentTab; + actionSpecifiesNavigationPolicy(action, &navigationPolicy); + + // Give the delegate a chance to change the navigation policy. + const WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl(); + if (ds) { + KURL url = ds->request().url(); + if (url.protocolIs(backForwardNavigationScheme)) { + handleBackForwardNavigation(url); + navigationPolicy = WebNavigationPolicyIgnore; + } else { + bool isRedirect = ds->hasRedirectChain(); + + WebNavigationType webnavType = + WebDataSourceImpl::toWebNavigationType(action.type()); + + RefPtr<Node> node; + for (const Event* event = action.event(); event; event = event->underlyingEvent()) { + if (event->isMouseEvent()) { + const MouseEvent* mouseEvent = + static_cast<const MouseEvent*>(event); + node = m_webFrame->frame()->eventHandler()->hitTestResultAtPoint( + mouseEvent->absoluteLocation(), false).innerNonSharedNode(); + break; + } + } + WebNode originatingNode(node); + + navigationPolicy = m_webFrame->client()->decidePolicyForNavigation( + m_webFrame, ds->request(), webnavType, originatingNode, + navigationPolicy, isRedirect); + } + } + + if (navigationPolicy == WebNavigationPolicyCurrentTab) + policyAction = PolicyUse; + else if (navigationPolicy == WebNavigationPolicyDownload) + policyAction = PolicyDownload; + else { + if (navigationPolicy != WebNavigationPolicyIgnore) { + WrappedResourceRequest webreq(request); + m_webFrame->client()->loadURLExternally(m_webFrame, webreq, navigationPolicy); + } + policyAction = PolicyIgnore; + } + } + + (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction); +} + +void FrameLoaderClientImpl::cancelPolicyCheck() +{ + // FIXME +} + +void FrameLoaderClientImpl::dispatchUnableToImplementPolicy(const ResourceError& error) +{ + m_webFrame->client()->unableToImplementPolicyWithError(m_webFrame, error); +} + +void FrameLoaderClientImpl::dispatchWillSubmitForm(FramePolicyFunction function, + PassRefPtr<FormState> formState) +{ + if (m_webFrame->client()) + m_webFrame->client()->willSubmitForm(m_webFrame, WebFormElement(formState->form())); + (m_webFrame->frame()->loader()->policyChecker()->*function)(PolicyUse); +} + +void FrameLoaderClientImpl::dispatchDidLoadMainResource(DocumentLoader*) +{ + // FIXME +} + +void FrameLoaderClientImpl::revertToProvisionalState(DocumentLoader*) +{ + m_hasRepresentation = true; +} + +void FrameLoaderClientImpl::setMainDocumentError(DocumentLoader*, + const ResourceError& error) +{ + if (m_pluginWidget.get()) { + if (m_sentInitialResponseToPlugin) { + m_pluginWidget->didFailLoading(error); + m_sentInitialResponseToPlugin = false; + } + m_pluginWidget = 0; + } +} + +void FrameLoaderClientImpl::postProgressStartedNotification() +{ + WebViewImpl* webview = m_webFrame->viewImpl(); + if (webview && webview->client()) + webview->client()->didStartLoading(); +} + +void FrameLoaderClientImpl::postProgressEstimateChangedNotification() +{ + // FIXME +} + +void FrameLoaderClientImpl::postProgressFinishedNotification() +{ + // FIXME: why might the webview be null? http://b/1234461 + WebViewImpl* webview = m_webFrame->viewImpl(); + if (webview && webview->client()) + webview->client()->didStopLoading(); +} + +void FrameLoaderClientImpl::setMainFrameDocumentReady(bool ready) +{ + // FIXME +} + +// Creates a new connection and begins downloading from that (contrast this +// with |download|). +void FrameLoaderClientImpl::startDownload(const ResourceRequest& request) +{ + if (m_webFrame->client()) { + WrappedResourceRequest webreq(request); + m_webFrame->client()->loadURLExternally( + m_webFrame, webreq, WebNavigationPolicyDownload); + } +} + +void FrameLoaderClientImpl::willChangeTitle(DocumentLoader*) +{ + // FIXME +} + +void FrameLoaderClientImpl::didChangeTitle(DocumentLoader*) +{ + // FIXME +} + +// Called whenever data is received. +void FrameLoaderClientImpl::committedLoad(DocumentLoader* loader, const char* data, int length) +{ + if (!m_pluginWidget.get()) { + if (m_webFrame->client()) { + bool preventDefault = false; + m_webFrame->client()->didReceiveDocumentData(m_webFrame, data, length, preventDefault); + if (!preventDefault) + m_webFrame->commitDocumentData(data, length); + } + } + + // If we are sending data to MediaDocument, we should stop here + // and cancel the request. + if (m_webFrame->frame()->document() + && m_webFrame->frame()->document()->isMediaDocument()) + loader->cancelMainResourceLoad(pluginWillHandleLoadError(loader->response())); + + // The plugin widget could have been created in the m_webFrame->DidReceiveData + // function. + if (m_pluginWidget.get()) { + if (!m_sentInitialResponseToPlugin) { + m_sentInitialResponseToPlugin = true; + m_pluginWidget->didReceiveResponse( + m_webFrame->frame()->loader()->activeDocumentLoader()->response()); + } + m_pluginWidget->didReceiveData(data, length); + } +} + +void FrameLoaderClientImpl::finishedLoading(DocumentLoader* dl) +{ + if (m_pluginWidget.get()) { + m_pluginWidget->didFinishLoading(); + m_pluginWidget = 0; + m_sentInitialResponseToPlugin = false; + } else { + // This is necessary to create an empty document. See bug 634004. + // However, we only want to do this if makeRepresentation has been called, to + // match the behavior on the Mac. + if (m_hasRepresentation) + dl->frameLoader()->setEncoding("", false); + } +} + +void FrameLoaderClientImpl::updateGlobalHistory() +{ +} + +void FrameLoaderClientImpl::updateGlobalHistoryRedirectLinks() +{ +} + +bool FrameLoaderClientImpl::shouldGoToHistoryItem(HistoryItem*) const +{ + // FIXME + return true; +} + +void FrameLoaderClientImpl::dispatchDidAddBackForwardItem(HistoryItem*) const +{ +} + +void FrameLoaderClientImpl::dispatchDidRemoveBackForwardItem(HistoryItem*) const +{ +} + +void FrameLoaderClientImpl::dispatchDidChangeBackForwardIndex() const +{ +} + +void FrameLoaderClientImpl::didDisplayInsecureContent() +{ + if (m_webFrame->client()) + m_webFrame->client()->didDisplayInsecureContent(m_webFrame); +} + +void FrameLoaderClientImpl::didRunInsecureContent(SecurityOrigin* origin) +{ + if (m_webFrame->client()) + m_webFrame->client()->didRunInsecureContent(m_webFrame, WebSecurityOrigin(origin)); +} + +ResourceError FrameLoaderClientImpl::blockedError(const ResourceRequest&) +{ + // FIXME + return ResourceError(); +} + +ResourceError FrameLoaderClientImpl::cancelledError(const ResourceRequest& request) +{ + if (!m_webFrame->client()) + return ResourceError(); + + return m_webFrame->client()->cancelledError( + m_webFrame, WrappedResourceRequest(request)); +} + +ResourceError FrameLoaderClientImpl::cannotShowURLError(const ResourceRequest& request) +{ + if (!m_webFrame->client()) + return ResourceError(); + + return m_webFrame->client()->cannotHandleRequestError( + m_webFrame, WrappedResourceRequest(request)); +} + +ResourceError FrameLoaderClientImpl::interruptForPolicyChangeError( + const ResourceRequest& request) +{ + return ResourceError(internalErrorDomain, PolicyChangeError, + request.url().string(), String()); +} + +ResourceError FrameLoaderClientImpl::cannotShowMIMETypeError(const ResourceResponse&) +{ + // FIXME + return ResourceError(); +} + +ResourceError FrameLoaderClientImpl::fileDoesNotExistError(const ResourceResponse&) +{ + // FIXME + return ResourceError(); +} + +ResourceError FrameLoaderClientImpl::pluginWillHandleLoadError(const ResourceResponse&) +{ + // FIXME + return ResourceError(); +} + +bool FrameLoaderClientImpl::shouldFallBack(const ResourceError& error) +{ + // This method is called when we fail to load the URL for an <object> tag + // that has fallback content (child elements) and is being loaded as a frame. + // The error parameter indicates the reason for the load failure. + // We should let the fallback content load only if this wasn't a cancelled + // request. + // Note: The mac version also has a case for "WebKitErrorPluginWillHandleLoad" + ResourceError c = cancelledError(ResourceRequest()); + return error.errorCode() != c.errorCode() || error.domain() != c.domain(); +} + +bool FrameLoaderClientImpl::canHandleRequest(const ResourceRequest& request) const +{ + return m_webFrame->client()->canHandleRequest( + m_webFrame, WrappedResourceRequest(request)); +} + +bool FrameLoaderClientImpl::canShowMIMEType(const String& mimeType) const +{ + // This method is called to determine if the media type can be shown + // "internally" (i.e. inside the browser) regardless of whether or not the + // browser or a plugin is doing the rendering. + + // mimeType strings are supposed to be ASCII, but if they are not for some + // reason, then it just means that the mime type will fail all of these "is + // supported" checks and go down the path of an unhandled mime type. + if (webKitClient()->mimeRegistry()->supportsMIMEType(mimeType) == WebMimeRegistry::IsSupported) + return true; + + // If Chrome is started with the --disable-plugins switch, pluginData is null. + PluginData* pluginData = m_webFrame->frame()->page()->pluginData(); + + // See if the type is handled by an installed plugin, if so, we can show it. + // FIXME: (http://b/1085524) This is the place to stick a preference to + // disable full page plugins (optionally for certain types!) + return !mimeType.isEmpty() && pluginData && pluginData->supportsMimeType(mimeType); +} + +bool FrameLoaderClientImpl::representationExistsForURLScheme(const String&) const +{ + // FIXME + return false; +} + +String FrameLoaderClientImpl::generatedMIMETypeForURLScheme(const String& scheme) const +{ + // This appears to generate MIME types for protocol handlers that are handled + // internally. The only place I can find in the WebKit code that uses this + // function is WebView::registerViewClass, where it is used as part of the + // process by which custom view classes for certain document representations + // are registered. + String mimeType("x-apple-web-kit/"); + mimeType.append(scheme.lower()); + return mimeType; +} + +void FrameLoaderClientImpl::frameLoadCompleted() +{ + // FIXME: the mac port also conditionally calls setDrawsBackground:YES on + // it's ScrollView here. + + // This comment from the Mac port: + // Note: Can be called multiple times. + // Even if already complete, we might have set a previous item on a frame that + // didn't do any data loading on the past transaction. Make sure to clear these out. + + // FIXME: setPreviousHistoryItem() no longer exists. http://crbug.com/8566 + // m_webFrame->frame()->loader()->setPreviousHistoryItem(0); +} + +void FrameLoaderClientImpl::saveViewStateToItem(HistoryItem*) +{ + // FIXME +} + +void FrameLoaderClientImpl::restoreViewState() +{ + // FIXME: probably scrolls to last position when you go back or forward +} + +void FrameLoaderClientImpl::provisionalLoadStarted() +{ + // FIXME: On mac, this does various caching stuff +} + +void FrameLoaderClientImpl::didFinishLoad() +{ + OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver(); + if (observer) + observer->didFinishLoading(); +} + +void FrameLoaderClientImpl::prepareForDataSourceReplacement() +{ + // FIXME +} + +PassRefPtr<DocumentLoader> FrameLoaderClientImpl::createDocumentLoader( + const ResourceRequest& request, + const SubstituteData& data) +{ + RefPtr<WebDataSourceImpl> ds = WebDataSourceImpl::create(request, data); + if (m_webFrame->client()) + m_webFrame->client()->didCreateDataSource(m_webFrame, ds.get()); + return ds.release(); +} + +void FrameLoaderClientImpl::setTitle(const String& title, const KURL& url) +{ + // FIXME: inform consumer of changes to the title. +} + +String FrameLoaderClientImpl::userAgent(const KURL& url) +{ + return webKitClient()->userAgent(url); +} + +void FrameLoaderClientImpl::savePlatformDataToCachedFrame(CachedFrame*) +{ + // The page cache should be disabled. + ASSERT_NOT_REACHED(); +} + +void FrameLoaderClientImpl::transitionToCommittedFromCachedFrame(CachedFrame*) +{ + ASSERT_NOT_REACHED(); +} + +// Called when the FrameLoader goes into a state in which a new page load +// will occur. +void FrameLoaderClientImpl::transitionToCommittedForNewPage() +{ + makeDocumentView(); +} + +bool FrameLoaderClientImpl::canCachePage() const +{ + // Since we manage the cache, always report this page as non-cacheable to + // FrameLoader. + return false; +} + +// Downloading is handled in the browser process, not WebKit. If we get to this +// point, our download detection code in the ResourceDispatcherHost is broken! +void FrameLoaderClientImpl::download(ResourceHandle* handle, + const ResourceRequest& request, + const ResourceRequest& initialRequest, + const ResourceResponse& response) +{ + ASSERT_NOT_REACHED(); +} + +PassRefPtr<Frame> FrameLoaderClientImpl::createFrame( + const KURL& url, + const String& name, + HTMLFrameOwnerElement* ownerElement, + const String& referrer, + bool allowsScrolling, + int marginWidth, + int marginHeight) +{ + FrameLoadRequest frameRequest(ResourceRequest(url, referrer), name); + return m_webFrame->createChildFrame(frameRequest, ownerElement); +} + +PassRefPtr<Widget> FrameLoaderClientImpl::createPlugin( + const IntSize& size, // FIXME: how do we use this? + HTMLPlugInElement* element, + const KURL& url, + const Vector<String>& paramNames, + const Vector<String>& paramValues, + const String& mimeType, + bool loadManually) +{ +#if !PLATFORM(WIN_OS) + // WebCore asks us to make a plugin even if we don't have a + // registered handler, with a comment saying it's so we can display + // the broken plugin icon. In Chromium, we normally register a + // fallback plugin handler that allows you to install a missing + // plugin. Since we don't yet have a default plugin handler, we + // need to return null here rather than going through all the + // plugin-creation IPCs only to discover we don't have a plugin + // registered, which causes a crash. + // FIXME: remove me once we have a default plugin. + if (objectContentType(url, mimeType) != ObjectContentNetscapePlugin) + return 0; +#endif + + if (!m_webFrame->client()) + return 0; + + WebPluginParams params; + params.url = url; + params.mimeType = mimeType; + params.attributeNames = paramNames; + params.attributeValues = paramValues; + params.loadManually = loadManually; + + WebPlugin* webPlugin = m_webFrame->client()->createPlugin(m_webFrame, params); + if (!webPlugin) + return 0; + + // The container takes ownership of the WebPlugin. + RefPtr<WebPluginContainerImpl> container = + WebPluginContainerImpl::create(element, webPlugin); + + if (!webPlugin->initialize(container.get())) + return 0; + + // The element might have been removed during plugin initialization! + if (!element->renderer()) + return 0; + + return container; +} + +// This method gets called when a plugin is put in place of html content +// (e.g., acrobat reader). +void FrameLoaderClientImpl::redirectDataToPlugin(Widget* pluginWidget) +{ + m_pluginWidget = static_cast<WebPluginContainerImpl*>(pluginWidget); + ASSERT(m_pluginWidget.get()); +} + +PassRefPtr<Widget> FrameLoaderClientImpl::createJavaAppletWidget( + const IntSize& size, + HTMLAppletElement* element, + const KURL& /* baseURL */, + const Vector<String>& paramNames, + const Vector<String>& paramValues) +{ + return createPlugin(size, element, KURL(), paramNames, paramValues, + "application/x-java-applet", false); +} + +ObjectContentType FrameLoaderClientImpl::objectContentType( + const KURL& url, + const String& explicitMimeType) +{ + // This code is based on Apple's implementation from + // WebCoreSupport/WebFrameBridge.mm. + + String mimeType = explicitMimeType; + if (mimeType.isEmpty()) { + // Try to guess the MIME type based off the extension. + String filename = url.lastPathComponent(); + int extensionPos = filename.reverseFind('.'); + if (extensionPos >= 0) { + String extension = filename.substring(extensionPos + 1); + mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension); + if (mimeType.isEmpty()) { + // If there's no mimetype registered for the extension, check to see + // if a plugin can handle the extension. + mimeType = getPluginMimeTypeFromExtension(extension); + } + } + + if (mimeType.isEmpty()) + return ObjectContentFrame; + } + + if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) + return ObjectContentImage; + + // If Chrome is started with the --disable-plugins switch, pluginData is 0. + PluginData* pluginData = m_webFrame->frame()->page()->pluginData(); + if (pluginData && pluginData->supportsMimeType(mimeType)) + return ObjectContentNetscapePlugin; + + if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) + return ObjectContentFrame; + + return ObjectContentNone; +} + +String FrameLoaderClientImpl::overrideMediaType() const +{ + // FIXME + return String(); +} + +bool FrameLoaderClientImpl::actionSpecifiesNavigationPolicy( + const NavigationAction& action, + WebNavigationPolicy* policy) +{ + if ((action.type() != NavigationTypeLinkClicked) || !action.event()->isMouseEvent()) + return false; + + const MouseEvent* event = static_cast<const MouseEvent*>(action.event()); + return WebViewImpl::navigationPolicyFromMouseEvent( + event->button(), event->ctrlKey(), event->shiftKey(), event->altKey(), + event->metaKey(), policy); +} + +void FrameLoaderClientImpl::handleBackForwardNavigation(const KURL& url) +{ + ASSERT(url.protocolIs(backForwardNavigationScheme)); + + bool ok; + int offset = url.lastPathComponent().toIntStrict(&ok); + if (!ok) + return; + + WebViewImpl* webview = m_webFrame->viewImpl(); + if (webview->client()) + webview->client()->navigateBackForwardSoon(offset); +} + +PassOwnPtr<WebPluginLoadObserver> FrameLoaderClientImpl::pluginLoadObserver() +{ + WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader( + m_webFrame->frame()->loader()->activeDocumentLoader()); + return ds->releasePluginLoadObserver(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.h b/WebKit/chromium/src/FrameLoaderClientImpl.h new file mode 100644 index 0000000..4ddfe5f --- /dev/null +++ b/WebKit/chromium/src/FrameLoaderClientImpl.h @@ -0,0 +1,240 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 FrameLoaderClientImpl_h +#define FrameLoaderClientImpl_h + +// FIXME: remove this relative path once consumers from glue are removed. +#include "../public/WebNavigationPolicy.h" +#include "FrameLoaderClient.h" +#include "KURL.h" +#include <wtf/PassOwnPtr.h> +#include <wtf/RefPtr.h> + + +namespace WebKit { + +class WebFrameImpl; +class WebPluginContainerImpl; +class WebPluginLoadObserver; + +class FrameLoaderClientImpl : public WebCore::FrameLoaderClient { +public: + FrameLoaderClientImpl(WebFrameImpl* webFrame); + ~FrameLoaderClientImpl(); + + WebFrameImpl* webFrame() const { return m_webFrame; } + + // WebCore::FrameLoaderClient ---------------------------------------------- + + virtual void frameLoaderDestroyed(); + + // Notifies the WebView delegate that the JS window object has been cleared, + // giving it a chance to bind native objects to the window before script + // parsing begins. + virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); + virtual void documentElementAvailable(); + + // A frame's V8 context was created or destroyed. + virtual void didCreateScriptContextForFrame(); + virtual void didDestroyScriptContextForFrame(); + + // A context untied to a frame was created (through evaluateInNewContext). + // This context is not tied to the lifetime of its frame, and is destroyed + // in garbage collection. + virtual void didCreateIsolatedScriptContext(); + + virtual bool hasWebView() const; + virtual bool hasFrameView() const; + virtual void makeRepresentation(WebCore::DocumentLoader*); + virtual void forceLayout(); + virtual void forceLayoutForNonHTML(); + virtual void setCopiesOnScroll(); + virtual void detachedFromParent2(); + virtual void detachedFromParent3(); + virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); + virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse); + virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier); + virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); + virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); + virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); + virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); + virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); + virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&); + virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); + virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString&); + virtual void dispatchDidHandleOnloadEvents(); + virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); + virtual void dispatchDidCancelClientRedirect(); + virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); + virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); + virtual void dispatchWillClose(); + virtual void dispatchDidReceiveIcon(); + virtual void dispatchDidStartProvisionalLoad(); + virtual void dispatchDidReceiveTitle(const WebCore::String& title); + virtual void dispatchDidCommitLoad(); + virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); + virtual void dispatchDidFailLoad(const WebCore::ResourceError&); + virtual void dispatchDidFinishDocumentLoad(); + virtual void dispatchDidFinishLoad(); + virtual void dispatchDidFirstLayout(); + virtual void dispatchDidFirstVisuallyNonEmptyLayout(); + virtual WebCore::Frame* dispatchCreatePage(); + virtual void dispatchShow(); + virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction function, const WebCore::String& mime_type, const WebCore::ResourceRequest&); + virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state, const WebCore::String& frame_name); + virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state); + virtual void cancelPolicyCheck(); + virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); + virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>); + virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); + virtual void revertToProvisionalState(WebCore::DocumentLoader*); + virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); + virtual void willChangeEstimatedProgress() { } + virtual void didChangeEstimatedProgress() { } + virtual void postProgressStartedNotification(); + virtual void postProgressEstimateChangedNotification(); + virtual void postProgressFinishedNotification(); + virtual void setMainFrameDocumentReady(bool); + virtual void startDownload(const WebCore::ResourceRequest&); + virtual void willChangeTitle(WebCore::DocumentLoader*); + virtual void didChangeTitle(WebCore::DocumentLoader*); + virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); + virtual void finishedLoading(WebCore::DocumentLoader*); + virtual void updateGlobalHistory(); + virtual void updateGlobalHistoryRedirectLinks(); + virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; + virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const; + virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const; + virtual void dispatchDidChangeBackForwardIndex() const; + virtual void didDisplayInsecureContent(); + virtual void didRunInsecureContent(WebCore::SecurityOrigin*); + virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&); + virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); + virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&); + virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&); + virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); + virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); + virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&); + virtual bool shouldFallBack(const WebCore::ResourceError&); + virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; + virtual bool canShowMIMEType(const WebCore::String& MIMEType) const; + virtual bool representationExistsForURLScheme(const WebCore::String& URLScheme) const; + virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String& URLScheme) const; + virtual void frameLoadCompleted(); + virtual void saveViewStateToItem(WebCore::HistoryItem*); + virtual void restoreViewState(); + virtual void provisionalLoadStarted(); + virtual void didFinishLoad(); + virtual void prepareForDataSourceReplacement(); + virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader( + const WebCore::ResourceRequest&, const WebCore::SubstituteData&); + virtual void setTitle(const WebCore::String& title, const WebCore::KURL&); + virtual WebCore::String userAgent(const WebCore::KURL&); + virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); + virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); + virtual void transitionToCommittedForNewPage(); + virtual bool canCachePage() const; + virtual void download( + WebCore::ResourceHandle*, const WebCore::ResourceRequest&, + const WebCore::ResourceRequest& initialRequest, + const WebCore::ResourceResponse&); + virtual PassRefPtr<WebCore::Frame> createFrame( + const WebCore::KURL& url, const WebCore::String& name, + WebCore::HTMLFrameOwnerElement* ownerElement, + const WebCore::String& referrer, bool allowsScrolling, + int marginWidth, int marginHeight); + virtual PassRefPtr<WebCore::Widget> createPlugin( + const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, + const Vector<WebCore::String>&, const Vector<WebCore::String>&, + const WebCore::String&, bool loadManually); + virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); + virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget( + const WebCore::IntSize&, + WebCore::HTMLAppletElement*, + const WebCore::KURL& /* base_url */, + const Vector<WebCore::String>& paramNames, + const Vector<WebCore::String>& paramValues); + virtual WebCore::ObjectContentType objectContentType( + const WebCore::KURL& url, const WebCore::String& mimeType); + virtual WebCore::String overrideMediaType() const; + virtual void didPerformFirstNavigation() const; + virtual void registerForIconNotification(bool listen = true); + virtual void didChangeScrollOffset(); + virtual bool allowJavaScript(bool enabledPerSettings); + +private: + void makeDocumentView(); + + // Given a NavigationAction, determine the associated WebNavigationPolicy. + // For example, a middle click means "open in background tab". + static bool actionSpecifiesNavigationPolicy( + const WebCore::NavigationAction& action, WebNavigationPolicy* policy); + + // Called when a dummy back-forward navigation is intercepted. + void handleBackForwardNavigation(const WebCore::KURL&); + + PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver(); + + // The WebFrame that owns this object and manages its lifetime. Therefore, + // the web frame object is guaranteed to exist. + WebFrameImpl* m_webFrame; + + // True if makeRepresentation was called. We don't actually have a concept + // of a "representation", but we need to know when we're expected to have one. + // See finishedLoading(). + bool m_hasRepresentation; + + // Used to help track client redirects. When a provisional load starts, it + // has no redirects in its chain. But in the case of client redirects, we want + // to add that initial load as a redirect. When we get a new provisional load + // and the dest URL matches that load, we know that it was the result of a + // previous client redirect and the source should be added as a redirect. + // Both should be empty if unused. + WebCore::KURL m_expectedClientRedirectSrc; + WebCore::KURL m_expectedClientRedirectDest; + + // Contains a pointer to the plugin widget. + RefPtr<WebPluginContainerImpl> m_pluginWidget; + + // Indicates if we need to send over the initial notification to the plugin + // which specifies that the plugin should be ready to accept data. + bool m_sentInitialResponseToPlugin; + + // The navigation policy to use for the next call to dispatchCreatePage. + WebNavigationPolicy m_nextNavigationPolicy; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/GraphicsContext3D.cpp b/WebKit/chromium/src/GraphicsContext3D.cpp new file mode 100644 index 0000000..c9ba5a1 --- /dev/null +++ b/WebKit/chromium/src/GraphicsContext3D.cpp @@ -0,0 +1,2146 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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" + +#if ENABLE(3D_CANVAS) + +#include "GraphicsContext3D.h" + +#include "CachedImage.h" +#include "CString.h" +#include "HTMLCanvasElement.h" +#include "HTMLImageElement.h" +#include "ImageBuffer.h" +#include "ImageData.h" +#include "NotImplemented.h" +#include "WebGLBuffer.h" +#include "WebGLByteArray.h" +#include "WebGLFloatArray.h" +#include "WebGLFramebuffer.h" +#include "WebGLIntArray.h" +#include "WebGLProgram.h" +#include "WebGLRenderbuffer.h" +#include "WebGLRenderingContext.h" +#include "WebGLShader.h" +#include "WebGLTexture.h" +#include "WebGLUnsignedByteArray.h" + +#include <stdio.h> +#include <wtf/FastMalloc.h> + +#if PLATFORM(WIN_OS) +#include <windows.h> +#endif + +#include "GL/glew.h" + +#if PLATFORM(CG) +#include "GraphicsContext.h" +#include <CoreGraphics/CGContext.h> +#include <CoreGraphics/CGBitmapContext.h> +#include <CoreGraphics/CGImage.h> +#include <OpenGL/OpenGL.h> +#else +#define FLIP_FRAMEBUFFER_VERTICALLY +#endif + +#if PLATFORM(SKIA) +#include "NativeImageSkia.h" +#endif + +#if PLATFORM(DARWIN) +#define USE_TEXTURE_RECTANGLE_FOR_FRAMEBUFFER +#endif + +#if PLATFORM(LINUX) +#include <dlfcn.h> +#include "GL/glxew.h" +#endif + +using namespace std; + +namespace WebCore { + +// GraphicsContext3DInternal ----------------------------------------------------- + +// Uncomment this to render to a separate window for debugging +// #define RENDER_TO_DEBUGGING_WINDOW + +#define EXTRACT(val) (!val ? 0 : val->object()) + +class GraphicsContext3DInternal { +public: + GraphicsContext3DInternal(); + ~GraphicsContext3DInternal(); + + bool makeContextCurrent(); + + PlatformGraphicsContext3D platformGraphicsContext3D() const; + Platform3DObject platformTexture() const; + + void reshape(int width, int height); + + void beginPaint(WebGLRenderingContext* context); + + bool validateTextureTarget(int target); + bool validateTextureParameter(int param); + + void activeTexture(unsigned long texture); + void bindBuffer(unsigned long target, + WebGLBuffer* buffer); + void bindTexture(unsigned long target, + WebGLTexture* texture); + void bufferDataImpl(unsigned long target, int size, const void* data, unsigned long usage); + void disableVertexAttribArray(unsigned long index); + void enableVertexAttribArray(unsigned long index); + unsigned long getError(); + void vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, + unsigned long stride, unsigned long offset); + void viewportImpl(long x, long y, unsigned long width, unsigned long height); + + void synthesizeGLError(unsigned long error); + +private: + unsigned int m_texture; + unsigned int m_fbo; + unsigned int m_depthBuffer; + unsigned int m_cachedWidth, m_cachedHeight; + +#ifdef FLIP_FRAMEBUFFER_VERTICALLY + unsigned char* m_scanline; + void flipVertically(unsigned char* framebuffer, + unsigned int width, + unsigned int height); +#endif + + // Note: we aren't currently using this information, but we will + // need to in order to verify that all enabled vertex arrays have + // a valid buffer bound -- to avoid crashes on certain cards. + unsigned int m_boundArrayBuffer; + class VertexAttribPointerState { + public: + VertexAttribPointerState(); + + bool enabled; + unsigned long buffer; + unsigned long indx; + int size; + int type; + bool normalized; + unsigned long stride; + unsigned long offset; + }; + + enum { + NumTrackedPointerStates = 2 + }; + VertexAttribPointerState m_vertexAttribPointerState[NumTrackedPointerStates]; + + // Errors raised by synthesizeGLError(). + ListHashSet<unsigned long> m_syntheticErrors; + +#if PLATFORM(SKIA) + // If the width and height of the Canvas's backing store don't + // match those that we were given in the most recent call to + // reshape(), then we need an intermediate bitmap to read back the + // frame buffer into. This seems to happen when CSS styles are + // used to resize the Canvas. + SkBitmap* m_resizingBitmap; +#endif + +#if PLATFORM(WIN_OS) + HWND m_canvasWindow; + HDC m_canvasDC; + HGLRC m_contextObj; +#elif PLATFORM(CG) + CGLPBufferObj m_pbuffer; + CGLContextObj m_contextObj; + unsigned char* m_renderOutput; + CGContextRef m_cgContext; +#elif PLATFORM(LINUX) + Display* m_display; + GLXContext m_contextObj; + GLXPbuffer m_pbuffer; + // In order to avoid problems caused by linking against libGL, we + // dynamically look up all the symbols we need. + // http://code.google.com/p/chromium/issues/detail?id=16800 + void* m_libGL; + PFNGLXCHOOSEFBCONFIGPROC m_glXChooseFBConfig; + PFNGLXCREATENEWCONTEXTPROC m_glXCreateNewContext; + PFNGLXCREATEPBUFFERPROC m_glXCreatePbuffer; + PFNGLXDESTROYPBUFFERPROC m_glXDestroyPbuffer; + typedef Bool (* PFNGLXMAKECURRENTPROC)(Display* dpy, GLXDrawable drawable, GLXContext ctx); + PFNGLXMAKECURRENTPROC m_glXMakeCurrent; + typedef void (* PFNGLXDESTROYCONTEXTPROC)(Display* dpy, GLXContext ctx); + PFNGLXDESTROYCONTEXTPROC m_glXDestroyContext; + typedef GLXContext (* PFNGLXGETCURRENTCONTEXTPROC)(void); + PFNGLXGETCURRENTCONTEXTPROC m_glXGetCurrentContext; +#else + #error Must port GraphicsContext3D to your platform +#endif +}; + +GraphicsContext3DInternal::VertexAttribPointerState::VertexAttribPointerState() + : enabled(false) + , buffer(0) + , indx(0) + , size(0) + , type(0) + , normalized(false) + , stride(0) + , offset(0) +{ +} + +#if PLATFORM(LINUX) +static void* tryLoad(const char* libName) +{ + // We use RTLD_GLOBAL semantics so that GLEW initialization works; + // GLEW expects to be able to open the current process's handle + // and do dlsym's of GL entry points from there. + return dlopen(libName, RTLD_LAZY | RTLD_GLOBAL); +} +#endif + +GraphicsContext3DInternal::GraphicsContext3DInternal() + : m_texture(0) + , m_fbo(0) + , m_depthBuffer(0) +#ifdef FLIP_FRAMEBUFFER_VERTICALLY + , m_scanline(0) +#endif + , m_boundArrayBuffer(0) +#if PLATFORM(SKIA) + , m_resizingBitmap(0) +#endif +#if PLATFORM(WIN_OS) + , m_canvasWindow(0) + , m_canvasDC(0) + , m_contextObj(0) +#elif PLATFORM(CG) + , m_pbuffer(0) + , m_contextObj(0) + , m_renderOutput(0) + , m_cgContext(0) +#elif PLATFORM(LINUX) + , m_display(0) + , m_contextObj(0) + , m_pbuffer(0) + , m_glXChooseFBConfig(0) + , m_glXCreateNewContext(0) + , m_glXCreatePbuffer(0) + , m_glXDestroyPbuffer(0) + , m_glXMakeCurrent(0) + , m_glXDestroyContext(0) + , m_glXGetCurrentContext(0) +#else +#error Must port to your platform +#endif +{ +#if PLATFORM(WIN_OS) + WNDCLASS wc; + if (!GetClassInfo(GetModuleHandle(0), L"CANVASGL", &wc)) { + ZeroMemory(&wc, sizeof(WNDCLASS)); + wc.style = CS_OWNDC; + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = DefWindowProc; + wc.lpszClassName = L"CANVASGL"; + + if (!RegisterClass(&wc)) { + printf("GraphicsContext3D: RegisterClass failed\n"); + return; + } + } + + m_canvasWindow = CreateWindow(L"CANVASGL", L"CANVASGL", + WS_CAPTION, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, 0, 0, GetModuleHandle(0), 0); + if (!m_canvasWindow) { + printf("GraphicsContext3DInternal: CreateWindow failed\n"); + return; + } + + // get the device context + m_canvasDC = GetDC(m_canvasWindow); + if (!m_canvasDC) { + printf("GraphicsContext3DInternal: GetDC failed\n"); + return; + } + + // find default pixel format + PIXELFORMATDESCRIPTOR pfd; + ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR)); + pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL +#ifdef RENDER_TO_DEBUGGING_WINDOW + | PFD_DOUBLEBUFFER +#endif // RENDER_TO_DEBUGGING_WINDOW + ; + int pixelformat = ChoosePixelFormat(m_canvasDC, &pfd); + + // set the pixel format for the dc + if (!SetPixelFormat(m_canvasDC, pixelformat, &pfd)) { + printf("GraphicsContext3D: SetPixelFormat failed\n"); + return; + } + + // create rendering context + m_contextObj = wglCreateContext(m_canvasDC); + if (!m_contextObj) { + printf("GraphicsContext3D: wglCreateContext failed\n"); + return; + } + + if (!wglMakeCurrent(m_canvasDC, m_contextObj)) { + printf("GraphicsContext3D: wglMakeCurrent failed\n"); + return; + } + +#ifdef RENDER_TO_DEBUGGING_WINDOW + typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); + PFNWGLSWAPINTERVALEXTPROC setSwapInterval = 0; + setSwapInterval = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT"); + if (setSwapInterval) + setSwapInterval(1); +#endif // RENDER_TO_DEBUGGING_WINDOW + +#elif PLATFORM(CG) + // Create a 1x1 pbuffer and associated context to bootstrap things + CGLPixelFormatAttribute attribs[] = { + (CGLPixelFormatAttribute) kCGLPFAPBuffer, + (CGLPixelFormatAttribute) 0 + }; + CGLPixelFormatObj pixelFormat; + GLint numPixelFormats; + if (CGLChoosePixelFormat(attribs, &pixelFormat, &numPixelFormats) != kCGLNoError) { + printf("GraphicsContext3D: error choosing pixel format\n"); + return; + } + if (!pixelFormat) { + printf("GraphicsContext3D: no pixel format selected\n"); + return; + } + CGLContextObj context; + CGLError res = CGLCreateContext(pixelFormat, 0, &context); + CGLDestroyPixelFormat(pixelFormat); + if (res != kCGLNoError) { + printf("GraphicsContext3D: error creating context\n"); + return; + } + CGLPBufferObj pbuffer; + if (CGLCreatePBuffer(1, 1, GL_TEXTURE_2D, GL_RGBA, 0, &pbuffer) != kCGLNoError) { + CGLDestroyContext(context); + printf("GraphicsContext3D: error creating pbuffer\n"); + return; + } + if (CGLSetPBuffer(context, pbuffer, 0, 0, 0) != kCGLNoError) { + CGLDestroyContext(context); + CGLDestroyPBuffer(pbuffer); + printf("GraphicsContext3D: error attaching pbuffer to context\n"); + return; + } + if (CGLSetCurrentContext(context) != kCGLNoError) { + CGLDestroyContext(context); + CGLDestroyPBuffer(pbuffer); + printf("GraphicsContext3D: error making context current\n"); + return; + } + m_pbuffer = pbuffer; + m_contextObj = context; +#elif PLATFORM(LINUX) + m_display = XOpenDisplay(0); + if (!m_display) { + printf("GraphicsContext3D: error opening X display\n"); + return; + } + + const char* libNames[] = { + "/usr/lib/libGL.so.1", + "/usr/lib32/libGL.so.1", + "/usr/lib64/libGL.so.1", + }; + for (int i = 0; i < sizeof(libNames) / sizeof(const char*); i++) { + m_libGL = tryLoad(libNames[i]); + if (m_libGL) + break; + } + if (!m_libGL) { + printf("GraphicsContext3D: error opening libGL.so.1\n"); + printf("GraphicsContext3D: tried:"); + for (int i = 0; i < sizeof(libNames) / sizeof(const char*); i++) + printf(" %s", libNames[i]); + return; + } + m_glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) dlsym(m_libGL, "glXChooseFBConfig"); + m_glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC) dlsym(m_libGL, "glXCreateNewContext"); + m_glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC) dlsym(m_libGL, "glXCreatePbuffer"); + m_glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC) dlsym(m_libGL, "glXDestroyPbuffer"); + m_glXMakeCurrent = (PFNGLXMAKECURRENTPROC) dlsym(m_libGL, "glXMakeCurrent"); + m_glXDestroyContext = (PFNGLXDESTROYCONTEXTPROC) dlsym(m_libGL, "glXDestroyContext"); + m_glXGetCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC) dlsym(m_libGL, "glXGetCurrentContext"); + if (!m_glXChooseFBConfig || !m_glXCreateNewContext || !m_glXCreatePbuffer + || !m_glXDestroyPbuffer || !m_glXMakeCurrent || !m_glXDestroyContext + || !m_glXGetCurrentContext) { + printf("GraphicsContext3D: error looking up bootstrapping entry points\n"); + return; + } + int configAttrs[] = { + GLX_DRAWABLE_TYPE, + GLX_PBUFFER_BIT, + GLX_RENDER_TYPE, + GLX_RGBA_BIT, + GLX_DOUBLEBUFFER, + 0, + 0 + }; + int nelements = 0; + GLXFBConfig* config = m_glXChooseFBConfig(m_display, 0, configAttrs, &nelements); + if (!config) { + printf("GraphicsContext3D: glXChooseFBConfig failed\n"); + return; + } + if (!nelements) { + printf("GraphicsContext3D: glXChooseFBConfig returned 0 elements\n"); + XFree(config); + return; + } + GLXContext context = m_glXCreateNewContext(m_display, config[0], GLX_RGBA_TYPE, 0, True); + if (!context) { + printf("GraphicsContext3D: glXCreateNewContext failed\n"); + XFree(config); + return; + } + int pbufferAttrs[] = { + GLX_PBUFFER_WIDTH, + 1, + GLX_PBUFFER_HEIGHT, + 1, + 0 + }; + GLXPbuffer pbuffer = m_glXCreatePbuffer(m_display, config[0], pbufferAttrs); + XFree(config); + if (!pbuffer) { + printf("GraphicsContext3D: glxCreatePbuffer failed\n"); + return; + } + if (!m_glXMakeCurrent(m_display, pbuffer, context)) { + printf("GraphicsContext3D: glXMakeCurrent failed\n"); + return; + } + m_contextObj = context; + m_pbuffer = pbuffer; +#else +#error Must port to your platform +#endif + + static bool initializedGLEW = false; + if (!initializedGLEW) { + // Initialize GLEW and check for GL 2.0 support by the drivers. + GLenum glewInitResult = glewInit(); + if (glewInitResult != GLEW_OK) { + printf("GraphicsContext3D: GLEW initialization failed\n"); + return; + } + if (!glewIsSupported("GL_VERSION_2_0")) { + printf("GraphicsContext3D: OpenGL 2.0 not supported\n"); + return; + } + initializedGLEW = true; + } +} + +GraphicsContext3DInternal::~GraphicsContext3DInternal() +{ + makeContextCurrent(); +#ifndef RENDER_TO_DEBUGGING_WINDOW + glDeleteRenderbuffersEXT(1, &m_depthBuffer); + glDeleteTextures(1, &m_texture); +#ifdef FLIP_FRAMEBUFFER_VERTICALLY + if (m_scanline) + delete[] m_scanline; +#endif + glDeleteFramebuffersEXT(1, &m_fbo); +#endif // !RENDER_TO_DEBUGGING_WINDOW +#if PLATFORM(SKIA) + if (m_resizingBitmap) + delete m_resizingBitmap; +#endif +#if PLATFORM(WIN_OS) + wglMakeCurrent(0, 0); + wglDeleteContext(m_contextObj); + ReleaseDC(m_canvasWindow, m_canvasDC); + DestroyWindow(m_canvasWindow); +#elif PLATFORM(CG) + CGLSetCurrentContext(0); + CGLDestroyContext(m_contextObj); + CGLDestroyPBuffer(m_pbuffer); + if (m_cgContext) + CGContextRelease(m_cgContext); + if (m_renderOutput) + delete[] m_renderOutput; +#elif PLATFORM(LINUX) + m_glXMakeCurrent(m_display, 0, 0); + m_glXDestroyContext(m_display, m_contextObj); + m_glXDestroyPbuffer(m_display, m_pbuffer); + XCloseDisplay(m_display); + dlclose(m_libGL); +#else +#error Must port to your platform +#endif + m_contextObj = 0; +} + +bool GraphicsContext3DInternal::makeContextCurrent() +{ +#if PLATFORM(WIN_OS) + if (wglGetCurrentContext() != m_contextObj) + if (wglMakeCurrent(m_canvasDC, m_contextObj)) + return true; +#elif PLATFORM(CG) + if (CGLGetCurrentContext() != m_contextObj) + if (CGLSetCurrentContext(m_contextObj) == kCGLNoError) + return true; +#elif PLATFORM(LINUX) + if (m_glXGetCurrentContext() != m_contextObj) + if (m_glXMakeCurrent(m_display, m_pbuffer, m_contextObj)) + return true; +#else +#error Must port to your platform +#endif + return false; +} + +PlatformGraphicsContext3D GraphicsContext3DInternal::platformGraphicsContext3D() const +{ + return m_contextObj; +} + +Platform3DObject GraphicsContext3DInternal::platformTexture() const +{ + return m_texture; +} + +static int createTextureObject(GLenum target) +{ + GLuint texture = 0; + glGenTextures(1, &texture); + glBindTexture(target, texture); + glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + return texture; +} + +void GraphicsContext3DInternal::reshape(int width, int height) +{ +#ifdef RENDER_TO_DEBUGGING_WINDOW + SetWindowPos(m_canvasWindow, HWND_TOP, 0, 0, width, height, + SWP_NOMOVE); + ShowWindow(m_canvasWindow, SW_SHOW); +#endif + + m_cachedWidth = width; + m_cachedHeight = height; + makeContextCurrent(); + +#ifndef RENDER_TO_DEBUGGING_WINDOW +#ifdef USE_TEXTURE_RECTANGLE_FOR_FRAMEBUFFER + // GL_TEXTURE_RECTANGLE_ARB is the best supported render target on Mac OS X + GLenum target = GL_TEXTURE_RECTANGLE_ARB; +#else + GLenum target = GL_TEXTURE_2D; +#endif + if (!m_texture) { + // Generate the texture object + m_texture = createTextureObject(target); + // Generate the framebuffer object + glGenFramebuffersEXT(1, &m_fbo); + // Generate the depth buffer + glGenRenderbuffersEXT(1, &m_depthBuffer); + } + + // Reallocate the color and depth buffers + glBindTexture(target, m_texture); + glTexImage2D(target, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glBindTexture(target, 0); + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); + + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, m_texture, 0); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer); + GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + printf("GraphicsContext3D: framebuffer was incomplete\n"); + + // FIXME: cleanup. + notImplemented(); + } +#endif // RENDER_TO_DEBUGGING_WINDOW + +#ifdef FLIP_FRAMEBUFFER_VERTICALLY + if (m_scanline) { + delete[] m_scanline; + m_scanline = 0; + } + m_scanline = new unsigned char[width * 4]; +#endif // FLIP_FRAMEBUFFER_VERTICALLY + + glClear(GL_COLOR_BUFFER_BIT); + viewportImpl(0, 0, width, height); + +#if PLATFORM(CG) + // Need to reallocate the client-side backing store. + // FIXME: make this more efficient. + if (m_cgContext) { + CGContextRelease(m_cgContext); + m_cgContext = 0; + } + if (m_renderOutput) { + delete[] m_renderOutput; + m_renderOutput = 0; + } + int rowBytes = width * 4; + m_renderOutput = new unsigned char[height * rowBytes]; + CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + m_cgContext = CGBitmapContextCreate(m_renderOutput, width, height, 8, rowBytes, + colorSpace, kCGImageAlphaPremultipliedLast); + CGColorSpaceRelease(colorSpace); +#endif // PLATFORM(CG) +} + +#ifdef FLIP_FRAMEBUFFER_VERTICALLY +void GraphicsContext3DInternal::flipVertically(unsigned char* framebuffer, + unsigned int width, + unsigned int height) +{ + unsigned char* scanline = m_scanline; + if (!scanline) + return; + unsigned int rowBytes = width * 4; + unsigned int count = height / 2; + for (unsigned int i = 0; i < count; i++) { + unsigned char* rowA = framebuffer + i * rowBytes; + unsigned char* rowB = framebuffer + (height - i - 1) * rowBytes; + // FIXME: this is where the multiplication of the alpha + // channel into the color buffer will need to occur if the + // user specifies the "premultiplyAlpha" flag in the context + // creation attributes. + memcpy(scanline, rowB, rowBytes); + memcpy(rowB, rowA, rowBytes); + memcpy(rowA, scanline, rowBytes); + } +} +#endif + +void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) +{ + makeContextCurrent(); + +#ifdef RENDER_TO_DEBUGGING_WINDOW + SwapBuffers(m_canvasDC); +#else + // Earlier versions of this code used the GPU to flip the + // framebuffer vertically before reading it back for compositing + // via software. This code was quite complicated, used a lot of + // GPU memory, and didn't provide an obvious speedup. Since this + // vertical flip is only a temporary solution anyway until Chrome + // is fully GPU composited, it wasn't worth the complexity. + + HTMLCanvasElement* canvas = context->canvas(); + ImageBuffer* imageBuffer = canvas->buffer(); + unsigned char* pixels = 0; +#if PLATFORM(SKIA) + const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap(); + const SkBitmap* readbackBitmap = 0; + ASSERT(canvasBitmap->config() == SkBitmap::kARGB_8888_Config); + if (canvasBitmap->width() == m_cachedWidth && canvasBitmap->height() == m_cachedHeight) { + // This is the fastest and most common case. We read back + // directly into the canvas's backing store. + readbackBitmap = canvasBitmap; + if (m_resizingBitmap) { + delete m_resizingBitmap; + m_resizingBitmap = 0; + } + } else { + // We need to allocate a temporary bitmap for reading back the + // pixel data. We will then use Skia to rescale this bitmap to + // the size of the canvas's backing store. + if (m_resizingBitmap && (m_resizingBitmap->width() != m_cachedWidth || m_resizingBitmap->height() != m_cachedHeight)) { + delete m_resizingBitmap; + m_resizingBitmap = 0; + } + if (!m_resizingBitmap) { + m_resizingBitmap = new SkBitmap(); + m_resizingBitmap->setConfig(SkBitmap::kARGB_8888_Config, + m_cachedWidth, + m_cachedHeight); + if (!m_resizingBitmap->allocPixels()) { + delete m_resizingBitmap; + m_resizingBitmap = 0; + return; + } + } + readbackBitmap = m_resizingBitmap; + } + + // Read back the frame buffer. + SkAutoLockPixels bitmapLock(*readbackBitmap); + pixels = static_cast<unsigned char*>(readbackBitmap->getPixels()); + glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels); +#elif PLATFORM(CG) + if (m_renderOutput) { + ASSERT(CGBitmapContextGetWidth(m_cgContext) == m_cachedWidth); + ASSERT(CGBitmapContextGetHeight(m_cgContext) == m_cachedHeight); + pixels = m_renderOutput; + glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + } +#else +#error Must port to your platform +#endif + +#ifdef FLIP_FRAMEBUFFER_VERTICALLY + if (pixels) + flipVertically(pixels, m_cachedWidth, m_cachedHeight); +#endif + +#if PLATFORM(SKIA) + if (m_resizingBitmap) { + // We need to draw the resizing bitmap into the canvas's backing store. + SkCanvas canvas(*canvasBitmap); + SkRect dst; + dst.set(0, 0, canvasBitmap->width(), canvasBitmap->height()); + canvas.drawBitmapRect(*m_resizingBitmap, 0, dst); + } +#elif PLATFORM(CG) + if (m_renderOutput) { + CGImageRef cgImage = CGBitmapContextCreateImage(m_cgContext); + // CSS styling may cause the canvas's content to be resized on + // the page. Go back to the Canvas to figure out the correct + // width and height to draw. + CGRect rect = CGRectMake(0, 0, + context->canvas()->width(), + context->canvas()->height()); + // We want to completely overwrite the previous frame's + // rendering results. + CGContextSetBlendMode(imageBuffer->context()->platformContext(), + kCGBlendModeCopy); + CGContextDrawImage(imageBuffer->context()->platformContext(), + rect, cgImage); + CGImageRelease(cgImage); + } +#else +#error Must port to your platform +#endif + +#endif // RENDER_TO_DEBUGGING_WINDOW +} + +void GraphicsContext3DInternal::activeTexture(unsigned long texture) +{ + // FIXME: query number of textures available. + if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0+32) + // FIXME: raise exception. + return; + + makeContextCurrent(); + glActiveTexture(texture); +} + +void GraphicsContext3DInternal::bindBuffer(unsigned long target, + WebGLBuffer* buffer) +{ + makeContextCurrent(); + GLuint bufID = EXTRACT(buffer); + if (target == GL_ARRAY_BUFFER) + m_boundArrayBuffer = bufID; + glBindBuffer(target, bufID); +} + +// If we didn't have to hack GL_TEXTURE_WRAP_R for cube maps, +// we could just use: +// GL_SAME_METHOD_2_X2(BindTexture, bindTexture, unsigned long, WebGLTexture*) +void GraphicsContext3DInternal::bindTexture(unsigned long target, + WebGLTexture* texture) +{ + makeContextCurrent(); + unsigned int textureObject = EXTRACT(texture); + + glBindTexture(target, textureObject); + + // FIXME: GL_TEXTURE_WRAP_R isn't exposed in the OpenGL ES 2.0 + // API. On desktop OpenGL implementations it seems necessary to + // set this wrap mode to GL_CLAMP_TO_EDGE to get correct behavior + // of cube maps. + if (texture) { + if (target == GL_TEXTURE_CUBE_MAP) { + if (!texture->isCubeMapRWrapModeInitialized()) { + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + texture->setCubeMapRWrapModeInitialized(true); + } + } else + texture->setCubeMapRWrapModeInitialized(false); + } +} + +void GraphicsContext3DInternal::bufferDataImpl(unsigned long target, int size, const void* data, unsigned long usage) +{ + makeContextCurrent(); + // FIXME: make this verification more efficient. + GLint binding = 0; + GLenum binding_target = GL_ARRAY_BUFFER_BINDING; + if (target == GL_ELEMENT_ARRAY_BUFFER) + binding_target = GL_ELEMENT_ARRAY_BUFFER_BINDING; + glGetIntegerv(binding_target, &binding); + if (binding <= 0) { + // FIXME: raise exception. + // LogMessagef(("bufferData: no buffer bound")); + return; + } + + glBufferData(target, + size, + data, + usage); +} + +void GraphicsContext3DInternal::disableVertexAttribArray(unsigned long index) +{ + makeContextCurrent(); + if (index < NumTrackedPointerStates) + m_vertexAttribPointerState[index].enabled = false; + glDisableVertexAttribArray(index); +} + +void GraphicsContext3DInternal::enableVertexAttribArray(unsigned long index) +{ + makeContextCurrent(); + if (index < NumTrackedPointerStates) + m_vertexAttribPointerState[index].enabled = true; + glEnableVertexAttribArray(index); +} + +unsigned long GraphicsContext3DInternal::getError() +{ + if (m_syntheticErrors.size() > 0) { + ListHashSet<unsigned long>::iterator iter = m_syntheticErrors.begin(); + unsigned long err = *iter; + m_syntheticErrors.remove(iter); + return err; + } + + makeContextCurrent(); + return glGetError(); +} + +void GraphicsContext3DInternal::vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, + unsigned long stride, unsigned long offset) +{ + makeContextCurrent(); + + if (m_boundArrayBuffer <= 0) { + // FIXME: raise exception. + // LogMessagef(("bufferData: no buffer bound")); + return; + } + + if (indx < NumTrackedPointerStates) { + VertexAttribPointerState& state = m_vertexAttribPointerState[indx]; + state.buffer = m_boundArrayBuffer; + state.indx = indx; + state.size = size; + state.type = type; + state.normalized = normalized; + state.stride = stride; + state.offset = offset; + } + + glVertexAttribPointer(indx, size, type, normalized, stride, + reinterpret_cast<void*>(static_cast<intptr_t>(offset))); +} + +void GraphicsContext3DInternal::viewportImpl(long x, long y, unsigned long width, unsigned long height) +{ + glViewport(x, y, width, height); +} + +void GraphicsContext3DInternal::synthesizeGLError(unsigned long error) +{ + m_syntheticErrors.add(error); +} + +// GraphicsContext3D ----------------------------------------------------- + +/* Helper macros for when we're just wrapping a gl method, so that + * we can avoid having to type this 500 times. Note that these MUST + * NOT BE USED if we need to check any of the parameters. + */ + +#define GL_SAME_METHOD_0(glname, name) \ +void GraphicsContext3D::name() \ +{ \ + makeContextCurrent(); \ + gl##glname(); \ +} + +#define GL_SAME_METHOD_1(glname, name, t1) \ +void GraphicsContext3D::name(t1 a1) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1); \ +} + +#define GL_SAME_METHOD_1_X(glname, name, t1) \ +void GraphicsContext3D::name(t1 a1) \ +{ \ + makeContextCurrent(); \ + gl##glname(EXTRACT(a1)); \ +} + +#define GL_SAME_METHOD_2(glname, name, t1, t2) \ +void GraphicsContext3D::name(t1 a1, t2 a2) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2); \ +} + +#define GL_SAME_METHOD_2_X12(glname, name, t1, t2) \ +void GraphicsContext3D::name(t1 a1, t2 a2) \ +{ \ + makeContextCurrent(); \ + gl##glname(EXTRACT(a1), EXTRACT(a2)); \ +} + +#define GL_SAME_METHOD_2_X2(glname, name, t1, t2) \ +void GraphicsContext3D::name(t1 a1, t2 a2) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, EXTRACT(a2)); \ +} + +#define GL_SAME_METHOD_3(glname, name, t1, t2, t3) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2, a3); \ +} + +#define GL_SAME_METHOD_3_X12(glname, name, t1, t2, t3) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \ +{ \ + makeContextCurrent(); \ + gl##glname(EXTRACT(a1), EXTRACT(a2), a3); \ +} + +#define GL_SAME_METHOD_3_X2(glname, name, t1, t2, t3) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, EXTRACT(a2), a3); \ +} + +#define GL_SAME_METHOD_4(glname, name, t1, t2, t3, t4) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2, a3, a4); \ +} + +#define GL_SAME_METHOD_4_X4(glname, name, t1, t2, t3, t4) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2, a3, EXTRACT(a4)); \ +} + +#define GL_SAME_METHOD_5(glname, name, t1, t2, t3, t4, t5) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2, a3, a4, a5); \ +} + +#define GL_SAME_METHOD_5_X4(glname, name, t1, t2, t3, t4, t5) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2, a3, EXTRACT(a4), a5); \ +} + +#define GL_SAME_METHOD_6(glname, name, t1, t2, t3, t4, t5, t6) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2, a3, a4, a5, a6); \ +} + +#define GL_SAME_METHOD_8(glname, name, t1, t2, t3, t4, t5, t6, t7, t8) \ +void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \ +{ \ + makeContextCurrent(); \ + gl##glname(a1, a2, a3, a4, a5, a6, a7, a8); \ +} + +PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create() +{ + PassOwnPtr<GraphicsContext3D> context = new GraphicsContext3D(); + // FIXME: add error checking + return context; +} + +GraphicsContext3D::GraphicsContext3D() + : m_currentWidth(0) + , m_currentHeight(0) + , m_internal(new GraphicsContext3DInternal()) +{ +} + +GraphicsContext3D::~GraphicsContext3D() +{ +} + +PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const +{ + return m_internal->platformGraphicsContext3D(); +} + +Platform3DObject GraphicsContext3D::platformTexture() const +{ + return m_internal->platformTexture(); +} + +void GraphicsContext3D::makeContextCurrent() +{ + m_internal->makeContextCurrent(); +} + +void GraphicsContext3D::reshape(int width, int height) +{ + if (width == m_currentWidth && height == m_currentHeight) + return; + + m_currentWidth = width; + m_currentHeight = height; + + m_internal->reshape(width, height); +} + +void GraphicsContext3D::beginPaint(WebGLRenderingContext* context) +{ + m_internal->beginPaint(context); +} + +void GraphicsContext3D::endPaint() +{ +} + +int GraphicsContext3D::sizeInBytes(int type) +{ + switch (type) { + case GL_BYTE: + return sizeof(GLbyte); + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + case GL_SHORT: + return sizeof(GLshort); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_INT: + return sizeof(GLint); + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_FLOAT: + return sizeof(GLfloat); + default: // FIXME: default cases are discouraged in WebKit. + return 0; + } +} + +unsigned GraphicsContext3D::createBuffer() +{ + makeContextCurrent(); + GLuint o; + glGenBuffers(1, &o); + return o; +} + +unsigned GraphicsContext3D::createFramebuffer() +{ + makeContextCurrent(); + GLuint o = 0; + glGenFramebuffersEXT(1, &o); + return o; +} + +unsigned GraphicsContext3D::createProgram() +{ + makeContextCurrent(); + return glCreateProgram(); +} + +unsigned GraphicsContext3D::createRenderbuffer() +{ + makeContextCurrent(); + GLuint o; + glGenRenderbuffersEXT(1, &o); + return o; +} + +unsigned GraphicsContext3D::createShader(unsigned long type) +{ + makeContextCurrent(); + return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER); +} + +unsigned GraphicsContext3D::createTexture() +{ + makeContextCurrent(); + GLuint o; + glGenTextures(1, &o); + return o; +} + +void GraphicsContext3D::deleteBuffer(unsigned buffer) +{ + makeContextCurrent(); + glDeleteBuffers(1, &buffer); +} + +void GraphicsContext3D::deleteFramebuffer(unsigned framebuffer) +{ + makeContextCurrent(); + glDeleteFramebuffersEXT(1, &framebuffer); +} + +void GraphicsContext3D::deleteProgram(unsigned program) +{ + makeContextCurrent(); + glDeleteProgram(program); +} + +void GraphicsContext3D::deleteRenderbuffer(unsigned renderbuffer) +{ + makeContextCurrent(); + glDeleteRenderbuffersEXT(1, &renderbuffer); +} + +void GraphicsContext3D::deleteShader(unsigned shader) +{ + makeContextCurrent(); + glDeleteShader(shader); +} + +void GraphicsContext3D::deleteTexture(unsigned texture) +{ + makeContextCurrent(); + glDeleteTextures(1, &texture); +} + +void GraphicsContext3D::activeTexture(unsigned long texture) +{ + m_internal->activeTexture(texture); +} + +GL_SAME_METHOD_2_X12(AttachShader, attachShader, WebGLProgram*, WebGLShader*) + +void GraphicsContext3D::bindAttribLocation(WebGLProgram* program, + unsigned long index, + const String& name) +{ + if (!program) + return; + makeContextCurrent(); + glBindAttribLocation(EXTRACT(program), index, name.utf8().data()); +} + +void GraphicsContext3D::bindBuffer(unsigned long target, + WebGLBuffer* buffer) +{ + m_internal->bindBuffer(target, buffer); +} + +GL_SAME_METHOD_2_X2(BindFramebufferEXT, bindFramebuffer, unsigned long, WebGLFramebuffer*) + +GL_SAME_METHOD_2_X2(BindRenderbufferEXT, bindRenderbuffer, unsigned long, WebGLRenderbuffer*) + +// If we didn't have to hack GL_TEXTURE_WRAP_R for cube maps, +// we could just use: +// GL_SAME_METHOD_2_X2(BindTexture, bindTexture, unsigned long, WebGLTexture*) +void GraphicsContext3D::bindTexture(unsigned long target, + WebGLTexture* texture) +{ + m_internal->bindTexture(target, texture); +} + +GL_SAME_METHOD_4(BlendColor, blendColor, double, double, double, double) + +GL_SAME_METHOD_1(BlendEquation, blendEquation, unsigned long) + +GL_SAME_METHOD_2(BlendEquationSeparate, blendEquationSeparate, unsigned long, unsigned long) + +GL_SAME_METHOD_2(BlendFunc, blendFunc, unsigned long, unsigned long) + +GL_SAME_METHOD_4(BlendFuncSeparate, blendFuncSeparate, unsigned long, unsigned long, unsigned long, unsigned long) + +void GraphicsContext3D::bufferData(unsigned long target, int size, unsigned long usage) +{ + m_internal->bufferDataImpl(target, size, 0, usage); +} + +void GraphicsContext3D::bufferData(unsigned long target, WebGLArray* array, unsigned long usage) +{ + m_internal->bufferDataImpl(target, array->byteLength(), array->baseAddress(), usage); +} + +void GraphicsContext3D::bufferSubData(unsigned long target, long offset, WebGLArray* array) +{ + if (!array || !array->length()) + return; + + makeContextCurrent(); + // FIXME: make this verification more efficient. + GLint binding = 0; + GLenum binding_target = GL_ARRAY_BUFFER_BINDING; + if (target == GL_ELEMENT_ARRAY_BUFFER) + binding_target = GL_ELEMENT_ARRAY_BUFFER_BINDING; + glGetIntegerv(binding_target, &binding); + if (binding <= 0) { + // FIXME: raise exception. + // LogMessagef(("bufferSubData: no buffer bound")); + return; + } + glBufferSubData(target, offset, array->byteLength(), array->baseAddress()); +} + +unsigned long GraphicsContext3D::checkFramebufferStatus(unsigned long target) +{ + makeContextCurrent(); + return glCheckFramebufferStatusEXT(target); +} + +GL_SAME_METHOD_1(Clear, clear, unsigned long) + +GL_SAME_METHOD_4(ClearColor, clearColor, double, double, double, double) + +GL_SAME_METHOD_1(ClearDepth, clearDepth, double) + +GL_SAME_METHOD_1(ClearStencil, clearStencil, long) + +GL_SAME_METHOD_4(ColorMask, colorMask, bool, bool, bool, bool) + +GL_SAME_METHOD_1_X(CompileShader, compileShader, WebGLShader*) + +GL_SAME_METHOD_8(CopyTexImage2D, copyTexImage2D, unsigned long, long, unsigned long, long, long, unsigned long, unsigned long, long) + +GL_SAME_METHOD_8(CopyTexSubImage2D, copyTexSubImage2D, unsigned long, long, long, long, long, long, unsigned long, unsigned long) + +GL_SAME_METHOD_1(CullFace, cullFace, unsigned long) + +GL_SAME_METHOD_1(DepthFunc, depthFunc, unsigned long) + +GL_SAME_METHOD_1(DepthMask, depthMask, bool) + +GL_SAME_METHOD_2(DepthRange, depthRange, double, double) + +void GraphicsContext3D::detachShader(WebGLProgram* program, WebGLShader* shader) +{ + if (!program || !shader) + return; + + makeContextCurrent(); + glDetachShader(EXTRACT(program), EXTRACT(shader)); +} + +GL_SAME_METHOD_1(Disable, disable, unsigned long) + +void GraphicsContext3D::disableVertexAttribArray(unsigned long index) +{ + m_internal->disableVertexAttribArray(index); +} + +void GraphicsContext3D::drawArrays(unsigned long mode, long first, long count) +{ + switch (mode) { + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + case GL_POINTS: + case GL_LINE_STRIP: + case GL_LINE_LOOP: + case GL_LINES: + break; + default: // FIXME: default cases are discouraged in WebKit. + // FIXME: output log message, raise exception. + // LogMessage(NS_LITERAL_CSTRING("drawArrays: invalid mode")); + // return NS_ERROR_DOM_SYNTAX_ERR; + return; + } + + if (first+count < first || first+count < count) { + // FIXME: output log message, raise exception. + // LogMessage(NS_LITERAL_CSTRING("drawArrays: overflow in first+count")); + // return NS_ERROR_INVALID_ARG; + return; + } + + // FIXME: validate against currently bound buffer. + // if (!ValidateBuffers(first+count)) + // return NS_ERROR_INVALID_ARG; + + makeContextCurrent(); + glDrawArrays(mode, first, count); +} + +void GraphicsContext3D::drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset) +{ + makeContextCurrent(); + // FIXME: make this verification more efficient. + GLint binding = 0; + GLenum binding_target = GL_ELEMENT_ARRAY_BUFFER_BINDING; + glGetIntegerv(binding_target, &binding); + if (binding <= 0) { + // FIXME: raise exception. + // LogMessagef(("bufferData: no buffer bound")); + return; + } + glDrawElements(mode, count, type, + reinterpret_cast<void*>(static_cast<intptr_t>(offset))); +} + +GL_SAME_METHOD_1(Enable, enable, unsigned long) + +void GraphicsContext3D::enableVertexAttribArray(unsigned long index) +{ + m_internal->enableVertexAttribArray(index); +} + +GL_SAME_METHOD_0(Finish, finish) + +GL_SAME_METHOD_0(Flush, flush) + +GL_SAME_METHOD_4_X4(FramebufferRenderbufferEXT, framebufferRenderbuffer, unsigned long, unsigned long, unsigned long, WebGLRenderbuffer*) + +GL_SAME_METHOD_5_X4(FramebufferTexture2DEXT, framebufferTexture2D, unsigned long, unsigned long, unsigned long, WebGLTexture*, long) + +GL_SAME_METHOD_1(FrontFace, frontFace, unsigned long) + +void GraphicsContext3D::generateMipmap(unsigned long target) +{ + makeContextCurrent(); + if (glGenerateMipmapEXT) + glGenerateMipmapEXT(target); + // FIXME: provide alternative code path? This will be unpleasant + // to implement if glGenerateMipmapEXT is not available -- it will + // require a texture readback and re-upload. +} + +bool GraphicsContext3D::getActiveAttrib(WebGLProgram* program, unsigned long index, ActiveInfo& info) +{ + if (!program) { + synthesizeGLError(INVALID_VALUE); + return false; + } + GLint maxNameLength = -1; + glGetProgramiv(EXTRACT(program), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxNameLength); + if (maxNameLength < 0) + return false; + GLchar* name = 0; + if (!tryFastMalloc(maxNameLength * sizeof(GLchar)).getValue(name)) { + synthesizeGLError(OUT_OF_MEMORY); + return false; + } + GLsizei length = 0; + GLint size = -1; + GLenum type = 0; + glGetActiveAttrib(EXTRACT(program), index, maxNameLength, + &length, &size, &type, name); + if (size < 0) { + fastFree(name); + return false; + } + info.name = String(name, length); + info.type = type; + info.size = size; + fastFree(name); + return true; +} + +bool GraphicsContext3D::getActiveUniform(WebGLProgram* program, unsigned long index, ActiveInfo& info) +{ + if (!program) { + synthesizeGLError(INVALID_VALUE); + return false; + } + GLint maxNameLength = -1; + glGetProgramiv(EXTRACT(program), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameLength); + if (maxNameLength < 0) + return false; + GLchar* name = 0; + if (!tryFastMalloc(maxNameLength * sizeof(GLchar)).getValue(name)) { + synthesizeGLError(OUT_OF_MEMORY); + return false; + } + GLsizei length = 0; + GLint size = -1; + GLenum type = 0; + glGetActiveUniform(EXTRACT(program), index, maxNameLength, + &length, &size, &type, name); + if (size < 0) { + fastFree(name); + return false; + } + info.name = String(name, length); + info.type = type; + info.size = size; + fastFree(name); + return true; +} + +int GraphicsContext3D::getAttribLocation(WebGLProgram* program, const String& name) +{ + if (!program) + return -1; + + makeContextCurrent(); + return glGetAttribLocation(EXTRACT(program), name.utf8().data()); +} + +void GraphicsContext3D::getBooleanv(unsigned long pname, unsigned char* value) +{ + makeContextCurrent(); + glGetBooleanv(pname, value); +} + +void GraphicsContext3D::getBufferParameteriv(unsigned long target, unsigned long pname, int* value) +{ + makeContextCurrent(); + glGetBufferParameteriv(target, pname, value); +} + +unsigned long GraphicsContext3D::getError() +{ + return m_internal->getError(); +} + +void GraphicsContext3D::getFloatv(unsigned long pname, float* value) +{ + makeContextCurrent(); + glGetFloatv(pname, value); +} + +void GraphicsContext3D::getFramebufferAttachmentParameteriv(unsigned long target, + unsigned long attachment, + unsigned long pname, + int* value) +{ + makeContextCurrent(); + glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value); +} + +void GraphicsContext3D::getIntegerv(unsigned long pname, int* value) +{ + makeContextCurrent(); + glGetIntegerv(pname, value); +} + +void GraphicsContext3D::getProgramiv(WebGLProgram* program, + unsigned long pname, + int* value) +{ + makeContextCurrent(); + glGetProgramiv(EXTRACT(program), pname, value); +} + +String GraphicsContext3D::getProgramInfoLog(WebGLProgram* program) +{ + makeContextCurrent(); + GLuint programID = EXTRACT(program); + GLint logLength; + glGetProgramiv(programID, GL_INFO_LOG_LENGTH, &logLength); + if (!logLength) + return String(); + GLchar* log = 0; + if (!tryFastMalloc(logLength * sizeof(GLchar)).getValue(log)) + return String(); + GLsizei returnedLogLength; + glGetProgramInfoLog(programID, logLength, &returnedLogLength, log); + ASSERT(logLength == returnedLogLength + 1); + String res = String(log, returnedLogLength); + fastFree(log); + return res; +} + +void GraphicsContext3D::getRenderbufferParameteriv(unsigned long target, + unsigned long pname, + int* value) +{ + makeContextCurrent(); + glGetRenderbufferParameterivEXT(target, pname, value); +} + +void GraphicsContext3D::getShaderiv(WebGLShader* shader, + unsigned long pname, + int* value) +{ + makeContextCurrent(); + glGetShaderiv(EXTRACT(shader), pname, value); +} + +String GraphicsContext3D::getShaderInfoLog(WebGLShader* shader) +{ + makeContextCurrent(); + GLuint shaderID = EXTRACT(shader); + GLint logLength; + glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &logLength); + if (!logLength) + return String(); + GLchar* log = 0; + if (!tryFastMalloc(logLength * sizeof(GLchar)).getValue(log)) + return String(); + GLsizei returnedLogLength; + glGetShaderInfoLog(shaderID, logLength, &returnedLogLength, log); + ASSERT(logLength == returnedLogLength + 1); + String res = String(log, returnedLogLength); + fastFree(log); + return res; +} + +String GraphicsContext3D::getShaderSource(WebGLShader* shader) +{ + makeContextCurrent(); + GLuint shaderID = EXTRACT(shader); + GLint logLength; + glGetShaderiv(shaderID, GL_SHADER_SOURCE_LENGTH, &logLength); + if (!logLength) + return String(); + GLchar* log = 0; + if (!tryFastMalloc(logLength * sizeof(GLchar)).getValue(log)) + return String(); + GLsizei returnedLogLength; + glGetShaderSource(shaderID, logLength, &returnedLogLength, log); + ASSERT(logLength == returnedLogLength + 1); + String res = String(log, returnedLogLength); + fastFree(log); + return res; +} + +String GraphicsContext3D::getString(unsigned long name) +{ + makeContextCurrent(); + return String(reinterpret_cast<const char*>(glGetString(name))); +} + +void GraphicsContext3D::getTexParameterfv(unsigned long target, unsigned long pname, float* value) +{ + makeContextCurrent(); + glGetTexParameterfv(target, pname, value); +} + +void GraphicsContext3D::getTexParameteriv(unsigned long target, unsigned long pname, int* value) +{ + makeContextCurrent(); + glGetTexParameteriv(target, pname, value); +} + +void GraphicsContext3D::getUniformfv(WebGLProgram* program, long location, float* value) +{ + makeContextCurrent(); + glGetUniformfv(EXTRACT(program), location, value); +} + +void GraphicsContext3D::getUniformiv(WebGLProgram* program, long location, int* value) +{ + makeContextCurrent(); + glGetUniformiv(EXTRACT(program), location, value); +} + +long GraphicsContext3D::getUniformLocation(WebGLProgram* program, const String& name) +{ + if (!program) + return -1; + + makeContextCurrent(); + return glGetUniformLocation(EXTRACT(program), name.utf8().data()); +} + +void GraphicsContext3D::getVertexAttribfv(unsigned long index, + unsigned long pname, + float* value) +{ + makeContextCurrent(); + glGetVertexAttribfv(index, pname, value); +} + +void GraphicsContext3D::getVertexAttribiv(unsigned long index, + unsigned long pname, + int* value) +{ + makeContextCurrent(); + glGetVertexAttribiv(index, pname, value); +} + +long GraphicsContext3D::getVertexAttribOffset(unsigned long index, unsigned long pname) +{ + // FIXME: implement. + notImplemented(); + return 0; +} + +GL_SAME_METHOD_2(Hint, hint, unsigned long, unsigned long); + +bool GraphicsContext3D::isBuffer(WebGLBuffer* buffer) +{ + makeContextCurrent(); + return glIsBuffer(EXTRACT(buffer)); +} + +bool GraphicsContext3D::isEnabled(unsigned long cap) +{ + makeContextCurrent(); + return glIsEnabled(cap); +} + +bool GraphicsContext3D::isFramebuffer(WebGLFramebuffer* framebuffer) +{ + makeContextCurrent(); + return glIsFramebufferEXT(EXTRACT(framebuffer)); +} + +bool GraphicsContext3D::isProgram(WebGLProgram* program) +{ + makeContextCurrent(); + return glIsProgram(EXTRACT(program)); +} + +bool GraphicsContext3D::isRenderbuffer(WebGLRenderbuffer* renderbuffer) +{ + makeContextCurrent(); + return glIsRenderbufferEXT(EXTRACT(renderbuffer)); +} + +bool GraphicsContext3D::isShader(WebGLShader* shader) +{ + makeContextCurrent(); + return glIsShader(EXTRACT(shader)); +} + +bool GraphicsContext3D::isTexture(WebGLTexture* texture) +{ + makeContextCurrent(); + return glIsTexture(EXTRACT(texture)); +} + +GL_SAME_METHOD_1(LineWidth, lineWidth, double) + +GL_SAME_METHOD_1_X(LinkProgram, linkProgram, WebGLProgram*) + +void GraphicsContext3D::pixelStorei(unsigned long pname, long param) +{ + if (pname != GL_PACK_ALIGNMENT && pname != GL_UNPACK_ALIGNMENT) { + // FIXME: Create a fake GL error and throw an exception. + return; + } + + makeContextCurrent(); + glPixelStorei(pname, param); +} + +GL_SAME_METHOD_2(PolygonOffset, polygonOffset, double, double) + +PassRefPtr<WebGLArray> GraphicsContext3D::readPixels(long x, long y, + unsigned long width, unsigned long height, + unsigned long format, unsigned long type) { + // FIXME: support more pixel formats and types. + if (!((format == GL_RGBA) && (type == GL_UNSIGNED_BYTE))) + return 0; + + // FIXME: take into account pack alignment. + RefPtr<WebGLUnsignedByteArray> array = WebGLUnsignedByteArray::create(width * height * 4); + glReadPixels(x, y, width, height, format, type, array->baseAddress()); + return array; +} + +void GraphicsContext3D::releaseShaderCompiler() +{ +} + +GL_SAME_METHOD_4(RenderbufferStorageEXT, renderbufferStorage, unsigned long, unsigned long, unsigned long, unsigned long) + +GL_SAME_METHOD_2(SampleCoverage, sampleCoverage, double, bool) + +GL_SAME_METHOD_4(Scissor, scissor, long, long, unsigned long, unsigned long) + +void GraphicsContext3D::shaderSource(WebGLShader* shader, const String& source) +{ + makeContextCurrent(); + CString str = source.utf8(); + const char* data = str.data(); + GLint length = str.length(); + glShaderSource(EXTRACT(shader), 1, &data, &length); +} + +GL_SAME_METHOD_3(StencilFunc, stencilFunc, unsigned long, long, unsigned long) + +GL_SAME_METHOD_4(StencilFuncSeparate, stencilFuncSeparate, unsigned long, unsigned long, long, unsigned long) + +GL_SAME_METHOD_1(StencilMask, stencilMask, unsigned long) + +GL_SAME_METHOD_2(StencilMaskSeparate, stencilMaskSeparate, unsigned long, unsigned long) + +GL_SAME_METHOD_3(StencilOp, stencilOp, unsigned long, unsigned long, unsigned long) + +GL_SAME_METHOD_4(StencilOpSeparate, stencilOpSeparate, unsigned long, unsigned long, unsigned long, unsigned long) + +void GraphicsContext3D::synthesizeGLError(unsigned long error) +{ + m_internal->synthesizeGLError(error); +} + +int GraphicsContext3D::texImage2D(unsigned target, + unsigned level, + unsigned internalformat, + unsigned width, + unsigned height, + unsigned border, + unsigned format, + unsigned type, + WebGLArray* pixels) +{ + // FIXME: must do validation similar to JOGL's to ensure that + // the incoming array is of the appropriate length. + glTexImage2D(target, + level, + internalformat, + width, + height, + border, + format, + type, + pixels->baseAddress()); + return 0; +} + +int GraphicsContext3D::texImage2D(unsigned target, + unsigned level, + unsigned internalformat, + unsigned width, + unsigned height, + unsigned border, + unsigned format, + unsigned type, + ImageData* pixels) +{ + // FIXME: implement. + notImplemented(); + return -1; +} + +// Remove premultiplied alpha from color channels. +// FIXME: this is lossy. Must retrieve original values from HTMLImageElement. +static void unmultiplyAlpha(unsigned char* rgbaData, int numPixels) +{ + for (int j = 0; j < numPixels; j++) { + float b = rgbaData[4*j+0] / 255.0f; + float g = rgbaData[4*j+1] / 255.0f; + float r = rgbaData[4*j+2] / 255.0f; + float a = rgbaData[4*j+3] / 255.0f; + if (a > 0.0f) { + b /= a; + g /= a; + r /= a; + b = (b > 1.0f) ? 1.0f : b; + g = (g > 1.0f) ? 1.0f : g; + r = (r > 1.0f) ? 1.0f : r; + rgbaData[4*j+0] = (unsigned char) (b * 255.0f); + rgbaData[4*j+1] = (unsigned char) (g * 255.0f); + rgbaData[4*j+2] = (unsigned char) (r * 255.0f); + } + } +} + +// FIXME: this must be changed to refer to the original image data +// rather than unmultiplying the alpha channel. +static int texImage2DHelper(unsigned target, unsigned level, + int width, int height, + int rowBytes, + bool flipY, + bool premultiplyAlpha, + GLenum format, + bool skipAlpha, + unsigned char* pixels) +{ + ASSERT(format == GL_RGBA || format == GL_BGRA); + GLint internalFormat = GL_RGBA8; + if (skipAlpha) { + internalFormat = GL_RGB8; + // Ignore the alpha channel + premultiplyAlpha = true; + } + if (flipY) { + // Need to flip images vertically. To avoid making a copy of + // the entire image, we perform a ton of glTexSubImage2D + // calls. FIXME: should rethink this strategy for efficiency. + glTexImage2D(target, level, internalFormat, + width, + height, + 0, + format, + GL_UNSIGNED_BYTE, + 0); + unsigned char* row = 0; + bool allocatedRow = false; + if (!premultiplyAlpha) { + row = new unsigned char[rowBytes]; + allocatedRow = true; + } + for (int i = 0; i < height; i++) { + if (premultiplyAlpha) + row = pixels + (rowBytes * i); + else { + memcpy(row, pixels + (rowBytes * i), rowBytes); + unmultiplyAlpha(row, width); + } + glTexSubImage2D(target, level, 0, height - i - 1, + width, 1, + format, + GL_UNSIGNED_BYTE, + row); + } + if (allocatedRow) + delete[] row; + } else { + // The pixels of cube maps' faces are defined with a top-down + // scanline ordering, unlike GL_TEXTURE_2D, so when uploading + // these, the above vertical flip is the wrong thing to do. + if (premultiplyAlpha) + glTexImage2D(target, level, internalFormat, + width, + height, + 0, + format, + GL_UNSIGNED_BYTE, + pixels); + else { + glTexImage2D(target, level, internalFormat, + width, + height, + 0, + format, + GL_UNSIGNED_BYTE, + 0); + unsigned char* row = new unsigned char[rowBytes]; + for (int i = 0; i < height; i++) { + memcpy(row, pixels + (rowBytes * i), rowBytes); + unmultiplyAlpha(row, width); + glTexSubImage2D(target, level, 0, i, + width, 1, + format, + GL_UNSIGNED_BYTE, + row); + } + delete[] row; + } + } + return 0; +} + +int GraphicsContext3D::texImage2D(unsigned target, unsigned level, Image* image, + bool flipY, bool premultiplyAlpha) +{ + ASSERT(image); + + int res = -1; +#if PLATFORM(SKIA) + NativeImageSkia* skiaImage = image->nativeImageForCurrentFrame(); + if (!skiaImage) { + ASSERT_NOT_REACHED(); + return -1; + } + SkBitmap::Config skiaConfig = skiaImage->config(); + // FIXME: must support more image configurations. + if (skiaConfig != SkBitmap::kARGB_8888_Config) { + ASSERT_NOT_REACHED(); + return -1; + } + SkBitmap& skiaImageRef = *skiaImage; + SkAutoLockPixels lock(skiaImageRef); + int width = skiaImage->width(); + int height = skiaImage->height(); + unsigned char* pixels = + reinterpret_cast<unsigned char*>(skiaImage->getPixels()); + int rowBytes = skiaImage->rowBytes(); + res = texImage2DHelper(target, level, + width, height, + rowBytes, + flipY, premultiplyAlpha, + GL_BGRA, + false, + pixels); +#elif PLATFORM(CG) + CGImageRef cgImage = image->nativeImageForCurrentFrame(); + if (!cgImage) { + ASSERT_NOT_REACHED(); + return -1; + } + int width = CGImageGetWidth(cgImage); + int height = CGImageGetHeight(cgImage); + int rowBytes = width * 4; + CGImageAlphaInfo info = CGImageGetAlphaInfo(cgImage); + bool skipAlpha = (info == kCGImageAlphaNone + || info == kCGImageAlphaNoneSkipLast + || info == kCGImageAlphaNoneSkipFirst); + unsigned char* imageData = new unsigned char[height * rowBytes]; + CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + CGContextRef tmpContext = CGBitmapContextCreate(imageData, width, height, 8, rowBytes, + colorSpace, + kCGImageAlphaPremultipliedLast); + CGColorSpaceRelease(colorSpace); + CGContextDrawImage(tmpContext, + CGRectMake(0, 0, static_cast<CGFloat>(width), static_cast<CGFloat>(height)), + cgImage); + CGContextRelease(tmpContext); + res = texImage2DHelper(target, level, width, height, rowBytes, + flipY, premultiplyAlpha, GL_RGBA, skipAlpha, imageData); + delete[] imageData; +#else +#error Must port to your platform +#endif + return res; +} + +int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, + bool flipY, bool premultiplyAlpha) +{ + // FIXME: implement. + notImplemented(); + return -1; +} + +GL_SAME_METHOD_3(TexParameterf, texParameterf, unsigned, unsigned, float); + +GL_SAME_METHOD_3(TexParameteri, texParameteri, unsigned, unsigned, int); + +int GraphicsContext3D::texSubImage2D(unsigned target, + unsigned level, + unsigned xoffset, + unsigned yoffset, + unsigned width, + unsigned height, + unsigned format, + unsigned type, + WebGLArray* pixels) +{ + // FIXME: implement. + notImplemented(); + return -1; +} + +int GraphicsContext3D::texSubImage2D(unsigned target, + unsigned level, + unsigned xoffset, + unsigned yoffset, + unsigned width, + unsigned height, + unsigned format, + unsigned type, + ImageData* pixels) +{ + // FIXME: implement. + notImplemented(); + return -1; +} + +int GraphicsContext3D::texSubImage2D(unsigned target, + unsigned level, + unsigned xoffset, + unsigned yoffset, + unsigned width, + unsigned height, + Image* image, + bool flipY, + bool premultiplyAlpha) +{ + // FIXME: implement. + notImplemented(); + return -1; +} + +int GraphicsContext3D::texSubImage2D(unsigned target, + unsigned level, + unsigned xoffset, + unsigned yoffset, + unsigned width, + unsigned height, + HTMLVideoElement* video, + bool flipY, + bool premultiplyAlpha) +{ + // FIXME: implement. + notImplemented(); + return -1; +} + +GL_SAME_METHOD_2(Uniform1f, uniform1f, long, float) + +void GraphicsContext3D::uniform1fv(long location, float* v, int size) +{ + makeContextCurrent(); + glUniform1fv(location, size, v); +} + +GL_SAME_METHOD_2(Uniform1i, uniform1i, long, int) + +void GraphicsContext3D::uniform1iv(long location, int* v, int size) +{ + makeContextCurrent(); + glUniform1iv(location, size, v); +} + +GL_SAME_METHOD_3(Uniform2f, uniform2f, long, float, float) + +void GraphicsContext3D::uniform2fv(long location, float* v, int size) +{ + makeContextCurrent(); + glUniform2fv(location, size, v); +} + +GL_SAME_METHOD_3(Uniform2i, uniform2i, long, int, int) + +void GraphicsContext3D::uniform2iv(long location, int* v, int size) +{ + makeContextCurrent(); + glUniform2iv(location, size, v); +} + +GL_SAME_METHOD_4(Uniform3f, uniform3f, long, float, float, float) + +void GraphicsContext3D::uniform3fv(long location, float* v, int size) +{ + makeContextCurrent(); + glUniform3fv(location, size, v); +} + +GL_SAME_METHOD_4(Uniform3i, uniform3i, long, int, int, int) + +void GraphicsContext3D::uniform3iv(long location, int* v, int size) +{ + makeContextCurrent(); + glUniform3iv(location, size, v); +} + +GL_SAME_METHOD_5(Uniform4f, uniform4f, long, float, float, float, float) + +void GraphicsContext3D::uniform4fv(long location, float* v, int size) +{ + makeContextCurrent(); + glUniform4fv(location, size, v); +} + +GL_SAME_METHOD_5(Uniform4i, uniform4i, long, int, int, int, int) + +void GraphicsContext3D::uniform4iv(long location, int* v, int size) +{ + makeContextCurrent(); + glUniform4iv(location, size, v); +} + +void GraphicsContext3D::uniformMatrix2fv(long location, bool transpose, float* value, int size) +{ + makeContextCurrent(); + glUniformMatrix2fv(location, size, transpose, value); +} + +void GraphicsContext3D::uniformMatrix3fv(long location, bool transpose, float* value, int size) +{ + makeContextCurrent(); + glUniformMatrix3fv(location, size, transpose, value); +} + +void GraphicsContext3D::uniformMatrix4fv(long location, bool transpose, float* value, int size) +{ + makeContextCurrent(); + glUniformMatrix4fv(location, size, transpose, value); +} + +GL_SAME_METHOD_1_X(UseProgram, useProgram, WebGLProgram*) + +GL_SAME_METHOD_1_X(ValidateProgram, validateProgram, WebGLProgram*) + +GL_SAME_METHOD_2(VertexAttrib1f, vertexAttrib1f, unsigned long, float) + +void GraphicsContext3D::vertexAttrib1fv(unsigned long indx, float* values) +{ + makeContextCurrent(); + glVertexAttrib1fv(indx, values); +} + +GL_SAME_METHOD_3(VertexAttrib2f, vertexAttrib2f, unsigned long, float, float) + +void GraphicsContext3D::vertexAttrib2fv(unsigned long indx, float* values) +{ + makeContextCurrent(); + glVertexAttrib2fv(indx, values); +} + +GL_SAME_METHOD_4(VertexAttrib3f, vertexAttrib3f, unsigned long, float, float, float) + +void GraphicsContext3D::vertexAttrib3fv(unsigned long indx, float* values) +{ + makeContextCurrent(); + glVertexAttrib3fv(indx, values); +} + +GL_SAME_METHOD_5(VertexAttrib4f, vertexAttrib4f, unsigned long, float, float, float, float) + +void GraphicsContext3D::vertexAttrib4fv(unsigned long indx, float* values) +{ + makeContextCurrent(); + glVertexAttrib4fv(indx, values); +} + +void GraphicsContext3D::vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, + unsigned long stride, unsigned long offset) +{ + m_internal->vertexAttribPointer(indx, size, type, normalized, stride, offset); +} + +void GraphicsContext3D::viewport(long x, long y, unsigned long width, unsigned long height) +{ + makeContextCurrent(); + m_internal->viewportImpl(x, y, width, height); +} + +} + +#endif // ENABLE(3D_CANVAS) diff --git a/WebKit/chromium/src/InspectorClientImpl.cpp b/WebKit/chromium/src/InspectorClientImpl.cpp new file mode 100644 index 0000000..54550d1 --- /dev/null +++ b/WebKit/chromium/src/InspectorClientImpl.cpp @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "InspectorClientImpl.h" + +#include "DOMWindow.h" +#include "FloatRect.h" +#include "InspectorController.h" +#include "NotImplemented.h" +#include "Page.h" +#include "Settings.h" +#include "WebRect.h" +#include "WebURL.h" +#include "WebURLRequest.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" +#include <wtf/Vector.h> + +using namespace WebCore; + +namespace WebKit { + +InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView) + : m_inspectedWebView(webView) +{ + ASSERT(m_inspectedWebView); +} + +InspectorClientImpl::~InspectorClientImpl() +{ +} + +void InspectorClientImpl::inspectorDestroyed() +{ + // Our lifetime is bound to the WebViewImpl. +} + +Page* InspectorClientImpl::createPage() +{ + // This method should never be called in Chrome as inspector front-end lives + // in a separate process. + ASSERT_NOT_REACHED(); + return 0; +} + +void InspectorClientImpl::showWindow() +{ + ASSERT(m_inspectedWebView->devToolsAgentPrivate()); + m_inspectedWebView->page()->inspectorController()->setWindowVisible(true); +} + +void InspectorClientImpl::closeWindow() +{ + if (m_inspectedWebView->page()) + m_inspectedWebView->page()->inspectorController()->setWindowVisible(false); +} + +bool InspectorClientImpl::windowVisible() +{ + ASSERT(m_inspectedWebView->devToolsAgentPrivate()); + return false; +} + +void InspectorClientImpl::attachWindow() +{ + // FIXME: Implement this +} + +void InspectorClientImpl::detachWindow() +{ + // FIXME: Implement this +} + +void InspectorClientImpl::setAttachedWindowHeight(unsigned int height) +{ + // FIXME: Implement this + notImplemented(); +} + +static void invalidateNodeBoundingRect(WebViewImpl* webView) +{ + // FIXME: Is it important to just invalidate the rect of the node region + // given that this is not on a critical codepath? In order to do so, we'd + // have to take scrolling into account. + const WebSize& size = webView->size(); + WebRect damagedRect(0, 0, size.width, size.height); + if (webView->client()) + webView->client()->didInvalidateRect(damagedRect); +} + +void InspectorClientImpl::highlight(Node* node) +{ + // InspectorController does the actually tracking of the highlighted node + // and the drawing of the highlight. Here we just make sure to invalidate + // the rects of the old and new nodes. + hideHighlight(); +} + +void InspectorClientImpl::hideHighlight() +{ + // FIXME: able to invalidate a smaller rect. + invalidateNodeBoundingRect(m_inspectedWebView); +} + +void InspectorClientImpl::inspectedURLChanged(const String& newURL) +{ + // FIXME: Implement this +} + +String InspectorClientImpl::localizedStringsURL() +{ + notImplemented(); + return String(); +} + +String InspectorClientImpl::hiddenPanels() +{ + notImplemented(); + return ""; +} + +void InspectorClientImpl::populateSetting(const String& key, String* value) +{ + loadSettings(); + if (m_settings->contains(key)) + *value = m_settings->get(key); +} + +void InspectorClientImpl::storeSetting(const String& key, const String& value) +{ + loadSettings(); + m_settings->set(key, value); + saveSettings(); +} + +void InspectorClientImpl::inspectorWindowObjectCleared() +{ + notImplemented(); +} + +void InspectorClientImpl::loadSettings() +{ + if (m_settings) + return; + + m_settings.set(new SettingsMap); + String data = m_inspectedWebView->inspectorSettings(); + if (data.isEmpty()) + return; + + Vector<String> entries; + data.split("\n", entries); + for (Vector<String>::iterator it = entries.begin(); it != entries.end(); ++it) { + Vector<String> tokens; + it->split(":", tokens); + if (tokens.size() < 3) + continue; + + String name = decodeURLEscapeSequences(tokens[0]); + String type = tokens[1]; + String value = tokens[2]; + for (size_t i = 3; i < tokens.size(); ++i) + value += ":" + tokens[i]; + + if (type == "string") + value = decodeURLEscapeSequences(value); + + m_settings->set(name, value); + } +} + +void InspectorClientImpl::saveSettings() +{ + String data; + for (SettingsMap::iterator it = m_settings->begin(); it != m_settings->end(); ++it) { + String name = encodeWithURLEscapeSequences(it->first); + String value = it->second; + String entry = String::format( + "%s:string:%s", + name.utf8().data(), + encodeWithURLEscapeSequences(value).utf8().data()); + data.append(entry); + data.append("\n"); + } + m_inspectedWebView->setInspectorSettings(data); + if (m_inspectedWebView->client()) + m_inspectedWebView->client()->didUpdateInspectorSettings(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/InspectorClientImpl.h b/WebKit/chromium/src/InspectorClientImpl.h new file mode 100644 index 0000000..6f7f8b1 --- /dev/null +++ b/WebKit/chromium/src/InspectorClientImpl.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 InspectorClientImpl_h +#define InspectorClientImpl_h + +#include "InspectorClient.h" +#include "InspectorController.h" +#include <wtf/OwnPtr.h> + +namespace WebKit { +class WebViewImpl; + +class InspectorClientImpl : public WebCore::InspectorClient { +public: + InspectorClientImpl(WebViewImpl*); + ~InspectorClientImpl(); + + // InspectorClient methods: + virtual void inspectorDestroyed(); + virtual WebCore::Page* createPage(); + virtual WebCore::String localizedStringsURL(); + virtual WebCore::String hiddenPanels(); + virtual void showWindow(); + virtual void closeWindow(); + virtual bool windowVisible(); + virtual void attachWindow(); + virtual void detachWindow(); + virtual void setAttachedWindowHeight(unsigned height); + virtual void highlight(WebCore::Node*); + virtual void hideHighlight(); + virtual void inspectedURLChanged(const WebCore::String& newURL); + virtual void populateSetting( + const WebCore::String& key, + WebCore::String* value); + virtual void storeSetting( + const WebCore::String& key, + const WebCore::String& value); + virtual void inspectorWindowObjectCleared(); + +private: + void loadSettings(); + void saveSettings(); + + // The WebViewImpl of the page being inspected; gets passed to the constructor + WebViewImpl* m_inspectedWebView; + + typedef HashMap<WebCore::String, WebCore::String> SettingsMap; + OwnPtr<SettingsMap> m_settings; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/LocalizedStrings.cpp b/WebKit/chromium/src/LocalizedStrings.cpp new file mode 100644 index 0000000..1121931 --- /dev/null +++ b/WebKit/chromium/src/LocalizedStrings.cpp @@ -0,0 +1,307 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "LocalizedStrings.h" + +#include "IntSize.h" +#include "NotImplemented.h" +#include "PlatformString.h" +#include "StringBuilder.h" + +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebLocalizedString.h" +#include "WebString.h" + +using WebKit::WebLocalizedString; + +namespace WebCore { + +static String query(WebLocalizedString::Name name) +{ + return WebKit::webKitClient()->queryLocalizedString(name); +} + +static String query(WebLocalizedString::Name name, int numericValue) +{ + return WebKit::webKitClient()->queryLocalizedString(name, numericValue); +} + +String searchableIndexIntroduction() +{ + return query(WebLocalizedString::SearchableIndexIntroduction); +} + +String submitButtonDefaultLabel() +{ + return query(WebLocalizedString::SubmitButtonDefaultLabel); +} + +String inputElementAltText() +{ + return query(WebLocalizedString::InputElementAltText); +} + +String resetButtonDefaultLabel() +{ + return query(WebLocalizedString::ResetButtonDefaultLabel); +} + +String fileButtonChooseFileLabel() +{ + return query(WebLocalizedString::FileButtonChooseFileLabel); +} + +String fileButtonNoFileSelectedLabel() +{ + return query(WebLocalizedString::FileButtonNoFileSelectedLabel); +} + +String searchMenuNoRecentSearchesText() +{ + return query(WebLocalizedString::SearchMenuNoRecentSearchesText); +} +String searchMenuRecentSearchesText() +{ + return query(WebLocalizedString::SearchMenuRecentSearchesText); +} +String searchMenuClearRecentSearchesText() +{ + return query(WebLocalizedString::SearchMenuClearRecentSearchesText); +} + +String AXWebAreaText() +{ + return query(WebLocalizedString::AXWebAreaText); +} + +String AXLinkText() +{ + return query(WebLocalizedString::AXLinkText); +} + +String AXListMarkerText() +{ + return query(WebLocalizedString::AXListMarkerText); +} + +String AXImageMapText() +{ + return query(WebLocalizedString::AXImageMapText); +} + +String AXHeadingText() +{ + return query(WebLocalizedString::AXHeadingText); +} + +String AXDefinitionListTermText() +{ + notImplemented(); + return String("term"); +} + +String AXDefinitionListDefinitionText() +{ + notImplemented(); + return String("definition"); +} + +String AXButtonActionVerb() +{ + return query(WebLocalizedString::AXButtonActionVerb); +} + +String AXRadioButtonActionVerb() +{ + return query(WebLocalizedString::AXRadioButtonActionVerb); +} + +String AXTextFieldActionVerb() +{ + return query(WebLocalizedString::AXTextFieldActionVerb); +} + +String AXCheckedCheckBoxActionVerb() +{ + return query(WebLocalizedString::AXCheckedCheckBoxActionVerb); +} + +String AXUncheckedCheckBoxActionVerb() +{ + return query(WebLocalizedString::AXUncheckedCheckBoxActionVerb); +} + +String AXLinkActionVerb() +{ + return query(WebLocalizedString::AXLinkActionVerb); +} + +String multipleFileUploadText(unsigned numberOfFiles) +{ + return query(WebLocalizedString::MultipleFileUploadText, numberOfFiles); +} + +// Used in FTPDirectoryDocument.cpp +String unknownFileSizeText() +{ + return String(); +} + +// The following two functions are not declared in LocalizedStrings.h. +// They are used by the menu for the HTML keygen tag. +String keygenMenuHighGradeKeySize() +{ + return query(WebLocalizedString::KeygenMenuHighGradeKeySize); +} + +String keygenMenuMediumGradeKeySize() +{ + return query(WebLocalizedString::KeygenMenuMediumGradeKeySize); +} + +// Used in ImageDocument.cpp as the title for pages when that page is an image. +String imageTitle(const String& filename, const IntSize& size) +{ + // Note that we cannot use String::format because it works for ASCII only. + StringBuilder result; + result.append(filename); + result.append(" ("); + result.append(String::number(size.width())); + result.append(static_cast<UChar>(0xD7)); // U+00D7 (multiplication sign) + result.append(String::number(size.height())); + result.append(")"); + return result.toString(); +} + +// We don't use these strings, so they return an empty String. We can't just +// make them asserts because webcore still calls them. +String contextMenuItemTagOpenLinkInNewWindow() { return String(); } +String contextMenuItemTagDownloadLinkToDisk() { return String(); } +String contextMenuItemTagCopyLinkToClipboard() { return String(); } +String contextMenuItemTagOpenImageInNewWindow() { return String(); } +String contextMenuItemTagDownloadImageToDisk() { return String(); } +String contextMenuItemTagCopyImageToClipboard() { return String(); } +String contextMenuItemTagOpenFrameInNewWindow() { return String(); } +String contextMenuItemTagCopy() { return String(); } +String contextMenuItemTagGoBack() { return String(); } +String contextMenuItemTagGoForward() { return String(); } +String contextMenuItemTagStop() { return String(); } +String contextMenuItemTagReload() { return String(); } +String contextMenuItemTagCut() { return String(); } +String contextMenuItemTagPaste() { return String(); } +String contextMenuItemTagNoGuessesFound() { return String(); } +String contextMenuItemTagIgnoreSpelling() { return String(); } +String contextMenuItemTagLearnSpelling() { return String(); } +String contextMenuItemTagSearchWeb() { return String(); } +String contextMenuItemTagLookUpInDictionary() { return String(); } +String contextMenuItemTagOpenLink() { return String(); } +String contextMenuItemTagIgnoreGrammar() { return String(); } +String contextMenuItemTagSpellingMenu() { return String(); } +String contextMenuItemTagCheckSpelling() { return String(); } +String contextMenuItemTagCheckSpellingWhileTyping() { return String(); } +String contextMenuItemTagCheckGrammarWithSpelling() { return String(); } +String contextMenuItemTagFontMenu() { return String(); } +String contextMenuItemTagBold() { return String(); } +String contextMenuItemTagItalic() { return String(); } +String contextMenuItemTagUnderline() { return String(); } +String contextMenuItemTagOutline() { return String(); } +String contextMenuItemTagWritingDirectionMenu() { return String(); } +String contextMenuItemTagTextDirectionMenu() { return String(); } +String contextMenuItemTagDefaultDirection() { return String(); } +String contextMenuItemTagLeftToRight() { return String(); } +String contextMenuItemTagRightToLeft() { return String(); } +String contextMenuItemTagInspectElement() { return String(); } +String contextMenuItemTagShowSpellingPanel(bool show) { return String(); } +String mediaElementLiveBroadcastStateText() { return String(); } +String mediaElementLoadingStateText() { return String(); } + +String localizedMediaControlElementString(const String& /*name*/) +{ + // FIXME: to be fixed. + return String(); +} + +String localizedMediaControlElementHelpText(const String& /*name*/) +{ + // FIXME: to be fixed. + return String(); +} + +String localizedMediaTimeDescription(float /*time*/) +{ + // FIXME: to be fixed. + return String(); +} + +String validationMessageValueMissingText() +{ + notImplemented(); + return String(); +} + +String validationMessageTypeMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessagePatternMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessageTooLongText() +{ + notImplemented(); + return String(); +} + +String validationMessageRangeUnderflowText() +{ + notImplemented(); + return String(); +} + +String validationMessageRangeOverflowText() +{ + notImplemented(); + return String(); +} + +String validationMessageStepMismatchText() +{ + notImplemented(); + return String(); +} + +} // namespace WebCore diff --git a/WebKit/chromium/src/MediaPlayerPrivateChromium.cpp b/WebKit/chromium/src/MediaPlayerPrivateChromium.cpp new file mode 100644 index 0000000..09d33d4 --- /dev/null +++ b/WebKit/chromium/src/MediaPlayerPrivateChromium.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "MediaPlayerPrivateChromium.h" + +#if ENABLE(VIDEO) + +#include "WebMediaPlayerClientImpl.h" + +namespace WebCore { + +void MediaPlayerPrivate::registerMediaEngine(MediaEngineRegistrar registrar) +{ + WebKit::WebMediaPlayerClientImpl::registerSelf(registrar); +} + +} // namespace WebCore + +#endif diff --git a/WebKit/chromium/src/NotificationPresenterImpl.cpp b/WebKit/chromium/src/NotificationPresenterImpl.cpp new file mode 100644 index 0000000..6b22319 --- /dev/null +++ b/WebKit/chromium/src/NotificationPresenterImpl.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "NotificationPresenterImpl.h" + +#if ENABLE(NOTIFICATIONS) + +#include "Notification.h" +#include "SecurityOrigin.h" + +#include "WebNotification.h" +#include "WebNotificationPermissionCallback.h" +#include "WebNotificationPresenter.h" + +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class VoidCallbackClient : public WebNotificationPermissionCallback { +public: + VoidCallbackClient(PassRefPtr<VoidCallback> callback) + : m_callback(callback) + { + } + + virtual void permissionRequestComplete() + { + if (m_callback) + m_callback->handleEvent(); + delete this; + } + +private: + RefPtr<VoidCallback> m_callback; +}; + +void NotificationPresenterImpl::initialize(WebNotificationPresenter* presenter) +{ + m_presenter = presenter; +} + +bool NotificationPresenterImpl::isInitialized() +{ + return !!m_presenter; +} + +bool NotificationPresenterImpl::show(Notification* notification) +{ + return m_presenter->show(PassRefPtr<Notification>(notification)); +} + +void NotificationPresenterImpl::cancel(Notification* notification) +{ + m_presenter->cancel(PassRefPtr<Notification>(notification)); +} + +void NotificationPresenterImpl::notificationObjectDestroyed(Notification* notification) +{ + m_presenter->objectDestroyed(PassRefPtr<Notification>(notification)); +} + +NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(SecurityOrigin* origin) +{ + int result = m_presenter->checkPermission(origin->toString()); + return static_cast<NotificationPresenter::Permission>(result); +} + +void NotificationPresenterImpl::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback) +{ + m_presenter->requestPermission(origin->toString(), new VoidCallbackClient(callback)); +} + +} // namespace WebKit + +#endif // ENABLE(NOTIFICATIONS) diff --git a/WebKit/chromium/src/NotificationPresenterImpl.h b/WebKit/chromium/src/NotificationPresenterImpl.h new file mode 100644 index 0000000..4afe9dc --- /dev/null +++ b/WebKit/chromium/src/NotificationPresenterImpl.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 NotificationPresenterImpl_h +#define NotificationPresenterImpl_h + +#include "NotificationPresenter.h" +#include "VoidCallback.h" + +#include <wtf/HashMap.h> +#include <wtf/PassRefPtr.h> + +#if ENABLE(NOTIFICATIONS) + +namespace WebKit { + +class WebNotificationPresenter; + +class NotificationPresenterImpl : public WebCore::NotificationPresenter { +public: + NotificationPresenterImpl() : m_presenter(0) { } + + void initialize(WebNotificationPresenter* presenter); + bool isInitialized(); + + // WebCore::NotificationPresenter implementation. + virtual bool show(WebCore::Notification* object); + virtual void cancel(WebCore::Notification* object); + virtual void notificationObjectDestroyed(WebCore::Notification* object); + virtual WebCore::NotificationPresenter::Permission checkPermission(WebCore::SecurityOrigin* origin); + virtual void requestPermission(WebCore::SecurityOrigin* origin, WTF::PassRefPtr<WebCore::VoidCallback> callback); + +private: + // WebNotificationPresenter that this object delegates to. + WebNotificationPresenter* m_presenter; +}; + +} // namespace WebKit + +#endif // ENABLE(NOTIFICATIONS) + +#endif diff --git a/WebKit/chromium/src/PlatformMessagePortChannel.cpp b/WebKit/chromium/src/PlatformMessagePortChannel.cpp new file mode 100644 index 0000000..f8c41d3 --- /dev/null +++ b/WebKit/chromium/src/PlatformMessagePortChannel.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "PlatformMessagePortChannel.h" + +#include "MessagePort.h" +#include "ScriptExecutionContext.h" +#include "SerializedScriptValue.h" + +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebMessagePortChannel.h" +#include "WebString.h" + +using namespace WebKit; + +namespace WebCore { + +PassOwnPtr<MessagePortChannel> MessagePortChannel::create(PassRefPtr<PlatformMessagePortChannel> channel) +{ + return new MessagePortChannel(channel); +} + +void MessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2) +{ + PlatformMessagePortChannel::createChannel(port1, port2); +} + +MessagePortChannel::MessagePortChannel(PassRefPtr<PlatformMessagePortChannel> channel) + : m_channel(channel) +{ +} + +MessagePortChannel::~MessagePortChannel() +{ + // Make sure we close our platform channel when the base is freed, to keep the channel objects from leaking. + m_channel->close(); +} + +bool MessagePortChannel::entangleIfOpen(MessagePort* port) +{ + return m_channel->entangleIfOpen(port); +} + +void MessagePortChannel::disentangle() +{ + m_channel->disentangle(); +} + +void MessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message) +{ + m_channel->postMessageToRemote(message); +} + +bool MessagePortChannel::tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>& result) +{ + return m_channel->tryGetMessageFromRemote(result); +} + +void MessagePortChannel::close() +{ + m_channel->close(); +} + +bool MessagePortChannel::isConnectedTo(MessagePort* port) +{ + return m_channel->isConnectedTo(port); +} + +bool MessagePortChannel::hasPendingActivity() +{ + return m_channel->hasPendingActivity(); +} + +MessagePort* MessagePortChannel::locallyEntangledPort(const ScriptExecutionContext* context) +{ + // This is just an optimization, so return 0 always. + return 0; +} + + +PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create() +{ + return adoptRef(new PlatformMessagePortChannel()); +} + +PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create( + WebMessagePortChannel* channel) +{ + return adoptRef(new PlatformMessagePortChannel(channel)); +} + + +PlatformMessagePortChannel::PlatformMessagePortChannel() + : m_localPort(0) +{ + m_webChannel = webKitClient()->createMessagePortChannel(); + if (m_webChannel) + m_webChannel->setClient(this); +} + +PlatformMessagePortChannel::PlatformMessagePortChannel(WebMessagePortChannel* channel) + : m_localPort(0) + , m_webChannel(channel) +{ +} + +PlatformMessagePortChannel::~PlatformMessagePortChannel() +{ + if (m_webChannel) + m_webChannel->destroy(); +} + +void PlatformMessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2) +{ + // Create proxies for each endpoint. + RefPtr<PlatformMessagePortChannel> channel1 = PlatformMessagePortChannel::create(); + RefPtr<PlatformMessagePortChannel> channel2 = PlatformMessagePortChannel::create(); + + // Entangle the two endpoints. + channel1->setEntangledChannel(channel2); + channel2->setEntangledChannel(channel1); + + // Now entangle the proxies with the appropriate local ports. + port1->entangle(MessagePortChannel::create(channel2)); + port2->entangle(MessagePortChannel::create(channel1)); +} + +void PlatformMessagePortChannel::messageAvailable() +{ + MutexLocker lock(m_mutex); + if (m_localPort) + m_localPort->messageAvailable(); +} + +bool PlatformMessagePortChannel::entangleIfOpen(MessagePort* port) +{ + MutexLocker lock(m_mutex); + m_localPort = port; + return true; +} + +void PlatformMessagePortChannel::disentangle() +{ + MutexLocker lock(m_mutex); + m_localPort = 0; +} + +void PlatformMessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message) +{ + if (!m_localPort || !m_webChannel) + return; + + WebString messageString = message->message()->toString(); + OwnPtr<WebCore::MessagePortChannelArray> channels = message->channels(); + WebMessagePortChannelArray* webChannels = 0; + if (channels.get() && channels->size()) { + webChannels = new WebMessagePortChannelArray(channels->size()); + for (size_t i = 0; i < channels->size(); ++i) { + WebCore::PlatformMessagePortChannel* platformChannel = (*channels)[i]->channel(); + (*webChannels)[i] = platformChannel->webChannelRelease(); + (*webChannels)[i]->setClient(0); + } + } + m_webChannel->postMessage(messageString, webChannels); +} + +bool PlatformMessagePortChannel::tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>& result) +{ + if (!m_webChannel) + return false; + + WebString message; + WebMessagePortChannelArray webChannels; + bool rv = m_webChannel->tryGetMessage(&message, webChannels); + if (rv) { + OwnPtr<MessagePortChannelArray> channels; + if (webChannels.size()) { + channels = new MessagePortChannelArray(webChannels.size()); + for (size_t i = 0; i < webChannels.size(); ++i) { + RefPtr<PlatformMessagePortChannel> platformChannel = create(webChannels[i]); + webChannels[i]->setClient(platformChannel.get()); + (*channels)[i] = MessagePortChannel::create(platformChannel); + } + } + RefPtr<SerializedScriptValue> serializedMessage = SerializedScriptValue::create(message); + result = MessagePortChannel::EventData::create(serializedMessage.release(), channels.release()); + } + + return rv; +} + +void PlatformMessagePortChannel::close() +{ + MutexLocker lock(m_mutex); + // Disentangle ourselves from the other end. We still maintain a reference to m_webChannel, + // since previously-existing messages should still be delivered. + m_localPort = 0; + m_entangledChannel = 0; +} + +bool PlatformMessagePortChannel::isConnectedTo(MessagePort* port) +{ + MutexLocker lock(m_mutex); + return m_entangledChannel && m_entangledChannel->m_localPort == port; +} + +bool PlatformMessagePortChannel::hasPendingActivity() +{ + MutexLocker lock(m_mutex); + return m_localPort; +} + +void PlatformMessagePortChannel::setEntangledChannel(PassRefPtr<PlatformMessagePortChannel> remote) +{ + if (m_webChannel) + m_webChannel->entangle(remote->m_webChannel); + + MutexLocker lock(m_mutex); + m_entangledChannel = remote; +} + +WebMessagePortChannel* PlatformMessagePortChannel::webChannelRelease() +{ + WebMessagePortChannel* rv = m_webChannel; + m_webChannel = 0; + return rv; +} + +} // namespace WebCore diff --git a/WebKit/chromium/src/PlatformMessagePortChannel.h b/WebKit/chromium/src/PlatformMessagePortChannel.h new file mode 100644 index 0000000..05e8397 --- /dev/null +++ b/WebKit/chromium/src/PlatformMessagePortChannel.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 PlatformMessagePortChannel_h +#define PlatformMessagePortChannel_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebMessagePortChannelClient.h" + +#include "MessagePortChannel.h" + +#include <wtf/PassRefPtr.h> +#include <wtf/Threading.h> + +namespace WebKit { +class WebMessagePortChannel; +} + +namespace WebCore { + +class MessagePort; + +// PlatformMessagePortChannel is a platform-dependent interface to the remote side of a message channel. +class PlatformMessagePortChannel : public ThreadSafeShared<PlatformMessagePortChannel>, + public WebKit::WebMessagePortChannelClient { +public: + static void createChannel(PassRefPtr<MessagePort>, PassRefPtr<MessagePort>); + static PassRefPtr<PlatformMessagePortChannel> create(); + static PassRefPtr<PlatformMessagePortChannel> create(WebKit::WebMessagePortChannel*); + + // APIs delegated from MessagePortChannel.h + bool entangleIfOpen(MessagePort*); + void disentangle(); + void postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData>); + bool tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>&); + void close(); + bool isConnectedTo(MessagePort* port); + bool hasPendingActivity(); + + // Releases ownership of the contained web channel. + WebKit::WebMessagePortChannel* webChannelRelease(); + + ~PlatformMessagePortChannel(); + +private: + PlatformMessagePortChannel(); + PlatformMessagePortChannel(WebKit::WebMessagePortChannel*); + + void setEntangledChannel(PassRefPtr<PlatformMessagePortChannel>); + + // WebKit::WebMessagePortChannelClient implementation + virtual void messageAvailable(); + + // Mutex used to ensure exclusive access to the object internals. + Mutex m_mutex; + + // Pointer to our entangled pair - cleared when close() is called. + RefPtr<PlatformMessagePortChannel> m_entangledChannel; + + // The port we are connected to - this is the port that is notified when new messages arrive. + MessagePort* m_localPort; + + WebKit::WebMessagePortChannel* m_webChannel; +}; + +} // namespace WebCore + +#endif // PlatformMessagePortChannel_h diff --git a/WebKit/chromium/src/ResourceHandle.cpp b/WebKit/chromium/src/ResourceHandle.cpp new file mode 100644 index 0000000..bf6910f --- /dev/null +++ b/WebKit/chromium/src/ResourceHandle.cpp @@ -0,0 +1,282 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "ResourceHandle.h" + +#include "ResourceHandleClient.h" +#include "ResourceRequest.h" + +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebURLError.h" +#include "WebURLLoader.h" +#include "WebURLLoaderClient.h" +#include "WebURLRequest.h" +#include "WebURLResponse.h" +#include "WrappedResourceRequest.h" +#include "WrappedResourceResponse.h" + +using namespace WebKit; + +namespace WebCore { + +// ResourceHandleInternal ----------------------------------------------------- + +class ResourceHandleInternal : public WebURLLoaderClient { +public: + ResourceHandleInternal(const ResourceRequest& request, ResourceHandleClient* client) + : m_request(request) + , m_owner(0) + , m_client(client) + { + } + + void start(); + void cancel(); + void setDefersLoading(bool); + bool allowStoredCredentials() const; + + // WebURLLoaderClient methods: + virtual void willSendRequest(WebURLLoader*, WebURLRequest&, const WebURLResponse&); + virtual void didSendData( + WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent); + virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&); + virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength); + virtual void didFinishLoading(WebURLLoader*); + virtual void didFail(WebURLLoader*, const WebURLError&); + + ResourceRequest m_request; + ResourceHandle* m_owner; + ResourceHandleClient* m_client; + OwnPtr<WebURLLoader> m_loader; +}; + +void ResourceHandleInternal::start() +{ + m_loader.set(webKitClient()->createURLLoader()); + ASSERT(m_loader.get()); + + WrappedResourceRequest wrappedRequest(m_request); + wrappedRequest.setAllowStoredCredentials(allowStoredCredentials()); + m_loader->loadAsynchronously(wrappedRequest, this); +} + +void ResourceHandleInternal::cancel() +{ + m_loader->cancel(); + + // Do not make any further calls to the client. + m_client = 0; +} + +void ResourceHandleInternal::setDefersLoading(bool value) +{ + m_loader->setDefersLoading(value); +} + +bool ResourceHandleInternal::allowStoredCredentials() const +{ + return m_client && m_client->shouldUseCredentialStorage(m_owner); +} + +void ResourceHandleInternal::willSendRequest( + WebURLLoader*, WebURLRequest& request, const WebURLResponse& response) +{ + ASSERT(m_client); + ASSERT(!request.isNull()); + ASSERT(!response.isNull()); + m_client->willSendRequest(m_owner, request.toMutableResourceRequest(), response.toResourceResponse()); +} + +void ResourceHandleInternal::didSendData( + WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) +{ + ASSERT(m_client); + m_client->didSendData(m_owner, bytesSent, totalBytesToBeSent); +} + +void ResourceHandleInternal::didReceiveResponse(WebURLLoader*, const WebURLResponse& response) +{ + ASSERT(m_client); + ASSERT(!response.isNull()); + m_client->didReceiveResponse(m_owner, response.toResourceResponse()); +} + +void ResourceHandleInternal::didReceiveData( + WebURLLoader*, const char* data, int dataLength) +{ + ASSERT(m_client); + + // FIXME(yurys): it looks like lengthReceived is always the same as + // dataLength and that the latter parameter can be eliminated. + // See WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=31019 + m_client->didReceiveData(m_owner, data, dataLength, dataLength); +} + +void ResourceHandleInternal::didFinishLoading(WebURLLoader*) +{ + ASSERT(m_client); + m_client->didFinishLoading(m_owner); +} + +void ResourceHandleInternal::didFail(WebURLLoader*, const WebURLError& error) +{ + ASSERT(m_client); + m_client->didFail(m_owner, error); +} + +// ResourceHandle ------------------------------------------------------------- + +ResourceHandle::ResourceHandle(const ResourceRequest& request, + ResourceHandleClient* client, + bool defersLoading, + bool shouldContentSniff, + bool mightDownloadFromHandle) + : d(new ResourceHandleInternal(request, client)) +{ + d->m_owner = this; + + // FIXME: Figure out what to do with the bool params. +} + +PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request, + ResourceHandleClient* client, + Frame* deprecated, + bool defersLoading, + bool shouldContentSniff, + bool mightDownloadFromHandle) +{ + RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle( + request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle)); + + if (newHandle->start(deprecated)) + return newHandle.release(); + + return 0; +} + +const ResourceRequest& ResourceHandle::request() const +{ + return d->m_request; +} + +ResourceHandleClient* ResourceHandle::client() const +{ + return d->m_client; +} + +void ResourceHandle::setClient(ResourceHandleClient* client) +{ + d->m_client = client; +} + +void ResourceHandle::setDefersLoading(bool value) +{ + d->setDefersLoading(value); +} + +bool ResourceHandle::start(Frame* deprecated) +{ + d->start(); + return true; +} + +void ResourceHandle::clearAuthentication() +{ +} + +void ResourceHandle::cancel() +{ + d->cancel(); +} + +ResourceHandle::~ResourceHandle() +{ + d->m_owner = 0; +} + +PassRefPtr<SharedBuffer> ResourceHandle::bufferedData() +{ + return 0; +} + +bool ResourceHandle::loadsBlocked() +{ + return false; // This seems to be related to sync XMLHttpRequest... +} + +// static +bool ResourceHandle::supportsBufferedData() +{ + return false; // The loader will buffer manually if it needs to. +} + +// static +void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, + StoredCredentials storedCredentials, + ResourceError& error, + ResourceResponse& response, + Vector<char>& data, + Frame* deprecated) +{ + OwnPtr<WebURLLoader> loader(webKitClient()->createURLLoader()); + ASSERT(loader.get()); + + WrappedResourceRequest requestIn(request); + requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredentials); + WrappedResourceResponse responseOut(response); + WebURLError errorOut; + WebData dataOut; + + loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); + + error = errorOut; + data.clear(); + data.append(dataOut.data(), dataOut.size()); +} + +// static +bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*) +{ + // This method is used to determine if a POST request can be repeated from + // cache, but you cannot really know until you actually try to read from the + // cache. Even if we checked now, something else could come along and wipe + // out the cache entry by the time we fetch it. + // + // So, we always say yes here, to prevent the FrameLoader from initiating a + // reload. Then in FrameLoaderClientImpl::dispatchWillSendRequest, we + // fix-up the cache policy of the request to force a load from the cache. + // + ASSERT(request.httpMethod() == "POST"); + return true; +} + +} // namespace WebCore diff --git a/WebKit/chromium/src/SharedWorkerRepository.cpp b/WebKit/chromium/src/SharedWorkerRepository.cpp new file mode 100644 index 0000000..5e5bc46 --- /dev/null +++ b/WebKit/chromium/src/SharedWorkerRepository.cpp @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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" + +#if ENABLE(SHARED_WORKERS) + +#include "SharedWorkerRepository.h" + +#include "Event.h" +#include "EventNames.h" +#include "MessagePortChannel.h" +#include "PlatformMessagePortChannel.h" +#include "ScriptExecutionContext.h" +#include "SharedWorker.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebMessagePortChannel.h" +#include "WebSharedWorker.h" +#include "WebSharedWorkerRepository.h" +#include "WebString.h" +#include "WebURL.h" +#include "WorkerScriptLoader.h" +#include "WorkerScriptLoaderClient.h" + +namespace WebCore { + +class Document; +using WebKit::WebFrameImpl; +using WebKit::WebMessagePortChannel; +using WebKit::WebSharedWorker; +using WebKit::WebSharedWorkerRepository; + +// Callback class that keeps the SharedWorker and WebSharedWorker objects alive while loads are potentially happening, and also translates load errors into error events on the worker. +class SharedWorkerScriptLoader : private WorkerScriptLoaderClient, private WebSharedWorker::ConnectListener, private ActiveDOMObject { +public: + SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<MessagePortChannel> port, PassOwnPtr<WebSharedWorker> webWorker) + : ActiveDOMObject(worker->scriptExecutionContext(), this) + , m_worker(worker) + , m_url(url) + , m_name(name) + , m_webWorker(webWorker) + , m_port(port) + { + } + + void load(); + virtual void contextDestroyed(); +private: + // WorkerScriptLoaderClient callback + virtual void notifyFinished(); + + virtual void connected(); + + void sendConnect(); + + RefPtr<SharedWorker> m_worker; + KURL m_url; + String m_name; + OwnPtr<WebSharedWorker> m_webWorker; + OwnPtr<MessagePortChannel> m_port; + WorkerScriptLoader m_scriptLoader; +}; + +void SharedWorkerScriptLoader::load() +{ + // If the shared worker is not yet running, load the script resource for it, otherwise just send it a connect event. + if (m_webWorker->isStarted()) + sendConnect(); + else + m_scriptLoader.loadAsynchronously(m_worker->scriptExecutionContext(), m_url, DenyCrossOriginRequests, this); +} + +// Extracts a WebMessagePortChannel from a MessagePortChannel. +static WebMessagePortChannel* getWebPort(PassOwnPtr<MessagePortChannel> port) +{ + // Extract the WebMessagePortChannel to send to the worker. + PlatformMessagePortChannel* platformChannel = port->channel(); + WebMessagePortChannel* webPort = platformChannel->webChannelRelease(); + webPort->setClient(0); + return webPort; +} + +void SharedWorkerScriptLoader::notifyFinished() +{ + if (m_scriptLoader.failed()) { + m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true)); + delete this; + } else { + // Pass the script off to the worker, then send a connect event. + m_webWorker->startWorkerContext(m_url, m_name, m_worker->scriptExecutionContext()->userAgent(m_url), m_scriptLoader.script()); + sendConnect(); + } +} + +void SharedWorkerScriptLoader::sendConnect() +{ + // Send the connect event off, and linger until it is done sending. + m_webWorker->connect(getWebPort(m_port.release()), this); +} + +void SharedWorkerScriptLoader::contextDestroyed() +{ + ActiveDOMObject::contextDestroyed(); + delete this; +} + +void SharedWorkerScriptLoader::connected() +{ + // Connect event has been sent, so free ourselves (this releases the SharedWorker so it can be freed as well if unreferenced). + delete this; +} + +bool SharedWorkerRepository::isAvailable() +{ + // Allow the WebKitClient to determine if SharedWorkers are available. + return WebKit::webKitClient()->sharedWorkerRepository(); +} + +static WebSharedWorkerRepository::DocumentID getId(void* document) +{ + ASSERT(document); + return reinterpret_cast<WebSharedWorkerRepository::DocumentID>(document); +} + +void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, ExceptionCode& ec) +{ + // This should not be callable unless there's a SharedWorkerRepository for + // this context (since isAvailable() should have returned null). + ASSERT(WebKit::webKitClient()->sharedWorkerRepository()); + + // No nested workers (for now) - connect() should only be called from document context. + ASSERT(worker->scriptExecutionContext()->isDocument()); + Document* document = static_cast<Document*>(worker->scriptExecutionContext()); + WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); + OwnPtr<WebSharedWorker> webWorker; + webWorker = webFrame->client()->createSharedWorker(webFrame, url, name, getId(document)); + + if (!webWorker) { + // Existing worker does not match this url, so return an error back to the caller. + ec = URL_MISMATCH_ERR; + return; + } + + WebKit::webKitClient()->sharedWorkerRepository()->addSharedWorker( + webWorker.get(), getId(document)); + + // The loader object manages its own lifecycle (and the lifecycles of the two worker objects). + // It will free itself once loading is completed. + SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url, name, port.release(), webWorker.release()); + loader->load(); +} + +void SharedWorkerRepository::documentDetached(Document* document) +{ + WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository(); + if (repo) + repo->documentDetached(getId(document)); +} + +bool SharedWorkerRepository::hasSharedWorkers(Document* document) +{ + WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository(); + return repo && repo->hasSharedWorkers(getId(document)); +} + + + +} // namespace WebCore + +#endif // ENABLE(SHARED_WORKERS) diff --git a/WebKit/chromium/src/SocketStreamHandle.cpp b/WebKit/chromium/src/SocketStreamHandle.cpp new file mode 100644 index 0000000..9f19942 --- /dev/null +++ b/WebKit/chromium/src/SocketStreamHandle.cpp @@ -0,0 +1,236 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "SocketStreamHandle.h" + +#if ENABLE(WEB_SOCKETS) + +#include "Logging.h" +#include "NotImplemented.h" +#include "SocketStreamHandleClient.h" +#include "WebData.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebSocketStreamHandle.h" +#include "WebSocketStreamHandleClient.h" +#include "WebURL.h" +#include <wtf/PassOwnPtr.h> + +using namespace WebKit; + +namespace WebCore { + +class SocketStreamHandleInternal : public WebSocketStreamHandleClient { +public: + static PassOwnPtr<SocketStreamHandleInternal> create(SocketStreamHandle* handle) + { + return new SocketStreamHandleInternal(handle); + } + virtual ~SocketStreamHandleInternal(); + + void connect(const KURL&); + int send(const char*, int); + void close(); + + virtual void didOpenStream(WebSocketStreamHandle*, int); + virtual void didSendData(WebSocketStreamHandle*, int); + virtual void didReceiveData(WebSocketStreamHandle*, const WebData&); + virtual void didClose(WebSocketStreamHandle*); + virtual void didFail(WebSocketStreamHandle*, const WebSocketStreamError&); + +private: + explicit SocketStreamHandleInternal(SocketStreamHandle*); + + SocketStreamHandle* m_handle; + OwnPtr<WebSocketStreamHandle> m_socket; + int m_maxPendingSendAllowed; + int m_pendingAmountSent; +}; + +SocketStreamHandleInternal::SocketStreamHandleInternal(SocketStreamHandle* handle) + : m_handle(handle) + , m_maxPendingSendAllowed(0) + , m_pendingAmountSent(0) +{ +} + +SocketStreamHandleInternal::~SocketStreamHandleInternal() +{ + m_handle = 0; +} + +void SocketStreamHandleInternal::connect(const KURL& url) +{ + m_socket.set(webKitClient()->createSocketStreamHandle()); + LOG(Network, "connect"); + ASSERT(m_socket.get()); + m_socket->connect(url, this); +} + +int SocketStreamHandleInternal::send(const char* data, int len) +{ + LOG(Network, "send len=%d", len); + ASSERT(m_socket.get()); + if (m_pendingAmountSent + len >= m_maxPendingSendAllowed) + len = m_maxPendingSendAllowed - m_pendingAmountSent - 1; + + if (len <= 0) + return len; + WebData webdata(data, len); + if (m_socket->send(webdata)) { + m_pendingAmountSent += len; + LOG(Network, "sent"); + return len; + } + LOG(Network, "busy. buffering"); + return 0; +} + +void SocketStreamHandleInternal::close() +{ + LOG(Network, "close"); + m_socket->close(); +} + +void SocketStreamHandleInternal::didOpenStream(WebSocketStreamHandle* socketHandle, int maxPendingSendAllowed) +{ + LOG(Network, "SocketStreamHandleInternal::didOpen %d", + maxPendingSendAllowed); + ASSERT(maxPendingSendAllowed > 0); + if (m_handle && m_socket.get()) { + ASSERT(socketHandle == m_socket.get()); + m_maxPendingSendAllowed = maxPendingSendAllowed; + m_handle->m_state = SocketStreamHandleBase::Open; + if (m_handle->m_client) { + m_handle->m_client->didOpen(m_handle); + return; + } + } + LOG(Network, "no m_handle or m_socket?"); +} + +void SocketStreamHandleInternal::didSendData(WebSocketStreamHandle* socketHandle, int amountSent) +{ + LOG(Network, "SocketStreamHandleInternal::didSendData %d", amountSent); + ASSERT(amountSent > 0); + if (m_handle && m_socket.get()) { + ASSERT(socketHandle == m_socket.get()); + m_pendingAmountSent -= amountSent; + ASSERT(m_pendingAmountSent >= 0); + m_handle->sendPendingData(); + } +} + +void SocketStreamHandleInternal::didReceiveData(WebSocketStreamHandle* socketHandle, const WebData& data) +{ + LOG(Network, "didReceiveData"); + if (m_handle && m_socket.get()) { + ASSERT(socketHandle == m_socket.get()); + if (m_handle->m_client) + m_handle->m_client->didReceiveData(m_handle, data.data(), data.size()); + } +} + +void SocketStreamHandleInternal::didClose(WebSocketStreamHandle* socketHandle) +{ + LOG(Network, "didClose"); + if (m_handle && m_socket.get()) { + ASSERT(socketHandle == m_socket.get()); + m_socket.clear(); + SocketStreamHandle* h = m_handle; + m_handle = 0; + if (h->m_client) + h->m_client->didClose(h); + } +} + +void SocketStreamHandleInternal::didFail(WebSocketStreamHandle* socketHandle, const WebSocketStreamError& err) +{ + LOG(Network, "didFail"); + if (m_handle && m_socket.get()) { + ASSERT(socketHandle == m_socket.get()); + m_socket.clear(); + SocketStreamHandle* h = m_handle; + m_handle = 0; + if (h->m_client) + h->m_client->didClose(h); // didFail(h, err); + } +} + +// FIXME: auth + +// SocketStreamHandle ---------------------------------------------------------- + +SocketStreamHandle::SocketStreamHandle(const KURL& url, SocketStreamHandleClient* client) + : SocketStreamHandleBase(url, client) +{ + m_internal = SocketStreamHandleInternal::create(this); + m_internal->connect(m_url); +} + +SocketStreamHandle::~SocketStreamHandle() +{ + setClient(0); + m_internal.clear(); +} + +int SocketStreamHandle::platformSend(const char* buf, int len) +{ + if (!m_internal.get()) + return 0; + return m_internal->send(buf, len); +} + +void SocketStreamHandle::platformClose() +{ + if (m_internal.get()) + m_internal->close(); +} + +void SocketStreamHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) +{ + if (m_client) + m_client->didReceiveAuthenticationChallenge(this, challenge); +} + +void SocketStreamHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) +{ + notImplemented(); +} + +void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge) +{ + notImplemented(); +} + +} // namespace WebCore + +#endif // ENABLE(WEB_SOCKETS) diff --git a/WebKit/chromium/src/StorageAreaProxy.cpp b/WebKit/chromium/src/StorageAreaProxy.cpp new file mode 100644 index 0000000..551507f --- /dev/null +++ b/WebKit/chromium/src/StorageAreaProxy.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 Google 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 GOOGLE 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 GOOGLE 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. + */ + +#include "config.h" +#include "StorageAreaProxy.h" + +#if ENABLE(DOM_STORAGE) + +#include "Document.h" +#include "ExceptionCode.h" +#include "Frame.h" +#include "SecurityOrigin.h" +#include "StorageAreaImpl.h" + +#include "WebStorageArea.h" +#include "WebString.h" +#include "WebURL.h" + +namespace WebCore { + +StorageAreaProxy::StorageAreaProxy(WebKit::WebStorageArea* storageArea) + : m_storageArea(storageArea) +{ +} + +StorageAreaProxy::~StorageAreaProxy() +{ +} + +unsigned StorageAreaProxy::length() const +{ + return m_storageArea->length(); +} + +String StorageAreaProxy::key(unsigned index) const +{ + return m_storageArea->key(index); +} + +String StorageAreaProxy::getItem(const String& key) const +{ + return m_storageArea->getItem(key); +} + +void StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame) +{ + bool quotaException = false; + m_storageArea->setItem(key, value, frame->document()->url(), quotaException); + ec = quotaException ? QUOTA_EXCEEDED_ERR : 0; +} + +void StorageAreaProxy::removeItem(const String& key, Frame* frame) +{ + m_storageArea->removeItem(key, frame->document()->url()); +} + +void StorageAreaProxy::clear(Frame* frame) +{ + m_storageArea->clear(frame->document()->url()); +} + +bool StorageAreaProxy::contains(const String& key) const +{ + return !getItem(key).isNull(); +} + +} // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/mac/WebCoreSupport/WebGeolocation.mm b/WebKit/chromium/src/StorageAreaProxy.h index 89d6ad9..5d09d82 100644 --- a/WebKit/mac/WebCoreSupport/WebGeolocation.mm +++ b/WebKit/chromium/src/StorageAreaProxy.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 Google Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,57 +10,50 @@ * 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 INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY GOOGLE 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 INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#import "WebGeolocationInternal.h" -#import <WebCore/Geolocation.h> +#ifndef StorageAreaProxy_h +#define StorageAreaProxy_h -using namespace WebCore; +#if ENABLE(DOM_STORAGE) -@implementation WebGeolocation (WebInternal) +#include "StorageArea.h" -- (id)_initWithWebCoreGeolocation:(WebCoreGeolocation *)geolocation -{ - ASSERT(geolocation); +namespace WebKit { class WebStorageArea; } - self = [super init]; - if (self) { - geolocation->ref(); - _private = reinterpret_cast<WebGeolocationPrivate*>(geolocation); - } - return self; -} +namespace WebCore { -@end +class StorageAreaProxy : public StorageArea { +public: + StorageAreaProxy(WebKit::WebStorageArea* storageArea); + virtual ~StorageAreaProxy(); -@implementation WebGeolocation + // The HTML5 DOM Storage API + virtual unsigned length() const; + virtual String key(unsigned index) const; + virtual String getItem(const String& key) const; + virtual void setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame); + virtual void removeItem(const String& key, Frame* sourceFrame); + virtual void clear(Frame* sourceFrame); + virtual bool contains(const String& key) const; -- (BOOL)shouldClearCache -{ - return reinterpret_cast<Geolocation*>(_private)->shouldClearCache(); -} +private: + OwnPtr<WebKit::WebStorageArea> m_storageArea; +}; -- (void)setIsAllowed:(BOOL)allowed -{ - reinterpret_cast<Geolocation*>(_private)->setIsAllowed(allowed); -} +} // namespace WebCore -- (void)dealloc -{ - if (_private) - reinterpret_cast<Geolocation*>(_private)->deref(); - [super dealloc]; -} +#endif // ENABLE(DOM_STORAGE) -@end +#endif // StorageAreaProxy_h diff --git a/WebKit/chromium/src/StorageEventDispatcherChromium.cpp b/WebKit/chromium/src/StorageEventDispatcherChromium.cpp new file mode 100644 index 0000000..3286929 --- /dev/null +++ b/WebKit/chromium/src/StorageEventDispatcherChromium.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "StorageEventDispatcher.h" + +#if ENABLE(DOM_STORAGE) + +#include "SecurityOrigin.h" +#include "StorageArea.h" + +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebString.h" +#include "WebURL.h" + +namespace WebCore { + +void StorageEventDispatcher::dispatch(const String& key, const String& oldValue, + const String& newValue, StorageType storageType, + SecurityOrigin* origin, Frame* sourceFrame) +{ + ASSERT(!sourceFrame); // Sad, but true. + WebKit::webKitClient()->dispatchStorageEvent(key, oldValue, newValue, origin->toString(), WebKit::WebURL(), storageType == LocalStorage); +} + +} // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/chromium/src/StorageEventDispatcherImpl.cpp b/WebKit/chromium/src/StorageEventDispatcherImpl.cpp new file mode 100644 index 0000000..3518796 --- /dev/null +++ b/WebKit/chromium/src/StorageEventDispatcherImpl.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "StorageEventDispatcherImpl.h" + +#if ENABLE(DOM_STORAGE) + +#include "DOMWindow.h" +#include "EventNames.h" +#include "Frame.h" +#include "KURL.h" +#include "Page.h" +#include "PageGroup.h" +#include "SecurityOrigin.h" +#include "StorageEvent.h" + +namespace WebCore { + +StorageEventDispatcherImpl::StorageEventDispatcherImpl(const String& groupName) + : m_pageGroup(PageGroup::pageGroup(groupName)) +{ + ASSERT(m_pageGroup); +} + +void StorageEventDispatcherImpl::dispatchStorageEvent(const String& key, const String& oldValue, + const String& newValue, SecurityOrigin* securityOrigin, + const KURL& url, StorageType storageType) +{ + // FIXME: Implement + if (storageType == SessionStorage) + return; + + // We need to copy all relevant frames from every page to a vector since sending the event to one frame might mutate the frame tree + // of any given page in the group or mutate the page group itself. + Vector<RefPtr<Frame> > frames; + + const HashSet<Page*>& pages = m_pageGroup->pages(); + HashSet<Page*>::const_iterator end = pages.end(); + for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { + for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) { + if (frame->document()->securityOrigin()->equal(securityOrigin)) + frames.append(frame); + } + } + + // FIXME: Figure out how to pass in the document URI. + for (unsigned i = 0; i < frames.size(); ++i) { + frames[i]->document()->dispatchWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, + url, frames[i]->domWindow()->localStorage())); + } +} + +} // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/chromium/src/StorageEventDispatcherImpl.h b/WebKit/chromium/src/StorageEventDispatcherImpl.h new file mode 100644 index 0000000..4c2db7c --- /dev/null +++ b/WebKit/chromium/src/StorageEventDispatcherImpl.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 StorageEventDispatcherImpl_h +#define StorageEventDispatcherImpl_h + +#if ENABLE(DOM_STORAGE) + +#include "PlatformString.h" +#include "StorageArea.h" + +namespace WebCore { + +class KURL; +class PageGroup; +class SecurityOrigin; + +class StorageEventDispatcherImpl { +public: + StorageEventDispatcherImpl(const String& groupName); + + void dispatchStorageEvent(const String& key, const String& oldValue, + const String& newValue, SecurityOrigin*, + const KURL&, StorageType); + +private: + PageGroup* m_pageGroup; +}; + +} // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) + +#endif // StorageEventDispatcherImpl_h diff --git a/WebKit/chromium/src/StorageNamespaceProxy.cpp b/WebKit/chromium/src/StorageNamespaceProxy.cpp new file mode 100644 index 0000000..e22bbef --- /dev/null +++ b/WebKit/chromium/src/StorageNamespaceProxy.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2009 Google 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 GOOGLE 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 GOOGLE 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. + */ + +#include "config.h" +#include "StorageNamespaceProxy.h" + +#if ENABLE(DOM_STORAGE) + +#include "SecurityOrigin.h" +#include "StorageAreaProxy.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebStorageNamespace.h" +#include "WebString.h" + +namespace WebCore { + +PassRefPtr<StorageNamespace> StorageNamespace::localStorageNamespace(const String& path, unsigned quota) +{ + return new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path, quota)); +} + +PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace() +{ + return new StorageNamespaceProxy(WebKit::webKitClient()->createSessionStorageNamespace()); +} + +StorageNamespaceProxy::StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace) + : m_storageNamespace(storageNamespace) +{ +} + +StorageNamespaceProxy::~StorageNamespaceProxy() +{ +} + +PassRefPtr<StorageNamespace> StorageNamespaceProxy::copy() +{ + return adoptRef(new StorageNamespaceProxy(m_storageNamespace->copy())); +} + +PassRefPtr<StorageArea> StorageNamespaceProxy::storageArea(PassRefPtr<SecurityOrigin> origin) +{ + return adoptRef(new StorageAreaProxy(m_storageNamespace->createStorageArea(origin->toString()))); +} + +void StorageNamespaceProxy::close() +{ + m_storageNamespace->close(); +} + +void StorageNamespaceProxy::unlock() +{ + // FIXME: Implement. +} + +} // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationInternal.h b/WebKit/chromium/src/StorageNamespaceProxy.h index 8145d4d..9ff624b 100644 --- a/WebKit/mac/WebCoreSupport/WebGeolocationInternal.h +++ b/WebKit/chromium/src/StorageNamespaceProxy.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 Google Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,29 +10,45 @@ * 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 INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY GOOGLE 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 INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#import "WebGeolocationPrivate.h" +#ifndef StorageNamespaceProxy_h +#define StorageNamespaceProxy_h + +#if ENABLE(DOM_STORAGE) + +#include "StorageNamespace.h" + +namespace WebKit { class WebStorageNamespace; } namespace WebCore { - class Geolocation; -} -typedef WebCore::Geolocation WebCoreGeolocation; +class StorageNamespaceProxy : public StorageNamespace { +public: + StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace); + virtual ~StorageNamespaceProxy(); + virtual PassRefPtr<StorageArea> storageArea(PassRefPtr<SecurityOrigin>); + virtual PassRefPtr<StorageNamespace> copy(); + virtual void close(); + virtual void unlock(); + +private: + OwnPtr<WebKit::WebStorageNamespace> m_storageNamespace; +}; -@interface WebGeolocation (WebInternal) +} // namespace WebCore -- (id)_initWithWebCoreGeolocation:(WebCoreGeolocation *)geolocation; +#endif // ENABLE(DOM_STORAGE) -@end +#endif // StorageNamespaceProxy_h diff --git a/WebKit/chromium/src/WebAccessibilityCache.cpp b/WebKit/chromium/src/WebAccessibilityCache.cpp new file mode 100644 index 0000000..8a3f697 --- /dev/null +++ b/WebKit/chromium/src/WebAccessibilityCache.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebAccessibilityCache.h" + +#include "AXObjectCache.h" + +using namespace WebCore; + +namespace WebKit { + +void WebAccessibilityCache::enableAccessibility() +{ + AXObjectCache::enableAccessibility(); +} + +} diff --git a/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp b/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp new file mode 100644 index 0000000..03e5f46 --- /dev/null +++ b/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebAccessibilityCacheImpl.h" + +#include "AccessibilityObject.h" +#include "AXObjectCache.h" +#include "Document.h" +#include "Frame.h" + +#include "WebAccessibilityObject.h" +#include "WebFrameImpl.h" +#include "WebViewImpl.h" + +using namespace WebCore; + +namespace WebKit { + +const int invalidObjectId = -1; +const int firstObjectId = 1000; + +static PassRefPtr<AccessibilityObject> toAccessibilityObject(const WebAccessibilityObject& object) +{ + return object; +} + +// WebView ---------------------------------------------------------------- + +WebAccessibilityCache* WebAccessibilityCache::create() +{ + return new WebAccessibilityCacheImpl(); +} + +// WeakHandle ------------------------------------------------------------- + +PassRefPtr<WebAccessibilityCacheImpl::WeakHandle> WebAccessibilityCacheImpl::WeakHandle::create(AccessibilityObject* object) +{ + // FIXME: Remove resetting ref-count from AccessibilityObjectWrapper + // and convert to use adoptRef. + return new WebAccessibilityCacheImpl::WeakHandle(object); +} + +WebAccessibilityCacheImpl::WeakHandle::WeakHandle(AccessibilityObject* object) + : AccessibilityObjectWrapper(object) +{ + m_object->setWrapper(this); +} + +// WebAccessibilityCacheImpl ---------------------------------------- + +void WebAccessibilityCacheImpl::WeakHandle::detach() +{ + if (m_object) + m_object = 0; +} + +WebAccessibilityCacheImpl::WebAccessibilityCacheImpl() + : m_nextNewId(firstObjectId) + , m_initialized(false) +{ +} + +WebAccessibilityCacheImpl::~WebAccessibilityCacheImpl() +{ +} + +void WebAccessibilityCacheImpl::initialize(WebView* view) +{ + AXObjectCache::enableAccessibility(); + WebAccessibilityObject root = view->accessibilityObject(); + if (root.isNull()) + return; + + RefPtr<AccessibilityObject> rootObject = toAccessibilityObject(root); + + // Insert root in hashmaps. + m_objectMap.set(m_nextNewId, WeakHandle::create(rootObject.get())); + m_idMap.set(rootObject.get(), m_nextNewId++); + + m_initialized = true; +} + +WebAccessibilityObject WebAccessibilityCacheImpl::getObjectById(int id) +{ + ObjectMap::iterator it = m_objectMap.find(id); + + if (it == m_objectMap.end() || !it->second) + return WebAccessibilityObject(); + + return WebAccessibilityObject(it->second->accessibilityObject()); +} + +bool WebAccessibilityCacheImpl::isValidId(int id) const +{ + return id >= firstObjectId; +} + +void WebAccessibilityCacheImpl::remove(int id) +{ + ObjectMap::iterator it = m_objectMap.find(id); + + if (it == m_objectMap.end()) + return; + + if (it->second) { + // Erase element from reverse hashmap. + IdMap::iterator it2 = m_idMap.find(it->second->accessibilityObject()); + if (it2 != m_idMap.end()) + m_idMap.remove(it2); + } + + m_objectMap.remove(it); +} + +void WebAccessibilityCacheImpl::clear() +{ + m_objectMap.clear(); + m_idMap.clear(); +} + +int WebAccessibilityCacheImpl::addOrGetId(const WebAccessibilityObject& object) +{ + if (object.isNull()) + return invalidObjectId; + + RefPtr<AccessibilityObject> o = toAccessibilityObject(object); + + IdMap::iterator it = m_idMap.find(o.get()); + + if (it != m_idMap.end()) + return it->second; + + // Insert new accessibility object in hashmaps and return its newly + // assigned accessibility object id. + m_objectMap.set(m_nextNewId, WeakHandle::create(o.get())); + m_idMap.set(o.get(), m_nextNewId); + + return m_nextNewId++; +} + +} diff --git a/WebKit/chromium/src/WebAccessibilityCacheImpl.h b/WebKit/chromium/src/WebAccessibilityCacheImpl.h new file mode 100644 index 0000000..5148b74 --- /dev/null +++ b/WebKit/chromium/src/WebAccessibilityCacheImpl.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebAccessibilityCacheImpl_h +#define WebAccessibilityCacheImpl_h + +#include "AccessibilityObjectWrapper.h" +#include "WebAccessibilityCache.h" +#include <wtf/HashMap.h> +#include <wtf/PassRefPtr.h> + +namespace WebKit { + +// FIXME: Should be eliminated to use AXObjectCache instead. +class WebAccessibilityCacheImpl : public WebKit::WebAccessibilityCache { +public: + virtual void initialize(WebView* view); + virtual bool isInitialized() const { return m_initialized; } + + virtual WebAccessibilityObject getObjectById(int); + virtual bool isValidId(int) const; + virtual int addOrGetId(const WebKit::WebAccessibilityObject&); + + virtual void remove(int); + virtual void clear(); + +protected: + friend class WebKit::WebAccessibilityCache; + + WebAccessibilityCacheImpl(); + ~WebAccessibilityCacheImpl(); + +private: + // FIXME: This can be just part of Chromium's AccessibilityObjectWrapper. + class WeakHandle : public WebCore::AccessibilityObjectWrapper { + public: + static PassRefPtr<WeakHandle> create(WebCore::AccessibilityObject*); + virtual void detach(); + private: + WeakHandle(WebCore::AccessibilityObject*); + }; + + typedef HashMap<int, RefPtr<WeakHandle> > ObjectMap; + typedef HashMap<WebCore::AccessibilityObject*, int> IdMap; + + // Hashmap for caching of elements in use by the AT, mapping id (int) to + // WebAccessibilityObject. + ObjectMap m_objectMap; + // Hashmap for caching of elements in use by the AT, mapping a + // AccessibilityObject pointer to its id (int). Needed for reverse lookup, + // to ensure unnecessary duplicate entries are not created in the + // ObjectMap and for focus changes in WebKit. + IdMap m_idMap; + + // Unique identifier for retrieving an accessibility object from the page's + // hashmaps. Id is always 0 for the root of the accessibility object + // hierarchy (on a per-renderer process basis). + int m_nextNewId; + + bool m_initialized; +}; + +} + +#endif diff --git a/WebKit/chromium/src/WebAccessibilityObject.cpp b/WebKit/chromium/src/WebAccessibilityObject.cpp new file mode 100644 index 0000000..bdbd260 --- /dev/null +++ b/WebKit/chromium/src/WebAccessibilityObject.cpp @@ -0,0 +1,413 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebAccessibilityObject.h" + +#include "AccessibilityObject.h" +#include "EventHandler.h" +#include "FrameView.h" +#include "PlatformKeyboardEvent.h" +#include "WebPoint.h" +#include "WebRect.h" +#include "WebString.h" + +using namespace WebCore; + +namespace WebKit { + +class WebAccessibilityObjectPrivate : public WebCore::AccessibilityObject { +}; + +void WebAccessibilityObject::reset() +{ + assign(0); +} + +void WebAccessibilityObject::assign(const WebKit::WebAccessibilityObject& other) +{ + WebAccessibilityObjectPrivate* p = const_cast<WebAccessibilityObjectPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +WebString WebAccessibilityObject::accessibilityDescription() const +{ + if (!m_private) + return WebString(); + + m_private->updateBackingStore(); + return m_private->accessibilityDescription(); +} + +WebString WebAccessibilityObject::actionVerb() const +{ + if (!m_private) + return WebString(); + + m_private->updateBackingStore(); + return m_private->actionVerb(); +} + +bool WebAccessibilityObject::canSetFocusAttribute() const +{ + if (!m_private) + return false; + + m_private->updateBackingStore(); + return m_private->canSetFocusAttribute(); +} + +bool WebAccessibilityObject::canSetValueAttribute() const +{ + if (!m_private) + return false; + + m_private->updateBackingStore(); + return m_private->canSetValueAttribute(); +} + +unsigned WebAccessibilityObject::childCount() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->children().size(); +} + +WebAccessibilityObject WebAccessibilityObject::childAt(unsigned index) const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + if (m_private->children().size() <= index) + return WebAccessibilityObject(); + + return WebAccessibilityObject(m_private->children()[index]); +} + +WebAccessibilityObject WebAccessibilityObject::firstChild() const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + return WebAccessibilityObject(m_private->firstChild()); +} + +WebAccessibilityObject WebAccessibilityObject::focusedChild() const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + RefPtr<AccessibilityObject> focused = m_private->focusedUIElement(); + if (m_private == focused.get() || focused->parentObject() == m_private) + return WebAccessibilityObject(focused); + + return WebAccessibilityObject(); +} + +WebAccessibilityObject WebAccessibilityObject::lastChild() const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + return WebAccessibilityObject(m_private->lastChild()); +} + + +WebAccessibilityObject WebAccessibilityObject::nextSibling() const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + return WebAccessibilityObject(m_private->nextSibling()); +} + +WebAccessibilityObject WebAccessibilityObject::parentObject() const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + return WebAccessibilityObject(m_private->parentObject()); +} + + +WebAccessibilityObject WebAccessibilityObject::previousSibling() const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + return WebAccessibilityObject(m_private->previousSibling()); +} + +bool WebAccessibilityObject::isAnchor() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isAnchor(); +} + +bool WebAccessibilityObject::isChecked() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isChecked(); +} + + +bool WebAccessibilityObject::isFocused() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isFocused(); +} + +bool WebAccessibilityObject::isEnabled() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isEnabled(); +} + +bool WebAccessibilityObject::isHovered() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isHovered(); +} + +bool WebAccessibilityObject::isIndeterminate() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isIndeterminate(); +} + +bool WebAccessibilityObject::isMultiSelect() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isMultiSelect(); +} + +bool WebAccessibilityObject::isOffScreen() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isOffScreen(); +} + +bool WebAccessibilityObject::isPasswordField() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isPasswordField(); +} + +bool WebAccessibilityObject::isPressed() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isPressed(); +} + +bool WebAccessibilityObject::isReadOnly() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isReadOnly(); +} + +bool WebAccessibilityObject::isVisited() const +{ + if (!m_private) + return 0; + + m_private->updateBackingStore(); + return m_private->isVisited(); +} + +WebRect WebAccessibilityObject::boundingBoxRect() const +{ + if (!m_private) + return WebRect(); + + m_private->updateBackingStore(); + return m_private->documentFrameView()->contentsToWindow(m_private->boundingBoxRect()); +} + +WebString WebAccessibilityObject::helpText() const +{ + if (!m_private) + return WebString(); + + m_private->updateBackingStore(); + return m_private->helpText(); +} + +WebAccessibilityObject WebAccessibilityObject::hitTest(const WebPoint& point) const +{ + if (!m_private) + return WebAccessibilityObject(); + + m_private->updateBackingStore(); + IntPoint contentsPoint = m_private->documentFrameView()->windowToContents(point); + RefPtr<AccessibilityObject> hit = m_private->doAccessibilityHitTest(contentsPoint); + + if (hit.get()) + return WebAccessibilityObject(hit); + + if (m_private->boundingBoxRect().contains(contentsPoint)) + return *this; + + return WebAccessibilityObject(); +} + +WebString WebAccessibilityObject::keyboardShortcut() const +{ + if (!m_private) + return WebString(); + + m_private->updateBackingStore(); + String accessKey = m_private->accessKey(); + if (accessKey.isNull()) + return WebString(); + + static String modifierString; + if (modifierString.isNull()) { + unsigned modifiers = EventHandler::accessKeyModifiers(); + // Follow the same order as Mozilla MSAA implementation: + // Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings + // should not be localized and defines the separator as "+". + if (modifiers & PlatformKeyboardEvent::CtrlKey) + modifierString += "Ctrl+"; + if (modifiers & PlatformKeyboardEvent::AltKey) + modifierString += "Alt+"; + if (modifiers & PlatformKeyboardEvent::ShiftKey) + modifierString += "Shift+"; + if (modifiers & PlatformKeyboardEvent::MetaKey) + modifierString += "Win+"; + } + + return modifierString + accessKey; +} + +bool WebAccessibilityObject::performDefaultAction() const +{ + if (!m_private) + return false; + + m_private->updateBackingStore(); + return m_private->performDefaultAction(); +} + +WebAccessibilityRole WebAccessibilityObject::roleValue() const +{ + if (!m_private) + return WebKit::WebAccessibilityRoleUnknown; + + m_private->updateBackingStore(); + return static_cast<WebAccessibilityRole>(m_private->roleValue()); +} + +WebString WebAccessibilityObject::stringValue() const +{ + if (!m_private) + return WebString(); + + m_private->updateBackingStore(); + return m_private->stringValue(); +} + +WebString WebAccessibilityObject::title() const +{ + if (!m_private) + return WebString(); + + m_private->updateBackingStore(); + return m_private->title(); +} + +WebAccessibilityObject::WebAccessibilityObject(const WTF::PassRefPtr<WebCore::AccessibilityObject>& object) + : m_private(static_cast<WebAccessibilityObjectPrivate*>(object.releaseRef())) +{ +} + +WebAccessibilityObject& WebAccessibilityObject::operator=(const WTF::PassRefPtr<WebCore::AccessibilityObject>& object) +{ + assign(static_cast<WebAccessibilityObjectPrivate*>(object.releaseRef())); + return *this; +} + +WebAccessibilityObject::operator WTF::PassRefPtr<WebCore::AccessibilityObject>() const +{ + return PassRefPtr<WebCore::AccessibilityObject>(const_cast<WebAccessibilityObjectPrivate*>(m_private)); +} + +void WebAccessibilityObject::assign(WebAccessibilityObjectPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebBindings.cpp b/WebKit/chromium/src/WebBindings.cpp new file mode 100644 index 0000000..0bc67b6 --- /dev/null +++ b/WebKit/chromium/src/WebBindings.cpp @@ -0,0 +1,323 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebBindings.h" + +#include "npruntime_impl.h" +#include "npruntime_priv.h" + +#include "../public/WebDragData.h" +#include "../public/WebRange.h" + +#if USE(V8) +#include "ChromiumDataObject.h" +#include "ClipboardChromium.h" +#include "EventNames.h" +#include "MouseEvent.h" +#include "NPV8Object.h" // for PrivateIdentifier +#include "Range.h" +#include "V8DOMWrapper.h" +#include "V8Helpers.h" +#include "V8Proxy.h" +#elif USE(JSC) +#include "bridge/c/c_utility.h" +#endif + +#if USE(JAVASCRIPTCORE_BINDINGS) +using JSC::Bindings::PrivateIdentifier; +#endif + +using namespace WebCore; + +namespace WebKit { + +bool WebBindings::construct(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant* result) +{ + return _NPN_Construct(npp, npobj, args, argCount, result); +} + +NPObject* WebBindings::createObject(NPP npp, NPClass* npClass) +{ + return _NPN_CreateObject(npp, npClass); +} + +bool WebBindings::enumerate(NPP id, NPObject* obj, NPIdentifier** identifier, uint32_t* val) +{ + return _NPN_Enumerate(id, obj, identifier, val); +} + +bool WebBindings::evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result) +{ + return _NPN_Evaluate(npp, npObject, npScript, result); +} + +bool WebBindings::evaluateHelper(NPP npp, bool popups_allowed, NPObject* npobj, NPString* npscript, NPVariant* result) +{ + return _NPN_EvaluateHelper(npp, popups_allowed, npobj, npscript, result); +} + +NPIdentifier WebBindings::getIntIdentifier(int32_t number) +{ + return _NPN_GetIntIdentifier(number); +} + +bool WebBindings::getProperty(NPP npp, NPObject* obj, NPIdentifier propertyName, NPVariant *result) +{ + return _NPN_GetProperty(npp, obj, propertyName, result); +} + +NPIdentifier WebBindings::getStringIdentifier(const NPUTF8* string) +{ + return _NPN_GetStringIdentifier(string); +} + +void WebBindings::getStringIdentifiers(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers) +{ + _NPN_GetStringIdentifiers(names, nameCount, identifiers); +} + +bool WebBindings::hasMethod(NPP npp, NPObject* npObject, NPIdentifier methodName) +{ + return _NPN_HasMethod(npp, npObject, methodName); +} + +bool WebBindings::hasProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName) +{ + return _NPN_HasProperty(npp, npObject, propertyName); +} + +bool WebBindings::identifierIsString(NPIdentifier identifier) +{ + return _NPN_IdentifierIsString(identifier); +} + +int32_t WebBindings::intFromIdentifier(NPIdentifier identifier) +{ + return _NPN_IntFromIdentifier(identifier); +} + +void WebBindings::initializeVariantWithStringCopy(NPVariant* variant, const NPString* value) +{ +#if USE(V8) + _NPN_InitializeVariantWithStringCopy(variant, value); +#else + NPN_InitializeVariantWithStringCopy(variant, value); +#endif +} + +bool WebBindings::invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) +{ + return _NPN_Invoke(npp, npObject, methodName, arguments, argumentCount, result); +} + +bool WebBindings::invokeDefault(NPP id, NPObject* obj, const NPVariant* args, uint32_t count, NPVariant* result) +{ + return _NPN_InvokeDefault(id, obj, args, count, result); +} + +void WebBindings::releaseObject(NPObject* npObject) +{ + return _NPN_ReleaseObject(npObject); +} + +void WebBindings::releaseVariantValue(NPVariant* variant) +{ + _NPN_ReleaseVariantValue(variant); +} + +bool WebBindings::removeProperty(NPP id, NPObject* object, NPIdentifier identifier) +{ + return _NPN_RemoveProperty(id, object, identifier); +} + +NPObject* WebBindings::retainObject(NPObject* npObject) +{ + return _NPN_RetainObject(npObject); +} + +void WebBindings::setException(NPObject* obj, const NPUTF8* message) +{ + _NPN_SetException(obj, message); +} + +bool WebBindings::setProperty(NPP id, NPObject* obj, NPIdentifier identifier, const NPVariant* variant) +{ + return _NPN_SetProperty(id, obj, identifier, variant); +} + +void WebBindings::unregisterObject(NPObject* npObject) +{ +#if USE(V8) + _NPN_UnregisterObject(npObject); +#endif +} + +NPUTF8* WebBindings::utf8FromIdentifier(NPIdentifier identifier) +{ + return _NPN_UTF8FromIdentifier(identifier); +} + +void WebBindings::extractIdentifierData(const NPIdentifier& identifier, const NPUTF8*& string, int32_t& number, bool& isString) +{ + PrivateIdentifier* priv = static_cast<PrivateIdentifier*>(identifier); + if (!priv) { + isString = false; + number = 0; + return; + } + + isString = priv->isString; + if (isString) + string = priv->value.string; + else + number = priv->value.number; +} + +#if USE(V8) + +static v8::Local<v8::Value> getEvent(const v8::Handle<v8::Context>& context) +{ + static v8::Persistent<v8::String> eventSymbol(v8::Persistent<v8::String>::New(v8::String::NewSymbol("event"))); + return context->Global()->GetHiddenValue(eventSymbol); +} + +static bool getDragDataImpl(NPObject* npobj, int* eventId, WebDragData* data) +{ + if (!npobj) + return false; + if (npobj->_class != npScriptObjectClass) + return false; + + v8::HandleScope handleScope; + v8::Handle<v8::Context> context = v8::Context::GetEntered(); + if (context.IsEmpty()) + return false; + + // Get the current WebCore event. + v8::Handle<v8::Value> currentEvent(getEvent(context)); + Event* event = V8DOMWrapper::convertToNativeEvent(currentEvent); + if (!event) + return false; + + // Check that the given npobj is that event. + V8NPObject* object = reinterpret_cast<V8NPObject*>(npobj); + Event* given = V8DOMWrapper::convertToNativeEvent(object->v8Object); + if (given != event) + return false; + + // Check the execution frames are same origin. + V8Proxy* current = V8Proxy::retrieve(V8Proxy::retrieveFrameForCurrentContext()); + Frame* frame = V8Proxy::retrieveFrame(context); + if (!current || !current->canAccessFrame(frame, false)) + return false; + + const EventNames& names(eventNames()); + const AtomicString& eventType(event->type()); + + enum DragTargetMouseEventId { + DragEnterId = 1, DragOverId = 2, DragLeaveId = 3, DropId = 4 + }; + + // The event type should be a drag event. + if (eventType == names.dragenterEvent) + *eventId = DragEnterId; + else if (eventType == names.dragoverEvent) + *eventId = DragOverId; + else if (eventType == names.dragleaveEvent) + *eventId = DragLeaveId; + else if (eventType == names.dropEvent) + *eventId = DropId; + else + return false; + + // Drag events are mouse events and should have a clipboard. + MouseEvent* me = static_cast<MouseEvent*>(event); + Clipboard* clipboard = me->clipboard(); + if (!clipboard) + return false; + + // And that clipboard should be accessible by WebKit policy. + ClipboardChromium* chrome = static_cast<ClipboardChromium*>(clipboard); + HashSet<String> accessible(chrome->types()); + if (accessible.isEmpty()) + return false; + + RefPtr<ChromiumDataObject> dataObject(chrome->dataObject()); + if (dataObject && data) + *data = WebDragData(dataObject); + + return dataObject; +} + +static bool getRangeImpl(NPObject* npobj, WebRange* range) +{ + V8NPObject* v8npobject = reinterpret_cast<V8NPObject*>(npobj); + v8::Handle<v8::Object> v8object(v8npobject->v8Object); + if (V8ClassIndex::RANGE != V8DOMWrapper::domWrapperType(v8object)) + return false; + + Range* native = V8DOMWrapper::convertToNativeObject<WebCore::Range>(V8ClassIndex::RANGE, v8object); + if (!native) + return false; + + *range = WebRange(native); + return true; +} + +#endif + +bool WebBindings::getDragData(NPObject* event, int* eventId, WebDragData* data) +{ +#if USE(V8) + return getDragDataImpl(event, eventId, data); +#else + // Not supported on other ports (JSC, etc). + return false; +#endif +} + +bool WebBindings::isDragEvent(NPObject* event) +{ + int eventId; + return getDragData(event, &eventId, 0); +} + +bool WebBindings::getRange(NPObject* range, WebRange* webrange) +{ +#if USE(V8) + return getRangeImpl(range, webrange); +#else + // Not supported on other ports (JSC, etc). + return false; +#endif +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebCString.cpp b/WebKit/chromium/src/WebCString.cpp new file mode 100644 index 0000000..82fbac0 --- /dev/null +++ b/WebKit/chromium/src/WebCString.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebCString.h" + +#include "CString.h" +#include "TextEncoding.h" + +#include "WebString.h" + +namespace WebKit { + +class WebCStringPrivate : public WebCore::CStringBuffer { +}; + +void WebCString::reset() +{ + if (m_private) { + m_private->deref(); + m_private = 0; + } +} + +void WebCString::assign(const WebCString& other) +{ + assign(const_cast<WebCStringPrivate*>(other.m_private)); +} + +void WebCString::assign(const char* data, size_t length) +{ + char* newData; + RefPtr<WebCore::CStringBuffer> buffer = + WebCore::CString::newUninitialized(length, newData).buffer(); + memcpy(newData, data, length); + assign(static_cast<WebCStringPrivate*>(buffer.get())); +} + +size_t WebCString::length() const +{ + if (!m_private) + return 0; + // NOTE: The buffer's length includes the null byte. + return const_cast<WebCStringPrivate*>(m_private)->length() - 1; +} + +const char* WebCString::data() const +{ + if (!m_private) + return 0; + return const_cast<WebCStringPrivate*>(m_private)->data(); +} + +WebString WebCString::utf16() const +{ + return WebCore::UTF8Encoding().decode(data(), length()); +} + +WebCString WebCString::fromUTF16(const WebUChar* data, size_t length) +{ + return WebCore::UTF8Encoding().encode( + data, length, WebCore::QuestionMarksForUnencodables); +} + +WebCString WebCString::fromUTF16(const WebUChar* data) +{ + size_t len = 0; + while (data[len] != WebUChar(0)) + len++; + return fromUTF16(data, len); +} + +WebCString::WebCString(const WebCore::CString& s) + : m_private(static_cast<WebCStringPrivate*>(s.buffer())) +{ + if (m_private) + m_private->ref(); +} + +WebCString& WebCString::operator=(const WebCore::CString& s) +{ + assign(static_cast<WebCStringPrivate*>(s.buffer())); + return *this; +} + +WebCString::operator WebCore::CString() const +{ + return m_private; +} + +void WebCString::assign(WebCStringPrivate* p) +{ + // Take care to handle the case where m_private == p + if (p) + p->ref(); + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebCache.cpp b/WebKit/chromium/src/WebCache.cpp new file mode 100644 index 0000000..9d03a4d --- /dev/null +++ b/WebKit/chromium/src/WebCache.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebCache.h" + +// Instead of providing accessors, we make all members of Cache public. +// This will make it easier to track WebCore changes to the Cache class. +// FIXME: We should introduce public getters on the Cache class. +#define private public +#include "Cache.h" +#undef private + +using namespace WebCore; + +namespace WebKit { + +// A helper method for coverting a Cache::TypeStatistic to a +// WebCache::ResourceTypeStat. +static void ToResourceTypeStat(const Cache::TypeStatistic& from, + WebCache::ResourceTypeStat& to) +{ + to.count = static_cast<size_t>(from.count); + to.size = static_cast<size_t>(from.size); + to.liveSize = static_cast<size_t>(from.liveSize); + to.decodedSize = static_cast<size_t>(from.decodedSize); +} + +void WebCache::setCapacities( + size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity) +{ + Cache* cache = WebCore::cache(); + if (cache) + cache->setCapacities(static_cast<unsigned int>(minDeadCapacity), + static_cast<unsigned int>(maxDeadCapacity), + static_cast<unsigned int>(capacity)); +} + +void WebCache::clear() +{ + Cache* cache = WebCore::cache(); + if (cache && !cache->disabled()) { + // NOTE: I think using setDisabled() instead of setCapacities() will + // remove from the cache items that won't actually be freed from memory + // (due to other live references to them), so it just results in wasting + // time later and not saving memory compared to the below technique. + unsigned minDeadCapacity = cache->m_minDeadCapacity; + unsigned maxDeadCapacity = cache->m_maxDeadCapacity; + unsigned capacity = cache->m_capacity; + cache->setCapacities(0, 0, 0); // Will prune the cache. + cache->setCapacities(minDeadCapacity, maxDeadCapacity, capacity); + } +} + +void WebCache::getUsageStats(UsageStats* result) +{ + ASSERT(result); + + Cache* cache = WebCore::cache(); + if (cache) { + result->minDeadCapacity = cache->m_minDeadCapacity; + result->maxDeadCapacity = cache->m_maxDeadCapacity; + result->capacity = cache->m_capacity; + result->liveSize = cache->m_liveSize; + result->deadSize = cache->m_deadSize; + } else + memset(result, 0, sizeof(UsageStats)); +} + +void WebCache::getResourceTypeStats(ResourceTypeStats* result) +{ + Cache* cache = WebCore::cache(); + if (cache) { + Cache::Statistics stats = cache->getStatistics(); + ToResourceTypeStat(stats.images, result->images); + ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); + ToResourceTypeStat(stats.scripts, result->scripts); +#if ENABLE(XSLT) + ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets); +#else + memset(&result->xslStyleSheets, 0, sizeof(result->xslStyleSheets)); +#endif + ToResourceTypeStat(stats.fonts, result->fonts); + } else + memset(result, 0, sizeof(WebCache::ResourceTypeStats)); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebColor.cpp b/WebKit/chromium/src/WebColor.cpp new file mode 100644 index 0000000..9323433 --- /dev/null +++ b/WebKit/chromium/src/WebColor.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebColor.h" + +#include "Color.h" +#include "CSSValueKeywords.h" +#include "RenderTheme.h" +#include "UnusedParam.h" +#include "WebColorName.h" + +using namespace::WebCore; + +namespace WebKit { + +static int toCSSValueKeyword(WebColorName in_value) +{ + switch (in_value) { + case WebColorActiveBorder: + return CSSValueActiveborder; + case WebColorActiveCaption: + return CSSValueActivecaption; + case WebColorAppworkspace: + return CSSValueAppworkspace; + case WebColorBackground: + return CSSValueBackground; + case WebColorButtonFace: + return CSSValueButtonface; + case WebColorButtonHighlight: + return CSSValueButtonhighlight; + case WebColorButtonShadow: + return CSSValueButtonshadow; + case WebColorButtonText: + return CSSValueButtontext; + case WebColorCaptionText: + return CSSValueCaptiontext; + case WebColorGrayText: + return CSSValueGraytext; + case WebColorHighlight: + return CSSValueHighlight; + case WebColorHighlightText: + return CSSValueHighlighttext; + case WebColorInactiveBorder: + return CSSValueInactiveborder; + case WebColorInactiveCaption: + return CSSValueInactivecaption; + case WebColorInactiveCaptionText: + return CSSValueInactivecaptiontext; + case WebColorInfoBackground: + return CSSValueInfobackground; + case WebColorInfoText: + return CSSValueInfotext; + case WebColorMenu: + return CSSValueMenu; + case WebColorMenuText: + return CSSValueMenutext; + case WebColorScrollbar: + return CSSValueScrollbar; + case WebColorText: + return CSSValueText; + case WebColorThreedDarkShadow: + return CSSValueThreeddarkshadow; + case WebColorThreedShadow: + return CSSValueThreedshadow; + case WebColorThreedFace: + return CSSValueThreedface; + case WebColorThreedHighlight: + return CSSValueThreedhighlight; + case WebColorThreedLightShadow: + return CSSValueThreedlightshadow; + case WebColorWebkitFocusRingColor: + return CSSValueWebkitFocusRingColor; + case WebColorWindow: + return CSSValueWindow; + case WebColorWindowFrame: + return CSSValueWindowframe; + case WebColorWindowText: + return CSSValueWindowtext; + default: + return CSSValueInvalid; + } +} + +void setNamedColors(const WebColorName* colorNames, const WebColor* colors, size_t length) +{ + for (size_t i = 0; i < length; ++i) { + WebColorName colorName = colorNames[i]; + WebColor color = colors[i]; + + // Convert color to internal value identifier. + int internalColorName = toCSSValueKeyword(colorName); + if (internalColorName == CSSValueWebkitFocusRingColor) { + RenderTheme::setCustomFocusRingColor(color); + continue; + } + } + + // TODO(jeremy): Tell RenderTheme to update colors. +} + +} // WebKit diff --git a/WebKit/chromium/src/WebCrossOriginPreflightResultCache.cpp b/WebKit/chromium/src/WebCrossOriginPreflightResultCache.cpp new file mode 100644 index 0000000..719316d --- /dev/null +++ b/WebKit/chromium/src/WebCrossOriginPreflightResultCache.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebCrossOriginPreflightResultCache.h" + +#include "CrossOriginPreflightResultCache.h" + +namespace WebKit { + +void WebCrossOriginPreflightResultCache::clear() +{ + WebCore::CrossOriginPreflightResultCache::shared().empty(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebCursorInfo.cpp b/WebKit/chromium/src/WebCursorInfo.cpp new file mode 100644 index 0000000..d4b0f81 --- /dev/null +++ b/WebKit/chromium/src/WebCursorInfo.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebCursorInfo.h" + +#include "Cursor.h" + +using namespace WebCore; + +namespace WebKit { + +WebCursorInfo::WebCursorInfo(const Cursor& cursor) +{ + type = static_cast<Type>(cursor.impl().type()); + hotSpot = cursor.impl().hotSpot(); + customImage = cursor.impl().customImage(); +#ifdef WIN32 + externalHandle = 0; +#endif +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebData.cpp b/WebKit/chromium/src/WebData.cpp new file mode 100644 index 0000000..6aafe79 --- /dev/null +++ b/WebKit/chromium/src/WebData.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebData.h" + +#include "SharedBuffer.h" + +using namespace WebCore; + +namespace WebKit { + +class WebDataPrivate : public SharedBuffer { +}; + +void WebData::reset() +{ + if (m_private) { + m_private->deref(); + m_private = 0; + } +} + +void WebData::assign(const WebData& other) +{ + WebDataPrivate* p = const_cast<WebDataPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +void WebData::assign(const char* data, size_t size) +{ + assign(static_cast<WebDataPrivate*>( + SharedBuffer::create(data, size).releaseRef())); +} + +size_t WebData::size() const +{ + if (!m_private) + return 0; + return const_cast<WebDataPrivate*>(m_private)->size(); +} + +const char* WebData::data() const +{ + if (!m_private) + return 0; + return const_cast<WebDataPrivate*>(m_private)->data(); +} + +WebData::WebData(const PassRefPtr<SharedBuffer>& buffer) + : m_private(static_cast<WebDataPrivate*>(buffer.releaseRef())) +{ +} + +WebData& WebData::operator=(const PassRefPtr<SharedBuffer>& buffer) +{ + assign(static_cast<WebDataPrivate*>(buffer.releaseRef())); + return *this; +} + +WebData::operator PassRefPtr<SharedBuffer>() const +{ + return PassRefPtr<SharedBuffer>(const_cast<WebDataPrivate*>(m_private)); +} + +void WebData::assign(WebDataPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebDataSourceImpl.cpp b/WebKit/chromium/src/WebDataSourceImpl.cpp new file mode 100644 index 0000000..456706a --- /dev/null +++ b/WebKit/chromium/src/WebDataSourceImpl.cpp @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebDataSourceImpl.h" + +#include "WebURL.h" +#include "WebURLError.h" +#include "WebVector.h" + +using namespace WebCore; + +namespace WebKit { + +WebPluginLoadObserver* WebDataSourceImpl::m_nextPluginLoadObserver = 0; + +PassRefPtr<WebDataSourceImpl> WebDataSourceImpl::create(const ResourceRequest& request, const SubstituteData& data) +{ + return adoptRef(new WebDataSourceImpl(request, data)); +} + +const WebURLRequest& WebDataSourceImpl::originalRequest() const +{ + m_originalRequestWrapper.bind(DocumentLoader::originalRequest()); + return m_originalRequestWrapper; +} + +const WebURLRequest& WebDataSourceImpl::request() const +{ + m_requestWrapper.bind(DocumentLoader::request()); + return m_requestWrapper; +} + +const WebURLResponse& WebDataSourceImpl::response() const +{ + m_responseWrapper.bind(DocumentLoader::response()); + return m_responseWrapper; +} + +bool WebDataSourceImpl::hasUnreachableURL() const +{ + return !DocumentLoader::unreachableURL().isEmpty(); +} + +WebURL WebDataSourceImpl::unreachableURL() const +{ + return DocumentLoader::unreachableURL(); +} + +void WebDataSourceImpl::redirectChain(WebVector<WebURL>& result) const +{ + result.assign(m_redirectChain); +} + +WebString WebDataSourceImpl::pageTitle() const +{ + return title(); +} + +WebNavigationType WebDataSourceImpl::navigationType() const +{ + return toWebNavigationType(triggeringAction().type()); +} + +double WebDataSourceImpl::triggeringEventTime() const +{ + if (!triggeringAction().event()) + return 0.0; + + // DOMTimeStamp uses units of milliseconds. + return triggeringAction().event()->timeStamp() / 1000.0; +} + +WebDataSource::ExtraData* WebDataSourceImpl::extraData() const +{ + return m_extraData.get(); +} + +void WebDataSourceImpl::setExtraData(ExtraData* extraData) +{ + m_extraData.set(extraData); +} + +WebNavigationType WebDataSourceImpl::toWebNavigationType(NavigationType type) +{ + switch (type) { + case NavigationTypeLinkClicked: + return WebNavigationTypeLinkClicked; + case NavigationTypeFormSubmitted: + return WebNavigationTypeFormSubmitted; + case NavigationTypeBackForward: + return WebNavigationTypeBackForward; + case NavigationTypeReload: + return WebNavigationTypeReload; + case NavigationTypeFormResubmitted: + return WebNavigationTypeFormResubmitted; + case NavigationTypeOther: + default: + return WebNavigationTypeOther; + } +} + +const KURL& WebDataSourceImpl::endOfRedirectChain() const +{ + ASSERT(!m_redirectChain.isEmpty()); + return m_redirectChain.last(); +} + +void WebDataSourceImpl::clearRedirectChain() +{ + m_redirectChain.clear(); +} + +void WebDataSourceImpl::appendRedirect(const KURL& url) +{ + m_redirectChain.append(url); +} + +void WebDataSourceImpl::setNextPluginLoadObserver(PassOwnPtr<WebPluginLoadObserver> observer) +{ + // This call should always be followed up with the creation of a + // WebDataSourceImpl, so we should never leak this object. + m_nextPluginLoadObserver = observer.release(); +} + +WebDataSourceImpl::WebDataSourceImpl(const ResourceRequest& request, const SubstituteData& data) + : DocumentLoader(request, data) +{ + if (m_nextPluginLoadObserver) { + // When a new frame is created, it initially gets a data source for an + // empty document. Then it is navigated to the source URL of the + // frame, which results in a second data source being created. We want + // to wait to attach the WebPluginLoadObserver to that data source. + if (!request.url().isEmpty()) { + ASSERT(m_nextPluginLoadObserver->url() == request.url()); + m_pluginLoadObserver.set(m_nextPluginLoadObserver); + m_nextPluginLoadObserver = 0; + } + } +} + +WebDataSourceImpl::~WebDataSourceImpl() +{ +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebDataSourceImpl.h b/WebKit/chromium/src/WebDataSourceImpl.h new file mode 100644 index 0000000..8860fe4 --- /dev/null +++ b/WebKit/chromium/src/WebDataSourceImpl.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDataSourceImpl_h +#define WebDataSourceImpl_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebDataSource.h" + +#include "DocumentLoader.h" +#include "KURL.h" + +#include "WebPluginLoadObserver.h" +#include "WrappedResourceRequest.h" +#include "WrappedResourceResponse.h" + +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/Vector.h> + + +namespace WebKit { + +class WebPluginLoadObserver; + +class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { +public: + static PassRefPtr<WebDataSourceImpl> create(const WebCore::ResourceRequest&, + const WebCore::SubstituteData&); + + static WebDataSourceImpl* fromDocumentLoader(WebCore::DocumentLoader* loader) + { + return static_cast<WebDataSourceImpl*>(loader); + } + + // WebDataSource methods: + virtual const WebURLRequest& originalRequest() const; + virtual const WebURLRequest& request() const; + virtual const WebURLResponse& response() const; + virtual bool hasUnreachableURL() const; + virtual WebURL unreachableURL() const; + virtual void redirectChain(WebVector<WebURL>&) const; + virtual WebString pageTitle() const; + virtual WebNavigationType navigationType() const; + virtual double triggeringEventTime() const; + virtual ExtraData* extraData() const; + virtual void setExtraData(ExtraData*); + + static WebNavigationType toWebNavigationType(WebCore::NavigationType type); + + bool hasRedirectChain() const { return !m_redirectChain.isEmpty(); } + const WebCore::KURL& endOfRedirectChain() const; + void clearRedirectChain(); + void appendRedirect(const WebCore::KURL& url); + + PassOwnPtr<WebPluginLoadObserver> releasePluginLoadObserver() { return m_pluginLoadObserver.release(); } + static void setNextPluginLoadObserver(PassOwnPtr<WebPluginLoadObserver>); + +private: + WebDataSourceImpl(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); + ~WebDataSourceImpl(); + + // Mutable because the const getters will magically sync these to the + // latest version from WebKit. + mutable WrappedResourceRequest m_originalRequestWrapper; + mutable WrappedResourceRequest m_requestWrapper; + mutable WrappedResourceResponse m_responseWrapper; + + // Lists all intermediate URLs that have redirected for the current provisional load. + // See WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad for a + // description of who modifies this when to keep it up to date. + Vector<WebCore::KURL> m_redirectChain; + + OwnPtr<ExtraData> m_extraData; + OwnPtr<WebPluginLoadObserver> m_pluginLoadObserver; + + static WebPluginLoadObserver* m_nextPluginLoadObserver; +}; + +} // namespace WebKit + +#endif // WebDataSourceImpl_h diff --git a/WebKit/chromium/src/WebDatabase.cpp b/WebKit/chromium/src/WebDatabase.cpp new file mode 100644 index 0000000..2cd36b6 --- /dev/null +++ b/WebKit/chromium/src/WebDatabase.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebDatabase.h" + +#include "Database.h" +#include "DatabaseThread.h" +#include "Document.h" +#include "KURL.h" +#include "QuotaTracker.h" +#include "SecurityOrigin.h" +#include "WebDatabaseObserver.h" +#include "WebString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +static WebDatabaseObserver* databaseObserver = 0; + +class WebDatabasePrivate : public Database { +}; + +void WebDatabase::reset() +{ + assign(0); +} + +void WebDatabase::assign(const WebDatabase& other) +{ + WebDatabasePrivate* d = const_cast<WebDatabasePrivate*>(other.m_private); + if (d) + d->ref(); + assign(d); +} + +WebString WebDatabase::name() const +{ + ASSERT(m_private); + return m_private->stringIdentifier(); +} + +WebString WebDatabase::displayName() const +{ + ASSERT(m_private); + return m_private->displayName(); +} + +unsigned long WebDatabase::estimatedSize() const +{ + ASSERT(m_private); + return m_private->estimatedSize(); +} + +WebSecurityOrigin WebDatabase::securityOrigin() const +{ + ASSERT(m_private); + return WebSecurityOrigin(m_private->securityOrigin()); +} + +void WebDatabase::setObserver(WebDatabaseObserver* observer) +{ + databaseObserver = observer; +} + +WebDatabaseObserver* WebDatabase::observer() +{ + return databaseObserver; +} + +void WebDatabase::updateDatabaseSize( + const WebString& originIdentifier, const WebString& databaseName, + unsigned long long databaseSize, unsigned long long spaceAvailable) +{ + WebCore::QuotaTracker::instance().updateDatabaseSizeAndSpaceAvailableToOrigin( + originIdentifier, databaseName, databaseSize, spaceAvailable); +} + +WebDatabase::WebDatabase(const WTF::PassRefPtr<Database>& database) + : m_private(static_cast<WebDatabasePrivate*>(database.releaseRef())) +{ +} + +WebDatabase& WebDatabase::operator=(const WTF::PassRefPtr<Database>& database) +{ + assign(static_cast<WebDatabasePrivate*>(database.releaseRef())); + return *this; +} + +WebDatabase::operator WTF::PassRefPtr<Database>() const +{ + return PassRefPtr<Database>(const_cast<WebDatabasePrivate*>(m_private)); +} + +void WebDatabase::assign(WebDatabasePrivate* d) +{ + // d is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = d; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebDevToolsAgentPrivate.h b/WebKit/chromium/src/WebDevToolsAgentPrivate.h new file mode 100644 index 0000000..0c1c67e --- /dev/null +++ b/WebKit/chromium/src/WebDevToolsAgentPrivate.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebDevToolsAgentPrivate_h +#define WebDevToolsAgentPrivate_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebDevToolsAgent.h" + +namespace WebKit { +class WebFrameImpl; + +class WebDevToolsAgentPrivate : public WebDevToolsAgent { +public: + // Notifications from FrameLoaderClientImpl: + + // The window object for the frame has been cleared of any extra properties + // that may have been set by script from the previously loaded document. + virtual void didClearWindowObject(WebFrameImpl*) = 0; + + // The provisional datasource is now committed. The first part of the + // response body has been received, and the encoding of the response body + // is known. + virtual void didCommitProvisionalLoad(WebFrameImpl*, bool isNewNavigation) = 0; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebDragData.cpp b/WebKit/chromium/src/WebDragData.cpp new file mode 100644 index 0000000..4af1119 --- /dev/null +++ b/WebKit/chromium/src/WebDragData.cpp @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebDragData.h" + +#include "ChromiumDataObject.h" +#include "WebData.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebVector.h" + +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebDragDataPrivate : public ChromiumDataObject { +}; + +void WebDragData::initialize() +{ + assign(static_cast<WebDragDataPrivate*>(ChromiumDataObject::create().releaseRef())); +} + +void WebDragData::reset() +{ + assign(0); +} + +void WebDragData::assign(const WebDragData& other) +{ + WebDragDataPrivate* p = const_cast<WebDragDataPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +WebURL WebDragData::url() const +{ + ASSERT(!isNull()); + return m_private->url; +} + +void WebDragData::setURL(const WebURL& url) +{ + ensureMutable(); + m_private->url = url; +} + +WebString WebDragData::urlTitle() const +{ + ASSERT(!isNull()); + return m_private->urlTitle; +} + +void WebDragData::setURLTitle(const WebString& urlTitle) +{ + ensureMutable(); + m_private->urlTitle = urlTitle; +} + +WebString WebDragData::fileExtension() const +{ + ASSERT(!isNull()); + return m_private->fileExtension; +} + +void WebDragData::setFileExtension(const WebString& fileExtension) +{ + ensureMutable(); + m_private->fileExtension = fileExtension; +} + +bool WebDragData::hasFileNames() const +{ + ASSERT(!isNull()); + return !m_private->filenames.isEmpty(); +} + +void WebDragData::fileNames(WebVector<WebString>& fileNames) const +{ + ASSERT(!isNull()); + fileNames = m_private->filenames; +} + +void WebDragData::setFileNames(const WebVector<WebString>& fileNames) +{ + ensureMutable(); + m_private->filenames.clear(); + m_private->filenames.append(fileNames.data(), fileNames.size()); +} + +void WebDragData::appendToFileNames(const WebString& fileName) +{ + ensureMutable(); + m_private->filenames.append(fileName); +} + +WebString WebDragData::plainText() const +{ + ASSERT(!isNull()); + return m_private->plainText; +} + +void WebDragData::setPlainText(const WebString& plainText) +{ + ensureMutable(); + m_private->plainText = plainText; +} + +WebString WebDragData::htmlText() const +{ + ASSERT(!isNull()); + return m_private->textHtml; +} + +void WebDragData::setHTMLText(const WebString& htmlText) +{ + ensureMutable(); + m_private->textHtml = htmlText; +} + +WebURL WebDragData::htmlBaseURL() const +{ + ASSERT(!isNull()); + return m_private->htmlBaseUrl; +} + +void WebDragData::setHTMLBaseURL(const WebURL& htmlBaseURL) +{ + ensureMutable(); + m_private->htmlBaseUrl = htmlBaseURL; +} + +WebString WebDragData::fileContentFileName() const +{ + ASSERT(!isNull()); + return m_private->fileContentFilename; +} + +void WebDragData::setFileContentFileName(const WebString& fileName) +{ + ensureMutable(); + m_private->fileContentFilename = fileName; +} + +WebData WebDragData::fileContent() const +{ + ASSERT(!isNull()); + return WebData(m_private->fileContent); +} + +void WebDragData::setFileContent(const WebData& fileContent) +{ + ensureMutable(); + m_private->fileContent = fileContent; +} + +WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data) + : m_private(static_cast<WebDragDataPrivate*>(data.releaseRef())) +{ +} + +WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data) +{ + assign(static_cast<WebDragDataPrivate*>(data.releaseRef())); + return *this; +} + +WebDragData::operator WTF::PassRefPtr<WebCore::ChromiumDataObject>() const +{ + return PassRefPtr<ChromiumDataObject>(const_cast<WebDragDataPrivate*>(m_private)); +} + +void WebDragData::assign(WebDragDataPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +void WebDragData::ensureMutable() +{ + ASSERT(!isNull()); + if (!m_private->hasOneRef()) + assign(static_cast<WebDragDataPrivate*>(m_private->copy().releaseRef())); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebElement.cpp b/WebKit/chromium/src/WebElement.cpp new file mode 100644 index 0000000..3f13ee1 --- /dev/null +++ b/WebKit/chromium/src/WebElement.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebElement.h" + +#include "Element.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +WebElement::WebElement(const WTF::PassRefPtr<WebCore::Element>& elem) + : WebNode(elem.releaseRef()) +{ +} + +WebElement& WebElement::operator=(const WTF::PassRefPtr<WebCore::Element>& elem) +{ + WebNode::assign(elem.releaseRef()); + return *this; +} + +WebElement::operator WTF::PassRefPtr<Element>() const +{ + return PassRefPtr<Element>(static_cast<Element*>(m_private)); +} + +} // namespace WebKit + diff --git a/WebKit/chromium/src/WebFileChooserCompletionImpl.cpp b/WebKit/chromium/src/WebFileChooserCompletionImpl.cpp new file mode 100644 index 0000000..4152dc5 --- /dev/null +++ b/WebKit/chromium/src/WebFileChooserCompletionImpl.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebFileChooserCompletionImpl.h" + +namespace WebKit { + +WebFileChooserCompletionImpl::WebFileChooserCompletionImpl(PassRefPtr<WebCore::FileChooser> chooser) + : m_fileChooser(chooser) +{ +} + +WebFileChooserCompletionImpl::~WebFileChooserCompletionImpl() +{ +} + +void WebFileChooserCompletionImpl::didChooseFile(const WebVector<WebString>& fileNames) +{ + if (fileNames.size() == 1) + m_fileChooser->chooseFile(fileNames[0]); + else { + // This clause handles a case of file_names.size()==0 too. + Vector<WebCore::String> paths; + for (size_t i = 0; i < fileNames.size(); ++i) + paths.append(fileNames[i]); + m_fileChooser->chooseFiles(paths); + } + // This object is no longer needed. + delete this; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebFileChooserCompletionImpl.h b/WebKit/chromium/src/WebFileChooserCompletionImpl.h new file mode 100644 index 0000000..fe759e0 --- /dev/null +++ b/WebKit/chromium/src/WebFileChooserCompletionImpl.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFileChooserCompletionImpl_h +#define WebFileChooserCompletionImpl_h + +// FIXME: These relative paths are a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebFileChooserCompletion.h" +#include "../public/WebString.h" +#include "../public/WebVector.h" + +#include "FileChooser.h" + +#include <wtf/PassRefPtr.h> + +using WebKit::WebFileChooserCompletion; +using WebKit::WebString; +using WebKit::WebVector; + +namespace WebKit { + +class WebFileChooserCompletionImpl : public WebFileChooserCompletion { +public: + WebFileChooserCompletionImpl(PassRefPtr<WebCore::FileChooser> chooser); + ~WebFileChooserCompletionImpl(); + virtual void didChooseFile(const WebVector<WebString>& fileNames); +private: + RefPtr<WebCore::FileChooser> m_fileChooser; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebFontCache.cpp b/WebKit/chromium/src/WebFontCache.cpp new file mode 100644 index 0000000..52358ec --- /dev/null +++ b/WebKit/chromium/src/WebFontCache.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebFontCache.h" + +#include "FontCache.h" + +using namespace WebCore; + +namespace WebKit { + +// static +size_t WebFontCache::fontDataCount() +{ + return fontCache()->fontDataCount(); +} + +// static +size_t WebFontCache::inactiveFontDataCount() +{ + return fontCache()->inactiveFontDataCount(); +} + +// static +void WebFontCache::clear() +{ + fontCache()->invalidate(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebFormElement.cpp b/WebKit/chromium/src/WebFormElement.cpp new file mode 100644 index 0000000..5471608 --- /dev/null +++ b/WebKit/chromium/src/WebFormElement.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebFormElement.h" + +#include "HTMLFormControlElement.h" +#include "HTMLFormElement.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "WebString.h" +#include "WebURL.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebFormPrivate : public HTMLFormElement { +}; + +WebFormElement::WebFormElement(const WTF::PassRefPtr<HTMLFormElement>& e) + : WebElement(e.releaseRef()) +{ +} + +WebFormElement& WebFormElement::operator=(const WTF::PassRefPtr<HTMLFormElement>& e) +{ + WebNode::assign(e.releaseRef()); + return *this; +} + +WebFormElement::operator WTF::PassRefPtr<WebCore::HTMLFormElement>() const +{ + return PassRefPtr<HTMLFormElement>(static_cast<HTMLFormElement*>(m_private)); +} + +bool WebFormElement::autoComplete() const +{ + return constUnwrap<HTMLFormElement>()->autoComplete(); +} + +WebString WebFormElement::action() const +{ + return constUnwrap<HTMLFormElement>()->action(); +} + +WebString WebFormElement::name() const +{ + return constUnwrap<HTMLFormElement>()->name(); +} + +WebString WebFormElement::method() const +{ + return constUnwrap<HTMLFormElement>()->method(); +} + +void WebFormElement::submit() +{ + unwrap<HTMLFormElement>()->submit(); +} + +void WebFormElement::getNamedElements(const WebString& name, + WebVector<WebNode>& result) +{ + Vector<RefPtr<Node> > tempVector; + unwrap<HTMLFormElement>()->getNamedElements(name, tempVector); + result.assign(tempVector); +} + +void WebFormElement::getInputElements(WebVector<WebInputElement>& result) const +{ + const HTMLFormElement* form = constUnwrap<HTMLFormElement>(); + Vector<RefPtr<HTMLInputElement> > tempVector; + for (size_t i = 0; i < form->formElements.size(); i++) { + if (form->formElements[i]->hasLocalName(HTMLNames::inputTag)) + tempVector.append(static_cast<HTMLInputElement*>( + form->formElements[i])); + } + result.assign(tempVector); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebFrameImpl.cpp b/WebKit/chromium/src/WebFrameImpl.cpp new file mode 100644 index 0000000..ab6769f --- /dev/null +++ b/WebKit/chromium/src/WebFrameImpl.cpp @@ -0,0 +1,1915 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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. + */ + +// How ownership works +// ------------------- +// +// Big oh represents a refcounted relationship: owner O--- ownee +// +// WebView (for the toplevel frame only) +// O +// | +// Page O------- Frame (m_mainFrame) O-------O FrameView +// || +// || +// FrameLoader O-------- WebFrame (via FrameLoaderClient) +// +// FrameLoader and Frame are formerly one object that was split apart because +// it got too big. They basically have the same lifetime, hence the double line. +// +// WebFrame is refcounted and has one ref on behalf of the FrameLoader/Frame. +// This is not a normal reference counted pointer because that would require +// changing WebKit code that we don't control. Instead, it is created with this +// ref initially and it is removed when the FrameLoader is getting destroyed. +// +// WebFrames are created in two places, first in WebViewImpl when the root +// frame is created, and second in WebFrame::CreateChildFrame when sub-frames +// are created. WebKit will hook up this object to the FrameLoader/Frame +// and the refcount will be correct. +// +// How frames are destroyed +// ------------------------ +// +// The main frame is never destroyed and is re-used. The FrameLoader is re-used +// and a reference to the main frame is kept by the Page. +// +// When frame content is replaced, all subframes are destroyed. This happens +// in FrameLoader::detachFromParent for each subframe. +// +// Frame going away causes the FrameLoader to get deleted. In FrameLoader's +// destructor, it notifies its client with frameLoaderDestroyed. This calls +// WebFrame::Closing and then derefs the WebFrame and will cause it to be +// deleted (unless an external someone is also holding a reference). + +#include "config.h" +#include "WebFrameImpl.h" + +#include "Chrome.h" +#include "ChromiumBridge.h" +#include "ClipboardUtilitiesChromium.h" +#include "Console.h" +#include "Document.h" +#include "DocumentFragment.h" // Only needed for ReplaceSelectionCommand.h :( +#include "DocumentLoader.h" +#include "DocumentMarker.h" +#include "DOMUtilitiesPrivate.h" +#include "DOMWindow.h" +#include "Editor.h" +#include "EventHandler.h" +#include "FormState.h" +#include "FrameChromium.h" +#include "FrameLoader.h" +#include "FrameLoadRequest.h" +#include "FrameTree.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HistoryItem.h" +#include "HTMLCollection.h" +#include "HTMLFormElement.h" +#include "HTMLFrameOwnerElement.h" +#include "HTMLHeadElement.h" +#include "HTMLInputElement.h" +#include "HTMLLinkElement.h" +#include "HTMLNames.h" +#include "InspectorController.h" +#include "markup.h" +#include "Page.h" +#include "PlatformContextSkia.h" +#include "PrintContext.h" +#include "RenderFrame.h" +#include "RenderView.h" +#include "RenderWidget.h" +#include "ReplaceSelectionCommand.h" +#include "ResourceHandle.h" +#include "ResourceRequest.h" +#include "ScriptController.h" +#include "ScriptSourceCode.h" +#include "ScriptValue.h" +#include "ScrollbarTheme.h" +#include "ScrollTypes.h" +#include "SelectionController.h" +#include "Settings.h" +#include "SkiaUtils.h" +#include "SubstituteData.h" +#include "TextAffinity.h" +#include "TextIterator.h" +#include "WebConsoleMessage.h" +#include "WebDataSourceImpl.h" +#include "WebFindOptions.h" +#include "WebFormElement.h" +#include "WebFrameClient.h" +#include "WebHistoryItem.h" +#include "WebInputElement.h" +#include "WebPasswordAutocompleteListener.h" +#include "WebRange.h" +#include "WebRect.h" +#include "WebScriptSource.h" +#include "WebSecurityOrigin.h" +#include "WebSize.h" +#include "WebURLError.h" +#include "WebVector.h" +#include "WebViewImpl.h" +#include "XPathResult.h" + +#include <algorithm> +#include <wtf/CurrentTime.h> + + +#if PLATFORM(DARWIN) +#include "LocalCurrentGraphicsContext.h" +#endif + +#if PLATFORM(LINUX) +#include <gdk/gdk.h> +#endif + +using namespace WebCore; + +namespace WebKit { + +// Key for a StatsCounter tracking how many WebFrames are active. +static const char* const webFrameActiveCount = "WebFrameActiveCount"; + +static const char* const osdType = "application/opensearchdescription+xml"; +static const char* const osdRel = "search"; + +// Backend for contentAsPlainText, this is a recursive function that gets +// the text for the current frame and all of its subframes. It will append +// the text of each frame in turn to the |output| up to |maxChars| length. +// +// The |frame| must be non-null. +static void frameContentAsPlainText(size_t maxChars, Frame* frame, + Vector<UChar>* output) +{ + Document* doc = frame->document(); + if (!doc) + return; + + if (!frame->view()) + return; + + // TextIterator iterates over the visual representation of the DOM. As such, + // it requires you to do a layout before using it (otherwise it'll crash). + if (frame->view()->needsLayout()) + frame->view()->layout(); + + // Select the document body. + RefPtr<Range> range(doc->createRange()); + ExceptionCode exception = 0; + range->selectNodeContents(doc->body(), exception); + + if (!exception) { + // The text iterator will walk nodes giving us text. This is similar to + // the plainText() function in TextIterator.h, but we implement the maximum + // size and also copy the results directly into a wstring, avoiding the + // string conversion. + for (TextIterator it(range.get()); !it.atEnd(); it.advance()) { + const UChar* chars = it.characters(); + if (!chars) { + if (it.length()) { + // It appears from crash reports that an iterator can get into a state + // where the character count is nonempty but the character pointer is + // null. advance()ing it will then just add that many to the null + // pointer which won't be caught in a null check but will crash. + // + // A null pointer and 0 length is common for some nodes. + // + // IF YOU CATCH THIS IN A DEBUGGER please let brettw know. We don't + // currently understand the conditions for this to occur. Ideally, the + // iterators would never get into the condition so we should fix them + // if we can. + ASSERT_NOT_REACHED(); + break; + } + + // Just got a null node, we can forge ahead! + continue; + } + size_t toAppend = + std::min(static_cast<size_t>(it.length()), maxChars - output->size()); + output->append(chars, toAppend); + if (output->size() >= maxChars) + return; // Filled up the buffer. + } + } + + // The separator between frames when the frames are converted to plain text. + const UChar frameSeparator[] = { '\n', '\n' }; + const size_t frameSeparatorLen = 2; + + // Recursively walk the children. + FrameTree* frameTree = frame->tree(); + for (Frame* curChild = frameTree->firstChild(); curChild; curChild = curChild->tree()->nextSibling()) { + // Make sure the frame separator won't fill up the buffer, and give up if + // it will. The danger is if the separator will make the buffer longer than + // maxChars. This will cause the computation above: + // maxChars - output->size() + // to be a negative number which will crash when the subframe is added. + if (output->size() >= maxChars - frameSeparatorLen) + return; + + output->append(frameSeparator, frameSeparatorLen); + frameContentAsPlainText(maxChars, curChild, output); + if (output->size() >= maxChars) + return; // Filled up the buffer. + } +} + +// Simple class to override some of PrintContext behavior. +class ChromePrintContext : public PrintContext, public Noncopyable { +public: + ChromePrintContext(Frame* frame) + : PrintContext(frame) + , m_printedPageWidth(0) + { + } + + void begin(float width) + { + ASSERT(!m_printedPageWidth); + m_printedPageWidth = width; + PrintContext::begin(m_printedPageWidth); + } + + float getPageShrink(int pageNumber) const + { + IntRect pageRect = m_pageRects[pageNumber]; + return m_printedPageWidth / pageRect.width(); + } + + // Spools the printed page, a subrect of m_frame. Skip the scale step. + // NativeTheme doesn't play well with scaling. Scaling is done browser side + // instead. Returns the scale to be applied. + float spoolPage(GraphicsContext& ctx, int pageNumber) + { + IntRect pageRect = m_pageRects[pageNumber]; + float scale = m_printedPageWidth / pageRect.width(); + + ctx.save(); + ctx.translate(static_cast<float>(-pageRect.x()), + static_cast<float>(-pageRect.y())); + ctx.clip(pageRect); + m_frame->view()->paintContents(&ctx, pageRect); + ctx.restore(); + return scale; + } + +private: + // Set when printing. + float m_printedPageWidth; +}; + +static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) +{ + return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0; +} + + +// WebFrame ------------------------------------------------------------------- + +class WebFrameImpl::DeferredScopeStringMatches { +public: + DeferredScopeStringMatches(WebFrameImpl* webFrame, + int identifier, + const WebString& searchText, + const WebFindOptions& options, + bool reset) + : m_timer(this, &DeferredScopeStringMatches::doTimeout) + , m_webFrame(webFrame) + , m_identifier(identifier) + , m_searchText(searchText) + , m_options(options) + , m_reset(reset) + { + m_timer.startOneShot(0.0); + } + +private: + void doTimeout(Timer<DeferredScopeStringMatches>*) + { + m_webFrame->callScopeStringMatches( + this, m_identifier, m_searchText, m_options, m_reset); + } + + Timer<DeferredScopeStringMatches> m_timer; + RefPtr<WebFrameImpl> m_webFrame; + int m_identifier; + WebString m_searchText; + WebFindOptions m_options; + bool m_reset; +}; + + +// WebFrame ------------------------------------------------------------------- + +WebFrame* WebFrame::frameForEnteredContext() +{ + Frame* frame = + ScriptController::retrieveFrameForEnteredContext(); + return WebFrameImpl::fromFrame(frame); +} + +WebFrame* WebFrame::frameForCurrentContext() +{ + Frame* frame = + ScriptController::retrieveFrameForCurrentContext(); + return WebFrameImpl::fromFrame(frame); +} + +WebString WebFrameImpl::name() const +{ + return m_frame->tree()->name(); +} + +WebURL WebFrameImpl::url() const +{ + const WebDataSource* ds = dataSource(); + if (!ds) + return WebURL(); + return ds->request().url(); +} + +WebURL WebFrameImpl::favIconURL() const +{ + FrameLoader* frameLoader = m_frame->loader(); + // The URL to the favicon may be in the header. As such, only + // ask the loader for the favicon if it's finished loading. + if (frameLoader->state() == FrameStateComplete) { + const KURL& url = frameLoader->iconURL(); + if (!url.isEmpty()) + return url; + } + return WebURL(); +} + +WebURL WebFrameImpl::openSearchDescriptionURL() const +{ + FrameLoader* frameLoader = m_frame->loader(); + if (frameLoader->state() == FrameStateComplete + && m_frame->document() && m_frame->document()->head() + && !m_frame->tree()->parent()) { + HTMLHeadElement* head = m_frame->document()->head(); + if (head) { + RefPtr<HTMLCollection> children = head->children(); + for (Node* child = children->firstItem(); child; child = children->nextItem()) { + HTMLLinkElement* linkElement = toHTMLLinkElement(child); + if (linkElement + && linkElement->type() == osdType + && linkElement->rel() == osdRel + && !linkElement->href().isEmpty()) + return linkElement->href(); + } + } + } + return WebURL(); +} + +WebSize WebFrameImpl::scrollOffset() const +{ + FrameView* view = frameView(); + if (view) + return view->scrollOffset(); + + return WebSize(); +} + +WebSize WebFrameImpl::contentsSize() const +{ + return frame()->view()->contentsSize(); +} + +int WebFrameImpl::contentsPreferredWidth() const +{ + if (m_frame->document() && m_frame->document()->renderView()) + return m_frame->document()->renderView()->minPrefWidth(); + return 0; +} + +int WebFrameImpl::documentElementScrollHeight() const +{ + if (m_frame->document() && m_frame->document()->documentElement()) + return m_frame->document()->documentElement()->scrollHeight(); + return 0; +} + +bool WebFrameImpl::hasVisibleContent() const +{ + return frame()->view()->visibleWidth() > 0 && frame()->view()->visibleHeight() > 0; +} + +WebView* WebFrameImpl::view() const +{ + return viewImpl(); +} + +WebFrame* WebFrameImpl::opener() const +{ + Frame* opener = 0; + if (m_frame) + opener = m_frame->loader()->opener(); + return fromFrame(opener); +} + +WebFrame* WebFrameImpl::parent() const +{ + Frame* parent = 0; + if (m_frame) + parent = m_frame->tree()->parent(); + return fromFrame(parent); +} + +WebFrame* WebFrameImpl::top() const +{ + if (m_frame) + return fromFrame(m_frame->tree()->top()); + + return 0; +} + +WebFrame* WebFrameImpl::firstChild() const +{ + return fromFrame(frame()->tree()->firstChild()); +} + +WebFrame* WebFrameImpl::lastChild() const +{ + return fromFrame(frame()->tree()->lastChild()); +} + +WebFrame* WebFrameImpl::nextSibling() const +{ + return fromFrame(frame()->tree()->nextSibling()); +} + +WebFrame* WebFrameImpl::previousSibling() const +{ + return fromFrame(frame()->tree()->previousSibling()); +} + +WebFrame* WebFrameImpl::traverseNext(bool wrap) const +{ + return fromFrame(frame()->tree()->traverseNextWithWrap(wrap)); +} + +WebFrame* WebFrameImpl::traversePrevious(bool wrap) const +{ + return fromFrame(frame()->tree()->traversePreviousWithWrap(wrap)); +} + +WebFrame* WebFrameImpl::findChildByName(const WebString& name) const +{ + return fromFrame(frame()->tree()->child(name)); +} + +WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const +{ + if (xpath.isEmpty()) + return 0; + + Document* document = m_frame->document(); + + ExceptionCode ec = 0; + PassRefPtr<XPathResult> xpathResult = + document->evaluate(xpath, + document, + 0, // namespace + XPathResult::ORDERED_NODE_ITERATOR_TYPE, + 0, // XPathResult object + ec); + if (!xpathResult.get()) + return 0; + + Node* node = xpathResult->iterateNext(ec); + + if (!node || !node->isFrameOwnerElement()) + return 0; + HTMLFrameOwnerElement* frameElement = + static_cast<HTMLFrameOwnerElement*>(node); + return fromFrame(frameElement->contentFrame()); +} + +void WebFrameImpl::forms(WebVector<WebFormElement>& results) const +{ + if (!m_frame) + return; + + RefPtr<HTMLCollection> forms = m_frame->document()->forms(); + size_t formCount = forms->length(); + + WebVector<WebFormElement> temp(formCount); + for (size_t i = 0; i < formCount; ++i) { + Node* node = forms->item(i); + // Strange but true, sometimes item can be 0. + if (node) + temp[i] = static_cast<HTMLFormElement*>(node); + } + results.swap(temp); +} + +WebSecurityOrigin WebFrameImpl::securityOrigin() const +{ + if (!m_frame || !m_frame->document()) + return WebSecurityOrigin(); + + return WebSecurityOrigin(m_frame->document()->securityOrigin()); +} + +void WebFrameImpl::grantUniversalAccess() +{ + ASSERT(m_frame && m_frame->document()); + if (m_frame && m_frame->document()) + m_frame->document()->securityOrigin()->grantUniversalAccess(); +} + +NPObject* WebFrameImpl::windowObject() const +{ + if (!m_frame) + return 0; + + return m_frame->script()->windowScriptNPObject(); +} + +void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object) +{ + ASSERT(m_frame); + if (!m_frame || !m_frame->script()->isEnabled()) + return; + + String key = name; +#if USE(V8) + m_frame->script()->bindToWindowObject(m_frame, key, object); +#else + notImplemented(); +#endif +} + +void WebFrameImpl::executeScript(const WebScriptSource& source) +{ + m_frame->script()->executeScript( + ScriptSourceCode(source.code, source.url, source.startLine)); +} + +void WebFrameImpl::executeScriptInNewContext( + const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup) +{ + Vector<ScriptSourceCode> sources; + + for (unsigned i = 0; i < numSources; ++i) { + sources.append(ScriptSourceCode( + sourcesIn[i].code, sourcesIn[i].url, sourcesIn[i].startLine)); + } + + m_frame->script()->evaluateInNewContext(sources, extensionGroup); +} + +void WebFrameImpl::executeScriptInIsolatedWorld( + int worldId, const WebScriptSource* sourcesIn, unsigned numSources, + int extensionGroup) +{ + Vector<ScriptSourceCode> sources; + + for (unsigned i = 0; i < numSources; ++i) { + sources.append(ScriptSourceCode( + sourcesIn[i].code, sourcesIn[i].url, sourcesIn[i].startLine)); + } + + m_frame->script()->evaluateInIsolatedWorld(worldId, sources, extensionGroup); +} + +void WebFrameImpl::addMessageToConsole(const WebConsoleMessage& message) +{ + ASSERT(frame()); + + MessageLevel webCoreMessageLevel; + switch (message.level) { + case WebConsoleMessage::LevelTip: + webCoreMessageLevel = TipMessageLevel; + break; + case WebConsoleMessage::LevelLog: + webCoreMessageLevel = LogMessageLevel; + break; + case WebConsoleMessage::LevelWarning: + webCoreMessageLevel = WarningMessageLevel; + break; + case WebConsoleMessage::LevelError: + webCoreMessageLevel = ErrorMessageLevel; + break; + default: + ASSERT_NOT_REACHED(); + return; + } + + frame()->domWindow()->console()->addMessage( + OtherMessageSource, LogMessageType, webCoreMessageLevel, message.text, + 1, String()); +} + +void WebFrameImpl::collectGarbage() +{ + if (!m_frame) + return; + if (!m_frame->settings()->isJavaScriptEnabled()) + return; + // FIXME: Move this to the ScriptController and make it JS neutral. +#if USE(V8) + m_frame->script()->collectGarbage(); +#else + notImplemented(); +#endif +} + +#if USE(V8) +// Returns the V8 context for this frame, or an empty handle if there is none. +v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const +{ + if (!m_frame) + return v8::Local<v8::Context>(); + + return V8Proxy::mainWorldContext(m_frame); +} +#endif + +bool WebFrameImpl::insertStyleText( + const WebString& css, const WebString& id) { + Document* document = frame()->document(); + if (!document) + return false; + Element* documentElement = document->documentElement(); + if (!documentElement) + return false; + + ExceptionCode err = 0; + + if (!id.isEmpty()) { + Element* oldElement = document->getElementById(id); + if (oldElement) { + Node* parent = oldElement->parent(); + if (!parent) + return false; + parent->removeChild(oldElement, err); + } + } + + RefPtr<Element> stylesheet = document->createElement( + HTMLNames::styleTag, false); + if (!id.isEmpty()) + stylesheet->setAttribute(HTMLNames::idAttr, id); + stylesheet->setTextContent(css, err); + ASSERT(!err); + Node* first = documentElement->firstChild(); + bool success = documentElement->insertBefore(stylesheet, first, err); + ASSERT(success); + return success; +} + +void WebFrameImpl::reload() +{ + m_frame->loader()->history()->saveDocumentAndScrollState(); + + stopLoading(); // Make sure existing activity stops. + m_frame->loader()->reload(); +} + +void WebFrameImpl::loadRequest(const WebURLRequest& request) +{ + ASSERT(!request.isNull()); + const ResourceRequest& resourceRequest = request.toResourceRequest(); + + if (resourceRequest.url().protocolIs("javascript")) { + loadJavaScriptURL(resourceRequest.url()); + return; + } + + stopLoading(); // Make sure existing activity stops. + m_frame->loader()->load(resourceRequest, false); +} + +void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item) +{ + RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item); + ASSERT(historyItem.get()); + + stopLoading(); // Make sure existing activity stops. + + // If there is no currentItem, which happens when we are navigating in + // session history after a crash, we need to manufacture one otherwise WebKit + // hoarks. This is probably the wrong thing to do, but it seems to work. + RefPtr<HistoryItem> currentItem = m_frame->loader()->history()->currentItem(); + if (!currentItem) { + currentItem = HistoryItem::create(); + currentItem->setLastVisitWasFailure(true); + m_frame->loader()->history()->setCurrentItem(currentItem.get()); + viewImpl()->setCurrentHistoryItem(currentItem.get()); + } + + m_frame->loader()->history()->goToItem( + historyItem.get(), FrameLoadTypeIndexedBackForward); +} + +void WebFrameImpl::loadData(const WebData& data, + const WebString& mimeType, + const WebString& textEncoding, + const WebURL& baseURL, + const WebURL& unreachableURL, + bool replace) +{ + SubstituteData substData(data, mimeType, textEncoding, unreachableURL); + ASSERT(substData.isValid()); + + // If we are loading substitute data to replace an existing load, then + // inherit all of the properties of that original request. This way, + // reload will re-attempt the original request. It is essential that + // we only do this when there is an unreachableURL since a non-empty + // unreachableURL informs FrameLoader::reload to load unreachableURL + // instead of the currently loaded URL. + ResourceRequest request; + if (replace && !unreachableURL.isEmpty()) + request = m_frame->loader()->originalRequest(); + request.setURL(baseURL); + + stopLoading(); // Make sure existing activity stops. + + m_frame->loader()->load(request, substData, false); + if (replace) { + // Do this to force WebKit to treat the load as replacing the currently + // loaded page. + m_frame->loader()->setReplacing(); + } +} + +void WebFrameImpl::loadHTMLString(const WebData& data, + const WebURL& baseURL, + const WebURL& unreachableURL, + bool replace) +{ + loadData(data, + WebString::fromUTF8("text/html"), + WebString::fromUTF8("UTF-8"), + baseURL, + unreachableURL, + replace); +} + +bool WebFrameImpl::isLoading() const +{ + if (!m_frame) + return false; + return m_frame->loader()->isLoading(); +} + +void WebFrameImpl::stopLoading() +{ + if (!m_frame) + return; + + // FIXME: Figure out what we should really do here. It seems like a bug + // that FrameLoader::stopLoading doesn't call stopAllLoaders. + m_frame->loader()->stopAllLoaders(); + m_frame->loader()->stopLoading(UnloadEventPolicyNone); +} + +WebDataSource* WebFrameImpl::provisionalDataSource() const +{ + FrameLoader* frameLoader = m_frame->loader(); + + // We regard the policy document loader as still provisional. + DocumentLoader* docLoader = frameLoader->provisionalDocumentLoader(); + if (!docLoader) + docLoader = frameLoader->policyDocumentLoader(); + + return DataSourceForDocLoader(docLoader); +} + +WebDataSource* WebFrameImpl::dataSource() const +{ + return DataSourceForDocLoader(m_frame->loader()->documentLoader()); +} + +WebHistoryItem WebFrameImpl::previousHistoryItem() const +{ + // We use the previous item here because documentState (filled-out forms) + // only get saved to history when it becomes the previous item. The caller + // is expected to query the history item after a navigation occurs, after + // the desired history item has become the previous entry. + return WebHistoryItem(viewImpl()->previousHistoryItem()); +} + +WebHistoryItem WebFrameImpl::currentHistoryItem() const +{ + m_frame->loader()->history()->saveDocumentAndScrollState(); + + return WebHistoryItem(m_frame->page()->backForwardList()->currentItem()); +} + +void WebFrameImpl::enableViewSourceMode(bool enable) +{ + if (m_frame) + m_frame->setInViewSourceMode(enable); +} + +bool WebFrameImpl::isViewSourceModeEnabled() const +{ + if (m_frame) + return m_frame->inViewSourceMode(); + + return false; +} + +void WebFrameImpl::setReferrerForRequest( + WebURLRequest& request, const WebURL& referrerURL) { + String referrer; + if (referrerURL.isEmpty()) + referrer = m_frame->loader()->outgoingReferrer(); + else + referrer = referrerURL.spec().utf16(); + if (SecurityOrigin::shouldHideReferrer(request.url(), referrer)) + return; + request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); +} + +void WebFrameImpl::dispatchWillSendRequest(WebURLRequest& request) +{ + ResourceResponse response; + m_frame->loader()->client()->dispatchWillSendRequest( + 0, 0, request.toMutableResourceRequest(), response); +} + +void WebFrameImpl::commitDocumentData(const char* data, size_t dataLen) +{ + DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); + + // Set the text encoding. This calls begin() for us. It is safe to call + // this multiple times (Mac does: page/mac/WebCoreFrameBridge.mm). + bool userChosen = true; + String encoding = documentLoader->overrideEncoding(); + if (encoding.isNull()) { + userChosen = false; + encoding = documentLoader->response().textEncodingName(); + } + m_frame->loader()->setEncoding(encoding, userChosen); + + // NOTE: mac only does this if there is a document + m_frame->loader()->addData(data, dataLen); +} + +unsigned WebFrameImpl::unloadListenerCount() const +{ + return frame()->domWindow()->pendingUnloadEventListeners(); +} + +bool WebFrameImpl::isProcessingUserGesture() const +{ + return frame()->loader()->isProcessingUserGesture(); +} + +bool WebFrameImpl::willSuppressOpenerInNewFrame() const +{ + return frame()->loader()->suppressOpenerInNewFrame(); +} + +void WebFrameImpl::replaceSelection(const WebString& text) +{ + RefPtr<DocumentFragment> fragment = createFragmentFromText( + frame()->selection()->toNormalizedRange().get(), text); + applyCommand(ReplaceSelectionCommand::create( + frame()->document(), fragment.get(), false, true, true)); +} + +void WebFrameImpl::insertText(const WebString& text) +{ + frame()->editor()->insertText(text, 0); +} + +void WebFrameImpl::setMarkedText( + const WebString& text, unsigned location, unsigned length) +{ + Editor* editor = frame()->editor(); + + editor->confirmComposition(text); + + Vector<CompositionUnderline> decorations; + editor->setComposition(text, decorations, location, length); +} + +void WebFrameImpl::unmarkText() +{ + frame()->editor()->confirmCompositionWithoutDisturbingSelection(); +} + +bool WebFrameImpl::hasMarkedText() const +{ + return frame()->editor()->hasComposition(); +} + +WebRange WebFrameImpl::markedRange() const +{ + return frame()->editor()->compositionRange(); +} + +bool WebFrameImpl::executeCommand(const WebString& name) +{ + ASSERT(frame()); + + if (name.length() <= 2) + return false; + + // Since we don't have NSControl, we will convert the format of command + // string and call the function on Editor directly. + String command = name; + + // Make sure the first letter is upper case. + command.replace(0, 1, command.substring(0, 1).upper()); + + // Remove the trailing ':' if existing. + if (command[command.length() - 1] == UChar(':')) + command = command.substring(0, command.length() - 1); + + bool rv = true; + + // Specially handling commands that Editor::execCommand does not directly + // support. + if (command == "DeleteToEndOfParagraph") { + Editor* editor = frame()->editor(); + if (!editor->deleteWithDirection(SelectionController::FORWARD, + ParagraphBoundary, + true, + false)) { + editor->deleteWithDirection(SelectionController::FORWARD, + CharacterGranularity, + true, + false); + } + } else if (command == "Indent") + frame()->editor()->indent(); + else if (command == "Outdent") + frame()->editor()->outdent(); + else if (command == "DeleteBackward") + rv = frame()->editor()->command(AtomicString("BackwardDelete")).execute(); + else if (command == "DeleteForward") + rv = frame()->editor()->command(AtomicString("ForwardDelete")).execute(); + else if (command == "AdvanceToNextMisspelling") { + // False must be passed here, or the currently selected word will never be + // skipped. + frame()->editor()->advanceToNextMisspelling(false); + } else if (command == "ToggleSpellPanel") + frame()->editor()->showSpellingGuessPanel(); + else + rv = frame()->editor()->command(command).execute(); + return rv; +} + +bool WebFrameImpl::executeCommand(const WebString& name, const WebString& value) +{ + ASSERT(frame()); + String webName = name; + + // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebKit + // for editable nodes. + if (!frame()->editor()->canEdit() && webName == "moveToBeginningOfDocument") + return viewImpl()->propagateScroll(ScrollUp, ScrollByDocument); + + if (!frame()->editor()->canEdit() && webName == "moveToEndOfDocument") + return viewImpl()->propagateScroll(ScrollDown, ScrollByDocument); + + return frame()->editor()->command(webName).execute(value); +} + +bool WebFrameImpl::isCommandEnabled(const WebString& name) const +{ + ASSERT(frame()); + return frame()->editor()->command(name).isEnabled(); +} + +void WebFrameImpl::enableContinuousSpellChecking(bool enable) +{ + if (enable == isContinuousSpellCheckingEnabled()) + return; + frame()->editor()->toggleContinuousSpellChecking(); +} + +bool WebFrameImpl::isContinuousSpellCheckingEnabled() const +{ + return frame()->editor()->isContinuousSpellCheckingEnabled(); +} + +bool WebFrameImpl::hasSelection() const +{ + // frame()->selection()->isNone() never returns true. + return (frame()->selection()->start() != frame()->selection()->end()); +} + +WebRange WebFrameImpl::selectionRange() const +{ + return frame()->selection()->toNormalizedRange(); +} + +WebString WebFrameImpl::selectionAsText() const +{ + RefPtr<Range> range = frame()->selection()->toNormalizedRange(); + if (!range.get()) + return WebString(); + + String text = range->text(); +#if PLATFORM(WIN_OS) + replaceNewlinesWithWindowsStyleNewlines(text); +#endif + replaceNBSPWithSpace(text); + return text; +} + +WebString WebFrameImpl::selectionAsMarkup() const +{ + RefPtr<Range> range = frame()->selection()->toNormalizedRange(); + if (!range.get()) + return WebString(); + + return createMarkup(range.get(), 0); +} + +int WebFrameImpl::printBegin(const WebSize& pageSize) +{ + ASSERT(!frame()->document()->isFrameSet()); + + m_printContext.set(new ChromePrintContext(frame())); + FloatRect rect(0, 0, static_cast<float>(pageSize.width), + static_cast<float>(pageSize.height)); + m_printContext->begin(rect.width()); + float pageHeight; + // We ignore the overlays calculation for now since they are generated in the + // browser. pageHeight is actually an output parameter. + m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); + return m_printContext->pageCount(); +} + +float WebFrameImpl::getPrintPageShrink(int page) +{ + // Ensure correct state. + if (!m_printContext.get() || page < 0) { + ASSERT_NOT_REACHED(); + return 0; + } + + return m_printContext->getPageShrink(page); +} + +float WebFrameImpl::printPage(int page, WebCanvas* canvas) +{ + // Ensure correct state. + if (!m_printContext.get() || page < 0 || !frame() || !frame()->document()) { + ASSERT_NOT_REACHED(); + return 0; + } + +#if PLATFORM(WIN_OS) || PLATFORM(LINUX) || PLATFORM(FREEBSD) + PlatformContextSkia context(canvas); + GraphicsContext spool(&context); +#elif PLATFORM(DARWIN) + GraphicsContext spool(canvas); + LocalCurrentGraphicsContext localContext(&spool); +#endif + + return m_printContext->spoolPage(spool, page); +} + +void WebFrameImpl::printEnd() +{ + ASSERT(m_printContext.get()); + if (m_printContext.get()) + m_printContext->end(); + m_printContext.clear(); +} + +bool WebFrameImpl::find(int identifier, + const WebString& searchText, + const WebFindOptions& options, + bool wrapWithinFrame, + WebRect* selectionRect) +{ + WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); + + if (!options.findNext) + frame()->page()->unmarkAllTextMatches(); + else + setMarkerActive(m_activeMatch.get(), false); // Active match is changing. + + // Starts the search from the current selection. + bool startInSelection = true; + + // If the user has selected something since the last Find operation we want + // to start from there. Otherwise, we start searching from where the last Find + // operation left off (either a Find or a FindNext operation). + VisibleSelection selection(frame()->selection()->selection()); + bool activeSelection = !selection.isNone(); + if (!activeSelection && m_activeMatch) { + selection = VisibleSelection(m_activeMatch.get()); + frame()->selection()->setSelection(selection); + } + + ASSERT(frame() && frame()->view()); + bool found = frame()->findString( + searchText, options.forward, options.matchCase, wrapWithinFrame, + startInSelection); + if (found) { + // Store which frame was active. This will come in handy later when we + // change the active match ordinal below. + WebFrameImpl* oldActiveFrame = mainFrameImpl->m_activeMatchFrame; + // Set this frame as the active frame (the one with the active highlight). + mainFrameImpl->m_activeMatchFrame = this; + + // We found something, so we can now query the selection for its position. + VisibleSelection newSelection(frame()->selection()->selection()); + IntRect currSelectionRect; + + // If we thought we found something, but it couldn't be selected (perhaps + // because it was marked -webkit-user-select: none), we can't set it to + // be active but we still continue searching. This matches Safari's + // behavior, including some oddities when selectable and un-selectable text + // are mixed on a page: see https://bugs.webkit.org/show_bug.cgi?id=19127. + if (newSelection.isNone() || (newSelection.start() == newSelection.end())) + m_activeMatch = 0; + else { + m_activeMatch = newSelection.toNormalizedRange(); + currSelectionRect = m_activeMatch->boundingBox(); + setMarkerActive(m_activeMatch.get(), true); // Active. + // WebKit draws the highlighting for all matches. + executeCommand(WebString::fromUTF8("Unselect")); + } + + if (!options.findNext || activeSelection) { + // This is either a Find operation or a Find-next from a new start point + // due to a selection, so we set the flag to ask the scoping effort + // to find the active rect for us so we can update the ordinal (n of m). + m_locatingActiveRect = true; + } else { + if (oldActiveFrame != this) { + // If the active frame has changed it means that we have a multi-frame + // page and we just switch to searching in a new frame. Then we just + // want to reset the index. + if (options.forward) + m_activeMatchIndex = 0; + else + m_activeMatchIndex = m_lastMatchCount - 1; + } else { + // We are still the active frame, so increment (or decrement) the + // |m_activeMatchIndex|, wrapping if needed (on single frame pages). + options.forward ? ++m_activeMatchIndex : --m_activeMatchIndex; + if (m_activeMatchIndex + 1 > m_lastMatchCount) + m_activeMatchIndex = 0; + if (m_activeMatchIndex == -1) + m_activeMatchIndex = m_lastMatchCount - 1; + } + if (selectionRect) { + WebRect rect = frame()->view()->convertToContainingWindow(currSelectionRect); + rect.x -= frameView()->scrollOffset().width(); + rect.y -= frameView()->scrollOffset().height(); + *selectionRect = rect; + + reportFindInPageSelection(rect, m_activeMatchIndex + 1, identifier); + } + } + } else { + // Nothing was found in this frame. + m_activeMatch = 0; + + // Erase all previous tickmarks and highlighting. + invalidateArea(InvalidateAll); + } + + return found; +} + +void WebFrameImpl::stopFinding(bool clearSelection) +{ + if (!clearSelection) + setFindEndstateFocusAndSelection(); + cancelPendingScopingEffort(); + + // Remove all markers for matches found and turn off the highlighting. + if (!parent()) + frame()->document()->removeMarkers(DocumentMarker::TextMatch); + frame()->setMarkedTextMatchesAreHighlighted(false); + + // Let the frame know that we don't want tickmarks or highlighting anymore. + invalidateArea(InvalidateAll); +} + +void WebFrameImpl::scopeStringMatches(int identifier, + const WebString& searchText, + const WebFindOptions& options, + bool reset) +{ + if (!shouldScopeMatches(searchText)) + return; + + WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); + + if (reset) { + // This is a brand new search, so we need to reset everything. + // Scoping is just about to begin. + m_scopingComplete = false; + // Clear highlighting for this frame. + if (frame()->markedTextMatchesAreHighlighted()) + frame()->page()->unmarkAllTextMatches(); + // Clear the counters from last operation. + m_lastMatchCount = 0; + m_nextInvalidateAfter = 0; + + m_resumeScopingFromRange = 0; + + mainFrameImpl->m_framesScopingCount++; + + // Now, defer scoping until later to allow find operation to finish quickly. + scopeStringMatchesSoon( + identifier, + searchText, + options, + false); // false=we just reset, so don't do it again. + return; + } + + RefPtr<Range> searchRange(rangeOfContents(frame()->document())); + + ExceptionCode ec = 0, ec2 = 0; + if (m_resumeScopingFromRange.get()) { + // This is a continuation of a scoping operation that timed out and didn't + // complete last time around, so we should start from where we left off. + searchRange->setStart(m_resumeScopingFromRange->startContainer(), + m_resumeScopingFromRange->startOffset(ec2) + 1, + ec); + if (ec || ec2) { + if (ec2) // A non-zero |ec| happens when navigating during search. + ASSERT_NOT_REACHED(); + return; + } + } + + // This timeout controls how long we scope before releasing control. This + // value does not prevent us from running for longer than this, but it is + // periodically checked to see if we have exceeded our allocated time. + const double maxScopingDuration = 0.1; // seconds + + int matchCount = 0; + bool timedOut = false; + double startTime = currentTime(); + do { + // Find next occurrence of the search string. + // FIXME: (http://b/1088245) This WebKit operation may run for longer + // than the timeout value, and is not interruptible as it is currently + // written. We may need to rewrite it with interruptibility in mind, or + // find an alternative. + RefPtr<Range> resultRange(findPlainText(searchRange.get(), + searchText, + true, + options.matchCase)); + if (resultRange->collapsed(ec)) { + if (!resultRange->startContainer()->isInShadowTree()) + break; + + searchRange = rangeOfContents(frame()->document()); + searchRange->setStartAfter( + resultRange->startContainer()->shadowAncestorNode(), ec); + continue; + } + + // A non-collapsed result range can in some funky whitespace cases still not + // advance the range's start position (4509328). Break to avoid infinite + // loop. (This function is based on the implementation of + // Frame::markAllMatchesForText, which is where this safeguard comes from). + VisiblePosition newStart = endVisiblePosition(resultRange.get(), DOWNSTREAM); + if (newStart == startVisiblePosition(searchRange.get(), DOWNSTREAM)) + break; + + // Only treat the result as a match if it is visible + if (frame()->editor()->insideVisibleArea(resultRange.get())) { + ++matchCount; + + setStart(searchRange.get(), newStart); + Node* shadowTreeRoot = searchRange->shadowTreeRootNode(); + if (searchRange->collapsed(ec) && shadowTreeRoot) + searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount(), ec); + + // Catch a special case where Find found something but doesn't know what + // the bounding box for it is. In this case we set the first match we find + // as the active rect. + IntRect resultBounds = resultRange->boundingBox(); + IntRect activeSelectionRect; + if (m_locatingActiveRect) { + activeSelectionRect = m_activeMatch.get() ? + m_activeMatch->boundingBox() : resultBounds; + } + + // If the Find function found a match it will have stored where the + // match was found in m_activeSelectionRect on the current frame. If we + // find this rect during scoping it means we have found the active + // tickmark. + bool foundActiveMatch = false; + if (m_locatingActiveRect && (activeSelectionRect == resultBounds)) { + // We have found the active tickmark frame. + mainFrameImpl->m_activeMatchFrame = this; + foundActiveMatch = true; + // We also know which tickmark is active now. + m_activeMatchIndex = matchCount - 1; + // To stop looking for the active tickmark, we set this flag. + m_locatingActiveRect = false; + + // Notify browser of new location for the selected rectangle. + resultBounds.move(-frameView()->scrollOffset().width(), + -frameView()->scrollOffset().height()); + reportFindInPageSelection( + frame()->view()->convertToContainingWindow(resultBounds), + m_activeMatchIndex + 1, + identifier); + } + + addMarker(resultRange.get(), foundActiveMatch); + } + + m_resumeScopingFromRange = resultRange; + timedOut = (currentTime() - startTime) >= maxScopingDuration; + } while (!timedOut); + + // Remember what we search for last time, so we can skip searching if more + // letters are added to the search string (and last outcome was 0). + m_lastSearchString = searchText; + + if (matchCount > 0) { + frame()->setMarkedTextMatchesAreHighlighted(true); + + m_lastMatchCount += matchCount; + + // Let the mainframe know how much we found during this pass. + mainFrameImpl->increaseMatchCount(matchCount, identifier); + } + + if (timedOut) { + // If we found anything during this pass, we should redraw. However, we + // don't want to spam too much if the page is extremely long, so if we + // reach a certain point we start throttling the redraw requests. + if (matchCount > 0) + invalidateIfNecessary(); + + // Scoping effort ran out of time, lets ask for another time-slice. + scopeStringMatchesSoon( + identifier, + searchText, + options, + false); // don't reset. + return; // Done for now, resume work later. + } + + // This frame has no further scoping left, so it is done. Other frames might, + // of course, continue to scope matches. + m_scopingComplete = true; + mainFrameImpl->m_framesScopingCount--; + + // If this is the last frame to finish scoping we need to trigger the final + // update to be sent. + if (!mainFrameImpl->m_framesScopingCount) + mainFrameImpl->increaseMatchCount(0, identifier); + + // This frame is done, so show any scrollbar tickmarks we haven't drawn yet. + invalidateArea(InvalidateScrollbar); +} + +void WebFrameImpl::cancelPendingScopingEffort() +{ + deleteAllValues(m_deferredScopingWork); + m_deferredScopingWork.clear(); + + m_activeMatchIndex = -1; +} + +void WebFrameImpl::increaseMatchCount(int count, int identifier) +{ + // This function should only be called on the mainframe. + ASSERT(!parent()); + + m_totalMatchCount += count; + + // Update the UI with the latest findings. + if (client()) + client()->reportFindInPageMatchCount(identifier, m_totalMatchCount, !m_framesScopingCount); +} + +void WebFrameImpl::reportFindInPageSelection(const WebRect& selectionRect, + int activeMatchOrdinal, + int identifier) +{ + // Update the UI with the latest selection rect. + if (client()) + client()->reportFindInPageSelection(identifier, ordinalOfFirstMatchForFrame(this) + activeMatchOrdinal, selectionRect); +} + +void WebFrameImpl::resetMatchCount() +{ + m_totalMatchCount = 0; + m_framesScopingCount = 0; +} + +WebURL WebFrameImpl::completeURL(const WebString& url) const +{ + if (!m_frame || !m_frame->document()) + return WebURL(); + + return m_frame->document()->completeURL(url); +} + +WebString WebFrameImpl::contentAsText(size_t maxChars) const +{ + if (!m_frame) + return WebString(); + + Vector<UChar> text; + frameContentAsPlainText(maxChars, m_frame, &text); + return String::adopt(text); +} + +WebString WebFrameImpl::contentAsMarkup() const +{ + return createFullMarkup(m_frame->document()); +} + +// WebFrameImpl public --------------------------------------------------------- + +int WebFrameImpl::m_liveObjectCount = 0; + +PassRefPtr<WebFrameImpl> WebFrameImpl::create(WebFrameClient* client) +{ + return adoptRef(new WebFrameImpl(client)); +} + +WebFrameImpl::WebFrameImpl(WebFrameClient* client) + : m_frameLoaderClient(this) + , m_client(client) + , m_activeMatchFrame(0) + , m_activeMatchIndex(-1) + , m_locatingActiveRect(false) + , m_resumeScopingFromRange(0) + , m_lastMatchCount(-1) + , m_totalMatchCount(-1) + , m_framesScopingCount(-1) + , m_scopingComplete(false) + , m_nextInvalidateAfter(0) +{ + ChromiumBridge::incrementStatsCounter(webFrameActiveCount); + m_liveObjectCount++; +} + +WebFrameImpl::~WebFrameImpl() +{ + ChromiumBridge::decrementStatsCounter(webFrameActiveCount); + m_liveObjectCount--; + + cancelPendingScopingEffort(); + clearPasswordListeners(); +} + +void WebFrameImpl::initializeAsMainFrame(WebViewImpl* webViewImpl) +{ + RefPtr<Frame> frame = Frame::create(webViewImpl->page(), 0, &m_frameLoaderClient); + m_frame = frame.get(); + + // Add reference on behalf of FrameLoader. See comments in + // WebFrameLoaderClient::frameLoaderDestroyed for more info. + ref(); + + // We must call init() after m_frame is assigned because it is referenced + // during init(). + m_frame->init(); +} + +PassRefPtr<Frame> WebFrameImpl::createChildFrame( + const FrameLoadRequest& request, HTMLFrameOwnerElement* ownerElement) +{ + RefPtr<WebFrameImpl> webframe(adoptRef(new WebFrameImpl(m_client))); + + // Add an extra ref on behalf of the Frame/FrameLoader, which references the + // WebFrame via the FrameLoaderClient interface. See the comment at the top + // of this file for more info. + webframe->ref(); + + RefPtr<Frame> childFrame = Frame::create( + m_frame->page(), ownerElement, &webframe->m_frameLoaderClient); + webframe->m_frame = childFrame.get(); + + childFrame->tree()->setName(request.frameName()); + + m_frame->tree()->appendChild(childFrame); + + // Frame::init() can trigger onload event in the parent frame, + // which may detach this frame and trigger a null-pointer access + // in FrameTree::removeChild. Move init() after appendChild call + // so that webframe->mFrame is in the tree before triggering + // onload event handler. + // Because the event handler may set webframe->mFrame to null, + // it is necessary to check the value after calling init() and + // return without loading URL. + // (b:791612) + childFrame->init(); // create an empty document + if (!childFrame->tree()->parent()) + return 0; + + m_frame->loader()->loadURLIntoChildFrame( + request.resourceRequest().url(), + request.resourceRequest().httpReferrer(), + childFrame.get()); + + // A synchronous navigation (about:blank) would have already processed + // onload, so it is possible for the frame to have already been destroyed by + // script in the page. + if (!childFrame->tree()->parent()) + return 0; + + return childFrame.release(); +} + +void WebFrameImpl::layout() +{ + // layout this frame + FrameView* view = m_frame->view(); + if (view) + view->layoutIfNeededRecursive(); +} + +void WebFrameImpl::paint(WebCanvas* canvas, const WebRect& rect) +{ + if (rect.isEmpty()) + return; + IntRect dirtyRect(rect); +#if WEBKIT_USING_CG + GraphicsContext gc(canvas); + LocalCurrentGraphicsContext localContext(&gc); +#elif WEBKIT_USING_SKIA + PlatformContextSkia context(canvas); + + // PlatformGraphicsContext is actually a pointer to PlatformContextSkia + GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); +#else + notImplemented(); +#endif + gc.save(); + if (m_frame->document() && frameView()) { + gc.clip(dirtyRect); + frameView()->paint(&gc, dirtyRect); + m_frame->page()->inspectorController()->drawNodeHighlight(gc); + } else + gc.fillRect(dirtyRect, Color::white, DeviceColorSpace); + gc.restore(); +} + +void WebFrameImpl::createFrameView() +{ + ASSERT(m_frame); // If m_frame doesn't exist, we probably didn't init properly. + + Page* page = m_frame->page(); + ASSERT(page); + ASSERT(page->mainFrame()); + + bool isMainFrame = m_frame == page->mainFrame(); + if (isMainFrame && m_frame->view()) + m_frame->view()->setParentVisible(false); + + m_frame->setView(0); + + WebViewImpl* webView = viewImpl(); + + RefPtr<FrameView> view; + if (isMainFrame) + view = FrameView::create(m_frame, webView->size()); + else + view = FrameView::create(m_frame); + + m_frame->setView(view); + + if (webView->isTransparent()) + view->setTransparent(true); + + // FIXME: The Mac code has a comment about this possibly being unnecessary. + // See installInFrame in WebCoreFrameBridge.mm + if (m_frame->ownerRenderer()) + m_frame->ownerRenderer()->setWidget(view.get()); + + if (HTMLFrameOwnerElement* owner = m_frame->ownerElement()) + view->setCanHaveScrollbars(owner->scrollingMode() != ScrollbarAlwaysOff); + + if (isMainFrame) + view->setParentVisible(true); +} + +WebFrameImpl* WebFrameImpl::fromFrame(Frame* frame) +{ + if (!frame) + return 0; + + return static_cast<FrameLoaderClientImpl*>(frame->loader()->client())->webFrame(); +} + +WebViewImpl* WebFrameImpl::viewImpl() const +{ + if (!m_frame) + return 0; + + return WebViewImpl::fromPage(m_frame->page()); +} + +WebDataSourceImpl* WebFrameImpl::dataSourceImpl() const +{ + return static_cast<WebDataSourceImpl*>(dataSource()); +} + +WebDataSourceImpl* WebFrameImpl::provisionalDataSourceImpl() const +{ + return static_cast<WebDataSourceImpl*>(provisionalDataSource()); +} + +void WebFrameImpl::setFindEndstateFocusAndSelection() +{ + WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); + + if (this == mainFrameImpl->activeMatchFrame() && m_activeMatch.get()) { + // If the user has set the selection since the match was found, we + // don't focus anything. + VisibleSelection selection(frame()->selection()->selection()); + if (!selection.isNone()) + return; + + // Try to find the first focusable node up the chain, which will, for + // example, focus links if we have found text within the link. + Node* node = m_activeMatch->firstNode(); + while (node && !node->isFocusable() && node != frame()->document()) + node = node->parent(); + + if (node && node != frame()->document()) { + // Found a focusable parent node. Set focus to it. + frame()->document()->setFocusedNode(node); + return; + } + + // Iterate over all the nodes in the range until we find a focusable node. + // This, for example, sets focus to the first link if you search for + // text and text that is within one or more links. + node = m_activeMatch->firstNode(); + while (node && node != m_activeMatch->pastLastNode()) { + if (node->isFocusable()) { + frame()->document()->setFocusedNode(node); + return; + } + node = node->traverseNextNode(); + } + + // No node related to the active match was focusable, so set the + // active match as the selection (so that when you end the Find session, + // you'll have the last thing you found highlighted) and make sure that + // we have nothing focused (otherwise you might have text selected but + // a link focused, which is weird). + frame()->selection()->setSelection(m_activeMatch.get()); + frame()->document()->setFocusedNode(0); + } +} + +void WebFrameImpl::didFail(const ResourceError& error, bool wasProvisional) +{ + if (!client()) + return; + WebURLError webError = error; + if (wasProvisional) + client()->didFailProvisionalLoad(this, webError); + else + client()->didFailLoad(this, webError); +} + +void WebFrameImpl::setAllowsScrolling(bool flag) +{ + m_frame->view()->setCanHaveScrollbars(flag); +} + +void WebFrameImpl::registerPasswordListener( + WebInputElement inputElement, + WebPasswordAutocompleteListener* listener) +{ + RefPtr<HTMLInputElement> element = inputElement.operator PassRefPtr<HTMLInputElement>(); + ASSERT(m_passwordListeners.find(element) == m_passwordListeners.end()); + m_passwordListeners.set(element, listener); +} + +WebPasswordAutocompleteListener* WebFrameImpl::getPasswordListener( + HTMLInputElement* inputElement) +{ + return m_passwordListeners.get(RefPtr<HTMLInputElement>(inputElement)); +} + +// WebFrameImpl private -------------------------------------------------------- + +void WebFrameImpl::closing() +{ + m_frame = 0; +} + +void WebFrameImpl::invalidateArea(AreaToInvalidate area) +{ + ASSERT(frame() && frame()->view()); + FrameView* view = frame()->view(); + + if ((area & InvalidateAll) == InvalidateAll) + view->invalidateRect(view->frameRect()); + else { + if ((area & InvalidateContentArea) == InvalidateContentArea) { + IntRect contentArea( + view->x(), view->y(), view->visibleWidth(), view->visibleHeight()); + view->invalidateRect(contentArea); + } + + if ((area & InvalidateScrollbar) == InvalidateScrollbar) { + // Invalidate the vertical scroll bar region for the view. + IntRect scrollBarVert( + view->x() + view->visibleWidth(), view->y(), + ScrollbarTheme::nativeTheme()->scrollbarThickness(), + view->visibleHeight()); + view->invalidateRect(scrollBarVert); + } + } +} + +void WebFrameImpl::addMarker(Range* range, bool activeMatch) +{ + // Use a TextIterator to visit the potentially multiple nodes the range + // covers. + TextIterator markedText(range); + for (; !markedText.atEnd(); markedText.advance()) { + RefPtr<Range> textPiece = markedText.range(); + int exception = 0; + + DocumentMarker marker = { + DocumentMarker::TextMatch, + textPiece->startOffset(exception), + textPiece->endOffset(exception), + "", + activeMatch + }; + + if (marker.endOffset > marker.startOffset) { + // Find the node to add a marker to and add it. + Node* node = textPiece->startContainer(exception); + frame()->document()->addMarker(node, marker); + + // Rendered rects for markers in WebKit are not populated until each time + // the markers are painted. However, we need it to happen sooner, because + // the whole purpose of tickmarks on the scrollbar is to show where + // matches off-screen are (that haven't been painted yet). + Vector<DocumentMarker> markers = frame()->document()->markersForNode(node); + frame()->document()->setRenderedRectForMarker( + textPiece->startContainer(exception), + markers[markers.size() - 1], + range->boundingBox()); + } + } +} + +void WebFrameImpl::setMarkerActive(Range* range, bool active) +{ + if (!range) + return; + + frame()->document()->setMarkersActive(range, active); +} + +int WebFrameImpl::ordinalOfFirstMatchForFrame(WebFrameImpl* frame) const +{ + int ordinal = 0; + WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); + // Iterate from the main frame up to (but not including) |frame| and + // add up the number of matches found so far. + for (WebFrameImpl* it = mainFrameImpl; + it != frame; + it = static_cast<WebFrameImpl*>(it->traverseNext(true))) { + if (it->m_lastMatchCount > 0) + ordinal += it->m_lastMatchCount; + } + return ordinal; +} + +bool WebFrameImpl::shouldScopeMatches(const String& searchText) +{ + // Don't scope if we can't find a frame or if the frame is not visible. + // The user may have closed the tab/application, so abort. + if (!frame() || !hasVisibleContent()) + return false; + + ASSERT(frame()->document() && frame()->view()); + + // If the frame completed the scoping operation and found 0 matches the last + // time it was searched, then we don't have to search it again if the user is + // just adding to the search string or sending the same search string again. + if (m_scopingComplete && !m_lastSearchString.isEmpty() && !m_lastMatchCount) { + // Check to see if the search string prefixes match. + String previousSearchPrefix = + searchText.substring(0, m_lastSearchString.length()); + + if (previousSearchPrefix == m_lastSearchString) + return false; // Don't search this frame, it will be fruitless. + } + + return true; +} + +void WebFrameImpl::scopeStringMatchesSoon(int identifier, const WebString& searchText, + const WebFindOptions& options, bool reset) +{ + m_deferredScopingWork.append(new DeferredScopeStringMatches( + this, identifier, searchText, options, reset)); +} + +void WebFrameImpl::callScopeStringMatches(DeferredScopeStringMatches* caller, + int identifier, const WebString& searchText, + const WebFindOptions& options, bool reset) +{ + m_deferredScopingWork.remove(m_deferredScopingWork.find(caller)); + + scopeStringMatches(identifier, searchText, options, reset); + + // This needs to happen last since searchText is passed by reference. + delete caller; +} + +void WebFrameImpl::invalidateIfNecessary() +{ + if (m_lastMatchCount > m_nextInvalidateAfter) { + // FIXME: (http://b/1088165) Optimize the drawing of the tickmarks and + // remove this. This calculation sets a milestone for when next to + // invalidate the scrollbar and the content area. We do this so that we + // don't spend too much time drawing the scrollbar over and over again. + // Basically, up until the first 500 matches there is no throttle. + // After the first 500 matches, we set set the milestone further and + // further out (750, 1125, 1688, 2K, 3K). + static const int startSlowingDownAfter = 500; + static const int slowdown = 750; + int i = (m_lastMatchCount / startSlowingDownAfter); + m_nextInvalidateAfter += i * slowdown; + + invalidateArea(InvalidateScrollbar); + } +} + +void WebFrameImpl::clearPasswordListeners() +{ + deleteAllValues(m_passwordListeners); + m_passwordListeners.clear(); +} + +void WebFrameImpl::loadJavaScriptURL(const KURL& url) +{ + // This is copied from FrameLoader::executeIfJavaScriptURL. Unfortunately, + // we cannot just use that method since it is private, and it also doesn't + // quite behave as we require it to for bookmarklets. The key difference is + // that we need to suppress loading the string result from evaluating the JS + // URL if executing the JS URL resulted in a location change. We also allow + // a JS URL to be loaded even if scripts on the page are otherwise disabled. + + if (!m_frame->document() || !m_frame->page()) + return; + + String script = decodeURLEscapeSequences(url.string().substring(strlen("javascript:"))); + ScriptValue result = m_frame->script()->executeScript(script, true); + + String scriptResult; + if (!result.getString(scriptResult)) + return; + + SecurityOrigin* securityOrigin = m_frame->document()->securityOrigin(); + + if (!m_frame->redirectScheduler()->locationChangePending()) { + m_frame->loader()->stopAllLoaders(); + m_frame->loader()->begin(m_frame->loader()->url(), true, securityOrigin); + m_frame->loader()->write(scriptResult); + m_frame->loader()->end(); + } +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebFrameImpl.h b/WebKit/chromium/src/WebFrameImpl.h new file mode 100644 index 0000000..2cd332a --- /dev/null +++ b/WebKit/chromium/src/WebFrameImpl.h @@ -0,0 +1,355 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebFrameImpl_h +#define WebFrameImpl_h + +// FIXME: remove this relative path once consumers from glue are removed. +#include "../public/WebFrame.h" +#include "Frame.h" +#include "FrameLoaderClientImpl.h" +#include "PlatformString.h" +#include <wtf/OwnPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { +class HistoryItem; +class KURL; +class Node; +class Range; +class SubstituteData; +struct WindowFeatures; +} + +namespace WebKit { +class ChromePrintContext; +class WebDataSourceImpl; +class WebInputElement; +class WebFrameClient; +class WebPasswordAutocompleteListener; +class WebView; +class WebViewImpl; + +// Implementation of WebFrame, note that this is a reference counted object. +class WebFrameImpl : public WebFrame, public RefCounted<WebFrameImpl> { +public: + // WebFrame methods: + virtual WebString name() const; + virtual WebURL url() const; + virtual WebURL favIconURL() const; + virtual WebURL openSearchDescriptionURL() const; + virtual WebSize scrollOffset() const; + virtual WebSize contentsSize() const; + virtual int contentsPreferredWidth() const; + virtual int documentElementScrollHeight() const; + virtual bool hasVisibleContent() const; + virtual WebView* view() const; + virtual WebFrame* opener() const; + virtual WebFrame* parent() const; + virtual WebFrame* top() const; + virtual WebFrame* firstChild() const; + virtual WebFrame* lastChild() const; + virtual WebFrame* nextSibling() const; + virtual WebFrame* previousSibling() const; + virtual WebFrame* traverseNext(bool wrap) const; + virtual WebFrame* traversePrevious(bool wrap) const; + virtual WebFrame* findChildByName(const WebString&) const; + virtual WebFrame* findChildByExpression(const WebString&) const; + virtual void forms(WebVector<WebFormElement>&) const; + virtual WebSecurityOrigin securityOrigin() const; + virtual void grantUniversalAccess(); + virtual NPObject* windowObject() const; + virtual void bindToWindowObject(const WebString& name, NPObject*); + virtual void executeScript(const WebScriptSource&); + virtual void executeScriptInNewContext( + const WebScriptSource* sources, unsigned numSources, int extensionGroup); + virtual void executeScriptInIsolatedWorld( + int worldId, const WebScriptSource* sources, unsigned numSources, + int extensionGroup); + virtual void addMessageToConsole(const WebConsoleMessage&); + virtual void collectGarbage(); +#if WEBKIT_USING_V8 + virtual v8::Local<v8::Context> mainWorldScriptContext() const; +#endif + virtual bool insertStyleText(const WebString& css, const WebString& id); + virtual void reload(); + virtual void loadRequest(const WebURLRequest&); + virtual void loadHistoryItem(const WebHistoryItem&); + virtual void loadData( + const WebData&, const WebString& mimeType, const WebString& textEncoding, + const WebURL& baseURL, const WebURL& unreachableURL, bool replace); + virtual void loadHTMLString( + const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL, + bool replace); + virtual bool isLoading() const; + virtual void stopLoading(); + virtual WebDataSource* provisionalDataSource() const; + virtual WebDataSource* dataSource() const; + virtual WebHistoryItem previousHistoryItem() const; + virtual WebHistoryItem currentHistoryItem() const; + virtual void enableViewSourceMode(bool enable); + virtual bool isViewSourceModeEnabled() const; + virtual void setReferrerForRequest(WebURLRequest&, const WebURL& referrer); + virtual void dispatchWillSendRequest(WebURLRequest&); + virtual void commitDocumentData(const char* data, size_t length); + virtual unsigned unloadListenerCount() const; + virtual bool isProcessingUserGesture() const; + virtual bool willSuppressOpenerInNewFrame() const; + virtual void replaceSelection(const WebString&); + virtual void insertText(const WebString&); + virtual void setMarkedText(const WebString&, unsigned location, unsigned length); + virtual void unmarkText(); + virtual bool hasMarkedText() const; + virtual WebRange markedRange() const; + virtual bool executeCommand(const WebString&); + virtual bool executeCommand(const WebString&, const WebString& value); + virtual bool isCommandEnabled(const WebString&) const; + virtual void enableContinuousSpellChecking(bool); + virtual bool isContinuousSpellCheckingEnabled() const; + virtual bool hasSelection() const; + virtual WebRange selectionRange() const; + virtual WebString selectionAsText() const; + virtual WebString selectionAsMarkup() const; + virtual int printBegin(const WebSize& pageSize); + virtual float printPage(int pageToPrint, WebCanvas*); + virtual float getPrintPageShrink(int page); + virtual void printEnd(); + virtual bool find( + int identifier, const WebString& searchText, const WebFindOptions&, + bool wrapWithinFrame, WebRect* selectionRect); + virtual void stopFinding(bool clearSelection); + virtual void scopeStringMatches( + int identifier, const WebString& searchText, const WebFindOptions&, + bool reset); + virtual void cancelPendingScopingEffort(); + virtual void increaseMatchCount(int count, int identifier); + virtual void resetMatchCount(); + virtual void registerPasswordListener( + WebInputElement, WebPasswordAutocompleteListener*); + + virtual WebURL completeURL(const WebString& url) const; + virtual WebString contentAsText(size_t maxChars) const; + virtual WebString contentAsMarkup() const; + + static PassRefPtr<WebFrameImpl> create(WebFrameClient* client); + ~WebFrameImpl(); + + static int liveObjectCount() { return m_liveObjectCount; } + + // Called by the WebViewImpl to initialize its main frame: + void initializeAsMainFrame(WebViewImpl*); + + PassRefPtr<WebCore::Frame> createChildFrame( + const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*); + + void layout(); + void paint(WebCanvas*, const WebRect&); + void createFrameView(); + + static WebFrameImpl* fromFrame(WebCore::Frame* frame); + + WebViewImpl* viewImpl() const; + + WebCore::Frame* frame() const { return m_frame; } + WebCore::FrameView* frameView() const { return m_frame ? m_frame->view() : 0; } + + // Getters for the impls corresponding to Get(Provisional)DataSource. They + // may return 0 if there is no corresponding data source. + WebDataSourceImpl* dataSourceImpl() const; + WebDataSourceImpl* provisionalDataSourceImpl() const; + + // Returns which frame has an active match. This function should only be + // called on the main frame, as it is the only frame keeping track. Returned + // value can be 0 if no frame has an active match. + const WebFrameImpl* activeMatchFrame() const { return m_activeMatchFrame; } + + // When a Find operation ends, we want to set the selection to what was active + // and set focus to the first focusable node we find (starting with the first + // node in the matched range and going up the inheritance chain). If we find + // nothing to focus we focus the first focusable node in the range. This + // allows us to set focus to a link (when we find text inside a link), which + // allows us to navigate by pressing Enter after closing the Find box. + void setFindEndstateFocusAndSelection(); + + void didFail(const WebCore::ResourceError&, bool wasProvisional); + + // Sets whether the WebFrameImpl allows its document to be scrolled. + // If the parameter is true, allow the document to be scrolled. + // Otherwise, disallow scrolling. + void setAllowsScrolling(bool); + + // Returns the password autocomplete listener associated with the passed + // user name input element, or 0 if none available. + // Note that the returned listener is owner by the WebFrameImpl and should not + // be kept around as it is deleted when the page goes away. + WebPasswordAutocompleteListener* getPasswordListener(WebCore::HTMLInputElement*); + + WebFrameClient* client() const { return m_client; } + void dropClient() { m_client = 0; } + +private: + class DeferredScopeStringMatches; + friend class DeferredScopeStringMatches; + friend class FrameLoaderClientImpl; + + // A bit mask specifying area of the frame to invalidate. + enum AreaToInvalidate { + InvalidateNothing, + InvalidateContentArea, + InvalidateScrollbar, // Vertical scrollbar only. + InvalidateAll // Both content area and the scrollbar. + }; + + WebFrameImpl(WebFrameClient*); + + // Informs the WebFrame that the Frame is being closed, called by the + // WebFrameLoaderClient + void closing(); + + // Notifies the delegate about a new selection rect. + void reportFindInPageSelection( + const WebRect& selectionRect, int activeMatchOrdinal, int identifier); + + // Invalidates a certain area within the frame. + void invalidateArea(AreaToInvalidate); + + // Add a WebKit TextMatch-highlight marker to nodes in a range. + void addMarker(WebCore::Range*, bool activeMatch); + + // Sets the markers within a range as active or inactive. + void setMarkerActive(WebCore::Range*, bool active); + + // Returns the ordinal of the first match in the frame specified. This + // function enumerates the frames, starting with the main frame and up to (but + // not including) the frame passed in as a parameter and counts how many + // matches have been found. + int ordinalOfFirstMatchForFrame(WebFrameImpl*) const; + + // Determines whether the scoping effort is required for a particular frame. + // It is not necessary if the frame is invisible, for example, or if this + // is a repeat search that already returned nothing last time the same prefix + // was searched. + bool shouldScopeMatches(const WebCore::String& searchText); + + // Queue up a deferred call to scopeStringMatches. + void scopeStringMatchesSoon( + int identifier, const WebString& searchText, const WebFindOptions&, + bool reset); + + // Called by a DeferredScopeStringMatches instance. + void callScopeStringMatches( + DeferredScopeStringMatches*, int identifier, const WebString& searchText, + const WebFindOptions&, bool reset); + + // Determines whether to invalidate the content area and scrollbar. + void invalidateIfNecessary(); + + // Clears the map of password listeners. + void clearPasswordListeners(); + + void loadJavaScriptURL(const WebCore::KURL&); + + // Used to check for leaks of this object. + static int m_liveObjectCount; + + FrameLoaderClientImpl m_frameLoaderClient; + + WebFrameClient* m_client; + + // This is a weak pointer to our corresponding WebCore frame. A reference to + // ourselves is held while frame_ is valid. See our Closing method. + WebCore::Frame* m_frame; + + // A way for the main frame to keep track of which frame has an active + // match. Should be 0 for all other frames. + WebFrameImpl* m_activeMatchFrame; + + // The range of the active match for the current frame. + RefPtr<WebCore::Range> m_activeMatch; + + // The index of the active match. + int m_activeMatchIndex; + + // This flag is used by the scoping effort to determine if we need to figure + // out which rectangle is the active match. Once we find the active + // rectangle we clear this flag. + bool m_locatingActiveRect; + + // The scoping effort can time out and we need to keep track of where we + // ended our last search so we can continue from where we left of. + RefPtr<WebCore::Range> m_resumeScopingFromRange; + + // Keeps track of the last string this frame searched for. This is used for + // short-circuiting searches in the following scenarios: When a frame has + // been searched and returned 0 results, we don't need to search that frame + // again if the user is just adding to the search (making it more specific). + WebCore::String m_lastSearchString; + + // Keeps track of how many matches this frame has found so far, so that we + // don't loose count between scoping efforts, and is also used (in conjunction + // with m_lastSearchString and m_scopingComplete) to figure out if we need to + // search the frame again. + int m_lastMatchCount; + + // This variable keeps a cumulative total of matches found so far for ALL the + // frames on the page, and is only incremented by calling IncreaseMatchCount + // (on the main frame only). It should be -1 for all other frames. + size_t m_totalMatchCount; + + // This variable keeps a cumulative total of how many frames are currently + // scoping, and is incremented/decremented on the main frame only. + // It should be -1 for all other frames. + int m_framesScopingCount; + + // Keeps track of whether the scoping effort was completed (the user may + // interrupt it before it completes by submitting a new search). + bool m_scopingComplete; + + // Keeps track of when the scoping effort should next invalidate the scrollbar + // and the frame area. + int m_nextInvalidateAfter; + + // A list of all of the pending calls to scopeStringMatches. + Vector<DeferredScopeStringMatches*> m_deferredScopingWork; + + // Valid between calls to BeginPrint() and EndPrint(). Containts the print + // information. Is used by PrintPage(). + OwnPtr<ChromePrintContext> m_printContext; + + // The input fields that are interested in edit events and their associated + // listeners. + typedef HashMap<RefPtr<WebCore::HTMLInputElement>, + WebPasswordAutocompleteListener*> PasswordListenerMap; + PasswordListenerMap m_passwordListeners; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebHTTPBody.cpp b/WebKit/chromium/src/WebHTTPBody.cpp new file mode 100644 index 0000000..335ed5c --- /dev/null +++ b/WebKit/chromium/src/WebHTTPBody.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebHTTPBody.h" + +#include "FormData.h" + +using namespace WebCore; + +namespace WebKit { + +class WebHTTPBodyPrivate : public FormData { +}; + +void WebHTTPBody::initialize() +{ + assign(static_cast<WebHTTPBodyPrivate*>(FormData::create().releaseRef())); +} + +void WebHTTPBody::reset() +{ + assign(0); +} + +void WebHTTPBody::assign(const WebHTTPBody& other) +{ + WebHTTPBodyPrivate* p = const_cast<WebHTTPBodyPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +size_t WebHTTPBody::elementCount() const +{ + ASSERT(!isNull()); + return m_private->elements().size(); +} + +bool WebHTTPBody::elementAt(size_t index, Element& result) const +{ + ASSERT(!isNull()); + + if (index >= m_private->elements().size()) + return false; + + const FormDataElement& element = m_private->elements()[index]; + + switch (element.m_type) { + case FormDataElement::data: + result.type = Element::TypeData; + result.data.assign(element.m_data.data(), element.m_data.size()); + result.filePath.reset(); + break; + case FormDataElement::encodedFile: + result.type = Element::TypeFile; + result.data.reset(); + result.filePath = element.m_filename; + break; + default: + ASSERT_NOT_REACHED(); + return false; + } + + return true; +} + +void WebHTTPBody::appendData(const WebData& data) +{ + ensureMutable(); + // FIXME: FormDataElement::m_data should be a SharedBuffer<char>. Then we + // could avoid this buffer copy. + m_private->appendData(data.data(), data.size()); +} + +void WebHTTPBody::appendFile(const WebString& filePath) +{ + ensureMutable(); + m_private->appendFile(filePath); +} + +long long WebHTTPBody::identifier() const +{ + ASSERT(!isNull()); + return m_private->identifier(); +} + +void WebHTTPBody::setIdentifier(long long identifier) +{ + ensureMutable(); + return m_private->setIdentifier(identifier); +} + +WebHTTPBody::WebHTTPBody(const PassRefPtr<FormData>& data) + : m_private(static_cast<WebHTTPBodyPrivate*>(data.releaseRef())) +{ +} + +WebHTTPBody& WebHTTPBody::operator=(const PassRefPtr<FormData>& data) +{ + assign(static_cast<WebHTTPBodyPrivate*>(data.releaseRef())); + return *this; +} + +WebHTTPBody::operator PassRefPtr<FormData>() const +{ + return m_private; +} + +void WebHTTPBody::assign(WebHTTPBodyPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +void WebHTTPBody::ensureMutable() +{ + ASSERT(!isNull()); + if (!m_private->hasOneRef()) + assign(static_cast<WebHTTPBodyPrivate*>(m_private->copy().releaseRef())); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebHistoryItem.cpp b/WebKit/chromium/src/WebHistoryItem.cpp new file mode 100644 index 0000000..d4ee50a --- /dev/null +++ b/WebKit/chromium/src/WebHistoryItem.cpp @@ -0,0 +1,296 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebHistoryItem.h" + +#include "FormData.h" +#include "HistoryItem.h" +#include "KURL.h" + +#include "WebHTTPBody.h" +#include "WebPoint.h" +#include "WebString.h" +#include "WebVector.h" + +using namespace WebCore; + +namespace WebKit { + +class WebHistoryItemPrivate : public HistoryItem { +}; + +void WebHistoryItem::initialize() +{ + assign(static_cast<WebHistoryItemPrivate*>(HistoryItem::create().releaseRef())); +} + +void WebHistoryItem::reset() +{ + assign(0); +} + +void WebHistoryItem::assign(const WebHistoryItem& other) +{ + WebHistoryItemPrivate* p = const_cast<WebHistoryItemPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +WebString WebHistoryItem::urlString() const +{ + ASSERT(!isNull()); + return m_private->urlString(); +} + +void WebHistoryItem::setURLString(const WebString& url) +{ + ensureMutable(); + m_private->setURLString(KURL(ParsedURLString, url).string()); +} + +WebString WebHistoryItem::originalURLString() const +{ + ASSERT(!isNull()); + return m_private->originalURLString(); +} + +void WebHistoryItem::setOriginalURLString(const WebString& originalURLString) +{ + ensureMutable(); + m_private->setOriginalURLString(originalURLString); +} + +WebString WebHistoryItem::referrer() const +{ + ASSERT(!isNull()); + return m_private->referrer(); +} + +void WebHistoryItem::setReferrer(const WebString& referrer) +{ + ensureMutable(); + m_private->setReferrer(referrer); +} + +WebString WebHistoryItem::target() const +{ + ASSERT(!isNull()); + return m_private->target(); +} + +void WebHistoryItem::setTarget(const WebString& target) +{ + ensureMutable(); + m_private->setTarget(target); +} + +WebString WebHistoryItem::parent() const +{ + ASSERT(!isNull()); + return m_private->parent(); +} + +void WebHistoryItem::setParent(const WebString& parent) +{ + ensureMutable(); + m_private->setParent(parent); +} + +WebString WebHistoryItem::title() const +{ + ASSERT(!isNull()); + return m_private->title(); +} + +void WebHistoryItem::setTitle(const WebString& title) +{ + ensureMutable(); + m_private->setTitle(title); +} + +WebString WebHistoryItem::alternateTitle() const +{ + ASSERT(!isNull()); + return m_private->alternateTitle(); +} + +void WebHistoryItem::setAlternateTitle(const WebString& alternateTitle) +{ + ensureMutable(); + m_private->setAlternateTitle(alternateTitle); +} + +double WebHistoryItem::lastVisitedTime() const +{ + ASSERT(!isNull()); + return m_private->lastVisitedTime(); +} + +void WebHistoryItem::setLastVisitedTime(double lastVisitedTime) +{ + ensureMutable(); + // FIXME: setLastVisitedTime increments the visit count, so we have to + // correct for that. Instead, we should have a back-door to just mutate + // the last visited time directly. + int count = m_private->visitCount(); + m_private->setLastVisitedTime(lastVisitedTime); + m_private->setVisitCount(count); +} + +WebPoint WebHistoryItem::scrollOffset() const +{ + ASSERT(!isNull()); + return m_private->scrollPoint(); +} + +void WebHistoryItem::setScrollOffset(const WebPoint& scrollOffset) +{ + ensureMutable(); + m_private->setScrollPoint(scrollOffset); +} + +bool WebHistoryItem::isTargetItem() const +{ + ASSERT(!isNull()); + return m_private->isTargetItem(); +} + +void WebHistoryItem::setIsTargetItem(bool isTargetItem) +{ + ensureMutable(); + m_private->setIsTargetItem(isTargetItem); +} + +int WebHistoryItem::visitCount() const +{ + ASSERT(!isNull()); + return m_private->visitCount(); +} + +void WebHistoryItem::setVisitCount(int count) +{ + ensureMutable(); + m_private->setVisitCount(count); +} + +WebVector<WebString> WebHistoryItem::documentState() const +{ + ASSERT(!isNull()); + return m_private->documentState(); +} + +void WebHistoryItem::setDocumentState(const WebVector<WebString>& state) +{ + ensureMutable(); + // FIXME: would be nice to avoid the intermediate copy + Vector<String> ds; + for (size_t i = 0; i < state.size(); ++i) + ds.append(state[i]); + m_private->setDocumentState(ds); +} + +WebString WebHistoryItem::httpContentType() const +{ + ASSERT(!isNull()); + return m_private->formContentType(); +} + +void WebHistoryItem::setHTTPContentType(const WebString& httpContentType) +{ + ensureMutable(); + m_private->setFormContentType(httpContentType); +} + +WebHTTPBody WebHistoryItem::httpBody() const +{ + ASSERT(!isNull()); + return WebHTTPBody(m_private->formData()); +} + +void WebHistoryItem::setHTTPBody(const WebHTTPBody& httpBody) +{ + ensureMutable(); + m_private->setFormData(httpBody); +} + +WebVector<WebHistoryItem> WebHistoryItem::children() const +{ + ASSERT(!isNull()); + return m_private->children(); +} + +void WebHistoryItem::setChildren(const WebVector<WebHistoryItem>& items) +{ + ensureMutable(); + m_private->clearChildren(); + for (size_t i = 0; i < items.size(); ++i) + m_private->addChildItem(items[i]); +} + +void WebHistoryItem::appendToChildren(const WebHistoryItem& item) +{ + ensureMutable(); + m_private->addChildItem(item); +} + +WebHistoryItem::WebHistoryItem(const PassRefPtr<HistoryItem>& item) + : m_private(static_cast<WebHistoryItemPrivate*>(item.releaseRef())) +{ +} + +WebHistoryItem& WebHistoryItem::operator=(const PassRefPtr<HistoryItem>& item) +{ + assign(static_cast<WebHistoryItemPrivate*>(item.releaseRef())); + return *this; +} + +WebHistoryItem::operator PassRefPtr<HistoryItem>() const +{ + return m_private; +} + +void WebHistoryItem::assign(WebHistoryItemPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +void WebHistoryItem::ensureMutable() +{ + ASSERT(!isNull()); + if (!m_private->hasOneRef()) + assign(static_cast<WebHistoryItemPrivate*>(m_private->copy().releaseRef())); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebImageCG.cpp b/WebKit/chromium/src/WebImageCG.cpp new file mode 100644 index 0000000..60b2449 --- /dev/null +++ b/WebKit/chromium/src/WebImageCG.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebImage.h" + +#include "Image.h" +#include "ImageSource.h" +#include "SharedBuffer.h" + +#include "WebData.h" +#include "WebSize.h" + +#include <CoreGraphics/CGImage.h> + +#include <wtf/PassRefPtr.h> +#include <wtf/RetainPtr.h> + +using namespace WebCore; + +namespace WebKit { + +WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize) +{ + // FIXME: Do something like what WebImageSkia.cpp does to enumerate frames. + // Not sure whether the CG decoder uses the same frame ordering rules (if so + // we can just use the same logic). + + ImageSource source; + source.setData(PassRefPtr<SharedBuffer>(data).get(), true); + if (!source.isSizeAvailable()) + return WebImage(); + + RetainPtr<CGImageRef> frame0(AdoptCF, source.createFrameAtIndex(0)); + if (!frame0) + return WebImage(); + + return WebImage(frame0.get()); +} + +void WebImage::reset() +{ + CGImageRelease(m_imageRef); + m_imageRef = 0; +} + +void WebImage::assign(const WebImage& image) +{ + assign(image.m_imageRef); +} + +bool WebImage::isNull() const +{ + return !m_imageRef; +} + +WebSize WebImage::size() const +{ + return WebSize(CGImageGetWidth(m_imageRef), CGImageGetHeight(m_imageRef)); +} + +WebImage::WebImage(const PassRefPtr<Image>& image) + : m_imageRef(0) +{ + if (image.get()) + assign(image->nativeImageForCurrentFrame()); +} + +WebImage& WebImage::operator=(const PassRefPtr<Image>& image) +{ + if (image.get()) + assign(image->nativeImageForCurrentFrame()); + else + reset(); + return *this; +} + +void WebImage::assign(CGImageRef imageRef) +{ + // Make sure to retain the imageRef first incase m_imageRef == imageRef. + CGImageRetain(imageRef); + CGImageRelease(m_imageRef); + m_imageRef = imageRef; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebImageSkia.cpp b/WebKit/chromium/src/WebImageSkia.cpp new file mode 100644 index 0000000..0684b58 --- /dev/null +++ b/WebKit/chromium/src/WebImageSkia.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebImage.h" + +#include "Image.h" +#include "ImageSource.h" +#include "NativeImageSkia.h" +#include "SharedBuffer.h" + +#include "WebData.h" +#include "WebSize.h" + +#include <wtf/OwnPtr.h> +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize) +{ + ImageSource source; + source.setData(PassRefPtr<SharedBuffer>(data).get(), true); + if (!source.isSizeAvailable()) + return WebImage(); + + // Frames are arranged by decreasing size, then decreasing bit depth. + // Pick the frame closest to |desiredSize|'s area without being smaller, + // which has the highest bit depth. + const size_t frameCount = source.frameCount(); + size_t index = 0; // Default to first frame if none are large enough. + int frameAreaAtIndex = 0; + for (size_t i = 0; i < frameCount; ++i) { + const IntSize frameSize = source.frameSizeAtIndex(i); + if (WebSize(frameSize) == desiredSize) { + index = i; + break; // Perfect match. + } + + const int frameArea = frameSize.width() * frameSize.height(); + if (frameArea < (desiredSize.width * desiredSize.height)) + break; // No more frames that are large enough. + + if (!i || (frameArea < frameAreaAtIndex)) { + index = i; // Closer to desired area than previous best match. + frameAreaAtIndex = frameArea; + } + } + + OwnPtr<NativeImageSkia> frame(source.createFrameAtIndex(index)); + if (!frame.get()) + return WebImage(); + + return WebImage(*frame); +} + +void WebImage::reset() +{ + m_bitmap.reset(); +} + +void WebImage::assign(const WebImage& image) +{ + m_bitmap = image.m_bitmap; +} + +bool WebImage::isNull() const +{ + return m_bitmap.isNull(); +} + +WebSize WebImage::size() const +{ + return WebSize(m_bitmap.width(), m_bitmap.height()); +} + +WebImage::WebImage(const PassRefPtr<Image>& image) +{ + operator=(image); +} + +WebImage& WebImage::operator=(const PassRefPtr<Image>& image) +{ + NativeImagePtr p; + if (image.get() && (p = image->nativeImageForCurrentFrame())) + assign(*p); + else + reset(); + return *this; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebInputElement.cpp b/WebKit/chromium/src/WebInputElement.cpp new file mode 100644 index 0000000..d403120 --- /dev/null +++ b/WebKit/chromium/src/WebInputElement.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebInputElement.h" + +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "WebString.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +WebInputElement::WebInputElement(const WTF::PassRefPtr<HTMLInputElement>& elem) + : WebElement(elem.releaseRef()) +{ +} + +WebInputElement& WebInputElement::operator=(const WTF::PassRefPtr<HTMLInputElement>& elem) +{ + WebNode::assign(elem.releaseRef()); + return *this; +} + +WebInputElement::operator WTF::PassRefPtr<HTMLInputElement>() const +{ + return PassRefPtr<HTMLInputElement>(static_cast<HTMLInputElement*>(m_private)); +} + +bool WebInputElement::isEnabledFormControl() const +{ + return constUnwrap<HTMLInputElement>()->isEnabledFormControl(); +} + +WebInputElement::InputType WebInputElement::inputType() const +{ + return static_cast<InputType>(constUnwrap<HTMLInputElement>()->inputType()); +} + +WebString WebInputElement::formControlType() const +{ + return constUnwrap<HTMLInputElement>()->formControlType(); +} + +void WebInputElement::setActivatedSubmit(bool activated) +{ + unwrap<HTMLInputElement>()->setActivatedSubmit(activated); +} + +void WebInputElement::setValue(const WebString& value) +{ + unwrap<HTMLInputElement>()->setValue(value); +} + +WebString WebInputElement::value() const +{ + return constUnwrap<HTMLInputElement>()->value(); +} + +void WebInputElement::setAutofilled(bool autoFilled) +{ + unwrap<HTMLInputElement>()->setAutofilled(autoFilled); +} + +void WebInputElement::dispatchFormControlChangeEvent() +{ + unwrap<HTMLInputElement>()->dispatchFormControlChangeEvent(); +} + +void WebInputElement::setSelectionRange(int start, int end) +{ + unwrap<HTMLInputElement>()->setSelectionRange(start, end); +} + +WebString WebInputElement::name() const +{ + return constUnwrap<HTMLInputElement>()->name(); +} + +WebString WebInputElement::nameForAutofill() const +{ + String name = constUnwrap<HTMLInputElement>()->name(); + String trimmedName = name.stripWhiteSpace(); + if (!trimmedName.isEmpty()) + return trimmedName; + name = constUnwrap<HTMLInputElement>()->getAttribute(HTMLNames::idAttr); + trimmedName = name.stripWhiteSpace(); + if (!trimmedName.isEmpty()) + return trimmedName; + return String(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebInputEvent.cpp b/WebKit/chromium/src/WebInputEvent.cpp new file mode 100644 index 0000000..b5c56fa --- /dev/null +++ b/WebKit/chromium/src/WebInputEvent.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebInputEvent.h" + +#include "KeyboardCodes.h" + +#include <ctype.h> +#include <stdio.h> + +#include <wtf/Assertions.h> +#include <wtf/StringExtras.h> + +using namespace WebCore; + +namespace WebKit { + +static const char* staticKeyIdentifiers(unsigned short keyCode) +{ + switch (keyCode) { + case VKEY_MENU: + return "Alt"; + case VKEY_CONTROL: + return "Control"; + case VKEY_SHIFT: + return "Shift"; + case VKEY_CAPITAL: + return "CapsLock"; + case VKEY_LWIN: + case VKEY_RWIN: + return "Win"; + case VKEY_CLEAR: + return "Clear"; + case VKEY_DOWN: + return "Down"; + case VKEY_END: + return "End"; + case VKEY_RETURN: + return "Enter"; + case VKEY_EXECUTE: + return "Execute"; + case VKEY_F1: + return "F1"; + case VKEY_F2: + return "F2"; + case VKEY_F3: + return "F3"; + case VKEY_F4: + return "F4"; + case VKEY_F5: + return "F5"; + case VKEY_F6: + return "F6"; + case VKEY_F7: + return "F7"; + case VKEY_F8: + return "F8"; + case VKEY_F9: + return "F9"; + case VKEY_F10: + return "F11"; + case VKEY_F12: + return "F12"; + case VKEY_F13: + return "F13"; + case VKEY_F14: + return "F14"; + case VKEY_F15: + return "F15"; + case VKEY_F16: + return "F16"; + case VKEY_F17: + return "F17"; + case VKEY_F18: + return "F18"; + case VKEY_F19: + return "F19"; + case VKEY_F20: + return "F20"; + case VKEY_F21: + return "F21"; + case VKEY_F22: + return "F22"; + case VKEY_F23: + return "F23"; + case VKEY_F24: + return "F24"; + case VKEY_HELP: + return "Help"; + case VKEY_HOME: + return "Home"; + case VKEY_INSERT: + return "Insert"; + case VKEY_LEFT: + return "Left"; + case VKEY_NEXT: + return "PageDown"; + case VKEY_PRIOR: + return "PageUp"; + case VKEY_PAUSE: + return "Pause"; + case VKEY_SNAPSHOT: + return "PrintScreen"; + case VKEY_RIGHT: + return "Right"; + case VKEY_SCROLL: + return "Scroll"; + case VKEY_SELECT: + return "Select"; + case VKEY_UP: + return "Up"; + case VKEY_DELETE: + return "U+007F"; // Standard says that DEL becomes U+007F. + default: + return 0; + } +} + +void WebKeyboardEvent::setKeyIdentifierFromWindowsKeyCode() +{ + const char* id = staticKeyIdentifiers(windowsKeyCode); + if (id) { + strncpy(keyIdentifier, id, sizeof(keyIdentifier) - 1); + keyIdentifier[sizeof(keyIdentifier) - 1] = '\0'; + } else + snprintf(keyIdentifier, sizeof(keyIdentifier), "U+%04X", toupper(windowsKeyCode)); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebInputEventConversion.cpp b/WebKit/chromium/src/WebInputEventConversion.cpp new file mode 100644 index 0000000..147f88b --- /dev/null +++ b/WebKit/chromium/src/WebInputEventConversion.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebInputEventConversion.h" + +#include "EventNames.h" +#include "KeyboardCodes.h" +#include "KeyboardEvent.h" +#include "MouseEvent.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformMouseEvent.h" +#include "PlatformWheelEvent.h" +#include "ScrollView.h" +#include "WebInputEvent.h" +#include "Widget.h" + +using namespace WebCore; + +namespace WebKit { + +// MakePlatformMouseEvent ----------------------------------------------------- + +PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e) +{ + // FIXME: widget is always toplevel, unless it's a popup. We may be able + // to get rid of this once we abstract popups into a WebKit API. + m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); + m_globalPosition = IntPoint(e.globalX, e.globalY); + m_button = static_cast<MouseButton>(e.button); + m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey); + m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey); + m_altKey = (e.modifiers & WebInputEvent::AltKey); + m_metaKey = (e.modifiers & WebInputEvent::MetaKey); + m_modifierFlags = e.modifiers; + m_timestamp = e.timeStampSeconds; + m_clickCount = e.clickCount; + + switch (e.type) { + case WebInputEvent::MouseMove: + case WebInputEvent::MouseLeave: // synthesize a move event + m_eventType = MouseEventMoved; + break; + + case WebInputEvent::MouseDown: + m_eventType = MouseEventPressed; + break; + + case WebInputEvent::MouseUp: + m_eventType = MouseEventReleased; + break; + + default: + ASSERT_NOT_REACHED(); + } +} + +// PlatformWheelEventBuilder -------------------------------------------------- + +PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e) +{ + m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); + m_globalPosition = IntPoint(e.globalX, e.globalY); + m_deltaX = e.deltaX; + m_deltaY = e.deltaY; + m_wheelTicksX = e.wheelTicksX; + m_wheelTicksY = e.wheelTicksY; + m_isAccepted = false; + m_granularity = e.scrollByPage ? + ScrollByPageWheelEvent : ScrollByPixelWheelEvent; + m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey); + m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey); + m_altKey = (e.modifiers & WebInputEvent::AltKey); + m_metaKey = (e.modifiers & WebInputEvent::MetaKey); +} + +// MakePlatformKeyboardEvent -------------------------------------------------- + +static inline const PlatformKeyboardEvent::Type toPlatformKeyboardEventType(WebInputEvent::Type type) +{ + switch (type) { + case WebInputEvent::KeyUp: + return PlatformKeyboardEvent::KeyUp; + case WebInputEvent::KeyDown: + return PlatformKeyboardEvent::KeyDown; + case WebInputEvent::RawKeyDown: + return PlatformKeyboardEvent::RawKeyDown; + case WebInputEvent::Char: + return PlatformKeyboardEvent::Char; + default: + ASSERT_NOT_REACHED(); + } + return PlatformKeyboardEvent::KeyDown; +} + +PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEvent& e) +{ + m_type = toPlatformKeyboardEventType(e.type); + m_text = String(e.text); + m_unmodifiedText = String(e.unmodifiedText); + m_keyIdentifier = String(e.keyIdentifier); + m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat); + m_windowsVirtualKeyCode = e.windowsKeyCode; + m_nativeVirtualKeyCode = e.nativeKeyCode; + m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad); + m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey); + m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey); + m_altKey = (e.modifiers & WebInputEvent::AltKey); + m_metaKey = (e.modifiers & WebInputEvent::MetaKey); + m_isSystemKey = e.isSystemKey; +} + +void PlatformKeyboardEventBuilder::setKeyType(Type type) +{ + // According to the behavior of Webkit in Windows platform, + // we need to convert KeyDown to RawKeydown and Char events + // See WebKit/WebKit/Win/WebView.cpp + ASSERT(m_type == KeyDown); + ASSERT(type == RawKeyDown || type == Char); + m_type = type; + + if (type == RawKeyDown) { + m_text = String(); + m_unmodifiedText = String(); + } else { + m_keyIdentifier = String(); + m_windowsVirtualKeyCode = 0; + } +} + +// Please refer to bug http://b/issue?id=961192, which talks about Webkit +// keyboard event handling changes. It also mentions the list of keys +// which don't have associated character events. +bool PlatformKeyboardEventBuilder::isCharacterKey() const +{ + switch (windowsVirtualKeyCode()) { + case VKEY_BACK: + case VKEY_ESCAPE: + return false; + } + return true; +} + +static int getWebInputModifiers(const UIEventWithKeyState& event) +{ + int modifiers = 0; + if (event.ctrlKey()) + modifiers |= WebInputEvent::ControlKey; + if (event.shiftKey()) + modifiers |= WebInputEvent::ShiftKey; + if (event.altKey()) + modifiers |= WebInputEvent::AltKey; + if (event.metaKey()) + modifiers |= WebInputEvent::MetaKey; + return modifiers; +} + +WebMouseEventBuilder::WebMouseEventBuilder(const ScrollView* view, const MouseEvent& event) +{ + if (event.type() == eventNames().mousemoveEvent) + type = WebInputEvent::MouseMove; + else if (event.type() == eventNames().mouseoutEvent) + type = WebInputEvent::MouseLeave; + else if (event.type() == eventNames().mouseoverEvent) + type = WebInputEvent::MouseEnter; + else if (event.type() == eventNames().mousedownEvent) + type = WebInputEvent::MouseDown; + else if (event.type() == eventNames().mouseupEvent) + type = WebInputEvent::MouseUp; + else + return; // Skip all other mouse events. + timeStampSeconds = event.timeStamp() * 1.0e-3; + switch (event.button()) { + case LeftButton: + button = WebMouseEvent::ButtonLeft; + break; + case MiddleButton: + button = WebMouseEvent::ButtonMiddle; + break; + case RightButton: + button = WebMouseEvent::ButtonRight; + break; + } + modifiers = getWebInputModifiers(event); + if (event.buttonDown()) { + switch (event.button()) { + case LeftButton: + modifiers |= WebInputEvent::LeftButtonDown; + break; + case MiddleButton: + modifiers |= WebInputEvent::MiddleButtonDown; + break; + case RightButton: + modifiers |= WebInputEvent::RightButtonDown; + break; + } + } + IntPoint p = view->contentsToWindow(IntPoint(event.pageX(), event.pageY())); + globalX = event.screenX(); + globalY = event.screenY(); + windowX = p.x(); + windowY = p.y(); + x = event.offsetX(); + y = event.offsetY(); + clickCount = event.detail(); +} + +WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) +{ + if (event.type() == eventNames().keydownEvent) + type = KeyDown; + else if (event.type() == eventNames().keyupEvent) + type = WebInputEvent::KeyUp; + else if (event.type() == eventNames().keypressEvent) + type = WebInputEvent::Char; + else + return; // Skip all other keyboard events. + modifiers = getWebInputModifiers(event); + timeStampSeconds = event.timeStamp() * 1.0e-3; + windowsKeyCode = event.keyCode(); + nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); + unsigned int numChars = std::min(event.keyEvent()->text().length(), + static_cast<unsigned int>(WebKeyboardEvent::textLengthCap)); + for (unsigned int i = 0; i < numChars; i++) { + text[i] = event.keyEvent()->text()[i]; + unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; + } +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebInputEventConversion.h b/WebKit/chromium/src/WebInputEventConversion.h new file mode 100644 index 0000000..4c9cf82 --- /dev/null +++ b/WebKit/chromium/src/WebInputEventConversion.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebInputEventConversion_h +#define WebInputEventConversion_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebInputEvent.h" + +#include "PlatformKeyboardEvent.h" +#include "PlatformMouseEvent.h" +#include "PlatformWheelEvent.h" + +namespace WebCore { +class KeyboardEvent; +class MouseEvent; +class ScrollView; +class Widget; +} + +namespace WebKit { + +class WebMouseEvent; +class WebMouseWheelEvent; +class WebKeyboardEvent; + +// These classes are used to convert from WebInputEvent subclasses to +// corresponding WebCore events. + +class PlatformMouseEventBuilder : public WebCore::PlatformMouseEvent { +public: + PlatformMouseEventBuilder(WebCore::Widget*, const WebMouseEvent&); +}; + +class PlatformWheelEventBuilder : public WebCore::PlatformWheelEvent { +public: + PlatformWheelEventBuilder(WebCore::Widget*, const WebMouseWheelEvent&); +}; + +class PlatformKeyboardEventBuilder : public WebCore::PlatformKeyboardEvent { +public: + PlatformKeyboardEventBuilder(const WebKeyboardEvent&); + void setKeyType(Type); + bool isCharacterKey() const; +}; + +// Converts a WebCore::MouseEvent to a corresponding WebMouseEvent. view is +// the ScrollView corresponding to the event. Returns true if successful. +// NOTE: This is only implemented for mousemove, mouseover, mouseout, +// mousedown and mouseup. If the event mapping fails, the event type will +// be set to Undefined. +class WebMouseEventBuilder : public WebMouseEvent { +public: + WebMouseEventBuilder(const WebCore::ScrollView*, const WebCore::MouseEvent&); +}; + +// Converts a WebCore::KeyboardEvent to a corresponding WebKeyboardEvent. +// Returns true if successful. NOTE: This is only implemented for keydown +// and keyup. If the event mapping fails, the event type will be set to +// Undefined. +class WebKeyboardEventBuilder : public WebKeyboardEvent { +public: + WebKeyboardEventBuilder(const WebCore::KeyboardEvent&); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebKit.cpp b/WebKit/chromium/src/WebKit.cpp new file mode 100644 index 0000000..a129f85 --- /dev/null +++ b/WebKit/chromium/src/WebKit.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebKit.h" + +#include "AtomicString.h" +#include "DOMTimer.h" +#include "Page.h" +#include "RuntimeEnabledFeatures.h" +#include "TextEncoding.h" +#include "WebMediaPlayerClientImpl.h" +#include "WebSocket.h" +#include "WorkerContextExecutionProxy.h" + +#include <wtf/Assertions.h> +#include <wtf/Threading.h> + +namespace WebKit { + +static WebKitClient* s_webKitClient = 0; +static bool s_layoutTestMode = false; + +void initialize(WebKitClient* webKitClient) +{ + ASSERT(webKitClient); + ASSERT(!s_webKitClient); + s_webKitClient = webKitClient; + + WTF::initializeThreading(); + WebCore::AtomicString::init(); + + // Chromium sets the minimum interval timeout to 4ms, overriding the + // default of 10ms. We'd like to go lower, however there are poorly + // coded websites out there which do create CPU-spinning loops. Using + // 4ms prevents the CPU from spinning too busily and provides a balance + // between CPU spinning and the smallest possible interval timer. + WebCore::DOMTimer::setMinTimerInterval(0.004); + + // There are some code paths (for example, running WebKit in the browser + // process and calling into LocalStorage before anything else) where the + // UTF8 string encoding tables are used on a background thread before + // they're set up. This is a problem because their set up routines assert + // they're running on the main WebKitThread. It might be possible to make + // the initialization thread-safe, but given that so many code paths use + // this, initializing this lazily probably doesn't buy us much. + WebCore::UTF8Encoding(); +} + +void shutdown() +{ + s_webKitClient = 0; +} + +WebKitClient* webKitClient() +{ + return s_webKitClient; +} + +void setLayoutTestMode(bool value) +{ + s_layoutTestMode = value; +} + +bool layoutTestMode() +{ + return s_layoutTestMode; +} + +void resetPluginCache(bool reloadPages) +{ + WebCore::Page::refreshPlugins(reloadPages); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp new file mode 100644 index 0000000..c2a3535 --- /dev/null +++ b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp @@ -0,0 +1,397 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "WebMediaPlayerClientImpl.h" + +#if ENABLE(VIDEO) + +#include "CString.h" +#include "Frame.h" +#include "GraphicsContext.h" +#include "HTMLMediaElement.h" +#include "IntSize.h" +#include "KURL.h" +#include "MediaPlayer.h" +#include "NotImplemented.h" +#include "TimeRanges.h" + +#include "WebCanvas.h" +#include "WebCString.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebMediaPlayer.h" +#include "WebMimeRegistry.h" +#include "WebRect.h" +#include "WebSize.h" +#include "WebString.h" +#include "WebURL.h" + +// WebCommon.h defines WEBKIT_USING_SKIA so this has to be included last. +#if WEBKIT_USING_SKIA +#include "PlatformContextSkia.h" +#endif + +#include <wtf/Assertions.h> + +using namespace WebCore; + +namespace WebKit { + +static WebMediaPlayer* createWebMediaPlayer( + WebMediaPlayerClient* client, Frame* frame) +{ + WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); + if (!webFrame->client()) + return 0; + return webFrame->client()->createMediaPlayer(webFrame, client); +} + +bool WebMediaPlayerClientImpl::m_isEnabled = false; + +bool WebMediaPlayerClientImpl::isEnabled() +{ + return m_isEnabled; +} + +void WebMediaPlayerClientImpl::setIsEnabled(bool isEnabled) +{ + m_isEnabled = isEnabled; +} + +void WebMediaPlayerClientImpl::registerSelf(MediaEngineRegistrar registrar) +{ + if (m_isEnabled) { + registrar(WebMediaPlayerClientImpl::create, + WebMediaPlayerClientImpl::getSupportedTypes, + WebMediaPlayerClientImpl::supportsType); + } +} + +// WebMediaPlayerClient -------------------------------------------------------- + +void WebMediaPlayerClientImpl::networkStateChanged() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->networkStateChanged(); +} + +void WebMediaPlayerClientImpl::readyStateChanged() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->readyStateChanged(); +} + +void WebMediaPlayerClientImpl::volumeChanged() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->volumeChanged(); +} + +void WebMediaPlayerClientImpl::timeChanged() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->timeChanged(); +} + +void WebMediaPlayerClientImpl::repaint() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->repaint(); +} + +void WebMediaPlayerClientImpl::durationChanged() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->durationChanged(); +} + +void WebMediaPlayerClientImpl::rateChanged() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->rateChanged(); +} + +void WebMediaPlayerClientImpl::sizeChanged() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->sizeChanged(); +} + +void WebMediaPlayerClientImpl::sawUnsupportedTracks() +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->mediaPlayerClient()->mediaPlayerSawUnsupportedTracks(m_mediaPlayer); +} + +// MediaPlayerPrivateInterface ------------------------------------------------- + +void WebMediaPlayerClientImpl::load(const String& url) +{ + Frame* frame = static_cast<HTMLMediaElement*>( + m_mediaPlayer->mediaPlayerClient())->document()->frame(); + m_webMediaPlayer.set(createWebMediaPlayer(this, frame)); + if (m_webMediaPlayer.get()) + m_webMediaPlayer->load(KURL(ParsedURLString, url)); +} + +void WebMediaPlayerClientImpl::cancelLoad() +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->cancelLoad(); +} + +void WebMediaPlayerClientImpl::play() +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->play(); +} + +void WebMediaPlayerClientImpl::pause() +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->pause(); +} + +IntSize WebMediaPlayerClientImpl::naturalSize() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->naturalSize(); + return IntSize(); +} + +bool WebMediaPlayerClientImpl::hasVideo() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->hasVideo(); + return false; +} + +bool WebMediaPlayerClientImpl::hasAudio() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->hasAudio(); + return false; +} + +void WebMediaPlayerClientImpl::setVisible(bool visible) +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->setVisible(visible); +} + +float WebMediaPlayerClientImpl::duration() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->duration(); + return 0.0f; +} + +float WebMediaPlayerClientImpl::currentTime() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->currentTime(); + return 0.0f; +} + +void WebMediaPlayerClientImpl::seek(float time) +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->seek(time); +} + +bool WebMediaPlayerClientImpl::seeking() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->seeking(); + return false; +} + +void WebMediaPlayerClientImpl::setEndTime(float time) +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->setEndTime(time); +} + +void WebMediaPlayerClientImpl::setRate(float rate) +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->setRate(rate); +} + +bool WebMediaPlayerClientImpl::paused() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->paused(); + return false; +} + +bool WebMediaPlayerClientImpl::supportsFullscreen() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->supportsFullscreen(); + return false; +} + +bool WebMediaPlayerClientImpl::supportsSave() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->supportsSave(); + return false; +} + +void WebMediaPlayerClientImpl::setVolume(float volume) +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->setVolume(volume); +} + +MediaPlayer::NetworkState WebMediaPlayerClientImpl::networkState() const +{ + if (m_webMediaPlayer.get()) + return static_cast<MediaPlayer::NetworkState>(m_webMediaPlayer->networkState()); + return MediaPlayer::Empty; +} + +MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const +{ + if (m_webMediaPlayer.get()) + return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState()); + return MediaPlayer::HaveNothing; +} + +float WebMediaPlayerClientImpl::maxTimeSeekable() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->maxTimeSeekable(); + return 0.0f; +} + +PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::buffered() const +{ + if (m_webMediaPlayer.get()) { + const WebTimeRanges& webRanges = m_webMediaPlayer->buffered(); + + // FIXME: Save the time ranges in a member variable and update it when needed. + RefPtr<TimeRanges> ranges = TimeRanges::create(); + for (size_t i = 0; i < webRanges.size(); ++i) + ranges->add(webRanges[i].start, webRanges[i].end); + return ranges.release(); + } + return TimeRanges::create(); +} + +int WebMediaPlayerClientImpl::dataRate() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->dataRate(); + return 0; +} + +bool WebMediaPlayerClientImpl::totalBytesKnown() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->totalBytesKnown(); + return false; +} + +unsigned WebMediaPlayerClientImpl::totalBytes() const +{ + if (m_webMediaPlayer.get()) + return static_cast<unsigned>(m_webMediaPlayer->totalBytes()); + return 0; +} + +unsigned WebMediaPlayerClientImpl::bytesLoaded() const +{ + if (m_webMediaPlayer.get()) + return static_cast<unsigned>(m_webMediaPlayer->bytesLoaded()); + return 0; +} + +void WebMediaPlayerClientImpl::setSize(const IntSize& size) +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->setSize(WebSize(size.width(), size.height())); +} + +void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& rect) +{ + // Normally GraphicsContext operations do nothing when painting is disabled. + // Since we're accessing platformContext() directly we have to manually + // check. + if (m_webMediaPlayer.get() && !context->paintingDisabled()) { +#if WEBKIT_USING_SKIA + m_webMediaPlayer->paint(context->platformContext()->canvas(), rect); +#elif WEBKIT_USING_CG + m_webMediaPlayer->paint(context->platformContext(), rect); +#else + notImplemented(); +#endif + } +} + +void WebMediaPlayerClientImpl::setAutobuffer(bool autoBuffer) +{ + if (m_webMediaPlayer.get()) + m_webMediaPlayer->setAutoBuffer(autoBuffer); +} + +bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const +{ + if (m_webMediaPlayer.get()) + return m_webMediaPlayer->hasSingleSecurityOrigin(); + return false; +} + +MediaPlayer::MovieLoadType WebMediaPlayerClientImpl::movieLoadType() const +{ + if (m_webMediaPlayer.get()) + return static_cast<MediaPlayer::MovieLoadType>( + m_webMediaPlayer->movieLoadType()); + return MediaPlayer::Unknown; +} + +MediaPlayerPrivateInterface* WebMediaPlayerClientImpl::create(MediaPlayer* player) +{ + WebMediaPlayerClientImpl* client = new WebMediaPlayerClientImpl(); + client->m_mediaPlayer = player; + return client; +} + +void WebMediaPlayerClientImpl::getSupportedTypes(HashSet<String>& supportedTypes) +{ + // FIXME: integrate this list with WebMediaPlayerClientImpl::supportsType. + notImplemented(); +} + +MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType(const String& type, + const String& codecs) +{ + WebMimeRegistry::SupportsType supportsType = + webKitClient()->mimeRegistry()->supportsMediaMIMEType(type, codecs); + + switch (supportsType) { + default: + ASSERT_NOT_REACHED(); + case WebMimeRegistry::IsNotSupported: + return MediaPlayer::IsNotSupported; + case WebMimeRegistry::IsSupported: + return MediaPlayer::IsSupported; + case WebMimeRegistry::MayBeSupported: + return MediaPlayer::MayBeSupported; + } + return MediaPlayer::IsNotSupported; +} + +WebMediaPlayerClientImpl::WebMediaPlayerClientImpl() + : m_mediaPlayer(0) +{ +} + +} // namespace WebKit + +#endif // ENABLE(VIDEO) diff --git a/WebKit/chromium/src/WebMediaPlayerClientImpl.h b/WebKit/chromium/src/WebMediaPlayerClientImpl.h new file mode 100644 index 0000000..7f087d0 --- /dev/null +++ b/WebKit/chromium/src/WebMediaPlayerClientImpl.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebMediaPlayerClientImpl_h +#define WebMediaPlayerClientImpl_h + +#if ENABLE(VIDEO) + +#include "MediaPlayerPrivate.h" +#include "WebMediaPlayerClient.h" +#include <wtf/OwnPtr.h> + +namespace WebKit { + +class WebMediaPlayer; + +// This class serves as a bridge between WebCore::MediaPlayer and +// WebKit::WebMediaPlayer. +class WebMediaPlayerClientImpl : public WebMediaPlayerClient + , public WebCore::MediaPlayerPrivateInterface { +public: + static bool isEnabled(); + static void setIsEnabled(bool); + static void registerSelf(WebCore::MediaEngineRegistrar); + + // WebMediaPlayerClient methods: + virtual void networkStateChanged(); + virtual void readyStateChanged(); + virtual void volumeChanged(); + virtual void timeChanged(); + virtual void repaint(); + virtual void durationChanged(); + virtual void rateChanged(); + virtual void sizeChanged(); + virtual void sawUnsupportedTracks(); + + // MediaPlayerPrivateInterface methods: + virtual void load(const WebCore::String& url); + virtual void cancelLoad(); + virtual void play(); + virtual void pause(); + virtual bool supportsFullscreen() const; + virtual bool supportsSave() const; + virtual WebCore::IntSize naturalSize() const; + virtual bool hasVideo() const; + virtual bool hasAudio() const; + virtual void setVisible(bool); + virtual float duration() const; + virtual float currentTime() const; + virtual void seek(float time); + virtual bool seeking() const; + virtual void setEndTime(float time); + virtual void setRate(float); + virtual bool paused() const; + virtual void setVolume(float); + virtual WebCore::MediaPlayer::NetworkState networkState() const; + virtual WebCore::MediaPlayer::ReadyState readyState() const; + virtual float maxTimeSeekable() const; + virtual WTF::PassRefPtr<WebCore::TimeRanges> buffered() const; + virtual int dataRate() const; + virtual void setAutobuffer(bool); + virtual bool totalBytesKnown() const; + virtual unsigned totalBytes() const; + virtual unsigned bytesLoaded() const; + virtual void setSize(const WebCore::IntSize&); + virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&); + virtual bool hasSingleSecurityOrigin() const; + virtual WebCore::MediaPlayer::MovieLoadType movieLoadType() const; + +private: + WebMediaPlayerClientImpl(); + + static WebCore::MediaPlayerPrivateInterface* create(WebCore::MediaPlayer*); + static void getSupportedTypes(WTF::HashSet<WebCore::String>&); + static WebCore::MediaPlayer::SupportsType supportsType( + const WebCore::String& type, const WebCore::String& codecs); + + WebCore::MediaPlayer* m_mediaPlayer; + OwnPtr<WebMediaPlayer> m_webMediaPlayer; + static bool m_isEnabled; +}; + +} // namespace WebKit + +#endif + +#endif diff --git a/WebKit/chromium/src/WebNode.cpp b/WebKit/chromium/src/WebNode.cpp new file mode 100644 index 0000000..965c412 --- /dev/null +++ b/WebKit/chromium/src/WebNode.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebNode.h" + +#include "Document.h" +#include "Frame.h" +#include "FrameLoaderClientImpl.h" +#include "Node.h" + +#include "WebFrameImpl.h" +#include "WebString.h" + +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebNodePrivate : public Node { +}; + +void WebNode::reset() +{ + assign(0); +} + +void WebNode::assign(const WebNode& other) +{ + WebNodePrivate* p = const_cast<WebNodePrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +WebNode WebNode::parentNode() const +{ + return PassRefPtr<Node>(const_cast<Node*>(m_private->parentNode())); +} + +WebString WebNode::nodeName() const +{ + return m_private->nodeName(); +} + +WebNode::WebNode(const WTF::PassRefPtr<WebCore::Node>& node) + : m_private(static_cast<WebNodePrivate*>(node.releaseRef())) +{ +} + +WebNode& WebNode::operator=(const WTF::PassRefPtr<WebCore::Node>& node) +{ + assign(static_cast<WebNodePrivate*>(node.releaseRef())); + return *this; +} + +WebNode::operator WTF::PassRefPtr<WebCore::Node>() const +{ + return PassRefPtr<Node>(const_cast<WebNodePrivate*>(m_private)); +} + +void WebNode::assign(WebNodePrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +WebFrame* WebNode::frame() const +{ + return WebFrameImpl::fromFrame(m_private->document()->frame()); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebNotification.cpp b/WebKit/chromium/src/WebNotification.cpp new file mode 100644 index 0000000..1f6916e --- /dev/null +++ b/WebKit/chromium/src/WebNotification.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebNotification.h" + +#if ENABLE(NOTIFICATIONS) + +#include "Notification.h" + +#include "WebString.h" +#include "WebURL.h" + +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebNotificationPrivate : public Notification { +}; + +void WebNotification::reset() +{ + assign(0); +} + +void WebNotification::assign(const WebNotification& other) +{ + WebNotificationPrivate* p = const_cast<WebNotificationPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +bool WebNotification::lessThan(const WebNotification& other) const +{ + return reinterpret_cast<uintptr_t>(m_private) < reinterpret_cast<uintptr_t>(other.m_private); +} + +bool WebNotification::isHTML() const +{ + return m_private->isHTML(); +} + +WebURL WebNotification::url() const +{ + ASSERT(isHTML()); + return m_private->url(); +} + +WebString WebNotification::icon() const +{ + ASSERT(!isHTML()); + return m_private->contents().icon(); +} + +WebString WebNotification::title() const +{ + ASSERT(!isHTML()); + return m_private->contents().title(); +} + +WebString WebNotification::body() const +{ + ASSERT(!isHTML()); + return m_private->contents().body(); +} + +void WebNotification::dispatchDisplayEvent() +{ + RefPtr<Event> event = Event::create("display", false, true); + m_private->dispatchEvent(event.release()); +} + +void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */) +{ + // FIXME: errorMessage not supported by WebCore yet + RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true); + m_private->dispatchEvent(event.release()); +} + +void WebNotification::dispatchCloseEvent(bool /* byUser */) +{ + // FIXME: byUser flag not supported by WebCore yet + RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true); + m_private->dispatchEvent(event.release()); +} + +WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notification) + : m_private(static_cast<WebNotificationPrivate*>(notification.releaseRef())) +{ +} + +WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification) +{ + assign(static_cast<WebNotificationPrivate*>(notification.releaseRef())); + return *this; +} + +WebNotification::operator WTF::PassRefPtr<Notification>() const +{ + return WTF::PassRefPtr<Notification>(const_cast<WebNotificationPrivate*>(m_private)); +} + +void WebNotification::assign(WebNotificationPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit + +#endif // ENABLE(NOTIFICATIONS) diff --git a/WebKit/chromium/src/WebPasswordFormData.cpp b/WebKit/chromium/src/WebPasswordFormData.cpp new file mode 100644 index 0000000..64b1754 --- /dev/null +++ b/WebKit/chromium/src/WebPasswordFormData.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebPasswordFormData.h" + +#include "Document.h" +#include "DocumentLoader.h" +#include "Frame.h" +#include "FrameLoader.h" +#include "HTMLFormElement.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "KURL.h" + +#include "DOMUtilitiesPrivate.h" +#include "WebPasswordFormUtils.h" + +using namespace WebCore; + +namespace WebKit { + +namespace { + +// Helper to determine which password is the main one, and which is +// an old password (e.g on a "make new password" form), if any. +bool locateSpecificPasswords(PasswordFormFields* fields, + HTMLInputElement** password, + HTMLInputElement** oldPassword) +{ + ASSERT(fields); + ASSERT(password); + ASSERT(oldPassword); + switch (fields->passwords.size()) { + case 1: + // Single password, easy. + *password = fields->passwords[0]; + break; + case 2: + if (fields->passwords[0]->value() == fields->passwords[1]->value()) + // Treat two identical passwords as a single password. + *password = fields->passwords[0]; + else { + // Assume first is old password, second is new (no choice but to guess). + *oldPassword = fields->passwords[0]; + *password = fields->passwords[1]; + } + break; + case 3: + if (fields->passwords[0]->value() == fields->passwords[1]->value() + && fields->passwords[0]->value() == fields->passwords[2]->value()) { + // All three passwords the same? Just treat as one and hope. + *password = fields->passwords[0]; + } else if (fields->passwords[0]->value() == fields->passwords[1]->value()) { + // Two the same and one different -> old password is duplicated one. + *oldPassword = fields->passwords[0]; + *password = fields->passwords[2]; + } else if (fields->passwords[1]->value() == fields->passwords[2]->value()) { + *oldPassword = fields->passwords[0]; + *password = fields->passwords[1]; + } else { + // Three different passwords, or first and last match with middle + // different. No idea which is which, so no luck. + return false; + } + break; + default: + return false; + } + return true; +} + +// Helped method to clear url of unneeded parts. +KURL stripURL(const KURL& url) +{ + KURL strippedURL = url; + strippedURL.setUser(String()); + strippedURL.setPass(String()); + strippedURL.setQuery(String()); + strippedURL.setFragmentIdentifier(String()); + return strippedURL; +} + +// Helper to gather up the final form data and create a PasswordForm. +void assemblePasswordFormResult(const KURL& fullOrigin, + const KURL& fullAction, + HTMLFormControlElement* submit, + HTMLInputElement* userName, + HTMLInputElement* oldPassword, + HTMLInputElement* password, + WebPasswordFormData* result) +{ + // We want to keep the path but strip any authentication data, as well as + // query and ref portions of URL, for the form action and form origin. + result->action = stripURL(fullAction); + result->origin = stripURL(fullOrigin); + + // Naming is confusing here because we have both the HTML form origin URL + // the page where the form was seen), and the "origin" components of the url + // (scheme, host, and port). + KURL signonRealmURL = stripURL(fullOrigin); + signonRealmURL.setPath(""); + result->signonRealm = signonRealmURL; + + if (submit) + result->submitElement = submit->name(); + if (userName) { + result->userNameElement = userName->name(); + result->userNameValue = userName->value(); + } + if (password) { + result->passwordElement = password->name(); + result->passwordValue = password->value(); + } + if (oldPassword) { + result->oldPasswordElement = oldPassword->name(); + result->oldPasswordValue = oldPassword->value(); + } +} + +} // namespace + +WebPasswordFormData::WebPasswordFormData(const WebFormElement& webForm) +{ + RefPtr<HTMLFormElement> form = webForm.operator PassRefPtr<HTMLFormElement>(); + + Frame* frame = form->document()->frame(); + if (!frame) + return; + + PasswordFormFields fields; + findPasswordFormFields(form.get(), &fields); + + // Get the document URL + KURL fullOrigin(ParsedURLString, form->document()->documentURI()); + + // Calculate the canonical action URL + KURL fullAction = frame->loader()->completeURL(form->action()); + if (!fullAction.isValid()) + return; + + // Determine the types of the password fields + HTMLInputElement* password = 0; + HTMLInputElement* oldPassword = 0; + if (!locateSpecificPasswords(&fields, &password, &oldPassword)) + return; + + assemblePasswordFormResult(fullOrigin, fullAction, + fields.submit, fields.userName, + oldPassword, password, this); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPasswordFormUtils.cpp b/WebKit/chromium/src/WebPasswordFormUtils.cpp new file mode 100644 index 0000000..766dc63 --- /dev/null +++ b/WebKit/chromium/src/WebPasswordFormUtils.cpp @@ -0,0 +1,110 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: MPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Mozilla Public License Version +* 1.1 (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* http://www.mozilla.org/MPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is Mozilla Password Manager. +* +* The Initial Developer of the Original Code is +* Brian Ryner. +* Portions created by the Initial Developer are Copyright (C) 2003 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): +* Brian Ryner <bryner@brianryner.com> +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the MPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the MPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** */ + +// Helper to WebPasswordFormData to do the locating of username/password +// fields. +// This method based on Firefox2 code in +// toolkit/components/passwordmgr/base/nsPasswordManager.cpp + +#include "config.h" +#include "WebPasswordFormUtils.h" + +#include "HTMLFormElement.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "KURL.h" + +#include "DOMUtilitiesPrivate.h" + +using namespace WebCore; + +namespace WebKit { + +// Maximum number of password fields we will observe before throwing our +// hands in the air and giving up with a given form. +static const size_t maxPasswords = 3; + +void findPasswordFormFields(HTMLFormElement* form, PasswordFormFields* fields) +{ + ASSERT(form); + ASSERT(fields); + + int firstPasswordIndex = 0; + // First, find the password fields and activated submit button + const Vector<HTMLFormControlElement*>& formElements = form->formElements; + for (size_t i = 0; i < formElements.size(); i++) { + HTMLFormControlElement* formElement = formElements[i]; + if (formElement->isActivatedSubmit()) + fields->submit = formElement; + + if (!formElement->hasLocalName(HTMLNames::inputTag)) + continue; + + HTMLInputElement* inputElement = toHTMLInputElement(formElement); + if (!inputElement->isEnabledFormControl()) + continue; + + if ((fields->passwords.size() < maxPasswords) + && (inputElement->inputType() == HTMLInputElement::PASSWORD) + && (inputElement->autoComplete())) { + if (fields->passwords.isEmpty()) + firstPasswordIndex = i; + fields->passwords.append(inputElement); + } + } + + if (!fields->passwords.isEmpty()) { + // Then, search backwards for the username field + for (int i = firstPasswordIndex - 1; i >= 0; i--) { + HTMLFormControlElement* formElement = formElements[i]; + if (!formElement->hasLocalName(HTMLNames::inputTag)) + continue; + + HTMLInputElement* inputElement = toHTMLInputElement(formElement); + if (!inputElement->isEnabledFormControl()) + continue; + + if ((inputElement->inputType() == HTMLInputElement::TEXT) + && (inputElement->autoComplete())) { + fields->userName = inputElement; + break; + } + } + } +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPasswordFormUtils.h b/WebKit/chromium/src/WebPasswordFormUtils.h new file mode 100644 index 0000000..fd503b4 --- /dev/null +++ b/WebKit/chromium/src/WebPasswordFormUtils.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPasswordFormUtils_h +#define WebPasswordFormUtils_h + +#include <wtf/Vector.h> + +namespace WebCore { +class HTMLInputElement; +class HTMLFormControlElement; +class HTMLFormElement; +} + +namespace WebKit { + +// Helper structure to locate username, passwords and submit fields. +struct PasswordFormFields { + WebCore::HTMLInputElement* userName; + Vector<WebCore::HTMLInputElement*> passwords; + WebCore::HTMLFormControlElement* submit; + PasswordFormFields() : userName(0), submit(0) { } +}; + +void findPasswordFormFields(WebCore::HTMLFormElement* form, + PasswordFormFields* fields); + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebPluginContainerImpl.cpp b/WebKit/chromium/src/WebPluginContainerImpl.cpp new file mode 100644 index 0000000..43f3cef --- /dev/null +++ b/WebKit/chromium/src/WebPluginContainerImpl.cpp @@ -0,0 +1,556 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebPluginContainerImpl.h" + +#include "ChromeClientImpl.h" +#include "WebCursorInfo.h" +#include "WebDataSourceImpl.h" +#include "WebInputEvent.h" +#include "WebInputEventConversion.h" +#include "WebKit.h" +#include "WebPlugin.h" +#include "WebRect.h" +#include "WebURLError.h" +#include "WebURLRequest.h" +#include "WebVector.h" +#include "WrappedResourceResponse.h" + +#include "EventNames.h" +#include "FocusController.h" +#include "FormState.h" +#include "Frame.h" +#include "FrameLoadRequest.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HostWindow.h" +#include "HTMLFormElement.h" +#include "HTMLNames.h" +#include "HTMLPlugInElement.h" +#include "KeyboardEvent.h" +#include "MouseEvent.h" +#include "Page.h" +#include "ScrollView.h" + +#if WEBKIT_USING_SKIA +#include "PlatformContextSkia.h" +#endif + +using namespace WebCore; + +namespace WebKit { + +// Public methods -------------------------------------------------------------- + +void WebPluginContainerImpl::setFrameRect(const IntRect& frameRect) +{ + Widget::setFrameRect(frameRect); + reportGeometry(); +} + +void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRect) +{ + if (gc->paintingDisabled()) + return; + + if (!parent()) + return; + + // Don't paint anything if the plugin doesn't intersect the damage rect. + if (!frameRect().intersects(damageRect)) + return; + + gc->save(); + + ASSERT(parent()->isFrameView()); + ScrollView* view = parent(); + + // The plugin is positioned in window coordinates, so it needs to be painted + // in window coordinates. + IntPoint origin = view->windowToContents(IntPoint(0, 0)); + gc->translate(static_cast<float>(origin.x()), static_cast<float>(origin.y())); + +#if WEBKIT_USING_SKIA + WebCanvas* canvas = gc->platformContext()->canvas(); +#elif WEBKIT_USING_CG + WebCanvas* canvas = gc->platformContext(); +#endif + + IntRect windowRect = + IntRect(view->contentsToWindow(damageRect.location()), damageRect.size()); + m_webPlugin->paint(canvas, windowRect); + + gc->restore(); +} + +void WebPluginContainerImpl::invalidateRect(const IntRect& rect) +{ + if (!parent()) + return; + + IntRect damageRect = convertToContainingWindow(rect); + + // Get our clip rect and intersect with it to ensure we don't invalidate + // too much. + IntRect clipRect = parent()->windowClipRect(); + damageRect.intersect(clipRect); + + parent()->hostWindow()->repaint(damageRect, true); +} + +void WebPluginContainerImpl::setFocus() +{ + Widget::setFocus(); + m_webPlugin->updateFocus(true); +} + +void WebPluginContainerImpl::show() +{ + setSelfVisible(true); + m_webPlugin->updateVisibility(true); + + Widget::show(); +} + +void WebPluginContainerImpl::hide() +{ + setSelfVisible(false); + m_webPlugin->updateVisibility(false); + + Widget::hide(); +} + +void WebPluginContainerImpl::handleEvent(Event* event) +{ + if (!m_webPlugin->acceptsInputEvents()) + return; + + // The events we pass are defined at: + // http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/structures5.html#1000000 + // Don't take the documentation as truth, however. There are many cases + // where mozilla behaves differently than the spec. + if (event->isMouseEvent()) + handleMouseEvent(static_cast<MouseEvent*>(event)); + else if (event->isKeyboardEvent()) + handleKeyboardEvent(static_cast<KeyboardEvent*>(event)); +} + +void WebPluginContainerImpl::frameRectsChanged() +{ + Widget::frameRectsChanged(); + reportGeometry(); +} + +void WebPluginContainerImpl::setParentVisible(bool parentVisible) +{ + // We override this function to make sure that geometry updates are sent + // over to the plugin. For e.g. when a plugin is instantiated it does not + // have a valid parent. As a result the first geometry update from webkit + // is ignored. This function is called when the plugin eventually gets a + // parent. + + if (isParentVisible() == parentVisible) + return; // No change. + + Widget::setParentVisible(parentVisible); + if (!isSelfVisible()) + return; // This widget has explicitely been marked as not visible. + + m_webPlugin->updateVisibility(isVisible()); +} + +void WebPluginContainerImpl::setParent(ScrollView* view) +{ + // We override this function so that if the plugin is windowed, we can call + // NPP_SetWindow at the first possible moment. This ensures that + // NPP_SetWindow is called before the manual load data is sent to a plugin. + // If this order is reversed, Flash won't load videos. + + Widget::setParent(view); + if (view) + reportGeometry(); +} + +void WebPluginContainerImpl::invalidate() +{ + Widget::invalidate(); +} + +void WebPluginContainerImpl::invalidateRect(const WebRect& rect) +{ + invalidateRect(static_cast<IntRect>(rect)); +} + +void WebPluginContainerImpl::reportGeometry() +{ + if (!parent()) + return; + + IntRect windowRect, clipRect; + Vector<IntRect> cutOutRects; + calculateGeometry(frameRect(), windowRect, clipRect, cutOutRects); + + m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible()); +} + +void WebPluginContainerImpl::clearScriptObjects() +{ + Frame* frame = m_element->document()->frame(); + if (!frame) + return; + frame->script()->cleanupScriptObjectsForPlugin(this); +} + +NPObject* WebPluginContainerImpl::scriptableObjectForElement() +{ + return m_element->getNPObject(); +} + +WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed) +{ + Frame* frame = m_element->document()->frame(); + if (!frame) + return WebString(); + + const KURL& kurl = url; + ASSERT(kurl.protocolIs("javascript")); + + String script = decodeURLEscapeSequences( + kurl.string().substring(strlen("javascript:"))); + + ScriptValue result = frame->script()->executeScript(script, popupsAllowed); + + // Failure is reported as a null string. + String resultStr; + result.getString(resultStr); + return resultStr; +} + +void WebPluginContainerImpl::loadFrameRequest( + const WebURLRequest& request, const WebString& target, bool notifyNeeded, void* notifyData) +{ + Frame* frame = m_element->document()->frame(); + if (!frame) + return; // FIXME: send a notification in this case? + + if (notifyNeeded) { + // FIXME: This is a bit of hack to allow us to observe completion of + // our frame request. It would be better to evolve FrameLoader to + // support a completion callback instead. + WebPluginLoadObserver* observer = + new WebPluginLoadObserver(this, request.url(), notifyData); + m_pluginLoadObservers.append(observer); + WebDataSourceImpl::setNextPluginLoadObserver(observer); + } + + FrameLoadRequest frameRequest(request.toResourceRequest()); + frameRequest.setFrameName(target); + + frame->loader()->loadFrameRequest( + frameRequest, + false, // lock history + false, // lock back forward list + 0, // event + 0, // form state + SendReferrer); +} + +void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response) +{ + // Make sure that the plugin receives window geometry before data, or else + // plugins misbehave. + frameRectsChanged(); + + WrappedResourceResponse urlResponse(response); + m_webPlugin->didReceiveResponse(urlResponse); +} + +void WebPluginContainerImpl::didReceiveData(const char *data, int dataLength) +{ + m_webPlugin->didReceiveData(data, dataLength); +} + +void WebPluginContainerImpl::didFinishLoading() +{ + m_webPlugin->didFinishLoading(); +} + +void WebPluginContainerImpl::didFailLoading(const ResourceError& error) +{ + m_webPlugin->didFailLoading(error); +} + +NPObject* WebPluginContainerImpl::scriptableObject() +{ + return m_webPlugin->scriptableObject(); +} + +void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver* observer) +{ + size_t pos = m_pluginLoadObservers.find(observer); + if (pos == notFound) + return; + m_pluginLoadObservers.remove(pos); +} + +// Private methods ------------------------------------------------------------- + +WebPluginContainerImpl::~WebPluginContainerImpl() +{ + for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i) + m_pluginLoadObservers[i]->clearPluginContainer(); + m_webPlugin->destroy(); +} + +void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) +{ + ASSERT(parent()->isFrameView()); + + // We cache the parent FrameView here as the plugin widget could be deleted + // in the call to HandleEvent. See http://b/issue?id=1362948 + FrameView* parentView = static_cast<FrameView*>(parent()); + + WebMouseEventBuilder webEvent(parentView, *event); + if (webEvent.type == WebInputEvent::Undefined) + return; + + if (event->type() == eventNames().mousedownEvent) { + // Ensure that the frame containing the plugin has focus. + Frame* containingFrame = parentView->frame(); + if (Page* currentPage = containingFrame->page()) + currentPage->focusController()->setFocusedFrame(containingFrame); + // Give focus to our containing HTMLPluginElement. + containingFrame->document()->setFocusedNode(m_element); + } + + WebCursorInfo cursorInfo; + bool handled = m_webPlugin->handleInputEvent(webEvent, cursorInfo); +#if !PLATFORM(DARWIN) + // TODO(pkasting): http://b/1119691 This conditional seems exactly + // backwards, but if I reverse it, giving focus to a transparent + // (windowless) plugin fails. + handled = !handled; + // TODO(awalker): oddly, the above is not true in Mac builds. Looking + // at Apple's corresponding code for Mac and Windows (PluginViewMac and + // PluginViewWin), setDefaultHandled() gets called when handleInputEvent() + // returns true, which then indicates to WebCore that the plugin wants to + // swallow the event--which is what we want. Calling setDefaultHandled() + // fixes several Mac Chromium bugs, but does indeed prevent windowless plugins + // from getting focus in Windows builds, as pkasting notes above. So for + // now, we only do so in Mac builds. +#endif + if (handled) + event->setDefaultHandled(); + + // A windowless plugin can change the cursor in response to a mouse move + // event. We need to reflect the changed cursor in the frame view as the + // mouse is moved in the boundaries of the windowless plugin. + Page* page = parentView->frame()->page(); + if (!page) + return; + ChromeClientImpl* chromeClient = + static_cast<ChromeClientImpl*>(page->chrome()->client()); + chromeClient->setCursorForPlugin(cursorInfo); +} + +void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) +{ + WebKeyboardEventBuilder webEvent(*event); + if (webEvent.type == WebInputEvent::Undefined) + return; + + WebCursorInfo cursor_info; + bool handled = m_webPlugin->handleInputEvent(webEvent, cursor_info); +#if !PLATFORM(DARWIN) + // TODO(pkasting): http://b/1119691 See above. + handled = !handled; +#endif + if (handled) + event->setDefaultHandled(); +} + +void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect, + IntRect& windowRect, + IntRect& clipRect, + Vector<IntRect>& cutOutRects) +{ + windowRect = IntRect( + parent()->contentsToWindow(frameRect.location()), frameRect.size()); + + // Calculate a clip-rect so that we don't overlap the scrollbars, etc. + clipRect = windowClipRect(); + clipRect.move(-windowRect.x(), -windowRect.y()); + + windowCutOutRects(frameRect, cutOutRects); + // Convert to the plugin position. + for (size_t i = 0; i < cutOutRects.size(); i++) + cutOutRects[i].move(-frameRect.x(), -frameRect.y()); +} + +WebCore::IntRect WebPluginContainerImpl::windowClipRect() const +{ + // Start by clipping to our bounds. + IntRect clipRect = + convertToContainingWindow(IntRect(0, 0, width(), height())); + + // document()->renderer() can be 0 when we receive messages from the + // plugins while we are destroying a frame. + if (m_element->renderer()->document()->renderer()) { + // Take our element and get the clip rect from the enclosing layer and + // frame view. + RenderLayer* layer = m_element->renderer()->enclosingLayer(); + clipRect.intersect( + m_element->document()->view()->windowClipRectForLayer(layer, true)); + } + + return clipRect; +} + +static void getObjectStack(const RenderObject* ro, + Vector<const RenderObject*>* roStack) +{ + roStack->clear(); + while (ro) { + roStack->append(ro); + ro = ro->parent(); + } +} + +// Returns true if stack1 is at or above stack2 +static bool checkStackOnTop( + const Vector<const RenderObject*>& iframeZstack, + const Vector<const RenderObject*>& pluginZstack) +{ + for (size_t i1 = 0, i2 = 0; + i1 < iframeZstack.size() && i2 < pluginZstack.size(); + i1++, i2++) { + // The root is at the end of these stacks. We want to iterate + // root-downwards so we index backwards from the end. + const RenderObject* ro1 = iframeZstack[iframeZstack.size() - 1 - i1]; + const RenderObject* ro2 = pluginZstack[pluginZstack.size() - 1 - i2]; + + if (ro1 != ro2) { + // When we find nodes in the stack that are not the same, then + // we've found the nodes just below the lowest comment ancestor. + // Determine which should be on top. + + // See if z-index determines an order. + if (ro1->style() && ro2->style()) { + int z1 = ro1->style()->zIndex(); + int z2 = ro2->style()->zIndex(); + if (z1 > z2) + return true; + if (z1 < z2) + return false; + } + + // For compatibility with IE: when the plugin is not positioned, + // it stacks behind the iframe, even if it's later in the + // document order. + if (ro2->style()->position() == StaticPosition) + return true; + + // Inspect the document order. Later order means higher + // stacking. + const RenderObject* parent = ro1->parent(); + if (!parent) + return false; + ASSERT(parent == ro2->parent()); + + for (const RenderObject* ro = parent->firstChild(); ro; ro = ro->nextSibling()) { + if (ro == ro1) + return false; + if (ro == ro2) + return true; + } + ASSERT(false); // We should have seen ro1 and ro2 by now. + return false; + } + } + return true; +} + +// Return a set of rectangles that should not be overdrawn by the +// plugin ("cutouts"). This helps implement the "iframe shim" +// technique of overlaying a windowed plugin with content from the +// page. In a nutshell, iframe elements should occlude plugins when +// they occur higher in the stacking order. +void WebPluginContainerImpl::windowCutOutRects(const IntRect& frameRect, + Vector<IntRect>& cutOutRects) +{ + RenderObject* pluginNode = m_element->renderer(); + ASSERT(pluginNode); + if (!pluginNode->style()) + return; + Vector<const RenderObject*> pluginZstack; + Vector<const RenderObject*> iframeZstack; + getObjectStack(pluginNode, &pluginZstack); + + // Get the parent widget + Widget* parentWidget = this->parent(); + if (!parentWidget->isFrameView()) + return; + + FrameView* parentFrameView = static_cast<FrameView*>(parentWidget); + + const HashSet<RefPtr<Widget> >* children = parentFrameView->children(); + for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != children->end(); ++it) { + // We only care about FrameView's because iframes show up as FrameViews. + if (!(*it)->isFrameView()) + continue; + + const FrameView* frameView = + static_cast<const FrameView*>((*it).get()); + // Check to make sure we can get both the element and the RenderObject + // for this FrameView, if we can't just move on to the next object. + if (!frameView->frame() || !frameView->frame()->ownerElement() + || !frameView->frame()->ownerElement()->renderer()) + continue; + + HTMLElement* element = frameView->frame()->ownerElement(); + RenderObject* iframeRenderer = element->renderer(); + + if (element->hasTagName(HTMLNames::iframeTag) + && iframeRenderer->absoluteBoundingBoxRect().intersects(frameRect) + && (!iframeRenderer->style() || iframeRenderer->style()->visibility() == VISIBLE)) { + getObjectStack(iframeRenderer, &iframeZstack); + if (checkStackOnTop(iframeZstack, pluginZstack)) { + IntPoint point = + roundedIntPoint(iframeRenderer->localToAbsolute()); + RenderBox* rbox = toRenderBox(iframeRenderer); + IntSize size(rbox->width(), rbox->height()); + cutOutRects.append(IntRect(point, size)); + } + } + } +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPluginContainerImpl.h b/WebKit/chromium/src/WebPluginContainerImpl.h new file mode 100644 index 0000000..00450bb --- /dev/null +++ b/WebKit/chromium/src/WebPluginContainerImpl.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPluginContainerImpl_h +#define WebPluginContainerImpl_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebPluginContainer.h" + +#include "Widget.h" +#include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> + +struct NPObject; + +namespace WebCore { +class HTMLPlugInElement; +class IntRect; +class KeyboardEvent; +class MouseEvent; +class ResourceError; +class ResourceResponse; +} + +namespace WebKit { + +class WebPlugin; +class WebPluginLoadObserver; + +class WebPluginContainerImpl : public WebCore::Widget, public WebPluginContainer { +public: + static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin) + { + return adoptRef(new WebPluginContainerImpl(element, webPlugin)); + } + + // Widget methods + virtual void setFrameRect(const WebCore::IntRect&); + virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&); + virtual void invalidateRect(const WebCore::IntRect&); + virtual void setFocus(); + virtual void show(); + virtual void hide(); + virtual void handleEvent(WebCore::Event*); + virtual void frameRectsChanged(); + virtual void setParentVisible(bool); + virtual void setParent(WebCore::ScrollView*); + + // WebPluginContainer methods + virtual void invalidate(); + virtual void invalidateRect(const WebRect&); + virtual void reportGeometry(); + virtual void clearScriptObjects(); + virtual NPObject* scriptableObjectForElement(); + virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed); + virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData); + + // Resource load events for the plugin's source data: + void didReceiveResponse(const WebCore::ResourceResponse&); + void didReceiveData(const char *data, int dataLength); + void didFinishLoading(); + void didFailLoading(const WebCore::ResourceError&); + + NPObject* scriptableObject(); + + // This cannot be null. + WebPlugin* plugin() { return m_webPlugin; } + + void willDestroyPluginLoadObserver(WebPluginLoadObserver*); + +private: + WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin) + : m_element(element) + , m_webPlugin(webPlugin) { } + ~WebPluginContainerImpl(); + + void handleMouseEvent(WebCore::MouseEvent*); + void handleKeyboardEvent(WebCore::KeyboardEvent*); + + void calculateGeometry(const WebCore::IntRect& frameRect, + WebCore::IntRect& windowRect, + WebCore::IntRect& clipRect, + Vector<WebCore::IntRect>& cutOutRects); + WebCore::IntRect windowClipRect() const; + void windowCutOutRects(const WebCore::IntRect& frameRect, + Vector<WebCore::IntRect>& cutOutRects); + + WebCore::HTMLPlugInElement* m_element; + WebPlugin* m_webPlugin; + Vector<WebPluginLoadObserver*> m_pluginLoadObservers; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebPluginListBuilderImpl.cpp b/WebKit/chromium/src/WebPluginListBuilderImpl.cpp new file mode 100644 index 0000000..6926a2d --- /dev/null +++ b/WebKit/chromium/src/WebPluginListBuilderImpl.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebPluginListBuilderImpl.h" + +#include "PluginData.h" +#include "WebString.h" +#include <wtf/Vector.h> + +using namespace WebCore; + +namespace WebKit { + +void WebPluginListBuilderImpl::addPlugin(const WebString& name, const WebString& description, const WebString& fileName) +{ + PluginInfo* info = new PluginInfo(); + info->name = name; + info->desc = description; + info->file = fileName; + m_results->append(info); +} + +void WebPluginListBuilderImpl::addMediaTypeToLastPlugin(const WebString& name, const WebString& description) +{ + MimeClassInfo* info = new MimeClassInfo(); + info->type = name; + info->desc = description; + m_results->last()->mimes.append(info); +} + +void WebPluginListBuilderImpl::addFileExtensionToLastMediaType(const WebString& extension) +{ + MimeClassInfo* info = m_results->last()->mimes.last(); + if (!info->suffixes.isEmpty()) + info->suffixes.append(','); + info->suffixes.append(extension); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPluginListBuilderImpl.h b/WebKit/chromium/src/WebPluginListBuilderImpl.h new file mode 100644 index 0000000..7a8a497 --- /dev/null +++ b/WebKit/chromium/src/WebPluginListBuilderImpl.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPluginListBuilderImpl_h +#define WebPluginListBuilderImpl_h + +#include "WebPluginListBuilder.h" + +#include "PluginData.h" +#include <wtf/Vector.h> + +namespace WebKit { + +class WebPluginListBuilderImpl : public WebPluginListBuilder { +public: + WebPluginListBuilderImpl(Vector<WebCore::PluginInfo*>* results) : m_results(results) { } + + // WebPluginListBuilder methods: + virtual void addPlugin(const WebString& name, const WebString& description, const WebString& fileName); + virtual void addMediaTypeToLastPlugin(const WebString& name, const WebString& description); + virtual void addFileExtensionToLastMediaType(const WebString& extension); + +private: + Vector<WebCore::PluginInfo*>* m_results; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebPluginLoadObserver.cpp b/WebKit/chromium/src/WebPluginLoadObserver.cpp new file mode 100644 index 0000000..5ec59a6 --- /dev/null +++ b/WebKit/chromium/src/WebPluginLoadObserver.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebPluginLoadObserver.h" + +#include "WebPlugin.h" +#include "WebPluginContainerImpl.h" + +namespace WebKit { + +WebPluginLoadObserver::~WebPluginLoadObserver() +{ + if (m_pluginContainer) + m_pluginContainer->willDestroyPluginLoadObserver(this); +} + +void WebPluginLoadObserver::didFinishLoading() +{ + if (m_pluginContainer) + m_pluginContainer->plugin()->didFinishLoadingFrameRequest(m_notifyURL, m_notifyData); +} + +void WebPluginLoadObserver::didFailLoading(const WebURLError& error) +{ + if (m_pluginContainer) + m_pluginContainer->plugin()->didFailLoadingFrameRequest(m_notifyURL, m_notifyData, error); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPluginLoadObserver.h b/WebKit/chromium/src/WebPluginLoadObserver.h new file mode 100644 index 0000000..097d08d --- /dev/null +++ b/WebKit/chromium/src/WebPluginLoadObserver.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPluginLoadObserver_h +#define WebPluginLoadObserver_h + +#include "../public/WebURL.h" + +namespace WebKit { + +class WebPluginContainerImpl; +struct WebURLError; + +class WebPluginLoadObserver { +public: + WebPluginLoadObserver(WebPluginContainerImpl* pluginContainer, + const WebURL& notifyURL, void* notifyData) + : m_pluginContainer(pluginContainer) + , m_notifyURL(notifyURL) + , m_notifyData(notifyData) + { + } + + ~WebPluginLoadObserver(); + + const WebURL& url() const { return m_notifyURL; } + + void clearPluginContainer() { m_pluginContainer = 0; } + void didFinishLoading(); + void didFailLoading(const WebURLError&); + +private: + WebPluginContainerImpl* m_pluginContainer; + WebURL m_notifyURL; + void* m_notifyData; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebPopupMenuImpl.cpp b/WebKit/chromium/src/WebPopupMenuImpl.cpp new file mode 100644 index 0000000..f6d360e --- /dev/null +++ b/WebKit/chromium/src/WebPopupMenuImpl.cpp @@ -0,0 +1,312 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebPopupMenuImpl.h" + +#include "Cursor.h" +#include "FramelessScrollView.h" +#include "FrameView.h" +#include "IntRect.h" +#include "PlatformContextSkia.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformMouseEvent.h" +#include "PlatformWheelEvent.h" +#include "SkiaUtils.h" + +#include "WebInputEvent.h" +#include "WebInputEventConversion.h" +#include "WebRect.h" +#include "WebWidgetClient.h" + +#include <skia/ext/platform_canvas.h> + +using namespace WebCore; + +namespace WebKit { + +// WebPopupMenu --------------------------------------------------------------- + +WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) +{ + return new WebPopupMenuImpl(client); +} + +// WebWidget ------------------------------------------------------------------ + +WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) + : m_client(client) + , m_widget(0) +{ + // set to impossible point so we always get the first mouse pos + m_lastMousePosition = WebPoint(-1, -1); +} + +WebPopupMenuImpl::~WebPopupMenuImpl() +{ + if (m_widget) + m_widget->setClient(0); +} + +void WebPopupMenuImpl::Init(FramelessScrollView* widget, const WebRect& bounds) +{ + m_widget = widget; + m_widget->setClient(this); + + if (m_client) { + m_client->setWindowRect(bounds); + m_client->show(WebNavigationPolicy()); // Policy is ignored + } +} + +void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event) +{ + // don't send mouse move messages if the mouse hasn't moved. + if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) { + m_lastMousePosition = WebPoint(event.x, event.y); + m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event)); + } +} + +void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event) +{ + m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event)); +} + +void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event) +{ + m_widget->handleMouseDownEvent(PlatformMouseEventBuilder(m_widget, event)); +} + +void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event) +{ + mouseCaptureLost(); + m_widget->handleMouseReleaseEvent(PlatformMouseEventBuilder(m_widget, event)); +} + +void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event) +{ + m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event)); +} + +bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event) +{ + return m_widget->handleKeyEvent(PlatformKeyboardEventBuilder(event)); +} + +// WebWidget ------------------------------------------------------------------- + +void WebPopupMenuImpl::close() +{ + if (m_widget) + m_widget->hide(); + + m_client = 0; + + deref(); // Balances ref() from WebWidget::Create +} + +void WebPopupMenuImpl::resize(const WebSize& newSize) +{ + if (m_size == newSize) + return; + m_size = newSize; + + if (m_widget) { + IntRect newGeometry(0, 0, m_size.width, m_size.height); + m_widget->setFrameRect(newGeometry); + } + + if (m_client) { + WebRect damagedRect(0, 0, m_size.width, m_size.height); + m_client->didInvalidateRect(damagedRect); + } +} + +void WebPopupMenuImpl::layout() +{ +} + +void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) +{ + if (!m_widget) + return; + + if (!rect.isEmpty()) { +#if WEBKIT_USING_CG + GraphicsContext gc(canvas); +#elif WEBKIT_USING_SKIA + PlatformContextSkia context(canvas); + // PlatformGraphicsContext is actually a pointer to PlatformContextSkia. + GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); +#else + notImplemented(); +#endif + m_widget->paint(&gc, rect); + } +} + +bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent) +{ + if (!m_widget) + return false; + + // TODO (jcampan): WebKit seems to always return false on mouse events + // methods. For now we'll assume it has processed them (as we are only + // interested in whether keyboard events are processed). + switch (inputEvent.type) { + case WebInputEvent::MouseMove: + MouseMove(*static_cast<const WebMouseEvent*>(&inputEvent)); + return true; + + case WebInputEvent::MouseLeave: + MouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent)); + return true; + + case WebInputEvent::MouseWheel: + MouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent)); + return true; + + case WebInputEvent::MouseDown: + MouseDown(*static_cast<const WebMouseEvent*>(&inputEvent)); + return true; + + case WebInputEvent::MouseUp: + MouseUp(*static_cast<const WebMouseEvent*>(&inputEvent)); + return true; + + // In Windows, RawKeyDown only has information about the physical key, but + // for "selection", we need the information about the character the key + // translated into. For English, the physical key value and the character + // value are the same, hence, "selection" works for English. But for other + // languages, such as Hebrew, the character value is different from the + // physical key value. Thus, without accepting Char event type which + // contains the key's character value, the "selection" won't work for + // non-English languages, such as Hebrew. + case WebInputEvent::RawKeyDown: + case WebInputEvent::KeyDown: + case WebInputEvent::KeyUp: + case WebInputEvent::Char: + return KeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent)); + + default: + break; + } + return false; +} + +void WebPopupMenuImpl::mouseCaptureLost() +{ +} + +void WebPopupMenuImpl::setFocus(bool enable) +{ +} + +bool WebPopupMenuImpl::handleCompositionEvent( + WebCompositionCommand command, int cursorPosition, int targetStart, + int targetEnd, const WebString& imeString) +{ + return false; +} + +bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled, WebRect* caretRect) +{ + return false; +} + +void WebPopupMenuImpl::setTextDirection(WebTextDirection direction) +{ +} + + +//----------------------------------------------------------------------------- +// WebCore::HostWindow + +void WebPopupMenuImpl::repaint(const IntRect& paintRect, + bool contentChanged, + bool immediate, + bool repaintContentOnly) +{ + // Ignore spurious calls. + if (!contentChanged || paintRect.isEmpty()) + return; + if (m_client) + m_client->didInvalidateRect(paintRect); +} + +void WebPopupMenuImpl::scroll(const IntSize& scrollDelta, + const IntRect& scrollRect, + const IntRect& clipRect) +{ + if (m_client) { + int dx = scrollDelta.width(); + int dy = scrollDelta.height(); + m_client->didScrollRect(dx, dy, clipRect); + } +} + +IntPoint WebPopupMenuImpl::screenToWindow(const IntPoint& point) const +{ + notImplemented(); + return IntPoint(); +} + +IntRect WebPopupMenuImpl::windowToScreen(const IntRect& rect) const +{ + notImplemented(); + return IntRect(); +} + +void WebPopupMenuImpl::scrollRectIntoView(const IntRect&, const ScrollView*) const +{ + // Nothing to be done here since we do not have the concept of a container + // that implements its own scrolling. +} + +void WebPopupMenuImpl::scrollbarsModeDidChange() const +{ + // Nothing to be done since we have no concept of different scrollbar modes. +} + +//----------------------------------------------------------------------------- +// WebCore::FramelessScrollViewClient + +void WebPopupMenuImpl::popupClosed(FramelessScrollView* widget) +{ + ASSERT(widget == m_widget); + if (m_widget) { + m_widget->setClient(0); + m_widget = 0; + } + m_client->closeWidgetSoon(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPopupMenuImpl.h b/WebKit/chromium/src/WebPopupMenuImpl.h new file mode 100644 index 0000000..13eb674 --- /dev/null +++ b/WebKit/chromium/src/WebPopupMenuImpl.h @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebPopupMenuImpl_h +#define WebPopupMenuImpl_h + +// FIXME: Add this to FramelessScrollViewClient.h +namespace WebCore { class FramelessScrollView; } + +#include "FramelessScrollViewClient.h" +// FIXME: remove the relative paths once glue/ consumers are removed. +#include "../public/WebPoint.h" +#include "../public/WebPopupMenu.h" +#include "../public/WebSize.h" +#include <wtf/RefCounted.h> + +namespace WebCore { +class Frame; +class FramelessScrollView; +class KeyboardEvent; +class Page; +class PlatformKeyboardEvent; +class Range; +class Widget; +} + +namespace WebKit { +class WebKeyboardEvent; +class WebMouseEvent; +class WebMouseWheelEvent; +struct WebRect; + +class WebPopupMenuImpl : public WebPopupMenu, + public WebCore::FramelessScrollViewClient, + public RefCounted<WebPopupMenuImpl> { +public: + // WebWidget + virtual void close(); + virtual WebSize size() { return m_size; } + virtual void resize(const WebSize&); + virtual void layout(); + virtual void paint(WebCanvas* canvas, const WebRect& rect); + virtual bool handleInputEvent(const WebInputEvent&); + virtual void mouseCaptureLost(); + virtual void setFocus(bool enable); + virtual bool handleCompositionEvent( + WebCompositionCommand command, int cursorPosition, + int targetStart, int targetEnd, const WebString& text); + virtual bool queryCompositionStatus(bool* enabled, WebRect* caretRect); + virtual void setTextDirection(WebTextDirection direction); + + // WebPopupMenuImpl + void Init(WebCore::FramelessScrollView* widget, + const WebRect& bounds); + + WebWidgetClient* client() { return m_client; } + + void MouseMove(const WebMouseEvent&); + void MouseLeave(const WebMouseEvent&); + void MouseDown(const WebMouseEvent&); + void MouseUp(const WebMouseEvent&); + void MouseDoubleClick(const WebMouseEvent&); + void MouseWheel(const WebMouseWheelEvent&); + bool KeyEvent(const WebKeyboardEvent&); + + protected: + friend class WebPopupMenu; // For WebPopupMenu::create + friend class WTF::RefCounted<WebPopupMenuImpl>; + + WebPopupMenuImpl(WebWidgetClient* client); + ~WebPopupMenuImpl(); + + // WebCore::HostWindow methods: + virtual void repaint( + const WebCore::IntRect&, bool contentChanged, bool immediate = false, + bool repaintContentOnly = false); + virtual void scroll( + const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, + const WebCore::IntRect& clipRect); + virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; + virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; + virtual PlatformPageClient platformPageClient() const { return 0; } + virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; + virtual void scrollbarsModeDidChange() const; + + // WebCore::FramelessScrollViewClient methods: + virtual void popupClosed(WebCore::FramelessScrollView*); + + WebWidgetClient* m_client; + WebSize m_size; + + WebPoint m_lastMousePosition; + + // This is a non-owning ref. The popup will notify us via popupClosed() + // before it is destroyed. + WebCore::FramelessScrollView* m_widget; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebRange.cpp b/WebKit/chromium/src/WebRange.cpp new file mode 100644 index 0000000..3dd000d --- /dev/null +++ b/WebKit/chromium/src/WebRange.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebRange.h" + +#include "Range.h" +#include "WebNode.h" +#include "WebString.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebRangePrivate : public Range { +}; + +void WebRange::reset() +{ + assign(0); +} + +void WebRange::assign(const WebRange& other) +{ + WebRangePrivate* p = const_cast<WebRangePrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +int WebRange::startOffset() const +{ + return m_private->startOffset(); +} + +int WebRange::endOffset() const +{ + return m_private->endOffset(); +} + +WebNode WebRange::startContainer(int& exceptionCode) const +{ + return PassRefPtr<Node>(m_private->startContainer(exceptionCode)); +} + +WebNode WebRange::endContainer(int& exceptionCode) const +{ + return PassRefPtr<Node>(m_private->endContainer(exceptionCode)); +} + +WebString WebRange::toHTMLText() const +{ + return m_private->toHTML(); +} + +WebString WebRange::toPlainText() const +{ + return m_private->text(); +} + +WebRange::WebRange(const WTF::PassRefPtr<WebCore::Range>& range) + : m_private(static_cast<WebRangePrivate*>(range.releaseRef())) +{ +} + +WebRange& WebRange::operator=(const WTF::PassRefPtr<WebCore::Range>& range) +{ + assign(static_cast<WebRangePrivate*>(range.releaseRef())); + return *this; +} + +WebRange::operator WTF::PassRefPtr<WebCore::Range>() const +{ + return PassRefPtr<Range>(const_cast<WebRangePrivate*>(m_private)); +} + +void WebRange::assign(WebRangePrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebRegularExpression.cpp b/WebKit/chromium/src/WebRegularExpression.cpp new file mode 100644 index 0000000..558b750 --- /dev/null +++ b/WebKit/chromium/src/WebRegularExpression.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebRegularExpression.h" + +#include "RegularExpression.h" +#include "WebString.h" + +using namespace WebCore; + +namespace WebKit { + +class WebRegularExpressionPrivate : public RegularExpression { +}; + +WebRegularExpression::WebRegularExpression(const WebString& pattern, + WebTextCaseSensitivity caseSensitivity) +{ + TextCaseSensitivity sensitivity = static_cast<TextCaseSensitivity>(caseSensitivity); + RegularExpression* re = new RegularExpression(pattern, sensitivity); + m_private = static_cast<WebRegularExpressionPrivate*>(re); +} + +WebRegularExpression::~WebRegularExpression() +{ + delete m_private; +} + +int WebRegularExpression::match(const WebString& str, + int startFrom, + int* matchLength) const +{ + if (!m_private) + return -1; + + return m_private->match(str, startFrom, matchLength); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebRuntimeFeatures.cpp b/WebKit/chromium/src/WebRuntimeFeatures.cpp new file mode 100644 index 0000000..b630a09 --- /dev/null +++ b/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebRuntimeFeatures.h" + +#include "RuntimeEnabledFeatures.h" +#include "WebMediaPlayerClientImpl.h" +#include "WebSocket.h" + +using namespace WebCore; + +namespace WebKit { + +void WebRuntimeFeatures::enableDatabase(bool enable) +{ +#if ENABLE(DATABASE) + RuntimeEnabledFeatures::setDatabaseEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isDatabaseEnabled() +{ +#if ENABLE(DATABASE) + return RuntimeEnabledFeatures::databaseEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableLocalStorage(bool enable) +{ +#if ENABLE(DOM_STORAGE) + RuntimeEnabledFeatures::setLocalStorageEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isLocalStorageEnabled() +{ +#if ENABLE(DOM_STORAGE) + return RuntimeEnabledFeatures::localStorageEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableSessionStorage(bool enable) +{ +#if ENABLE(DOM_STORAGE) + RuntimeEnabledFeatures::setSessionStorageEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isSessionStorageEnabled() +{ +#if ENABLE(DOM_STORAGE) + return RuntimeEnabledFeatures::sessionStorageEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableMediaPlayer(bool enable) +{ +#if ENABLE(VIDEO) + WebMediaPlayerClientImpl::setIsEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isMediaPlayerEnabled() +{ +#if ENABLE(VIDEO) + return WebMediaPlayerClientImpl::isEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableSockets(bool enable) +{ +#if ENABLE(WEB_SOCKETS) + WebSocket::setIsAvailable(enable); +#endif +} + +bool WebRuntimeFeatures::isSocketsEnabled() +{ +#if ENABLE(WEB_SOCKETS) + return WebSocket::isAvailable(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableNotifications(bool enable) +{ +#if ENABLE(NOTIFICATIONS) + RuntimeEnabledFeatures::setNotificationsEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isNotificationsEnabled() +{ +#if ENABLE(NOTIFICATIONS) + return RuntimeEnabledFeatures::notificationsEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableApplicationCache(bool enable) +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + RuntimeEnabledFeatures::setApplicationCacheEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isApplicationCacheEnabled() +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + return RuntimeEnabledFeatures::applicationCacheEnabled(); +#else + return false; +#endif +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebScriptController.cpp b/WebKit/chromium/src/WebScriptController.cpp new file mode 100644 index 0000000..d2c168d --- /dev/null +++ b/WebKit/chromium/src/WebScriptController.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebScriptController.h" + +#include "V8Binding.h" +#include "V8DOMMap.h" +#include "V8Proxy.h" + +#include "WebString.h" + +using namespace WebCore; + +namespace WebKit { + +void WebScriptController::registerExtension(v8::Extension* extension) +{ + V8Proxy::registerExtension(extension, WebString()); +} + +void WebScriptController::registerExtension(v8::Extension* extension, + const WebString& schemeRestriction) +{ + V8Proxy::registerExtension(extension, schemeRestriction); +} + +void WebScriptController::registerExtension(v8::Extension* extension, + int extensionGroup) +{ + V8Proxy::registerExtension(extension, extensionGroup); +} + +void WebScriptController::enableV8SingleThreadMode() +{ + enableStringImplCache(); + enableFasterDOMStoreAccess(); +} + +void WebScriptController::flushConsoleMessages() +{ + WebCore::V8Proxy::processConsoleMessages(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebSearchableFormData.cpp b/WebKit/chromium/src/WebSearchableFormData.cpp new file mode 100644 index 0000000..eddaffe --- /dev/null +++ b/WebKit/chromium/src/WebSearchableFormData.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebSearchableFormData.h" + +#include "Document.h" +#include "FormDataBuilder.h" +#include "FormDataList.h" +#include "Frame.h" +#include "HTMLFormControlElement.h" +#include "HTMLFormElement.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "HTMLOptionElement.h" +#include "HTMLOptionsCollection.h" +#include "HTMLSelectElement.h" +#include "TextEncoding.h" +#include "WebFormElement.h" + +using namespace WebCore; + +namespace { + +// Gets the encoding for the form. +void GetFormEncoding(const HTMLFormElement* form, TextEncoding* encoding) +{ + String str(form->getAttribute(HTMLNames::accept_charsetAttr)); + str.replace(',', ' '); + Vector<String> charsets; + str.split(' ', charsets); + for (Vector<String>::const_iterator i(charsets.begin()); i != charsets.end(); ++i) { + *encoding = TextEncoding(*i); + if (encoding->isValid()) + return; + } + const Frame* frame = form->document()->frame(); + *encoding = frame ? TextEncoding(frame->loader()->encoding()) : Latin1Encoding(); +} + +// Returns true if the submit request results in an HTTP URL. +bool IsHTTPFormSubmit(const HTMLFormElement* form) +{ + String action(form->action()); + return form->document()->frame()->loader()->completeURL(action.isNull() ? "" : action).protocol() == "http"; +} + +// If the form does not have an activated submit button, the first submit +// button is returned. +HTMLFormControlElement* GetButtonToActivate(HTMLFormElement* form) +{ + HTMLFormControlElement* firstSubmitButton = 0; + for (Vector<HTMLFormControlElement*>::const_iterator i(form->formElements.begin()); i != form->formElements.end(); ++i) { + HTMLFormControlElement* formElement = *i; + if (formElement->isActivatedSubmit()) + // There's a button that is already activated for submit, return 0. + return 0; + if (!firstSubmitButton && formElement->isSuccessfulSubmitButton()) + firstSubmitButton = formElement; + } + return firstSubmitButton; +} + +// Returns true if the selected state of all the options matches the default +// selected state. +bool IsSelectInDefaultState(const HTMLSelectElement* select) +{ + const Vector<Element*>& listItems = select->listItems(); + if (select->multiple() || select->size() > 1) { + for (Vector<Element*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) { + if (!(*i)->hasLocalName(HTMLNames::optionTag)) + continue; + const HTMLOptionElement* optionElement = static_cast<const HTMLOptionElement*>(*i); + if (optionElement->selected() != optionElement->defaultSelected()) + return false; + } + return true; + } + + // The select is rendered as a combobox (called menulist in WebKit). At + // least one item is selected, determine which one. + const HTMLOptionElement* initialSelected = 0; + for (Vector<Element*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) { + if (!(*i)->hasLocalName(HTMLNames::optionTag)) + continue; + const HTMLOptionElement* optionElement = static_cast<const HTMLOptionElement*>(*i); + if (optionElement->defaultSelected()) { + // The page specified the option to select. + initialSelected = optionElement; + break; + } + if (!initialSelected) + initialSelected = optionElement; + } + return initialSelected ? initialSelected->selected() : true; +} + +// Returns true if the form element is in its default state, false otherwise. +// The default state is the state of the form element on initial load of the +// page, and varies depending upon the form element. For example, a checkbox is +// in its default state if the checked state matches the defaultChecked state. +bool IsInDefaultState(const HTMLFormControlElement* formElement) +{ + if (formElement->hasTagName(HTMLNames::inputTag)) { + const HTMLInputElement* inputElement = static_cast<const HTMLInputElement*>(formElement); + if (inputElement->inputType() == HTMLInputElement::CHECKBOX || inputElement->inputType() == HTMLInputElement::RADIO) + return inputElement->checked() == inputElement->defaultChecked(); + } else if (formElement->hasTagName(HTMLNames::selectTag)) + return IsSelectInDefaultState(static_cast<const HTMLSelectElement*>(formElement)); + return true; +} + +// If form has only one text input element, return true. If a valid input +// element is not found, return false. Additionally, the form data for all +// elements is added to enc_string and the encoding used is set in +// encoding_name. +bool HasSuitableTextElement(const HTMLFormElement* form, Vector<char>* encodedString, String* encodingName) +{ + TextEncoding encoding; + GetFormEncoding(form, &encoding); + if (!encoding.isValid()) { + // Need a valid encoding to encode the form elements. + // If the encoding isn't found webkit ends up replacing the params with + // empty strings. So, we don't try to do anything here. + return 0; + } + *encodingName = encoding.name(); + + HTMLInputElement* textElement = 0; + for (Vector<HTMLFormControlElement*>::const_iterator i(form->formElements.begin()); i != form->formElements.end(); ++i) { + HTMLFormControlElement* formElement = *i; + if (formElement->disabled() || formElement->name().isNull()) + continue; + + if (!IsInDefaultState(formElement) || formElement->hasTagName(HTMLNames::textareaTag)) + return 0; + + bool isTextElement = false; + if (formElement->hasTagName(HTMLNames::inputTag)) { + switch (static_cast<const HTMLInputElement*>(formElement)->inputType()) { + case HTMLInputElement::TEXT: + case HTMLInputElement::ISINDEX: + isTextElement = true; + break; + case HTMLInputElement::PASSWORD: + // Don't store passwords! This is most likely an https anyway. + // Fall through. + case HTMLInputElement::FILE: + // Too big, don't try to index this. + return 0; + default: + // All other input types are indexable. + break; + } + } + + FormDataList dataList(encoding); + if (!formElement->appendFormData(dataList, false)) + continue; + + const Vector<FormDataList::Item>& itemList = dataList.list(); + if (isTextElement && !itemList.isEmpty()) { + if (textElement) { + // The auto-complete bar only knows how to fill in one value. + // This form has multiple fields; don't treat it as searchable. + return false; + } + textElement = static_cast<HTMLInputElement*>(formElement); + } + for (Vector<FormDataList::Item>::const_iterator j(itemList.begin()); j != itemList.end(); ++j) { + // Handle ISINDEX / <input name=isindex> specially, but only if it's + // the first entry. + if (!encodedString->isEmpty() || j->data() != "isindex") { + if (!encodedString->isEmpty()) + encodedString->append('&'); + FormDataBuilder::encodeStringAsFormData(*encodedString, j->data()); + encodedString->append('='); + } + ++j; + if (formElement == textElement) + encodedString->append("{searchTerms}", 13); + else + FormDataBuilder::encodeStringAsFormData(*encodedString, j->data()); + } + } + + return textElement; +} + +} // namespace + +namespace WebKit { + +WebSearchableFormData::WebSearchableFormData(const WebFormElement& form) +{ + RefPtr<HTMLFormElement> formElement = form.operator PassRefPtr<HTMLFormElement>(); + const Frame* frame = formElement->document()->frame(); + if (!frame) + return; + + // Only consider forms that GET data and the action targets an http page. + if (equalIgnoringCase(formElement->getAttribute(HTMLNames::methodAttr), "post") || !IsHTTPFormSubmit(formElement.get())) + return; + + HTMLFormControlElement* firstSubmitButton = GetButtonToActivate(formElement.get()); + if (firstSubmitButton) { + // The form does not have an active submit button, make the first button + // active. We need to do this, otherwise the URL will not contain the + // name of the submit button. + firstSubmitButton->setActivatedSubmit(true); + } + Vector<char> encodedString; + String encoding; + bool hasElement = HasSuitableTextElement(formElement.get(), &encodedString, &encoding); + if (firstSubmitButton) + firstSubmitButton->setActivatedSubmit(false); + if (!hasElement) { + // Not a searchable form. + return; + } + + String action(formElement->action()); + KURL url(frame->loader()->completeURL(action.isNull() ? "" : action)); + RefPtr<FormData> formData = FormData::create(encodedString); + url.setQuery(formData->flattenToString()); + m_url = url; + m_encoding = encoding; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebSecurityOrigin.cpp b/WebKit/chromium/src/WebSecurityOrigin.cpp new file mode 100644 index 0000000..3cf7364 --- /dev/null +++ b/WebKit/chromium/src/WebSecurityOrigin.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebSecurityOrigin.h" + +#include "SecurityOrigin.h" +#include "WebString.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebSecurityOriginPrivate : public SecurityOrigin { +}; + +void WebSecurityOrigin::reset() +{ + assign(0); +} + +void WebSecurityOrigin::assign(const WebSecurityOrigin& other) +{ + WebSecurityOriginPrivate* p = const_cast<WebSecurityOriginPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +WebString WebSecurityOrigin::protocol() const +{ + ASSERT(m_private); + return m_private->protocol(); +} + +WebString WebSecurityOrigin::host() const +{ + ASSERT(m_private); + return m_private->host(); +} + +unsigned short WebSecurityOrigin::port() const +{ + ASSERT(m_private); + return m_private->port(); +} + +bool WebSecurityOrigin::isEmpty() const +{ + ASSERT(m_private); + return m_private->isEmpty(); +} + +WebString WebSecurityOrigin::toString() const +{ + ASSERT(m_private); + return m_private->toString(); +} + +WebString WebSecurityOrigin::databaseIdentifier() +{ + ASSERT(m_private); + return m_private->databaseIdentifier(); +} + +WebSecurityOrigin::WebSecurityOrigin(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin) + : m_private(static_cast<WebSecurityOriginPrivate*>(origin.releaseRef())) +{ +} + +WebSecurityOrigin& WebSecurityOrigin::operator=(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin) +{ + assign(static_cast<WebSecurityOriginPrivate*>(origin.releaseRef())); + return *this; +} + +WebSecurityOrigin::operator WTF::PassRefPtr<WebCore::SecurityOrigin>() const +{ + return PassRefPtr<SecurityOrigin>(const_cast<WebSecurityOriginPrivate*>(m_private)); +} + +void WebSecurityOrigin::assign(WebSecurityOriginPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebSecurityPolicy.cpp b/WebKit/chromium/src/WebSecurityPolicy.cpp new file mode 100644 index 0000000..c66c805 --- /dev/null +++ b/WebKit/chromium/src/WebSecurityPolicy.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebSecurityPolicy.h" + +#include "FrameLoader.h" +#include "SecurityOrigin.h" + +#include "WebString.h" +#include "WebURL.h" + +using namespace WebCore; + +namespace WebKit { + +void WebSecurityPolicy::registerURLSchemeAsLocal(const WebString& scheme) +{ + SecurityOrigin::registerURLSchemeAsLocal(scheme); +} + +void WebSecurityPolicy::registerURLSchemeAsNoAccess(const WebString& scheme) +{ + SecurityOrigin::registerURLSchemeAsNoAccess(scheme); +} + +void WebSecurityPolicy::whiteListAccessFromOrigin(const WebURL& sourceOrigin, + const WebString& destinationProtocol, + const WebString& destinationHost, + bool allowDestinationSubdomains) +{ + SecurityOrigin::whiteListAccessFromOrigin( + *SecurityOrigin::create(sourceOrigin), destinationProtocol, + destinationHost, allowDestinationSubdomains); +} + +void WebSecurityPolicy::resetOriginAccessWhiteLists() +{ + SecurityOrigin::resetOriginAccessWhiteLists(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebSettingsImpl.cpp b/WebKit/chromium/src/WebSettingsImpl.cpp new file mode 100644 index 0000000..e019653 --- /dev/null +++ b/WebKit/chromium/src/WebSettingsImpl.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebSettingsImpl.h" + +#include "FontRenderingMode.h" +#include "Settings.h" +#include "WebString.h" +#include "WebURL.h" + +#if defined(OS_WIN) +#include "RenderThemeChromiumWin.h" +#endif + +using namespace WebCore; + +namespace WebKit { + +WebSettingsImpl::WebSettingsImpl(Settings* settings) + : m_settings(settings) +{ + ASSERT(settings); +} + +void WebSettingsImpl::setStandardFontFamily(const WebString& font) +{ + m_settings->setStandardFontFamily(font); +} + +void WebSettingsImpl::setFixedFontFamily(const WebString& font) +{ + m_settings->setFixedFontFamily((String)font); +} + +void WebSettingsImpl::setSerifFontFamily(const WebString& font) +{ + m_settings->setSerifFontFamily((String)font); +} + +void WebSettingsImpl::setSansSerifFontFamily(const WebString& font) +{ + m_settings->setSansSerifFontFamily((String)font); +} + +void WebSettingsImpl::setCursiveFontFamily(const WebString& font) +{ + m_settings->setCursiveFontFamily((String)font); +} + +void WebSettingsImpl::setFantasyFontFamily(const WebString& font) +{ + m_settings->setFantasyFontFamily((String)font); +} + +void WebSettingsImpl::setDefaultFontSize(int size) +{ + m_settings->setDefaultFontSize(size); +#if defined(OS_WIN) + // RenderTheme is a singleton that needs to know the default font size to + // draw some form controls. We let it know each time the size changes. + WebCore::RenderThemeChromiumWin::setDefaultFontSize(size); +#endif +} + +void WebSettingsImpl::setDefaultFixedFontSize(int size) +{ + m_settings->setDefaultFixedFontSize(size); +} + +void WebSettingsImpl::setMinimumFontSize(int size) +{ + m_settings->setMinimumFontSize(size); +} + +void WebSettingsImpl::setMinimumLogicalFontSize(int size) +{ + m_settings->setMinimumLogicalFontSize(size); +} + +void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding) +{ + m_settings->setDefaultTextEncodingName((String)encoding); +} + +void WebSettingsImpl::setJavaScriptEnabled(bool enabled) +{ + m_settings->setJavaScriptEnabled(enabled); +} + +void WebSettingsImpl::setWebSecurityEnabled(bool enabled) +{ + m_settings->setWebSecurityEnabled(enabled); +} + +void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows) +{ + m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows); +} + +void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically) +{ + m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically); +} + +void WebSettingsImpl::setPluginsEnabled(bool enabled) +{ + m_settings->setPluginsEnabled(enabled); +} + +void WebSettingsImpl::setDOMPasteAllowed(bool enabled) +{ + m_settings->setDOMPasteAllowed(enabled); +} + +void WebSettingsImpl::setDeveloperExtrasEnabled(bool enabled) +{ + m_settings->setDeveloperExtrasEnabled(enabled); +} + +void WebSettingsImpl::setNeedsSiteSpecificQuirks(bool enabled) +{ + m_settings->setNeedsSiteSpecificQuirks(enabled); +} + +void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages) +{ + m_settings->setShrinksStandaloneImagesToFit(shrinkImages); +} + +void WebSettingsImpl::setUsesEncodingDetector(bool usesDetector) +{ + m_settings->setUsesEncodingDetector(usesDetector); +} + +void WebSettingsImpl::setTextAreasAreResizable(bool areResizable) +{ + m_settings->setTextAreasAreResizable(areResizable); +} + +void WebSettingsImpl::setJavaEnabled(bool enabled) +{ + m_settings->setJavaEnabled(enabled); +} + +void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow) +{ + m_settings->setAllowScriptsToCloseWindows(allow); +} + +void WebSettingsImpl::setUserStyleSheetLocation(const WebURL& location) +{ + m_settings->setUserStyleSheetLocation(location); +} + +void WebSettingsImpl::setUsesPageCache(bool usesPageCache) +{ + m_settings->setUsesPageCache(usesPageCache); +} + +void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled) +{ + m_settings->setDownloadableBinaryFontsEnabled(enabled); +} + +void WebSettingsImpl::setXSSAuditorEnabled(bool enabled) +{ + m_settings->setXSSAuditorEnabled(enabled); +} + +void WebSettingsImpl::setLocalStorageEnabled(bool enabled) +{ + m_settings->setLocalStorageEnabled(enabled); +} + +void WebSettingsImpl::setEditableLinkBehaviorNeverLive() +{ + // FIXME: If you ever need more behaviors than this, then we should probably + // define an enum in WebSettings.h and have a switch statement that + // translates. Until then, this is probably fine, though. + m_settings->setEditableLinkBehavior(WebCore::EditableLinkNeverLive); +} + +void WebSettingsImpl::setFontRenderingModeNormal() +{ + // FIXME: If you ever need more behaviors than this, then we should probably + // define an enum in WebSettings.h and have a switch statement that + // translates. Until then, this is probably fine, though. + m_settings->setFontRenderingMode(WebCore::NormalRenderingMode); +} + +void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled) +{ + m_settings->setShouldPaintCustomScrollbars(enabled); +} + +void WebSettingsImpl::setDatabasesEnabled(bool enabled) +{ + m_settings->setDatabasesEnabled(enabled); +} + +void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow) +{ + m_settings->setAllowUniversalAccessFromFileURLs(allow); +} + +void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded() +{ + // FIXME: If you ever need more behaviors than this, then we should probably + // define an enum in WebSettings.h and have a switch statement that + // translates. Until then, this is probably fine, though. + m_settings->setTextDirectionSubmenuInclusionBehavior(WebCore::TextDirectionSubmenuNeverIncluded); +} + +void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled) +{ + m_settings->setOfflineWebApplicationCacheEnabled(enabled); +} + +void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled) +{ + m_settings->setWebGLEnabled(enabled); +} + +void WebSettingsImpl::setGeolocationEnabled(bool enabled) +{ + m_settings->setGeolocationEnabled(enabled); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebSettingsImpl.h b/WebKit/chromium/src/WebSettingsImpl.h new file mode 100644 index 0000000..9c0f9f4 --- /dev/null +++ b/WebKit/chromium/src/WebSettingsImpl.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSettingsImpl_h +#define WebSettingsImpl_h + +// TODO(jorlow): Remove this hack once WebView is free of glue. +#include "../public/WebSettings.h" + +namespace WebCore { +class Settings; +} + +namespace WebKit { + +class WebSettingsImpl : public WebSettings { +public: + explicit WebSettingsImpl(WebCore::Settings*); + virtual ~WebSettingsImpl() { } + + virtual void setStandardFontFamily(const WebString&); + virtual void setFixedFontFamily(const WebString&); + virtual void setSerifFontFamily(const WebString&); + virtual void setSansSerifFontFamily(const WebString&); + virtual void setCursiveFontFamily(const WebString&); + virtual void setFantasyFontFamily(const WebString&); + virtual void setDefaultFontSize(int); + virtual void setDefaultFixedFontSize(int); + virtual void setMinimumFontSize(int); + virtual void setMinimumLogicalFontSize(int); + virtual void setDefaultTextEncodingName(const WebString&); + virtual void setJavaScriptEnabled(bool); + virtual void setWebSecurityEnabled(bool); + virtual void setJavaScriptCanOpenWindowsAutomatically(bool); + virtual void setLoadsImagesAutomatically(bool); + virtual void setPluginsEnabled(bool); + virtual void setDOMPasteAllowed(bool); + virtual void setDeveloperExtrasEnabled(bool); + virtual void setNeedsSiteSpecificQuirks(bool); + virtual void setShrinksStandaloneImagesToFit(bool); + virtual void setUsesEncodingDetector(bool); + virtual void setTextAreasAreResizable(bool); + virtual void setJavaEnabled(bool); + virtual void setAllowScriptsToCloseWindows(bool); + virtual void setUserStyleSheetLocation(const WebURL&); + virtual void setUsesPageCache(bool); + virtual void setDownloadableBinaryFontsEnabled(bool); + virtual void setXSSAuditorEnabled(bool); + virtual void setLocalStorageEnabled(bool); + virtual void setEditableLinkBehaviorNeverLive(); + virtual void setFontRenderingModeNormal(); + virtual void setShouldPaintCustomScrollbars(bool); + virtual void setDatabasesEnabled(bool); + virtual void setAllowUniversalAccessFromFileURLs(bool); + virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); + virtual void setOfflineWebApplicationCacheEnabled(bool); + virtual void setExperimentalWebGLEnabled(bool); + virtual void setGeolocationEnabled(bool); + +private: + WebCore::Settings* m_settings; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebSharedWorkerImpl.cpp b/WebKit/chromium/src/WebSharedWorkerImpl.cpp new file mode 100644 index 0000000..4547336 --- /dev/null +++ b/WebKit/chromium/src/WebSharedWorkerImpl.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebSharedWorkerImpl.h" + +#include "GenericWorkerTask.h" +#include "KURL.h" +#include "MessageEvent.h" +#include "MessagePortChannel.h" +#include "PlatformMessagePortChannel.h" +#include "ScriptExecutionContext.h" +#include "SharedWorkerContext.h" +#include "SharedWorkerThread.h" + +#include "WebMessagePortChannel.h" +#include "WebString.h" +#include "WebURL.h" + +using namespace WebCore; + +namespace WebKit { + +#if ENABLE(SHARED_WORKERS) + +WebSharedWorkerImpl::WebSharedWorkerImpl(WebCommonWorkerClient* client) + : m_client(client) +{ +} + +WebSharedWorkerImpl::~WebSharedWorkerImpl() +{ +} + +bool WebSharedWorkerImpl::isStarted() +{ + // Should not ever be called from the worker thread (this API is only called on WebSharedWorkerProxy on the renderer thread). + ASSERT_NOT_REACHED(); + return workerThread(); +} + +void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel, ConnectListener* listener) +{ + // Convert the WebMessagePortChanel to a WebCore::MessagePortChannel. + RefPtr<PlatformMessagePortChannel> platform_channel = + PlatformMessagePortChannel::create(webChannel); + webChannel->setClient(platform_channel.get()); + OwnPtr<MessagePortChannel> channel = + MessagePortChannel::create(platform_channel); + + workerThread()->runLoop().postTask( + createCallbackTask(&connectTask, this, channel.release())); + if (listener) + listener->connected(); +} + +void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, WebSharedWorkerImpl* worker, PassOwnPtr<MessagePortChannel> channel) +{ + // Wrap the passed-in channel in a MessagePort, and send it off via a connect event. + RefPtr<MessagePort> port = MessagePort::create(*context); + port->entangle(channel.release()); + ASSERT(context->isWorkerContext()); + WorkerContext* workerContext = static_cast<WorkerContext*>(context); + ASSERT(workerContext->isSharedWorkerContext()); + workerContext->toSharedWorkerContext()->dispatchEvent(createConnectEvent(port)); +} + +void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode) +{ + initializeLoader(url); + setWorkerThread(SharedWorkerThread::create(name, url, userAgent, sourceCode, *this, *this)); + workerThread()->start(); +} + +void WebSharedWorkerImpl::terminateWorkerContext() +{ + stopWorkerThread(); +} + +void WebSharedWorkerImpl::clientDestroyed() +{ + m_client = 0; +} + +WebWorkerClient* WebSharedWorkerImpl::client() +{ + // We should never be asked for a WebWorkerClient (only dedicated workers have an associated WebWorkerClient). + // It should not be possible for SharedWorkerContext to generate an API call outside those supported by WebCommonWorkerClient. + ASSERT_NOT_REACHED(); + return 0; +} + +WebSharedWorker* WebSharedWorker::create(WebCommonWorkerClient* client) +{ + return new WebSharedWorkerImpl(client); +} + +#endif // ENABLE(SHARED_WORKERS) + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebSharedWorkerImpl.h b/WebKit/chromium/src/WebSharedWorkerImpl.h new file mode 100644 index 0000000..7c10d76 --- /dev/null +++ b/WebKit/chromium/src/WebSharedWorkerImpl.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebSharedWorkerImpl_h +#define WebSharedWorkerImpl_h + +#include "WebSharedWorker.h" + +#if ENABLE(SHARED_WORKERS) + +#include "ScriptExecutionContext.h" + +#include "WebWorkerBase.h" + +namespace WebKit { + +// This class is used by the worker process code to talk to the WebCore::SharedWorker implementation. +// It can't use it directly since it uses WebKit types, so this class converts the data types. +// When the WebCore::SharedWorker object wants to call WebCore::WorkerReportingProxy, this class will +// convert to Chrome data types first and then call the supplied WebCommonWorkerClient. +class WebSharedWorkerImpl : public WebWorkerBase, public WebSharedWorker { +public: + explicit WebSharedWorkerImpl(WebCommonWorkerClient* client); + + // WebSharedWorker methods: + virtual bool isStarted(); + virtual void startWorkerContext(const WebURL&, const WebString& name, const WebString& userAgent, const WebString& sourceCode); + virtual void connect(WebMessagePortChannel*, ConnectListener*); + virtual void terminateWorkerContext(); + virtual void clientDestroyed(); + + // WebWorkerBase methods: + WebWorkerClient* client(); + WebCommonWorkerClient* commonClient() { return m_client; } + +private: + virtual ~WebSharedWorkerImpl(); + + static void connectTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl*, PassOwnPtr<WebCore::MessagePortChannel>); + + WebCommonWorkerClient* m_client; +}; + +} // namespace WebKit + +#endif // ENABLE(SHARED_WORKERS) + +#endif diff --git a/WebKit/chromium/src/WebStorageAreaImpl.cpp b/WebKit/chromium/src/WebStorageAreaImpl.cpp new file mode 100644 index 0000000..f24bee3 --- /dev/null +++ b/WebKit/chromium/src/WebStorageAreaImpl.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebStorageAreaImpl.h" + +#if ENABLE(DOM_STORAGE) + +#include "ExceptionCode.h" + +#include "WebString.h" +#include "WebURL.h" + +namespace WebKit { + +const WebURL* WebStorageAreaImpl::storageEventURL = 0; + +WebStorageAreaImpl::WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea) + : m_storageArea(storageArea) +{ +} + +WebStorageAreaImpl::~WebStorageAreaImpl() +{ +} + +unsigned WebStorageAreaImpl::length() +{ + return m_storageArea->length(); +} + +WebString WebStorageAreaImpl::key(unsigned index) +{ + return m_storageArea->key(index); +} + +WebString WebStorageAreaImpl::getItem(const WebString& key) +{ + return m_storageArea->getItem(key); +} + +void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException) +{ + int exceptionCode = 0; + + ScopedStorageEventURL scope(url); + m_storageArea->setItem(key, value, exceptionCode, 0); + + if (exceptionCode) { + ASSERT(exceptionCode == WebCore::QUOTA_EXCEEDED_ERR); + quotaException = true; + } else + quotaException = false; +} + +void WebStorageAreaImpl::removeItem(const WebString& key, const WebURL& url) +{ + ScopedStorageEventURL scope(url); + m_storageArea->removeItem(key, 0); +} + +void WebStorageAreaImpl::clear(const WebURL& url) +{ + ScopedStorageEventURL scope(url); + m_storageArea->clear(0); +} + +} // namespace WebKit + +#endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/chromium/src/WebStorageAreaImpl.h b/WebKit/chromium/src/WebStorageAreaImpl.h new file mode 100644 index 0000000..e1f74e0 --- /dev/null +++ b/WebKit/chromium/src/WebStorageAreaImpl.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebStorageAreaImpl_h +#define WebStorageAreaImpl_h + +#if ENABLE(DOM_STORAGE) + +#include "StorageAreaImpl.h" +#include "WebStorageArea.h" + +namespace WebKit { + +class WebStorageAreaImpl : public WebStorageArea { +public: + WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea); + virtual ~WebStorageAreaImpl(); + virtual unsigned length(); + virtual WebString key(unsigned index); + virtual WebString getItem(const WebString& key); + virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException); + virtual void removeItem(const WebString& key, const WebURL& url); + virtual void clear(const WebURL& url); + + // For storage events in single-process mode and test shell. + static const WebURL* currentStorageEventURL() { return storageEventURL; } + +private: + class ScopedStorageEventURL { + public: + ScopedStorageEventURL(const WebURL& url) + { + // FIXME: Once storage events are fired async in WebKit (as they should + // be) this can be ASSERTed to be 0 rather than saved. + m_existingStorageEventURL = storageEventURL; + storageEventURL = &url; + } + ~ScopedStorageEventURL() + { + storageEventURL = m_existingStorageEventURL; + } + + private: + const WebURL* m_existingStorageEventURL; + }; + + static const WebURL* storageEventURL; + + RefPtr<WebCore::StorageArea> m_storageArea; +}; + +} // namespace WebKit + +#endif // ENABLE(DOM_STORAGE) + +#endif // WebStorageAreaImpl_h diff --git a/WebKit/chromium/src/WebStorageEventDispatcherImpl.cpp b/WebKit/chromium/src/WebStorageEventDispatcherImpl.cpp new file mode 100644 index 0000000..515a423 --- /dev/null +++ b/WebKit/chromium/src/WebStorageEventDispatcherImpl.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebStorageEventDispatcherImpl.h" + +#if ENABLE(DOM_STORAGE) + +#include "KURL.h" +#include "SecurityOrigin.h" + +#include "WebStorageAreaImpl.h" +#include "WebURL.h" + +namespace WebKit { + +extern const char* pageGroupName; + +WebStorageEventDispatcher* WebStorageEventDispatcher::create() +{ + return new WebStorageEventDispatcherImpl(); +} + +WebStorageEventDispatcherImpl::WebStorageEventDispatcherImpl() + : m_eventDispatcher(new WebCore::StorageEventDispatcherImpl(pageGroupName)) +{ + ASSERT(m_eventDispatcher); +} + +void WebStorageEventDispatcherImpl::dispatchStorageEvent(const WebString& key, const WebString& oldValue, + const WebString& newValue, const WebString& origin, + const WebURL& passedInURL, bool isLocalStorage) +{ + // Hack for single-process mode and test shell. + const WebURL* storageAreaImplURL = WebStorageAreaImpl::currentStorageEventURL(); + const WebURL& url = storageAreaImplURL ? *storageAreaImplURL : passedInURL; + + WebCore::StorageType storageType = isLocalStorage ? WebCore::LocalStorage : WebCore::SessionStorage; + RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromString(origin); + m_eventDispatcher->dispatchStorageEvent(key, oldValue, newValue, securityOrigin.get(), url, storageType); +} + +} // namespace WebKit + +#endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/chromium/src/WebStorageEventDispatcherImpl.h b/WebKit/chromium/src/WebStorageEventDispatcherImpl.h new file mode 100644 index 0000000..6848b99 --- /dev/null +++ b/WebKit/chromium/src/WebStorageEventDispatcherImpl.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebStorageEventDispatcherImpl_h +#define WebStorageEventDispatcherImpl_h + +#if ENABLE(DOM_STORAGE) + +#include "StorageEventDispatcherImpl.h" +#include "WebStorageEventDispatcher.h" +#include <wtf/OwnPtr.h> + +namespace WebKit { + +class WebStorageEventDispatcherImpl : public WebStorageEventDispatcher { +public: + WebStorageEventDispatcherImpl(); + + virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue, + const WebString& newValue, const WebString& origin, + const WebURL&, bool isLocalStorage); + +private: + OwnPtr<WebCore::StorageEventDispatcherImpl> m_eventDispatcher; +}; + +} // namespace WebKit + +#endif // ENABLE(DOM_STORAGE) + +#endif // WebStorageEventDispatcherImpl_h diff --git a/WebKit/chromium/src/WebStorageNamespaceImpl.cpp b/WebKit/chromium/src/WebStorageNamespaceImpl.cpp new file mode 100644 index 0000000..e6f6548 --- /dev/null +++ b/WebKit/chromium/src/WebStorageNamespaceImpl.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebStorageNamespaceImpl.h" + +#if ENABLE(DOM_STORAGE) + +#include "SecurityOrigin.h" + +#include "WebStorageAreaImpl.h" +#include "WebString.h" + +namespace WebKit { + +WebStorageNamespace* WebStorageNamespace::createLocalStorageNamespace(const WebString& path, unsigned quota) +{ + return new WebStorageNamespaceImpl(WebCore::StorageNamespaceImpl::localStorageNamespace(path, quota)); +} + +WebStorageNamespace* WebStorageNamespace::createSessionStorageNamespace() +{ + return new WebStorageNamespaceImpl(WebCore::StorageNamespaceImpl::sessionStorageNamespace()); +} + +WebStorageNamespaceImpl::WebStorageNamespaceImpl(PassRefPtr<WebCore::StorageNamespace> storageNamespace) + : m_storageNamespace(storageNamespace) +{ +} + +WebStorageNamespaceImpl::~WebStorageNamespaceImpl() +{ +} + +WebStorageArea* WebStorageNamespaceImpl::createStorageArea(const WebString& originString) +{ + WebCore::String originWebCoreString = originString; + if (originWebCoreString == "file://") { + // FIXME: We should really be passing around WebSecurityOrigin objects + // to represent security origins instead of strings. One issue + // with using strings is that createFromString(toString) does + // not round-trip for file URLs because file:// looks like a + // directory (which is sandboxed). + // + // For the time being, we work around this issue by using "file:///a", + // which does not look like a directory. We should fix this when + // jorlow gets back from vactation. + originWebCoreString = "file:///a"; + } + RefPtr<WebCore::SecurityOrigin> origin = WebCore::SecurityOrigin::createFromString(originWebCoreString); + return new WebStorageAreaImpl(m_storageNamespace->storageArea(origin.release())); +} + +WebStorageNamespace* WebStorageNamespaceImpl::copy() +{ + return new WebStorageNamespaceImpl(m_storageNamespace->copy()); +} + +void WebStorageNamespaceImpl::close() +{ + m_storageNamespace->close(); +} + +} // namespace WebKit + +#endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/chromium/src/WebStorageNamespaceImpl.h b/WebKit/chromium/src/WebStorageNamespaceImpl.h new file mode 100644 index 0000000..4e82c21 --- /dev/null +++ b/WebKit/chromium/src/WebStorageNamespaceImpl.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebStorageNamespaceImpl_h +#define WebStorageNamespaceImpl_h + +#if ENABLE(DOM_STORAGE) + +#include "StorageNamespaceImpl.h" +#include "WebStorageNamespace.h" + +namespace WebKit { + +class WebStorageNamespaceImpl : public WebStorageNamespace { +public: + WebStorageNamespaceImpl(PassRefPtr<WebCore::StorageNamespace> storageNamespace); + virtual ~WebStorageNamespaceImpl(); + virtual WebStorageArea* createStorageArea(const WebString& origin); + virtual WebStorageNamespace* copy(); + virtual void close(); + +private: + RefPtr<WebCore::StorageNamespace> m_storageNamespace; +}; + +} // namespace WebKit + +#endif // ENABLE(DOM_STORAGE) + +#endif // WebStorageNamespaceImpl_h diff --git a/WebKit/chromium/src/WebString.cpp b/WebKit/chromium/src/WebString.cpp new file mode 100644 index 0000000..f45e05f --- /dev/null +++ b/WebKit/chromium/src/WebString.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebString.h" + +#include "AtomicString.h" +#include "CString.h" +#include "PlatformString.h" + +#include "WebCString.h" + +namespace WebKit { + +class WebStringPrivate : public WebCore::StringImpl { +}; + +void WebString::reset() +{ + if (m_private) { + m_private->deref(); + m_private = 0; + } +} + +void WebString::assign(const WebString& other) +{ + assign(const_cast<WebStringPrivate*>(other.m_private)); +} + +void WebString::assign(const WebUChar* data, size_t length) +{ + assign(static_cast<WebStringPrivate*>( + WebCore::StringImpl::create(data, length).get())); +} + +size_t WebString::length() const +{ + return m_private ? const_cast<WebStringPrivate*>(m_private)->length() : 0; +} + +const WebUChar* WebString::data() const +{ + return m_private ? const_cast<WebStringPrivate*>(m_private)->characters() : 0; +} + +WebCString WebString::utf8() const +{ + return WebCore::String(m_private).utf8(); +} + +WebString WebString::fromUTF8(const char* data, size_t length) +{ + return WebCore::String::fromUTF8(data, length); +} + +WebString WebString::fromUTF8(const char* data) +{ + return WebCore::String::fromUTF8(data); +} + +WebString::WebString(const WebCore::String& s) + : m_private(static_cast<WebStringPrivate*>(s.impl())) +{ + if (m_private) + m_private->ref(); +} + +WebString& WebString::operator=(const WebCore::String& s) +{ + assign(static_cast<WebStringPrivate*>(s.impl())); + return *this; +} + +WebString::operator WebCore::String() const +{ + return m_private; +} + +WebString::WebString(const WebCore::AtomicString& s) + : m_private(0) +{ + assign(s.string()); +} + +WebString& WebString::operator=(const WebCore::AtomicString& s) +{ + assign(s.string()); + return *this; +} + +WebString::operator WebCore::AtomicString() const +{ + return WebCore::AtomicString(static_cast<WebCore::StringImpl *>(m_private)); +} + +void WebString::assign(WebStringPrivate* p) +{ + // Take care to handle the case where m_private == p + if (p) + p->ref(); + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebURL.cpp b/WebKit/chromium/src/WebURL.cpp new file mode 100644 index 0000000..feb92c1 --- /dev/null +++ b/WebKit/chromium/src/WebURL.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebURL.h" + +#include "KURL.h" + +namespace WebKit { + +WebURL::WebURL(const WebCore::KURL& url) + : m_spec(url.utf8String()) + , m_parsed(url.parsed()) + , m_isValid(url.isValid()) +{ +} + +WebURL& WebURL::operator=(const WebCore::KURL& url) +{ + m_spec = url.utf8String(); + m_parsed = url.parsed(); + m_isValid = url.isValid(); + return *this; +} + +WebURL::operator WebCore::KURL() const +{ + return WebCore::KURL(m_spec, m_parsed, m_isValid); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebURLError.cpp b/WebKit/chromium/src/WebURLError.cpp new file mode 100644 index 0000000..a038aee --- /dev/null +++ b/WebKit/chromium/src/WebURLError.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebURLError.h" + +#include "CString.h" +#include "KURL.h" +#include "ResourceError.h" + +using namespace WebCore; + +namespace WebKit { + +WebURLError::WebURLError(const ResourceError& error) +{ + *this = error; +} + +WebURLError& WebURLError::operator=(const ResourceError& error) +{ + if (error.isNull()) + *this = WebURLError(); + else { + domain = error.domain(); + reason = error.errorCode(); + unreachableURL = KURL(ParsedURLString, error.failingURL()); + } + return *this; +} + +WebURLError::operator ResourceError() const +{ + if (!reason) + return ResourceError(); + CString spec = unreachableURL.spec(); + return ResourceError(domain, reason, + String::fromUTF8(spec.data(), spec.length()), + String()); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebURLRequest.cpp b/WebKit/chromium/src/WebURLRequest.cpp new file mode 100644 index 0000000..46fa842 --- /dev/null +++ b/WebKit/chromium/src/WebURLRequest.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebURLRequest.h" + +#include "ResourceRequest.h" + +#include "WebHTTPBody.h" +#include "WebHTTPHeaderVisitor.h" +#include "WebURL.h" +#include "WebURLRequestPrivate.h" + +using namespace WebCore; + +namespace WebKit { + +// The standard implementation of WebURLRequestPrivate, which maintains +// ownership of a ResourceRequest instance. +class WebURLRequestPrivateImpl : public WebURLRequestPrivate { +public: + WebURLRequestPrivateImpl() + { + m_resourceRequest = &m_resourceRequestAllocation; + } + + WebURLRequestPrivateImpl(const WebURLRequestPrivate* p) + : m_resourceRequestAllocation(*p->m_resourceRequest) + { + m_resourceRequest = &m_resourceRequestAllocation; + } + + virtual void dispose() { delete this; } + + ResourceRequest m_resourceRequestAllocation; +}; + +void WebURLRequest::initialize() +{ + assign(new WebURLRequestPrivateImpl()); +} + +void WebURLRequest::reset() +{ + assign(0); +} + +void WebURLRequest::assign(const WebURLRequest& r) +{ + if (&r != this) + assign(r.m_private ? new WebURLRequestPrivateImpl(r.m_private) : 0); +} + +bool WebURLRequest::isNull() const +{ + return !m_private || m_private->m_resourceRequest->isNull(); +} + +WebURL WebURLRequest::url() const +{ + return m_private->m_resourceRequest->url(); +} + +void WebURLRequest::setURL(const WebURL& url) +{ + m_private->m_resourceRequest->setURL(url); +} + +WebURL WebURLRequest::firstPartyForCookies() const +{ + return m_private->m_resourceRequest->firstPartyForCookies(); +} + +void WebURLRequest::setFirstPartyForCookies(const WebURL& firstPartyForCookies) +{ + m_private->m_resourceRequest->setFirstPartyForCookies(firstPartyForCookies); +} + +bool WebURLRequest::allowCookies() const +{ + return m_private->m_resourceRequest->allowCookies(); +} + +void WebURLRequest::setAllowCookies(bool allowCookies) +{ + m_private->m_resourceRequest->setAllowCookies(allowCookies); +} + +bool WebURLRequest::allowStoredCredentials() const +{ + return m_private->m_allowStoredCredentials; +} + +void WebURLRequest::setAllowStoredCredentials(bool allowStoredCredentials) +{ + m_private->m_allowStoredCredentials = allowStoredCredentials; +} + +WebURLRequest::CachePolicy WebURLRequest::cachePolicy() const +{ + return static_cast<WebURLRequest::CachePolicy>( + m_private->m_resourceRequest->cachePolicy()); +} + +void WebURLRequest::setCachePolicy(CachePolicy cachePolicy) +{ + m_private->m_resourceRequest->setCachePolicy( + static_cast<ResourceRequestCachePolicy>(cachePolicy)); +} + +WebString WebURLRequest::httpMethod() const +{ + return m_private->m_resourceRequest->httpMethod(); +} + +void WebURLRequest::setHTTPMethod(const WebString& httpMethod) +{ + m_private->m_resourceRequest->setHTTPMethod(httpMethod); +} + +WebString WebURLRequest::httpHeaderField(const WebString& name) const +{ + return m_private->m_resourceRequest->httpHeaderField(name); +} + +void WebURLRequest::setHTTPHeaderField(const WebString& name, const WebString& value) +{ + m_private->m_resourceRequest->setHTTPHeaderField(name, value); +} + +void WebURLRequest::addHTTPHeaderField(const WebString& name, const WebString& value) +{ + m_private->m_resourceRequest->addHTTPHeaderField(name, value); +} + +void WebURLRequest::clearHTTPHeaderField(const WebString& name) +{ + // FIXME: Add a clearHTTPHeaderField method to ResourceRequest. + const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields(); + const_cast<HTTPHeaderMap*>(&map)->remove(name); +} + +void WebURLRequest::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const +{ + const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields(); + for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) + visitor->visitHeader(it->first, it->second); +} + +WebHTTPBody WebURLRequest::httpBody() const +{ + return WebHTTPBody(m_private->m_resourceRequest->httpBody()); +} + +void WebURLRequest::setHTTPBody(const WebHTTPBody& httpBody) +{ + m_private->m_resourceRequest->setHTTPBody(httpBody); +} + +bool WebURLRequest::reportUploadProgress() const +{ + return m_private->m_resourceRequest->reportUploadProgress(); +} + +void WebURLRequest::setReportUploadProgress(bool reportUploadProgress) +{ + m_private->m_resourceRequest->setReportUploadProgress(reportUploadProgress); +} + +WebURLRequest::TargetType WebURLRequest::targetType() const +{ + return static_cast<TargetType>(m_private->m_resourceRequest->targetType()); +} + +void WebURLRequest::setTargetType(TargetType targetType) +{ + m_private->m_resourceRequest->setTargetType( + static_cast<ResourceRequest::TargetType>(targetType)); +} + +int WebURLRequest::requestorID() const +{ + return m_private->m_resourceRequest->requestorID(); +} + +void WebURLRequest::setRequestorID(int requestorID) +{ + m_private->m_resourceRequest->setRequestorID(requestorID); +} + +int WebURLRequest::requestorProcessID() const +{ + return m_private->m_resourceRequest->requestorProcessID(); +} + +void WebURLRequest::setRequestorProcessID(int requestorProcessID) +{ + m_private->m_resourceRequest->setRequestorProcessID(requestorProcessID); +} + +int WebURLRequest::appCacheHostID() const +{ + return m_private->m_resourceRequest->appCacheHostID(); +} + +void WebURLRequest::setAppCacheHostID(int appCacheHostID) +{ + m_private->m_resourceRequest->setAppCacheHostID(appCacheHostID); +} + +ResourceRequest& WebURLRequest::toMutableResourceRequest() +{ + ASSERT(m_private); + ASSERT(m_private->m_resourceRequest); + + return *m_private->m_resourceRequest; +} + +const ResourceRequest& WebURLRequest::toResourceRequest() const +{ + ASSERT(m_private); + ASSERT(m_private->m_resourceRequest); + + return *m_private->m_resourceRequest; +} + +void WebURLRequest::assign(WebURLRequestPrivate* p) +{ + // Subclasses may call this directly so a self-assignment check is needed + // here as well as in the public assign method. + if (m_private == p) + return; + if (m_private) + m_private->dispose(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebURLRequestPrivate.h b/WebKit/chromium/src/WebURLRequestPrivate.h new file mode 100644 index 0000000..2f7c25f --- /dev/null +++ b/WebKit/chromium/src/WebURLRequestPrivate.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURLRequestPrivate_h +#define WebURLRequestPrivate_h + +namespace WebCore { class ResourceRequest; } + +namespace WebKit { + +class WebURLRequestPrivate { +public: + WebURLRequestPrivate() : m_resourceRequest(0), m_allowStoredCredentials(true) { } + + // Called by WebURLRequest when it no longer needs this object. + virtual void dispose() = 0; + + WebCore::ResourceRequest* m_resourceRequest; + bool m_allowStoredCredentials; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebURLResponse.cpp b/WebKit/chromium/src/WebURLResponse.cpp new file mode 100644 index 0000000..49f07f9 --- /dev/null +++ b/WebKit/chromium/src/WebURLResponse.cpp @@ -0,0 +1,269 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebURLResponse.h" + +#include "ResourceResponse.h" + +#include "WebHTTPHeaderVisitor.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebURLResponsePrivate.h" + +using namespace WebCore; + +namespace WebKit { + +// The standard implementation of WebURLResponsePrivate, which maintains +// ownership of a ResourceResponse instance. +class WebURLResponsePrivateImpl : public WebURLResponsePrivate { +public: + WebURLResponsePrivateImpl() + { + m_resourceResponse = &m_resourceResponseAllocation; + } + + WebURLResponsePrivateImpl(const WebURLResponsePrivate* p) + : m_resourceResponseAllocation(*p->m_resourceResponse) + { + m_resourceResponse = &m_resourceResponseAllocation; + } + + virtual void dispose() { delete this; } + + ResourceResponse m_resourceResponseAllocation; +}; + +void WebURLResponse::initialize() +{ + assign(new WebURLResponsePrivateImpl()); +} + +void WebURLResponse::reset() +{ + assign(0); +} + +void WebURLResponse::assign(const WebURLResponse& r) +{ + if (&r != this) + assign(r.m_private ? new WebURLResponsePrivateImpl(r.m_private) : 0); +} + +bool WebURLResponse::isNull() const +{ + return !m_private || m_private->m_resourceResponse->isNull(); +} + +WebURL WebURLResponse::url() const +{ + return m_private->m_resourceResponse->url(); +} + +void WebURLResponse::setURL(const WebURL& url) +{ + m_private->m_resourceResponse->setURL(url); +} + +WebString WebURLResponse::mimeType() const +{ + return m_private->m_resourceResponse->mimeType(); +} + +void WebURLResponse::setMIMEType(const WebString& mimeType) +{ + m_private->m_resourceResponse->setMimeType(mimeType); +} + +long long WebURLResponse::expectedContentLength() const +{ + return m_private->m_resourceResponse->expectedContentLength(); +} + +void WebURLResponse::setExpectedContentLength(long long expectedContentLength) +{ + m_private->m_resourceResponse->setExpectedContentLength(expectedContentLength); +} + +WebString WebURLResponse::textEncodingName() const +{ + return m_private->m_resourceResponse->textEncodingName(); +} + +void WebURLResponse::setTextEncodingName(const WebString& textEncodingName) +{ + m_private->m_resourceResponse->setTextEncodingName(textEncodingName); +} + +WebString WebURLResponse::suggestedFileName() const +{ + return m_private->m_resourceResponse->suggestedFilename(); +} + +void WebURLResponse::setSuggestedFileName(const WebString& suggestedFileName) +{ + m_private->m_resourceResponse->setSuggestedFilename(suggestedFileName); +} + +int WebURLResponse::httpStatusCode() const +{ + return m_private->m_resourceResponse->httpStatusCode(); +} + +void WebURLResponse::setHTTPStatusCode(int httpStatusCode) +{ + m_private->m_resourceResponse->setHTTPStatusCode(httpStatusCode); +} + +WebString WebURLResponse::httpStatusText() const +{ + return m_private->m_resourceResponse->httpStatusText(); +} + +void WebURLResponse::setHTTPStatusText(const WebString& httpStatusText) +{ + m_private->m_resourceResponse->setHTTPStatusText(httpStatusText); +} + +WebString WebURLResponse::httpHeaderField(const WebString& name) const +{ + return m_private->m_resourceResponse->httpHeaderField(name); +} + +void WebURLResponse::setHTTPHeaderField(const WebString& name, const WebString& value) +{ + m_private->m_resourceResponse->setHTTPHeaderField(name, value); +} + +void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString& value) +{ + // FIXME: Add an addHTTPHeaderField method to ResourceResponse. + const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); + String valueStr(value); + pair<HTTPHeaderMap::iterator, bool> result = + const_cast<HTTPHeaderMap*>(&map)->add(name, valueStr); + if (!result.second) + result.first->second += ", " + valueStr; +} + +void WebURLResponse::clearHTTPHeaderField(const WebString& name) +{ + // FIXME: Add a clearHTTPHeaderField method to ResourceResponse. + const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); + const_cast<HTTPHeaderMap*>(&map)->remove(name); +} + +void WebURLResponse::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const +{ + const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); + for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) + visitor->visitHeader(it->first, it->second); +} + +double WebURLResponse::lastModifiedDate() const +{ + return static_cast<double>(m_private->m_resourceResponse->lastModifiedDate()); +} + +void WebURLResponse::setLastModifiedDate(double lastModifiedDate) +{ + m_private->m_resourceResponse->setLastModifiedDate(static_cast<time_t>(lastModifiedDate)); +} + +bool WebURLResponse::isContentFiltered() const +{ + return m_private->m_resourceResponse->isContentFiltered(); +} + +void WebURLResponse::setIsContentFiltered(bool isContentFiltered) +{ + m_private->m_resourceResponse->setIsContentFiltered(isContentFiltered); +} + +long long WebURLResponse::appCacheID() const +{ + return m_private->m_resourceResponse->appCacheID(); +} + +void WebURLResponse::setAppCacheID(long long appCacheID) +{ + m_private->m_resourceResponse->setAppCacheID(appCacheID); +} + +WebURL WebURLResponse::appCacheManifestURL() const +{ + return m_private->m_resourceResponse->appCacheManifestURL(); +} + +void WebURLResponse::setAppCacheManifestURL(const WebURL& url) +{ + m_private->m_resourceResponse->setAppCacheManifestURL(url); +} + +WebCString WebURLResponse::securityInfo() const +{ + // FIXME: getSecurityInfo is misnamed. + return m_private->m_resourceResponse->getSecurityInfo(); +} + +void WebURLResponse::setSecurityInfo(const WebCString& securityInfo) +{ + m_private->m_resourceResponse->setSecurityInfo(securityInfo); +} + +ResourceResponse& WebURLResponse::toMutableResourceResponse() +{ + ASSERT(m_private); + ASSERT(m_private->m_resourceResponse); + + return *m_private->m_resourceResponse; +} + +const ResourceResponse& WebURLResponse::toResourceResponse() const +{ + ASSERT(m_private); + ASSERT(m_private->m_resourceResponse); + + return *m_private->m_resourceResponse; +} + +void WebURLResponse::assign(WebURLResponsePrivate* p) +{ + // Subclasses may call this directly so a self-assignment check is needed + // here as well as in the public assign method. + if (m_private == p) + return; + if (m_private) + m_private->dispose(); + m_private = p; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebURLResponsePrivate.h b/WebKit/chromium/src/WebURLResponsePrivate.h new file mode 100644 index 0000000..716c8db --- /dev/null +++ b/WebKit/chromium/src/WebURLResponsePrivate.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebURLResponsePrivate_h +#define WebURLResponsePrivate_h + +namespace WebCore { class ResourceResponse; } + +namespace WebKit { + +class WebURLResponsePrivate { +public: + WebURLResponsePrivate() : m_resourceResponse(0) { } + + // Called by WebURLResponse when it no longer needs this object. + virtual void dispose() = 0; + + WebCore::ResourceResponse* m_resourceResponse; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp new file mode 100644 index 0000000..357cdca --- /dev/null +++ b/WebKit/chromium/src/WebViewImpl.cpp @@ -0,0 +1,1798 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebViewImpl.h" + +#include "AutocompletePopupMenuClient.h" +#include "AXObjectCache.h" +#include "ContextMenu.h" +#include "ContextMenuController.h" +#include "ContextMenuItem.h" +#include "CSSStyleSelector.h" +#include "CSSValueKeywords.h" +#include "Cursor.h" +#include "Document.h" +#include "DocumentLoader.h" +#include "DOMUtilitiesPrivate.h" +#include "DragController.h" +#include "DragData.h" +#include "Editor.h" +#include "EventHandler.h" +#include "FocusController.h" +#include "FontDescription.h" +#include "FrameLoader.h" +#include "FrameTree.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HitTestResult.h" +#include "HTMLInputElement.h" +#include "HTMLMediaElement.h" +#include "HTMLNames.h" +#include "Image.h" +#include "InspectorController.h" +#include "IntRect.h" +#include "KeyboardCodes.h" +#include "KeyboardEvent.h" +#include "MIMETypeRegistry.h" +#include "NodeRenderStyle.h" +#include "Page.h" +#include "PageGroup.h" +#include "Pasteboard.h" +#include "PlatformContextSkia.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformMouseEvent.h" +#include "PlatformWheelEvent.h" +#include "PluginInfoStore.h" +#include "PopupMenuChromium.h" +#include "PopupMenuClient.h" +#include "ProgressTracker.h" +#include "RenderView.h" +#include "ResourceHandle.h" +#include "SecurityOrigin.h" +#include "SelectionController.h" +#include "Settings.h" +#include "TypingCommand.h" +#include "WebAccessibilityObject.h" +#include "WebDevToolsAgentPrivate.h" +#include "WebDragData.h" +#include "WebFrameImpl.h" +#include "WebInputEvent.h" +#include "WebInputEventConversion.h" +#include "WebMediaPlayerAction.h" +#include "WebNode.h" +#include "WebPoint.h" +#include "WebPopupMenuImpl.h" +#include "WebRect.h" +#include "WebSettingsImpl.h" +#include "WebString.h" +#include "WebVector.h" +#include "WebViewClient.h" + +#if PLATFORM(WIN_OS) +#include "KeyboardCodesWin.h" +#include "RenderThemeChromiumWin.h" +#else +#if PLATFORM(LINUX) +#include "RenderThemeChromiumLinux.h" +#endif +#include "KeyboardCodesPosix.h" +#include "RenderTheme.h" +#endif + +// Get rid of WTF's pow define so we can use std::pow. +#undef pow +#include <cmath> // for std::pow + +using namespace WebCore; + +namespace WebKit { + +// Change the text zoom level by kTextSizeMultiplierRatio each time the user +// zooms text in or out (ie., change by 20%). The min and max values limit +// text zoom to half and 3x the original text size. These three values match +// those in Apple's port in WebKit/WebKit/WebView/WebView.mm +static const double textSizeMultiplierRatio = 1.2; +static const double minTextSizeMultiplier = 0.5; +static const double maxTextSizeMultiplier = 3.0; + +// The group name identifies a namespace of pages. Page group is used on OSX +// for some programs that use HTML views to display things that don't seem like +// web pages to the user (so shouldn't have visited link coloring). We only use +// one page group. +const char* pageGroupName = "default"; + +// Ensure that the WebDragOperation enum values stay in sync with the original +// DragOperation constants. +#define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ + COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) +COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationPrivate); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); + +// Note that focusOnShow is false so that the autocomplete popup is shown not +// activated. We need the page to still have focus so the user can keep typing +// while the popup is showing. +static const PopupContainerSettings autocompletePopupSettings = { + false, // focusOnShow + false, // setTextOnIndexChange + false, // acceptOnAbandon + true, // loopSelectionNavigation + true, // restrictWidthOfListBox. Same as other browser (Fx, IE, and safari) + // For autocomplete, we use the direction of the input field as the direction + // of the popup items. The main reason is to keep the display of items in + // drop-down the same as the items in the input field. + PopupContainerSettings::DOMElementDirection, +}; + +// WebView ---------------------------------------------------------------- + +WebView* WebView::create(WebViewClient* client) +{ + return new WebViewImpl(client); +} + +void WebView::updateVisitedLinkState(unsigned long long linkHash) +{ + Page::visitedStateChanged(PageGroup::pageGroup(pageGroupName), linkHash); +} + +void WebView::resetVisitedLinkState() +{ + Page::allVisitedStateChanged(PageGroup::pageGroup(pageGroupName)); +} + +void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient) +{ + // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame + // and releases that reference once the corresponding Frame is destroyed. + RefPtr<WebFrameImpl> frame = WebFrameImpl::create(frameClient); + + frame->initializeAsMainFrame(this); + + // Restrict the access to the local file system + // (see WebView.mm WebView::_commonInitializationWithFrameName). + SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForLocalOnly); +} + +WebViewImpl::WebViewImpl(WebViewClient* client) + : m_client(client) + , m_backForwardListClientImpl(this) + , m_chromeClientImpl(this) + , m_contextMenuClientImpl(this) + , m_dragClientImpl(this) + , m_editorClientImpl(this) + , m_inspectorClientImpl(this) + , m_observedNewNavigation(false) +#ifndef NDEBUG + , m_newNavigationLoader(0) +#endif + , m_zoomLevel(0) + , m_contextMenuAllowed(false) + , m_doingDragAndDrop(false) + , m_ignoreInputEvents(false) + , m_suppressNextKeypressEvent(false) + , m_initialNavigationPolicy(WebNavigationPolicyIgnore) + , m_imeAcceptEvents(true) + , m_dragTargetDispatch(false) + , m_dragIdentity(0) + , m_dropEffect(DropEffectDefault) + , m_operationsAllowed(WebDragOperationNone) + , m_dragOperation(WebDragOperationNone) + , m_autocompletePopupShowing(false) + , m_isTransparent(false) + , m_tabsToLinks(false) +{ + // WebKit/win/WebView.cpp does the same thing, except they call the + // KJS specific wrapper around this method. We need to have threading + // initialized because CollatorICU requires it. + WTF::initializeThreading(); + + // set to impossible point so we always get the first mouse pos + m_lastMousePosition = WebPoint(-1, -1); + + // the page will take ownership of the various clients + m_page.set(new Page(&m_chromeClientImpl, + &m_contextMenuClientImpl, + &m_editorClientImpl, + &m_dragClientImpl, + &m_inspectorClientImpl, + 0)); + + m_page->backForwardList()->setClient(&m_backForwardListClientImpl); + m_page->setGroupName(pageGroupName); +} + +WebViewImpl::~WebViewImpl() +{ + ASSERT(!m_page); +} + +RenderTheme* WebViewImpl::theme() const +{ + return m_page.get() ? m_page->theme() : RenderTheme::defaultTheme().get(); +} + +WebFrameImpl* WebViewImpl::mainFrameImpl() +{ + return m_page.get() ? WebFrameImpl::fromFrame(m_page->mainFrame()) : 0; +} + +bool WebViewImpl::tabKeyCyclesThroughElements() const +{ + ASSERT(m_page.get()); + return m_page->tabKeyCyclesThroughElements(); +} + +void WebViewImpl::setTabKeyCyclesThroughElements(bool value) +{ + if (m_page) + m_page->setTabKeyCyclesThroughElements(value); +} + +void WebViewImpl::mouseMove(const WebMouseEvent& event) +{ + if (!mainFrameImpl() || !mainFrameImpl()->frameView()) + return; + + m_lastMousePosition = WebPoint(event.x, event.y); + + // We call mouseMoved here instead of handleMouseMovedEvent because we need + // our ChromeClientImpl to receive changes to the mouse position and + // tooltip text, and mouseMoved handles all of that. + mainFrameImpl()->frame()->eventHandler()->mouseMoved( + PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event)); +} + +void WebViewImpl::mouseLeave(const WebMouseEvent& event) +{ + // This event gets sent as the main frame is closing. In that case, just + // ignore it. + if (!mainFrameImpl() || !mainFrameImpl()->frameView()) + return; + + m_client->setMouseOverURL(WebURL()); + + mainFrameImpl()->frame()->eventHandler()->handleMouseMoveEvent( + PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event)); +} + +void WebViewImpl::mouseDown(const WebMouseEvent& event) +{ + if (!mainFrameImpl() || !mainFrameImpl()->frameView()) + return; + + m_lastMouseDownPoint = WebPoint(event.x, event.y); + + // If a text field that has focus is clicked again, we should display the + // autocomplete popup. + RefPtr<Node> clickedNode; + if (event.button == WebMouseEvent::ButtonLeft) { + RefPtr<Node> focusedNode = focusedWebCoreNode(); + if (focusedNode.get() && toHTMLInputElement(focusedNode.get())) { + IntPoint point(event.x, event.y); + point = m_page->mainFrame()->view()->windowToContents(point); + HitTestResult result(point); + result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false); + if (result.innerNonSharedNode() == focusedNode) { + // Already focused text field was clicked, let's remember this. If + // focus has not changed after the mouse event is processed, we'll + // trigger the autocomplete. + clickedNode = focusedNode; + } + } + } + + mainFrameImpl()->frame()->eventHandler()->handleMousePressEvent( + PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event)); + + if (clickedNode.get() && clickedNode == focusedWebCoreNode()) { + // Focus has not changed, show the autocomplete popup. + static_cast<EditorClientImpl*>(m_page->editorClient())-> + showFormAutofillForNode(clickedNode.get()); + } + + // Dispatch the contextmenu event regardless of if the click was swallowed. + // On Windows, we handle it on mouse up, not down. +#if PLATFORM(DARWIN) + if (event.button == WebMouseEvent::ButtonRight + || (event.button == WebMouseEvent::ButtonLeft + && event.modifiers & WebMouseEvent::ControlKey)) + mouseContextMenu(event); +#elif PLATFORM(LINUX) + if (event.button == WebMouseEvent::ButtonRight) + mouseContextMenu(event); +#endif +} + +void WebViewImpl::mouseContextMenu(const WebMouseEvent& event) +{ + if (!mainFrameImpl() || !mainFrameImpl()->frameView()) + return; + + m_page->contextMenuController()->clearContextMenu(); + + PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); + + // Find the right target frame. See issue 1186900. + HitTestResult result = hitTestResultForWindowPos(pme.pos()); + Frame* targetFrame; + if (result.innerNonSharedNode()) + targetFrame = result.innerNonSharedNode()->document()->frame(); + else + targetFrame = m_page->focusController()->focusedOrMainFrame(); + +#if PLATFORM(WIN_OS) + targetFrame->view()->setCursor(pointerCursor()); +#endif + + m_contextMenuAllowed = true; + targetFrame->eventHandler()->sendContextMenuEvent(pme); + m_contextMenuAllowed = false; + // Actually showing the context menu is handled by the ContextMenuClient + // implementation... +} + +void WebViewImpl::mouseUp(const WebMouseEvent& event) +{ + if (!mainFrameImpl() || !mainFrameImpl()->frameView()) + return; + +#if PLATFORM(LINUX) + // If the event was a middle click, attempt to copy text into the focused + // frame. We execute this before we let the page have a go at the event + // because the page may change what is focused during in its event handler. + // + // This code is in the mouse up handler. There is some debate about putting + // this here, as opposed to the mouse down handler. + // xterm: pastes on up. + // GTK: pastes on down. + // Firefox: pastes on up. + // Midori: couldn't paste at all with 0.1.2 + // + // There is something of a webcompat angle to this well, as highlighted by + // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on + // down then the text is pasted just before the onclick handler runs and + // clears the text box. So it's important this happens after the + // handleMouseReleaseEvent() earlier in this function + if (event.button == WebMouseEvent::ButtonMiddle) { + Frame* focused = focusedWebCoreFrame(); + IntPoint clickPoint(m_lastMouseDownPoint.x, m_lastMouseDownPoint.y); + clickPoint = m_page->mainFrame()->view()->windowToContents(clickPoint); + HitTestResult hitTestResult = + focused->eventHandler()->hitTestResultAtPoint(clickPoint, false, false, + ShouldHitTestScrollbars); + // We don't want to send a paste when middle clicking a scroll bar or a + // link (which will navigate later in the code). + if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused) { + Editor* editor = focused->editor(); + Pasteboard* pasteboard = Pasteboard::generalPasteboard(); + bool oldSelectionMode = pasteboard->isSelectionMode(); + pasteboard->setSelectionMode(true); + editor->command(AtomicString("Paste")).execute(); + pasteboard->setSelectionMode(oldSelectionMode); + } + } +#endif + + mouseCaptureLost(); + mainFrameImpl()->frame()->eventHandler()->handleMouseReleaseEvent( + PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event)); + +#if PLATFORM(WIN_OS) + // Dispatch the contextmenu event regardless of if the click was swallowed. + // On Mac/Linux, we handle it on mouse down, not up. + if (event.button == WebMouseEvent::ButtonRight) + mouseContextMenu(event); +#endif +} + +void WebViewImpl::mouseWheel(const WebMouseWheelEvent& event) +{ + PlatformWheelEventBuilder platformEvent(mainFrameImpl()->frameView(), event); + mainFrameImpl()->frame()->eventHandler()->handleWheelEvent(platformEvent); +} + +bool WebViewImpl::keyEvent(const WebKeyboardEvent& event) +{ + ASSERT((event.type == WebInputEvent::RawKeyDown) + || (event.type == WebInputEvent::KeyDown) + || (event.type == WebInputEvent::KeyUp)); + + // Please refer to the comments explaining the m_suppressNextKeypressEvent + // member. + // The m_suppressNextKeypressEvent is set if the KeyDown is handled by + // Webkit. A keyDown event is typically associated with a keyPress(char) + // event and a keyUp event. We reset this flag here as this is a new keyDown + // event. + m_suppressNextKeypressEvent = false; + + // Give autocomplete a chance to consume the key events it is interested in. + if (autocompleteHandleKeyEvent(event)) + return true; + + Frame* frame = focusedWebCoreFrame(); + if (!frame) + return false; + + EventHandler* handler = frame->eventHandler(); + if (!handler) + return keyEventDefault(event); + +#if PLATFORM(WIN_OS) || PLATFORM(LINUX) + if ((!event.modifiers && (event.windowsKeyCode == VKEY_APPS)) + || ((event.modifiers == WebInputEvent::ShiftKey) && (event.windowsKeyCode == VKEY_F10))) { + sendContextMenuEvent(event); + return true; + } +#endif + + // It's not clear if we should continue after detecting a capslock keypress. + // I'll err on the side of continuing, which is the pre-existing behaviour. + if (event.windowsKeyCode == VKEY_CAPITAL) + handler->capsLockStateMayHaveChanged(); + + PlatformKeyboardEventBuilder evt(event); + + if (handler->keyEvent(evt)) { + if (WebInputEvent::RawKeyDown == event.type) + m_suppressNextKeypressEvent = true; + return true; + } + + return keyEventDefault(event); +} + +bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event) +{ + if (!m_autocompletePopupShowing + // Home and End should be left to the text field to process. + || event.windowsKeyCode == VKEY_HOME + || event.windowsKeyCode == VKEY_END) + return false; + + // Pressing delete triggers the removal of the selected suggestion from the DB. + if (event.windowsKeyCode == VKEY_DELETE + && m_autocompletePopup->selectedIndex() != -1) { + Node* node = focusedWebCoreNode(); + if (!node || (node->nodeType() != Node::ELEMENT_NODE)) { + ASSERT_NOT_REACHED(); + return false; + } + Element* element = static_cast<Element*>(node); + if (!element->hasLocalName(HTMLNames::inputTag)) { + ASSERT_NOT_REACHED(); + return false; + } + + int selectedIndex = m_autocompletePopup->selectedIndex(); + HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element); + WebString name = inputElement->name(); + WebString value = m_autocompletePopupClient->itemText(selectedIndex); + m_client->removeAutofillSuggestions(name, value); + // Update the entries in the currently showing popup to reflect the + // deletion. + m_autocompletePopupClient->removeItemAtIndex(selectedIndex); + refreshAutofillPopup(); + return false; + } + + if (!m_autocompletePopup->isInterestedInEventForKey(event.windowsKeyCode)) + return false; + + if (m_autocompletePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) { + // We need to ignore the next Char event after this otherwise pressing + // enter when selecting an item in the menu will go to the page. + if (WebInputEvent::RawKeyDown == event.type) + m_suppressNextKeypressEvent = true; + return true; + } + + return false; +} + +bool WebViewImpl::charEvent(const WebKeyboardEvent& event) +{ + ASSERT(event.type == WebInputEvent::Char); + + // Please refer to the comments explaining the m_suppressNextKeypressEvent + // member. The m_suppressNextKeypressEvent is set if the KeyDown is + // handled by Webkit. A keyDown event is typically associated with a + // keyPress(char) event and a keyUp event. We reset this flag here as it + // only applies to the current keyPress event. + bool suppress = m_suppressNextKeypressEvent; + m_suppressNextKeypressEvent = false; + + Frame* frame = focusedWebCoreFrame(); + if (!frame) + return suppress; + + EventHandler* handler = frame->eventHandler(); + if (!handler) + return suppress || keyEventDefault(event); + + PlatformKeyboardEventBuilder evt(event); + if (!evt.isCharacterKey()) + return true; + + // Accesskeys are triggered by char events and can't be suppressed. + if (handler->handleAccessKey(evt)) + return true; + + // Safari 3.1 does not pass off windows system key messages (WM_SYSCHAR) to + // the eventHandler::keyEvent. We mimic this behavior on all platforms since + // for now we are converting other platform's key events to windows key + // events. + if (evt.isSystemKey()) + return false; + + if (!suppress && !handler->keyEvent(evt)) + return keyEventDefault(event); + + return true; +} + +// The WebViewImpl::SendContextMenuEvent function is based on the Webkit +// function +// bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam) in +// webkit\webkit\win\WebView.cpp. The only significant change in this +// function is the code to convert from a Keyboard event to the Right +// Mouse button up event. +// +// This function is an ugly copy/paste and should be cleaned up when the +// WebKitWin version is cleaned: https://bugs.webkit.org/show_bug.cgi?id=20438 +#if PLATFORM(WIN_OS) || PLATFORM(LINUX) +// FIXME: implement on Mac +bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event) +{ + static const int kContextMenuMargin = 1; + Frame* mainFrameImpl = page()->mainFrame(); + FrameView* view = mainFrameImpl->view(); + if (!view) + return false; + + IntPoint coords(-1, -1); +#if PLATFORM(WIN_OS) + int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); +#else + int rightAligned = 0; +#endif + IntPoint location; + + // The context menu event was generated from the keyboard, so show the + // context menu by the current selection. + Position start = mainFrameImpl->selection()->selection().start(); + Position end = mainFrameImpl->selection()->selection().end(); + + Frame* focusedFrame = page()->focusController()->focusedOrMainFrame(); + Node* focusedNode = focusedFrame->document()->focusedNode(); + + if (start.node() && end.node()) { + RenderObject* renderer = start.node()->renderer(); + if (!renderer) + return false; + + RefPtr<Range> selection = mainFrameImpl->selection()->toNormalizedRange(); + IntRect firstRect = mainFrameImpl->firstRectForRange(selection.get()); + + int x = rightAligned ? firstRect.right() : firstRect.x(); + location = IntPoint(x, firstRect.bottom()); + } else if (focusedNode) + location = focusedNode->getRect().bottomLeft(); + else { + location = IntPoint( + rightAligned ? view->contentsWidth() - kContextMenuMargin : kContextMenuMargin, + kContextMenuMargin); + } + + location = view->contentsToWindow(location); + // FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in + // the selected element. Ideally we'd have the position of a context menu + // event be separate from its target node. + coords = location + IntSize(0, -1); + + // The contextMenuController() holds onto the last context menu that was + // popped up on the page until a new one is created. We need to clear + // this menu before propagating the event through the DOM so that we can + // detect if we create a new menu for this event, since we won't create + // a new menu if the DOM swallows the event and the defaultEventHandler does + // not run. + page()->contextMenuController()->clearContextMenu(); + + focusedFrame->view()->setCursor(pointerCursor()); + WebMouseEvent mouseEvent; + mouseEvent.button = WebMouseEvent::ButtonRight; + mouseEvent.x = coords.x(); + mouseEvent.y = coords.y(); + mouseEvent.type = WebInputEvent::MouseUp; + + PlatformMouseEventBuilder platformEvent(view, mouseEvent); + + m_contextMenuAllowed = true; + bool handled = focusedFrame->eventHandler()->sendContextMenuEvent(platformEvent); + m_contextMenuAllowed = false; + return handled; +} +#endif + +bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event) +{ + Frame* frame = focusedWebCoreFrame(); + if (!frame) + return false; + + switch (event.type) { + case WebInputEvent::Char: + if (event.windowsKeyCode == VKEY_SPACE) { + int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT); + return scrollViewWithKeyboard(keyCode, event.modifiers); + } + break; + case WebInputEvent::RawKeyDown: + if (event.modifiers == WebInputEvent::ControlKey) { + switch (event.windowsKeyCode) { + case 'A': + focusedFrame()->executeCommand(WebString::fromUTF8("SelectAll")); + return true; + case VKEY_INSERT: + case 'C': + focusedFrame()->executeCommand(WebString::fromUTF8("Copy")); + return true; + // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl + // key combinations which affect scrolling. Safari is buggy in the + // sense that it scrolls the page for all Ctrl+scrolling key + // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc. + case VKEY_HOME: + case VKEY_END: + break; + default: + return false; + } + } + if (!event.isSystemKey && !(event.modifiers & WebInputEvent::ShiftKey)) + return scrollViewWithKeyboard(event.windowsKeyCode, event.modifiers); + break; + default: + break; + } + return false; +} + +bool WebViewImpl::scrollViewWithKeyboard(int keyCode, int modifiers) +{ + ScrollDirection scrollDirection; + ScrollGranularity scrollGranularity; + + switch (keyCode) { + case VKEY_LEFT: + scrollDirection = ScrollLeft; + scrollGranularity = ScrollByLine; + break; + case VKEY_RIGHT: + scrollDirection = ScrollRight; + scrollGranularity = ScrollByLine; + break; + case VKEY_UP: + scrollDirection = ScrollUp; + scrollGranularity = ScrollByLine; + break; + case VKEY_DOWN: + scrollDirection = ScrollDown; + scrollGranularity = ScrollByLine; + break; + case VKEY_HOME: + scrollDirection = ScrollUp; + scrollGranularity = ScrollByDocument; + break; + case VKEY_END: + scrollDirection = ScrollDown; + scrollGranularity = ScrollByDocument; + break; + case VKEY_PRIOR: // page up + scrollDirection = ScrollUp; + scrollGranularity = ScrollByPage; + break; + case VKEY_NEXT: // page down + scrollDirection = ScrollDown; + scrollGranularity = ScrollByPage; + break; + default: + return false; + } + + return propagateScroll(scrollDirection, scrollGranularity); +} + +bool WebViewImpl::propagateScroll(ScrollDirection scrollDirection, + ScrollGranularity scrollGranularity) +{ + Frame* frame = focusedWebCoreFrame(); + if (!frame) + return false; + + bool scrollHandled = + frame->eventHandler()->scrollOverflow(scrollDirection, + scrollGranularity); + Frame* currentFrame = frame; + while (!scrollHandled && currentFrame) { + scrollHandled = currentFrame->view()->scroll(scrollDirection, + scrollGranularity); + currentFrame = currentFrame->tree()->parent(); + } + return scrollHandled; +} + +Frame* WebViewImpl::focusedWebCoreFrame() +{ + return m_page.get() ? m_page->focusController()->focusedOrMainFrame() : 0; +} + +WebViewImpl* WebViewImpl::fromPage(Page* page) +{ + if (!page) + return 0; + + return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView(); +} + +// WebWidget ------------------------------------------------------------------ + +void WebViewImpl::close() +{ + RefPtr<WebFrameImpl> mainFrameImpl; + + if (m_page.get()) { + // Initiate shutdown for the entire frameset. This will cause a lot of + // notifications to be sent. + if (m_page->mainFrame()) { + mainFrameImpl = WebFrameImpl::fromFrame(m_page->mainFrame()); + m_page->mainFrame()->loader()->frameDetached(); + } + m_page.clear(); + } + + // Should happen after m_page.clear(). + if (m_devToolsAgent.get()) + m_devToolsAgent.clear(); + + // Reset the delegate to prevent notifications being sent as we're being + // deleted. + m_client = 0; + + deref(); // Balances ref() acquired in WebView::create +} + +void WebViewImpl::resize(const WebSize& newSize) +{ + if (m_size == newSize) + return; + m_size = newSize; + + if (mainFrameImpl()->frameView()) { + mainFrameImpl()->frameView()->resize(m_size.width, m_size.height); + mainFrameImpl()->frame()->eventHandler()->sendResizeEvent(); + } + + if (m_client) { + WebRect damagedRect(0, 0, m_size.width, m_size.height); + m_client->didInvalidateRect(damagedRect); + } +} + +void WebViewImpl::layout() +{ + WebFrameImpl* webframe = mainFrameImpl(); + if (webframe) { + // In order for our child HWNDs (NativeWindowWidgets) to update properly, + // they need to be told that we are updating the screen. The problem is + // that the native widgets need to recalculate their clip region and not + // overlap any of our non-native widgets. To force the resizing, call + // setFrameRect(). This will be a quick operation for most frames, but + // the NativeWindowWidgets will update a proper clipping region. + FrameView* view = webframe->frameView(); + if (view) + view->setFrameRect(view->frameRect()); + + // setFrameRect may have the side-effect of causing existing page + // layout to be invalidated, so layout needs to be called last. + + webframe->layout(); + } +} + +void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) +{ + WebFrameImpl* webframe = mainFrameImpl(); + if (webframe) + webframe->paint(canvas, rect); +} + +// FIXME: m_currentInputEvent should be removed once ChromeClient::show() can +// get the current-event information from WebCore. +const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; + +bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) +{ + // If we've started a drag and drop operation, ignore input events until + // we're done. + if (m_doingDragAndDrop) + return true; + + if (m_ignoreInputEvents) + return true; + + // FIXME: Remove m_currentInputEvent. + // This only exists to allow ChromeClient::show() to know which mouse button + // triggered a window.open event. + // Safari must perform a similar hack, ours is in our WebKit glue layer + // theirs is in the application. This should go when WebCore can be fixed + // to pass more event information to ChromeClient::show() + m_currentInputEvent = &inputEvent; + + bool handled = true; + + // FIXME: WebKit seems to always return false on mouse events processing + // methods. For now we'll assume it has processed them (as we are only + // interested in whether keyboard events are processed). + switch (inputEvent.type) { + case WebInputEvent::MouseMove: + mouseMove(*static_cast<const WebMouseEvent*>(&inputEvent)); + break; + + case WebInputEvent::MouseLeave: + mouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent)); + break; + + case WebInputEvent::MouseWheel: + mouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent)); + break; + + case WebInputEvent::MouseDown: + mouseDown(*static_cast<const WebMouseEvent*>(&inputEvent)); + break; + + case WebInputEvent::MouseUp: + mouseUp(*static_cast<const WebMouseEvent*>(&inputEvent)); + break; + + case WebInputEvent::RawKeyDown: + case WebInputEvent::KeyDown: + case WebInputEvent::KeyUp: + handled = keyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent)); + break; + + case WebInputEvent::Char: + handled = charEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent)); + break; + + default: + handled = false; + } + + m_currentInputEvent = 0; + + return handled; +} + +void WebViewImpl::mouseCaptureLost() +{ +} + +void WebViewImpl::setFocus(bool enable) +{ + m_page->focusController()->setFocused(enable); + if (enable) { + // Note that we don't call setActive() when disabled as this cause extra + // focus/blur events to be dispatched. + m_page->focusController()->setActive(true); + RefPtr<Frame> focusedFrame = m_page->focusController()->focusedFrame(); + if (focusedFrame) { + Node* focusedNode = focusedFrame->document()->focusedNode(); + if (focusedNode && focusedNode->isElementNode() + && focusedFrame->selection()->selection().isNone()) { + // If the selection was cleared while the WebView was not + // focused, then the focus element shows with a focus ring but + // no caret and does respond to keyboard inputs. + Element* element = static_cast<Element*>(focusedNode); + if (element->isTextFormControl()) + element->updateFocusAppearance(true); + else if (focusedNode->isContentEditable()) { + // updateFocusAppearance() selects all the text of + // contentseditable DIVs. So we set the selection explicitly + // instead. Note that this has the side effect of moving the + // caret back to the beginning of the text. + Position position(focusedNode, 0, + Position::PositionIsOffsetInAnchor); + focusedFrame->selection()->setSelection( + VisibleSelection(position, SEL_DEFAULT_AFFINITY)); + } + } + } + m_imeAcceptEvents = true; + } else { + hideAutoCompletePopup(); + + // Clear focus on the currently focused frame if any. + if (!m_page.get()) + return; + + Frame* frame = m_page->mainFrame(); + if (!frame) + return; + + RefPtr<Frame> focusedFrame = m_page->focusController()->focusedFrame(); + if (focusedFrame.get()) { + // Finish an ongoing composition to delete the composition node. + Editor* editor = focusedFrame->editor(); + if (editor && editor->hasComposition()) + editor->confirmComposition(); + m_imeAcceptEvents = false; + } + } +} + +bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command, + int cursorPosition, + int targetStart, + int targetEnd, + const WebString& imeString) +{ + Frame* focused = focusedWebCoreFrame(); + if (!focused || !m_imeAcceptEvents) + return false; + Editor* editor = focused->editor(); + if (!editor) + return false; + if (!editor->canEdit()) { + // The input focus has been moved to another WebWidget object. + // We should use this |editor| object only to complete the ongoing + // composition. + if (!editor->hasComposition()) + return false; + } + + // We should verify the parent node of this IME composition node are + // editable because JavaScript may delete a parent node of the composition + // node. In this case, WebKit crashes while deleting texts from the parent + // node, which doesn't exist any longer. + PassRefPtr<Range> range = editor->compositionRange(); + if (range) { + const Node* node = range->startPosition().node(); + if (!node || !node->isContentEditable()) + return false; + } + + if (command == WebCompositionCommandDiscard) { + // A browser process sent an IPC message which does not contain a valid + // string, which means an ongoing composition has been canceled. + // If the ongoing composition has been canceled, replace the ongoing + // composition string with an empty string and complete it. + String emptyString; + Vector<CompositionUnderline> emptyUnderlines; + editor->setComposition(emptyString, emptyUnderlines, 0, 0); + } else { + // A browser process sent an IPC message which contains a string to be + // displayed in this Editor object. + // To display the given string, set the given string to the + // m_compositionNode member of this Editor object and display it. + if (targetStart < 0) + targetStart = 0; + if (targetEnd < 0) + targetEnd = static_cast<int>(imeString.length()); + String compositionString(imeString); + // Create custom underlines. + // To emphasize the selection, the selected region uses a solid black + // for its underline while other regions uses a pale gray for theirs. + Vector<CompositionUnderline> underlines(3); + underlines[0].startOffset = 0; + underlines[0].endOffset = targetStart; + underlines[0].thick = true; + underlines[0].color.setRGB(0xd3, 0xd3, 0xd3); + underlines[1].startOffset = targetStart; + underlines[1].endOffset = targetEnd; + underlines[1].thick = true; + underlines[1].color.setRGB(0x00, 0x00, 0x00); + underlines[2].startOffset = targetEnd; + underlines[2].endOffset = static_cast<int>(imeString.length()); + underlines[2].thick = true; + underlines[2].color.setRGB(0xd3, 0xd3, 0xd3); + // When we use custom underlines, WebKit ("InlineTextBox.cpp" Line 282) + // prevents from writing a text in between 'selectionStart' and + // 'selectionEnd' somehow. + // Therefore, we use the 'cursorPosition' for these arguments so that + // there are not any characters in the above region. + editor->setComposition(compositionString, underlines, + cursorPosition, cursorPosition); + // The given string is a result string, which means the ongoing + // composition has been completed. I have to call the + // Editor::confirmCompletion() and complete this composition. + if (command == WebCompositionCommandConfirm) + editor->confirmComposition(); + } + + return editor->hasComposition(); +} + +bool WebViewImpl::queryCompositionStatus(bool* enableIME, WebRect* caretRect) +{ + // Store whether the selected node needs IME and the caret rectangle. + // This process consists of the following four steps: + // 1. Retrieve the selection controller of the focused frame; + // 2. Retrieve the caret rectangle from the controller; + // 3. Convert the rectangle, which is relative to the parent view, to the + // one relative to the client window, and; + // 4. Store the converted rectangle. + const Frame* focused = focusedWebCoreFrame(); + if (!focused) + return false; + + const Editor* editor = focused->editor(); + if (!editor || !editor->canEdit()) + return false; + + SelectionController* controller = focused->selection(); + if (!controller) + return false; + + const Node* node = controller->start().node(); + if (!node) + return false; + + *enableIME = node->shouldUseInputMethod() && !controller->isInPasswordField(); + const FrameView* view = node->document()->view(); + if (!view) + return false; + + *caretRect = view->contentsToWindow(controller->absoluteCaretBounds()); + return true; +} + +void WebViewImpl::setTextDirection(WebTextDirection direction) +{ + // The Editor::setBaseWritingDirection() function checks if we can change + // the text direction of the selected node and updates its DOM "dir" + // attribute and its CSS "direction" property. + // So, we just call the function as Safari does. + const Frame* focused = focusedWebCoreFrame(); + if (!focused) + return; + + Editor* editor = focused->editor(); + if (!editor || !editor->canEdit()) + return; + + switch (direction) { + case WebTextDirectionDefault: + editor->setBaseWritingDirection(NaturalWritingDirection); + break; + + case WebTextDirectionLeftToRight: + editor->setBaseWritingDirection(LeftToRightWritingDirection); + break; + + case WebTextDirectionRightToLeft: + editor->setBaseWritingDirection(RightToLeftWritingDirection); + break; + + default: + notImplemented(); + break; + } +} + +// WebView -------------------------------------------------------------------- + +WebSettings* WebViewImpl::settings() +{ + if (!m_webSettings.get()) + m_webSettings.set(new WebSettingsImpl(m_page->settings())); + ASSERT(m_webSettings.get()); + return m_webSettings.get(); +} + +WebString WebViewImpl::pageEncoding() const +{ + if (!m_page.get()) + return WebString(); + + return m_page->mainFrame()->loader()->encoding(); +} + +void WebViewImpl::setPageEncoding(const WebString& encodingName) +{ + if (!m_page.get()) + return; + + // Only change override encoding, don't change default encoding. + // Note that the new encoding must be 0 if it isn't supposed to be set. + String newEncodingName; + if (!encodingName.isEmpty()) + newEncodingName = encodingName; + m_page->mainFrame()->loader()->reloadWithOverrideEncoding(newEncodingName); +} + +bool WebViewImpl::dispatchBeforeUnloadEvent() +{ + // FIXME: This should really cause a recursive depth-first walk of all + // frames in the tree, calling each frame's onbeforeunload. At the moment, + // we're consistent with Safari 3.1, not IE/FF. + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame) + return true; + + return frame->shouldClose(); +} + +void WebViewImpl::dispatchUnloadEvent() +{ + // Run unload handlers. + m_page->mainFrame()->loader()->closeURL(); +} + +WebFrame* WebViewImpl::mainFrame() +{ + return mainFrameImpl(); +} + +WebFrame* WebViewImpl::findFrameByName( + const WebString& name, WebFrame* relativeToFrame) +{ + if (!relativeToFrame) + relativeToFrame = mainFrame(); + Frame* frame = static_cast<WebFrameImpl*>(relativeToFrame)->frame(); + frame = frame->tree()->find(name); + return WebFrameImpl::fromFrame(frame); +} + +WebFrame* WebViewImpl::focusedFrame() +{ + return WebFrameImpl::fromFrame(focusedWebCoreFrame()); +} + +void WebViewImpl::setFocusedFrame(WebFrame* frame) +{ + if (!frame) { + // Clears the focused frame if any. + Frame* frame = focusedWebCoreFrame(); + if (frame) + frame->selection()->setFocused(false); + return; + } + WebFrameImpl* frameImpl = static_cast<WebFrameImpl*>(frame); + Frame* webcoreFrame = frameImpl->frame(); + webcoreFrame->page()->focusController()->setFocusedFrame(webcoreFrame); +} + +void WebViewImpl::setInitialFocus(bool reverse) +{ + if (!m_page.get()) + return; + + // Since we don't have a keyboard event, we'll create one. + WebKeyboardEvent keyboardEvent; + keyboardEvent.type = WebInputEvent::RawKeyDown; + if (reverse) + keyboardEvent.modifiers = WebInputEvent::ShiftKey; + + // VK_TAB which is only defined on Windows. + keyboardEvent.windowsKeyCode = 0x09; + PlatformKeyboardEventBuilder platformEvent(keyboardEvent); + RefPtr<KeyboardEvent> webkitEvent = KeyboardEvent::create(platformEvent, 0); + page()->focusController()->setInitialFocus( + reverse ? FocusDirectionBackward : FocusDirectionForward, + webkitEvent.get()); +} + +void WebViewImpl::clearFocusedNode() +{ + if (!m_page.get()) + return; + + RefPtr<Frame> frame = m_page->mainFrame(); + if (!frame.get()) + return; + + RefPtr<Document> document = frame->document(); + if (!document.get()) + return; + + RefPtr<Node> oldFocusedNode = document->focusedNode(); + + // Clear the focused node. + document->setFocusedNode(0); + + if (!oldFocusedNode.get()) + return; + + // If a text field has focus, we need to make sure the selection controller + // knows to remove selection from it. Otherwise, the text field is still + // processing keyboard events even though focus has been moved to the page and + // keystrokes get eaten as a result. + if (oldFocusedNode->hasTagName(HTMLNames::textareaTag) + || (oldFocusedNode->hasTagName(HTMLNames::inputTag) + && static_cast<HTMLInputElement*>(oldFocusedNode.get())->isTextField())) { + // Clear the selection. + SelectionController* selection = frame->selection(); + selection->clear(); + } +} + +int WebViewImpl::zoomLevel() +{ + return m_zoomLevel; +} + +int WebViewImpl::setZoomLevel(bool textOnly, int zoomLevel) +{ + float zoomFactor = static_cast<float>( + std::max(std::min(std::pow(textSizeMultiplierRatio, zoomLevel), + maxTextSizeMultiplier), + minTextSizeMultiplier)); + Frame* frame = mainFrameImpl()->frame(); + if (zoomFactor != frame->zoomFactor()) { + m_zoomLevel = zoomLevel; + frame->setZoomFactor(zoomFactor, textOnly); + } + return m_zoomLevel; +} + +void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, + const WebPoint& location) +{ + HitTestResult result = + hitTestResultForWindowPos(location); + RefPtr<Node> node = result.innerNonSharedNode(); + if (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::audioTag)) + return; + + RefPtr<HTMLMediaElement> mediaElement = + static_pointer_cast<HTMLMediaElement>(node); + switch (action.type) { + case WebMediaPlayerAction::Play: + if (action.enable) + mediaElement->play(); + else + mediaElement->pause(); + break; + case WebMediaPlayerAction::Mute: + mediaElement->setMuted(action.enable); + break; + case WebMediaPlayerAction::Loop: + mediaElement->setLoop(action.enable); + break; + default: + ASSERT_NOT_REACHED(); + } +} + +void WebViewImpl::copyImageAt(const WebPoint& point) +{ + if (!m_page.get()) + return; + + HitTestResult result = hitTestResultForWindowPos(point); + + if (result.absoluteImageURL().isEmpty()) { + // There isn't actually an image at these coordinates. Might be because + // the window scrolled while the context menu was open or because the page + // changed itself between when we thought there was an image here and when + // we actually tried to retreive the image. + // + // FIXME: implement a cache of the most recent HitTestResult to avoid having + // to do two hit tests. + return; + } + + m_page->mainFrame()->editor()->copyImage(result); +} + +void WebViewImpl::dragSourceEndedAt( + const WebPoint& clientPoint, + const WebPoint& screenPoint, + WebDragOperation operation) +{ + PlatformMouseEvent pme(clientPoint, + screenPoint, + LeftButton, MouseEventMoved, 0, false, false, false, + false, 0); + m_page->mainFrame()->eventHandler()->dragSourceEndedAt(pme, + static_cast<DragOperation>(operation)); +} + +void WebViewImpl::dragSourceSystemDragEnded() +{ + // It's possible for us to get this callback while not doing a drag if + // it's from a previous page that got unloaded. + if (m_doingDragAndDrop) { + m_page->dragController()->dragEnded(); + m_doingDragAndDrop = false; + } +} + +WebDragOperation WebViewImpl::dragTargetDragEnter( + const WebDragData& webDragData, int identity, + const WebPoint& clientPoint, + const WebPoint& screenPoint, + WebDragOperationsMask operationsAllowed) +{ + ASSERT(!m_currentDragData.get()); + + m_currentDragData = webDragData; + m_dragIdentity = identity; + m_operationsAllowed = operationsAllowed; + + DragData dragData( + m_currentDragData.get(), + clientPoint, + screenPoint, + static_cast<DragOperation>(operationsAllowed)); + + m_dropEffect = DropEffectDefault; + m_dragTargetDispatch = true; + DragOperation effect = m_page->dragController()->dragEntered(&dragData); + // Mask the operation against the drag source's allowed operations. + if ((effect & dragData.draggingSourceOperationMask()) != effect) + effect = DragOperationNone; + m_dragTargetDispatch = false; + + if (m_dropEffect != DropEffectDefault) { + m_dragOperation = (m_dropEffect != DropEffectNone) ? WebDragOperationCopy + : WebDragOperationNone; + } else + m_dragOperation = static_cast<WebDragOperation>(effect); + return m_dragOperation; +} + +WebDragOperation WebViewImpl::dragTargetDragOver( + const WebPoint& clientPoint, + const WebPoint& screenPoint, + WebDragOperationsMask operationsAllowed) +{ + ASSERT(m_currentDragData.get()); + + m_operationsAllowed = operationsAllowed; + DragData dragData( + m_currentDragData.get(), + clientPoint, + screenPoint, + static_cast<DragOperation>(operationsAllowed)); + + m_dropEffect = DropEffectDefault; + m_dragTargetDispatch = true; + DragOperation effect = m_page->dragController()->dragUpdated(&dragData); + // Mask the operation against the drag source's allowed operations. + if ((effect & dragData.draggingSourceOperationMask()) != effect) + effect = DragOperationNone; + m_dragTargetDispatch = false; + + if (m_dropEffect != DropEffectDefault) { + m_dragOperation = (m_dropEffect != DropEffectNone) ? WebDragOperationCopy + : WebDragOperationNone; + } else + m_dragOperation = static_cast<WebDragOperation>(effect); + return m_dragOperation; +} + +void WebViewImpl::dragTargetDragLeave() +{ + ASSERT(m_currentDragData.get()); + + DragData dragData( + m_currentDragData.get(), + IntPoint(), + IntPoint(), + static_cast<DragOperation>(m_operationsAllowed)); + + m_dragTargetDispatch = true; + m_page->dragController()->dragExited(&dragData); + m_dragTargetDispatch = false; + + m_currentDragData = 0; + m_dropEffect = DropEffectDefault; + m_dragOperation = WebDragOperationNone; + m_dragIdentity = 0; +} + +void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint, + const WebPoint& screenPoint) +{ + ASSERT(m_currentDragData.get()); + + // If this webview transitions from the "drop accepting" state to the "not + // accepting" state, then our IPC message reply indicating that may be in- + // flight, or else delayed by javascript processing in this webview. If a + // drop happens before our IPC reply has reached the browser process, then + // the browser forwards the drop to this webview. So only allow a drop to + // proceed if our webview m_dragOperation state is not DragOperationNone. + + if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop. + dragTargetDragLeave(); + return; + } + + DragData dragData( + m_currentDragData.get(), + clientPoint, + screenPoint, + static_cast<DragOperation>(m_operationsAllowed)); + + m_dragTargetDispatch = true; + m_page->dragController()->performDrag(&dragData); + m_dragTargetDispatch = false; + + m_currentDragData = 0; + m_dropEffect = DropEffectDefault; + m_dragOperation = WebDragOperationNone; + m_dragIdentity = 0; +} + +int WebViewImpl::dragIdentity() +{ + if (m_dragTargetDispatch) + return m_dragIdentity; + return 0; +} + +unsigned long WebViewImpl::createUniqueIdentifierForRequest() { + if (m_page) + return m_page->progress()->createUniqueIdentifier(); + return 0; +} + +void WebViewImpl::inspectElementAt(const WebPoint& point) +{ + if (!m_page.get()) + return; + + if (point.x == -1 || point.y == -1) + m_page->inspectorController()->inspect(0); + else { + HitTestResult result = hitTestResultForWindowPos(point); + + if (!result.innerNonSharedNode()) + return; + + m_page->inspectorController()->inspect(result.innerNonSharedNode()); + } +} + +WebString WebViewImpl::inspectorSettings() const +{ + return m_inspectorSettings; +} + +void WebViewImpl::setInspectorSettings(const WebString& settings) +{ + m_inspectorSettings = settings; +} + +WebDevToolsAgent* WebViewImpl::devToolsAgent() +{ + return m_devToolsAgent.get(); +} + +void WebViewImpl::setDevToolsAgent(WebDevToolsAgent* devToolsAgent) +{ + ASSERT(!m_devToolsAgent.get()); // May only set once! + m_devToolsAgent.set(static_cast<WebDevToolsAgentPrivate*>(devToolsAgent)); +} + +WebAccessibilityObject WebViewImpl::accessibilityObject() +{ + if (!mainFrameImpl()) + return WebAccessibilityObject(); + + Document* document = mainFrameImpl()->frame()->document(); + return WebAccessibilityObject( + document->axObjectCache()->getOrCreate(document->renderer())); +} + +void WebViewImpl::applyAutofillSuggestions( + const WebNode& node, + const WebVector<WebString>& suggestions, + int defaultSuggestionIndex) +{ + if (!m_page.get() || suggestions.isEmpty()) { + hideAutoCompletePopup(); + return; + } + + ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); + + if (RefPtr<Frame> focused = m_page->focusController()->focusedFrame()) { + RefPtr<Document> document = focused->document(); + if (!document.get()) { + hideAutoCompletePopup(); + return; + } + + RefPtr<Node> focusedNode = document->focusedNode(); + // If the node for which we queried the autofill suggestions is not the + // focused node, then we have nothing to do. FIXME: also check the + // carret is at the end and that the text has not changed. + if (!focusedNode.get() || focusedNode != PassRefPtr<Node>(node)) { + hideAutoCompletePopup(); + return; + } + + if (!focusedNode->hasTagName(HTMLNames::inputTag)) { + ASSERT_NOT_REACHED(); + return; + } + + HTMLInputElement* inputElem = + static_cast<HTMLInputElement*>(focusedNode.get()); + + // The first time the autocomplete is shown we'll create the client and the + // popup. + if (!m_autocompletePopupClient.get()) + m_autocompletePopupClient.set(new AutocompletePopupMenuClient(this)); + m_autocompletePopupClient->initialize(inputElem, + suggestions, + defaultSuggestionIndex); + if (!m_autocompletePopup.get()) { + m_autocompletePopup = + PopupContainer::create(m_autocompletePopupClient.get(), + autocompletePopupSettings); + } + + if (m_autocompletePopupShowing) { + m_autocompletePopupClient->setSuggestions(suggestions); + refreshAutofillPopup(); + } else { + m_autocompletePopup->show(focusedNode->getRect(), + focusedNode->ownerDocument()->view(), 0); + m_autocompletePopupShowing = true; + } + } +} + +void WebViewImpl::hideAutofillPopup() +{ + hideAutoCompletePopup(); +} + +void WebViewImpl::performCustomContextMenuAction(unsigned action) +{ + if (!m_page) + return; + ContextMenu* menu = m_page->contextMenuController()->contextMenu(); + if (!menu) + return; + ContextMenuItem* item = menu->itemWithAction(static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + action)); + if (item) + m_page->contextMenuController()->contextMenuItemSelected(item); + m_page->contextMenuController()->clearContextMenu(); +} + +// WebView -------------------------------------------------------------------- + +bool WebViewImpl::setDropEffect(bool accept) +{ + if (m_dragTargetDispatch) { + m_dropEffect = accept ? DropEffectCopy : DropEffectNone; + return true; + } + return false; +} + +void WebViewImpl::setIsTransparent(bool isTransparent) +{ + // Set any existing frames to be transparent. + Frame* frame = m_page->mainFrame(); + while (frame) { + frame->view()->setTransparent(isTransparent); + frame = frame->tree()->traverseNext(); + } + + // Future frames check this to know whether to be transparent. + m_isTransparent = isTransparent; +} + +bool WebViewImpl::isTransparent() const +{ + return m_isTransparent; +} + +void WebViewImpl::setIsActive(bool active) +{ + if (page() && page()->focusController()) + page()->focusController()->setActive(active); +} + +bool WebViewImpl::isActive() const +{ + return (page() && page()->focusController()) ? page()->focusController()->isActive() : false; +} + +void WebViewImpl::setScrollbarColors(unsigned inactiveColor, + unsigned activeColor, + unsigned trackColor) { +#if PLATFORM(LINUX) + RenderThemeChromiumLinux::setScrollbarColors(inactiveColor, + activeColor, + trackColor); +#endif +} + +void WebViewImpl::didCommitLoad(bool* isNewNavigation) +{ + if (isNewNavigation) + *isNewNavigation = m_observedNewNavigation; + +#ifndef NDEBUG + ASSERT(!m_observedNewNavigation + || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoader); + m_newNavigationLoader = 0; +#endif + m_observedNewNavigation = false; +} + +bool WebViewImpl::navigationPolicyFromMouseEvent(unsigned short button, + bool ctrl, bool shift, + bool alt, bool meta, + WebNavigationPolicy* policy) +{ +#if PLATFORM(WIN_OS) || PLATFORM(LINUX) || PLATFORM(FREEBSD) + const bool newTabModifier = (button == 1) || ctrl; +#elif PLATFORM(DARWIN) + const bool newTabModifier = (button == 1) || meta; +#endif + if (!newTabModifier && !shift && !alt) + return false; + + ASSERT(policy); + if (newTabModifier) { + if (shift) + *policy = WebNavigationPolicyNewForegroundTab; + else + *policy = WebNavigationPolicyNewBackgroundTab; + } else { + if (shift) + *policy = WebNavigationPolicyNewWindow; + else + *policy = WebNavigationPolicyDownload; + } + return true; +} + +void WebViewImpl::startDragging(const WebPoint& eventPos, + const WebDragData& dragData, + WebDragOperationsMask mask) +{ + if (!m_client) + return; + ASSERT(!m_doingDragAndDrop); + m_doingDragAndDrop = true; + m_client->startDragging(eventPos, dragData, mask); +} + +void WebViewImpl::setCurrentHistoryItem(HistoryItem* item) +{ + m_backForwardListClientImpl.setCurrentHistoryItem(item); +} + +HistoryItem* WebViewImpl::previousHistoryItem() +{ + return m_backForwardListClientImpl.previousHistoryItem(); +} + +void WebViewImpl::observeNewNavigation() +{ + m_observedNewNavigation = true; +#ifndef NDEBUG + m_newNavigationLoader = m_page->mainFrame()->loader()->documentLoader(); +#endif +} + +void WebViewImpl::hideAutoCompletePopup() +{ + if (m_autocompletePopupShowing) { + m_autocompletePopup->hidePopup(); + autoCompletePopupDidHide(); + } +} + +void WebViewImpl::autoCompletePopupDidHide() +{ + m_autocompletePopupShowing = false; +} + +void WebViewImpl::setIgnoreInputEvents(bool newValue) +{ + ASSERT(m_ignoreInputEvents != newValue); + m_ignoreInputEvents = newValue; +} + +#if ENABLE(NOTIFICATIONS) +NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl() +{ + if (!m_notificationPresenter.isInitialized() && m_client) + m_notificationPresenter.initialize(m_client->notificationPresenter()); + return &m_notificationPresenter; +} +#endif + +void WebViewImpl::refreshAutofillPopup() +{ + ASSERT(m_autocompletePopupShowing); + + // Hide the popup if it has become empty. + if (!m_autocompletePopupClient->listSize()) { + hideAutoCompletePopup(); + return; + } + + IntRect oldBounds = m_autocompletePopup->boundsRect(); + m_autocompletePopup->refresh(); + IntRect newBounds = m_autocompletePopup->boundsRect(); + // Let's resize the backing window if necessary. + if (oldBounds != newBounds) { + WebPopupMenuImpl* popupMenu = + static_cast<WebPopupMenuImpl*>(m_autocompletePopup->client()); + popupMenu->client()->setWindowRect(newBounds); + } +} + +Node* WebViewImpl::focusedWebCoreNode() +{ + Frame* frame = m_page->focusController()->focusedFrame(); + if (!frame) + return 0; + + Document* document = frame->document(); + if (!document) + return 0; + + return document->focusedNode(); +} + +HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) +{ + IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos)); + return m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(docPoint, false); +} + +void WebViewImpl::setTabsToLinks(bool enable) +{ + m_tabsToLinks = enable; +} + +bool WebViewImpl::tabsToLinks() const +{ + return m_tabsToLinks; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h new file mode 100644 index 0000000..dd5191e --- /dev/null +++ b/WebKit/chromium/src/WebViewImpl.h @@ -0,0 +1,420 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebViewImpl_h +#define WebViewImpl_h + +// FIXME: Remove these relative paths once consumers from glue are removed. +#include "../public/WebNavigationPolicy.h" +#include "../public/WebPoint.h" +#include "../public/WebSize.h" +#include "../public/WebString.h" +#include "../public/WebView.h" + +#include "BackForwardListClientImpl.h" +#include "ChromeClientImpl.h" +#include "ContextMenuClientImpl.h" +#include "DragClientImpl.h" +#include "EditorClientImpl.h" +#include "InspectorClientImpl.h" +#include "NotificationPresenterImpl.h" + +#include <wtf/OwnPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { +class ChromiumDataObject; +class Frame; +class HistoryItem; +class HitTestResult; +class KeyboardEvent; +class Page; +class PlatformKeyboardEvent; +class PopupContainer; +class Range; +class RenderTheme; +class Widget; +} + +namespace WebKit { +class AutocompletePopupMenuClient; +class ContextMenuClientImpl; +class WebAccessibilityObject; +class WebDevToolsAgentPrivate; +class WebFrameImpl; +class WebKeyboardEvent; +class WebMouseEvent; +class WebMouseWheelEvent; +class WebSettingsImpl; + +class WebViewImpl : public WebView, public RefCounted<WebViewImpl> { +public: + // WebWidget methods: + virtual void close(); + virtual WebSize size() { return m_size; } + virtual void resize(const WebSize&); + virtual void layout(); + virtual void paint(WebCanvas*, const WebRect&); + virtual bool handleInputEvent(const WebInputEvent&); + virtual void mouseCaptureLost(); + virtual void setFocus(bool enable); + virtual bool handleCompositionEvent(WebCompositionCommand command, + int cursorPosition, + int targetStart, + int targetEnd, + const WebString& text); + virtual bool queryCompositionStatus(bool* enabled, + WebRect* caretRect); + virtual void setTextDirection(WebTextDirection direction); + + // WebView methods: + virtual void initializeMainFrame(WebFrameClient*); + virtual WebSettings* settings(); + virtual WebString pageEncoding() const; + virtual void setPageEncoding(const WebString& encoding); + virtual bool isTransparent() const; + virtual void setIsTransparent(bool value); + virtual bool tabsToLinks() const; + virtual void setTabsToLinks(bool value); + virtual bool tabKeyCyclesThroughElements() const; + virtual void setTabKeyCyclesThroughElements(bool value); + virtual bool isActive() const; + virtual void setIsActive(bool value); + virtual bool dispatchBeforeUnloadEvent(); + virtual void dispatchUnloadEvent(); + virtual WebFrame* mainFrame(); + virtual WebFrame* findFrameByName( + const WebString& name, WebFrame* relativeToFrame); + virtual WebFrame* focusedFrame(); + virtual void setFocusedFrame(WebFrame* frame); + virtual void setInitialFocus(bool reverse); + virtual void clearFocusedNode(); + virtual int zoomLevel(); + virtual int setZoomLevel(bool textOnly, int zoomLevel); + virtual void performMediaPlayerAction( + const WebMediaPlayerAction& action, + const WebPoint& location); + virtual void copyImageAt(const WebPoint& point); + virtual void dragSourceEndedAt( + const WebPoint& clientPoint, + const WebPoint& screenPoint, + WebDragOperation operation); + virtual void dragSourceSystemDragEnded(); + virtual WebDragOperation dragTargetDragEnter( + const WebDragData& dragData, int identity, + const WebPoint& clientPoint, + const WebPoint& screenPoint, + WebDragOperationsMask operationsAllowed); + virtual WebDragOperation dragTargetDragOver( + const WebPoint& clientPoint, + const WebPoint& screenPoint, + WebDragOperationsMask operationsAllowed); + virtual void dragTargetDragLeave(); + virtual void dragTargetDrop( + const WebPoint& clientPoint, + const WebPoint& screenPoint); + virtual int dragIdentity(); + virtual bool setDropEffect(bool accept); + virtual unsigned long createUniqueIdentifierForRequest(); + virtual void inspectElementAt(const WebPoint& point); + virtual WebString inspectorSettings() const; + virtual void setInspectorSettings(const WebString& settings); + virtual WebDevToolsAgent* devToolsAgent(); + virtual void setDevToolsAgent(WebDevToolsAgent*); + virtual WebAccessibilityObject accessibilityObject(); + virtual void applyAutofillSuggestions( + const WebNode&, + const WebVector<WebString>& suggestions, + int defaultSuggestionIndex); + virtual void hideAutofillPopup(); + virtual void setScrollbarColors(unsigned inactiveColor, + unsigned activeColor, + unsigned trackColor); + virtual void performCustomContextMenuAction(unsigned action); + + // WebViewImpl + + void setIgnoreInputEvents(bool newValue); + WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); } + + const WebPoint& lastMouseDownPoint() const + { + return m_lastMouseDownPoint; + } + + WebCore::Frame* focusedWebCoreFrame(); + + // Returns the currently focused Node or null if no node has focus. + WebCore::Node* focusedWebCoreNode(); + + static WebViewImpl* fromPage(WebCore::Page*); + + WebViewClient* client() + { + return m_client; + } + + // Returns the page object associated with this view. This may be null when + // the page is shutting down, but will be valid at all other times. + WebCore::Page* page() const + { + return m_page.get(); + } + + WebCore::RenderTheme* theme() const; + + // Returns the main frame associated with this view. This may be null when + // the page is shutting down, but will be valid at all other times. + WebFrameImpl* mainFrameImpl(); + + // History related methods: + void setCurrentHistoryItem(WebCore::HistoryItem*); + WebCore::HistoryItem* previousHistoryItem(); + void observeNewNavigation(); + + // Event related methods: + void mouseMove(const WebMouseEvent&); + void mouseLeave(const WebMouseEvent&); + void mouseDown(const WebMouseEvent&); + void mouseUp(const WebMouseEvent&); + void mouseContextMenu(const WebMouseEvent&); + void mouseDoubleClick(const WebMouseEvent&); + void mouseWheel(const WebMouseWheelEvent&); + bool keyEvent(const WebKeyboardEvent&); + bool charEvent(const WebKeyboardEvent&); + + // Handles context menu events orignated via the the keyboard. These + // include the VK_APPS virtual key and the Shift+F10 combine. Code is + // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM + // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only + // significant change in this function is the code to convert from a + // Keyboard event to the Right Mouse button down event. + bool sendContextMenuEvent(const WebKeyboardEvent&); + + // Notifies the WebView that a load has been committed. isNewNavigation + // will be true if a new session history item should be created for that + // load. + void didCommitLoad(bool* isNewNavigation); + + bool contextMenuAllowed() const + { + return m_contextMenuAllowed; + } + + // Set the disposition for how this webview is to be initially shown. + void setInitialNavigationPolicy(WebNavigationPolicy policy) + { + m_initialNavigationPolicy = policy; + } + WebNavigationPolicy initialNavigationPolicy() const + { + return m_initialNavigationPolicy; + } + + // Determines whether a page should e.g. be opened in a background tab. + // Returns false if it has no opinion, in which case it doesn't set *policy. + static bool navigationPolicyFromMouseEvent( + unsigned short button, + bool ctrl, + bool shift, + bool alt, + bool meta, + WebNavigationPolicy*); + + // Start a system drag and drop operation. + void startDragging( + const WebPoint& eventPos, + const WebDragData& dragData, + WebDragOperationsMask dragSourceOperationMask); + + // Hides the autocomplete popup if it is showing. + void hideAutoCompletePopup(); + void autoCompletePopupDidHide(); + +#if ENABLE(NOTIFICATIONS) + // Returns the provider of desktop notifications. + NotificationPresenterImpl* notificationPresenterImpl(); +#endif + + // Tries to scroll a frame or any parent of a frame. Returns true if the view + // was scrolled. + bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity); + + // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can + // fix WebKit to pass enough information up into ChromeClient::show() so we + // can decide if the window.open event was caused by a middle-mouse click + static const WebInputEvent* currentInputEvent() + { + return m_currentInputEvent; + } + +private: + friend class WebView; // So WebView::Create can call our constructor + friend class WTF::RefCounted<WebViewImpl>; + + WebViewImpl(WebViewClient* client); + ~WebViewImpl(); + + // Returns true if the event was actually processed. + bool keyEventDefault(const WebKeyboardEvent&); + + // Returns true if the autocomple has consumed the event. + bool autocompleteHandleKeyEvent(const WebKeyboardEvent&); + + // Repaints the autofill popup. Should be called when the suggestions have + // changed. Note that this should only be called when the autofill popup is + // showing. + void refreshAutofillPopup(); + + // Returns true if the view was scrolled. + bool scrollViewWithKeyboard(int keyCode, int modifiers); + + // Converts |pos| from window coordinates to contents coordinates and gets + // the HitTestResult for it. + WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&); + + WebViewClient* m_client; + + BackForwardListClientImpl m_backForwardListClientImpl; + ChromeClientImpl m_chromeClientImpl; + ContextMenuClientImpl m_contextMenuClientImpl; + DragClientImpl m_dragClientImpl; + EditorClientImpl m_editorClientImpl; + InspectorClientImpl m_inspectorClientImpl; + + WebSize m_size; + + WebPoint m_lastMousePosition; + OwnPtr<WebCore::Page> m_page; + + // This flag is set when a new navigation is detected. It is used to satisfy + // the corresponding argument to WebFrameClient::didCommitProvisionalLoad. + bool m_observedNewNavigation; +#ifndef NDEBUG + // Used to assert that the new navigation we observed is the same navigation + // when we make use of m_observedNewNavigation. + const WebCore::DocumentLoader* m_newNavigationLoader; +#endif + + // An object that can be used to manipulate m_page->settings() without linking + // against WebCore. This is lazily allocated the first time GetWebSettings() + // is called. + OwnPtr<WebSettingsImpl> m_webSettings; + + // A copy of the web drop data object we received from the browser. + RefPtr<WebCore::ChromiumDataObject> m_currentDragData; + + // The point relative to the client area where the mouse was last pressed + // down. This is used by the drag client to determine what was under the + // mouse when the drag was initiated. We need to track this here in + // WebViewImpl since DragClient::startDrag does not pass the position the + // mouse was at when the drag was initiated, only the current point, which + // can be misleading as it is usually not over the element the user actually + // dragged by the time a drag is initiated. + WebPoint m_lastMouseDownPoint; + + // Keeps track of the current zoom level. 0 means no zoom, positive numbers + // mean zoom in, negative numbers mean zoom out. + int m_zoomLevel; + + bool m_contextMenuAllowed; + + bool m_doingDragAndDrop; + + bool m_ignoreInputEvents; + + // Webkit expects keyPress events to be suppressed if the associated keyDown + // event was handled. Safari implements this behavior by peeking out the + // associated WM_CHAR event if the keydown was handled. We emulate + // this behavior by setting this flag if the keyDown was handled. + bool m_suppressNextKeypressEvent; + + // The policy for how this webview is to be initially shown. + WebNavigationPolicy m_initialNavigationPolicy; + + // Represents whether or not this object should process incoming IME events. + bool m_imeAcceptEvents; + + // True while dispatching system drag and drop events to drag/drop targets + // within this WebView. + bool m_dragTargetDispatch; + + // Valid when m_dragTargetDispatch is true; the identity of the drag data + // copied from the WebDropData object sent from the browser process. + int m_dragIdentity; + + // Valid when m_dragTargetDispatch is true. Used to override the default + // browser drop effect with the effects "none" or "copy". + enum DragTargetDropEffect { + DropEffectDefault = -1, + DropEffectNone, + DropEffectCopy + } m_dropEffect; + + // The available drag operations (copy, move link...) allowed by the source. + WebDragOperation m_operationsAllowed; + + // The current drag operation as negotiated by the source and destination. + // When not equal to DragOperationNone, the drag data can be dropped onto the + // current drop target in this WebView (the drop target can accept the drop). + WebDragOperation m_dragOperation; + + // The autocomplete popup. Kept around and reused every-time new suggestions + // should be shown. + RefPtr<WebCore::PopupContainer> m_autocompletePopup; + + // Whether the autocomplete popup is currently showing. + bool m_autocompletePopupShowing; + + // The autocomplete client. + OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient; + + OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent; + + // Whether the webview is rendering transparently. + bool m_isTransparent; + + // Whether the user can press tab to focus links. + bool m_tabsToLinks; + + // Inspector settings. + WebString m_inspectorSettings; + +#if ENABLE(NOTIFICATIONS) + // The provider of desktop notifications; + NotificationPresenterImpl m_notificationPresenter; +#endif + + static const WebInputEvent* m_currentInputEvent; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebWorkerBase.cpp b/WebKit/chromium/src/WebWorkerBase.cpp new file mode 100644 index 0000000..85a263b --- /dev/null +++ b/WebKit/chromium/src/WebWorkerBase.cpp @@ -0,0 +1,308 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebWorkerBase.h" + +#include "GenericWorkerTask.h" +#include "MessagePortChannel.h" +#include "PlatformMessagePortChannel.h" + +#include "WebDataSourceImpl.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" +#include "WebMessagePortChannel.h" +#include "WebView.h" +#include "WebWorkerClient.h" + +#include "WorkerThread.h" +#include <wtf/MainThread.h> + +using namespace WebCore; + +namespace WebKit { + +#if ENABLE(WORKERS) + +// Dummy WebViewDelegate - we only need it in Worker process to load a +// 'shadow page' which will initialize WebCore loader. +class WorkerWebFrameClient : public WebFrameClient { +public: + // Tell the loader to load the data into the 'shadow page' synchronously, + // so we can grab the resulting Document right after load. + virtual void didCreateDataSource(WebFrame* frame, WebDataSource* ds) + { + static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false); + } + + // Lazy allocate and leak this instance. + static WorkerWebFrameClient* sharedInstance() + { + static WorkerWebFrameClient client; + return &client; + } + +private: + WorkerWebFrameClient() + { + } +}; + +// This function is called on the main thread to force to initialize some static +// values used in WebKit before any worker thread is started. This is because in +// our worker processs, we do not run any WebKit code in main thread and thus +// when multiple workers try to start at the same time, we might hit crash due +// to contention for initializing static values. +static void initializeWebKitStaticValues() +{ + static bool initialized = false; + if (!initialized) { + initialized = true; + // Note that we have to pass a URL with valid protocol in order to follow + // the path to do static value initializations. + RefPtr<SecurityOrigin> origin = + SecurityOrigin::create(KURL(ParsedURLString, "http://localhost")); + origin.release(); + } +} + +WebWorkerBase::WebWorkerBase() + : m_webView(0) + , m_askedToTerminate(false) +{ + initializeWebKitStaticValues(); +} + +WebWorkerBase::~WebWorkerBase() +{ + ASSERT(m_webView); + m_webView->close(); +} + +void WebWorkerBase::stopWorkerThread() +{ + if (m_askedToTerminate) + return; + m_askedToTerminate = true; + if (m_workerThread) + m_workerThread->stop(); +} + +void WebWorkerBase::initializeLoader(const WebURL& url) +{ + // Create 'shadow page'. This page is never displayed, it is used to proxy the + // loading requests from the worker context to the rest of WebKit and Chromium + // infrastructure. + ASSERT(!m_webView); + m_webView = WebView::create(0); + m_webView->initializeMainFrame(WorkerWebFrameClient::sharedInstance()); + + WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame()); + + // Construct substitute data source for the 'shadow page'. We only need it + // to have same origin as the worker so the loading checks work correctly. + CString content(""); + int len = static_cast<int>(content.length()); + RefPtr<SharedBuffer> buf(SharedBuffer::create(content.data(), len)); + SubstituteData substData(buf, String("text/html"), String("UTF-8"), KURL()); + ResourceRequest request(url, CString()); + webFrame->frame()->loader()->load(request, substData, false); + + // This document will be used as 'loading context' for the worker. + m_loadingDocument = webFrame->frame()->document(); +} + +void WebWorkerBase::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task) +{ + return callOnMainThread(invokeTaskMethod, task.release()); +} + +void WebWorkerBase::invokeTaskMethod(void* param) +{ + ScriptExecutionContext::Task* task = + static_cast<ScriptExecutionContext::Task*>(param); + task->performTask(0); + delete task; +} + +// WorkerObjectProxy ----------------------------------------------------------- + +void WebWorkerBase::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message, + PassOwnPtr<MessagePortChannelArray> channels) +{ + dispatchTaskToMainThread(createCallbackTask(&postMessageTask, this, + message->toString(), channels)); +} + +void WebWorkerBase::postMessageTask(ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + String message, + PassOwnPtr<MessagePortChannelArray> channels) +{ + if (!thisPtr->client()) + return; + + WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0); + for (size_t i = 0; i < webChannels.size(); ++i) { + webChannels[i] = (*channels)[i]->channel()->webChannelRelease(); + webChannels[i]->setClient(0); + } + + thisPtr->client()->postMessageToWorkerObject(message, webChannels); +} + +void WebWorkerBase::postExceptionToWorkerObject(const String& errorMessage, + int lineNumber, + const String& sourceURL) +{ + dispatchTaskToMainThread(createCallbackTask(&postExceptionTask, this, + errorMessage, lineNumber, + sourceURL)); +} + +void WebWorkerBase::postExceptionTask(ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + const String& errorMessage, + int lineNumber, const String& sourceURL) +{ + if (!thisPtr->commonClient()) + return; + + thisPtr->commonClient()->postExceptionToWorkerObject(errorMessage, + lineNumber, + sourceURL); +} + +void WebWorkerBase::postConsoleMessageToWorkerObject(MessageDestination destination, + MessageSource source, + MessageType type, + MessageLevel level, + const String& message, + int lineNumber, + const String& sourceURL) +{ + dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, this, + static_cast<int>(destination), + static_cast<int>(source), + static_cast<int>(type), + static_cast<int>(level), + message, lineNumber, sourceURL)); +} + +void WebWorkerBase::postConsoleMessageTask(ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + int destination, int source, + int type, int level, + const String& message, + int lineNumber, + const String& sourceURL) +{ + if (!thisPtr->commonClient()) + return; + thisPtr->commonClient()->postConsoleMessageToWorkerObject(destination, source, + type, level, message, + lineNumber, sourceURL); +} + +void WebWorkerBase::confirmMessageFromWorkerObject(bool hasPendingActivity) +{ + dispatchTaskToMainThread(createCallbackTask(&confirmMessageTask, this, + hasPendingActivity)); +} + +void WebWorkerBase::confirmMessageTask(ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + bool hasPendingActivity) +{ + if (!thisPtr->client()) + return; + thisPtr->client()->confirmMessageFromWorkerObject(hasPendingActivity); +} + +void WebWorkerBase::reportPendingActivity(bool hasPendingActivity) +{ + dispatchTaskToMainThread(createCallbackTask(&reportPendingActivityTask, + this, hasPendingActivity)); +} + +void WebWorkerBase::reportPendingActivityTask(ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + bool hasPendingActivity) +{ + if (!thisPtr->client()) + return; + thisPtr->client()->reportPendingActivity(hasPendingActivity); +} + +void WebWorkerBase::workerContextClosed() +{ + dispatchTaskToMainThread(createCallbackTask(&workerContextClosedTask, + this)); +} + +void WebWorkerBase::workerContextClosedTask(ScriptExecutionContext* context, + WebWorkerBase* thisPtr) +{ + if (thisPtr->commonClient()) + thisPtr->commonClient()->workerContextClosed(); +} + +void WebWorkerBase::workerContextDestroyed() +{ + dispatchTaskToMainThread(createCallbackTask(&workerContextDestroyedTask, + this)); +} + +void WebWorkerBase::workerContextDestroyedTask(ScriptExecutionContext* context, + WebWorkerBase* thisPtr) +{ + if (thisPtr->commonClient()) + thisPtr->commonClient()->workerContextDestroyed(); + // The lifetime of this proxy is controlled by the worker context. + delete thisPtr; +} + +// WorkerLoaderProxy ----------------------------------------------------------- + +void WebWorkerBase::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task) +{ + ASSERT(m_loadingDocument->isDocument()); + m_loadingDocument->postTask(task); +} + +void WebWorkerBase::postTaskForModeToWorkerContext( + PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) +{ + m_workerThread->runLoop().postTaskForMode(task, mode); +} + +#endif // ENABLE(WORKERS) + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebWorkerBase.h b/WebKit/chromium/src/WebWorkerBase.h new file mode 100644 index 0000000..0217401 --- /dev/null +++ b/WebKit/chromium/src/WebWorkerBase.h @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebWorkerBase_h +#define WebWorkerBase_h + +#if ENABLE(WORKERS) + +#include "ScriptExecutionContext.h" +#include "WorkerLoaderProxy.h" +#include "WorkerObjectProxy.h" +#include <wtf/PassOwnPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { +class WorkerThread; +} + +namespace WebKit { +class WebCommonWorkerClient; +class WebURL; +class WebView; +class WebWorkerClient; + +// Base class for WebSharedWorkerImpl and WebWorkerImpl. It contains common +// code used by both implementation classes, including implementations of the +// WorkerObjectProxy and WorkerLoaderProxy interfaces. +class WebWorkerBase : public WebCore::WorkerObjectProxy + , public WebCore::WorkerLoaderProxy { +public: + WebWorkerBase(); + virtual ~WebWorkerBase(); + + // WebCore::WorkerObjectProxy methods: + virtual void postMessageToWorkerObject( + PassRefPtr<WebCore::SerializedScriptValue>, + PassOwnPtr<WebCore::MessagePortChannelArray>); + virtual void postExceptionToWorkerObject( + const WebCore::String&, int, const WebCore::String&); + virtual void postConsoleMessageToWorkerObject( + WebCore::MessageDestination, WebCore::MessageSource, WebCore::MessageType, + WebCore::MessageLevel, const WebCore::String&, int, const WebCore::String&); + virtual void confirmMessageFromWorkerObject(bool); + virtual void reportPendingActivity(bool); + virtual void workerContextClosed(); + virtual void workerContextDestroyed(); + + // WebCore::WorkerLoaderProxy methods: + virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>); + virtual void postTaskForModeToWorkerContext( + PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WebCore::String& mode); + + // Executes the given task on the main thread. + static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>); + +protected: + virtual WebWorkerClient* client() = 0; + virtual WebCommonWorkerClient* commonClient() = 0; + + void setWorkerThread(PassRefPtr<WebCore::WorkerThread> thread) { m_workerThread = thread; } + WebCore::WorkerThread* workerThread() { return m_workerThread.get(); } + + // Shuts down the worker thread. + void stopWorkerThread(); + + // Creates the shadow loader used for worker network requests. + void initializeLoader(const WebURL&); + +private: + // Function used to invoke tasks on the main thread. + static void invokeTaskMethod(void*); + + // Tasks that are run on the main thread. + static void postMessageTask( + WebCore::ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + WebCore::String message, + PassOwnPtr<WebCore::MessagePortChannelArray> channels); + static void postExceptionTask( + WebCore::ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + const WebCore::String& message, + int lineNumber, + const WebCore::String& sourceURL); + static void postConsoleMessageTask( + WebCore::ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + int destination, + int source, + int type, + int level, + const WebCore::String& message, + int lineNumber, + const WebCore::String& sourceURL); + static void confirmMessageTask( + WebCore::ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + bool hasPendingActivity); + static void reportPendingActivityTask( + WebCore::ScriptExecutionContext* context, + WebWorkerBase* thisPtr, + bool hasPendingActivity); + static void workerContextClosedTask( + WebCore::ScriptExecutionContext* context, + WebWorkerBase* thisPtr); + static void workerContextDestroyedTask( + WebCore::ScriptExecutionContext* context, + WebWorkerBase* thisPtr); + + // 'shadow page' - created to proxy loading requests from the worker. + RefPtr<WebCore::ScriptExecutionContext> m_loadingDocument; + WebView* m_webView; + bool m_askedToTerminate; + + RefPtr<WebCore::WorkerThread> m_workerThread; +}; + +} // namespace WebKit + +#endif // ENABLE(WORKERS) + +#endif diff --git a/WebKit/chromium/src/WebWorkerClientImpl.cpp b/WebKit/chromium/src/WebWorkerClientImpl.cpp new file mode 100644 index 0000000..6be03a7 --- /dev/null +++ b/WebKit/chromium/src/WebWorkerClientImpl.cpp @@ -0,0 +1,416 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebWorkerClientImpl.h" + +#if ENABLE(WORKERS) + +#include "DedicatedWorkerThread.h" +#include "ErrorEvent.h" +#include "Frame.h" +#include "FrameLoaderClient.h" +#include "GenericWorkerTask.h" +#include "MessageEvent.h" +#include "MessagePort.h" +#include "MessagePortChannel.h" +#include "ScriptExecutionContext.h" +#include "Worker.h" +#include "WorkerContext.h" +#include "WorkerContextExecutionProxy.h" +#include "WorkerMessagingProxy.h" +#include <wtf/Threading.h> + +#include "FrameLoaderClientImpl.h" +#include "PlatformMessagePortChannel.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebMessagePortChannel.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebViewImpl.h" +#include "WebWorker.h" +#include "WebWorkerImpl.h" + +using namespace WebCore; + +namespace WebKit { + +// When WebKit creates a WorkerContextProxy object, we check if we're in the +// renderer or worker process. If the latter, then we just use +// WorkerMessagingProxy. +// +// If we're in the renderer process, then we need use the glue provided +// WebWorker object to talk to the worker process over IPC. The worker process +// talks to Worker* using WorkerObjectProxy, which we implement on +// WebWorkerClientImpl. +// +// Note that if we're running each worker in a separate process, then nested +// workers end up using the same codepath as the renderer process. + +// static +WorkerContextProxy* WebWorkerClientImpl::createWorkerContextProxy(Worker* worker) +{ + // Special behavior for multiple workers per process. + // FIXME: v8 doesn't support more than one workers per process. + // if (!worker->scriptExecutionContext()->isDocument()) + // return new WorkerMessagingProxy(worker); + + WebWorker* webWorker = 0; + WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker); + + if (worker->scriptExecutionContext()->isDocument()) { + Document* document = static_cast<Document*>( + worker->scriptExecutionContext()); + WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); + webWorker = webFrame->client()->createWorker(webFrame, proxy); + } else { + WorkerContextExecutionProxy* currentContext = + WorkerContextExecutionProxy::retrieve(); + if (!currentContext) { + ASSERT_NOT_REACHED(); + return 0; + } + + DedicatedWorkerThread* thread = + static_cast<DedicatedWorkerThread*>(currentContext->workerContext()->thread()); + WorkerObjectProxy* workerObjectProxy = &thread->workerObjectProxy(); + WebWorkerImpl* impl = reinterpret_cast<WebWorkerImpl*>(workerObjectProxy); + webWorker = impl->client()->createWorker(proxy); + } + + proxy->setWebWorker(webWorker); + return proxy; +} + +WebWorkerClientImpl::WebWorkerClientImpl(Worker* worker) + : m_scriptExecutionContext(worker->scriptExecutionContext()) + , m_worker(worker) + , m_askedToTerminate(false) + , m_unconfirmedMessageCount(0) + , m_workerContextHadPendingActivity(false) + , m_workerThreadId(currentThread()) +{ +} + +WebWorkerClientImpl::~WebWorkerClientImpl() +{ +} + +void WebWorkerClientImpl::setWebWorker(WebWorker* webWorker) +{ + m_webWorker = webWorker; +} + +void WebWorkerClientImpl::startWorkerContext(const KURL& scriptURL, + const String& userAgent, + const String& sourceCode) +{ + // Worker.terminate() could be called from JS before the context is started. + if (m_askedToTerminate) + return; + if (!isMainThread()) { + WebWorkerBase::dispatchTaskToMainThread(createCallbackTask( + &startWorkerContextTask, + this, + scriptURL.string(), + userAgent, + sourceCode)); + return; + } + m_webWorker->startWorkerContext(scriptURL, userAgent, sourceCode); +} + +void WebWorkerClientImpl::terminateWorkerContext() +{ + if (m_askedToTerminate) + return; + m_askedToTerminate = true; + if (!isMainThread()) { + WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&terminateWorkerContextTask, this)); + return; + } + m_webWorker->terminateWorkerContext(); +} + +void WebWorkerClientImpl::postMessageToWorkerContext( + PassRefPtr<SerializedScriptValue> message, + PassOwnPtr<MessagePortChannelArray> channels) +{ + // Worker.terminate() could be called from JS before the context is started. + if (m_askedToTerminate) + return; + ++m_unconfirmedMessageCount; + if (!isMainThread()) { + WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToWorkerContextTask, + this, + message->toString(), + channels)); + return; + } + WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0); + for (size_t i = 0; i < webChannels.size(); ++i) { + WebMessagePortChannel* webchannel = + (*channels)[i]->channel()->webChannelRelease(); + webchannel->setClient(0); + webChannels[i] = webchannel; + } + m_webWorker->postMessageToWorkerContext(message->toString(), webChannels); +} + +bool WebWorkerClientImpl::hasPendingActivity() const +{ + return !m_askedToTerminate + && (m_unconfirmedMessageCount || m_workerContextHadPendingActivity); +} + +void WebWorkerClientImpl::workerObjectDestroyed() +{ + if (isMainThread()) { + m_webWorker->workerObjectDestroyed(); + m_worker = 0; + } + // Even if this is called on the main thread, there could be a queued task for + // this object, so don't delete it right away. + WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerObjectDestroyedTask, + this)); +} + +void WebWorkerClientImpl::postMessageToWorkerObject(const WebString& message, + const WebMessagePortChannelArray& channels) +{ + OwnPtr<MessagePortChannelArray> channels2; + if (channels.size()) { + channels2 = new MessagePortChannelArray(channels.size()); + for (size_t i = 0; i < channels.size(); ++i) { + RefPtr<PlatformMessagePortChannel> platform_channel = + PlatformMessagePortChannel::create(channels[i]); + channels[i]->setClient(platform_channel.get()); + (*channels2)[i] = MessagePortChannel::create(platform_channel); + } + } + + if (currentThread() != m_workerThreadId) { + m_scriptExecutionContext->postTask(createCallbackTask(&postMessageToWorkerObjectTask, + this, + String(message), + channels2.release())); + return; + } + + postMessageToWorkerObjectTask(m_scriptExecutionContext.get(), this, + message, channels2.release()); +} + +void WebWorkerClientImpl::postExceptionToWorkerObject(const WebString& errorMessage, + int lineNumber, + const WebString& sourceURL) +{ + if (currentThread() != m_workerThreadId) { + m_scriptExecutionContext->postTask(createCallbackTask(&postExceptionToWorkerObjectTask, + this, + String(errorMessage), + lineNumber, + String(sourceURL))); + return; + } + + bool handled = false; + handled = m_worker->dispatchEvent(ErrorEvent::create(errorMessage, + sourceURL, + lineNumber)); + if (!handled) + m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL); +} + +void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int destinationId, + int sourceId, + int messageType, + int messageLevel, + const WebString& message, + int lineNumber, + const WebString& sourceURL) +{ + if (currentThread() != m_workerThreadId) { + m_scriptExecutionContext->postTask(createCallbackTask(&postConsoleMessageToWorkerObjectTask, + this, + destinationId, + sourceId, + messageType, + messageLevel, + String(message), + lineNumber, + String(sourceURL))); + return; + } + + m_scriptExecutionContext->addMessage(static_cast<MessageDestination>(destinationId), + static_cast<MessageSource>(sourceId), + static_cast<MessageType>(messageType), + static_cast<MessageLevel>(messageLevel), + String(message), lineNumber, + String(sourceURL)); +} + +void WebWorkerClientImpl::confirmMessageFromWorkerObject(bool hasPendingActivity) +{ + // unconfirmed_message_count_ can only be updated on the thread where it's + // accessed. Otherwise there are race conditions with v8's garbage + // collection. + m_scriptExecutionContext->postTask(createCallbackTask(&confirmMessageFromWorkerObjectTask, + this)); +} + +void WebWorkerClientImpl::reportPendingActivity(bool hasPendingActivity) +{ + // See above comment in confirmMessageFromWorkerObject. + m_scriptExecutionContext->postTask(createCallbackTask(&reportPendingActivityTask, + this, + hasPendingActivity)); +} + +void WebWorkerClientImpl::workerContextDestroyed() +{ +} + +void WebWorkerClientImpl::workerContextClosed() +{ +} + +void WebWorkerClientImpl::startWorkerContextTask(ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const String& scriptURL, + const String& userAgent, + const String& sourceCode) +{ + thisPtr->m_webWorker->startWorkerContext(KURL(ParsedURLString, scriptURL), + userAgent, sourceCode); +} + +void WebWorkerClientImpl::terminateWorkerContextTask(ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr) +{ + thisPtr->m_webWorker->terminateWorkerContext(); +} + +void WebWorkerClientImpl::postMessageToWorkerContextTask(ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const String& message, + PassOwnPtr<MessagePortChannelArray> channels) +{ + WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0); + + for (size_t i = 0; i < webChannels.size(); ++i) { + webChannels[i] = (*channels)[i]->channel()->webChannelRelease(); + webChannels[i]->setClient(0); + } + + thisPtr->m_webWorker->postMessageToWorkerContext(message, webChannels); +} + +void WebWorkerClientImpl::workerObjectDestroyedTask(ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr) +{ + if (thisPtr->m_worker) // Check we haven't alread called this. + thisPtr->m_webWorker->workerObjectDestroyed(); + delete thisPtr; +} + +void WebWorkerClientImpl::postMessageToWorkerObjectTask( + ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const String& message, + PassOwnPtr<MessagePortChannelArray> channels) +{ + + if (thisPtr->m_worker) { + OwnPtr<MessagePortArray> ports = + MessagePort::entanglePorts(*context, channels.release()); + RefPtr<SerializedScriptValue> serializedMessage = + SerializedScriptValue::create(message); + thisPtr->m_worker->dispatchEvent(MessageEvent::create(ports.release(), + serializedMessage.release())); + } +} + +void WebWorkerClientImpl::postExceptionToWorkerObjectTask( + ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const String& errorMessage, + int lineNumber, + const String& sourceURL) +{ + bool handled = false; + if (thisPtr->m_worker) + handled = thisPtr->m_worker->dispatchEvent(ErrorEvent::create(errorMessage, + sourceURL, + lineNumber)); + if (!handled) + thisPtr->m_scriptExecutionContext->reportException(errorMessage, + lineNumber, + sourceURL); +} + +void WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask(ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + int destinationId, + int sourceId, + int messageType, + int messageLevel, + const String& message, + int lineNumber, + const String& sourceURL) +{ + thisPtr->m_scriptExecutionContext->addMessage(static_cast<MessageDestination>(destinationId), + static_cast<MessageSource>(sourceId), + static_cast<MessageType>(messageType), + static_cast<MessageLevel>(messageLevel), + message, lineNumber, + sourceURL); +} + +void WebWorkerClientImpl::confirmMessageFromWorkerObjectTask(ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr) +{ + thisPtr->m_unconfirmedMessageCount--; +} + +void WebWorkerClientImpl::reportPendingActivityTask(ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + bool hasPendingActivity) +{ + thisPtr->m_workerContextHadPendingActivity = hasPendingActivity; +} + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebWorkerClientImpl.h b/WebKit/chromium/src/WebWorkerClientImpl.h new file mode 100644 index 0000000..63acebc --- /dev/null +++ b/WebKit/chromium/src/WebWorkerClientImpl.h @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebWorkerClientImpl_h +#define WebWorkerClientImpl_h + +#if ENABLE(WORKERS) + +// FIXME: fix to just "WebWorkerClient.h" once nobody in glue depends on us. +#include "../public/WebWorkerClient.h" + +#include "WorkerContextProxy.h" +#include <wtf/PassOwnPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { +class ScriptExecutionContext; +} + +namespace WebKit { +class WebWorker; + +// The purpose of this class is to provide a WorkerContextProxy +// implementation that we can give to WebKit. Internally, it converts the +// data types to Chrome compatible ones so that renderer code can use it over +// IPC. +class WebWorkerClientImpl : public WebCore::WorkerContextProxy + , public WebWorkerClient { +public: + WebWorkerClientImpl(WebCore::Worker*); + + // WebCore::WorkerContextProxy Factory. + static WebCore::WorkerContextProxy* createWorkerContextProxy(WebCore::Worker*); + void setWebWorker(WebWorker*); + + // WebCore::WorkerContextProxy methods: + // These are called on the thread that created the worker. In the renderer + // process, this will be the main WebKit thread. In the worker process, this + // will be the thread of the executing worker (not the main WebKit thread). + virtual void startWorkerContext(const WebCore::KURL&, + const WebCore::String&, + const WebCore::String&); + virtual void terminateWorkerContext(); + virtual void postMessageToWorkerContext( + PassRefPtr<WebCore::SerializedScriptValue> message, + PassOwnPtr<WebCore::MessagePortChannelArray> channels); + virtual bool hasPendingActivity() const; + virtual void workerObjectDestroyed(); + + // WebWorkerClient methods: + // These are called on the main WebKit thread. + virtual void postMessageToWorkerObject(const WebString&, const WebMessagePortChannelArray&); + virtual void postExceptionToWorkerObject(const WebString&, int, const WebString&); + virtual void postConsoleMessageToWorkerObject(int, int, int, int, const WebString&, + int, const WebString&); + virtual void confirmMessageFromWorkerObject(bool); + virtual void reportPendingActivity(bool); + virtual void workerContextClosed(); + virtual void workerContextDestroyed(); + virtual WebWorker* createWorker(WebWorkerClient*) { return 0; } + virtual WebNotificationPresenter* notificationPresenter() + { + // FIXME: Notifications not yet supported in workers. + return 0; + } + +private: + virtual ~WebWorkerClientImpl(); + + // Methods used to support WebWorkerClientImpl being constructed on worker + // threads. + // These tasks are dispatched on the WebKit thread. + static void startWorkerContextTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const WebCore::String& scriptURL, + const WebCore::String& userAgent, + const WebCore::String& sourceCode); + static void terminateWorkerContextTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr); + static void postMessageToWorkerContextTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const WebCore::String& message, + PassOwnPtr<WebCore::MessagePortChannelArray> channels); + static void workerObjectDestroyedTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr); + + // These tasks are dispatched on the thread that created the worker (i.e. + // main WebKit thread in renderer process, and the worker thread in the + // worker process). + static void postMessageToWorkerObjectTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const WebCore::String& message, + PassOwnPtr<WebCore::MessagePortChannelArray> channels); + static void postExceptionToWorkerObjectTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + const WebCore::String& message, + int lineNumber, + const WebCore::String& sourceURL); + static void postConsoleMessageToWorkerObjectTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + int destinationId, + int sourceId, + int messageType, + int messageLevel, + const WebCore::String& message, + int lineNumber, + const WebCore::String& sourceURL); + static void confirmMessageFromWorkerObjectTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr); + static void reportPendingActivityTask(WebCore::ScriptExecutionContext* context, + WebWorkerClientImpl* thisPtr, + bool hasPendingActivity); + + // Guard against context from being destroyed before a worker exits. + RefPtr<WebCore::ScriptExecutionContext> m_scriptExecutionContext; + + WebCore::Worker* m_worker; + WebWorker* m_webWorker; + bool m_askedToTerminate; + unsigned m_unconfirmedMessageCount; + bool m_workerContextHadPendingActivity; + ThreadIdentifier m_workerThreadId; +}; + +} // namespace WebKit; + +#endif // ENABLE(WORKERS) + +#endif diff --git a/WebKit/chromium/src/WebWorkerImpl.cpp b/WebKit/chromium/src/WebWorkerImpl.cpp new file mode 100644 index 0000000..744be30 --- /dev/null +++ b/WebKit/chromium/src/WebWorkerImpl.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebWorkerImpl.h" + +#include "DedicatedWorkerContext.h" +#include "DedicatedWorkerThread.h" +#include "GenericWorkerTask.h" +#include "KURL.h" +#include "MessageEvent.h" +#include "MessagePort.h" +#include "MessagePortChannel.h" +#include "ScriptExecutionContext.h" +#include "SecurityOrigin.h" +#include "SerializedScriptValue.h" +#include "SubstituteData.h" +#include <wtf/Threading.h> + +#include "PlatformMessagePortChannel.h" +#include "WebMessagePortChannel.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebWorkerClient.h" + +using namespace WebCore; + +namespace WebKit { + +#if ENABLE(WORKERS) + +WebWorker* WebWorker::create(WebWorkerClient* client) +{ + return new WebWorkerImpl(client); +} + + +WebWorkerImpl::WebWorkerImpl(WebWorkerClient* client) + : m_client(client) +{ +} + +WebWorkerImpl::~WebWorkerImpl() +{ +} + +WebCommonWorkerClient* WebWorkerImpl::commonClient() +{ + return m_client; +} + +void WebWorkerImpl::postMessageToWorkerContextTask(WebCore::ScriptExecutionContext* context, + WebWorkerImpl* thisPtr, + const String& message, + PassOwnPtr<MessagePortChannelArray> channels) +{ + ASSERT(context->isWorkerContext()); + DedicatedWorkerContext* workerContext = + static_cast<DedicatedWorkerContext*>(context); + + OwnPtr<MessagePortArray> ports = + MessagePort::entanglePorts(*context, channels.release()); + RefPtr<SerializedScriptValue> serializedMessage = + SerializedScriptValue::create(message); + workerContext->dispatchEvent(MessageEvent::create( + ports.release(), serializedMessage.release())); + thisPtr->confirmMessageFromWorkerObject(workerContext->hasPendingActivity()); +} + +// WebWorker ------------------------------------------------------------------- + +void WebWorkerImpl::startWorkerContext(const WebURL& scriptUrl, + const WebString& userAgent, + const WebString& sourceCode) +{ + initializeLoader(scriptUrl); + setWorkerThread(DedicatedWorkerThread::create(scriptUrl, userAgent, + sourceCode, *this, *this)); + // Worker initialization means a pending activity. + reportPendingActivity(true); + workerThread()->start(); +} + +void WebWorkerImpl::terminateWorkerContext() +{ + stopWorkerThread(); +} + +void WebWorkerImpl::postMessageToWorkerContext(const WebString& message, + const WebMessagePortChannelArray& webChannels) +{ + OwnPtr<MessagePortChannelArray> channels; + if (webChannels.size()) { + channels = new MessagePortChannelArray(webChannels.size()); + for (size_t i = 0; i < webChannels.size(); ++i) { + RefPtr<PlatformMessagePortChannel> platform_channel = + PlatformMessagePortChannel::create(webChannels[i]); + webChannels[i]->setClient(platform_channel.get()); + (*channels)[i] = MessagePortChannel::create(platform_channel); + } + } + + workerThread()->runLoop().postTask( + createCallbackTask(&postMessageToWorkerContextTask, + this, String(message), channels.release())); +} + +void WebWorkerImpl::workerObjectDestroyed() +{ + // Worker object in the renderer was destroyed, perhaps a result of GC. + // For us, it's a signal to start terminating the WorkerContext too. + // FIXME: when 'kill a worker' html5 spec algorithm is implemented, it + // should be used here instead of 'terminate a worker'. + terminateWorkerContext(); +} + +void WebWorkerImpl::clientDestroyed() +{ + m_client = 0; +} + +#else + +WebWorker* WebWorker::create(WebWorkerClient* client) +{ + return 0; +} + +#endif // ENABLE(WORKERS) + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebWorkerImpl.h b/WebKit/chromium/src/WebWorkerImpl.h new file mode 100644 index 0000000..bec96cd --- /dev/null +++ b/WebKit/chromium/src/WebWorkerImpl.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WebWorkerImpl_h +#define WebWorkerImpl_h + +#include "WebWorker.h" + +#if ENABLE(WORKERS) + +#include "ScriptExecutionContext.h" + +#include "WebWorkerBase.h" + +namespace WebKit { +class WebView; + +// This class is used by the worker process code to talk to the WebCore::Worker +// implementation. It can't use it directly since it uses WebKit types, so this +// class converts the data types. When the WebCore::Worker object wants to call +// WebCore::WorkerObjectProxy, this class will conver to Chrome data types first +// and then call the supplied WebWorkerClient. +class WebWorkerImpl : public WebWorkerBase, public WebWorker { +public: + explicit WebWorkerImpl(WebWorkerClient* client); + + // WebWorker methods: + virtual void startWorkerContext(const WebURL&, const WebString&, const WebString&); + virtual void terminateWorkerContext(); + virtual void postMessageToWorkerContext(const WebString&, const WebMessagePortChannelArray&); + virtual void workerObjectDestroyed(); + virtual void clientDestroyed(); + + // WebWorkerBase methods: + virtual WebWorkerClient* client() { return m_client; } + virtual WebCommonWorkerClient* commonClient(); + +private: + virtual ~WebWorkerImpl(); + + // Tasks that are run on the worker thread. + static void postMessageToWorkerContextTask( + WebCore::ScriptExecutionContext* context, + WebWorkerImpl* thisPtr, + const WebCore::String& message, + PassOwnPtr<WebCore::MessagePortChannelArray> channels); + + WebWorkerClient* m_client; + +}; + +} // namespace WebKit + +#endif // ENABLE(WORKERS) + +#endif diff --git a/WebKit/chromium/src/WrappedResourceRequest.h b/WebKit/chromium/src/WrappedResourceRequest.h new file mode 100644 index 0000000..97311db --- /dev/null +++ b/WebKit/chromium/src/WrappedResourceRequest.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WrappedResourceRequest_h +#define WrappedResourceRequest_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebURLRequest.h" +#include "WebURLRequestPrivate.h" + +namespace WebKit { + +class WrappedResourceRequest : public WebURLRequest { +public: + ~WrappedResourceRequest() + { + reset(); // Need to drop reference to m_handle + } + + WrappedResourceRequest() { } + + WrappedResourceRequest(WebCore::ResourceRequest& resourceRequest) + { + bind(resourceRequest); + } + + WrappedResourceRequest(const WebCore::ResourceRequest& resourceRequest) + { + bind(resourceRequest); + } + + void bind(WebCore::ResourceRequest& resourceRequest) + { + m_handle.m_resourceRequest = &resourceRequest; + assign(&m_handle); + } + + void bind(const WebCore::ResourceRequest& resourceRequest) + { + bind(*const_cast<WebCore::ResourceRequest*>(&resourceRequest)); + } + +private: + class Handle : public WebURLRequestPrivate { + public: + virtual void dispose() { m_resourceRequest = 0; } + }; + + Handle m_handle; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WrappedResourceResponse.h b/WebKit/chromium/src/WrappedResourceResponse.h new file mode 100644 index 0000000..af4f88f --- /dev/null +++ b/WebKit/chromium/src/WrappedResourceResponse.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 WrappedResourceResponse_h +#define WrappedResourceResponse_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebURLResponse.h" +#include "WebURLResponsePrivate.h" + +namespace WebKit { + +class WrappedResourceResponse : public WebURLResponse { +public: + ~WrappedResourceResponse() + { + reset(); // Need to drop reference to m_handle + } + + WrappedResourceResponse() { } + + WrappedResourceResponse(WebCore::ResourceResponse& resourceResponse) + { + bind(resourceResponse); + } + + WrappedResourceResponse(const WebCore::ResourceResponse& resourceResponse) + { + bind(resourceResponse); + } + + void bind(WebCore::ResourceResponse& resourceResponse) + { + m_handle.m_resourceResponse = &resourceResponse; + assign(&m_handle); + } + + void bind(const WebCore::ResourceResponse& resourceResponse) + { + bind(*const_cast<WebCore::ResourceResponse*>(&resourceResponse)); + } + +private: + class Handle : public WebURLResponsePrivate { + public: + virtual void dispose() { m_resourceResponse = 0; } + }; + + Handle m_handle; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/gtk/WebFontInfo.cpp b/WebKit/chromium/src/gtk/WebFontInfo.cpp new file mode 100644 index 0000000..76ed618 --- /dev/null +++ b/WebKit/chromium/src/gtk/WebFontInfo.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebFontInfo.h" + +#include <fontconfig/fontconfig.h> +#include <string.h> +#include <unicode/utf16.h> + +namespace WebKit { + +WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters) +{ + FcCharSet* cset = FcCharSetCreate(); + for (size_t i = 0; i < numCharacters; ++i) { + if (U16_IS_SURROGATE(characters[i]) + && U16_IS_SURROGATE_LEAD(characters[i]) + && i != numCharacters - 1 + && U16_IS_TRAIL(characters[i + 1])) { + FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1])); + i++; + } else + FcCharSetAddChar(cset, characters[i]); + } + FcPattern* pattern = FcPatternCreate(); + + FcValue fcvalue; + fcvalue.type = FcTypeCharSet; + fcvalue.u.c = cset; + FcPatternAdd(pattern, FC_CHARSET, fcvalue, 0); + + fcvalue.type = FcTypeBool; + fcvalue.u.b = FcTrue; + FcPatternAdd(pattern, FC_SCALABLE, fcvalue, 0); + + FcConfigSubstitute(0, pattern, FcMatchPattern); + FcDefaultSubstitute(pattern); + + FcResult result; + FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result); + FcPatternDestroy(pattern); + FcCharSetDestroy(cset); + + if (!fontSet) + return WebCString(); + + // Older versions of fontconfig have a bug where they cannot select + // only scalable fonts so we have to manually filter the results. + for (int i = 0; i < fontSet->nfont; ++i) { + FcPattern* current = fontSet->fonts[i]; + FcBool isScalable; + + if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch + || !isScalable) + continue; + + // fontconfig can also return fonts which are unreadable + FcChar8* cFilename; + if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch) + continue; + + if (access(reinterpret_cast<char*>(cFilename), R_OK)) + continue; + + FcChar8* family; + WebCString result; + if (FcPatternGetString(current, FC_FAMILY, 0, &family) == FcResultMatch) { + const char* charFamily = reinterpret_cast<char*>(family); + result = WebCString(charFamily, strlen(charFamily)); + } + FcFontSetDestroy(fontSet); + return result; + } + + FcFontSetDestroy(fontSet); + return WebCString(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/gtk/WebInputEventFactory.cpp b/WebKit/chromium/src/gtk/WebInputEventFactory.cpp new file mode 100644 index 0000000..7125a16 --- /dev/null +++ b/WebKit/chromium/src/gtk/WebInputEventFactory.cpp @@ -0,0 +1,496 @@ +/* + * Copyright (C) 2006-2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebInputEventFactory.h" + +#include "KeyboardCodes.h" +#include "KeyCodeConversion.h" + +#include "WebInputEvent.h" + +#include <gdk/gdk.h> +#include <gdk/gdkkeysyms.h> +#include <gtk/gtk.h> +#include <gtk/gtkversion.h> + +#include <wtf/Assertions.h> + +namespace { + +gint getDoubleClickTime() +{ + static GtkSettings* settings = gtk_settings_get_default(); + gint doubleClickTime = 250; + g_object_get(G_OBJECT(settings), "gtk-double-click-time", &doubleClickTime, 0); + return doubleClickTime; +} + +} // namespace + +namespace WebKit { + +static double gdkEventTimeToWebEventTime(guint32 time) +{ + // Convert from time in ms to time in sec. + return time / 1000.0; +} + +static int gdkStateToWebEventModifiers(guint state) +{ + int modifiers = 0; + if (state & GDK_SHIFT_MASK) + modifiers |= WebInputEvent::ShiftKey; + if (state & GDK_CONTROL_MASK) + modifiers |= WebInputEvent::ControlKey; + if (state & GDK_MOD1_MASK) + modifiers |= WebInputEvent::AltKey; +#if GTK_CHECK_VERSION(2, 10, 0) + if (state & GDK_META_MASK) + modifiers |= WebInputEvent::MetaKey; +#endif + if (state & GDK_BUTTON1_MASK) + modifiers |= WebInputEvent::LeftButtonDown; + if (state & GDK_BUTTON2_MASK) + modifiers |= WebInputEvent::MiddleButtonDown; + if (state & GDK_BUTTON3_MASK) + modifiers |= WebInputEvent::RightButtonDown; + return modifiers; +} + +static int gdkEventToWindowsKeyCode(const GdkEventKey* event) +{ + static const unsigned int hardwareCodeToGDKKeyval[] = { + 0, // 0x00: + 0, // 0x01: + 0, // 0x02: + 0, // 0x03: + 0, // 0x04: + 0, // 0x05: + 0, // 0x06: + 0, // 0x07: + 0, // 0x08: + 0, // 0x09: GDK_Escape + GDK_1, // 0x0A: GDK_1 + GDK_2, // 0x0B: GDK_2 + GDK_3, // 0x0C: GDK_3 + GDK_4, // 0x0D: GDK_4 + GDK_5, // 0x0E: GDK_5 + GDK_6, // 0x0F: GDK_6 + GDK_7, // 0x10: GDK_7 + GDK_8, // 0x11: GDK_8 + GDK_9, // 0x12: GDK_9 + GDK_0, // 0x13: GDK_0 + GDK_minus, // 0x14: GDK_minus + GDK_equal, // 0x15: GDK_equal + 0, // 0x16: GDK_BackSpace + 0, // 0x17: GDK_Tab + GDK_q, // 0x18: GDK_q + GDK_w, // 0x19: GDK_w + GDK_e, // 0x1A: GDK_e + GDK_r, // 0x1B: GDK_r + GDK_t, // 0x1C: GDK_t + GDK_y, // 0x1D: GDK_y + GDK_u, // 0x1E: GDK_u + GDK_i, // 0x1F: GDK_i + GDK_o, // 0x20: GDK_o + GDK_p, // 0x21: GDK_p + GDK_bracketleft, // 0x22: GDK_bracketleft + GDK_bracketright, // 0x23: GDK_bracketright + 0, // 0x24: GDK_Return + 0, // 0x25: GDK_Control_L + GDK_a, // 0x26: GDK_a + GDK_s, // 0x27: GDK_s + GDK_d, // 0x28: GDK_d + GDK_f, // 0x29: GDK_f + GDK_g, // 0x2A: GDK_g + GDK_h, // 0x2B: GDK_h + GDK_j, // 0x2C: GDK_j + GDK_k, // 0x2D: GDK_k + GDK_l, // 0x2E: GDK_l + GDK_semicolon, // 0x2F: GDK_semicolon + GDK_apostrophe, // 0x30: GDK_apostrophe + GDK_grave, // 0x31: GDK_grave + 0, // 0x32: GDK_Shift_L + GDK_backslash, // 0x33: GDK_backslash + GDK_z, // 0x34: GDK_z + GDK_x, // 0x35: GDK_x + GDK_c, // 0x36: GDK_c + GDK_v, // 0x37: GDK_v + GDK_b, // 0x38: GDK_b + GDK_n, // 0x39: GDK_n + GDK_m, // 0x3A: GDK_m + GDK_comma, // 0x3B: GDK_comma + GDK_period, // 0x3C: GDK_period + GDK_slash, // 0x3D: GDK_slash + 0, // 0x3E: GDK_Shift_R + }; + + // |windowsKeyCode| has to include a valid virtual-key code even when we + // use non-US layouts, e.g. even when we type an 'A' key of a US keyboard + // on the Hebrew layout, |windowsKeyCode| should be VK_A. + // On the other hand, |event->keyval| value depends on the current + // GdkKeymap object, i.e. when we type an 'A' key of a US keyboard on + // the Hebrew layout, |event->keyval| becomes GDK_hebrew_shin and this + // WebCore::windowsKeyCodeForKeyEvent() call returns 0. + // To improve compatibilty with Windows, we use |event->hardware_keycode| + // for retrieving its Windows key-code for the keys when the + // WebCore::windowsKeyCodeForEvent() call returns 0. + // We shouldn't use |event->hardware_keycode| for keys that GdkKeymap + // objects cannot change because |event->hardware_keycode| doesn't change + // even when we change the layout options, e.g. when we swap a control + // key and a caps-lock key, GTK doesn't swap their + // |event->hardware_keycode| values but swap their |event->keyval| values. + int windowsKeyCode = WebCore::windowsKeyCodeForKeyEvent(event->keyval); + if (windowsKeyCode) + return windowsKeyCode; + + const int tableSize = sizeof(hardwareCodeToGDKKeyval) / sizeof(hardwareCodeToGDKKeyval[0]); + if (event->hardware_keycode < tableSize) { + int keyval = hardwareCodeToGDKKeyval[event->hardware_keycode]; + if (keyval) + return WebCore::windowsKeyCodeForKeyEvent(keyval); + } + + // This key is one that keyboard-layout drivers cannot change. + // Use |event->keyval| to retrieve its |windowsKeyCode| value. + return WebCore::windowsKeyCodeForKeyEvent(event->keyval); +} + +// Gets the corresponding control character of a specified key code. See: +// http://en.wikipedia.org/wiki/Control_characters +// We emulate Windows behavior here. +static WebUChar getControlCharacter(int windowsKeyCode, bool shift) +{ + if (windowsKeyCode >= WebCore::VKEY_A && windowsKeyCode <= WebCore::VKEY_Z) { + // ctrl-A ~ ctrl-Z map to \x01 ~ \x1A + return windowsKeyCode - WebCore::VKEY_A + 1; + } + if (shift) { + // following graphics chars require shift key to input. + switch (windowsKeyCode) { + // ctrl-@ maps to \x00 (Null byte) + case WebCore::VKEY_2: + return 0; + // ctrl-^ maps to \x1E (Record separator, Information separator two) + case WebCore::VKEY_6: + return 0x1E; + // ctrl-_ maps to \x1F (Unit separator, Information separator one) + case WebCore::VKEY_OEM_MINUS: + return 0x1F; + // Returns 0 for all other keys to avoid inputting unexpected chars. + default: + return 0; + } + } else { + switch (windowsKeyCode) { + // ctrl-[ maps to \x1B (Escape) + case WebCore::VKEY_OEM_4: + return 0x1B; + // ctrl-\ maps to \x1C (File separator, Information separator four) + case WebCore::VKEY_OEM_5: + return 0x1C; + // ctrl-] maps to \x1D (Group separator, Information separator three) + case WebCore::VKEY_OEM_6: + return 0x1D; + // ctrl-Enter maps to \x0A (Line feed) + case WebCore::VKEY_RETURN: + return 0x0A; + // Returns 0 for all other keys to avoid inputting unexpected chars. + default: + return 0; + } + } +} + +// WebKeyboardEvent ----------------------------------------------------------- + +WebKeyboardEvent WebInputEventFactory::keyboardEvent(const GdkEventKey* event) +{ + WebKeyboardEvent result; + + result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); + result.modifiers = gdkStateToWebEventModifiers(event->state); + + switch (event->type) { + case GDK_KEY_RELEASE: + result.type = WebInputEvent::KeyUp; + break; + case GDK_KEY_PRESS: + result.type = WebInputEvent::RawKeyDown; + break; + default: + ASSERT_NOT_REACHED(); + } + + // According to MSDN: + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx + // Key events with Alt modifier and F10 are system key events. + // We just emulate this behavior. It's necessary to prevent webkit from + // processing keypress event generated by alt-d, etc. + // F10 is not special on Linux, so don't treat it as system key. + if (result.modifiers & WebInputEvent::AltKey) + result.isSystemKey = true; + + // The key code tells us which physical key was pressed (for example, the + // A key went down or up). It does not determine whether A should be lower + // or upper case. This is what text does, which should be the keyval. + result.windowsKeyCode = gdkEventToWindowsKeyCode(event); + result.nativeKeyCode = event->hardware_keycode; + + if (result.windowsKeyCode == WebCore::VKEY_RETURN) + // We need to treat the enter key as a key press of character \r. This + // is apparently just how webkit handles it and what it expects. + result.unmodifiedText[0] = '\r'; + else + // FIXME: fix for non BMP chars + result.unmodifiedText[0] = + static_cast<WebUChar>(gdk_keyval_to_unicode(event->keyval)); + + // If ctrl key is pressed down, then control character shall be input. + if (result.modifiers & WebInputEvent::ControlKey) + result.text[0] = getControlCharacter( + result.windowsKeyCode, result.modifiers & WebInputEvent::ShiftKey); + else + result.text[0] = result.unmodifiedText[0]; + + result.setKeyIdentifierFromWindowsKeyCode(); + + // FIXME: Do we need to set IsAutoRepeat or IsKeyPad? + + return result; +} + +WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, int state, double timeStampSeconds) +{ + // keyboardEvent(const GdkEventKey*) depends on the GdkEventKey object and + // it is hard to use/ it from signal handlers which don't use GdkEventKey + // objects (e.g. GtkIMContext signal handlers.) For such handlers, this + // function creates a WebInputEvent::Char event without using a + // GdkEventKey object. + WebKeyboardEvent result; + result.type = WebKit::WebInputEvent::Char; + result.timeStampSeconds = timeStampSeconds; + result.modifiers = gdkStateToWebEventModifiers(state); + result.windowsKeyCode = character; + result.nativeKeyCode = character; + result.text[0] = character; + result.unmodifiedText[0] = character; + + // According to MSDN: + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx + // Key events with Alt modifier and F10 are system key events. + // We just emulate this behavior. It's necessary to prevent webkit from + // processing keypress event generated by alt-d, etc. + // F10 is not special on Linux, so don't treat it as system key. + if (result.modifiers & WebInputEvent::AltKey) + result.isSystemKey = true; + + return result; +} + +// WebMouseEvent -------------------------------------------------------------- + +WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event) +{ + WebMouseEvent result; + + result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); + + result.modifiers = gdkStateToWebEventModifiers(event->state); + result.x = static_cast<int>(event->x); + result.y = static_cast<int>(event->y); + result.windowX = result.x; + result.windowY = result.y; + result.globalX = static_cast<int>(event->x_root); + result.globalY = static_cast<int>(event->y_root); + result.clickCount = 0; + + switch (event->type) { + case GDK_BUTTON_PRESS: + result.type = WebInputEvent::MouseDown; + break; + case GDK_BUTTON_RELEASE: + result.type = WebInputEvent::MouseUp; + break; + case GDK_3BUTTON_PRESS: + case GDK_2BUTTON_PRESS: + default: + ASSERT_NOT_REACHED(); + }; + + if (GDK_BUTTON_PRESS == event->type) { + static int numClicks = 0; + static GdkWindow* eventWindow = 0; + static gint lastLeftClickTime = 0; + + gint time_diff = event->time - lastLeftClickTime; + if (eventWindow == event->window && time_diff < getDoubleClickTime()) + numClicks++; + else + numClicks = 1; + + result.clickCount = numClicks; + eventWindow = event->window; + lastLeftClickTime = event->time; + } + + result.button = WebMouseEvent::ButtonNone; + if (event->button == 1) + result.button = WebMouseEvent::ButtonLeft; + else if (event->button == 2) + result.button = WebMouseEvent::ButtonMiddle; + else if (event->button == 3) + result.button = WebMouseEvent::ButtonRight; + + return result; +} + +WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventMotion* event) +{ + WebMouseEvent result; + + result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); + result.modifiers = gdkStateToWebEventModifiers(event->state); + result.x = static_cast<int>(event->x); + result.y = static_cast<int>(event->y); + result.windowX = result.x; + result.windowY = result.y; + result.globalX = static_cast<int>(event->x_root); + result.globalY = static_cast<int>(event->y_root); + + switch (event->type) { + case GDK_MOTION_NOTIFY: + result.type = WebInputEvent::MouseMove; + break; + default: + ASSERT_NOT_REACHED(); + } + + result.button = WebMouseEvent::ButtonNone; + if (event->state & GDK_BUTTON1_MASK) + result.button = WebMouseEvent::ButtonLeft; + else if (event->state & GDK_BUTTON2_MASK) + result.button = WebMouseEvent::ButtonMiddle; + else if (event->state & GDK_BUTTON3_MASK) + result.button = WebMouseEvent::ButtonRight; + + return result; +} + +WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventCrossing* event) +{ + WebMouseEvent result; + + result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); + result.modifiers = gdkStateToWebEventModifiers(event->state); + result.x = static_cast<int>(event->x); + result.y = static_cast<int>(event->y); + result.windowX = result.x; + result.windowY = result.y; + result.globalX = static_cast<int>(event->x_root); + result.globalY = static_cast<int>(event->y_root); + + switch (event->type) { + case GDK_ENTER_NOTIFY: + case GDK_LEAVE_NOTIFY: + // Note that if we sent MouseEnter or MouseLeave to WebKit, it + // wouldn't work - they don't result in the proper JavaScript events. + // MouseMove does the right thing. + result.type = WebInputEvent::MouseMove; + break; + default: + ASSERT_NOT_REACHED(); + } + + result.button = WebMouseEvent::ButtonNone; + if (event->state & GDK_BUTTON1_MASK) + result.button = WebMouseEvent::ButtonLeft; + else if (event->state & GDK_BUTTON2_MASK) + result.button = WebMouseEvent::ButtonMiddle; + else if (event->state & GDK_BUTTON3_MASK) + result.button = WebMouseEvent::ButtonRight; + + return result; +} + +// WebMouseWheelEvent --------------------------------------------------------- + +WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(const GdkEventScroll* event) +{ + WebMouseWheelEvent result; + + result.type = WebInputEvent::MouseWheel; + result.button = WebMouseEvent::ButtonNone; + + result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); + result.modifiers = gdkStateToWebEventModifiers(event->state); + result.x = static_cast<int>(event->x); + result.y = static_cast<int>(event->y); + result.windowX = result.x; + result.windowY = result.y; + result.globalX = static_cast<int>(event->x_root); + result.globalY = static_cast<int>(event->y_root); + + // How much should we scroll per mouse wheel event? + // - Windows uses 3 lines by default and obeys a system setting. + // - Mozilla has a pref that lets you either use the "system" number of lines + // to scroll, or lets the user override it. + // For the "system" number of lines, it appears they've hardcoded 3. + // See case NS_MOUSE_SCROLL in content/events/src/nsEventStateManager.cpp + // and InitMouseScrollEvent in widget/src/gtk2/nsCommonWidget.cpp . + // - Gtk makes the scroll amount a function of the size of the scroll bar, + // which is not available to us here. + // Instead, we pick a number that empirically matches Firefox's behavior. + static const float scrollbarPixelsPerTick = 160.0f / 3.0f; + + switch (event->direction) { + case GDK_SCROLL_UP: + result.deltaY = scrollbarPixelsPerTick; + result.wheelTicksY = 1; + break; + case GDK_SCROLL_DOWN: + result.deltaY = -scrollbarPixelsPerTick; + result.wheelTicksY = -1; + break; + case GDK_SCROLL_LEFT: + result.deltaX = scrollbarPixelsPerTick; + result.wheelTicksX = 1; + break; + case GDK_SCROLL_RIGHT: + result.deltaX = -scrollbarPixelsPerTick; + result.wheelTicksX = -1; + break; + } + + return result; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/gtk/WebScreenInfoFactory.cpp b/WebKit/chromium/src/gtk/WebScreenInfoFactory.cpp new file mode 100644 index 0000000..081daa2 --- /dev/null +++ b/WebKit/chromium/src/gtk/WebScreenInfoFactory.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebScreenInfoFactory.h" + +#include "WebScreenInfo.h" +#include <gtk/gtk.h> + +namespace WebKit { + +WebScreenInfo WebScreenInfoFactory::screenInfo(GtkWidget* widget) +{ + WebScreenInfo results; + results.depth = 32; + results.depthPerComponent = 8; + results.isMonochrome = false; + + if (!widget) + return results; + + GdkScreen* screen = gtk_widget_get_screen(widget); + + results.rect = WebRect( + 0, 0, gdk_screen_get_width(screen), gdk_screen_get_height(screen)); + + // I don't know of a way to query the "maximize" size of the window (e.g. + // screen size less sidebars etc) since this is something which only the + // window manager knows. + results.availableRect = results.rect; + + return results; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/linux/WebFontRendering.cpp b/WebKit/chromium/src/linux/WebFontRendering.cpp new file mode 100644 index 0000000..b9862f5 --- /dev/null +++ b/WebKit/chromium/src/linux/WebFontRendering.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebFontRendering.h" + +#include "FontPlatformData.h" + +using WebCore::FontPlatformData; + +namespace WebKit { + +// static +void WebFontRendering::setHinting(SkPaint::Hinting hinting) +{ + FontPlatformData::setHinting(hinting); +} + +// static +void WebFontRendering::setAntiAlias(bool isAntiAlias) +{ + FontPlatformData::setAntiAlias(isAntiAlias); +} + +// static +void WebFontRendering::setSubpixelGlyphs(bool isSubpixelGlyphs) +{ + FontPlatformData::setSubpixelGlyphs(isSubpixelGlyphs); +} + +// static +void WebFontRendering::setLCDOrder(SkFontHost::LCDOrder order) +{ + SkFontHost::SetSubpixelOrder(order); +} + +// static +void WebFontRendering::setLCDOrientation(SkFontHost::LCDOrientation orientation) +{ + SkFontHost::SetSubpixelOrientation(orientation); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/mac/WebInputEventFactory.mm b/WebKit/chromium/src/mac/WebInputEventFactory.mm new file mode 100644 index 0000000..d618228 --- /dev/null +++ b/WebKit/chromium/src/mac/WebInputEventFactory.mm @@ -0,0 +1,1196 @@ +/* + * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006-2009 Google Inc. + * + * 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. + */ + +#include "config.h" +#include "WebInputEventFactory.h" + +#include <ApplicationServices/ApplicationServices.h> +#import <Cocoa/Cocoa.h> + +#include "WebInputEvent.h" +#include <wtf/ASCIICType.h> + +namespace WebKit { + +// WebKeyboardEvent ----------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// Begin Apple code, copied from KeyEventMac.mm +// +// We can share some of this code if we factored it out of KeyEventMac, but +// the main problem is that it relies on the NSString ctor on String for +// conversions, and since we're building without PLATFORM(MAC), we don't have +// that. As a result we have to use NSString here exclusively and thus tweak +// the code so it's not re-usable as-is. One possiblity would be to make the +// upstream code only use NSString, but I'm not certain how far that change +// would propagate. + +static inline bool isKeyUpEvent(NSEvent* event) +{ + if ([event type] != NSFlagsChanged) + return [event type] == NSKeyUp; + // FIXME: This logic fails if the user presses both Shift keys at once, for example: + // we treat releasing one of them as keyDown. + switch ([event keyCode]) { + case 54: // Right Command + case 55: // Left Command + return ([event modifierFlags] & NSCommandKeyMask) == 0; + + case 57: // Capslock + return ([event modifierFlags] & NSAlphaShiftKeyMask) == 0; + + case 56: // Left Shift + case 60: // Right Shift + return ([event modifierFlags] & NSShiftKeyMask) == 0; + + case 58: // Left Alt + case 61: // Right Alt + return ([event modifierFlags] & NSAlternateKeyMask) == 0; + + case 59: // Left Ctrl + case 62: // Right Ctrl + return ([event modifierFlags] & NSControlKeyMask) == 0; + + case 63: // Function + return ([event modifierFlags] & NSFunctionKeyMask) == 0; + } + return false; +} + +static bool isKeypadEvent(NSEvent* event) +{ + // Check that this is the type of event that has a keyCode. + switch ([event type]) { + case NSKeyDown: + case NSKeyUp: + case NSFlagsChanged: + break; + default: + return false; + } + + switch ([event keyCode]) { + case 71: // Clear + case 81: // = + case 75: // / + case 67: // * + case 78: // - + case 69: // + + case 76: // Enter + case 65: // . + case 82: // 0 + case 83: // 1 + case 84: // 2 + case 85: // 3 + case 86: // 4 + case 87: // 5 + case 88: // 6 + case 89: // 7 + case 91: // 8 + case 92: // 9 + return true; + } + + return false; +} + +static int windowsKeyCodeForKeyEvent(NSEvent* event) +{ + switch ([event keyCode]) { + // VK_TAB (09) TAB key + case 48: + return 0x09; + + // VK_APPS (5D) Right windows/meta key + case 54: // Right Command + return 0x5D; + + // VK_LWIN (5B) Left windows/meta key + case 55: // Left Command + return 0x5B; + + // VK_CAPITAL (14) caps locks key + case 57: // Capslock + return 0x14; + + // VK_SHIFT (10) either shift key + case 56: // Left Shift + case 60: // Right Shift + return 0x10; + + // VK_MENU (12) either alt key + case 58: // Left Alt + case 61: // Right Alt + return 0x12; + + // VK_CONTROL (11) either ctrl key + case 59: // Left Ctrl + case 62: // Right Ctrl + return 0x11; + +// Begin non-Apple addition --------------------------------------------------- + case 63: // Function (no Windows key code) + return 0; +// End non-Apple addition ----------------------------------------------------- + + // VK_CLEAR (0C) CLEAR key + case 71: return 0x0C; + + // VK_NUMPAD0 (60) Numeric keypad 0 key + case 82: return 0x60; + // VK_NUMPAD1 (61) Numeric keypad 1 key + case 83: return 0x61; + // VK_NUMPAD2 (62) Numeric keypad 2 key + case 84: return 0x62; + // VK_NUMPAD3 (63) Numeric keypad 3 key + case 85: return 0x63; + // VK_NUMPAD4 (64) Numeric keypad 4 key + case 86: return 0x64; + // VK_NUMPAD5 (65) Numeric keypad 5 key + case 87: return 0x65; + // VK_NUMPAD6 (66) Numeric keypad 6 key + case 88: return 0x66; + // VK_NUMPAD7 (67) Numeric keypad 7 key + case 89: return 0x67; + // VK_NUMPAD8 (68) Numeric keypad 8 key + case 91: return 0x68; + // VK_NUMPAD9 (69) Numeric keypad 9 key + case 92: return 0x69; + // VK_MULTIPLY (6A) Multiply key + case 67: return 0x6A; + // VK_ADD (6B) Add key + case 69: return 0x6B; + + // VK_SUBTRACT (6D) Subtract key + case 78: return 0x6D; + // VK_DECIMAL (6E) Decimal key + case 65: return 0x6E; + // VK_DIVIDE (6F) Divide key + case 75: return 0x6F; + } + +// Begin non-Apple addition --------------------------------------------------- + // |-[NSEvent charactersIgnoringModifiers]| isn't allowed for + // NSFlagsChanged, and conceivably we may not have caught everything + // which causes an NSFlagsChanged above. + if ([event type] == NSFlagsChanged) + return 0; +// End non-Apple addition ----------------------------------------------------- + + NSString* s = [event charactersIgnoringModifiers]; + if ([s length] != 1) + return 0; + + switch ([s characterAtIndex:0]) { + // VK_LBUTTON (01) Left mouse button + // VK_RBUTTON (02) Right mouse button + // VK_CANCEL (03) Control-break processing + // VK_MBUTTON (04) Middle mouse button (three-button mouse) + // VK_XBUTTON1 (05) + // VK_XBUTTON2 (06) + + // VK_BACK (08) BACKSPACE key + case 8: case 0x7F: return 0x08; + // VK_TAB (09) TAB key + case 9: return 0x09; + + // VK_CLEAR (0C) CLEAR key + // handled by key code above + + // VK_RETURN (0D) + case 0xD: case 3: return 0x0D; + + // VK_SHIFT (10) SHIFT key + // VK_CONTROL (11) CTRL key + // VK_MENU (12) ALT key + + // VK_PAUSE (13) PAUSE key + case NSPauseFunctionKey: return 0x13; + + // VK_CAPITAL (14) CAPS LOCK key + // VK_KANA (15) Input Method Editor (IME) Kana mode + // VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL) + // VK_HANGUL (15) IME Hangul mode + // VK_JUNJA (17) IME Junja mode + // VK_FINAL (18) IME final mode + // VK_HANJA (19) IME Hanja mode + // VK_KANJI (19) IME Kanji mode + + // VK_ESCAPE (1B) ESC key + case 0x1B: return 0x1B; + + // VK_CONVERT (1C) IME convert + // VK_NONCONVERT (1D) IME nonconvert + // VK_ACCEPT (1E) IME accept + // VK_MODECHANGE (1F) IME mode change request + + // VK_SPACE (20) SPACEBAR + case ' ': return 0x20; + // VK_PRIOR (21) PAGE UP key + case NSPageUpFunctionKey: return 0x21; + // VK_NEXT (22) PAGE DOWN key + case NSPageDownFunctionKey: return 0x22; + // VK_END (23) END key + case NSEndFunctionKey: return 0x23; + // VK_HOME (24) HOME key + case NSHomeFunctionKey: return 0x24; + // VK_LEFT (25) LEFT ARROW key + case NSLeftArrowFunctionKey: return 0x25; + // VK_UP (26) UP ARROW key + case NSUpArrowFunctionKey: return 0x26; + // VK_RIGHT (27) RIGHT ARROW key + case NSRightArrowFunctionKey: return 0x27; + // VK_DOWN (28) DOWN ARROW key + case NSDownArrowFunctionKey: return 0x28; + // VK_SELECT (29) SELECT key + case NSSelectFunctionKey: return 0x29; + // VK_PRINT (2A) PRINT key + case NSPrintFunctionKey: return 0x2A; + // VK_EXECUTE (2B) EXECUTE key + case NSExecuteFunctionKey: return 0x2B; + // VK_SNAPSHOT (2C) PRINT SCREEN key + case NSPrintScreenFunctionKey: return 0x2C; + // VK_INSERT (2D) INS key + case NSInsertFunctionKey: case NSHelpFunctionKey: return 0x2D; + // VK_DELETE (2E) DEL key + case NSDeleteFunctionKey: return 0x2E; + + // VK_HELP (2F) HELP key + + // (30) 0 key + case '0': case ')': return 0x30; + // (31) 1 key + case '1': case '!': return 0x31; + // (32) 2 key + case '2': case '@': return 0x32; + // (33) 3 key + case '3': case '#': return 0x33; + // (34) 4 key + case '4': case '$': return 0x34; + // (35) 5 key + case '5': case '%': return 0x35; + // (36) 6 key + case '6': case '^': return 0x36; + // (37) 7 key + case '7': case '&': return 0x37; + // (38) 8 key + case '8': case '*': return 0x38; + // (39) 9 key + case '9': case '(': return 0x39; + // (41) A key + case 'a': case 'A': return 0x41; + // (42) B key + case 'b': case 'B': return 0x42; + // (43) C key + case 'c': case 'C': return 0x43; + // (44) D key + case 'd': case 'D': return 0x44; + // (45) E key + case 'e': case 'E': return 0x45; + // (46) F key + case 'f': case 'F': return 0x46; + // (47) G key + case 'g': case 'G': return 0x47; + // (48) H key + case 'h': case 'H': return 0x48; + // (49) I key + case 'i': case 'I': return 0x49; + // (4A) J key + case 'j': case 'J': return 0x4A; + // (4B) K key + case 'k': case 'K': return 0x4B; + // (4C) L key + case 'l': case 'L': return 0x4C; + // (4D) M key + case 'm': case 'M': return 0x4D; + // (4E) N key + case 'n': case 'N': return 0x4E; + // (4F) O key + case 'o': case 'O': return 0x4F; + // (50) P key + case 'p': case 'P': return 0x50; + // (51) Q key + case 'q': case 'Q': return 0x51; + // (52) R key + case 'r': case 'R': return 0x52; + // (53) S key + case 's': case 'S': return 0x53; + // (54) T key + case 't': case 'T': return 0x54; + // (55) U key + case 'u': case 'U': return 0x55; + // (56) V key + case 'v': case 'V': return 0x56; + // (57) W key + case 'w': case 'W': return 0x57; + // (58) X key + case 'x': case 'X': return 0x58; + // (59) Y key + case 'y': case 'Y': return 0x59; + // (5A) Z key + case 'z': case 'Z': return 0x5A; + + // VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard) + // VK_RWIN (5C) Right Windows key (Natural keyboard) + // VK_APPS (5D) Applications key (Natural keyboard) + // VK_SLEEP (5F) Computer Sleep key + + // VK_NUMPAD0 (60) Numeric keypad 0 key + // VK_NUMPAD1 (61) Numeric keypad 1 key + // VK_NUMPAD2 (62) Numeric keypad 2 key + // VK_NUMPAD3 (63) Numeric keypad 3 key + // VK_NUMPAD4 (64) Numeric keypad 4 key + // VK_NUMPAD5 (65) Numeric keypad 5 key + // VK_NUMPAD6 (66) Numeric keypad 6 key + // VK_NUMPAD7 (67) Numeric keypad 7 key + // VK_NUMPAD8 (68) Numeric keypad 8 key + // VK_NUMPAD9 (69) Numeric keypad 9 key + // VK_MULTIPLY (6A) Multiply key + // VK_ADD (6B) Add key + // handled by key code above + + // VK_SEPARATOR (6C) Separator key + + // VK_SUBTRACT (6D) Subtract key + // VK_DECIMAL (6E) Decimal key + // VK_DIVIDE (6F) Divide key + // handled by key code above + + // VK_F1 (70) F1 key + case NSF1FunctionKey: return 0x70; + // VK_F2 (71) F2 key + case NSF2FunctionKey: return 0x71; + // VK_F3 (72) F3 key + case NSF3FunctionKey: return 0x72; + // VK_F4 (73) F4 key + case NSF4FunctionKey: return 0x73; + // VK_F5 (74) F5 key + case NSF5FunctionKey: return 0x74; + // VK_F6 (75) F6 key + case NSF6FunctionKey: return 0x75; + // VK_F7 (76) F7 key + case NSF7FunctionKey: return 0x76; + // VK_F8 (77) F8 key + case NSF8FunctionKey: return 0x77; + // VK_F9 (78) F9 key + case NSF9FunctionKey: return 0x78; + // VK_F10 (79) F10 key + case NSF10FunctionKey: return 0x79; + // VK_F11 (7A) F11 key + case NSF11FunctionKey: return 0x7A; + // VK_F12 (7B) F12 key + case NSF12FunctionKey: return 0x7B; + // VK_F13 (7C) F13 key + case NSF13FunctionKey: return 0x7C; + // VK_F14 (7D) F14 key + case NSF14FunctionKey: return 0x7D; + // VK_F15 (7E) F15 key + case NSF15FunctionKey: return 0x7E; + // VK_F16 (7F) F16 key + case NSF16FunctionKey: return 0x7F; + // VK_F17 (80H) F17 key + case NSF17FunctionKey: return 0x80; + // VK_F18 (81H) F18 key + case NSF18FunctionKey: return 0x81; + // VK_F19 (82H) F19 key + case NSF19FunctionKey: return 0x82; + // VK_F20 (83H) F20 key + case NSF20FunctionKey: return 0x83; + // VK_F21 (84H) F21 key + case NSF21FunctionKey: return 0x84; + // VK_F22 (85H) F22 key + case NSF22FunctionKey: return 0x85; + // VK_F23 (86H) F23 key + case NSF23FunctionKey: return 0x86; + // VK_F24 (87H) F24 key + case NSF24FunctionKey: return 0x87; + + // VK_NUMLOCK (90) NUM LOCK key + + // VK_SCROLL (91) SCROLL LOCK key + case NSScrollLockFunctionKey: return 0x91; + + // VK_LSHIFT (A0) Left SHIFT key + // VK_RSHIFT (A1) Right SHIFT key + // VK_LCONTROL (A2) Left CONTROL key + // VK_RCONTROL (A3) Right CONTROL key + // VK_LMENU (A4) Left MENU key + // VK_RMENU (A5) Right MENU key + // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key + // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key + // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key + // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key + // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key + // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key + // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key + // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key + // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key + // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key + // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key + // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key + // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key + // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key + // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key + // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key + // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key + // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key + + // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key + case ';': case ':': return 0xBA; + // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key + case '=': case '+': return 0xBB; + // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key + case ',': case '<': return 0xBC; + // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key + case '-': case '_': return 0xBD; + // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key + case '.': case '>': return 0xBE; + // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key + case '/': case '?': return 0xBF; + // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key + case '`': case '~': return 0xC0; + // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key + case '[': case '{': return 0xDB; + // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key + case '\\': case '|': return 0xDC; + // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key + case ']': case '}': return 0xDD; + // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key + case '\'': case '"': return 0xDE; + + // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard. + // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard + // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key + // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP + // VK_ATTN (F6) Attn key + // VK_CRSEL (F7) CrSel key + // VK_EXSEL (F8) ExSel key + // VK_EREOF (F9) Erase EOF key + // VK_PLAY (FA) Play key + // VK_ZOOM (FB) Zoom key + // VK_NONAME (FC) Reserved for future use + // VK_PA1 (FD) PA1 key + // VK_OEM_CLEAR (FE) Clear key + } + + return 0; +} + +static inline NSString* textFromEvent(NSEvent* event) +{ + if ([event type] == NSFlagsChanged) + return @""; + return [event characters]; +} + +static inline NSString* unmodifiedTextFromEvent(NSEvent* event) +{ + if ([event type] == NSFlagsChanged) + return @""; + return [event charactersIgnoringModifiers]; +} + +static NSString* keyIdentifierForKeyEvent(NSEvent* event) +{ + if ([event type] == NSFlagsChanged) { + switch ([event keyCode]) { + case 54: // Right Command + case 55: // Left Command + return @"Meta"; + + case 57: // Capslock + return @"CapsLock"; + + case 56: // Left Shift + case 60: // Right Shift + return @"Shift"; + + case 58: // Left Alt + case 61: // Right Alt + return @"Alt"; + + case 59: // Left Ctrl + case 62: // Right Ctrl + return @"Control"; + +// Begin non-Apple addition/modification -------------------------------------- + case 63: // Function + return @"Function"; + + default: // Unknown, but this may be a strange/new keyboard. + return @"Unidentified"; +// End non-Apple addition/modification ---------------------------------------- + } + } + + NSString* s = [event charactersIgnoringModifiers]; + if ([s length] != 1) + return @"Unidentified"; + + unichar c = [s characterAtIndex:0]; + switch (c) { + // Each identifier listed in the DOM spec is listed here. + // Many are simply commented out since they do not appear on standard Macintosh keyboards + // or are on a key that doesn't have a corresponding character. + + // "Accept" + // "AllCandidates" + + // "Alt" + case NSMenuFunctionKey: + return @"Alt"; + + // "Apps" + // "BrowserBack" + // "BrowserForward" + // "BrowserHome" + // "BrowserRefresh" + // "BrowserSearch" + // "BrowserStop" + // "CapsLock" + + // "Clear" + case NSClearLineFunctionKey: + return @"Clear"; + + // "CodeInput" + // "Compose" + // "Control" + // "Crsel" + // "Convert" + // "Copy" + // "Cut" + + // "Down" + case NSDownArrowFunctionKey: + return @"Down"; + // "End" + case NSEndFunctionKey: + return @"End"; + // "Enter" + case 0x3: case 0xA: case 0xD: // Macintosh calls the one on the main keyboard Return, but Windows calls it Enter, so we'll do the same for the DOM + return @"Enter"; + + // "EraseEof" + + // "Execute" + case NSExecuteFunctionKey: + return @"Execute"; + + // "Exsel" + + // "F1" + case NSF1FunctionKey: + return @"F1"; + // "F2" + case NSF2FunctionKey: + return @"F2"; + // "F3" + case NSF3FunctionKey: + return @"F3"; + // "F4" + case NSF4FunctionKey: + return @"F4"; + // "F5" + case NSF5FunctionKey: + return @"F5"; + // "F6" + case NSF6FunctionKey: + return @"F6"; + // "F7" + case NSF7FunctionKey: + return @"F7"; + // "F8" + case NSF8FunctionKey: + return @"F8"; + // "F9" + case NSF9FunctionKey: + return @"F9"; + // "F10" + case NSF10FunctionKey: + return @"F10"; + // "F11" + case NSF11FunctionKey: + return @"F11"; + // "F12" + case NSF12FunctionKey: + return @"F12"; + // "F13" + case NSF13FunctionKey: + return @"F13"; + // "F14" + case NSF14FunctionKey: + return @"F14"; + // "F15" + case NSF15FunctionKey: + return @"F15"; + // "F16" + case NSF16FunctionKey: + return @"F16"; + // "F17" + case NSF17FunctionKey: + return @"F17"; + // "F18" + case NSF18FunctionKey: + return @"F18"; + // "F19" + case NSF19FunctionKey: + return @"F19"; + // "F20" + case NSF20FunctionKey: + return @"F20"; + // "F21" + case NSF21FunctionKey: + return @"F21"; + // "F22" + case NSF22FunctionKey: + return @"F22"; + // "F23" + case NSF23FunctionKey: + return @"F23"; + // "F24" + case NSF24FunctionKey: + return @"F24"; + + // "FinalMode" + + // "Find" + case NSFindFunctionKey: + return @"Find"; + + // "FullWidth" + // "HalfWidth" + // "HangulMode" + // "HanjaMode" + + // "Help" + case NSHelpFunctionKey: + return @"Help"; + + // "Hiragana" + + // "Home" + case NSHomeFunctionKey: + return @"Home"; + // "Insert" + case NSInsertFunctionKey: + return @"Insert"; + + // "JapaneseHiragana" + // "JapaneseKatakana" + // "JapaneseRomaji" + // "JunjaMode" + // "KanaMode" + // "KanjiMode" + // "Katakana" + // "LaunchApplication1" + // "LaunchApplication2" + // "LaunchMail" + + // "Left" + case NSLeftArrowFunctionKey: + return @"Left"; + + // "Meta" + // "MediaNextTrack" + // "MediaPlayPause" + // "MediaPreviousTrack" + // "MediaStop" + + // "ModeChange" + case NSModeSwitchFunctionKey: + return @"ModeChange"; + + // "Nonconvert" + // "NumLock" + + // "PageDown" + case NSPageDownFunctionKey: + return @"PageDown"; + // "PageUp" + case NSPageUpFunctionKey: + return @"PageUp"; + + // "Paste" + + // "Pause" + case NSPauseFunctionKey: + return @"Pause"; + + // "Play" + // "PreviousCandidate" + + // "PrintScreen" + case NSPrintScreenFunctionKey: + return @"PrintScreen"; + + // "Process" + // "Props" + + // "Right" + case NSRightArrowFunctionKey: + return @"Right"; + + // "RomanCharacters" + + // "Scroll" + case NSScrollLockFunctionKey: + return @"Scroll"; + // "Select" + case NSSelectFunctionKey: + return @"Select"; + + // "SelectMedia" + // "Shift" + + // "Stop" + case NSStopFunctionKey: + return @"Stop"; + // "Up" + case NSUpArrowFunctionKey: + return @"Up"; + // "Undo" + case NSUndoFunctionKey: + return @"Undo"; + + // "VolumeDown" + // "VolumeMute" + // "VolumeUp" + // "Win" + // "Zoom" + + // More function keys, not in the key identifier specification. + case NSF25FunctionKey: + return @"F25"; + case NSF26FunctionKey: + return @"F26"; + case NSF27FunctionKey: + return @"F27"; + case NSF28FunctionKey: + return @"F28"; + case NSF29FunctionKey: + return @"F29"; + case NSF30FunctionKey: + return @"F30"; + case NSF31FunctionKey: + return @"F31"; + case NSF32FunctionKey: + return @"F32"; + case NSF33FunctionKey: + return @"F33"; + case NSF34FunctionKey: + return @"F34"; + case NSF35FunctionKey: + return @"F35"; + + // Turn 0x7F into 0x08, because backspace needs to always be 0x08. + case 0x7F: + return @"U+0008"; + // Standard says that DEL becomes U+007F. + case NSDeleteFunctionKey: + return @"U+007F"; + + // Always use 0x09 for tab instead of AppKit's backtab character. + case NSBackTabCharacter: + return @"U+0009"; + + case NSBeginFunctionKey: + case NSBreakFunctionKey: + case NSClearDisplayFunctionKey: + case NSDeleteCharFunctionKey: + case NSDeleteLineFunctionKey: + case NSInsertCharFunctionKey: + case NSInsertLineFunctionKey: + case NSNextFunctionKey: + case NSPrevFunctionKey: + case NSPrintFunctionKey: + case NSRedoFunctionKey: + case NSResetFunctionKey: + case NSSysReqFunctionKey: + case NSSystemFunctionKey: + case NSUserFunctionKey: + // FIXME: We should use something other than the vendor-area Unicode values for the above keys. + // For now, just fall through to the default. + default: + return [NSString stringWithFormat:@"U+%04X", WTF::toASCIIUpper(c)]; + } +} + +// End Apple code. +// ---------------------------------------------------------------------------- + +static inline int modifiersFromEvent(NSEvent* event) { + int modifiers = 0; + + if ([event modifierFlags] & NSControlKeyMask) + modifiers |= WebInputEvent::ControlKey; + if ([event modifierFlags] & NSShiftKeyMask) + modifiers |= WebInputEvent::ShiftKey; + if ([event modifierFlags] & NSAlternateKeyMask) + modifiers |= WebInputEvent::AltKey; + if ([event modifierFlags] & NSCommandKeyMask) + modifiers |= WebInputEvent::MetaKey; + // TODO(port): Set mouse button states + + return modifiers; +} + +WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event) +{ + WebKeyboardEvent result; + + result.type = + isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::RawKeyDown; + + result.modifiers = modifiersFromEvent(event); + + if (isKeypadEvent(event)) + result.modifiers |= WebInputEvent::IsKeyPad; + + if (([event type] != NSFlagsChanged) && [event isARepeat]) + result.modifiers |= WebInputEvent::IsAutoRepeat; + + result.windowsKeyCode = windowsKeyCodeForKeyEvent(event); + result.nativeKeyCode = [event keyCode]; + + NSString* textStr = textFromEvent(event); + NSString* unmodifiedStr = unmodifiedTextFromEvent(event); + NSString* identifierStr = keyIdentifierForKeyEvent(event); + + // Begin Apple code, copied from KeyEventMac.mm + + // Always use 13 for Enter/Return -- we don't want to use AppKit's + // different character for Enter. + if (result.windowsKeyCode == '\r') { + textStr = @"\r"; + unmodifiedStr = @"\r"; + } + + // The adjustments below are only needed in backward compatibility mode, + // but we cannot tell what mode we are in from here. + + // Turn 0x7F into 8, because backspace needs to always be 8. + if ([textStr isEqualToString:@"\x7F"]) + textStr = @"\x8"; + if ([unmodifiedStr isEqualToString:@"\x7F"]) + unmodifiedStr = @"\x8"; + // Always use 9 for tab -- we don't want to use AppKit's different character + // for shift-tab. + if (result.windowsKeyCode == 9) { + textStr = @"\x9"; + unmodifiedStr = @"\x9"; + } + + // End Apple code. + + if ([textStr length] < WebKeyboardEvent::textLengthCap && + [unmodifiedStr length] < WebKeyboardEvent::textLengthCap) { + [textStr getCharacters:&result.text[0]]; + [unmodifiedStr getCharacters:&result.unmodifiedText[0]]; + } else + ASSERT_NOT_REACHED(); + + [identifierStr getCString:&result.keyIdentifier[0] + maxLength:sizeof(result.keyIdentifier) + encoding:NSASCIIStringEncoding]; + + result.timeStampSeconds = [event timestamp]; + + // Windows and Linux set |isSystemKey| if alt is down. WebKit looks at this + // flag to decide if it should handle a key or not. E.g. alt-left/right + // shouldn't be used by WebKit to scroll the current page, because we want + // to get that key back for it to do history navigation. Hence, the + // corresponding situation on OS X is to set this for cmd key presses. + if (result.modifiers & WebInputEvent::MetaKey) + result.isSystemKey = true; + + return result; +} + +WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, + int modifiers, + double timeStampSeconds) +{ + // keyboardEvent(NSEvent*) depends on the NSEvent object and + // it is hard to use it from methods of the NSTextInput protocol. For + // such methods, this function creates a WebInputEvent::Char event without + // using a NSEvent object. + WebKeyboardEvent result; + result.type = WebKit::WebInputEvent::Char; + result.timeStampSeconds = timeStampSeconds; + result.modifiers = modifiers; + result.windowsKeyCode = character; + result.nativeKeyCode = character; + result.text[0] = character; + result.unmodifiedText[0] = character; + + // Windows and Linux set |isSystemKey| if alt is down. WebKit looks at this + // flag to decide if it should handle a key or not. E.g. alt-left/right + // shouldn't be used by WebKit to scroll the current page, because we want + // to get that key back for it to do history navigation. Hence, the + // corresponding situation on OS X is to set this for cmd key presses. + if (result.modifiers & WebInputEvent::MetaKey) + result.isSystemKey = true; + + return result; +} + +// WebMouseEvent -------------------------------------------------------------- + +WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view) +{ + WebMouseEvent result; + + result.clickCount = 0; + + switch ([event type]) { + case NSMouseExited: + result.type = WebInputEvent::MouseLeave; + result.button = WebMouseEvent::ButtonNone; + break; + case NSLeftMouseDown: + result.type = WebInputEvent::MouseDown; + result.clickCount = [event clickCount]; + result.button = WebMouseEvent::ButtonLeft; + break; + case NSOtherMouseDown: + result.type = WebInputEvent::MouseDown; + result.clickCount = [event clickCount]; + result.button = WebMouseEvent::ButtonMiddle; + break; + case NSRightMouseDown: + result.type = WebInputEvent::MouseDown; + result.clickCount = [event clickCount]; + result.button = WebMouseEvent::ButtonRight; + break; + case NSLeftMouseUp: + result.type = WebInputEvent::MouseUp; + result.button = WebMouseEvent::ButtonLeft; + break; + case NSOtherMouseUp: + result.type = WebInputEvent::MouseUp; + result.button = WebMouseEvent::ButtonMiddle; + break; + case NSRightMouseUp: + result.type = WebInputEvent::MouseUp; + result.button = WebMouseEvent::ButtonRight; + break; + case NSMouseMoved: + case NSMouseEntered: + result.type = WebInputEvent::MouseMove; + break; + case NSLeftMouseDragged: + result.type = WebInputEvent::MouseMove; + result.button = WebMouseEvent::ButtonLeft; + break; + case NSOtherMouseDragged: + result.type = WebInputEvent::MouseMove; + result.button = WebMouseEvent::ButtonMiddle; + break; + case NSRightMouseDragged: + result.type = WebInputEvent::MouseMove; + result.button = WebMouseEvent::ButtonRight; + break; + default: + ASSERT_NOT_REACHED(); + } + + NSPoint location = [NSEvent mouseLocation]; // global coordinates + result.globalX = location.x; + result.globalY = [[[view window] screen] frame].size.height - location.y; + + NSPoint windowLocal = [event locationInWindow]; + location = [view convertPoint:windowLocal fromView:nil]; + result.y = [view frame].size.height - location.y; // flip y + result.x = location.x; + result.windowX = result.x; + result.windowY = result.y; + + result.modifiers = modifiersFromEvent(event); + + result.timeStampSeconds = [event timestamp]; + + return result; +} + +// WebMouseWheelEvent --------------------------------------------------------- + +WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(NSEvent* event, NSView* view) +{ + WebMouseWheelEvent result; + + result.type = WebInputEvent::MouseWheel; + result.button = WebMouseEvent::ButtonNone; + + result.modifiers = modifiersFromEvent(event); + + // Set coordinates by translating event coordinates from screen to client. + NSPoint location = [NSEvent mouseLocation]; // global coordinates + result.globalX = location.x; + result.globalY = location.y; + NSPoint windowLocal = [event locationInWindow]; + location = [view convertPoint:windowLocal fromView:nil]; + result.x = location.x; + result.y = [view frame].size.height - location.y; // flip y + result.windowX = result.x; + result.windowY = result.y; + + // Of Mice and Men + // --------------- + // + // There are three types of scroll data available on a scroll wheel CGEvent. + // Apple's documentation ([1]) is rather vague in their differences, and not + // terribly helpful in deciding which to use. This is what's really going on. + // + // First, these events behave very differently depending on whether a standard + // wheel mouse is used (one that scrolls in discrete units) or a + // trackpad/Mighty Mouse is used (which both provide continuous scrolling). + // You must check to see which was used for the event by testing the + // kCGScrollWheelEventIsContinuous field. + // + // Second, these events refer to "axes". Axis 1 is the y-axis, and axis 2 is + // the x-axis. + // + // Third, there is a concept of mouse acceleration. Scrolling the same amount + // of physical distance will give you different results logically depending on + // whether you scrolled a little at a time or in one continuous motion. Some + // fields account for this while others do not. + // + // Fourth, for trackpads there is a concept of chunkiness. When scrolling + // continuously, events can be delivered in chunks. That is to say, lots of + // scroll events with delta 0 will be delivered, and every so often an event + // with a non-zero delta will be delivered, containing the accumulated deltas + // from all the intermediate moves. [2] + // + // For notchy wheel mice (kCGScrollWheelEventIsContinuous == 0) + // ------------------------------------------------------------ + // + // kCGScrollWheelEventDeltaAxis* + // This is the rawest of raw events. For each mouse notch you get a value of + // +1/-1. This does not take acceleration into account and thus is less + // useful for building UIs. + // + // kCGScrollWheelEventPointDeltaAxis* + // This is smarter. In general, for each mouse notch you get a value of + // +1/-1, but this _does_ take acceleration into account, so you will get + // larger values on longer scrolls. This field would be ideal for building + // UIs except for one nasty bug: when the shift key is pressed, this set of + // fields fails to move the value into the axis2 field (the other two types + // of data do). This wouldn't be so bad except for the fact that while the + // number of axes is used in the creation of a CGScrollWheelEvent, there is + // no way to get that information out of the event once created. + // + // kCGScrollWheelEventFixedPtDeltaAxis* + // This is a fixed value, and for each mouse notch you get a value of + // +0.1/-0.1 (but, like above, scaled appropriately for acceleration). This + // value takes acceleration into account, and in fact is identical to the + // results you get from -[NSEvent delta*]. (That is, if you linked on Tiger + // or greater; see [2] for details.) + // + // A note about continuous devices + // ------------------------------- + // + // There are two devices that provide continuous scrolling events (trackpads + // and Mighty Mouses) and they behave rather differently. The Mighty Mouse + // behaves a lot like a regular mouse. There is no chunking, and the + // FixedPtDelta values are the PointDelta values multiplied by 0.1. With the + // trackpad, though, there is chunking. While the FixedPtDelta values are + // reasonable (they occur about every fifth event but have values five times + // larger than usual) the Delta values are unreasonable. They don't appear to + // accumulate properly. + // + // For continuous devices (kCGScrollWheelEventIsContinuous != 0) + // ------------------------------------------------------------- + // + // kCGScrollWheelEventDeltaAxis* + // This provides values with no acceleration. With a trackpad, these values + // are chunked but each non-zero value does not appear to be cumulative. + // This seems to be a bug. + // + // kCGScrollWheelEventPointDeltaAxis* + // This provides values with acceleration. With a trackpad, these values are + // not chunked and are highly accurate. + // + // kCGScrollWheelEventFixedPtDeltaAxis* + // This provides values with acceleration. With a trackpad, these values are + // chunked but unlike Delta events are properly cumulative. + // + // Summary + // ------- + // + // In general the best approach to take is: determine if the event is + // continuous. If it is not, then use the FixedPtDelta events (or just stick + // with Cocoa events). They provide both acceleration and proper horizontal + // scrolling. If the event is continuous, then doing pixel scrolling with the + // PointDelta is the way to go. In general, avoid the Delta events. They're + // the oldest (dating back to 10.4, before CGEvents were public) but they lack + // acceleration and precision, making them useful only in specific edge cases. + // + // References + // ---------- + // + // [1] <http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html> + // [2] <http://developer.apple.com/releasenotes/Cocoa/AppKitOlderNotes.html> + // Scroll to the section headed "NSScrollWheel events". + // + // P.S. The "smooth scrolling" option in the system preferences is utterly + // unrelated to any of this. + + CGEventRef cgEvent = [event CGEvent]; + ASSERT(cgEvent); + + // Wheel ticks are supposed to be raw, unaccelerated values, one per physical + // mouse wheel notch. The delta event is perfect for this (being a good + // "specific edge case" as mentioned above). Trackpads, unfortunately, do + // event chunking, and sending mousewheel events with 0 ticks causes some + // websites to malfunction. Therefore, for all continuous input devices we use + // the point delta data instead, since we cannot distinguish trackpad data + // from data from any other continuous device. + + if (CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventIsContinuous)) { + result.wheelTicksY = result.deltaY = + CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1); + result.wheelTicksX = result.deltaX = + CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2); + } else { + result.wheelTicksY = + CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventDeltaAxis1); + result.wheelTicksX = + CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventDeltaAxis2); + + // Convert wheel delta amount to a number of pixels to scroll. + static const double scrollbarPixelsPerCocoaTick = 40.0; + + result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick; + result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick; + } + + result.timeStampSeconds = [event timestamp]; + + return result; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/mac/WebScreenInfoFactory.mm b/WebKit/chromium/src/mac/WebScreenInfoFactory.mm new file mode 100644 index 0000000..2805f7a --- /dev/null +++ b/WebKit/chromium/src/mac/WebScreenInfoFactory.mm @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebScreenInfoFactory.h" + +#import <AppKit/AppKit.h> + +#include "WebScreenInfo.h" + +namespace WebKit { + +static NSScreen* screenForWindow(NSWindow* window) +{ + NSScreen* screen = [window screen]; // nil if the window is off-screen + if (screen) + return screen; + + NSArray* screens = [NSScreen screens]; + if ([screens count] > 0) + return [screens objectAtIndex:0]; // screen containing the menubar + + return nil; +} + +static WebRect toUserSpace(const NSRect& rect, NSWindow* destination) +{ + CGRect userRect = NSRectToCGRect(rect); + + userRect.origin.y = + NSMaxY([screenForWindow(destination) frame]) - (userRect.origin.y + userRect.size.height); // flip + + if (destination) { + CGFloat scale = 1 / [destination userSpaceScaleFactor]; // scale down + userRect.origin.x *= scale; + userRect.origin.y *= scale; + userRect.size.width *= scale; + userRect.size.height *= scale; + } + + return WebRect(userRect.origin.x, + userRect.origin.y, + userRect.size.width, + userRect.size.height); +} + +WebScreenInfo WebScreenInfoFactory::screenInfo(NSView* view) +{ + NSString *colorSpace = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]); + + WebScreenInfo results; + results.depth = + NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]); + results.depthPerComponent = + NSBitsPerSampleFromDepth([[NSScreen deepestScreen] depth]); + results.isMonochrome = colorSpace == NSCalibratedWhiteColorSpace + || colorSpace == NSCalibratedBlackColorSpace + || colorSpace == NSDeviceWhiteColorSpace + || colorSpace == NSDeviceBlackColorSpace; + results.rect = + toUserSpace([screenForWindow([view window]) frame], [view window]); + results.availableRect = + toUserSpace([screenForWindow([view window]) visibleFrame], [view window]); + return results; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/win/WebInputEventFactory.cpp b/WebKit/chromium/src/win/WebInputEventFactory.cpp new file mode 100644 index 0000000..a5bd935 --- /dev/null +++ b/WebKit/chromium/src/win/WebInputEventFactory.cpp @@ -0,0 +1,437 @@ +/* + * Copyright (C) 2006-2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebInputEventFactory.h" + +#include "WebInputEvent.h" + +#include <wtf/Assertions.h> + +namespace WebKit { + +static const unsigned long defaultScrollLinesPerWheelDelta = 3; +static const unsigned long defaultScrollCharsPerWheelDelta = 1; + +// WebKeyboardEvent ----------------------------------------------------------- + +static bool isKeyPad(WPARAM wparam, LPARAM lparam) +{ + bool keypad = false; + switch (wparam) { + case VK_RETURN: + keypad = (lparam >> 16) & KF_EXTENDED; + break; + case VK_INSERT: + case VK_DELETE: + case VK_HOME: + case VK_END: + case VK_PRIOR: + case VK_NEXT: + case VK_UP: + case VK_DOWN: + case VK_LEFT: + case VK_RIGHT: + keypad = !((lparam >> 16) & KF_EXTENDED); + break; + case VK_NUMLOCK: + case VK_NUMPAD0: + case VK_NUMPAD1: + case VK_NUMPAD2: + case VK_NUMPAD3: + case VK_NUMPAD4: + case VK_NUMPAD5: + case VK_NUMPAD6: + case VK_NUMPAD7: + case VK_NUMPAD8: + case VK_NUMPAD9: + case VK_DIVIDE: + case VK_MULTIPLY: + case VK_SUBTRACT: + case VK_ADD: + case VK_DECIMAL: + case VK_CLEAR: + keypad = true; + break; + default: + keypad = false; + } + return keypad; +} + +WebKeyboardEvent WebInputEventFactory::keyboardEvent(HWND hwnd, UINT message, + WPARAM wparam, LPARAM lparam) +{ + WebKeyboardEvent result; + + // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that + // GetMessageTime() refers to is the same one that we're passed in? Perhaps + // one of the construction parameters should be the time passed by the + // caller, who would know for sure. + result.timeStampSeconds = GetMessageTime() / 1000.0; + + result.windowsKeyCode = result.nativeKeyCode = static_cast<int>(wparam); + + switch (message) { + case WM_SYSKEYDOWN: + result.isSystemKey = true; + case WM_KEYDOWN: + result.type = WebInputEvent::RawKeyDown; + break; + case WM_SYSKEYUP: + result.isSystemKey = true; + case WM_KEYUP: + result.type = WebInputEvent::KeyUp; + break; + case WM_IME_CHAR: + result.type = WebInputEvent::Char; + break; + case WM_SYSCHAR: + result.isSystemKey = true; + result.type = WebInputEvent::Char; + case WM_CHAR: + result.type = WebInputEvent::Char; + break; + default: + ASSERT_NOT_REACHED(); + } + + if (result.type == WebInputEvent::Char || result.type == WebInputEvent::RawKeyDown) { + result.text[0] = result.windowsKeyCode; + result.unmodifiedText[0] = result.windowsKeyCode; + } + if (result.type != WebInputEvent::Char) + result.setKeyIdentifierFromWindowsKeyCode(); + + if (GetKeyState(VK_SHIFT) & 0x8000) + result.modifiers |= WebInputEvent::ShiftKey; + if (GetKeyState(VK_CONTROL) & 0x8000) + result.modifiers |= WebInputEvent::ControlKey; + if (GetKeyState(VK_MENU) & 0x8000) + result.modifiers |= WebInputEvent::AltKey; + // NOTE: There doesn't seem to be a way to query the mouse button state in + // this case. + + if (LOWORD(lparam) > 1) + result.modifiers |= WebInputEvent::IsAutoRepeat; + if (isKeyPad(wparam, lparam)) + result.modifiers |= WebInputEvent::IsKeyPad; + + return result; +} + +// WebMouseEvent -------------------------------------------------------------- + +static int gLastClickCount; +static double gLastClickTime; + +static LPARAM GetRelativeCursorPos(HWND hwnd) +{ + POINT pos = {-1, -1}; + GetCursorPos(&pos); + ScreenToClient(hwnd, &pos); + return MAKELPARAM(pos.x, pos.y); +} + +void WebInputEventFactory::resetLastClickState() +{ + gLastClickTime = gLastClickCount = 0; +} + +WebMouseEvent WebInputEventFactory::mouseEvent(HWND hwnd, UINT message, + WPARAM wparam, LPARAM lparam) +{ + WebMouseEvent result; //(WebInputEvent::Uninitialized()); + + switch (message) { + case WM_MOUSEMOVE: + result.type = WebInputEvent::MouseMove; + if (wparam & MK_LBUTTON) + result.button = WebMouseEvent::ButtonLeft; + else if (wparam & MK_MBUTTON) + result.button = WebMouseEvent::ButtonMiddle; + else if (wparam & MK_RBUTTON) + result.button = WebMouseEvent::ButtonRight; + else + result.button = WebMouseEvent::ButtonNone; + break; + case WM_MOUSELEAVE: + result.type = WebInputEvent::MouseLeave; + result.button = WebMouseEvent::ButtonNone; + // set the current mouse position (relative to the client area of the + // current window) since none is specified for this event + lparam = GetRelativeCursorPos(hwnd); + break; + case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + result.type = WebInputEvent::MouseDown; + result.button = WebMouseEvent::ButtonLeft; + break; + case WM_MBUTTONDOWN: + case WM_MBUTTONDBLCLK: + result.type = WebInputEvent::MouseDown; + result.button = WebMouseEvent::ButtonMiddle; + break; + case WM_RBUTTONDOWN: + case WM_RBUTTONDBLCLK: + result.type = WebInputEvent::MouseDown; + result.button = WebMouseEvent::ButtonRight; + break; + case WM_LBUTTONUP: + result.type = WebInputEvent::MouseUp; + result.button = WebMouseEvent::ButtonLeft; + break; + case WM_MBUTTONUP: + result.type = WebInputEvent::MouseUp; + result.button = WebMouseEvent::ButtonMiddle; + break; + case WM_RBUTTONUP: + result.type = WebInputEvent::MouseUp; + result.button = WebMouseEvent::ButtonRight; + break; + default: + ASSERT_NOT_REACHED(); + } + + // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that + // GetMessageTime() refers to is the same one that we're passed in? Perhaps + // one of the construction parameters should be the time passed by the + // caller, who would know for sure. + result.timeStampSeconds = GetMessageTime() / 1000.0; + + // set position fields: + + result.x = static_cast<short>(LOWORD(lparam)); + result.y = static_cast<short>(HIWORD(lparam)); + result.windowX = result.x; + result.windowY = result.y; + + POINT globalPoint = { result.x, result.y }; + ClientToScreen(hwnd, &globalPoint); + + result.globalX = globalPoint.x; + result.globalY = globalPoint.y; + + // calculate number of clicks: + + // This differs slightly from the WebKit code in WebKit/win/WebView.cpp + // where their original code looks buggy. + static int lastClickPositionX; + static int lastClickPositionY; + static WebMouseEvent::Button lastClickButton = WebMouseEvent::ButtonLeft; + + double currentTime = result.timeStampSeconds; + bool cancelPreviousClick = + (abs(lastClickPositionX - result.x) > (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) + || (abs(lastClickPositionY - result.y) > (GetSystemMetrics(SM_CYDOUBLECLK) / 2)) + || ((currentTime - gLastClickTime) * 1000.0 > GetDoubleClickTime()); + + if (result.type == WebInputEvent::MouseDown) { + if (!cancelPreviousClick && (result.button == lastClickButton)) + ++gLastClickCount; + else { + gLastClickCount = 1; + lastClickPositionX = result.x; + lastClickPositionY = result.y; + } + gLastClickTime = currentTime; + lastClickButton = result.button; + } else if (result.type == WebInputEvent::MouseMove + || result.type == WebInputEvent::MouseLeave) { + if (cancelPreviousClick) { + gLastClickCount = 0; + lastClickPositionX = 0; + lastClickPositionY = 0; + gLastClickTime = 0; + } + } + result.clickCount = gLastClickCount; + + // set modifiers: + + if (wparam & MK_CONTROL) + result.modifiers |= WebInputEvent::ControlKey; + if (wparam & MK_SHIFT) + result.modifiers |= WebInputEvent::ShiftKey; + if (GetKeyState(VK_MENU) & 0x8000) + result.modifiers |= WebInputEvent::AltKey; + if (wparam & MK_LBUTTON) + result.modifiers |= WebInputEvent::LeftButtonDown; + if (wparam & MK_MBUTTON) + result.modifiers |= WebInputEvent::MiddleButtonDown; + if (wparam & MK_RBUTTON) + result.modifiers |= WebInputEvent::RightButtonDown; + + return result; +} + +// WebMouseWheelEvent --------------------------------------------------------- + +WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(HWND hwnd, UINT message, + WPARAM wparam, LPARAM lparam) +{ + WebMouseWheelEvent result; //(WebInputEvent::Uninitialized()); + + result.type = WebInputEvent::MouseWheel; + + // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that + // GetMessageTime() refers to is the same one that we're passed in? Perhaps + // one of the construction parameters should be the time passed by the + // caller, who would know for sure. + result.timeStampSeconds = GetMessageTime() / 1000.0; + + result.button = WebMouseEvent::ButtonNone; + + // Get key state, coordinates, and wheel delta from event. + typedef SHORT (WINAPI *GetKeyStateFunction)(int key); + GetKeyStateFunction getKeyState; + UINT keyState; + float wheelDelta; + bool horizontalScroll = false; + if ((message == WM_VSCROLL) || (message == WM_HSCROLL)) { + // Synthesize mousewheel event from a scroll event. This is needed to + // simulate middle mouse scrolling in some laptops. Use GetAsyncKeyState + // for key state since we are synthesizing the input event. + getKeyState = GetAsyncKeyState; + keyState = 0; + if (getKeyState(VK_SHIFT)) + keyState |= MK_SHIFT; + if (getKeyState(VK_CONTROL)) + keyState |= MK_CONTROL; + // NOTE: There doesn't seem to be a way to query the mouse button state + // in this case. + + POINT cursorPosition = {0}; + GetCursorPos(&cursorPosition); + result.globalX = cursorPosition.x; + result.globalY = cursorPosition.y; + + switch (LOWORD(wparam)) { + case SB_LINEUP: // == SB_LINELEFT + wheelDelta = WHEEL_DELTA; + break; + case SB_LINEDOWN: // == SB_LINERIGHT + wheelDelta = -WHEEL_DELTA; + break; + case SB_PAGEUP: + wheelDelta = 1; + result.scrollByPage = true; + break; + case SB_PAGEDOWN: + wheelDelta = -1; + result.scrollByPage = true; + break; + default: // We don't supoprt SB_THUMBPOSITION or SB_THUMBTRACK here. + wheelDelta = 0; + break; + } + + if (message == WM_HSCROLL) + horizontalScroll = true; + } else { + // Non-synthesized event; we can just read data off the event. + getKeyState = GetKeyState; + keyState = GET_KEYSTATE_WPARAM(wparam); + + result.globalX = static_cast<short>(LOWORD(lparam)); + result.globalY = static_cast<short>(HIWORD(lparam)); + + wheelDelta = static_cast<float>(GET_WHEEL_DELTA_WPARAM(wparam)); + if (message == WM_MOUSEHWHEEL) { + horizontalScroll = true; + wheelDelta = -wheelDelta; // Windows is <- -/+ ->, WebKit <- +/- ->. + } + } + if (keyState & MK_SHIFT) + horizontalScroll = true; + + // Set modifiers based on key state. + if (keyState & MK_SHIFT) + result.modifiers |= WebInputEvent::ShiftKey; + if (keyState & MK_CONTROL) + result.modifiers |= WebInputEvent::ControlKey; + if (getKeyState(VK_MENU) & 0x8000) + result.modifiers |= WebInputEvent::AltKey; + if (keyState & MK_LBUTTON) + result.modifiers |= WebInputEvent::LeftButtonDown; + if (keyState & MK_MBUTTON) + result.modifiers |= WebInputEvent::MiddleButtonDown; + if (keyState & MK_RBUTTON) + result.modifiers |= WebInputEvent::RightButtonDown; + + // Set coordinates by translating event coordinates from screen to client. + POINT clientPoint = { result.globalX, result.globalY }; + MapWindowPoints(0, hwnd, &clientPoint, 1); + result.x = clientPoint.x; + result.y = clientPoint.y; + result.windowX = result.x; + result.windowY = result.y; + + // Convert wheel delta amount to a number of pixels to scroll. + // + // How many pixels should we scroll per line? Gecko uses the height of the + // current line, which means scroll distance changes as you go through the + // page or go to different pages. IE 7 is ~50 px/line, although the value + // seems to vary slightly by page and zoom level. Since IE 7 has a smoothing + // algorithm on scrolling, it can get away with slightly larger scroll values + // without feeling jerky. Here we use 100 px per three lines (the default + // scroll amount is three lines per wheel tick). + static const float scrollbarPixelsPerLine = 100.0f / 3.0f; + wheelDelta /= WHEEL_DELTA; + float scrollDelta = wheelDelta; + if (horizontalScroll) { + unsigned long scrollChars = defaultScrollCharsPerWheelDelta; + SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0); + // TODO(pkasting): Should probably have a different multiplier + // scrollbarPixelsPerChar here. + scrollDelta *= static_cast<float>(scrollChars) * scrollbarPixelsPerLine; + } else { + unsigned long scrollLines = defaultScrollLinesPerWheelDelta; + SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0); + if (scrollLines == WHEEL_PAGESCROLL) + result.scrollByPage = true; + if (!result.scrollByPage) + scrollDelta *= static_cast<float>(scrollLines) * scrollbarPixelsPerLine; + } + + // Set scroll amount based on above calculations. WebKit expects positive + // deltaY to mean "scroll up" and positive deltaX to mean "scroll left". + if (horizontalScroll) { + result.deltaX = scrollDelta; + result.wheelTicksX = wheelDelta; + } else { + result.deltaY = scrollDelta; + result.wheelTicksY = wheelDelta; + } + + return result; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/win/WebScreenInfoFactory.cpp b/WebKit/chromium/src/win/WebScreenInfoFactory.cpp new file mode 100644 index 0000000..8416acc --- /dev/null +++ b/WebKit/chromium/src/win/WebScreenInfoFactory.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebScreenInfoFactory.h" + +#include "WebScreenInfo.h" + +#include <windows.h> + +namespace WebKit { + +static WebRect toWebRect(const RECT& input) +{ + WebRect output; + output.x = input.left; + output.y = input.top; + output.width = input.right - input.left; + output.height = input.bottom - input.top; + return output; +} + +WebScreenInfo WebScreenInfoFactory::screenInfo(HWND window) +{ + HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); + + MONITORINFOEX monitorInfo; + monitorInfo.cbSize = sizeof(MONITORINFOEX); + GetMonitorInfo(monitor, &monitorInfo); + + DEVMODE devMode; + devMode.dmSize = sizeof(devMode); + devMode.dmDriverExtra = 0; + EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode); + + WebScreenInfo results; + results.depth = devMode.dmBitsPerPel; + results.depthPerComponent = devMode.dmBitsPerPel / 3; // Assumes RGB + results.isMonochrome = devMode.dmColor == DMCOLOR_MONOCHROME; + results.rect = toWebRect(monitorInfo.rcMonitor); + results.availableRect = toWebRect(monitorInfo.rcWork); + return results; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp b/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp new file mode 100644 index 0000000..548880c --- /dev/null +++ b/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 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 + * OWNER 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 "WebScreenInfoFactory.h" + +#include "WebScreenInfo.h" + +#include <X11/Xlib.h> + +namespace WebKit { + +WebScreenInfo WebScreenInfoFactory::screenInfo(Display* display, int screenNumber) +{ + WebScreenInfo results; + // FIXME: not all screens with use 8bpp. + results.depthPerComponent = 8; + + int displayWidth = XDisplayWidth(display, screenNumber); + int displayHeight = XDisplayHeight(display, screenNumber); + results.depth = XDisplayPlanes(display, screenNumber); + results.isMonochrome = results.depth == 1; + + results.rect = WebRect(0, 0, displayWidth, displayHeight); + + // I don't know of a way to query the "maximize" size of the window (e.g. + // screen size less sidebars etc) since this is something which only the + // window manager knows. + results.availableRect = results.rect; + + return results; +} + +} // namespace WebKit diff --git a/WebKit/chromium/webkit.gyp b/WebKit/chromium/webkit.gyp deleted file mode 100644 index 04d1bad..0000000 --- a/WebKit/chromium/webkit.gyp +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (C) 2009 Google 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: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * 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. -# * Neither the name of Google Inc. nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# 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 -# OWNER 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. -# - -{ - 'targets': [ - { - # This target only builds webcore right now, but it will also build - # the chromium webkit api once the api is upstreamed. - 'target_name': 'webkit', - 'type': 'none', - 'dependencies': [ - '../../WebCore/WebCore.gyp/WebCore.gyp:webcore', - ], - }, - ], # targets -} diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog index 62aa3da..ac80deb 100644 --- a/WebKit/gtk/ChangeLog +++ b/WebKit/gtk/ChangeLog @@ -1,3 +1,438 @@ +2009-12-10 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> + + Reviewed by Xan Lopez. + + Add a missing null-check, that is causing some crash reports. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::committedLoad): + +2009-12-10 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> + + Reviewed by Xan Lopez. + + [GTK] Should provide an API to control the IconDatabase + https://bugs.webkit.org/show_bug.cgi?id=32334 + + First step towards a full IconDatabase API. This provides + notification for pages with favicons, and lets clients handle + them. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::registerForIconNotification): + (WebKit::FrameLoaderClient::dispatchDidReceiveIcon): + * tests/resources/blank.ico: Added. + * tests/testwebview.c: Added. + (server_callback): + (idle_quit_loop_cb): + (icon_uri_changed_cb): + (icon_loaded_cb): + (test_webkit_web_view_icon_uri): + (main): + * webkit/webkitprivate.cpp: + (closeIconDatabaseOnExit): + (webkit_init): + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + (webkit_web_view_get_property): + (webkit_web_view_finalize): + (webkit_web_view_class_init): + (webkit_web_view_get_icon_uri): + * webkit/webkitwebview.h: + +2009-12-08 Christian Dywan <christian@twotoasts.de> + + Reviewed by Gustavo Noronha Silva. + + Point out the meaning of "Content-Disposition" when implementing the + mime-type-policy-decision-requested signal. + + * webkit/webkitwebview.cpp: + (webkit_web_view_class_init): + +2009-12-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> + + Reviewed by Xan Lopez. + + [GTK] Doesn't respect Content-Disposition for downloads, and provides no way for apps to do that + https://bugs.webkit.org/show_bug.cgi?id=32247 + + Provide a way for applications to respect Content-Disposition, by + fetching the WebKitNetworkResponse from the frame during + mime-type-policy-decision-requested. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType): Download + content when Content-Disposition is attachment. + * tests/testmimehandling.c: + (server_callback): + (mime_type_policy_decision_requested_cb): + * tests/testwebframe.c: + (test_webkit_web_frame_response): + (main): + * webkit/webkitprivate.cpp: + (WebKit::core): + * webkit/webkitwebframe.cpp: + (webkit_web_frame_get_network_response): + * webkit/webkitwebframe.h: + +2009-12-07 Gyuyoung Kim <gyuyoung@gmail.com> + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=32024 + [GTK] WebKit does not compile without JAVASCRIPT_DEBUGGER + + Fix build errors when javascript-debugger is disabled on GTK + + * webkit/webkitwebinspector.cpp: + (webkit_web_inspector_set_property): + (webkit_web_inspector_get_property): + +2009-12-07 Joanmarie Diggs <joanmarie.diggs@gmail.com> + + Reviewed by Xan Lopez. + + https://bugs.webkit.org/show_bug.cgi?id=25415 + [GTK][ATK] Please implement support for get_text_at_offset + + Eliminate the segfaults which occur when accessing the text interface now + implemented by text controls. + + * tests/testatk.c + (test_webkit_atk_get_text_at_offset_textarea): + (test_webkit_atk_get_text_at_offset_text_input): + (main): + +2009-12-06 Gustavo Noronha Silva <gns@gnome.org> + + Reviewed by Xan Lopez. + + New test to make sure we do not regress this feature anymore. All + test files were created by me. + + [GTK] REGRESSION: webkit thinks it can render PDFs + https://bugs.webkit.org/show_bug.cgi?id=32183 + + * tests/resources/test.html: Added. + * tests/resources/test.ogg: Added. + * tests/resources/test.pdf: Added. + * tests/resources/test.txt: Added. + * tests/testmimehandling.c: Added. + (server_callback): + (idle_quit_loop_cb): + (mime_type_policy_decision_requested_cb): + (test_mime_type): + (test_mime_pdf): + (test_mime_html): + (test_mime_text): + (test_mime_ogg): + (main): + +2009-12-05 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> + + Reviewed by Xan Lopez. + + Use a better URI for the unreachable test. localhost:80 is very + likely to be open. + + * tests/testwebdatasource.c: + (load_finished_unreachable_cb): + (test_webkit_web_data_source_unreachable_uri): + +2009-12-03 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7214236> and http://webkit.org/b/32052 - Implement HTML5 state object history API + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDidPushStateWithinPage): + (WebKit::FrameLoaderClient::dispatchDidReplaceStateWithinPage): + (WebKit::FrameLoaderClient::dispatchDidPopStateWithinPage): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::InspectorClient::populateSetting): + (WebKit::InspectorClient::storeSetting): + * WebCoreSupport/InspectorClientGtk.h: + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebKit::FrameLoaderClient::dispatchDidRemoveBackForwardItem): ditto. + (WebKit::FrameLoaderClient::dispatchDidChangeBackForwardIndex): ditto. + * WebCoreSupport/FrameLoaderClientGtk.h: + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Simon Fraser. + + Add SVG animation test framework with 'snapshot' functionality + https://bugs.webkit.org/show_bug.cgi?id=31897 + + Add API used by the new 'sampleSVGAnimationForElementAtTime' DRT method, + forwarding the call to SVGDocumentExtensions, if SVG is enabled. + + Implemented just like the existing pauseAnimation* methods for CSS animations. + + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + (webkit_web_frame_pause_svg_animation): + +2009-11-30 Xan Lopez <xlopez@igalia.com> + + Reviewed by Gustavo Noronha. + + Prepare for 1.1.17 release. + + * NEWS: + * docs/webkitgtk-docs.sgml: + * docs/webkitgtk-sections.txt: + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + +2009-11-26 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Oliver Hunt. + + Move GOwnPtr* from wtf to wtf/gtk + https://bugs.webkit.org/show_bug.cgi?id=31793 + + * webkit/webkitwebview.cpp: Change the path for GOwnPtr.h. + +2009-11-24 Joanmarie Diggs <joanmarie.diggs@gmail.com> + + Reviewed by Xan Lopez. + + https://bugs.webkit.org/show_bug.cgi?id=25415 + [GTK][ATK] Please implement support for get_text_at_offset + + When building up the pango layout from text boxes, only append a + newline char after verifying there are no more boxes on this line. + + * tests/testatk.c + (test_webkit_atk_get_text_at_offset_newlines): + (main): + +2009-11-19 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Gustavo Noronha Silva. + + Web Inspector: Implement "show inspector" in WebKit GTK + API and enable console tests. + + https://bugs.webkit.org/show_bug.cgi?id=31669 + + * webkit/webkitwebinspector.cpp: + (webkit_web_inspector_show): + * webkit/webkitwebinspector.h: + +2009-11-18 Martin Robinson <martin.james.robinson@gmail.com> + + Reviewed by Gustavo Noronha. + + [GTK] Tab key does not cycle through elements by default + https://bugs.webkit.org/show_bug.cgi?id=31505 + + Properly localize documentation strings for the + tab-key-cycles-through-elements property. + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + +2009-11-17 Martin Robinson <martin.james.robinson@gmail.com> + + Reviewed by Gustavo Noronha. + + [GTK] Tab key does not cycle through elements by default + https://bugs.webkit.org/show_bug.cgi?id=31505 + + Ensure that WebKitWebSettings tab-key-cycles-through-elements + property is true by default with the G_PARAM_CONSTRUCT_FLAG. + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + +2009-11-18 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> + + Reviewed by Xan Lopez. + + [GTK] Failing test media/video-document-types.html + https://bugs.webkit.org/show_bug.cgi?id=31352 + + Match what Mac has been doing since r36001: cancel the main load, + and handle failures caused by 'will be handled by plugin' errors. + + Covered by test media/video-document-types.html + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::committedLoad): + (WebKit::FrameLoaderClient::shouldFallBack): + +2009-11-17 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Web Inspector: Make DRT show web inspector for tests in inspector/ folder. + - Updated DRT to show/close inspector for all tests under /inspector + - Introduced LayoutTestController::setTimelineProfilingEnabled and + WebInspector::setTimelineProfilingEnabled beside setJavaScriptProfilingEnabled + - Removed reload on each inspector test + - Renamed fast/inspector to fast/inspector-support in order not to trigger + inspector for those. + - Reimplemented timeline tests in order to get rid of reload there. + - Moved tests that don't require harness into the fast group. + + https://bugs.webkit.org/show_bug.cgi?id=31472 + + * webkit/webkitwebinspector.cpp: + (webkit_web_inspector_class_init): + (webkit_web_inspector_set_property): + (webkit_web_inspector_get_property): + +2009-11-13 Adam Roben <aroben@apple.com> + + Update for changes to FrameLoaderClient + + Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when + window objects in isolated worlds are cleared + + Reviewed by Dave Hyatt. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDidClearWindowObjectInWorld): + * WebCoreSupport/FrameLoaderClientGtk.h: + Replaced windowObjectCleared with this function. Does nothing if the + passed-in world is not the mainThreadNormalWorld(). + +2009-11-12 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Darin Adler. + + externalRepresentation should take Frame as the argument + https://bugs.webkit.org/show_bug.cgi?id=31393 + + No new tests as this is just a refactoring. + + * webkit/webkitwebframe.cpp: + (webkit_web_frame_dump_render_tree): + +2009-11-11 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> + + Reviewed by Holger Freyther. + + Should not print javascript console messages to stdout + https://bugs.webkit.org/show_bug.cgi?id=31346 + + * webkit/webkitwebview.cpp: + (webkit_web_view_real_console_message): Print console messages to + stderr instead, using the recommended method (a g_log variant). + +2009-11-11 Philippe Normand <pnormand@igalia.com> + + Reviewed by Xan Lopez. + + https://bugs.webkit.org/show_bug.cgi?id=30221 + [GTK] fails to load media embedded in iframe element + + The FrameLoader can show Media if the audio/video support is + enabled at compile time. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::canShowMIMEType): + +2009-11-10 Martin Robinson <martin.james.robinson@gmail.com> + + Reviewed by Jan Alonzo. + + [GTK] Remove WebSocket configuration from WebKitWebSettings + https://bugs.webkit.org/show_bug.cgi?id=31244 + + Remove non-functional enable-web-sockets property from WebKitWebSettings. + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + (webkit_web_settings_set_property): + (webkit_web_settings_get_property): + (webkit_web_settings_copy): + +2009-11-09 Martin Robinson <martin.james.robinson@gmail.com> + + Reviewed by Jan Alonzo. + + [GTK] Expose Page::tabKeyCyclesThroughElements in the API + https://bugs.webkit.org/show_bug.cgi?id=30482 + + Expose Page::tabKeyCyclesThroughElements as a property of + WebKitWebSettings. + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + (webkit_web_settings_set_property): + (webkit_web_settings_get_property): + * webkit/webkitwebview.cpp: + (webkit_web_view_update_settings): + (webkit_web_view_settings_notify): + +2009-11-04 Martin Robinson <martin.james.robinson@gmail.com> + + Reviewed by Jan Alonzo. + + [GTK] Enable DOM clipboard and drag-and-drop access + https://bugs.webkit.org/show_bug.cgi?id=30623 + + Move handling of target list to PasteboardHelperGtk. + + * WebCoreSupport/PasteboardHelperGtk.cpp: + (WebKit::PasteboardHelperGtk::PasteboardHelperGtk): + (WebKit::PasteboardHelperGtk::~PasteboardHelperGtk): + (WebKit::PasteboardHelperGtk::fullTargetList): + * WebCoreSupport/PasteboardHelperGtk.h: + * webkit/webkitprivate.cpp: + (WebKit::pasteboardHelperInstance): + (webkit_init): + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + (webkit_web_view_dispose): + (webkit_web_view_init): + (webkit_web_view_get_copy_target_list): + (webkit_web_view_get_paste_target_list): + +2009-10-30 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Notify the chrome when the focused node has changed. + https://bugs.webkit.org/show_bug.cgi?id=30832 + + Added stub implementation for new ChromeClient function. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::focusedNodeChanged): + * WebCoreSupport/ChromeClientGtk.h: + +2009-10-29 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> + + Unreviewed. Trivial fix - move public API declaration into the + public subsection of the doc. + + * docs/webkitgtk-sections.txt: + 2009-10-28 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> Reviewed by Jan Alonzo. diff --git a/WebKit/gtk/NEWS b/WebKit/gtk/NEWS index b901f4b..f40390e 100644 --- a/WebKit/gtk/NEWS +++ b/WebKit/gtk/NEWS @@ -1,4 +1,18 @@ ================= +WebKitGTK+ 1.1.17 +================= + +What's new in WebKitGTK+ 1.1.17? + + - New APIs to show and close the web inspector and to inspect an + element at the given coordinates. + - New property, WebKitWebSettings::tab-key-cycles-through-elements, + controls whether TAB is simply interpreted as another keystroke or + is used to cycle through the elements in a page. + - Many a11y improvements. + - The usual amount of random bugfixes. + +================= WebKitGTK+ 1.1.16 ================= diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp index 8d31af3..d9a043b 100644 --- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp @@ -242,6 +242,10 @@ void ChromeClient::takeFocus(FocusDirection) unfocus(); } +void ChromeClient::focusedNodeChanged(Node*) +{ +} + bool ChromeClient::canRunBeforeUnloadConfirmPanel() { return true; diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h index e321c35..beb7a08 100644 --- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h @@ -47,6 +47,8 @@ namespace WebKit { virtual bool canTakeFocus(WebCore::FocusDirection); virtual void takeFocus(WebCore::FocusDirection); + virtual void focusedNodeChanged(WebCore::Node*); + virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&); virtual void show(); diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp index 7286625..0eaa7c8 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp @@ -149,6 +149,10 @@ void FrameLoaderClient::committedLoad(WebCore::DocumentLoader* loader, const cha frameLoader->setEncoding(encoding, userChosen); if (data) frameLoader->addData(data, length); + + Frame* coreFrame = loader->frame(); + if (coreFrame && coreFrame->document() && coreFrame->document()->isMediaDocument()) + loader->cancelMainResourceLoad(frameLoader->client()->pluginWillHandleLoadError(loader->response())); } if (m_pluginView) { @@ -301,10 +305,19 @@ void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction poli if (isHandled) return; + GOwnPtr<WebKitNetworkResponse> networkResponse(webkit_web_frame_get_network_response(m_frame)); + if (networkResponse) { + ResourceResponse response = core(networkResponse.get()); + if (response.isAttachment()) { + webkit_web_policy_decision_download(policyDecision); + return; + } + } + if (canShowMIMEType(mimeType)) - webkit_web_policy_decision_use (policyDecision); + webkit_web_policy_decision_use(policyDecision); else - webkit_web_policy_decision_ignore (policyDecision); + webkit_web_policy_decision_ignore(policyDecision); } static WebKitWebNavigationAction* getNavigationAction(const NavigationAction& action, const char* targetFrame) @@ -500,8 +513,11 @@ String FrameLoaderClient::overrideMediaType() const return String(); } -void FrameLoaderClient::windowObjectCleared() +void FrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) { + if (world != mainThreadNormalWorld()) + return; + // Is this obsolete now? g_signal_emit_by_name(m_frame, "cleared"); @@ -533,7 +549,7 @@ void FrameLoaderClient::didPerformFirstNavigation() const { } -void FrameLoaderClient::registerForIconNotification(bool) +void FrameLoaderClient::registerForIconNotification(bool shouldRegister) { notImplemented(); } @@ -662,6 +678,21 @@ void FrameLoaderClient::dispatchDidChangeLocationWithinPage() g_object_notify(G_OBJECT(webView), "uri"); } +void FrameLoaderClient::dispatchDidPushStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidReplaceStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidPopStateWithinPage() +{ + notImplemented(); +} + void FrameLoaderClient::dispatchWillClose() { notImplemented(); @@ -671,7 +702,12 @@ void FrameLoaderClient::dispatchDidReceiveIcon() { WebKitWebView* webView = getViewFromFrame(m_frame); - g_signal_emit_by_name(webView, "icon-loaded", m_frame); + // Avoid reporting favicons for non-main frames. + if (m_frame != webkit_web_view_get_main_frame(webView)) + return; + + g_object_notify(G_OBJECT(webView), "icon-uri"); + g_signal_emit_by_name(webView, "icon-loaded", webkit_web_view_get_icon_uri(webView)); } void FrameLoaderClient::dispatchDidStartProvisionalLoad() @@ -781,8 +817,10 @@ bool FrameLoaderClient::canHandleRequest(const ResourceRequest&) const bool FrameLoaderClient::canShowMIMEType(const String& type) const { - return MIMETypeRegistry::isSupportedImageMIMEType(type) || MIMETypeRegistry::isSupportedNonImageMIMEType(type) || - PluginDatabase::installedPlugins()->isMIMETypeRegistered(type); + return (MIMETypeRegistry::isSupportedImageMIMEType(type) + || MIMETypeRegistry::isSupportedNonImageMIMEType(type) + || MIMETypeRegistry::isSupportedMediaMIMEType(type) + || PluginDatabase::installedPlugins()->isMIMETypeRegistered(type)); } bool FrameLoaderClient::representationExistsForURLScheme(const String&) const @@ -993,9 +1031,7 @@ ResourceError FrameLoaderClient::pluginWillHandleLoadError(const ResourceRespons bool FrameLoaderClient::shouldFallBack(const ResourceError& error) { - // FIXME: Mac checks for WebKitErrorPlugInWillHandleLoad here to avoid - // loading plugin content twice. Do we need it? - return !(error.isCancellation() || error.errorCode() == WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE); + return !(error.isCancellation() || error.errorCode() == WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE || error.errorCode() == WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD); } bool FrameLoaderClient::canCachePage() const diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h index 997ea64..cace770 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h @@ -76,6 +76,9 @@ namespace WebKit { virtual void dispatchDidCancelClientRedirect(); virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double, double); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); @@ -114,7 +117,7 @@ namespace WebKit { virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const WTF::Vector<WebCore::String>& paramNames, const WTF::Vector<WebCore::String>& paramValues); virtual WebCore::String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp index 78f5543..a06ff50 100644 --- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp @@ -204,18 +204,12 @@ void InspectorClient::inspectorWindowObjectCleared() notImplemented(); } - -void InspectorClient::populateSetting(const String& key, InspectorController::Setting& setting) -{ - notImplemented(); -} - -void InspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting) +void InspectorClient::populateSetting(const String& key, String* value) { notImplemented(); } -void InspectorClient::removeSetting(const String& key) +void InspectorClient::storeSetting(const String& key, const String& value) { notImplemented(); } diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h index ed9fe08..297fd8f 100644 --- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h @@ -66,9 +66,8 @@ namespace WebKit { virtual void hideHighlight(); virtual void inspectedURLChanged(const WebCore::String& newURL); - virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&); - virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&); - virtual void removeSetting(const WebCore::String& key); + virtual void populateSetting(const WebCore::String& key, WebCore::String* value); + virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); virtual void inspectorWindowObjectCleared(); diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp index f2ea316..c71ef1b 100644 --- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp @@ -31,6 +31,20 @@ using namespace WebCore; namespace WebKit { +static GdkAtom gdkMarkupAtom = gdk_atom_intern("text/html", FALSE); + +PasteboardHelperGtk::PasteboardHelperGtk() + : m_targetList(gtk_target_list_new(0, 0)) +{ + gtk_target_list_add_text_targets(m_targetList, WEBKIT_WEB_VIEW_TARGET_INFO_TEXT); + gtk_target_list_add(m_targetList, gdkMarkupAtom, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML); +} + +PasteboardHelperGtk::~PasteboardHelperGtk() +{ + gtk_target_list_unref(m_targetList); +} + GtkClipboard* PasteboardHelperGtk::getCurrentTarget(Frame* frame) const { WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); @@ -55,16 +69,9 @@ GtkClipboard* PasteboardHelperGtk::getPrimary(Frame* frame) const GDK_SELECTION_PRIMARY); } -GtkTargetList* PasteboardHelperGtk::getCopyTargetList(Frame* frame) const -{ - WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); - return webkit_web_view_get_copy_target_list(webView); -} - -GtkTargetList* PasteboardHelperGtk::getPasteTargetList(Frame* frame) const +GtkTargetList* PasteboardHelperGtk::targetList() const { - WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); - return webkit_web_view_get_paste_target_list(webView); + return m_targetList; } gint PasteboardHelperGtk::getWebViewTargetInfoHtml() const diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h index 849b417..12ba207 100644 --- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h +++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h @@ -39,13 +39,16 @@ namespace WebKit { class PasteboardHelperGtk : public PasteboardHelper { public: - PasteboardHelperGtk() { } + PasteboardHelperGtk(); + ~PasteboardHelperGtk(); virtual GtkClipboard* getCurrentTarget(Frame*) const; virtual GtkClipboard* getClipboard(Frame*) const; virtual GtkClipboard* getPrimary(Frame*) const; - virtual GtkTargetList* getCopyTargetList(Frame*) const; - virtual GtkTargetList* getPasteTargetList(Frame*) const; + virtual GtkTargetList* targetList() const; virtual gint getWebViewTargetInfoHtml() const; + +private: + GtkTargetList* m_targetList; }; } diff --git a/WebKit/gtk/docs/webkitgtk-docs.sgml b/WebKit/gtk/docs/webkitgtk-docs.sgml index 7719336..ca478f9 100644 --- a/WebKit/gtk/docs/webkitgtk-docs.sgml +++ b/WebKit/gtk/docs/webkitgtk-docs.sgml @@ -93,4 +93,7 @@ <index id="index-1.1.16" role="1.1.16"> <title>Index of new symbols in 1.1.16</title> </index> + <index id="index-1.1.17" role="1.1.17"> + <title>Index of new symbols in 1.1.17</title> + </index> </book> diff --git a/WebKit/gtk/docs/webkitgtk-sections.txt b/WebKit/gtk/docs/webkitgtk-sections.txt index 8bdd3b3..1f4d1b7 100644 --- a/WebKit/gtk/docs/webkitgtk-sections.txt +++ b/WebKit/gtk/docs/webkitgtk-sections.txt @@ -282,6 +282,9 @@ WebKitSoupAuthDialogClass WebKitWebInspector webkit_web_inspector_get_inspected_uri webkit_web_inspector_get_web_view +webkit_web_inspector_inspect_coordinates +webkit_web_inspector_show +webkit_web_inspector_close <SUBSECTION Standard> WEBKIT_WEB_INSPECTOR WEBKIT_IS_WEB_INSPECTOR @@ -349,6 +352,7 @@ WebKitWebPolicyDecisionPrivate <FILE>webkitnetworkrequest</FILE> <TITLE>WebKitNetworkRequest</TITLE> WebKitNetworkRequest +webkit_network_request_new webkit_network_request_get_uri webkit_network_request_get_message webkit_network_request_set_uri @@ -361,7 +365,6 @@ WEBKIT_IS_NETWORK_REQUEST_CLASS WEBKIT_NETWORK_REQUEST_GET_CLASS <SUBSECTION Private> webkit_network_request_get_type -webkit_network_request_new WebKitNetworkRequestPrivate WebKitNetworkRequest WebKitNetworkRequestClass diff --git a/WebKit/gtk/tests/resources/blank.ico b/WebKit/gtk/tests/resources/blank.ico Binary files differnew file mode 100644 index 0000000..ea848b9 --- /dev/null +++ b/WebKit/gtk/tests/resources/blank.ico diff --git a/WebKit/gtk/tests/resources/test.html b/WebKit/gtk/tests/resources/test.html new file mode 100644 index 0000000..98f7d4f --- /dev/null +++ b/WebKit/gtk/tests/resources/test.html @@ -0,0 +1,6 @@ +<html> +<head><title>test</title></head> +<body>test</body> +</html>></head> +<body>test</body> +</html> diff --git a/WebKit/gtk/tests/resources/test.ogg b/WebKit/gtk/tests/resources/test.ogg Binary files differnew file mode 100644 index 0000000..7f3a3b9 --- /dev/null +++ b/WebKit/gtk/tests/resources/test.ogg diff --git a/WebKit/gtk/tests/resources/test.pdf b/WebKit/gtk/tests/resources/test.pdf Binary files differnew file mode 100644 index 0000000..2424c19 --- /dev/null +++ b/WebKit/gtk/tests/resources/test.pdf diff --git a/WebKit/gtk/tests/resources/test.txt b/WebKit/gtk/tests/resources/test.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/WebKit/gtk/tests/resources/test.txt @@ -0,0 +1 @@ +test diff --git a/WebKit/gtk/tests/testatk.c b/WebKit/gtk/tests/testatk.c index e47898b..c5f4db3 100644 --- a/WebKit/gtk/tests/testatk.c +++ b/WebKit/gtk/tests/testatk.c @@ -28,6 +28,12 @@ static const char* contents = "<html><body><p>This is a test. This is the second sentence. And this the third.</p></body></html>"; +static const char* contentsWithNewlines = "<html><body><p>This is a test. \n\nThis\n is the second sentence. And this the third.</p></body></html>"; + +static const char* contentsInTextarea = "<html><body><textarea cols='80'>This is a test. This is the second sentence. And this the third.</textarea></body></html>"; + +static const char* contentsInTextInput = "<html><body><input type='text' size='80' value='This is a test. This is the second sentence. And this the third.'/></body></html>"; + static gboolean bail_out(GMainLoop* loop) { if (g_main_loop_is_running(loop)) @@ -259,6 +265,105 @@ static void test_webkit_atk_get_text_at_offset(void) g_object_unref(webView); } +static void test_webkit_atk_get_text_at_offset_newlines(void) +{ + WebKitWebView* webView; + AtkObject* obj; + GMainLoop* loop; + AtkText* text_obj; + + webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + g_object_ref_sink(webView); + GtkAllocation alloc = { 0, 0, 800, 600 }; + gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); + webkit_web_view_load_string(webView, contentsWithNewlines, NULL, NULL, NULL); + loop = g_main_loop_new(NULL, TRUE); + + g_timeout_add(100, (GSourceFunc)bail_out, loop); + g_main_loop_run(loop); + + /* Get to the inner AtkText object */ + obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); + g_assert(obj); + obj = atk_object_ref_accessible_child(obj, 0); + g_assert(obj); + obj = atk_object_ref_accessible_child(obj, 0); + g_assert(obj); + + text_obj = ATK_TEXT(obj); + g_assert(ATK_IS_TEXT(text_obj)); + + run_get_text_tests(text_obj); + + g_object_unref(webView); +} + +static void test_webkit_atk_get_text_at_offset_textarea(void) +{ + WebKitWebView* webView; + AtkObject* obj; + GMainLoop* loop; + AtkText* text_obj; + + webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + g_object_ref_sink(webView); + GtkAllocation alloc = { 0, 0, 800, 600 }; + gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); + webkit_web_view_load_string(webView, contentsInTextarea, NULL, NULL, NULL); + loop = g_main_loop_new(NULL, TRUE); + + g_timeout_add(100, (GSourceFunc)bail_out, loop); + g_main_loop_run(loop); + + /* Get to the inner AtkText object */ + obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); + g_assert(obj); + obj = atk_object_ref_accessible_child(obj, 0); + g_assert(obj); + obj = atk_object_ref_accessible_child(obj, 0); + g_assert(obj); + + text_obj = ATK_TEXT(obj); + g_assert(ATK_IS_TEXT(text_obj)); + + run_get_text_tests(text_obj); + + g_object_unref(webView); +} + +static void test_webkit_atk_get_text_at_offset_text_input(void) +{ + WebKitWebView* webView; + AtkObject* obj; + GMainLoop* loop; + AtkText* text_obj; + + webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + g_object_ref_sink(webView); + GtkAllocation alloc = { 0, 0, 800, 600 }; + gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); + webkit_web_view_load_string(webView, contentsInTextInput, NULL, NULL, NULL); + loop = g_main_loop_new(NULL, TRUE); + + g_timeout_add(100, (GSourceFunc)bail_out, loop); + g_main_loop_run(loop); + + /* Get to the inner AtkText object */ + obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); + g_assert(obj); + obj = atk_object_ref_accessible_child(obj, 0); + g_assert(obj); + obj = atk_object_ref_accessible_child(obj, 0); + g_assert(obj); + + text_obj = ATK_TEXT(obj); + g_assert(ATK_IS_TEXT(text_obj)); + + run_get_text_tests(text_obj); + + g_object_unref(webView); +} + int main(int argc, char** argv) { g_thread_init(NULL); @@ -267,6 +372,9 @@ int main(int argc, char** argv) g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/atk/get_text_at_offset", test_webkit_atk_get_text_at_offset); g_test_add_func("/webkit/atk/get_text_at_offset_forms", test_webkit_atk_get_text_at_offset_forms); + g_test_add_func("/webkit/atk/get_text_at_offset_newlines", test_webkit_atk_get_text_at_offset_newlines); + g_test_add_func("/webkit/atk/get_text_at_offset_textarea", test_webkit_atk_get_text_at_offset_textarea); + g_test_add_func("/webkit/atk/get_text_at_offset_text_input", test_webkit_atk_get_text_at_offset_text_input); return g_test_run (); } diff --git a/WebKit/gtk/tests/testmimehandling.c b/WebKit/gtk/tests/testmimehandling.c new file mode 100644 index 0000000..e68dcdf --- /dev/null +++ b/WebKit/gtk/tests/testmimehandling.c @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2009 Jan Michael Alonzo + * Copyright (C) 2009 Gustavo Noronha Silva + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <glib.h> +#include <glib/gstdio.h> +#include <libsoup/soup.h> +#include <string.h> +#include <webkit/webkit.h> + +#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0) + +GMainLoop* loop; +SoupSession *session; +char* base_uri; + +/* For real request testing */ +static void +server_callback(SoupServer *server, SoupMessage *msg, + const char *path, GHashTable *query, + SoupClientContext *context, gpointer data) +{ + if (msg->method != SOUP_METHOD_GET) { + soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + soup_message_set_status(msg, SOUP_STATUS_OK); + + /* PDF */ + if (g_str_equal(path, "/pdf")) { + char* contents; + gsize length; + GError* error = NULL; + + g_file_get_contents("test.pdf", &contents, &length, &error); + g_assert(!error); + + soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, length); + } else if (g_str_equal(path, "/html")) { + char* contents; + gsize length; + GError* error = NULL; + + g_file_get_contents("test.html", &contents, &length, &error); + g_assert(!error); + + soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, length); + } else if (g_str_equal(path, "/text")) { + char* contents; + gsize length; + GError* error = NULL; + + soup_message_headers_append(msg->response_headers, "Content-Disposition", "attachment; filename=test.txt"); + + g_file_get_contents("test.txt", &contents, &length, &error); + g_assert(!error); + + soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, length); + } else if (g_str_equal(path, "/ogg")) { + char* contents; + gsize length; + GError* error = NULL; + + g_file_get_contents("test.ogg", &contents, &length, &error); + g_assert(!error); + + soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, length); + } + + soup_message_body_complete(msg->response_body); +} + +static gboolean idle_quit_loop_cb(gpointer data) +{ + g_main_loop_quit(loop); + return FALSE; +} + +static gboolean mime_type_policy_decision_requested_cb(WebKitWebView* view, WebKitWebFrame* frame, + WebKitNetworkRequest* request, const char* mime_type, + WebKitWebPolicyDecision* decision, gpointer data) +{ + char* type = (char*)data; + + if (g_str_equal(type, "pdf")) { + g_assert_cmpstr(mime_type, ==, "application/pdf"); + g_assert(!webkit_web_view_can_show_mime_type(view, mime_type)); + } else if (g_str_equal(type, "html")) { + g_assert_cmpstr(mime_type, ==, "text/html"); + g_assert(webkit_web_view_can_show_mime_type(view, mime_type)); + } else if (g_str_equal(type, "text")) { + WebKitNetworkResponse* response = webkit_web_frame_get_network_response(frame); + SoupMessage* message = webkit_network_response_get_message(response); + char* disposition; + + g_assert(message); + soup_message_headers_get_content_disposition(message->response_headers, + &disposition, NULL); + g_object_unref(response); + + g_assert_cmpstr(disposition, ==, "attachment"); + g_free(disposition); + + g_assert_cmpstr(mime_type, ==, "text/plain"); + g_assert(webkit_web_view_can_show_mime_type(view, mime_type)); + } else if (g_str_equal(type, "ogg")) { + g_assert_cmpstr(mime_type, ==, "audio/ogg"); + g_assert(webkit_web_view_can_show_mime_type(view, mime_type)); + } + + g_free(type); + + return FALSE; +} + +static void test_mime_type(const char* name) +{ + WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new()); + g_object_ref_sink(G_OBJECT(view)); + + loop = g_main_loop_new(NULL, TRUE); + + g_object_connect(G_OBJECT(view), + "signal::load-finished", idle_quit_loop_cb, NULL, + "signal::mime-type-policy-decision-requested", mime_type_policy_decision_requested_cb, g_strdup(name), + NULL); + + char* effective_uri = g_strdup_printf("%s%s", base_uri, name); + webkit_web_view_load_uri(view, effective_uri); + g_free(effective_uri); + + g_main_loop_run(loop); + + g_object_unref(view); +} + +static void test_mime_pdf() +{ + test_mime_type("pdf"); +} + +static void test_mime_html() +{ + test_mime_type("html"); +} + +static void test_mime_text() +{ + test_mime_type("text"); +} + +static void test_mime_ogg() +{ + test_mime_type("pdf"); +} + +int main(int argc, char** argv) +{ + SoupServer* server; + SoupURI* soup_uri; + char* test_dir; + char* resources_dir; + + g_thread_init(NULL); + gtk_test_init(&argc, &argv, NULL); + + /* Hopefully make test independent of the path it's called from. */ + test_dir = g_path_get_dirname(argv[0]); + resources_dir = g_build_path(G_DIR_SEPARATOR_S, test_dir, + "..", "..", "..", "..", + "WebKit", "gtk", "tests", "resources", + NULL); + g_free(test_dir); + + g_chdir(resources_dir); + g_free(resources_dir); + + server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); + soup_server_run_async(server); + + soup_server_add_handler(server, NULL, server_callback, NULL, NULL); + + soup_uri = soup_uri_new("http://127.0.0.1/"); + soup_uri_set_port(soup_uri, soup_server_get_port(server)); + + base_uri = soup_uri_to_string(soup_uri, FALSE); + soup_uri_free(soup_uri); + + g_test_bug_base("https://bugs.webkit.org/"); + g_test_add_func("/webkit/mime/PDF", test_mime_pdf); + g_test_add_func("/webkit/mime/HTML", test_mime_html); + g_test_add_func("/webkit/mime/TEXT", test_mime_text); + g_test_add_func("/webkit/mime/OGG", test_mime_ogg); + + return g_test_run(); +} + +#else +int main(int argc, char** argv) +{ + g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now."); + return 0; +} + +#endif diff --git a/WebKit/gtk/tests/testwebdatasource.c b/WebKit/gtk/tests/testwebdatasource.c index de2430f..fe5c62f 100644 --- a/WebKit/gtk/tests/testwebdatasource.c +++ b/WebKit/gtk/tests/testwebdatasource.c @@ -66,7 +66,7 @@ static void load_finished_unreachable_cb(WebKitWebView* view, WebKitWebFrame* fr frame = webkit_web_view_get_main_frame(view); datasource = webkit_web_frame_get_data_source(frame); - g_assert_cmpstr("http://localhost/doireallyexist.html", ==, + g_assert_cmpstr("http://this.host.does.not.exist/doireallyexist.html", ==, webkit_web_data_source_get_unreachable_uri(datasource)); if (g_main_loop_is_running(loop)) @@ -149,7 +149,7 @@ static void test_webkit_web_data_source_unreachable_uri() g_object_ref_sink(view); loop = g_main_loop_new(NULL, TRUE); g_signal_connect(view, "load-finished", G_CALLBACK(load_finished_unreachable_cb), loop); - webkit_web_view_load_uri(view, "http://localhost/doireallyexist.html"); + webkit_web_view_load_uri(view, "http://this.host.does.not.exist/doireallyexist.html"); if (!waitTimer) waitTimer = g_timeout_add_seconds(defaultTimeout, (GSourceFunc)wait_timer_fired, loop); diff --git a/WebKit/gtk/tests/testwebframe.c b/WebKit/gtk/tests/testwebframe.c index 068e2cf..620c9c9 100644 --- a/WebKit/gtk/tests/testwebframe.c +++ b/WebKit/gtk/tests/testwebframe.c @@ -155,6 +155,14 @@ cleanup: g_free(temporaryFilename); } +static void test_webkit_web_frame_response() +{ + WebKitWebFrame* frame = g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL); + WebKitNetworkResponse* response = webkit_web_frame_get_network_response(frame); + g_assert(!response); + g_object_unref(frame); +} + int main(int argc, char** argv) { g_thread_init(NULL); @@ -164,6 +172,7 @@ int main(int argc, char** argv) g_test_add_func("/webkit/webview/create_destroy", test_webkit_web_frame_create_destroy); g_test_add_func("/webkit/webframe/lifetime", test_webkit_web_frame_lifetime); g_test_add_func("/webkit/webview/printing", test_webkit_web_frame_printing); + g_test_add_func("/webkit/webview/response", test_webkit_web_frame_response); return g_test_run (); } diff --git a/WebKit/gtk/tests/testwebview.c b/WebKit/gtk/tests/testwebview.c new file mode 100644 index 0000000..e0921c0 --- /dev/null +++ b/WebKit/gtk/tests/testwebview.c @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2008 Holger Hans Peter Freyther + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <errno.h> +#include <unistd.h> +#include <string.h> + +#include <glib.h> +#include <glib/gstdio.h> +#include <gtk/gtk.h> +#include <webkit/webkit.h> + +#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0) + +GMainLoop* loop; +SoupSession *session; +char* base_uri; + +/* For real request testing */ +static void +server_callback(SoupServer* server, SoupMessage* msg, + const char* path, GHashTable* query, + SoupClientContext* context, gpointer data) +{ + if (msg->method != SOUP_METHOD_GET) { + soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + soup_message_set_status(msg, SOUP_STATUS_OK); + + if (g_str_equal(path, "/favicon.ico")) { + char* contents; + gsize length; + GError* error = NULL; + + g_file_get_contents("blank.ico", &contents, &length, &error); + g_assert(!error); + + soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, length); + } else { + char* contents = g_strdup("<html><body>test</body></html>"); + soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, strlen(contents)); + } + + soup_message_body_complete(msg->response_body); +} + +static gboolean idle_quit_loop_cb(gpointer data) +{ + g_main_loop_quit(loop); + return FALSE; +} + +static void icon_uri_changed_cb(WebKitWebView* web_view, GParamSpec* pspec, gpointer data) +{ + gboolean* been_here = (gboolean*)data; + char* expected_uri; + + g_assert_cmpstr(g_param_spec_get_name(pspec), ==, "icon-uri"); + + expected_uri = g_strdup_printf("%sfavicon.ico", base_uri); + g_assert_cmpstr(webkit_web_view_get_icon_uri(web_view), ==, expected_uri); + g_free(expected_uri); + + *been_here = TRUE; +} + +static void icon_loaded_cb(WebKitWebView* web_view, char* icon_uri, gpointer data) +{ + gboolean* been_here = (gboolean*)data; + char* expected_uri = g_strdup_printf("%sfavicon.ico", base_uri); + g_assert_cmpstr(icon_uri, ==, expected_uri); + g_free(expected_uri); + + g_assert_cmpstr(icon_uri, ==, webkit_web_view_get_icon_uri(web_view)); + + *been_here = TRUE; +} + +static void test_webkit_web_view_icon_uri() +{ + gboolean been_to_uri_changed = FALSE; + gboolean been_to_icon_loaded = FALSE; + WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new()); + g_object_ref_sink(G_OBJECT(view)); + + loop = g_main_loop_new(NULL, TRUE); + + g_object_connect(G_OBJECT(view), + "signal::load-finished", idle_quit_loop_cb, NULL, + "signal::notify::icon-uri", icon_uri_changed_cb, &been_to_uri_changed, + "signal::icon-loaded", icon_loaded_cb, &been_to_icon_loaded, + NULL); + + webkit_web_view_load_uri(view, base_uri); + + g_main_loop_run(loop); + + g_assert(been_to_uri_changed); + g_assert(been_to_icon_loaded); + + g_object_unref(view); +} + +int main(int argc, char** argv) +{ + SoupServer* server; + SoupURI* soup_uri; + char* test_dir; + char* resources_dir; + + g_thread_init(NULL); + gtk_test_init(&argc, &argv, NULL); + + /* Hopefully make test independent of the path it's called from. */ + test_dir = g_path_get_dirname(argv[0]); + resources_dir = g_build_path(G_DIR_SEPARATOR_S, test_dir, + "..", "..", "..", "..", + "WebKit", "gtk", "tests", "resources", + NULL); + g_free(test_dir); + + g_chdir(resources_dir); + g_free(resources_dir); + + server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); + soup_server_run_async(server); + + soup_server_add_handler(server, NULL, server_callback, NULL, NULL); + + soup_uri = soup_uri_new("http://127.0.0.1/"); + soup_uri_set_port(soup_uri, soup_server_get_port(server)); + + base_uri = soup_uri_to_string(soup_uri, FALSE); + soup_uri_free(soup_uri); + + g_test_bug_base("https://bugs.webkit.org/"); + g_test_add_func("/webkit/webview/icon-uri", test_webkit_web_view_icon_uri); + + return g_test_run (); +} + +#else +int main(int argc, char** argv) +{ + g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now."); + return 0; +} + +#endif diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp index 4425dcd..c80160c 100644 --- a/WebKit/gtk/webkit/webkitprivate.cpp +++ b/WebKit/gtk/webkit/webkitprivate.cpp @@ -28,6 +28,7 @@ #include "FrameLoader.h" #include "FrameLoaderClientGtk.h" #include "HitTestResult.h" +#include "IconDatabase.h" #include <libintl.h> #include "Logging.h" #include "PageCache.h" @@ -37,8 +38,11 @@ #include "ResourceHandle.h" #include "ResourceHandleClient.h" #include "ResourceHandleInternal.h" +#include "ResourceResponse.h" #include <runtime/InitializeThreading.h> #include "SecurityOrigin.h" +#include <stdlib.h> +#include "webkitnetworkresponse.h" #if ENABLE(DATABASE) #include "DatabaseTracker.h" @@ -112,6 +116,15 @@ WebCore::ResourceRequest core(WebKitNetworkRequest* request) return ResourceRequest(url); } +WebCore::ResourceResponse core(WebKitNetworkResponse* response) +{ + SoupMessage* soupMessage = webkit_network_response_get_message(response); + if (soupMessage) + return ResourceResponse(soupMessage); + + return ResourceResponse(); +} + WebCore::EditingBehavior core(WebKitEditingBehavior type) { return (WebCore::EditingBehavior)type; @@ -153,6 +166,12 @@ WebKitHitTestResult* kit(const WebCore::HitTestResult& result) NULL)); } +PasteboardHelperGtk* pasteboardHelperInstance() +{ + static PasteboardHelperGtk* helper = new PasteboardHelperGtk(); + return helper; +} + } /** end namespace WebKit */ namespace WTF { @@ -208,6 +227,11 @@ static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMes return NULL; } +static void closeIconDatabaseOnExit() +{ + iconDatabase()->close(); +} + void webkit_init() { static bool isInitialized = false; @@ -237,7 +261,14 @@ void webkit_init() PageGroup::setShouldTrackVisitedLinks(true); - Pasteboard::generalPasteboard()->setHelper(new WebKit::PasteboardHelperGtk()); + Pasteboard::generalPasteboard()->setHelper(WebKit::pasteboardHelperInstance()); + + iconDatabase()->setEnabled(true); + + GOwnPtr<gchar> iconDatabasePath(g_build_filename(g_get_user_data_dir(), "webkit", "icondatabase", NULL)); + iconDatabase()->open(iconDatabasePath.get()); + + atexit(closeIconDatabaseOnExit); SoupSession* session = webkit_get_default_session(); diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h index 088175f..e17e79e 100644 --- a/WebKit/gtk/webkit/webkitprivate.h +++ b/WebKit/gtk/webkit/webkitprivate.h @@ -70,6 +70,7 @@ class DownloadClient; namespace WebKit { class DocumentLoader; + class PasteboardHelperGtk; WebKitWebView* getViewFromFrame(WebKitWebFrame*); @@ -97,6 +98,8 @@ namespace WebKit { WebCore::SecurityOrigin* core(WebKitSecurityOrigin*); WebKitHitTestResult* kit(const WebCore::HitTestResult&); + + WebKit::PasteboardHelperGtk* pasteboardHelperInstance(); } typedef struct { @@ -129,9 +132,6 @@ extern "C" { bool editable; GtkIMContext* imContext; - GtkTargetList* copy_target_list; - GtkTargetList* paste_target_list; - gboolean transparent; GtkAdjustment* horizontalAdjustment; @@ -142,6 +142,8 @@ extern "C" { char* encoding; char* customEncoding; + char* iconURI; + gboolean disposing; gboolean usePrimaryForPaste; @@ -301,6 +303,9 @@ extern "C" { WEBKIT_API bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); + WEBKIT_API bool + webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId); + WEBKIT_API unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame); diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp index 843f923..64fdc40 100644 --- a/WebKit/gtk/webkit/webkitwebframe.cpp +++ b/WebKit/gtk/webkit/webkitwebframe.cpp @@ -54,6 +54,7 @@ #include "JSDOMBinding.h" #include "ScriptController.h" #include "SubstituteData.h" +#include "SVGSMILElement.h" #include <atk/atk.h> #include <JavaScriptCore/APICast.h> @@ -794,7 +795,7 @@ gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame) if (view && view->layoutPending()) view->layout(); - String string = externalRepresentation(coreFrame->contentRenderer()); + String string = externalRepresentation(coreFrame); return g_strdup(string.utf8().data()); } @@ -959,6 +960,22 @@ bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, return core(frame)->animation()->pauseTransitionAtTime(coreElement->renderer(), AtomicString(name), time); } +bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId) +{ + ASSERT(core(frame)); + Document* document = core(frame)->document(); + if (!document || !document->svgExtensions()) + return false; + Element* coreElement = document->getElementById(AtomicString(animationId)); + if (!coreElement || !SVGSMILElement::isSMILElement(coreElement)) + return false; +#if ENABLE(SVG) + return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreElement), time); +#else + return false; +#endif +} + unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame) { Frame* coreFrame = core(frame); @@ -1124,3 +1141,29 @@ void webkit_web_frame_layout(WebKitWebFrame* frame) view->layout(); } + +/** + * webkit_web_frame_get_network_response: + * @frame: a #WebKitWebFrame + * + * Returns a #WebKitNetworkResponse object representing the response + * that was given to the request for the given frame, or NULL if the + * frame was not created by a load. You must unref the object when you + * are done with it. + * + * Return value: a #WebKitNetworkResponse object + * + * Since: 1.1.18 + */ +WebKitNetworkResponse* webkit_web_frame_get_network_response(WebKitWebFrame* frame) +{ + Frame* coreFrame = core(frame); + if (!coreFrame) + return NULL; + + WebCore::DocumentLoader* loader = coreFrame->loader()->activeDocumentLoader(); + if (!loader) + return NULL; + + return webkit_network_response_new_with_core_response(loader->response()); +} diff --git a/WebKit/gtk/webkit/webkitwebframe.h b/WebKit/gtk/webkit/webkitwebframe.h index 7a95545..28d7113 100644 --- a/WebKit/gtk/webkit/webkitwebframe.h +++ b/WebKit/gtk/webkit/webkitwebframe.h @@ -172,6 +172,9 @@ webkit_web_frame_get_provisional_data_source (WebKitWebFrame *frame); WEBKIT_API WebKitSecurityOrigin* webkit_web_frame_get_security_origin (WebKitWebFrame *frame); +WEBKIT_API WebKitNetworkResponse* +webkit_web_frame_get_network_response (WebKitWebFrame *frame); + G_END_DECLS #endif diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp index ee2815c..2feb064 100644 --- a/WebKit/gtk/webkit/webkitwebinspector.cpp +++ b/WebKit/gtk/webkit/webkitwebinspector.cpp @@ -83,7 +83,8 @@ enum { PROP_WEB_VIEW, PROP_INSPECTED_URI, - PROP_JAVASCRIPT_PROFILING_ENABLED + PROP_JAVASCRIPT_PROFILING_ENABLED, + PROP_TIMELINE_PROFILING_ENABLED }; G_DEFINE_TYPE(WebKitWebInspector, webkit_web_inspector, G_TYPE_OBJECT) @@ -300,6 +301,22 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass) FALSE, WEBKIT_PARAM_READWRITE)); + /** + * WebKitWebInspector:timeline-profiling-enabled + * + * This is enabling Timeline profiling in the Inspector. + * + * Since: 1.1.17 + */ + g_object_class_install_property(gobject_class, + PROP_TIMELINE_PROFILING_ENABLED, + g_param_spec_boolean( + "timeline-profiling-enabled", + _("Enable Timeline profiling"), + _("Profile the WebCore instrumentation."), + FALSE, + WEBKIT_PARAM_READWRITE)); + g_type_class_add_private(klass, sizeof(WebKitWebInspectorPrivate)); } @@ -329,12 +346,25 @@ static void webkit_web_inspector_set_property(GObject* object, guint prop_id, co switch(prop_id) { case PROP_JAVASCRIPT_PROFILING_ENABLED: { +#if ENABLE(JAVASCRIPT_DEBUGGER) bool enabled = g_value_get_boolean(value); WebCore::InspectorController* controller = priv->page->inspectorController(); if (enabled) controller->enableProfiler(); else controller->disableProfiler(); +#else + g_message("PROP_JAVASCRIPT_PROFILING_ENABLED is not work because of the javascript debugger is disabled\n"); +#endif + break; + } + case PROP_TIMELINE_PROFILING_ENABLED: { + bool enabled = g_value_get_boolean(value); + WebCore::InspectorController* controller = priv->page->inspectorController(); + if (enabled) + controller->startTimelineProfiler(); + else + controller->stopTimelineProfiler(); break; } default: @@ -356,7 +386,14 @@ static void webkit_web_inspector_get_property(GObject* object, guint prop_id, GV g_value_set_string(value, priv->inspected_uri); break; case PROP_JAVASCRIPT_PROFILING_ENABLED: +#if ENABLE(JAVASCRIPT_DEBUGGER) g_value_set_boolean(value, priv->page->inspectorController()->profilerEnabled()); +#else + g_message("PROP_JAVASCRIPT_PROFILING_ENABLED is not work because of the javascript debugger is disabled\n"); +#endif + break; + case PROP_TIMELINE_PROFILING_ENABLED: + g_value_set_boolean(value, priv->page->inspectorController()->timelineAgent() != 0); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -437,6 +474,29 @@ webkit_web_inspector_set_inspector_client(WebKitWebInspector* web_inspector, Web } /** + * webkit_web_inspector_show: + * @web_inspector: the #WebKitWebInspector that will be shown + * + * Causes the Web Inspector to be shown. + * + * Since: 1.1.17 + */ +void webkit_web_inspector_show(WebKitWebInspector* webInspector) +{ + g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(webInspector)); + + WebKitWebInspectorPrivate* priv = webInspector->priv; + + Frame* frame = priv->page->focusController()->focusedOrMainFrame(); + FrameView* view = frame->view(); + + if (!view) + return; + + priv->page->inspectorController()->show(); +} + +/** * webkit_web_inspector_inspect_coordinates: * @web_inspector: the #WebKitWebInspector that will do the inspection * @x: the X coordinate of the node to be inspected diff --git a/WebKit/gtk/webkit/webkitwebinspector.h b/WebKit/gtk/webkit/webkitwebinspector.h index 94fd806..bde4854 100644 --- a/WebKit/gtk/webkit/webkitwebinspector.h +++ b/WebKit/gtk/webkit/webkitwebinspector.h @@ -64,8 +64,10 @@ WEBKIT_API void webkit_web_inspector_inspect_coordinates(WebKitWebInspector* web_inspector, gdouble x, gdouble y); WEBKIT_API void -webkit_web_inspector_close(WebKitWebInspector* webInspector); +webkit_web_inspector_show(WebKitWebInspector* webInspector); +WEBKIT_API void +webkit_web_inspector_close(WebKitWebInspector* webInspector); G_END_DECLS #endif /* webkitwebinspector_h */ diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp index 89c5233..143ae06 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -96,8 +96,8 @@ struct _WebKitWebSettingsPrivate { gboolean enable_offline_web_application_cache; WebKitEditingBehavior editing_behavior; gboolean enable_universal_access_from_file_uris; - gboolean enable_web_sockets; gboolean enable_dom_paste; + gboolean tab_key_cycles_through_elements; }; #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate)) @@ -138,8 +138,8 @@ enum { PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE, PROP_EDITING_BEHAVIOR, PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS, - PROP_ENABLE_WEB_SOCKETS, - PROP_ENABLE_DOM_PASTE + PROP_ENABLE_DOM_PASTE, + PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS }; // Create a default user agent string @@ -652,24 +652,6 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) flags)); /** - * WebKitWebSettings:enable-web-sockets - * - * Whether to enable support for Web Sockets. - * - * Implementation of Web Sockets is currently considered experimental. - * Name of this property and the behavior could change in the future. - * - * Since: 1.1.16 - */ - g_object_class_install_property(gobject_class, - PROP_ENABLE_WEB_SOCKETS, - g_param_spec_boolean("enable-web-sockets", - _("Enable Web Sockets"), - _("Whether to enable Web Sockets"), - FALSE, - flags)); - - /** * WebKitWebSettings:enable-dom-paste * * Whether to enable DOM paste. If set to %TRUE, document.execCommand("Paste") @@ -684,6 +666,25 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) _("Whether to enable DOM paste"), FALSE, flags)); + /** + * WebKitWebSettings:tab-key-cycles-through-elements: + * + * Whether the tab key cycles through elements on the page. + * + * If @flag is %TRUE, pressing the tab key will focus the next element in + * the @web_view. If @flag is %FALSE, the @web_view will interpret tab + * key presses as normal key presses. If the selected element is editable, the + * tab key will cause the insertion of a tab character. + * + * Since: 1.1.17 + */ + g_object_class_install_property(gobject_class, + PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS, + g_param_spec_boolean("tab-key-cycles-through-elements", + _("Tab key cycles through elements"), + _("Whether the tab key cycles through elements on the page."), + TRUE, + flags)); g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate)); } @@ -878,12 +879,12 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS: priv->enable_universal_access_from_file_uris = g_value_get_boolean(value); break; - case PROP_ENABLE_WEB_SOCKETS: - priv->enable_web_sockets = g_value_get_boolean(value); - break; case PROP_ENABLE_DOM_PASTE: priv->enable_dom_paste = g_value_get_boolean(value); break; + case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS: + priv->tab_key_cycles_through_elements = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -995,12 +996,12 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS: g_value_set_boolean(value, priv->enable_universal_access_from_file_uris); break; - case PROP_ENABLE_WEB_SOCKETS: - g_value_set_boolean(value, priv->enable_web_sockets); - break; case PROP_ENABLE_DOM_PASTE: g_value_set_boolean(value, priv->enable_dom_paste); break; + case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS: + g_value_set_boolean(value, priv->tab_key_cycles_through_elements); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1065,7 +1066,6 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings) "enable-offline-web-application-cache", priv->enable_offline_web_application_cache, "editing-behavior", priv->editing_behavior, "enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris, - "enable-web-sockets", priv->enable_web_sockets, "enable-dom-paste", priv->enable_dom_paste, NULL)); diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp index 9f668f4..bebd01a 100644 --- a/WebKit/gtk/webkit/webkitwebview.cpp +++ b/WebKit/gtk/webkit/webkitwebview.cpp @@ -59,11 +59,14 @@ #include "HitTestResult.h" #include <glib/gi18n-lib.h> #include "GraphicsContext.h" +#include "IconDatabase.h" #include "InspectorClientGtk.h" #include "FrameLoader.h" #include "FrameView.h" #include "MouseEventWithHitTestResults.h" +#include "Pasteboard.h" #include "PasteboardHelper.h" +#include "PasteboardHelperGtk.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" #include "ProgressTracker.h" @@ -71,7 +74,7 @@ #include "RenderView.h" #include "ScriptValue.h" #include "Scrollbar.h" -#include <wtf/GOwnPtr.h> +#include <wtf/gtk/GOwnPtr.h> #include <gdk/gdkkeysyms.h> @@ -131,7 +134,7 @@ enum { HOVERING_OVER_LINK, POPULATE_POPUP, STATUS_BAR_TEXT_CHANGED, - ICOND_LOADED, + ICON_LOADED, SELECTION_CHANGED, CONSOLE_MESSAGE, SCRIPT_ALERT, @@ -170,7 +173,8 @@ enum { PROP_LOAD_STATUS, PROP_PROGRESS, PROP_ENCODING, - PROP_CUSTOM_ENCODING + PROP_CUSTOM_ENCODING, + PROP_ICON_URI }; static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, }; @@ -352,6 +356,9 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* case PROP_PROGRESS: g_value_set_double(value, webkit_web_view_get_progress(webView)); break; + case PROP_ICON_URI: + g_value_set_string(value, webkit_web_view_get_icon_uri(webView)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } @@ -865,7 +872,7 @@ static gboolean webkit_web_view_real_script_prompt(WebKitWebView* webView, WebKi static gboolean webkit_web_view_real_console_message(WebKitWebView* webView, const gchar* message, unsigned int line, const gchar* sourceId) { - g_print("console message: %s @%d: %s\n", sourceId, line, message); + g_message("console message: %s @%d: %s\n", sourceId, line, message); return TRUE; } @@ -1001,12 +1008,6 @@ static void webkit_web_view_dispose(GObject* object) g_object_unref(priv->imContext); priv->imContext = NULL; - - gtk_target_list_unref(priv->copy_target_list); - priv->copy_target_list = NULL; - - gtk_target_list_unref(priv->paste_target_list); - priv->paste_target_list = NULL; } if (priv->mainResource) { @@ -1030,6 +1031,7 @@ static void webkit_web_view_finalize(GObject* object) g_free(priv->mainResourceIdentifier); g_free(priv->encoding); g_free(priv->customEncoding); + g_free(priv->iconURI); G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object); } @@ -1456,11 +1458,14 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * Decide whether or not to display the given MIME type. If this * signal is not handled, the default behavior is to show the * content of the requested URI if WebKit can show this MIME - * type; if WebKit is not able to show the MIME type nothing - * happens. + * type and the content disposition is not a download; if WebKit + * is not able to show the MIME type nothing happens. * * Notice that if you return TRUE, meaning that you handled the - * signal, you are expected to have decided what to do, by calling + * signal, you are expected to be aware of the "Content-Disposition" + * header. A value of "attachment" usually indicates a download + * regardless of the MIME type, see also + * soup_message_headers_get_content_disposition(). And you must call * webkit_web_policy_decision_ignore(), * webkit_web_policy_decision_use(), or * webkit_web_policy_decision_download() on the @policy_decision @@ -1730,14 +1735,24 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) G_TYPE_NONE, 1, G_TYPE_STRING); - webkit_web_view_signals[ICOND_LOADED] = g_signal_new("icon-loaded", + /** + * WebKitWebView::icon-loaded: + * @web_view: the object on which the signal is emitted + * @icon_uri: the URI for the icon + * + * This signal is emitted when the main frame has got a favicon. + * + * Since: 1.1.18 + */ + webkit_web_view_signals[ICON_LOADED] = g_signal_new("icon-loaded", G_TYPE_FROM_CLASS(webViewClass), (GSignalFlags)G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed", G_TYPE_FROM_CLASS(webViewClass), @@ -2378,6 +2393,20 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) 0.0, 1.0, 1.0, WEBKIT_PARAM_READABLE)); + /** + * WebKitWebView:icon-uri: + * + * The URI for the favicon for the #WebKitWebView. + * + * Since: 1.1.18 + */ + g_object_class_install_property(objectClass, PROP_ICON_URI, + g_param_spec_string("icon-uri", + _("Icon URI"), + _("The URI for the favicon for the #WebKitWebView."), + NULL, + WEBKIT_PARAM_READABLE)); + g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); } @@ -2392,7 +2421,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas, enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage, enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache, - enableUniversalAccessFromFileURI, enableDOMPaste; + enableUniversalAccessFromFileURI, enableDOMPaste, tabKeyCyclesThroughElements; WebKitEditingBehavior editingBehavior; @@ -2422,6 +2451,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) "editing-behavior", &editingBehavior, "enable-universal-access-from-file-uris", &enableUniversalAccessFromFileURI, "enable-dom-paste", &enableDOMPaste, + "tab-key-cycles-through-elements", &tabKeyCyclesThroughElements, NULL); settings->setDefaultTextEncodingName(defaultEncoding); @@ -2450,6 +2480,10 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI); settings->setDOMPasteAllowed(enableDOMPaste); + Page* page = core(webView); + if (page) + page->setTabKeyCyclesThroughElements(tabKeyCyclesThroughElements); + g_free(defaultEncoding); g_free(cursiveFontFamily); g_free(defaultFontFamily); @@ -2537,6 +2571,11 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar settings->setAllowUniversalAccessFromFileURLs(g_value_get_boolean(&value)); else if (name == g_intern_string("enable-dom-paste")) settings->setDOMPasteAllowed(g_value_get_boolean(&value)); + else if (name == g_intern_string("tab-key-cycles-through-elements")) { + Page* page = core(webView); + if (page) + page->setTabKeyCyclesThroughElements(g_value_get_boolean(&value)); + } else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name)) g_warning("Unexpected setting '%s'", name); g_value_unset(&value); @@ -2572,17 +2611,6 @@ static void webkit_web_view_init(WebKitWebView* webView) priv->zoomFullContent = FALSE; - GdkAtom textHtml = gdk_atom_intern_static_string("text/html"); - /* Targets for copy */ - priv->copy_target_list = gtk_target_list_new(NULL, 0); - gtk_target_list_add(priv->copy_target_list, textHtml, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML); - gtk_target_list_add_text_targets(priv->copy_target_list, WEBKIT_WEB_VIEW_TARGET_INFO_TEXT); - - /* Targets for pasting */ - priv->paste_target_list = gtk_target_list_new(NULL, 0); - gtk_target_list_add(priv->paste_target_list, textHtml, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML); - gtk_target_list_add_text_targets(priv->paste_target_list, WEBKIT_WEB_VIEW_TARGET_INFO_TEXT); - priv->webSettings = webkit_web_settings_new(); webkit_web_view_update_settings(webView); g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView); @@ -3386,10 +3414,7 @@ void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag) **/ GtkTargetList* webkit_web_view_get_copy_target_list(WebKitWebView* webView) { - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); - - WebKitWebViewPrivate* priv = webView->priv; - return priv->copy_target_list; + return pasteboardHelperInstance()->targetList(); } /** @@ -3406,10 +3431,7 @@ GtkTargetList* webkit_web_view_get_copy_target_list(WebKitWebView* webView) **/ GtkTargetList* webkit_web_view_get_paste_target_list(WebKitWebView* webView) { - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); - - WebKitWebViewPrivate* priv = webView->priv; - return priv->paste_target_list; + return pasteboardHelperInstance()->targetList(); } /** @@ -3973,3 +3995,27 @@ WebKitHitTestResult* webkit_web_view_get_hit_test_result(WebKitWebView* webView, return kit(mev.hitTestResult()); } + +/** + * webkit_web_view_get_icon_uri: + * @web_view: the #WebKitWebView object + * + * Obtains the URI for the favicon for the given #WebKitWebView, or + * %NULL if there is none. + * + * Return value: the URI for the favicon, or %NULL + * + * Since: 1.1.18 + */ +G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); + + Page* corePage = core(webView); + String iconURL = iconDatabase()->iconURLForPageURL(corePage->mainFrame()->loader()->url().prettyURL()); + + WebKitWebViewPrivate* priv = webView->priv; + g_free(priv->iconURI); + priv->iconURI = g_strdup(iconURL.utf8().data()); + return priv->iconURI; +} diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h index 1297695..8dd7f39 100644 --- a/WebKit/gtk/webkit/webkitwebview.h +++ b/WebKit/gtk/webkit/webkitwebview.h @@ -366,6 +366,10 @@ webkit_web_view_get_view_source_mode (WebKitWebView *web_view) WEBKIT_API WebKitHitTestResult* webkit_web_view_get_hit_test_result (WebKitWebView *webView, GdkEventButton *event); + +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_view_get_icon_uri (WebKitWebView *webView); + G_END_DECLS #endif diff --git a/WebKit/haiku/ChangeLog b/WebKit/haiku/ChangeLog index 457e3f4..2aa4ad7 100644 --- a/WebKit/haiku/ChangeLog +++ b/WebKit/haiku/ChangeLog @@ -1,3 +1,69 @@ +2009-12-06 Maxime Simon <simon.maxime@gmail.com> + + Reviewed by Adam Barth. + + Build fix. Add in FrameLoaderClientHaiku the declaration of three functions introduced in r51644. + + * WebCoreSupport/FrameLoaderClientHaiku.cpp: + (WebCore::FrameLoaderClientHaiku::dispatchDidPushStateWithinPage): + (WebCore::FrameLoaderClientHaiku::dispatchDidReplaceStateWithinPage): + (WebCore::FrameLoaderClientHaiku::dispatchDidPopStateWithinPage): + * WebCoreSupport/FrameLoaderClientHaiku.h: + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebCoreSupport/InspectorClientHaiku.cpp: + (WebCore::InspectorClientHaiku::populateSetting): + (WebCore::InspectorClientHaiku::storeSetting): + * WebCoreSupport/InspectorClientHaiku.h: + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * WebCoreSupport/FrameLoaderClientHaiku.cpp: + (WebCore::FrameLoaderClientHaiku::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebCore::FrameLoaderClientHaiku::dispatchDidRemoveBackForwardItem): ditto. + (WebCore::FrameLoaderClientHaiku::dispatchDidChangeBackForwardIndex): ditto. + * WebCoreSupport/FrameLoaderClientHaiku.h: + +2009-11-13 Adam Roben <aroben@apple.com> + + Update for changes to FrameLoaderClient + + Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when + window objects in isolated worlds are cleared + + Reviewed by Dave Hyatt. + + * WebCoreSupport/FrameLoaderClientHaiku.cpp: + (WebCore::FrameLoaderClientHaiku::dispatchDidClearWindowObjectInWorld): + * WebCoreSupport/FrameLoaderClientHaiku.h: + Replaced windowObjectCleared with this function. Does nothing if the + passed-in world is not the mainThreadNormalWorld(). + +2009-10-30 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Notify the chrome when the focused node has changed. + https://bugs.webkit.org/show_bug.cgi?id=30832 + + Added stub implementation for new ChromeClient function. + + * WebCoreSupport/ChromeClientHaiku.cpp: + (WebCore::ChromeClientHaiku::focusedNodeChanged): + * WebCoreSupport/ChromeClientHaiku.h: + 2009-10-07 Adam Barth <abarth@webkit.org> Reviewed by Darin Adler. diff --git a/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp b/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp index 4820d78..24f0b52 100644 --- a/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp +++ b/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp @@ -98,6 +98,10 @@ void ChromeClientHaiku::takeFocus(FocusDirection) notImplemented(); } +void ChromeClientHaiku::focusedNodeChanged(Node*) +{ +} + Page* ChromeClientHaiku::createWindow(Frame*, const FrameLoadRequest&, const WebCore::WindowFeatures&) { notImplemented(); diff --git a/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h b/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h index a6f57eb..ecd66de 100644 --- a/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h +++ b/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h @@ -57,6 +57,8 @@ namespace WebCore { bool canTakeFocus(FocusDirection); void takeFocus(FocusDirection); + void focusedNodeChanged(Node*); + Page* createWindow(Frame*, const FrameLoadRequest&, const WebCore::WindowFeatures&); Page* createModalDialog(Frame*, const FrameLoadRequest&); void show(); diff --git a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp index 9ade67b..3a84c4f 100644 --- a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp +++ b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp @@ -42,6 +42,7 @@ #include "Page.h" #include "PlatformString.h" #include "ResourceRequest.h" +#include "ScriptController.h" #include "WebView.h" #include <Message.h> @@ -207,6 +208,21 @@ void FrameLoaderClientHaiku::dispatchDidChangeLocationWithinPage() notImplemented(); } +void FrameLoaderClientHaiku::dispatchDidPushStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClientHaiku::dispatchDidReplaceStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClientHaiku::dispatchDidPopStateWithinPage() +{ + notImplemented(); +} + void FrameLoaderClientHaiku::dispatchWillClose() { notImplemented(); @@ -771,8 +787,11 @@ String FrameLoaderClientHaiku::overrideMediaType() const return String(); } -void FrameLoaderClientHaiku::windowObjectCleared() +void FrameLoaderClientHaiku::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) { + if (world != mainThreadNormalWorld()) + return; + if (m_webView) { BMessage message(JAVASCRIPT_WINDOW_OBJECT_CLEARED); m_messenger->SendMessage(&message); diff --git a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h index d91320c..2ffde8f 100644 --- a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h +++ b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h @@ -94,9 +94,11 @@ namespace WebCore { virtual void dispatchDidHandleOnloadEvents(); virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); virtual void dispatchDidCancelClientRedirect(); - virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, - double fireDate); + virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); @@ -231,7 +233,7 @@ namespace WebCore { virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType); virtual String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; diff --git a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp index 4064c51..f06e96b 100644 --- a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp +++ b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp @@ -105,17 +105,12 @@ void InspectorClientHaiku::inspectorWindowObjectCleared() notImplemented(); } -void InspectorClientHaiku::populateSetting(const String& key, InspectorController::Setting&) +void InspectorClientHaiku::populateSetting(const String& key, String* value) { notImplemented(); } -void InspectorClientHaiku::storeSetting(const String& key, const InspectorController::Setting&) -{ - notImplemented(); -} - -void InspectorClientHaiku::removeSetting(const String& key) +void InspectorClientHaiku::storeSetting(const String& key, const String& value) { notImplemented(); } diff --git a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h index 792ef40..8788a5f 100644 --- a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h +++ b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h @@ -61,9 +61,8 @@ namespace WebCore { virtual void inspectedURLChanged(const String& newURL); - virtual void populateSetting(const String& key, InspectorController::Setting&); - virtual void storeSetting(const String& key, const InspectorController::Setting&); - virtual void removeSetting(const String& key); + virtual void populateSetting(const WebCore::String& key, WebCore::String* value); + virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); virtual void inspectorWindowObjectCleared(); }; diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index 9104b89..b05f2a8 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,933 @@ +2009-12-10 Jon Honeycutt <jhoneycutt@apple.com> + + Mac build fix. Unreviewed. + + Re-adds code that was mistakenly removed from my last patch. + + * WebCoreSupport/WebPluginHalterClient.mm: + Add necessary #import. + + * WebView/WebDelegateImplementationCaching.h: + Declare a new overload of CallUIDelegateReturningBoolean. + + * WebView/WebDelegateImplementationCaching.mm: + (CallDelegateReturningBoolean): + Add a new overload with different arguments. + (CallUIDelegateReturningBoolean): + Ditto. + +2009-12-10 Jon Honeycutt <jhoneycutt@apple.com> + + Pass more information about a plug-in to the PluginHalterDelegate + + Reviewed by Adam Roben. + + * Plugins/WebBaseNetscapePluginView.mm: + (WebHaltablePlugin::isWindowed): + Return false - the Mac doesn't really have windowed plug-ins. + (WebHaltablePlugin::pluginName): + Return the name from the plug-in package. + + * WebCoreSupport/WebPluginHalterClient.h: + Update for new parameters. + + * WebCoreSupport/WebPluginHalterClient.mm: + (WebPluginHalterClient::shouldHaltPlugin): + Ditto; pass them when making the delegate call. + + * WebView/WebUIDelegatePrivate.h: + Update for new parameters. + +2009-12-08 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/7295070> WebKit video fullscreen keeps playing after closing the window + + Fix a leak of the QTMovieView when exiting fullscreen video, and remove the + old workaround. + + * WebView/WebVideoFullscreenController.mm: + (-[WebVideoFullscreenController windowDidLoad]): Set the movie view as the contentView directly. + (-[WebVideoFullscreenController setMediaElement:WebCore::]): Cast the contentView to a movie view. + (-[WebVideoFullscreenController windowDidExitFullscreen]): Remove the old workaround. + +2009-12-08 Dmitry Titov <dimich@chromium.org> + + Rubber-stamped by David Levin. + + Revert and reopen "Add asserts to RefCounted to make sure ref/deref happens on the right thread." + It may have caused massive increase of reported leaks on the bots. + https://bugs.webkit.org/show_bug.cgi?id=31639 + + * ForwardingHeaders/wtf/ThreadVerifier.h: Removed. + +2009-12-08 Dmitry Titov <dimich@chromium.org> + + Reviewed by Darin Adler. + + Add asserts to RefCounted to make sure ref/deref happens on the right thread. + https://bugs.webkit.org/show_bug.cgi?id=31639 + + * ForwardingHeaders/wtf/ThreadVerifier.h: Added. + +2009-12-07 Dmitry Titov <dimich@chromium.org> + + Rubber-stamped by Darin Adler. + + Remove ENABLE_SHARED_SCRIPT flags + https://bugs.webkit.org/show_bug.cgi?id=32245 + This patch was obtained by "git revert" command and then un-reverting of ChangeLog files. + + * Configurations/FeatureDefines.xcconfig: + +2009-12-07 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Darin Adler. + + <rdar://problem/7450481> One compositing test keeps DRT in "compositing mode", breaks repaint tests + + The counter that WebView used to keep track of the number of enclosed WebHTMLViews using + accelerated compositing was hard to manage, and maintained incorrectly in a number of cases. + This caused one compositing test make DumpRenderTree think that all subsequent tests + were compositing too. + + Replace this counter with notifications, which are only fired if a client (DRT) requests them. The + notification informs the client that a WebHTMLView entered compositing mode (or an already- + compositing WebHTML was added); it does not say when a view becomes uncomposited, or all + compositing subviews were removed, since this is tricky to get right. + + Change -[WebView _isUsingAcceleratedCompositing] to manually walk the frames, and + return YES if any document view is composited. + + * WebKit.exp: + * WebView/WebHTMLView.mm: + (-[WebHTMLView close]): + (-[WebHTMLView viewDidMoveToSuperview]): + (-[WebHTMLView attachRootLayer:]): + (-[WebHTMLView detachRootLayer]): + * WebView/WebView.mm: + (+[WebView automaticallyNotifiesObserversForKey:]): + (-[WebView _postsAcceleratedCompositingNotifications]): + (-[WebView _setPostsAcceleratedCompositingNotifications:]): + (-[WebView _isUsingAcceleratedCompositing]): + * WebView/WebViewData.h: + * WebView/WebViewInternal.h: + * WebView/WebViewPrivate.h: + +2009-12-07 Gavin Barraclough <barraclough@apple.com> + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=32184 + Handle out-of-memory conditions with JSC Ropes with a JS exception, rather than crashing. + Switch from using fastMalloc to tryFastMalloc, pass an ExecState to record the exception on. + + * WebView/WebView.mm: + (aeDescFromJSValue): + +2009-12-07 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Holger Hans Peter Freyther. + + Turn on (SVG) Filters support, by default. + https://bugs.webkit.org/show_bug.cgi?id=32224 + + * Configurations/FeatureDefines.xcconfig: Enable FILTERS build flag. + +2009-12-03 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7214236> and http://webkit.org/b/32052 - Implement HTML5 state object history API + + * WebCoreSupport/WebFrameLoaderClient.h: + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::dispatchDidPushStateWithinPage): + (WebFrameLoaderClient::dispatchDidReplaceStateWithinPage): + (WebFrameLoaderClient::dispatchDidPopStateWithinPage): + * WebView/WebDelegateImplementationCaching.h: + * WebView/WebFrameLoadDelegatePrivate.h: + * WebView/WebView.mm: + (-[WebView _cacheFrameLoadDelegateImplementations]): + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebCoreSupport/WebInspectorClient.h: + * WebCoreSupport/WebInspectorClient.mm: + (-[WebInspectorWindowController showWindow:]): + (-[WebInspectorWindowController attach]): + (-[WebInspectorWindowController detach]): + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] notifyHistoryItemChanged() should pass a pointer to the HistoryItem that changed. + https://bugs.webkit.org/show_bug.cgi?id=31915 + + * History/WebHistoryItem.mm: + (WKNotifyHistoryItemChanged): Update WKNotifyHistoryItemChanged() to add the new HistoryItem parameter added in the WebCore portion of this patch. + * History/WebHistoryItemInternal.h: ditto. + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * WebCoreSupport/WebFrameLoaderClient.h: + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebFrameLoaderClient::dispatchDidRemoveBackForwardItem): ditto. + (WebFrameLoaderClient::dispatchDidChangeBackForwardIndex): ditto. + +2009-12-02 Dan Bernstein <mitz@apple.com> + + Reviewed by Mark Rowe. + + Fix a mistake in the previous change + + * WebView/WebView.mm: + (+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:]): + Make sure to include the image types’ view and representation classes + even when plug-ins are not allowed. + +2009-12-02 Dan Bernstein <mitz@apple.com> + + Reviewed by Anders Carlsson. + + Fixed <rdar://problem/7254127> WebKit can load plug-ins even when + plug-ins are disabled + + Ensure that the shared WebPluginDatabase is not instantiated if no + WebViews are used that have plug-ins enabled. + + * DefaultDelegates/WebDefaultPolicyDelegate.m: + (-[WebDefaultPolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]): + Call -[WebView _canShowMIMEType:] on the WebView instead of calling the + class method. + + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::canShowMIMEType): Ditto. + (WebFrameLoaderClient::transitionToCommittedForNewPage): Call + -[WebFrameView _viewClassForMIMEType:] on the WebView instead of calling + the class method. + (WebFrameLoaderClient::objectContentType): Ditto. + + * WebView/WebDataSource.mm: + (+[WebDataSource _representationClassForMIMEType:allowingPlugins:]): + Added the allowPlugins parameter, which is passed through to + +[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:]. + (-[WebDataSource _makeRepresentation]): Pass an allowPlugins value + based on the WebView’s preferences. + + * WebView/WebFrameView.mm: + (-[WebFrameView _makeDocumentViewForDataSource:]): Call + -[WebFrameView _viewClassForMIMEType:] instead of calling the class + method. + (+[WebFrameView _viewClassForMIMEType:allowingPlugins:]): Added the + allowPlugins parameter, which is passed through to + +[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:]. + (-[WebFrameView _viewClassForMIMEType:]): Added. Passes an allowPlugins + value based on the WebView’s preferences. + + * WebView/WebFrameViewInternal.h: + * WebView/WebView.mm: + (+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:]): + Added the allowPlugins parameter. If false, skip the instantiation of + the shared WebPluginDatabase. + (-[WebView _viewClass:andRepresentationClass:forMIMEType:]): Pass an + allowPlugins value based on the WebView’s preferences. + (+[WebView _canShowMIMEType:allowingPlugins:]): Passes allowPlugins to + +_viewClass:andRepresentationClass:forMIMEType:allowingPlugins:. + (+[WebView canShowMIMEType:]): Changed to pass YES to + +_canShowMIMEType:allowingPlugins:. + (-[WebView _canShowMIMEType:]): Added. Passes an allowPlugins value + based on the WebView’s preferences. + (-[WebView _pluginForMIMEType:]): Return nil if plug-ins are disabled. + (-[WebView _pluginForExtension:]): Ditto. + (-[WebView _isMIMETypeRegisteredAsPlugin:]): Return NO if plug-ins are + disabled. + * WebView/WebViewInternal.h: + +2009-12-02 Timothy Hatcher <timothy@apple.com> + + Fixes a crash when scrolling a frame that goes away mid-scroll. + + <rdar://problem/7400263> + + Reviewed by John Sullivan. + + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView scrollWheel:]): Retain self incase the last + reference is released when calling super. + +2009-11-13 Timothy Hatcher <timothy@apple.com> + + Migrate DOMHTMLInputElementPrivate.h as a private header. + + Reviewed by Darin Adler. + + * MigrateHeaders.make: + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Simon Fraser. + + Add SVG animation test framework with 'snapshot' functionality + https://bugs.webkit.org/show_bug.cgi?id=31897 + + Add API used by the new 'sampleSVGAnimationForElementAtTime' DRT method, + forwarding the call to SVGDocumentExtensions, if SVG is enabled. + + Implemented just like the existing pauseAnimation* methods for CSS animations. + + * WebView/WebFrame.mm: + (-[WebFrame _pauseSVGAnimation:onSMILNode:atTime:]): + * WebView/WebFramePrivate.h: + +2009-12-01 Sam Weinig <sam@webkit.org> + + Reviewed by Mark Rowe. + + Simplify [WebView userAgentForURL:]. No need to call into helper function. + + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::userAgent): + * WebView/WebView.mm: + (-[WebView userAgentForURL:]): + * WebView/WebViewInternal.h: + +2009-11-24 Gavin Barraclough <barraclough@apple.com> + + Reviewed by Geoff Garen. + + Bug 31859 - Make world selection for JSC IsolatedWorlds automagical. + + WebCore presently has to explicitly specify the world before entering into JSC, + which is a little fragile (particularly since property access via a + getter/setter might invoke execution). Instead derive the current world from + the lexical global object. + + Since WebCore no longer needs to explicitly specify the world on entry to JSC DebuggerCallFrame::evaluate can be called directly. + + * WebView/WebScriptDebugDelegate.mm: + (-[WebScriptCallFrame evaluateWebScript:]): + +2009-11-24 Dmitry Titov <dimich@chromium.org> + + Reviewed by Eric Seidel. + + Add ENABLE_SHARED_SCRIPT feature define and flag for build-webkit + https://bugs.webkit.org/show_bug.cgi?id=31444 + + * Configurations/FeatureDefines.xcconfig: + +2009-11-24 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Brady Eidson. + + https://bugs.webkit.org/show_bug.cgi?id=31844 + SocketStreamHandleCFNet should support CONNECT proxy credentials + + * WebCoreSupport/WebSystemInterface.m: (InitWebCoreSystemInterface): Add WKSI methods. + +2009-11-23 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Dan Bernstein. + + DocumentMarkers need to be educated about transforms + https://bugs.webkit.org/show_bug.cgi?id=31751 + + Find highlight is incorrect with transforms + <rdar://problem/6358394> + + Allow callers to specify that Frame::selectionTextRects() takes transforms into account + when computing the set of rects that encompass a selection. For transformed elemenets, the + selection rect will be the bounding box of the selected content. + + Fix DocumentMarkers to cache rects in absolute coordinates, rather than painting coordinates. + + * WebView/WebHTMLView.mm: + (-[WebHTMLView selectionTextRects]): + Pass RespectTransforms to get a list of rects with transforms taken into account. + +2009-11-23 Kevin Decker <kdecker@apple.com> + + Reviewed by Adam Roben. + + <rdar://problem/7401503> + + Added a workaround for plug-ins not drawing immediately. + + * Plugins/WebBaseNetscapePluginView.mm: Added new constant. + (-[WebBaseNetscapePluginView _clearSubstituteImage]): Added. + (-[WebBaseNetscapePluginView resumeFromHalt]): Call above new method. + +2009-11-20 Dave Hyatt <hyatt@apple.com> + + Reviewed by Darin Adler. + + Make sure to export WebSerializedJSValue. + + * WebKit.exp: + +2009-11-20 Dave Hyatt <hyatt@apple.com> + + Reviewed by Oliver Hunt and Jon Honeycutt. + + Add support for WebSerializedJSValue to WebKit. This object wraps the SerializedScriptValue functionality in WebCore + and exposes the ability to do JS value serialization/deserialization to WebKit clients. + + * WebView/WebSerializedJSValue.h: Added. + * WebView/WebSerializedJSValue.mm: Added. + (-[WebSerializedJSValue initWithValue:context:]): + (-[WebSerializedJSValue deserialize:]): + (-[WebSerializedJSValue dealloc]): + +2009-11-20 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Beth Dakin. + + WAI-ARIA: add support for 'math' role + https://bugs.webkit.org/show_bug.cgi?id=31706 + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory AXARIAContentGroupText:]): + +2009-11-19 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/7035231> + Support closed caption in <video> element + + * WebCoreSupport/WebSystemInterface.m: + (InitWebCoreSystemInterface): + Add QTMovieHasClosedCaptions and QTMovieSetShowClosedCaptions. + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory localizedMediaControlElementString:]): + (-[WebViewFactory localizedMediaControlElementHelpText:]): + Add accessibility help strings for media controller closed caption button. + +2009-11-18 Michelangelo De Simone <micdesim@gmail.com> + + Reviewed by Darin Adler. + + Fix for <https://bugs.webkit.org/show_bug.cgi?id=27959>. + Support for validationMessage attribute, as per HTML5 specs. + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory validationMessageValueMissingText]): + (-[WebViewFactory validationMessageTypeMismatchText]): + (-[WebViewFactory validationMessagePatternMismatchText]): + (-[WebViewFactory validationMessageTooLongText]): + (-[WebViewFactory validationMessageRangeUnderflowText]): + (-[WebViewFactory validationMessageRangeOverflowText]): + (-[WebViewFactory validationMessageStepMismatchText]): + +2009-11-18 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Make the Mac Geolocation API async. + + * WebCoreSupport/WebChromeClient.mm: + (WebChromeClient::requestGeolocationPermissionForFrame): + (-[WebGeolocationPolicyListener initWithGeolocation:]): + (-[WebGeolocationPolicyListener allow]): + (-[WebGeolocationPolicyListener deny]): + Add WebGeolocationPolicyListener implementation of the new WebGeolocationPolicyListener + protocol and use if to implement requestGeolocationPermissionForFrame using the new async + API. + + * WebCoreSupport/WebGeolocation.mm: Removed. + * WebCoreSupport/WebGeolocationInternal.h: Removed. + * WebCoreSupport/WebGeolocationMock.mm: Remove bogus include. + * WebCoreSupport/WebGeolocationPrivate.h: Removed. + * WebView/WebUIDelegatePrivate.h: Remove requestGeolocationPermission and add + WebGeolocationPolicyListener protocol and decidePolicyForGeolocationRequestFromOrigin delegate + method. + +2009-11-18 Chris Marrin <cmarrin@apple.com> + + Reviewed by Simon Fraser. + + Add Preferences for WebKitShowDebugBorders and WebKitShowRepaintCounter + https://bugs.webkit.org/show_bug.cgi?id=31601 + + These are used to debug accelerated compositing layers + + * WebView/WebPreferenceKeysPrivate.h: + * WebView/WebPreferences.mm: + (+[WebPreferences initialize]): + (-[WebPreferences showDebugBorders]): + (-[WebPreferences setShowDebugBorders:]): + (-[WebPreferences showRepaintCounter]): + (-[WebPreferences setShowRepaintCounter:]): + * WebView/WebPreferencesPrivate.h: + * WebView/WebView.mm: + (-[WebView _preferencesChangedNotification:]): + +2009-11-17 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Web Inspector: Make DRT show web inspector for tests in inspector/ folder. + - Updated DRT to show/close inspector for all tests under /inspector + - Introduced LayoutTestController::setTimelineProfilingEnabled and + WebInspector::setTimelineProfilingEnabled beside setJavaScriptProfilingEnabled + - Removed reload on each inspector test + - Renamed fast/inspector to fast/inspector-support in order not to trigger + inspector for those. + - Reimplemented timeline tests in order to get rid of reload there. + - Moved tests that don't require harness into the fast group. + + https://bugs.webkit.org/show_bug.cgi?id=31472 + + * WebInspector/WebInspector.h: + * WebInspector/WebInspector.mm: + (-[WebInspector isTimelineProfilingEnabled]): + (-[WebInspector setTimelineProfilingEnabled:]): + +2009-11-14 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Darin Adler. + + Need to implement ARIA role="directory" + https://bugs.webkit.org/show_bug.cgi?id=31516 + + Fix a spelling error in the comment of a localized (accessibility) string. + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory AXARIAContentGroupText:]): + +2009-11-14 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Oliver Hunt. + + <rdar://problem/7287487> + Do not use QuickTime version to detect media controller theme + + * WebCoreSupport/WebSystemInterface.m: + (InitWebCoreSystemInterface): Initialize wkMediaControllerThemeAvailable. + +2009-11-13 Adam Roben <aroben@apple.com> + + Tell the WebFrameLoadDelegate when window objects in isolated worlds + are cleared + + Fixes <http://webkit.org/b/31124>. + + Reviewed by Dave Hyatt. + + * WebCoreSupport/WebFrameLoaderClient.h: + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld): + Replaced windowObjectCleared with this function. If the delegate + implements it, call + -webView:didClearWindowObjectForFrame:inScriptWorld:. Otherwise, if + the passed-in world is the mainThreadNormalWorld(), call + -webView:didClearWindowObject:forFrame:. + + * WebView/WebDelegateImplementationCaching.h: Added a new entry in the + frame load delegate implementation cache for the new delegate method. + + * WebView/WebFrameLoadDelegatePrivate.h: + * WebView/WebScriptWorld.mm: + (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in + existence. + (-[WebScriptWorld initWithWorld:]): Add ourselves to allWorlds(). + (-[WebScriptWorld dealloc]): Remove ourselves from allWorlds(). + (+[WebScriptWorld findOrCreateWorld:]): Returns the existing + WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't + already exist. + + * WebView/WebScriptWorldInternal.h: Declared +findOrCreateWorld:. + + * WebView/WebView.mm: + (-[WebView _cacheFrameLoadDelegateImplementations]): Cache the + implementation of the new frame load delegate method. + +2009-11-13 Adam Roben <aroben@apple.com> + + Finish replacing worldIDs with world objects + + The only remaining use of worldIDs was in a method only used by DRT + for the isolated worlds tests. + + Fixes <http://webkit.org/b/31414> Replace worldIDs with world objects + + Reviewed by Mark Rowe. + + * WebView/WebFrame.mm: + (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]): + * WebView/WebFramePrivate.h: + Renamed from + _stringByEvaluatingJavaScriptInIsolatedWorld:WithGobalObject:FromString:. + Now takes a WebScriptWorld instead of a worldID, so we don't need to + maintain a map of worldID -> world anymore. + +2009-11-12 Dan Bernstein <mitz@apple.com> + + Reviewed by Adele Peterson. + + When exiting full-screen video, rather than resetting the system UI + mode, restore it to what it was when full-screen mode was entered. + + * WebView/WebVideoFullscreenController.h: Cleaned up style, removed + unnecessary imports, and added _savedUIMode and _savedUIOptions ivars. + * WebView/WebVideoFullscreenController.mm: + (-[WebVideoFullscreenController delegate]): Cleaned up style. + (-[WebVideoFullscreenController setDelegate:]): Ditto. + (-[WebVideoFullscreenController windowDidExitFullscreen]): Restore the + system UI mode. + (-[WebVideoFullscreenController windowDidEnterFullscreen]): Save the + system UI mode. + * WebView/WebView.mm: Added now-necessary import. + +2009-11-12 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Darin Adler. + + externalRepresentation should take Frame as the argument + https://bugs.webkit.org/show_bug.cgi?id=31393 + + No new tests as this is just a refactoring. + + * Misc/WebCoreStatistics.mm: + (-[WebFrame renderTreeAsExternalRepresentation]): + +2009-11-12 Adam Roben <aroben@apple.com> + + Replace worldIDs with world objects + + WebScriptWorld is the new object that represents a world. The only + place worldID is still used is in -[WebFrame + _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:], + but that will change soon. + + Part of <http://webkit.org/b/31414> Implement new SPI for dealing with + user scripts/stylesheets and isolated worlds + + Reviewed by Sam Weinig. + + * WebKit.exp: Export WebScriptWorld. + + * WebView/WebFrame.mm: + (-[WebFrame _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:]): + Moved the bizarre world caching/creation logic that DRT depends on + here from the findWorld function in ScriptController.cpp. Updated to + use ScriptController::executeScriptInWorld instead of + ScriptController::executeScriptInIsolatedWorld. + (-[WebFrame _contextForWorld:]): Renamed from contextForWorldID:. Now + takes a WebScriptWorld. + + * WebView/WebFramePrivate.h: Replaced contextForWorldID: with + _contextForWorld:. + + * WebView/WebScriptWorld.h: Added. + * WebView/WebScriptWorld.mm: Added. + (-[WebScriptWorld initWithWorld:]): Store the passed-in world in our + _private member. + (-[WebScriptWorld init]): Create a new DOMWrapperWorld and pass it to + -initWithWorld:. + (-[WebScriptWorld dealloc]): Release _private. + (+[WebScriptWorld standardWorld]): Returns a shared instance that + represents WebCore's mainThreadNormalWorld(). + (+[WebScriptWorld world]): Returns a new instance. + (core): Returns the DOMWrapperWorld for this WebScriptWorld. + + * WebView/WebScriptWorldInternal.h: Added. + + * WebView/WebView.mm: + (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]): + (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]): + (+[WebView _removeUserScriptFromGroup:world:url:]): + (+[WebView _removeUserStyleSheetFromGroup:world:url:]): + (+[WebView _removeUserScriptsFromGroup:world:]): + (+[WebView _removeUserStyleSheetsFromGroup:world:]): + * WebView/WebViewPrivate.h: + Changed these functions to take a WebScriptWorld instead of a worldID. + +2009-11-12 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Darin Adler. + + ARIA: add alert type roles + https://bugs.webkit.org/show_bug.cgi?id=31392 + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory AXARIAContentGroupText:]): + +2009-11-10 Daniel Bates <dbates@webkit.org> + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=30754 + + Removed method draggedImage:movedTo: + + * WebView/WebFrame.mm: + * WebView/WebFrameInternal.h: + * WebView/WebHTMLView.mm: + +2009-11-10 Beth Dakin <bdakin@apple.com> + + Reviewed by Darin Adler. + + Small WebKit part of: + Fix for <rdar://problem/7059710> + -and corresponding- + https://bugs.webkit.org/show_bug.cgi?id=31196 Implement -webkit- + color-correction for CSS colors + + * Misc/WebKitNSStringExtras.mm: + (-[NSString _web_drawAtPoint:font:textColor:]): setFillColor now + requires callers to pass a ColorSpace. + +2009-11-10 Dan Bernstein <mitz@apple.com> + + Reviewed by Eric Carlson and Darin Adler. + + WebKit part of making full-screen video pause during scrubbing. + + * WebView/WebVideoFullscreenHUDWindowController.h: Added _isScrubbing + ivar. + * WebView/WebVideoFullscreenHUDWindowController.mm: + (-[WebVideoFullscreenHUDWindowController dealloc]): Assert that + _isScrubbing is NO. + (-[WebVideoFullscreenHUDWindowController endScrubbing]): Call + HTMLMediaElement::endScrubbing(). + (-[WebVideoFullscreenHUDWindowController timelinePositionChanged:]): + If scrubbing has just begun, call HTMLMediaElement::beginScrubbing() + and schedule -endScrubbing to be called when mouse tracking ends. + +2009-11-09 Mark Mentovai <mark@chromium.org> + + Reviewed by Dan Bernstein. + + Track "can have scrollbar" state within FrameView independently of the + individual scrollbar states in ScrollView. + + rdar://problem/7215132, https://bugs.webkit.org/show_bug.cgi?id=29167 + REGRESSION (r48064): mint.com loses scrollbars after coming out of + edit mode. + + rdar://problem/7314421, https://bugs.webkit.org/show_bug.cgi?id=30517 + REGRESSION (r48064): Extra scroll bars in GarageBand Lesson Store. + + Test: fast/overflow/scrollbar-restored.html + + * WebView/WebFrameView.mm: + (-[WebFrameView _install]): + +2009-11-08 Dan Bernstein <mitz@apple.com> + + Reviewed by Eric Carlson. + + Made the full-screen video HUD appear when playback stops, such as when + the end of the video is reached. + + * WebView/WebVideoFullscreenHUDWindowController.h: Cleaned up. + * WebView/WebVideoFullscreenHUDWindowController.mm: + (-[WebVideoFullscreenHUDWindowController scheduleTimeUpdate]): Updated + for the renaming of -updateRate to -updatePlayButton. + (-[WebVideoFullscreenHUDWindowController updatePlayButton]): Renamed + -updateRate to this. + (-[WebVideoFullscreenHUDWindowController updateRate]): This method now + responds to changes to the playback rate by updating the play button + and showing or hiding the HUD as necessary. + (-[WebVideoFullscreenHUDWindowController togglePlaying:]): Now only + toggles playing. UI updates are driven by -updateRate being called. + (-[WebVideoFullscreenHUDWindowController playing]): Cleaned up. + +2009-11-02 Eric Carlson <eric.carlson@apple.com> + + Reviewed by John Sullivan and Mark Rowe. + + <rdar://problem/7356733> Voiceover does not read correct media controller time values + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory localizedMediaTimeDescription:]): + +2009-11-02 Dan Bernstein <mitz@apple.com> + + Reviewed by Anders Carlsson. + + Made the remaining time display show negative zero at the end of the + video. + + Made other cleanup. + + * WebView/WebVideoFullscreenHUDWindowController.h: Reverted the types of + _timeline and _volumeSlider to the more generic NSControl. + * WebView/WebVideoFullscreenHUDWindowController.mm: + (-[WebVideoFullscreenHUDWindowController scheduleTimeUpdate]): Cleaned + up style. + (-[WebVideoFullscreenHUDWindowController windowDidLoad]): Added an + assertion that the cast to NSButton * is legal. Removed casts. + (-[WebVideoFullscreenHUDWindowController updateTime]): Use + -setValue:forKey: instead of an NSSlider method. + (timeToString): Changed to support only non-negative values and + simplified. + (-[WebVideoFullscreenHUDWindowController remainingTimeText]): Always + prepend a “-” to the time. + +2009-11-02 Dan Bernstein <mitz@apple.com> + + Reviewed by John Sullivan. + + WebKit part of making the appearance of the full-screen video HUD match + QuickTime Player X’s HUD. + + * WebView/WebVideoFullscreenHUDWindowController.h: Removed unnecessary + #import statements, cleaned up style, and changed _timeline, + _volumeSlider and _playButton to have more specific types. + * WebView/WebVideoFullscreenHUDWindowController.mm: Updated #import + statements. + (webkit_CGFloor): Added this helper function. + (-[WebVideoFullscreenHUDWindowController init]): Cleaned up style. + (createTimeTextField): Changed to use the bold system font. + (-[WebVideoFullscreenHUDWindowController windowDidLoad]): Changed the + subviews’ metrics and the text fields’ text alignment. + (-[WebVideoFullscreenHUDWindowController updateTime]): Avoid conversion + from double to float. + (stringToTimeTextAttributed): Removed this useless function that + returned an NSAttributedString masquerading as an NSString. + (-[WebVideoFullscreenHUDWindowController remainingTimeText]): Removed + call to stringToTimeTextAttributed(). + (-[WebVideoFullscreenHUDWindowController elapsedTimeText]): Ditto. + +2009-11-02 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Beth Dakin. + + Support ARIA "tab" roles + https://bugs.webkit.org/show_bug.cgi?id=30842 + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory AXARIAContentGroupText:]): + +2009-11-01 Dan Bernstein <mitz@apple.com> + + Reviewed by Mark Rowe. + + Made the space bar toggle playing state in full-screen video when + modifier keys are down. Made it do so without highlighting the + Play/Pause button. + + * WebView/WebVideoFullscreenHUDWindowController.mm: + (-[WebVideoFullscreenHUDWindowController keyDown:]): + +2009-11-01 Dan Bernstein <mitz@apple.com> + + Reviewed by Mark Rowe. + + Made the full-screen video HUD respond to the up and down arrow keys by + increasing and decreasing the volume by 1/10 of the range or, when + combined with the Option key, all the way up or down. + + Made the volume buttons in the full-screen video HUD match the behavior + of their equivalents in the QuickTime Player HUD by turning the volume + all the way up or down. + + Made the volume slider update immediately when the keyboard or volume + buttons are used to change the volume, rather than at the nearest 1/4 + second interval. + + Made the elapsed and remaining time displays update immediately when the + play head is dragged across the timeline, rather than at 1/4 second + intervals. + + * WebView/WebVideoFullscreenHUDWindowController.mm: + (-[WebVideoFullscreenHUDWindowController keyDown:]): Handle the up and + down arrow keys. + (-[WebVideoFullscreenHUDWindowController windowDidLoad]): Changed the + actions of the volume up and volume down buttons. + (-[WebVideoFullscreenHUDWindowController setCurrentTime:]): Call + -updateTime. + (-[WebVideoFullscreenHUDWindowController setVolumeToZero:]): Added this + action for the volume down button. + (-[WebVideoFullscreenHUDWindowController setVolumeToMaximum:]): Added + this action for the volume up button. + (-[WebVideoFullscreenHUDWindowController decrementVolume]): No longer + and action method. + (-[WebVideoFullscreenHUDWindowController incrementVolume]): Ditto. + (-[WebVideoFullscreenHUDWindowController setVolume:]): Call + -updateVolume. + +2009-10-30 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Notify the chrome when the focused node has changed. + https://bugs.webkit.org/show_bug.cgi?id=30832 + + Added stub implementation for new ChromeClient function. + + * WebCoreSupport/WebChromeClient.h: + * WebCoreSupport/WebChromeClient.mm: + (WebChromeClient::focusedNodeChanged): + +2009-10-30 Roland Steiner <rolandsteiner@chromium.org> + + Reviewed by Eric Seidel. + + Remove ENABLE_RUBY guards as discussed with Dave Hyatt and Maciej Stachowiak. + + Bug 28420 - Implement HTML5 <ruby> rendering + (https://bugs.webkit.org/show_bug.cgi?id=28420) + + No new tests (no functional change). + + * Configurations/FeatureDefines.xcconfig: + +2009-10-29 Mark Rowe <mrowe@apple.com> + + Reviewed by Oliver Hunt. + + Validate the stopSpeaking: selector so that is not always enabled when a WebView is first responder. + + * WebView/WebHTMLView.mm: + (-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]): + +2009-10-29 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=30932 + <rdar://problem/7350269> + + REGRESSION: Crash when turning on Private Browsing on site with flash. + + Null check setValue. + + * Plugins/WebNetscapePluginView.mm: + (-[WebNetscapePluginView privateBrowsingModeDidChange]): + +2009-10-29 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Kevin Decker. + + Refactor some duplicate plug-in clean up code into shared functions. + + * Plugins/WebPluginController.mm: + (-[WebPluginController stopOnePlugin:]): New, stop a plug-in. + (-[WebPluginController destroyOnePlugin:]): New, destroy plug-in. + (-[WebPluginController stopAllPlugins]): Call stopOnePlugin. + (-[WebPluginController destroyPlugin:]): Call stopOnePlugin and destroyOnePlugin. + (-[WebPluginController destroyAllPlugins]): Call destroyOnePlugin. + 2009-10-28 Eric Carlson <eric.carlson@apple.com> Reviewed by Simon Fraser. diff --git a/WebKit/mac/Configurations/FeatureDefines.xcconfig b/WebKit/mac/Configurations/FeatureDefines.xcconfig index 42aa3cf..cd462d6 100644 --- a/WebKit/mac/Configurations/FeatureDefines.xcconfig +++ b/WebKit/mac/Configurations/FeatureDefines.xcconfig @@ -44,14 +44,13 @@ ENABLE_DATAGRID = ENABLE_DATAGRID; ENABLE_DATALIST = ENABLE_DATALIST; ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE; ENABLE_EVENTSOURCE = ENABLE_EVENTSOURCE; -ENABLE_FILTERS = ; +ENABLE_FILTERS = ENABLE_FILTERS; ENABLE_GEOLOCATION = ; ENABLE_ICONDATABASE = ENABLE_ICONDATABASE; ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER; ENABLE_MATHML = ; ENABLE_NOTIFICATIONS = ; ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS; -ENABLE_RUBY = ENABLE_RUBY; ENABLE_SHARED_WORKERS = ENABLE_SHARED_WORKERS; ENABLE_SVG = ENABLE_SVG; ENABLE_SVG_ANIMATION = ENABLE_SVG_ANIMATION; @@ -67,4 +66,4 @@ ENABLE_WORKERS = ENABLE_WORKERS; ENABLE_XPATH = ENABLE_XPATH; ENABLE_XSLT = ENABLE_XSLT; -FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_RUBY) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT); +FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT); diff --git a/WebKit/mac/Configurations/Version.xcconfig b/WebKit/mac/Configurations/Version.xcconfig index fabc009..b3bf41d 100644 --- a/WebKit/mac/Configurations/Version.xcconfig +++ b/WebKit/mac/Configurations/Version.xcconfig @@ -22,7 +22,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. MAJOR_VERSION = 532; -MINOR_VERSION = 4; +MINOR_VERSION = 6; TINY_VERSION = 0; FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION); diff --git a/WebKit/mac/DefaultDelegates/WebDefaultPolicyDelegate.m b/WebKit/mac/DefaultDelegates/WebDefaultPolicyDelegate.m index c832993..6de2792 100644 --- a/WebKit/mac/DefaultDelegates/WebDefaultPolicyDelegate.m +++ b/WebKit/mac/DefaultDelegates/WebDefaultPolicyDelegate.m @@ -66,11 +66,11 @@ static WebDefaultPolicyDelegate *sharedDelegate = nil; BOOL isDirectory = NO; BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory]; - if (exists && !isDirectory && [WebView canShowMIMEType:type]) + if (exists && !isDirectory && [wv _canShowMIMEType:type]) [listener use]; else [listener ignore]; - } else if ([WebView canShowMIMEType:type]) + } else if ([wv _canShowMIMEType:type]) [listener use]; else [listener ignore]; diff --git a/WebKit/mac/MigrateHeaders.make b/WebKit/mac/MigrateHeaders.make index 9e78367..072da65 100644 --- a/WebKit/mac/MigrateHeaders.make +++ b/WebKit/mac/MigrateHeaders.make @@ -106,6 +106,7 @@ all : \ $(PUBLIC_HEADERS_DIR)/DOMHTMLIFrameElement.h \ $(PUBLIC_HEADERS_DIR)/DOMHTMLImageElement.h \ $(PUBLIC_HEADERS_DIR)/DOMHTMLInputElement.h \ + $(PRIVATE_HEADERS_DIR)/DOMHTMLInputElementPrivate.h \ $(INTERNAL_HEADERS_DIR)/DOMHTMLInputElementInternal.h \ $(PUBLIC_HEADERS_DIR)/DOMHTMLIsIndexElement.h \ $(PUBLIC_HEADERS_DIR)/DOMHTMLLIElement.h \ diff --git a/WebKit/mac/Misc/WebCoreStatistics.mm b/WebKit/mac/Misc/WebCoreStatistics.mm index 6bac46e..f204ddb 100644 --- a/WebKit/mac/Misc/WebCoreStatistics.mm +++ b/WebKit/mac/Misc/WebCoreStatistics.mm @@ -242,7 +242,7 @@ using namespace WebCore; - (NSString *)renderTreeAsExternalRepresentation { - return externalRepresentation(_private->coreFrame->contentRenderer()); + return externalRepresentation(_private->coreFrame); } - (NSString *)counterValueForElement:(DOMElement*)element diff --git a/WebKit/mac/Misc/WebKitNSStringExtras.mm b/WebKit/mac/Misc/WebKitNSStringExtras.mm index 5eb3e1f..da46630 100644 --- a/WebKit/mac/Misc/WebKitNSStringExtras.mm +++ b/WebKit/mac/Misc/WebKitNSStringExtras.mm @@ -93,7 +93,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length) CGFloat blue; CGFloat alpha; [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha]; - graphicsContext.setFillColor(makeRGBA(red * 255, green * 255, blue * 255, alpha * 255)); + graphicsContext.setFillColor(makeRGBA(red * 255, green * 255, blue * 255, alpha * 255), DeviceColorSpace); webCoreFont.drawText(&graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1 * point.y)))); diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm index 0b4d56a..bf8b80b 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm @@ -64,6 +64,8 @@ #define LoginWindowDidSwitchFromUserNotification @"WebLoginWindowDidSwitchFromUserNotification" #define LoginWindowDidSwitchToUserNotification @"WebLoginWindowDidSwitchToUserNotification" +static const NSTimeInterval ClearSubstituteImageDelay = 0.5; + using namespace WebCore; class WebHaltablePlugin : public HaltablePlugin { @@ -77,6 +79,8 @@ private: virtual void halt(); virtual void restart(); virtual Node* node() const; + virtual bool isWindowed() const; + virtual String pluginName() const; WebBaseNetscapePluginView* m_view; }; @@ -96,6 +100,16 @@ Node* WebHaltablePlugin::node() const return [m_view element]; } +bool WebHaltablePlugin::isWindowed() const +{ + return false; +} + +String WebHaltablePlugin::pluginName() const +{ + return [[m_view pluginPackage] name]; +} + @implementation WebBaseNetscapePluginView + (void)initialize @@ -498,6 +512,19 @@ Node* WebHaltablePlugin::node() const _hasBeenHalted = YES; } +- (void)_clearSubstituteImage +{ + Element* element = [self element]; + if (!element) + return; + + RenderObject* renderer = element->renderer(); + if (!renderer) + return; + + toRenderWidget(renderer)->showSubstituteImage(0); +} + - (void)resumeFromHalt { ASSERT(_isHalted); @@ -508,7 +535,9 @@ Node* WebHaltablePlugin::node() const _isHalted = NO; ASSERT([self element]->renderer()); - toRenderWidget([self element]->renderer())->showSubstituteImage(0); + // FIXME 7417484: This is a workaround for plug-ins not drawing immediately. We'd like to detect when the + // plug-in actually draws instead of just assuming it will do so within 0.5 seconds of being restarted. + [self performSelector:@selector(_clearSubstituteImage) withObject:nil afterDelay:ClearSubstituteImageDelay]; } - (BOOL)isHalted diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.mm b/WebKit/mac/Plugins/WebNetscapePluginView.mm index 135d45a..3ce5e39 100644 --- a/WebKit/mac/Plugins/WebNetscapePluginView.mm +++ b/WebKit/mac/Plugins/WebNetscapePluginView.mm @@ -849,7 +849,8 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) [self willCallPlugInFunction]; { JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [_pluginPackage.get() pluginFuncs]->setvalue(plugin, NPNVprivateModeBool, &value); + if ([_pluginPackage.get() pluginFuncs]->setvalue) + [_pluginPackage.get() pluginFuncs]->setvalue(plugin, NPNVprivateModeBool, &value); } [self didCallPlugInFunction]; } diff --git a/WebKit/mac/Plugins/WebPluginController.mm b/WebKit/mac/Plugins/WebPluginController.mm index 357cf7b..4343119 100644 --- a/WebKit/mac/Plugins/WebPluginController.mm +++ b/WebKit/mac/Plugins/WebPluginController.mm @@ -135,6 +135,28 @@ static NSMutableSet *pluginViews = nil; [super dealloc]; } +- (void)stopOnePlugin:(NSView *)view +{ + if ([view respondsToSelector:@selector(webPlugInStop)]) { + JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); + [view webPlugInStop]; + } else if ([view respondsToSelector:@selector(pluginStop)]) { + JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); + [view pluginStop]; + } +} + +- (void)destroyOnePlugin:(NSView *)view +{ + if ([view respondsToSelector:@selector(webPlugInDestroy)]) { + JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); + [view webPlugInDestroy]; + } else if ([view respondsToSelector:@selector(pluginDestroy)]) { + JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); + [view pluginDestroy]; + } +} + - (void)startAllPlugins { if (_started) @@ -167,16 +189,9 @@ static NSMutableSet *pluginViews = nil; } int i, count = [_views count]; - for (i = 0; i < count; i++) { - id aView = [_views objectAtIndex:i]; - if ([aView respondsToSelector:@selector(webPlugInStop)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [aView webPlugInStop]; - } else if ([aView respondsToSelector:@selector(pluginStop)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [aView pluginStop]; - } - } + for (i = 0; i < count; i++) + [self stopOnePlugin:[_views objectAtIndex:i]]; + _started = NO; } @@ -228,23 +243,9 @@ static NSMutableSet *pluginViews = nil; - (void)destroyPlugin:(NSView *)view { if ([_views containsObject:view]) { - if (_started) { - if ([view respondsToSelector:@selector(webPlugInStop)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [view webPlugInStop]; - } else if ([view respondsToSelector:@selector(pluginStop)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [view pluginStop]; - } - } - - if ([view respondsToSelector:@selector(webPlugInDestroy)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [view webPlugInDestroy]; - } else if ([view respondsToSelector:@selector(pluginDestroy)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [view pluginDestroy]; - } + if (_started) + [self stopOnePlugin:view]; + [self destroyOnePlugin:view]; #if ENABLE(NETSCAPE_PLUGIN_API) if (Frame* frame = core([self webFrame])) @@ -290,13 +291,7 @@ static void cancelOutstandingCheck(const void *item, void *context) int i, count = [_views count]; for (i = 0; i < count; i++) { id aView = [_views objectAtIndex:i]; - if ([aView respondsToSelector:@selector(webPlugInDestroy)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [aView webPlugInDestroy]; - } else if ([aView respondsToSelector:@selector(pluginDestroy)]) { - JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); - [aView pluginDestroy]; - } + [self destroyOnePlugin:aView]; #if ENABLE(NETSCAPE_PLUGIN_API) if (Frame* frame = core([self webFrame])) diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.h b/WebKit/mac/WebCoreSupport/WebChromeClient.h index a8f22f6..ca2863e 100644 --- a/WebKit/mac/WebCoreSupport/WebChromeClient.h +++ b/WebKit/mac/WebCoreSupport/WebChromeClient.h @@ -53,6 +53,8 @@ public: virtual bool canTakeFocus(WebCore::FocusDirection); virtual void takeFocus(WebCore::FocusDirection); + virtual void focusedNodeChanged(WebCore::Node*); + virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&); virtual void show(); diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.mm b/WebKit/mac/WebCoreSupport/WebChromeClient.mm index c107299..58323bb 100644 --- a/WebKit/mac/WebCoreSupport/WebChromeClient.mm +++ b/WebKit/mac/WebCoreSupport/WebChromeClient.mm @@ -35,7 +35,6 @@ #import "WebElementDictionary.h" #import "WebFrameInternal.h" #import "WebFrameView.h" -#import "WebGeolocationInternal.h" #import "WebHTMLViewInternal.h" #import "WebHistoryInternal.h" #import "WebKitPrefix.h" @@ -91,12 +90,20 @@ using namespace WebCore; -@interface WebOpenPanelResultListener : NSObject <WebOpenPanelResultListener> { +@interface WebOpenPanelResultListener : NSObject <WebOpenPanelResultListener> +{ FileChooser* _chooser; } - (id)initWithChooser:(PassRefPtr<FileChooser>)chooser; @end +@interface WebGeolocationPolicyListener : NSObject <WebGeolocationPolicyListener> +{ + RefPtr<Geolocation> _geolocation; +} +- (id)initWithGeolocation:(Geolocation*)geolocation; +@end + WebChromeClient::WebChromeClient(WebView *webView) : m_webView(webView) { @@ -172,6 +179,10 @@ void WebChromeClient::takeFocus(FocusDirection direction) } } +void WebChromeClient::focusedNodeChanged(Node*) +{ +} + Page* WebChromeClient::createWindow(Frame* frame, const FrameLoadRequest& request, const WindowFeatures& features) { NSURLRequest *URLRequest = nil; @@ -753,11 +764,19 @@ void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geoloca { BEGIN_BLOCK_OBJC_EXCEPTIONS; + SEL selector = @selector(webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener:); + if (![[m_webView UIDelegate] respondsToSelector:selector]) { + geolocation->setIsAllowed(false); + return; + } + WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()]; - WebGeolocation *webGeolocation = [[WebGeolocation alloc] _initWithWebCoreGeolocation:geolocation]; - CallUIDelegate(m_webView, @selector(webView:frame:requestGeolocationPermission:securityOrigin:), kit(frame), webGeolocation, webOrigin); + WebGeolocationPolicyListener* listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:geolocation]; + + CallUIDelegate(m_webView, selector, webOrigin, kit(frame), listener); + [webOrigin release]; - [webGeolocation release]; + [listener release]; END_BLOCK_OBJC_EXCEPTIONS; } @@ -823,3 +842,25 @@ void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geoloca } @end + +@implementation WebGeolocationPolicyListener + +- (id)initWithGeolocation:(Geolocation*)geolocation +{ + if (!(self = [super init])) + return nil; + _geolocation = geolocation; + return self; +} + +- (void)allow +{ + _geolocation->setIsAllowed(true); +} + +- (void)deny +{ + _geolocation->setIsAllowed(false); +} + +@end diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h index cf6eb0b..2774783 100644 --- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h +++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h @@ -91,6 +91,10 @@ private: virtual void dispatchDidCancelClientRedirect(); virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); + virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); @@ -194,7 +198,7 @@ private: virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); virtual WebCore::String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm index efd1f68..9816e01 100644 --- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm +++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm @@ -69,6 +69,7 @@ #import "WebPolicyDelegatePrivate.h" #import "WebPreferences.h" #import "WebResourceLoadDelegate.h" +#import "WebScriptWorldInternal.h" #import "WebSecurityOriginInternal.h" #import "WebUIDelegate.h" #import "WebUIDelegatePrivate.h" @@ -128,6 +129,7 @@ using namespace WebCore; using namespace HTMLNames; +using namespace std; #if ENABLE(MAC_JAVA_BRIDGE) @interface NSView (WebJavaPluginDetails) @@ -536,6 +538,30 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() CallFrameLoadDelegate(implementations->didChangeLocationWithinPageForFrameFunc, webView, @selector(webView:didChangeLocationWithinPageForFrame:), m_webFrame.get()); } +void WebFrameLoaderClient::dispatchDidPushStateWithinPage() +{ + WebView *webView = getWebView(m_webFrame.get()); + WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView); + if (implementations->didPushStateWithinPageForFrameFunc) + CallFrameLoadDelegate(implementations->didPushStateWithinPageForFrameFunc, webView, @selector(webView:didPushStateWithinPageForFrame:), m_webFrame.get()); +} + +void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage() +{ + WebView *webView = getWebView(m_webFrame.get()); + WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView); + if (implementations->didReplaceStateWithinPageForFrameFunc) + CallFrameLoadDelegate(implementations->didReplaceStateWithinPageForFrameFunc, webView, @selector(webView:didReplaceStateWithinPageForFrame:), m_webFrame.get()); +} + +void WebFrameLoaderClient::dispatchDidPopStateWithinPage() +{ + WebView *webView = getWebView(m_webFrame.get()); + WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView); + if (implementations->didPopStateWithinPageForFrameFunc) + CallFrameLoadDelegate(implementations->didPopStateWithinPageForFrameFunc, webView, @selector(webView:didPopStateWithinPageForFrame:), m_webFrame.get()); +} + void WebFrameLoaderClient::dispatchWillClose() { WebView *webView = getWebView(m_webFrame.get()); @@ -963,7 +989,7 @@ bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest& request) cons bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const { - return [WebView canShowMIMEType:MIMEType]; + return [getWebView(m_webFrame.get()) _canShowMIMEType:MIMEType]; } bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const @@ -1127,7 +1153,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() if (usesDocumentViews) { // FIXME (Viewless): I assume we want the equivalent of this optimization for viewless mode too. - bool willProduceHTMLView = [[WebFrameView class] _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class]; + bool willProduceHTMLView = [m_webFrame->_private->webFrameView _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class]; bool canSkipCreation = core(m_webFrame.get())->loader()->committingFirstRealLoad() && willProduceHTMLView; if (canSkipCreation) { [[m_webFrame->_private->webFrameView documentView] setDataSource:dataSource]; @@ -1234,7 +1260,7 @@ String WebFrameLoaderClient::userAgent(const KURL& url) if (!webView) return String(""); - return [webView _userAgentForURL:url]; + return [webView userAgentForURL:url]; } static const MouseEvent* findMouseEvent(const Event* event) @@ -1375,7 +1401,7 @@ ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const return ObjectContentOtherPlugin; } - if ([WebFrameView _viewClassForMIMEType:type]) + if ([m_webFrame->_private->webFrameView _viewClassForMIMEType:type]) return ObjectContentFrame; return ObjectContentNone; @@ -1701,12 +1727,23 @@ String WebFrameLoaderClient::overrideMediaType() const void WebFrameLoaderClient::documentElementAvailable() { } -void WebFrameLoaderClient::windowObjectCleared() +void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) { - Frame *frame = core(m_webFrame.get()); - ScriptController *script = frame->script(); WebView *webView = getWebView(m_webFrame.get()); WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView); + + if (implementations->didClearWindowObjectForFrameInScriptWorldFunc) { + CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameInScriptWorldFunc, + webView, @selector(webView:didClearWindowObjectForFrame:inScriptWorld:), m_webFrame.get(), [WebScriptWorld findOrCreateWorld:world]); + return; + } + + if (world != mainThreadNormalWorld()) + return; + + Frame *frame = core(m_webFrame.get()); + ScriptController *script = frame->script(); + if (implementations->didClearWindowObjectForFrameFunc) { CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameFunc, webView, @selector(webView:didClearWindowObject:forFrame:), script->windowScriptObject(), m_webFrame.get()); diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm b/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm index 95b4301..32e8d0d 100644 --- a/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm +++ b/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm @@ -25,7 +25,6 @@ #import "WebGeolocationMockPrivate.h" -#import "WebGeolocationInternal.h" #import <WebCore/GeolocationServiceMock.h> #import <WebCore/Geoposition.h> #import <WebCore/PositionError.h> diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationPrivate.h b/WebKit/mac/WebCoreSupport/WebGeolocationPrivate.h deleted file mode 100644 index 5807f7c..0000000 --- a/WebKit/mac/WebCoreSupport/WebGeolocationPrivate.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2009 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 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 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 <Foundation/Foundation.h> - -@class WebGeolocationPrivate; - -@interface WebGeolocation : NSObject { -@private - WebGeolocationPrivate *_private; -} - -- (BOOL)shouldClearCache; -- (void)setIsAllowed:(BOOL)allowed; -@end diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.h b/WebKit/mac/WebCoreSupport/WebInspectorClient.h index 7487728..64621f8 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.h +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.h @@ -62,9 +62,8 @@ public: virtual void hideHighlight(); virtual void inspectedURLChanged(const WebCore::String& newURL); - virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&); - virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&); - virtual void removeSetting(const WebCore::String& key); + virtual void populateSetting(const WebCore::String& key, WebCore::String* value); + virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); virtual void inspectorWindowObjectCleared(); diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm index 6a4f67d..01515b1 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm @@ -327,8 +327,8 @@ void WebInspectorClient::inspectorWindowObjectCleared() _visible = YES; // If no preference is set - default to an attached window. This is important for inspector LayoutTests. - InspectorController::Setting shouldAttach = [_inspectedWebView page]->inspectorController()->setting(inspectorStartsAttachedName); - _shouldAttach = (shouldAttach.type() == InspectorController::Setting::BooleanType) ? shouldAttach.booleanValue() : true; + String shouldAttach = [_inspectedWebView page]->inspectorController()->setting(inspectorStartsAttachedName); + _shouldAttach = shouldAttach != "false"; if (_shouldAttach) { WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView]; @@ -362,7 +362,7 @@ void WebInspectorClient::inspectorWindowObjectCleared() if (_attachedToInspectedWebView) return; - [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(true)); + [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "true"); _movingWindows = YES; [self close]; @@ -376,7 +376,7 @@ void WebInspectorClient::inspectorWindowObjectCleared() if (!_attachedToInspectedWebView) return; - [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(false)); + [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "false"); _movingWindows = YES; [self close]; diff --git a/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h b/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h index 0bab4e3..a0d398d 100644 --- a/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h +++ b/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h @@ -27,6 +27,7 @@ namespace WebCore { class Node; + class String; } @class WebView; @@ -35,7 +36,7 @@ class WebPluginHalterClient : public WebCore::PluginHalterClient { public: WebPluginHalterClient(WebView *); - virtual bool shouldHaltPlugin(WebCore::Node*) const; + virtual bool shouldHaltPlugin(WebCore::Node*, bool, const WebCore::String&) const; virtual bool enabled() const; private: diff --git a/WebKit/mac/WebCoreSupport/WebPluginHalterClient.mm b/WebKit/mac/WebCoreSupport/WebPluginHalterClient.mm index b83e4c8..0c87d19 100644 --- a/WebKit/mac/WebCoreSupport/WebPluginHalterClient.mm +++ b/WebKit/mac/WebCoreSupport/WebPluginHalterClient.mm @@ -28,6 +28,7 @@ #import "DOMNodeInternal.h" #import "WebDelegateImplementationCaching.h" #import "WebView.h" +#import <WebCore/PlatformString.h> using namespace WebCore; @@ -37,10 +38,10 @@ WebPluginHalterClient::WebPluginHalterClient(WebView *webView) ASSERT_ARG(webView, webView); } -bool WebPluginHalterClient::shouldHaltPlugin(Node* pluginNode) const +bool WebPluginHalterClient::shouldHaltPlugin(Node* pluginNode, bool isWindowed, const String& pluginName) const { - ASSERT_ARG(pluginNode, pluginNode); - return CallUIDelegateReturningBoolean(NO, m_webView, @selector(webView:shouldHaltPlugin:), kit(pluginNode)); + ASSERT_ARG(pluginNode, pluginNode); + return CallUIDelegateReturningBoolean(NO, m_webView, @selector(webView:shouldHaltPlugin:isWindowed:pluginName:), kit(pluginNode), isWindowed, (NSString *)pluginName); } bool WebPluginHalterClient::enabled() const diff --git a/WebKit/mac/WebCoreSupport/WebSystemInterface.m b/WebKit/mac/WebCoreSupport/WebSystemInterface.m index f957814..f2a215d 100644 --- a/WebKit/mac/WebCoreSupport/WebSystemInterface.m +++ b/WebKit/mac/WebCoreSupport/WebSystemInterface.m @@ -1,5 +1,5 @@ /* - * Copyright 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -41,6 +41,7 @@ void InitWebCoreSystemInterface(void) INIT(AdvanceDefaultButtonPulseAnimation); INIT(CGContextGetShouldSmoothFonts); + INIT(CopyCONNECTProxyResponse); INIT(CreateCustomCFReadStream); INIT(CreateNSURLConnectionDelegateProxy); INIT(DrawCapsLockIndicator); @@ -62,8 +63,11 @@ void InitWebCoreSystemInterface(void) INIT(InitializeMaximumHTTPConnectionCountPerHost); INIT(IsLatchingWheelEvent); INIT(MeasureMediaUIPart); + INIT(MediaControllerThemeAvailable); INIT(PopupMenu); INIT(SetCGFontRenderingMode); + INIT(SetCONNECTProxyAuthorizationForStream); + INIT(SetCONNECTProxyForStream); INIT(SetDragImage); INIT(SetNSURLConnectionDefersCallbacks); INIT(SetNSURLRequestShouldContentSniff); @@ -79,6 +83,8 @@ void InitWebCoreSystemInterface(void) INIT(QTMovieMaxTimeLoadedChangeNotification); INIT(QTMovieMaxTimeSeekable); INIT(QTMovieGetType); + INIT(QTMovieHasClosedCaptions); + INIT(QTMovieSetShowClosedCaptions); INIT(QTMovieViewSetDrawSynchronously); #ifndef BUILDING_ON_TIGER diff --git a/WebKit/mac/WebCoreSupport/WebViewFactory.mm b/WebKit/mac/WebCoreSupport/WebViewFactory.mm index 79b2959..99729dc 100644 --- a/WebKit/mac/WebCoreSupport/WebViewFactory.mm +++ b/WebKit/mac/WebCoreSupport/WebViewFactory.mm @@ -555,6 +555,12 @@ - (NSString *)AXARIAContentGroupText:(NSString *)ariaType { + if ([ariaType isEqualToString:@"ARIAApplicationAlert"]) + return UI_STRING("alert", "An ARIA accessibility group that acts as an alert."); + if ([ariaType isEqualToString:@"ARIAApplicationAlertDialog"]) + return UI_STRING("alert dialog", "An ARIA accessibility group that acts as an alert dialog."); + if ([ariaType isEqualToString:@"ARIAApplicationDialog"]) + return UI_STRING("dialog", "An ARIA accessibility group that acts as an dialog."); if ([ariaType isEqualToString:@"ARIAApplicationLog"]) return UI_STRING("log", "An ARIA accessibility group that acts as a console log."); if ([ariaType isEqualToString:@"ARIAApplicationMarquee"]) @@ -587,6 +593,10 @@ return UI_STRING("search", "An ARIA accessibility group that contains a search feature of a website."); if ([ariaType isEqualToString:@"ARIAUserInterfaceTooltip"]) return UI_STRING("tooltip", "An ARIA accessibility group that acts as a tooltip."); + if ([ariaType isEqualToString:@"ARIATabPanel"]) + return UI_STRING("tab panel", "An ARIA accessibility group that contains the content of a tab."); + if ([ariaType isEqualToString:@"ARIADocumentMath"]) + return UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols."); return nil; } @@ -684,6 +694,11 @@ return UI_STRING("fast forward", "accessibility role description for fast forward button"); if ([name isEqualToString:@"SeekBackButton"]) return UI_STRING("fast reverse", "accessibility role description for fast reverse button"); + if ([name isEqualToString:@"ShowClosedCaptionsButton"]) + return UI_STRING("show closed captions", "accessibility role description for show closed captions button"); + if ([name isEqualToString:@"HideClosedCaptionsButton"]) + return UI_STRING("hide closed captions", "accessibility role description for hide closed captions button"); + ASSERT_NOT_REACHED(); return @""; } @@ -723,6 +738,10 @@ return UI_STRING("seek quickly forward", "accessibility help text for fast forward button"); if ([name isEqualToString:@"FullscreenButton"]) return UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button"); + if ([name isEqualToString:@"ShowClosedCaptionsButton"]) + return UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button"); + if ([name isEqualToString:@"HideClosedCaptionsButton"]) + return UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button"); ASSERT_NOT_REACHED(); return @""; } @@ -730,7 +749,7 @@ - (NSString*)localizedMediaTimeDescription:(float)time { if (!isfinite(time)) - return UI_STRING("indefinite time", "string for an indefinite movie time"); + return UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value"); int seconds = (int)fabsf(time); int days = seconds / (60 * 60 * 24); @@ -739,13 +758,48 @@ seconds %= 60; if (days) - return [NSString stringWithFormat:UI_STRING("date.format.for.days", "string for days, hours, minutes & seconds"), days, hours, minutes, seconds]; + return [NSString stringWithFormat:UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds]; else if (hours) - return [NSString stringWithFormat:UI_STRING("date.format.for.hours", "string for hours, minutes & seconds"), hours, minutes, seconds]; + return [NSString stringWithFormat:UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds]; else if (minutes) - return [NSString stringWithFormat:UI_STRING("date.format.for.minutes", "string for minutes & seconds"), minutes, seconds]; + return [NSString stringWithFormat:UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds]; + + return [NSString stringWithFormat:UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds]; +} + +- (NSString *)validationMessageValueMissingText +{ + return UI_STRING("value missing", "Validation message for required form control elements that have no value"); +} + +- (NSString *)validationMessageTypeMismatchText +{ + return UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type"); +} + +- (NSString *)validationMessagePatternMismatchText +{ + return UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern"); +} + +- (NSString *)validationMessageTooLongText +{ + return UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length"); +} - return [NSString stringWithFormat:UI_STRING("date.format.for.seconds", "string for seconds"), seconds]; +- (NSString *)validationMessageRangeUnderflowText +{ + return UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum"); +} + +- (NSString *)validationMessageRangeOverflowText +{ + return UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum"); +} + +- (NSString *)validationMessageStepMismatchText +{ + return UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute"); } @end diff --git a/WebKit/mac/WebInspector/WebInspector.h b/WebKit/mac/WebInspector/WebInspector.h index c16726d..fa13c8d 100644 --- a/WebKit/mac/WebInspector/WebInspector.h +++ b/WebKit/mac/WebInspector/WebInspector.h @@ -49,6 +49,8 @@ - (BOOL)isJavaScriptProfilingEnabled; - (void)setJavaScriptProfilingEnabled:(BOOL)enabled; +- (BOOL)isTimelineProfilingEnabled; +- (void)setTimelineProfilingEnabled:(BOOL)enabled; - (BOOL)isProfilingJavaScript; - (void)toggleProfilingJavaScript:(id)sender; diff --git a/WebKit/mac/WebInspector/WebInspector.mm b/WebKit/mac/WebInspector/WebInspector.mm index ccb09c5..258dd01 100644 --- a/WebKit/mac/WebInspector/WebInspector.mm +++ b/WebKit/mac/WebInspector/WebInspector.mm @@ -148,6 +148,25 @@ using namespace WebCore; page->inspectorController()->disableProfiler(); } +- (BOOL)isTimelineProfilingEnabled +{ + if (Page* page = core(_webView)) + return page->inspectorController()->timelineAgent() ? YES : NO; + return NO; +} + +- (void)setTimelineProfilingEnabled:(BOOL)enabled +{ + Page* page = core(_webView); + if (!page) + return; + + if (enabled) + page->inspectorController()->startTimelineProfiler(); + else + page->inspectorController()->stopTimelineProfiler(); +} + - (void)close:(id)sender { if (Page* page = core(_webView)) diff --git a/WebKit/mac/WebKit.exp b/WebKit/mac/WebKit.exp index 12507d0..3aa270f 100644 --- a/WebKit/mac/WebKit.exp +++ b/WebKit/mac/WebKit.exp @@ -28,7 +28,9 @@ .objc_class_name_WebRenderNode .objc_class_name_WebResource .objc_class_name_WebScriptCallFrame +.objc_class_name_WebScriptWorld .objc_class_name_WebSecurityOrigin +.objc_class_name_WebSerializedJSValue .objc_class_name_WebStringTruncator .objc_class_name_WebTextIterator .objc_class_name_WebURLsWithTitles @@ -117,3 +119,4 @@ _WebViewDidEndEditingNotification _WebViewProgressEstimateChangedNotification _WebViewProgressFinishedNotification _WebViewProgressStartedNotification +__WebViewDidStartAcceleratedCompositingNotification diff --git a/WebKit/mac/WebView/WebDataSource.mm b/WebKit/mac/WebView/WebDataSource.mm index b83139d..ecd89f7 100644 --- a/WebKit/mac/WebView/WebDataSource.mm +++ b/WebKit/mac/WebView/WebDataSource.mm @@ -140,10 +140,10 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl } } -+ (Class)_representationClassForMIMEType:(NSString *)MIMEType ++ (Class)_representationClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins { Class repClass; - return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil; + return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType allowingPlugins:allowPlugins] ? repClass : nil; } @end @@ -340,7 +340,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl - (void)_makeRepresentation { - Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType]]; + Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType] allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]]; // Check if the data source was already bound? if (![[self representation] isKindOfClass:repClass]) { diff --git a/WebKit/mac/WebView/WebDelegateImplementationCaching.h b/WebKit/mac/WebView/WebDelegateImplementationCaching.h index edf3cad..3ad064c 100644 --- a/WebKit/mac/WebView/WebDelegateImplementationCaching.h +++ b/WebKit/mac/WebView/WebDelegateImplementationCaching.h @@ -49,6 +49,7 @@ struct WebResourceDelegateImplementationCache { struct WebFrameLoadDelegateImplementationCache { IMP didClearWindowObjectForFrameFunc; + IMP didClearWindowObjectForFrameInScriptWorldFunc; IMP didClearInspectorWindowObjectForFrameFunc; IMP windowScriptObjectAvailableFunc; IMP didHandleOnloadEventsForFrameFunc; @@ -56,6 +57,9 @@ struct WebFrameLoadDelegateImplementationCache { IMP didCancelClientRedirectForFrameFunc; IMP willPerformClientRedirectToURLDelayFireDateForFrameFunc; IMP didChangeLocationWithinPageForFrameFunc; + IMP didPushStateWithinPageForFrameFunc; + IMP didReplaceStateWithinPageForFrameFunc; + IMP didPopStateWithinPageForFrameFunc; IMP willCloseFrameFunc; IMP didStartProvisionalLoadForFrameFunc; IMP didReceiveTitleForFrameFunc; @@ -110,6 +114,7 @@ BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL); BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id); BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, id); BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, BOOL); +BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, BOOL, id); id CallFrameLoadDelegate(IMP, WebView *, SEL); id CallFrameLoadDelegate(IMP, WebView *, SEL, id); diff --git a/WebKit/mac/WebView/WebDelegateImplementationCaching.mm b/WebKit/mac/WebView/WebDelegateImplementationCaching.mm index 486d094..54c4c33 100644 --- a/WebKit/mac/WebView/WebDelegateImplementationCaching.mm +++ b/WebKit/mac/WebView/WebDelegateImplementationCaching.mm @@ -233,6 +233,20 @@ static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id d return result; } +static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object, BOOL boolean, id object2) +{ + if (!delegate || ![delegate respondsToSelector:selector]) + return result; + if (!self->_private->catchesDelegateExceptions) + return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id, BOOL, id)>(objc_msgSend)(delegate, selector, self, object, boolean, object2); + @try { + return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id, BOOL, id)>(objc_msgSend)(delegate, selector, self, object, boolean, object2); + } @catch(id exception) { + ReportDiscardedDelegateException(selector, exception); + } + return result; +} + static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object1, id object2) { if (!delegate || ![delegate respondsToSelector:selector]) @@ -456,6 +470,11 @@ BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object, boolean); } +BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object, BOOL boolean, id object2) +{ + return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object, boolean, object2); +} + BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object1, id object2) { return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object1, object2); diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm index 3c28e3c..b4424e1 100644 --- a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm +++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm @@ -354,6 +354,10 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; } } + // Calling super can release the last reference. <rdar://problem/7400263> + // Hold a reference so the code following the super call will not crash. + [self retain]; + [super scrollWheel:event]; if (!isLatchingEvent) { @@ -363,6 +367,8 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; verticallyPinnedByPreviousWheelEvent = (verticalPosition == 0.0 || verticalPosition == 1.0); horizontallyPinnedByPreviousWheelEvent = (horizontalPosition == 0.0 || horizontalPosition == 1.0); } + + [self release]; } - (BOOL)accessibilityIsIgnored diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm index 94fe997..58400d6 100644 --- a/WebKit/mac/WebView/WebFrame.mm +++ b/WebKit/mac/WebView/WebFrame.mm @@ -49,6 +49,7 @@ #import "WebNSObjectExtras.h" #import "WebNSURLExtras.h" #import "WebScriptDebugger.h" +#import "WebScriptWorldInternal.h" #import "WebViewInternal.h" #import <JavaScriptCore/APICast.h> #import <WebCore/AXObjectCache.h> @@ -78,6 +79,7 @@ #import <WebCore/RuntimeApplicationChecks.h> #import <WebCore/ScriptValue.h> #import <WebCore/SmartReplace.h> +#import <WebCore/SVGSMILElement.h> #import <WebCore/TextIterator.h> #import <WebCore/ThreadCheck.h> #import <WebCore/TypingCommand.h> @@ -923,20 +925,6 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) _private->coreFrame->computeAndSetTypingStyle(core(style), undoAction); } -- (void)_dragSourceMovedTo:(NSPoint)windowLoc -{ - if (!_private->coreFrame) - return; - FrameView* view = _private->coreFrame->view(); - if (!view) - return; - ASSERT([getWebView(self) _usesDocumentViews]); - // FIXME: These are fake modifier keys here, but they should be real ones instead. - PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [view->platformWidget() window]), - LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime()); - _private->coreFrame->eventHandler()->dragSourceMovedTo(event); -} - - (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation { if (!_private->coreFrame) @@ -1129,6 +1117,29 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) return controller->pauseTransitionAtTime(coreNode->renderer(), name, time); } +// Pause a given SVG animation on the target node at a specific time. +// This method is only intended to be used for testing the SVG animation system. +- (BOOL)_pauseSVGAnimation:(NSString*)elementId onSMILNode:(DOMNode *)node atTime:(NSTimeInterval)time +{ + Frame* frame = core(self); + if (!frame) + return false; + + Document* document = frame->document(); + if (!document || !document->svgExtensions()) + return false; + + Node* coreNode = core(node); + if (!coreNode || !SVGSMILElement::isSMILElement(coreNode)) + return false; + +#if ENABLE(SVG) + return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreNode), time); +#else + return false; +#endif +} + - (unsigned) _numberOfActiveAnimations { Frame* frame = core(self); @@ -1204,7 +1215,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) return SecurityOrigin::canLoad(URL, String(), _private->coreFrame->document()); } -- (NSString *)_stringByEvaluatingJavaScriptInIsolatedWorld:(unsigned)worldID WithGlobalObject:(JSObjectRef)globalObjectRef FromString:(NSString *)string +- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string withGlobalObject:(JSObjectRef)globalObjectRef inScriptWorld:(WebScriptWorld *)world { // Start off with some guess at a frame and a global object, we'll try to do better...! JSDOMWindow* anyWorldGlobalObject = _private->coreFrame->script()->globalObject(mainThreadNormalWorld()); @@ -1217,7 +1228,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) // Get the frame frome the global object we've settled on. Frame* frame = anyWorldGlobalObject->impl()->frame(); ASSERT(frame->document()); - JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue(); + JSValue result = frame->script()->executeScriptInWorld(core(world), string, true).jsValue(); if (!frame) // In case the script removed our frame from the page. return @""; @@ -1232,12 +1243,15 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) return String(result.toString(anyWorldGlobalObject->globalExec())); } -- (JSGlobalContextRef)contextForWorldID:(unsigned)worldID; +- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world { Frame* coreFrame = _private->coreFrame; if (!coreFrame) return 0; - return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec()); + DOMWrapperWorld* coreWorld = core(world); + if (!coreWorld) + return 0; + return toGlobalRef(coreFrame->script()->globalObject(coreWorld)->globalExec()); } @end diff --git a/WebKit/mac/WebView/WebFrameInternal.h b/WebKit/mac/WebView/WebFrameInternal.h index 10a3015..0dcf19b 100644 --- a/WebKit/mac/WebView/WebFrameInternal.h +++ b/WebKit/mac/WebView/WebFrameInternal.h @@ -155,7 +155,6 @@ WebView *getWebView(WebFrame *webFrame); - (DOMCSSStyleDeclaration *)_typingStyle; - (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction; -- (void)_dragSourceMovedTo:(NSPoint)windowLoc; - (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation; - (BOOL)_canProvideDocumentSource; diff --git a/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h b/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h index 80fa08a..2359cc6 100644 --- a/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h +++ b/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h @@ -28,6 +28,7 @@ #import <WebKit/WebFrameLoadDelegate.h> +@class WebScriptWorld; @class WebSecurityOrigin; @interface NSObject (WebFrameLoadDelegatePrivate) @@ -36,4 +37,10 @@ - (void)webView:(WebView *)webView didRunInsecureContent:(WebSecurityOrigin *)origin; +- (void)webView:(WebView *)webView didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world; + +- (void)webView:(WebView *)webView didPushStateWithinPageForFrame:(WebFrame *)frame; +- (void)webView:(WebView *)webView didReplaceStateWithinPageForFrame:(WebFrame *)frame; +- (void)webView:(WebView *)webView didPopStateWithinPageForFrame:(WebFrame *)frame; + @end diff --git a/WebKit/mac/WebView/WebFramePrivate.h b/WebKit/mac/WebView/WebFramePrivate.h index be13430..462686f 100644 --- a/WebKit/mac/WebView/WebFramePrivate.h +++ b/WebKit/mac/WebView/WebFramePrivate.h @@ -39,6 +39,7 @@ @class DOMNode; @class WebIconFetcher; @class WebScriptObject; +@class WebScriptWorld; // Keys for accessing the values in the page cache dictionary. extern NSString *WebPageCacheEntryDateKey; @@ -96,8 +97,8 @@ typedef enum { - (void)_recursive_pauseNullEventsForAllNetscapePlugins; #endif -- (NSString *)_stringByEvaluatingJavaScriptInIsolatedWorld:(unsigned)worldID WithGlobalObject:(JSObjectRef)globalObject FromString:(NSString *)string; -- (JSGlobalContextRef)contextForWorldID:(unsigned)worldID; +- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string withGlobalObject:(JSObjectRef)globalObject inScriptWorld:(WebScriptWorld *)world; +- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world; // Pause a given CSS animation or transition on the target node at a specific time. // If the animation or transition is already paused, it will update its pause time. @@ -105,6 +106,10 @@ typedef enum { - (BOOL)_pauseAnimation:(NSString*)name onNode:(DOMNode *)node atTime:(NSTimeInterval)time; - (BOOL)_pauseTransitionOfProperty:(NSString*)name onNode:(DOMNode*)node atTime:(NSTimeInterval)time; +// Pause a given SVG animation on the target node at a specific time. +// This method is only intended to be used for testing the SVG animation system. +- (BOOL)_pauseSVGAnimation:(NSString*)elementId onSMILNode:(DOMNode *)node atTime:(NSTimeInterval)time; + // Returns the total number of currently running animations (includes both CSS transitions and CSS animations). - (unsigned) _numberOfActiveAnimations; diff --git a/WebKit/mac/WebView/WebFrameView.mm b/WebKit/mac/WebView/WebFrameView.mm index c300586..4638418 100644 --- a/WebKit/mac/WebView/WebFrameView.mm +++ b/WebKit/mac/WebView/WebFrameView.mm @@ -156,7 +156,7 @@ enum { NSString* MIMEType = [dataSource _responseMIMEType]; if (!MIMEType) MIMEType = @"text/html"; - Class viewClass = [[self class] _viewClassForMIMEType:MIMEType]; + Class viewClass = [self _viewClassForMIMEType:MIMEType]; NSView <WebDocumentView> *documentView; if (viewClass) { // If the dataSource's representation has already been created, and it is also the @@ -244,10 +244,15 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl return [[[self _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType] isSubclassOfClass:[WebHTMLView class]]; } -+ (Class)_viewClassForMIMEType:(NSString *)MIMEType ++ (Class)_viewClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins { Class viewClass; - return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType] ? viewClass : nil; + return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType allowingPlugins:allowPlugins] ? viewClass : nil; +} + +- (Class)_viewClassForMIMEType:(NSString *)MIMEType +{ + return [[self class] _viewClassForMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]]; } - (void)_install @@ -273,6 +278,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl owner->setWidget(view); // Now the render part owns the view, so we don't any more. } + + view->updateCanHaveScrollbars(); } @end diff --git a/WebKit/mac/WebView/WebFrameViewInternal.h b/WebKit/mac/WebView/WebFrameViewInternal.h index 726b62e..9d7fd80 100644 --- a/WebKit/mac/WebView/WebFrameViewInternal.h +++ b/WebKit/mac/WebView/WebFrameViewInternal.h @@ -39,7 +39,8 @@ - (void)_setWebFrame:(WebFrame *)webFrame; - (float)_verticalPageScrollDistance; + (NSMutableDictionary *)_viewTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission; -+ (Class)_viewClassForMIMEType:(NSString *)MIMEType; +- (Class)_viewClassForMIMEType:(NSString *)MIMEType; ++ (Class)_viewClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins; + (BOOL)_canShowMIMETypeAsHTML:(NSString *)MIMEType; - (WebDynamicScrollBarsView *)_scrollView; - (void)_install; diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm index 936b6d7..5dc66ee 100644 --- a/WebKit/mac/WebView/WebHTMLView.mm +++ b/WebKit/mac/WebView/WebHTMLView.mm @@ -1976,11 +1976,6 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info) // remove tooltips before clearing _private so removeTrackingRect: will work correctly [self removeAllToolTips]; -#if USE(ACCELERATED_COMPOSITING) - if (_private->layerHostingView) - [[self _webView] _stoppedAcceleratedCompositingForFrame:[self _frame]]; -#endif - [_private clear]; Page* page = core([self _webView]); @@ -2666,7 +2661,10 @@ WEBCORE_COMMAND(yankAndSelect) if (action == @selector(_lookUpInDictionaryFromMenu:)) return [self _hasSelection]; - + + if (action == @selector(stopSpeaking:)) + return [NSApp isSpeaking]; + #ifndef BUILDING_ON_TIGER if (action == @selector(toggleGrammarChecking:)) { // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must validate @@ -2885,6 +2883,14 @@ WEBCORE_COMMAND(yankAndSelect) { if ([self superview] != nil) [self addSuperviewObservers]; + +#if USE(ACCELERATED_COMPOSITING) + if ([self superview] && [self _isUsingAcceleratedCompositing]) { + WebView *webView = [self _webView]; + if ([webView _postsAcceleratedCompositingNotifications]) + [[NSNotificationCenter defaultCenter] postNotificationName:_WebViewDidStartAcceleratedCompositingNotification object:webView userInfo:nil]; + } +#endif } - (void)viewWillMoveToWindow:(NSWindow *)window @@ -3441,21 +3447,6 @@ done: return (NSDragOperation)page->dragController()->sourceDragOperation(); } -- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenLoc -{ - ASSERT(![self _webView] || [self _isTopHTMLView]); - - NSPoint windowImageLoc = [[self window] convertScreenToBase:screenLoc]; - NSPoint windowMouseLoc = windowImageLoc; - - if (Page* page = core([self _webView])) { - DragController* dragController = page->dragController(); - NSPoint windowMouseLoc = NSMakePoint(windowImageLoc.x + dragController->dragOffset().x(), windowImageLoc.y + dragController->dragOffset().y()); - } - - [[self _frame] _dragSourceMovedTo:windowMouseLoc]; -} - - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation { ASSERT(![self _webView] || [self _isTopHTMLView]); @@ -5425,7 +5416,6 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) [hostingView release]; // hostingView is owned by being a subview of self _private->layerHostingView = hostingView; - [[self _webView] _startedAcceleratedCompositingForFrame:[self _frame]]; } // Make a container layer, which will get sized/positioned by AppKit and CA. @@ -5454,6 +5444,9 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) // Parent our root layer in the container layer [viewLayer addSublayer:layer]; + if ([[self _webView] _postsAcceleratedCompositingNotifications]) + [[NSNotificationCenter defaultCenter] postNotificationName:_WebViewDidStartAcceleratedCompositingNotification object:[self _webView] userInfo:nil]; + #if defined(BUILDING_ON_LEOPARD) [self _updateLayerHostingViewPosition]; #endif @@ -5466,7 +5459,6 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) [_private->layerHostingView setWantsLayer:NO]; [_private->layerHostingView removeFromSuperview]; _private->layerHostingView = nil; - [[self _webView] _stoppedAcceleratedCompositingForFrame:[self _frame]]; } } @@ -5923,7 +5915,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde Vector<FloatRect> list; if (Frame* coreFrame = core([self _frame])) - coreFrame->selectionTextRects(list); + coreFrame->selectionTextRects(list, Frame::RespectTransforms); unsigned size = list.size(); NSMutableArray *result = [[[NSMutableArray alloc] initWithCapacity:size] autorelease]; diff --git a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h index 4a87337..d295323 100644 --- a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h +++ b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h @@ -85,6 +85,8 @@ #define WebKitZoomsTextOnlyPreferenceKey @"WebKitZoomsTextOnly" #define WebKitXSSAuditorEnabledPreferenceKey @"WebKitXSSAuditorEnabled" #define WebKitAcceleratedCompositingEnabledPreferenceKey @"WebKitAcceleratedCompositingEnabled" +#define WebKitShowDebugBordersPreferenceKey @"WebKitShowDebugBorders" +#define WebKitShowRepaintCounterPreferenceKey @"WebKitShowRepaintCounter" #define WebKitWebGLEnabledPreferenceKey @"WebKitWebGLEnabled" #define WebKitPluginAllowedRunTimePreferenceKey @"WebKitPluginAllowedRunTime" diff --git a/WebKit/mac/WebView/WebPreferences.mm b/WebKit/mac/WebView/WebPreferences.mm index 4914340..6b55ea3 100644 --- a/WebKit/mac/WebView/WebPreferences.mm +++ b/WebKit/mac/WebView/WebPreferences.mm @@ -351,6 +351,8 @@ static WebCacheModel cacheModelForMainBundle(void) [NSNumber numberWithBool:YES], WebKitZoomsTextOnlyPreferenceKey, [NSNumber numberWithBool:YES], WebKitXSSAuditorEnabledPreferenceKey, [NSNumber numberWithBool:YES], WebKitAcceleratedCompositingEnabledPreferenceKey, + [NSNumber numberWithBool:NO], WebKitShowDebugBordersPreferenceKey, + [NSNumber numberWithBool:NO], WebKitShowRepaintCounterPreferenceKey, [NSNumber numberWithBool:NO], WebKitWebGLEnabledPreferenceKey, [NSNumber numberWithUnsignedInt:4], WebKitPluginAllowedRunTimePreferenceKey, nil]; @@ -1151,6 +1153,26 @@ static NSString *classIBCreatorID = nil; [self _setBoolValue:enabled forKey:WebKitAcceleratedCompositingEnabledPreferenceKey]; } +- (BOOL)showDebugBorders +{ + return [self _boolValueForKey:WebKitShowDebugBordersPreferenceKey]; +} + +- (void)setShowDebugBorders:(BOOL)enabled +{ + [self _setBoolValue:enabled forKey:WebKitShowDebugBordersPreferenceKey]; +} + +- (BOOL)showRepaintCounter +{ + return [self _boolValueForKey:WebKitShowRepaintCounterPreferenceKey]; +} + +- (void)setShowRepaintCounter:(BOOL)enabled +{ + [self _setBoolValue:enabled forKey:WebKitShowRepaintCounterPreferenceKey]; +} + - (BOOL)webGLEnabled { return [self _boolValueForKey:WebKitWebGLEnabledPreferenceKey]; diff --git a/WebKit/mac/WebView/WebPreferencesPrivate.h b/WebKit/mac/WebView/WebPreferencesPrivate.h index c558cbb..3cea78b 100644 --- a/WebKit/mac/WebView/WebPreferencesPrivate.h +++ b/WebKit/mac/WebView/WebPreferencesPrivate.h @@ -149,6 +149,12 @@ extern NSString *WebPreferencesRemovedNotification; - (BOOL)acceleratedCompositingEnabled; - (void)setAcceleratedCompositingEnabled:(BOOL)enabled; +- (BOOL)showDebugBorders; +- (void)setShowDebugBorders:(BOOL)show; + +- (BOOL)showRepaintCounter; +- (void)setShowRepaintCounter:(BOOL)show; + - (BOOL)webGLEnabled; - (void)setWebGLEnabled:(BOOL)enabled; diff --git a/WebKit/mac/WebView/WebScriptDebugDelegate.mm b/WebKit/mac/WebView/WebScriptDebugDelegate.mm index ef2cb67..8489c9b 100644 --- a/WebKit/mac/WebView/WebScriptDebugDelegate.mm +++ b/WebKit/mac/WebView/WebScriptDebugDelegate.mm @@ -249,7 +249,7 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; } JSValue exception; - JSValue result = DebuggerCallFrame_evaluateInWorld(*_private->debuggerCallFrame, String(script), exception); + JSValue result = _private->debuggerCallFrame->evaluate(String(script), exception); if (exception) return [self _convertValueToObjcValue:exception]; return result ? [self _convertValueToObjcValue:result] : nil; diff --git a/WebKit/mac/WebView/WebScriptWorld.h b/WebKit/mac/WebView/WebScriptWorld.h new file mode 100644 index 0000000..9204975 --- /dev/null +++ b/WebKit/mac/WebView/WebScriptWorld.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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. + */ + +@class WebScriptWorldPrivate; + +@interface WebScriptWorld : NSObject { +@private + WebScriptWorldPrivate *_private; +} + ++ (WebScriptWorld *)standardWorld; ++ (WebScriptWorld *)world; +@end diff --git a/WebKit/mac/WebView/WebScriptWorld.mm b/WebKit/mac/WebView/WebScriptWorld.mm new file mode 100644 index 0000000..0310701 --- /dev/null +++ b/WebKit/mac/WebView/WebScriptWorld.mm @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 "WebScriptWorld.h" + +#import "WebScriptWorldInternal.h" +#import <WebCore/JSDOMBinding.h> +#import <WebCore/ScriptController.h> +#import <wtf/RefPtr.h> + +using namespace WebCore; + +@interface WebScriptWorldPrivate : NSObject { +@public + RefPtr<DOMWrapperWorld> world; +} +@end + +@implementation WebScriptWorldPrivate +@end + +typedef HashMap<DOMWrapperWorld*, WebScriptWorld*> WorldMap; +static WorldMap& allWorlds() +{ + static WorldMap& map = *new WorldMap; + return map; +} + +@implementation WebScriptWorld + +- (id)initWithWorld:(PassRefPtr<DOMWrapperWorld>)world +{ + ASSERT_ARG(world, world); + if (!world) + return nil; + + self = [super init]; + if (!self) + return nil; + + _private = [[WebScriptWorldPrivate alloc] init]; + _private->world = world; + + ASSERT_ARG(world, !allWorlds().contains(_private->world.get())); + allWorlds().add(_private->world.get(), self); + + return self; +} + +- (id)init +{ + return [self initWithWorld:ScriptController::createWorld()]; +} + +- (void)dealloc +{ + ASSERT(allWorlds().contains(_private->world.get())); + allWorlds().remove(_private->world.get()); + + [_private release]; + _private = nil; + [super dealloc]; +} + ++ (WebScriptWorld *)standardWorld +{ + static WebScriptWorld *world = [[WebScriptWorld alloc] initWithWorld:mainThreadNormalWorld()]; + return world; +} + ++ (WebScriptWorld *)world +{ + return [[[self alloc] init] autorelease]; +} + +@end + +@implementation WebScriptWorld (WebInternal) + +DOMWrapperWorld* core(WebScriptWorld *world) +{ + return world ? world->_private->world.get() : 0; +} + ++ (WebScriptWorld *)findOrCreateWorld:(DOMWrapperWorld*) world +{ + ASSERT_ARG(world, world); + + if (world == mainThreadNormalWorld()) + return [self standardWorld]; + + if (WebScriptWorld *existingWorld = allWorlds().get(world)) + return existingWorld; + + return [[[self alloc] initWithWorld:world] autorelease]; +} + +@end diff --git a/WebKit/mac/WebView/WebScriptWorldInternal.h b/WebKit/mac/WebView/WebScriptWorldInternal.h new file mode 100644 index 0000000..785d9c0 --- /dev/null +++ b/WebKit/mac/WebView/WebScriptWorldInternal.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 "WebScriptWorld.h" + +namespace WebCore { + class DOMWrapperWorld; +} + +WebCore::DOMWrapperWorld* core(WebScriptWorld *); + +@interface WebScriptWorld (WebInternal) ++ (WebScriptWorld *)findOrCreateWorld:(WebCore::DOMWrapperWorld*)world; +@end diff --git a/WebKit/mac/WebView/WebSerializedJSValue.h b/WebKit/mac/WebView/WebSerializedJSValue.h new file mode 100644 index 0000000..5094776 --- /dev/null +++ b/WebKit/mac/WebView/WebSerializedJSValue.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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. + */ + +@class WebSerializedJSValuePrivate; + +typedef const struct OpaqueJSContext* JSContextRef; +typedef const struct OpaqueJSValue* JSValueRef; + +@interface WebSerializedJSValue : NSObject { +@private + WebSerializedJSValuePrivate *_private; +} + +- (id)initWithValue:(JSValueRef)object context:(JSContextRef)sourceContext exception:(JSValueRef*)exception; +- (JSValueRef)deserialize:(JSContextRef)destinationContext; + +@end diff --git a/WebKit/mac/WebView/WebSerializedJSValue.mm b/WebKit/mac/WebView/WebSerializedJSValue.mm new file mode 100644 index 0000000..af96aa4 --- /dev/null +++ b/WebKit/mac/WebView/WebSerializedJSValue.mm @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 "WebSerializedJSValue.h" + +#import <WebCore/SerializedScriptValue.h> +#import <wtf/RefPtr.h> + +using namespace WebCore; + +@interface WebSerializedJSValuePrivate : NSObject { +@public + RefPtr<SerializedScriptValue> value; +} +@end + +@implementation WebSerializedJSValuePrivate +@end + +@implementation WebSerializedJSValue + +- (id)initWithValue:(JSValueRef)value context:(JSContextRef)sourceContext exception:(JSValueRef*)exception; +{ + ASSERT_ARG(value, value); + ASSERT_ARG(sourceContext, sourceContext); + + if (!value || !sourceContext) { + [self release]; + return nil; + } + + self = [super init]; + if (!self) + return nil; + + _private = [[WebSerializedJSValuePrivate alloc] init]; + + _private->value = SerializedScriptValue::create(sourceContext, value, exception); + if (!_private->value) { + [self release]; + return nil; + } + + return self; +} + +- (JSValueRef)deserialize:(JSContextRef)destinationContext +{ + if (!_private || !_private->value) + return 0; + return _private->value->deserialize(destinationContext, 0); +} + +- (void)dealloc +{ + [_private release]; + _private = nil; + [super dealloc]; +} + +@end + diff --git a/WebKit/mac/WebView/WebUIDelegatePrivate.h b/WebKit/mac/WebView/WebUIDelegatePrivate.h index 0715475..a130b18 100644 --- a/WebKit/mac/WebView/WebUIDelegatePrivate.h +++ b/WebKit/mac/WebView/WebUIDelegatePrivate.h @@ -87,9 +87,14 @@ enum { WebMenuItemTagChangeBack, WebMenuItemTagBaseApplication = 10000 }; -@class WebGeolocation; + @class WebSecurityOrigin; +@protocol WebGeolocationPolicyListener <NSObject> +- (void)allow; +- (void)deny; +@end + @interface NSObject (WebUIDelegatePrivate) - (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message; @@ -109,7 +114,7 @@ enum { - (void)webView:(WebView *)sender willPopupMenu:(NSMenu *)menu; - (void)webView:(WebView *)sender contextMenuItemSelected:(NSMenuItem *)item forElement:(NSDictionary *)element; - (void)webView:(WebView *)sender saveFrameView:(WebFrameView *)frameView showingPanel:(BOOL)showingPanel; -- (BOOL)webView:(WebView *)sender shouldHaltPlugin:(DOMNode *)pluginNode; +- (BOOL)webView:(WebView *)sender shouldHaltPlugin:(DOMNode *)pluginNode isWindowed:(BOOL)isWindowed pluginName:(NSString *)pluginName; /*! @method webView:frame:exceededDatabaseQuotaForSecurityOrigin:database: @param sender The WebView sending the delegate method. @@ -124,7 +129,17 @@ enum { - (BOOL)webView:(WebView *)sender shouldReplaceUploadFile:(NSString *)path usingGeneratedFilename:(NSString **)filename; - (NSString *)webView:(WebView *)sender generateReplacementFile:(NSString *)path; -- (BOOL)webView:(WebView *)sender frame:(WebFrame *)frame requestGeolocationPermission:(WebGeolocation *)geolocation securityOrigin:(WebSecurityOrigin *)origin; +/*! + @method webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener: + @abstract + @param webView The WebView sending the delegate method. + @param origin The security origin that would like to use Geolocation. + @param frame The WebFrame whose JavaScript initiated this call. + @param listener The object to call when the decision is made +*/ +- (void)webView:(WebView *)webView decidePolicyForGeolocationRequestFromOrigin:(WebSecurityOrigin *)origin + frame:(WebFrame *)frame + listener:(id<WebGeolocationPolicyListener>)listener; - (void)webView:(WebView *)sender formStateDidChangeForNode:(DOMNode *)node; - (void)webView:(WebView *)sender formDidFocusNode:(DOMNode *)node; diff --git a/WebKit/mac/WebView/WebVideoFullscreenController.h b/WebKit/mac/WebView/WebVideoFullscreenController.h index bb6a083..2e0c4c3 100644 --- a/WebKit/mac/WebView/WebVideoFullscreenController.h +++ b/WebKit/mac/WebView/WebVideoFullscreenController.h @@ -10,47 +10,50 @@ * 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. + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. */ #if ENABLE(VIDEO) -#import <Cocoa/Cocoa.h> #import <wtf/RefPtr.h> -#import <WebCore/HTMLMediaElement.h> + +namespace WebCore { + class HTMLMediaElement; +} @protocol WebVideoFullscreenControllerDelegate; @class WebVideoFullscreenHUDWindowController; @class WebWindowFadeAnimation; -@interface WebVideoFullscreenController : NSWindowController -{ +@interface WebVideoFullscreenController : NSWindowController { @private RefPtr<WebCore::HTMLMediaElement> _mediaElement; // (retain) - id<WebVideoFullscreenControllerDelegate> _delegate; // (assign) + id <WebVideoFullscreenControllerDelegate> _delegate; // (assign) NSWindow *_backgroundFullscreenWindow; // (retain) - WebVideoFullscreenHUDWindowController* _hudController; // (retain) + WebVideoFullscreenHUDWindowController *_hudController; // (retain) WebWindowFadeAnimation *_fadeAnimation; // (retain) BOOL _isEndingFullscreen; BOOL _isWindowLoaded; BOOL _forceDisableAnimation; + SystemUIMode _savedUIMode; + SystemUIOptions _savedUIOptions; } -- (id<WebVideoFullscreenControllerDelegate>)delegate; -- (void)setDelegate:(id<WebVideoFullscreenControllerDelegate>)delegate; +- (id <WebVideoFullscreenControllerDelegate>)delegate; +- (void)setDelegate:(id <WebVideoFullscreenControllerDelegate>)delegate; - (void)setMediaElement:(WebCore::HTMLMediaElement*)mediaElement; - (WebCore::HTMLMediaElement*)mediaElement; @@ -60,5 +63,4 @@ @end -#endif - +#endif // ENABLE(VIDEO) diff --git a/WebKit/mac/WebView/WebVideoFullscreenController.mm b/WebKit/mac/WebView/WebVideoFullscreenController.mm index fe07f3e..946da90 100644 --- a/WebKit/mac/WebView/WebVideoFullscreenController.mm +++ b/WebKit/mac/WebView/WebVideoFullscreenController.mm @@ -10,34 +10,30 @@ * 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. + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. */ #if ENABLE(VIDEO) -#import <QTKit/QTKit.h> -#import <objc/objc-runtime.h> -#import <HIToolbox/HIToolbox.h> - -#import <wtf/UnusedParam.h> -#import <WebCore/SoftLinking.h> -#import <WebCore/IntRect.h> - #import "WebVideoFullscreenController.h" -#import "WebVideoFullscreenHUDWindowController.h" -#import "WebKitSystemInterface.h" + #import "WebTypesInternal.h" +#import "WebVideoFullscreenHUDWindowController.h" #import "WebWindowAnimation.h" +#import <QTKit/QTKit.h> +#import <WebCore/HTMLMediaElement.h> +#import <WebCore/SoftLinking.h> +#import <objc/objc-runtime.h> SOFT_LINK_FRAMEWORK(QTKit) SOFT_LINK_CLASS(QTKit, QTMovieView) @@ -53,11 +49,8 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) { SEL _controllerActionOnAnimationEnd; WebWindowScaleAnimation *_fullscreenAnimation; // (retain) - QTMovieView *_movieView; // (retain) } - (void)animateFromRect:(NSRect)startRect toRect:(NSRect)endRect withSubAnimation:(NSAnimation *)subAnimation controllerAction:(SEL)controllerAction; -- (QTMovieView *)movieView; -- (void)setMovieView:(QTMovieView *)movieView; @end @interface WebVideoFullscreenController(HUDWindowControllerDelegate) <WebVideoFullscreenHUDWindowControllerDelegate> @@ -94,7 +87,7 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) WebVideoFullscreenWindow *window = [self fullscreenWindow]; QTMovieView *view = [[getQTMovieViewClass() alloc] init]; [view setFillColor:[NSColor clearColor]]; - [window setMovieView:view]; + [window setContentView:view]; [view setControllerVisible:NO]; [view setPreservesAspectRatio:YES]; if (_mediaElement) @@ -113,10 +106,10 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) { _mediaElement = mediaElement; if ([self isWindowLoaded]) { - QTMovieView *movieView = [[self fullscreenWindow] movieView]; + QTMovieView *movieView = (QTMovieView *)[[self fullscreenWindow] contentView]; QTMovie *movie = _mediaElement->platformMedia().qtMovie; - ASSERT(movieView); + ASSERT(movieView && [movieView isKindOfClass:[getQTMovieViewClass() class]]); ASSERT(movie); [movieView setMovie:movie]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -126,12 +119,12 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) } } -- (id<WebVideoFullscreenControllerDelegate>)delegate +- (id <WebVideoFullscreenControllerDelegate>)delegate { return _delegate; } -- (void)setDelegate:(id<WebVideoFullscreenControllerDelegate>)delegate; +- (void)setDelegate:(id <WebVideoFullscreenControllerDelegate>)delegate; { _delegate = delegate; } @@ -148,13 +141,10 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) - (void)windowDidExitFullscreen { - // If we don't clear the movie, underlying movie data structures are leaked and the movie keeps playing <rdar://problem/7295070> - [[[self fullscreenWindow] movieView] setMovie:nil]; - [self clearFadeAnimation]; [[self window] close]; [self setWindow:nil]; - SetSystemUIMode(kUIModeNormal, 0); + SetSystemUIMode(_savedUIMode, _savedUIOptions); [_hudController setDelegate:nil]; [_hudController release]; _hudController = nil; @@ -174,6 +164,7 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) _hudController = [[WebVideoFullscreenHUDWindowController alloc] init]; [_hudController setDelegate:self]; + GetSystemUIMode(&_savedUIMode, &_savedUIOptions); SetSystemUIMode(kUIModeAllSuppressed , 0); [NSCursor setHiddenUntilMouseMoves:YES]; @@ -340,20 +331,6 @@ static NSWindow *createBackgroundFullscreenWindow(NSRect frame, int level) [super dealloc]; } -- (QTMovieView *)movieView -{ - return _movieView; -} - -- (void)setMovieView:(QTMovieView *)movieView -{ - if (_movieView == movieView) - return; - [_movieView release]; - _movieView = [movieView retain]; - [self setContentView:_movieView]; -} - - (BOOL)resignFirstResponder { return NO; diff --git a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.h b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.h index 1ffa596..a3d74d2 100644 --- a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.h +++ b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.h @@ -10,44 +10,47 @@ * 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. + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. */ #if ENABLE(VIDEO) -#import <Cocoa/Cocoa.h> -#import <WebCore/HTMLMediaElement.h> +namespace WebCore { + class HTMLMediaElement; +} @protocol WebVideoFullscreenHUDWindowControllerDelegate; -@interface WebVideoFullscreenHUDWindowController : NSWindowController { -@private - id<WebVideoFullscreenHUDWindowControllerDelegate> _delegate; +@interface WebVideoFullscreenHUDWindowController : NSWindowController +{ + id <WebVideoFullscreenHUDWindowControllerDelegate> _delegate; NSTimer *_timelineUpdateTimer; #if !defined(BUILDING_ON_TIGER) NSTrackingArea *_area; #endif BOOL _mouseIsInHUD; BOOL _isEndingFullscreen; + BOOL _isScrubbing; NSControl *_timeline; NSTextField *_remainingTimeText; NSTextField *_elapsedTimeText; NSControl *_volumeSlider; - NSControl *_playButton; + NSButton *_playButton; } -- (id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate; -- (void)setDelegate:(id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate; + +- (id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate; +- (void)setDelegate:(id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate; - (void)fadeWindowIn; - (void)fadeWindowOut; - (void)closeWindow; diff --git a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm index c61ae7c..82cb1bf 100644 --- a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm +++ b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm @@ -10,48 +10,56 @@ * 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. + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. */ #if ENABLE(VIDEO) #import "WebVideoFullscreenHUDWindowController.h" -#import <QTKit/QTKit.h> #import "WebKitSystemInterface.h" #import "WebTypesInternal.h" -#import <wtf/RetainPtr.h> -#import <limits> +#import <JavaScriptCore/RetainPtr.h> +#import <JavaScriptCore/UnusedParam.h> +#import <WebCore/HTMLMediaElement.h> +using namespace WebCore; using namespace std; +static inline CGFloat webkit_CGFloor(CGFloat value) +{ + if (sizeof(value) == sizeof(float)) + return floorf(value); + return floor(value); +} + #define HAVE_MEDIA_CONTROL (!defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)) @interface WebVideoFullscreenHUDWindowController (Private) <NSWindowDelegate> -- (void)keyDown:(NSEvent *)event; - - (void)updateTime; - (void)timelinePositionChanged:(id)sender; - (float)currentTime; - (void)setCurrentTime:(float)currentTime; - (double)duration; -- (double)maxVolume; - (void)volumeChanged:(id)sender; +- (double)maxVolume; - (double)volume; - (void)setVolume:(double)volume; +- (void)decrementVolume; +- (void)incrementVolume; +- (void)updatePlayButton; - (void)togglePlaying:(id)sender; - (BOOL)playing; - (void)setPlaying:(BOOL)playing; @@ -65,11 +73,6 @@ using namespace std; - (void)exitFullscreen:(id)sender; @end - -// -// HUD Window -// - @interface WebVideoFullscreenHUDWindow : NSWindow @end @@ -136,10 +139,6 @@ using namespace std; @end -// -// HUD Window Controller -// - static const CGFloat windowHeight = 59; static const CGFloat windowWidth = 438; @@ -149,7 +148,7 @@ static const NSTimeInterval HUDWindowFadeOutDelay = 3; - (id)init { - NSWindow* window = [[WebVideoFullscreenHUDWindow alloc] initWithContentRect:NSMakeRect(0, 0, windowWidth, windowHeight) + NSWindow *window = [[WebVideoFullscreenHUDWindow alloc] initWithContentRect:NSMakeRect(0, 0, windowWidth, windowHeight) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; self = [super initWithWindow:window]; [window setDelegate:self]; @@ -166,6 +165,7 @@ static const NSTimeInterval HUDWindowFadeOutDelay = 3; #if !defined(BUILDING_ON_TIGER) ASSERT(!_area); #endif + ASSERT(!_isScrubbing); [_timeline release]; [_remainingTimeText release]; [_elapsedTimeText release]; @@ -186,18 +186,38 @@ static const NSTimeInterval HUDWindowFadeOutDelay = 3; - (void)keyDown:(NSEvent *)event { - if ([[event characters] isEqualToString:@" "]) - [_playButton performClick:self]; - else - [super keyDown:event]; + NSString *charactersIgnoringModifiers = [event charactersIgnoringModifiers]; + if ([charactersIgnoringModifiers length] == 1) { + switch ([charactersIgnoringModifiers characterAtIndex:0]) { + case ' ': + [self togglePlaying:nil]; + return; + case NSUpArrowFunctionKey: + if ([event modifierFlags] & NSAlternateKeyMask) + [self setVolume:[self maxVolume]]; + else + [self incrementVolume]; + return; + case NSDownArrowFunctionKey: + if ([event modifierFlags] & NSAlternateKeyMask) + [self setVolume:0]; + else + [self decrementVolume]; + return; + default: + break; + } + } + + [super keyDown:event]; } -- (id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate +- (id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate { return _delegate; } -- (void)setDelegate:(id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate +- (void)setDelegate:(id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate { _delegate = delegate; } @@ -208,7 +228,7 @@ static const NSTimeInterval HUDWindowFadeOutDelay = 3; // First, update right away, then schedule future update [self updateTime]; - [self updateRate]; + [self updatePlayButton]; [_timelineUpdateTimer invalidate]; [_timelineUpdateTimer release]; @@ -216,7 +236,7 @@ static const NSTimeInterval HUDWindowFadeOutDelay = 3; // Note that this creates a retain cycle between the window and us. _timelineUpdateTimer = [[NSTimer timerWithTimeInterval:0.25 target:self selector:@selector(updateTime) userInfo:nil repeats:YES] retain]; #if defined(BUILDING_ON_TIGER) - [[NSRunLoop currentRunLoop] addTimer:_timelineUpdateTimer forMode:(NSString*)kCFRunLoopCommonModes]; + [[NSRunLoop currentRunLoop] addTimer:_timelineUpdateTimer forMode:(NSString *)kCFRunLoopCommonModes]; #else [[NSRunLoop currentRunLoop] addTimer:_timelineUpdateTimer forMode:NSRunLoopCommonModes]; #endif @@ -306,7 +326,7 @@ static NSTextField *createTimeTextField(NSRect frame) NSTextField *textField = [[NSTextField alloc] initWithFrame:frame]; [textField setTextColor:[NSColor whiteColor]]; [textField setBordered:NO]; - [textField setFont:[NSFont systemFontOfSize:10]]; + [textField setFont:[NSFont boldSystemFontOfSize:10]]; [textField setDrawsBackground:NO]; [textField setBezeled:NO]; [textField setEditable:NO]; @@ -316,10 +336,25 @@ static NSTextField *createTimeTextField(NSRect frame) - (void)windowDidLoad { - static const CGFloat kMargin = 9; - static const CGFloat kMarginTop = 9; - static const CGFloat kButtonSize = 25; - static const CGFloat kButtonMiniSize = 16; + static const CGFloat horizontalMargin = 10; + static const CGFloat playButtonWidth = 41; + static const CGFloat playButtonHeight = 35; + static const CGFloat playButtonTopMargin = 4; + static const CGFloat volumeSliderWidth = 50; + static const CGFloat volumeSliderHeight = 13; + static const CGFloat volumeButtonWidth = 18; + static const CGFloat volumeButtonHeight = 16; + static const CGFloat volumeUpButtonLeftMargin = 4; + static const CGFloat volumeControlsTopMargin = 13; + static const CGFloat exitFullScreenButtonWidth = 25; + static const CGFloat exitFullScreenButtonHeight = 21; + static const CGFloat exitFullScreenButtonTopMargin = 11; + static const CGFloat timelineWidth = 315; + static const CGFloat timelineHeight = 14; + static const CGFloat timelineBottomMargin = 7; + static const CGFloat timeTextFieldWidth = 54; + static const CGFloat timeTextFieldHeight = 13; + static const CGFloat timeTextFieldHorizontalMargin = 7; NSWindow *window = [self window]; ASSERT(window); @@ -331,53 +366,48 @@ static NSTextField *createTimeTextField(NSRect frame) #endif [window setContentView:background]; #if !defined(BUILDING_ON_TIGER) - _area = [[NSTrackingArea alloc] initWithRect:[background bounds] options:NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways owner:self userInfo:nil]; + _area = [[NSTrackingArea alloc] initWithRect:[background bounds] options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:self userInfo:nil]; [background addTrackingArea:_area]; #endif [background release]; - NSView *contentView = [[self window] contentView]; + NSView *contentView = [window contentView]; - CGFloat top = windowHeight - kMarginTop; - CGFloat center = (windowWidth - kButtonSize) / 2; - _playButton = createControlWithMediaUIControlType(WKMediaUIControlPlayPauseButton, NSMakeRect(center, top - kButtonSize, kButtonSize, kButtonSize)); + CGFloat center = webkit_CGFloor((windowWidth - playButtonWidth) / 2); + _playButton = (NSButton *)createControlWithMediaUIControlType(WKMediaUIControlPlayPauseButton, NSMakeRect(center, windowHeight - playButtonTopMargin - playButtonHeight, playButtonWidth, playButtonHeight)); + ASSERT([_playButton isKindOfClass:[NSButton class]]); [_playButton setTarget:self]; [_playButton setAction:@selector(togglePlaying:)]; [contentView addSubview:_playButton]; - CGFloat closeToRight = windowWidth - 2 * kMargin - kButtonMiniSize; - NSControl *exitFullscreenButton = createControlWithMediaUIControlType(WKMediaUIControlExitFullscreenButton, NSMakeRect(closeToRight, top - kButtonSize / 2 - kButtonMiniSize / 2, kButtonMiniSize, kButtonMiniSize)); + CGFloat closeToRight = windowWidth - horizontalMargin - exitFullScreenButtonWidth; + NSControl *exitFullscreenButton = createControlWithMediaUIControlType(WKMediaUIControlExitFullscreenButton, NSMakeRect(closeToRight, windowHeight - exitFullScreenButtonTopMargin - exitFullScreenButtonHeight, exitFullScreenButtonWidth, exitFullScreenButtonHeight)); [exitFullscreenButton setAction:@selector(exitFullscreen:)]; [exitFullscreenButton setTarget:self]; [contentView addSubview:exitFullscreenButton]; [exitFullscreenButton release]; - CGFloat left = kMargin; - NSControl *volumeDownButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeDownButton, NSMakeRect(left, top - kButtonSize / 2 - kButtonMiniSize / 2, kButtonMiniSize, kButtonMiniSize)); + CGFloat volumeControlsBottom = windowHeight - volumeControlsTopMargin - volumeButtonHeight; + CGFloat left = horizontalMargin; + NSControl *volumeDownButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeDownButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight)); [contentView addSubview:volumeDownButton]; [volumeDownButton setTarget:self]; - [volumeDownButton setAction:@selector(decrementVolume:)]; + [volumeDownButton setAction:@selector(setVolumeToZero:)]; [volumeDownButton release]; - static const int volumeSliderWidth = 50; - - left = kMargin + kButtonMiniSize; - _volumeSlider = createControlWithMediaUIControlType(WKMediaUIControlSlider, NSMakeRect(left, top - kButtonSize / 2 - kButtonMiniSize / 2, volumeSliderWidth, kButtonMiniSize)); + left += volumeButtonWidth; + _volumeSlider = createControlWithMediaUIControlType(WKMediaUIControlSlider, NSMakeRect(left, volumeControlsBottom + webkit_CGFloor((volumeButtonHeight - volumeSliderHeight) / 2), volumeSliderWidth, volumeSliderHeight)); [_volumeSlider setValue:[NSNumber numberWithDouble:[self maxVolume]] forKey:@"maxValue"]; [_volumeSlider setTarget:self]; [_volumeSlider setAction:@selector(volumeChanged:)]; [contentView addSubview:_volumeSlider]; - left = kMargin + kButtonMiniSize + volumeSliderWidth + kButtonMiniSize / 2; - NSControl *volumeUpButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeUpButton, NSMakeRect(left, top - kButtonSize / 2 - kButtonMiniSize / 2, kButtonMiniSize, kButtonMiniSize)); + left += volumeSliderWidth + volumeUpButtonLeftMargin; + NSControl *volumeUpButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeUpButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight)); [volumeUpButton setTarget:self]; - [volumeUpButton setAction:@selector(incrementVolume:)]; + [volumeUpButton setAction:@selector(setVolumeToMaximum:)]; [contentView addSubview:volumeUpButton]; [volumeUpButton release]; - - static const int timeTextWidth = 50; - static const int sliderHeight = 13; - static const int sliderMarginFixup = 4; #ifdef HAVE_MEDIA_CONTROL _timeline = WKCreateMediaUIControl(WKMediaUIControlTimeline); @@ -386,26 +416,21 @@ static NSTextField *createTimeTextField(NSRect frame) #endif [_timeline setTarget:self]; [_timeline setAction:@selector(timelinePositionChanged:)]; - [_timeline setFrame:NSMakeRect(kMargin + timeTextWidth + kMargin/2, kMargin - sliderMarginFixup, windowWidth - 2 * (kMargin - sliderMarginFixup) - kMargin * 2 - 2 * timeTextWidth, sliderHeight)]; + [_timeline setFrame:NSMakeRect(webkit_CGFloor((windowWidth - timelineWidth) / 2), timelineBottomMargin, timelineWidth, timelineHeight)]; [contentView addSubview:_timeline]; - static const int timeTextHeight = 11; - - _elapsedTimeText = createTimeTextField(NSMakeRect(kMargin, kMargin, timeTextWidth, timeTextHeight)); + _elapsedTimeText = createTimeTextField(NSMakeRect(timeTextFieldHorizontalMargin, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight)); + [_elapsedTimeText setAlignment:NSLeftTextAlignment]; [contentView addSubview:_elapsedTimeText]; - _remainingTimeText = createTimeTextField(NSMakeRect(windowWidth - kMargin - timeTextWidth, kMargin, timeTextWidth, timeTextHeight)); + _remainingTimeText = createTimeTextField(NSMakeRect(windowWidth - timeTextFieldHorizontalMargin - timeTextFieldWidth, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight)); + [_remainingTimeText setAlignment:NSRightTextAlignment]; [contentView addSubview:_remainingTimeText]; - + [window recalculateKeyViewLoop]; [window setInitialFirstResponder:_playButton]; [window center]; } - -/* - * Bindings - * - */ - (void)updateVolume { @@ -417,19 +442,31 @@ static NSTextField *createTimeTextField(NSRect frame) [self updateVolume]; [_timeline setFloatValue:[self currentTime]]; - [(NSSlider*)_timeline setMaxValue:[self duration]]; + [_timeline setValue:[NSNumber numberWithDouble:[self duration]] forKey:@"maxValue"]; [_remainingTimeText setStringValue:[self remainingTimeText]]; [_elapsedTimeText setStringValue:[self elapsedTimeText]]; } -- (void)fastForward +- (void)endScrubbing { + ASSERT(_isScrubbing); + _isScrubbing = NO; + if (HTMLMediaElement* mediaElement = [_delegate mediaElement]) + mediaElement->endScrubbing(); } - (void)timelinePositionChanged:(id)sender { [self setCurrentTime:[_timeline floatValue]]; + if (!_isScrubbing) { + _isScrubbing = YES; + if (HTMLMediaElement* mediaElement = [_delegate mediaElement]) + mediaElement->beginScrubbing(); + static NSArray *endScrubbingModes = [[NSArray alloc] initWithObjects:NSDefaultRunLoopMode, NSModalPanelRunLoopMode, nil]; + // Schedule -endScrubbing for when leaving mouse tracking mode. + [[NSRunLoop currentRunLoop] performSelector:@selector(endScrubbing) target:self argument:nil order:0 modes:endScrubbingModes]; + } } - (float)currentTime @@ -443,6 +480,7 @@ static NSTextField *createTimeTextField(NSRect frame) return; WebCore::ExceptionCode e; [_delegate mediaElement]->setCurrentTime(currentTime, e); + [self updateTime]; } - (double)duration @@ -461,7 +499,17 @@ static NSTextField *createTimeTextField(NSRect frame) [self setVolume:[_volumeSlider doubleValue]]; } -- (void)decrementVolume:(id)sender +- (void)setVolumeToZero:(id)sender +{ + [self setVolume:0]; +} + +- (void)setVolumeToMaximum:(id)sender +{ + [self setVolume:[self maxVolume]]; +} + +- (void)decrementVolume { if (![_delegate mediaElement]) return; @@ -470,7 +518,7 @@ static NSTextField *createTimeTextField(NSRect frame) [self setVolume:max(volume, 0.)]; } -- (void)incrementVolume:(id)sender +- (void)incrementVolume { if (![_delegate mediaElement]) return; @@ -492,32 +540,40 @@ static NSTextField *createTimeTextField(NSRect frame) if ([_delegate mediaElement]->muted()) [_delegate mediaElement]->setMuted(false); [_delegate mediaElement]->setVolume(volume / [self maxVolume], e); + [self updateVolume]; } -- (void)updateRate +- (void)updatePlayButton { [_playButton setIntValue:[self playing]]; } -- (void)togglePlaying:(id)sender +- (void)updateRate { - BOOL nowPlaying = [self playing]; - [self setPlaying:!nowPlaying]; + BOOL playing = [self playing]; - // Keep HUD visible when paused - if (!nowPlaying) + // Keep the HUD visible when paused. + if (!playing) [self fadeWindowIn]; else if (!_mouseIsInHUD) { [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil]; [self performSelector:@selector(fadeWindowOut) withObject:nil afterDelay:HUDWindowFadeOutDelay]; } + [self updatePlayButton]; +} + +- (void)togglePlaying:(id)sender +{ + [self setPlaying:![self playing]]; } - (BOOL)playing { - if (![_delegate mediaElement]) - return false; - return ![_delegate mediaElement]->canPlay(); + HTMLMediaElement* mediaElement = [_delegate mediaElement]; + if (!mediaElement) + return NO; + + return !mediaElement->canPlay(); } - (void)setPlaying:(BOOL)playing @@ -533,46 +589,29 @@ static NSTextField *createTimeTextField(NSRect frame) static NSString *timeToString(double time) { + ASSERT_ARG(time, time >= 0); + if (!isfinite(time)) time = 0; - int seconds = (int)fabsf(time); + + int seconds = fabs(time); int hours = seconds / (60 * 60); int minutes = (seconds / 60) % 60; seconds %= 60; - if (hours) { - if (hours > 9) - return [NSString stringWithFormat:@"%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds]; - else - return [NSString stringWithFormat:@"%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds]; - } - else - return [NSString stringWithFormat:@"%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds]; - -} -static NSString *stringToTimeTextAttributed(NSString *string, NSTextAlignment align) -{ - NSShadow *blackShadow = [[NSShadow alloc] init]; - [blackShadow setShadowColor:[NSColor blackColor]]; - [blackShadow setShadowBlurRadius:0]; - [blackShadow setShadowOffset:NSMakeSize(0, -1)]; - NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; - [style setAlignment:align]; - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:blackShadow, NSShadowAttributeName, style, NSParagraphStyleAttributeName, nil]; - [style release]; - [blackShadow release]; + if (hours) + return [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds]; - NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:string attributes:dict]; - return [attrString autorelease]; + return [NSString stringWithFormat:@"%02d:%02d", minutes, seconds]; } - (NSString *)remainingTimeText { - if (![_delegate mediaElement]) + HTMLMediaElement* mediaElement = [_delegate mediaElement]; + if (!mediaElement) return @""; - // Negative number - return stringToTimeTextAttributed(timeToString([_delegate mediaElement]->currentTime() - [_delegate mediaElement]->duration()), NSLeftTextAlignment); + return [@"-" stringByAppendingString:timeToString(mediaElement->duration() - mediaElement->currentTime())]; } - (NSString *)elapsedTimeText @@ -580,13 +619,10 @@ static NSString *stringToTimeTextAttributed(NSString *string, NSTextAlignment al if (![_delegate mediaElement]) return @""; - return stringToTimeTextAttributed(timeToString([_delegate mediaElement]->currentTime()), NSRightTextAlignment); + return timeToString([_delegate mediaElement]->currentTime()); } -/* - * Tracking area callbacks - * - */ +#pragma mark NSResponder - (void)mouseEntered:(NSEvent *)theEvent { @@ -601,11 +637,6 @@ static NSString *stringToTimeTextAttributed(NSString *string, NSTextAlignment al [self fadeWindowIn]; } -/* - * Other Interface callbacks - * - */ - - (void)rewind:(id)sender { if (![_delegate mediaElement]) @@ -627,10 +658,7 @@ static NSString *stringToTimeTextAttributed(NSString *string, NSTextAlignment al [_delegate requestExitFullscreen]; } -/* - * Window callback - * - */ +#pragma mark NSWindowDelegate - (void)windowDidExpose:(NSNotification *)notification { diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index 25da631..33ea069 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -90,6 +90,7 @@ #import "WebPreferenceKeysPrivate.h" #import "WebPreferencesPrivate.h" #import "WebScriptDebugDelegate.h" +#import "WebScriptWorldInternal.h" #import "WebSystemInterface.h" #import "WebTextCompletionController.h" #import "WebTextIterator.h" @@ -115,6 +116,7 @@ #import <WebCore/FrameTree.h> #import <WebCore/FrameView.h> #import <WebCore/GCController.h> +#import <WebCore/HTMLMediaElement.h> #import <WebCore/HTMLNames.h> #import <WebCore/HistoryItem.h> #import <WebCore/IconDatabase.h> @@ -319,10 +321,6 @@ macro(yankAndSelect) \ #define AppleKeyboardUIMode CFSTR("AppleKeyboardUIMode") #define UniversalAccessDomain CFSTR("com.apple.universalaccess") -#if USE(ACCELERATED_COMPOSITING) -#define UsingAcceleratedCompositingProperty @"_isUsingAcceleratedCompositing" -#endif - static BOOL s_didSetCacheModel; static WebCacheModel s_cacheModel = WebCacheModelDocumentViewer; @@ -398,6 +396,8 @@ NSString *_WebMainFrameTitleKey = @"mainFrameTitle"; NSString *_WebMainFrameURLKey = @"mainFrameURL"; NSString *_WebMainFrameDocumentKey = @"mainFrameDocument"; +NSString *_WebViewDidStartAcceleratedCompositingNotification = @"_WebViewDidStartAcceleratedCompositing"; + @interface WebProgressItem : NSObject { @public @@ -820,17 +820,20 @@ static bool runningTigerMail() return uniqueExtensions; } -+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType ++ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins { MIMEType = [MIMEType lowercaseString]; Class viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType]; Class repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType]; - + if (!viewClass || !repClass || [[WebPDFView supportedMIMETypes] containsObject:MIMEType]) { // Our optimization to avoid loading the plug-in DB and image types for the HTML case failed. - // Load the plug-in DB allowing plug-ins to install types. - [WebPluginDatabase sharedDatabase]; - + + if (allowPlugins) { + // Load the plug-in DB allowing plug-ins to install types. + [WebPluginDatabase sharedDatabase]; + } + // Load the image types and get the view class and rep class. This should be the fullest picture of all handled types. viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:NO] _webkit_objectForMIMEType:MIMEType]; repClass = [[WebDataSource _repTypesAllowImageTypeOmission:NO] _webkit_objectForMIMEType:MIMEType]; @@ -855,7 +858,7 @@ static bool runningTigerMail() - (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType { - if ([[self class] _viewClass:vClass andRepresentationClass:rClass forMIMEType:MIMEType]) + if ([[self class] _viewClass:vClass andRepresentationClass:rClass forMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]]) return YES; if (_private->pluginDatabase) { @@ -1301,6 +1304,8 @@ static bool fastDocumentTeardownEnabled() settings->setXSSAuditorEnabled([preferences isXSSAuditorEnabled]); settings->setEnforceCSSMIMETypeInStrictMode(!WKAppVersionCheckLessThan(@"com.apple.iWeb", -1, 2.1)); settings->setAcceleratedCompositingEnabled([preferences acceleratedCompositingEnabled]); + settings->setShowDebugBorders([preferences showDebugBorders]); + settings->setShowRepaintCounter([preferences showRepaintCounter]); settings->setPluginAllowedRunTime([preferences pluginAllowedRunTime]); settings->setWebGLEnabled([preferences webGLEnabled]); } @@ -1346,7 +1351,11 @@ static inline IMP getMethod(id o, SEL s) cache->didCancelClientRedirectForFrameFunc = getMethod(delegate, @selector(webView:didCancelClientRedirectForFrame:)); cache->didChangeLocationWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didChangeLocationWithinPageForFrame:)); + cache->didPushStateWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didPushStateWithinPageForFrame:)); + cache->didReplaceStateWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didReplaceStateWithinPageForFrame:)); + cache->didPopStateWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didPopStateWithinPageForFrame:)); cache->didClearWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearWindowObject:forFrame:)); + cache->didClearWindowObjectForFrameInScriptWorldFunc = getMethod(delegate, @selector(webView:didClearWindowObjectForFrame:inScriptWorld:)); cache->didClearInspectorWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearInspectorWindowObject:forFrame:)); cache->didCommitLoadForFrameFunc = getMethod(delegate, @selector(webView:didCommitLoadForFrame:)); cache->didFailLoadWithErrorForFrameFunc = getMethod(delegate, @selector(webView:didFailLoadWithError:forFrame:)); @@ -1542,9 +1551,6 @@ static inline IMP getMethod(id o, SEL s) if (!manualNotifyKeys) manualNotifyKeys = [[NSSet alloc] initWithObjects:_WebMainFrameURLKey, _WebIsLoadingKey, _WebEstimatedProgressKey, _WebCanGoBackKey, _WebCanGoForwardKey, _WebMainFrameTitleKey, _WebMainFrameIconKey, _WebMainFrameDocumentKey, -#if USE(ACCELERATED_COMPOSITING) - UsingAcceleratedCompositingProperty, // used by DRT -#endif nil]; if ([manualNotifyKeys containsObject:key]) return NO; @@ -2089,10 +2095,35 @@ static inline IMP getMethod(id o, SEL s) return handCursor().impl(); } +- (BOOL)_postsAcceleratedCompositingNotifications +{ +#if USE(ACCELERATED_COMPOSITING) + return _private->postsAcceleratedCompositingNotifications; +#else + return NO; +#endif + +} +- (void)_setPostsAcceleratedCompositingNotifications:(BOOL)flag +{ +#if USE(ACCELERATED_COMPOSITING) + _private->postsAcceleratedCompositingNotifications = flag; +#endif +} + - (BOOL)_isUsingAcceleratedCompositing { #if USE(ACCELERATED_COMPOSITING) - return _private->acceleratedFramesCount > 0; + Frame* coreFrame = [self _mainCoreFrame]; + if (_private->usesDocumentViews) { + for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) { + NSView *documentView = [[kit(frame) frameView] documentView]; + if ([documentView isKindOfClass:[WebHTMLView class]] && [(WebHTMLView *)documentView _isUsingAcceleratedCompositing]) + return YES; + } + } + + return NO; #else return NO; #endif @@ -2175,36 +2206,36 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) return patternsVector; } -+ (void)_addUserScriptToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url ++ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime { String group(groupName); - if (group.isEmpty() || worldID == UINT_MAX) + if (group.isEmpty()) return; PageGroup* pageGroup = PageGroup::pageGroup(group); if (!pageGroup) return; - pageGroup->addUserScriptToWorld(worldID, source, url, toStringVector(whitelist), toStringVector(blacklist), + pageGroup->addUserScriptToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist), injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd); } -+ (void)_addUserStyleSheetToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url ++ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist { String group(groupName); - if (group.isEmpty() || worldID == UINT_MAX) + if (group.isEmpty()) return; PageGroup* pageGroup = PageGroup::pageGroup(group); if (!pageGroup) return; - pageGroup->addUserStyleSheetToWorld(worldID, source, url, toStringVector(whitelist), toStringVector(blacklist)); + pageGroup->addUserStyleSheetToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist)); } -+ (void)_removeUserScriptFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url ++ (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url { String group(groupName); if (group.isEmpty()) @@ -2214,10 +2245,10 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) if (!pageGroup) return; - pageGroup->removeUserScriptFromWorld(worldID, url); + pageGroup->removeUserScriptFromWorld(core(world), url); } -+ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url ++ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url { String group(groupName); if (group.isEmpty()) @@ -2227,10 +2258,10 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) if (!pageGroup) return; - pageGroup->removeUserStyleSheetFromWorld(worldID, url); + pageGroup->removeUserStyleSheetFromWorld(core(world), url); } -+ (void)_removeUserScriptsFromGroup:(NSString *)groupName worldID:(unsigned)worldID ++ (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world { String group(groupName); if (group.isEmpty()) @@ -2240,10 +2271,10 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) if (!pageGroup) return; - pageGroup->removeUserScriptsFromWorld(worldID); + pageGroup->removeUserScriptsFromWorld(core(world)); } -+ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName worldID:(unsigned)worldID ++ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world { String group(groupName); if (group.isEmpty()) @@ -2253,7 +2284,7 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) if (!pageGroup) return; - pageGroup->removeUserStyleSheetsFromWorld(worldID); + pageGroup->removeUserStyleSheetsFromWorld(core(world)); } + (void)_removeAllUserContentFromGroup:(NSString *)groupName @@ -2374,13 +2405,26 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) PageGroup::closeLocalStorage(); } ++ (BOOL)_canShowMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins +{ + return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType allowingPlugins:allowPlugins]; +} + + (BOOL)canShowMIMEType:(NSString *)MIMEType { - return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType]; + return [self _canShowMIMEType:MIMEType allowingPlugins:YES]; +} + +- (BOOL)_canShowMIMEType:(NSString *)MIMEType +{ + return [[self class] _canShowMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]]; } - (WebBasePluginPackage *)_pluginForMIMEType:(NSString *)MIMEType { + if (![_private->preferences arePlugInsEnabled]) + return nil; + WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForMIMEType:MIMEType]; if (pluginPackage) return pluginPackage; @@ -2393,6 +2437,9 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) - (WebBasePluginPackage *)_pluginForExtension:(NSString *)extension { + if (![_private->preferences arePlugInsEnabled]) + return nil; + WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForExtension:extension]; if (pluginPackage) return pluginPackage; @@ -2424,6 +2471,9 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) - (BOOL)_isMIMETypeRegisteredAsPlugin:(NSString *)MIMEType { + if (![_private->preferences arePlugInsEnabled]) + return NO; + if ([[WebPluginDatabase sharedDatabase] isMIMETypeRegistered:MIMEType]) return YES; @@ -3192,7 +3242,14 @@ static bool needsWebViewInitThreadWorkaround() // Get the appropriate user-agent string for a particular URL. - (NSString *)userAgentForURL:(NSURL *)url { - return [self _userAgentForURL:KURL([url absoluteURL])]; + if (_private->useSiteSpecificSpoofing) { + // No current site-specific spoofs. + } + + if (_private->userAgent.isNull()) + _private->userAgent = [[self class] _standardUserAgentWithApplicationName:_private->applicationNameForUserAgent]; + + return _private->userAgent; } - (void)setHostWindow:(NSWindow *)hostWindow @@ -4009,7 +4066,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu if (jsValue.isBoolean()) return [NSAppleEventDescriptor descriptorWithBoolean:jsValue.getBoolean()]; if (jsValue.isString()) - return [NSAppleEventDescriptor descriptorWithString:String(jsValue.getString())]; + return [NSAppleEventDescriptor descriptorWithString:String(jsValue.getString(exec))]; if (jsValue.isNumber()) { double value = jsValue.uncheckedGetNumber(); int intValue = value; @@ -5294,19 +5351,6 @@ static WebFrameView *containingFrameView(NSView *view) } #endif // ENABLE(ICONDATABASE) -// Get the appropriate user-agent string for a particular URL. -- (WebCore::String)_userAgentForURL:(const WebCore::KURL&)url -{ - if (_private->useSiteSpecificSpoofing) { - // No current site-specific spoofs. - } - - if (_private->userAgent.isNull()) - _private->userAgent = [[self class] _standardUserAgentWithApplicationName:_private->applicationNameForUserAgent]; - - return _private->userAgent; -} - - (void)_addObject:(id)object forIdentifier:(unsigned long)identifier { ASSERT(!_private->identifierMap.contains(identifier)); @@ -5417,28 +5461,6 @@ static WebFrameView *containingFrameView(NSView *view) _private->needsOneShotDrawingSynchronization = needsSynchronization; } -- (void)_startedAcceleratedCompositingForFrame:(WebFrame*)webFrame -{ - BOOL entering = _private->acceleratedFramesCount == 0; - if (entering) - [self willChangeValueForKey:UsingAcceleratedCompositingProperty]; - ++_private->acceleratedFramesCount; - if (entering) - [self didChangeValueForKey:UsingAcceleratedCompositingProperty]; -} - -- (void)_stoppedAcceleratedCompositingForFrame:(WebFrame*)webFrame -{ - BOOL leaving = _private->acceleratedFramesCount == 1; - ASSERT(_private->acceleratedFramesCount > 0); - - if (leaving) - [self willChangeValueForKey:UsingAcceleratedCompositingProperty]; - --_private->acceleratedFramesCount; - if (leaving) - [self didChangeValueForKey:UsingAcceleratedCompositingProperty]; -} - - (BOOL)_syncCompositingChanges { Frame* frame = [self _mainCoreFrame]; diff --git a/WebKit/mac/WebView/WebViewData.h b/WebKit/mac/WebView/WebViewData.h index 6ec94a7..37024c7 100644 --- a/WebKit/mac/WebView/WebViewData.h +++ b/WebKit/mac/WebView/WebViewData.h @@ -141,8 +141,7 @@ extern int pluginDatabaseClientCount; // When this flag is set, next time a WebHTMLView draws, it needs to temporarily disable screen updates // so that the NSView drawing is visually synchronized with CALayer updates. BOOL needsOneShotDrawingSynchronization; - // Number of WebHTMLViews using accelerated compositing. Used to implement _isUsingAcceleratedCompositing. - int acceleratedFramesCount; + BOOL postsAcceleratedCompositingNotifications; // Run loop observer used to implement the compositing equivalent of -viewWillDraw CFRunLoopObserverRef layerSyncRunLoopObserver; #endif diff --git a/WebKit/mac/WebView/WebViewInternal.h b/WebKit/mac/WebView/WebViewInternal.h index 15596db..6c2ae50 100644 --- a/WebKit/mac/WebView/WebViewInternal.h +++ b/WebKit/mac/WebView/WebViewInternal.h @@ -67,7 +67,6 @@ namespace WebCore { - (WebCore::Frame*)_mainCoreFrame; - (WebFrame *)_selectedOrMainFrame; -- (WebCore::String)_userAgentForURL:(const WebCore::KURL&)url; - (WebCore::KeyboardUIMode)_keyboardUIMode; - (BOOL)_becomingFirstResponderFromOutside; @@ -82,8 +81,6 @@ namespace WebCore { #if USE(ACCELERATED_COMPOSITING) - (BOOL)_needsOneShotDrawingSynchronization; - (void)_setNeedsOneShotDrawingSynchronization:(BOOL)needsSynchronization; -- (void)_startedAcceleratedCompositingForFrame:(WebFrame*)webFrame; -- (void)_stoppedAcceleratedCompositingForFrame:(WebFrame*)webFrame; - (void)_scheduleCompositingLayerSync; #endif @@ -116,8 +113,10 @@ namespace WebCore { - (void)_pushPerformingProgrammaticFocus; - (void)_popPerformingProgrammaticFocus; - (void)_didStartProvisionalLoadForFrame:(WebFrame *)frame; -+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType; ++ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins; - (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType; ++ (BOOL)_canShowMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins; +- (BOOL)_canShowMIMEType:(NSString *)MIMEType; + (NSString *)_MIMETypeForFile:(NSString *)path; - (WebDownload *)_downloadURL:(NSURL *)URL; + (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme; diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h index 99bd5fa..0622d4c 100644 --- a/WebKit/mac/WebView/WebViewPrivate.h +++ b/WebKit/mac/WebView/WebViewPrivate.h @@ -45,6 +45,7 @@ @class WebFrame; @class WebInspector; @class WebPreferences; +@class WebScriptWorld; @class WebTextIterator; @protocol WebFormDelegate; @@ -66,6 +67,9 @@ extern NSString *WebElementIsContentEditableKey; // NSNumber indicating whether // other WebElementDictionary keys extern NSString *WebElementLinkIsLiveKey; // NSNumber of BOOL indictating whether the link is live or not +// One of the subviews of the WebView entered compositing mode. +extern NSString *_WebViewDidStartAcceleratedCompositingNotification; + #if ENABLE_DASHBOARD_SUPPORT typedef enum { WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows, @@ -460,6 +464,8 @@ Could be worth adding to the API. + (NSCursor *)_pointingHandCursor; // SPI for DumpRenderTree +- (BOOL)_postsAcceleratedCompositingNotifications; +- (void)_setPostsAcceleratedCompositingNotifications:(BOOL)flag; - (BOOL)_isUsingAcceleratedCompositing; // SPI for PluginHalter @@ -479,12 +485,12 @@ Could be worth adding to the API. // Removes all white list entries created with _whiteListAccessFromOrigin. + (void)_resetOriginAccessWhiteLists; -+ (void)_addUserScriptToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime; -+ (void)_addUserStyleSheetToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist; -+ (void)_removeUserScriptFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url; -+ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url; -+ (void)_removeUserScriptsFromGroup:(NSString *)groupName worldID:(unsigned)worldID; -+ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName worldID:(unsigned)worldID; ++ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime; ++ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist; ++ (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url; ++ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url; ++ (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world; ++ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world; + (void)_removeAllUserContentFromGroup:(NSString *)groupName; /*! diff --git a/WebKit/qt/Api/headers.pri b/WebKit/qt/Api/headers.pri index 5a95c67..1a42597 100644 --- a/WebKit/qt/Api/headers.pri +++ b/WebKit/qt/Api/headers.pri @@ -8,7 +8,6 @@ WEBKIT_API_HEADERS = $$PWD/qwebframe.h \ $$PWD/qwebdatabase.h \ $$PWD/qwebsecurityorigin.h \ $$PWD/qwebelement.h \ - $$PWD/qwebplugindatabase.h \ $$PWD/qwebpluginfactory.h \ $$PWD/qwebhistory.h \ $$PWD/qwebinspector.h \ diff --git a/WebKit/qt/Api/qcookiejar.cpp b/WebKit/qt/Api/qcookiejar.cpp deleted file mode 100644 index a02fe78..0000000 --- a/WebKit/qt/Api/qcookiejar.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2007 Staikos Computing Services Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include "qcookiejar.h" -#include <QCoreApplication> -uint qHash(const QUrl&); -#include <QHash> -#include <QPointer> - -class QCookieJarPrivate { - public: - QCookieJarPrivate() - { - enabled = true; - } - bool enabled; - QHash<QUrl, QString> jar; -}; - - -uint qHash(const QUrl& url) -{ - return qHash(url.toString()); -} - - -QCookieJar::QCookieJar() -: QObject(), d(new QCookieJarPrivate) -{ -} - - -QCookieJar::~QCookieJar() -{ - delete d; -} - - -void QCookieJar::setCookies(const QUrl& url, const QUrl& policyUrl, const QString& value) -{ - Q_UNUSED(policyUrl) - d->jar.insert(url, value); -} - - -QString QCookieJar::cookies(const QUrl& url) -{ - return d->jar.value(url); -} - - -bool QCookieJar::isEnabled() const -{ - return d->enabled; -} - - -void QCookieJar::setEnabled(bool enabled) -{ - d->enabled = enabled; -} - - -static QPointer<QCookieJar> gJar; -static bool gRoutineAdded = false; - -static void gCleanupJar() -{ - delete gJar; -} - - -void QCookieJar::setCookieJar(QCookieJar* jar) -{ - if (!gRoutineAdded) { - qAddPostRoutine(gCleanupJar); - gRoutineAdded = true; - } - delete gJar; - gJar = jar; -} - - -QCookieJar* QCookieJar::cookieJar() -{ - if (!gJar) - setCookieJar(new QCookieJar); - - return gJar; -} diff --git a/WebKit/qt/Api/qcookiejar.h b/WebKit/qt/Api/qcookiejar.h deleted file mode 100644 index 7885cc1..0000000 --- a/WebKit/qt/Api/qcookiejar.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2007 Staikos Computing Services Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QCOOKIEJAR_H -#define QCOOKIEJAR_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include "qwebkitglobal.h" - -class QCookieJarPrivate; - -class QWEBKIT_EXPORT QCookieJar : public QObject { - Q_OBJECT - - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) -public: - QCookieJar(); - ~QCookieJar(); - - virtual void setCookies(const QUrl& url, const QUrl& policyUrl, const QString& value); - virtual QString cookies(const QUrl& url); - - bool isEnabled() const; - - static void setCookieJar(QCookieJar* jar); - static QCookieJar* cookieJar(); - -public slots: - virtual void setEnabled(bool enabled); - -private: - friend class QCookieJarPrivate; - QCookieJarPrivate* d; -}; - - -#endif diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index 50a0986..b25b53b 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -39,13 +39,13 @@ public: QGraphicsWebViewPrivate(QGraphicsWebView* parent) : q(parent) , page(0) - , interactive(true) - , progress(1.0) {} + virtual ~QGraphicsWebViewPrivate(); virtual void scroll(int dx, int dy, const QRect&); virtual void update(const QRect& dirtyRect); virtual void setInputMethodEnabled(bool enable); + virtual bool inputMethodEnabled() const; #if QT_VERSION >= 0x040600 virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); #endif @@ -61,26 +61,14 @@ public: virtual QObject* pluginParent() const; - void _q_doLoadProgress(int progress); void _q_doLoadFinished(bool success); - void _q_setStatusBarMessage(const QString& message); QGraphicsWebView* q; QWebPage* page; - - QString statusBarMessage; - bool interactive; - qreal progress; }; -void QGraphicsWebViewPrivate::_q_doLoadProgress(int progress) +QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate() { - if (qFuzzyCompare(this->progress, qreal(progress / 100.))) - return; - - this->progress = progress / 100.; - - emit q->progressChanged(this->progress); } void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) @@ -105,8 +93,20 @@ void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable) { - q->setAttribute(Qt::WA_InputMethodEnabled, enable); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + q->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable); +#endif } + +bool QGraphicsWebViewPrivate::inputMethodEnabled() const +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + return q->flags() & QGraphicsItem::ItemAcceptsInputMethod; +#else + return false; +#endif +} + #if QT_VERSION >= 0x040600 void QGraphicsWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable) { @@ -156,22 +156,78 @@ QObject* QGraphicsWebViewPrivate::pluginParent() const return q; } -void QGraphicsWebViewPrivate::_q_setStatusBarMessage(const QString& s) -{ - statusBarMessage = s; - emit q->statusChanged(); -} - /*! \class QGraphicsWebView - \brief The QGraphicsWebView class allows web content to be added to a GraphicsView. + \brief The QGraphicsWebView class allows Web content to be added to a GraphicsView. \since 4.6 - A WebGraphicsItem renders web content based on a URL or set data. + An instance of this class renders Web content from a URL or supplied as data, using + features of the QtWebKit module. + + If the width and height of the item are not set, they will default to 800 and 600, + respectively. If the Web page contents is larger than that, scrollbars will be shown + if not disabled explicitly. + + \section1 Browser Features + + Many of the functions, signals and properties provided by QWebView are also available + for this item, making it simple to adapt existing code to use QGraphicsWebView instead + of QWebView. - If the width and height of the item is not set, they will - dynamically adjust to a size appropriate for the content. - This width may be large (eg. 980) for typical online web pages. + The item uses a QWebPage object to perform the rendering of Web content, and this can + be obtained with the page() function, enabling the document itself to be accessed and + modified. + + As with QWebView, the item records the browsing history using a QWebHistory object, + accessible using the history() function. The QWebSettings object that defines the + configuration of the browser can be obtained with the settings() function, enabling + features like plugin support to be customized for each item. + + \sa QWebView, QGraphicsTextItem +*/ + +/*! + \fn void QGraphicsWebView::titleChanged(const QString &title) + + This signal is emitted whenever the \a title of the main frame changes. + + \sa title() +*/ + +/*! + \fn void QGraphicsWebView::urlChanged(const QUrl &url) + + This signal is emitted when the \a url of the view changes. + + \sa url(), load() +*/ + +/*! + \fn void QGraphicsWebView::iconChanged() + + This signal is emitted whenever the icon of the page is loaded or changes. + + In order for icons to be loaded, you will need to set an icon database path + using QWebSettings::setIconDatabasePath(). + + \sa icon(), QWebSettings::setIconDatabasePath() +*/ + +/*! + \fn void QGraphicsWebView::loadStarted() + + This signal is emitted when a new load of the page is started. + + \sa loadProgress(), loadFinished() +*/ + +/*! + \fn void QGraphicsWebView::loadFinished(bool ok) + + This signal is emitted when a load of the page is finished. + \a ok will indicate whether the load was successful or any error occurred. + + \sa loadStarted() */ /*! @@ -186,12 +242,13 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) #if QT_VERSION >= 0x040600 setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); #endif + setAcceptDrops(true); setAcceptHoverEvents(true); setFocusPolicy(Qt::StrongFocus); } /*! - Destroys the web graphicsitem. + Destroys the item. */ QGraphicsWebView::~QGraphicsWebView() { @@ -272,6 +329,24 @@ QVariant QGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant& /*! \reimp */ +QSizeF QGraphicsWebView::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const +{ + if (which == Qt::PreferredSize) + return QSizeF(800, 600); // ### + return QGraphicsWidget::sizeHint(which, constraint); +} + +/*! \reimp +*/ +QVariant QGraphicsWebView::inputMethodQuery(Qt::InputMethodQuery query) const +{ + if (d->page) + return d->page->inputMethodQuery(query); + return QVariant(); +} + +/*! \reimp +*/ bool QGraphicsWebView::event(QEvent* event) { // Re-implemented in order to allows fixing event-related bugs in patch releases. @@ -293,7 +368,6 @@ bool QGraphicsWebView::event(QEvent* event) #endif // QT_NO_CONTEXTMENU { #ifndef QT_NO_CURSOR -#if QT_VERSION >= 0x040400 if (event->type() == QEvent::CursorChange) { // An unsetCursor will set the cursor to Qt::ArrowCursor. // Thus this cursor change might be a QWidget::unsetCursor() @@ -307,7 +381,6 @@ bool QGraphicsWebView::event(QEvent* event) d->resetCursor(); } #endif -#endif } } return QGraphicsWidget::event(event); @@ -345,20 +418,22 @@ void QGraphicsWebView::setPage(QWebPage* page) QWebFrame* mainFrame = d->page->mainFrame(); - connect(mainFrame, SIGNAL(titleChanged(const QString&)), - this, SIGNAL(titleChanged(const QString&))); + connect(mainFrame, SIGNAL(titleChanged(QString)), + this, SIGNAL(titleChanged(QString))); connect(mainFrame, SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(mainFrame, SIGNAL(urlChanged(const QUrl&)), - this, SIGNAL(urlChanged(const QUrl&))); + connect(mainFrame, SIGNAL(urlChanged(QUrl)), + this, SIGNAL(urlChanged(QUrl))); connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); connect(d->page, SIGNAL(loadProgress(int)), - this, SLOT(_q_doLoadProgress(int))); + this, SIGNAL(loadProgress(int))); connect(d->page, SIGNAL(loadFinished(bool)), this, SLOT(_q_doLoadFinished(bool))); - connect(d->page, SIGNAL(statusBarMessage(const QString&)), - this, SLOT(_q_setStatusBarMessage(const QString&))); + connect(d->page, SIGNAL(statusBarMessage(QString)), + this, SIGNAL(statusBarMessage(QString))); + connect(d->page, SIGNAL(linkClicked(QUrl)), + this, SIGNAL(linkClicked(QUrl))); } /*! @@ -429,7 +504,6 @@ void QGraphicsWebView::setZoomFactor(qreal factor) return; page()->mainFrame()->setZoomFactor(factor); - emit zoomFactorChanged(); } qreal QGraphicsWebView::zoomFactor() const @@ -466,21 +540,6 @@ void QGraphicsWebView::setGeometry(const QRectF& rect) } /*! - \property QGraphicsWebView::status - \brief the load status message. - - Provides the latest status message set during the load of a URL. - Commonly shown by Status Bar widgets. - - \sa statusChanged() -*/ - -QString QGraphicsWebView::status() const -{ - return d->statusBarMessage; -} - -/*! Convenience slot that stops loading the document. \sa reload(), loadFinished() @@ -527,15 +586,6 @@ void QGraphicsWebView::reload() } /*! - \property QGraphicsWebView::progress - \brief the progress of loading the current URL, from 0 to 1. -*/ -qreal QGraphicsWebView::progress() const -{ - return d->progress; -} - -/*! Loads the specified \a url and displays it. \note The view remains the same until enough data has arrived to display the new \a url. @@ -567,15 +617,14 @@ void QGraphicsWebView::load(const QNetworkRequest& request, } /*! - \property QGraphicsWebView::html - This property provides an HTML interface to the text in the webview. + Sets the content of the web view to the specified \a html. - When setting this property, external objects such as stylesheets or images - referenced in the HTML document are located relative to \a baseUrl. + External objects such as stylesheets or images referenced in the HTML + document are located relative to \a baseUrl. The \a html is loaded immediately; external objects are loaded asynchronously. - When using these methods, WebKit assumes that external resources such as + When using this method, WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. Alternatively, the @@ -588,11 +637,6 @@ void QGraphicsWebView::setHtml(const QString& html, const QUrl& baseUrl) page()->mainFrame()->setHtml(html, baseUrl); } -QString QGraphicsWebView::toHtml() const -{ - return page()->mainFrame()->toHtml(); -} - /*! Sets the content of the web graphicsitem to the specified content \a data. If the \a mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce @@ -622,22 +666,19 @@ QWebHistory* QGraphicsWebView::history() const } /*! - \property QGraphicsWebView::interactive - \brief controls whether the item responds to mouse and key events. -*/ + \property QGraphicsWebView::modified + \brief whether the document was modified by the user -bool QGraphicsWebView::isInteractive() const -{ - return d->interactive; -} + Parts of HTML documents can be editable for example through the + \c{contenteditable} attribute on HTML elements. -void QGraphicsWebView::setInteractive(bool allowed) + By default, this property is false. +*/ +bool QGraphicsWebView::isModified() const { - if (d->interactive == allowed) - return; - - d->interactive = allowed; - emit interactivityChanged(); + if (d->page) + return d->page->isModified(); + return false; } /*! @@ -654,11 +695,53 @@ QWebSettings* QGraphicsWebView::settings() const return page()->settings(); } +/*! + Returns a pointer to a QAction that encapsulates the specified web action \a action. +*/ +QAction *QGraphicsWebView::pageAction(QWebPage::WebAction action) const +{ + return page()->action(action); +} + +/*! + Triggers the specified \a action. If it is a checkable action the specified + \a checked state is assumed. + + \sa pageAction() +*/ +void QGraphicsWebView::triggerPageAction(QWebPage::WebAction action, bool checked) +{ + page()->triggerAction(action, checked); +} + +/*! + Finds the specified string, \a subString, in the page, using the given \a options. + + If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences + that exist in the page. All subsequent calls will extend the highlight, rather than + replace it, with occurrences of the new string. + + If the HighlightAllOccurrences flag is not passed, the function will select an occurrence + and all subsequent calls will replace the current occurrence with the next one. + + To clear the selection, just pass an empty string. + + Returns true if \a subString was found; otherwise returns false. + + \sa QWebPage::selectedText(), QWebPage::selectionChanged() +*/ +bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags options) +{ + if (d->page) + return d->page->findText(subString, options); + return false; +} + /*! \reimp */ void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); QMouseEvent me = QMouseEvent(QEvent::MouseMove, ev->pos().toPoint(), Qt::NoButton, @@ -682,7 +765,7 @@ void QGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent* ev) */ void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -696,7 +779,7 @@ void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -710,7 +793,7 @@ void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -724,7 +807,7 @@ void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -738,7 +821,7 @@ void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) @@ -749,7 +832,7 @@ void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) */ void QGraphicsWebView::keyReleaseEvent(QKeyEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) @@ -791,10 +874,8 @@ bool QGraphicsWebView::focusNextPrevChild(bool next) void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - //if (d->page) - // d->page->event(ev); - //Just remove this line below when the code above is working - Q_UNUSED(ev); + if (d->page) + d->page->event(ev); #else Q_UNUSED(ev); #endif @@ -805,7 +886,7 @@ void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -823,7 +904,7 @@ void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -841,7 +922,7 @@ void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dropEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -872,7 +953,7 @@ void QGraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) */ void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -887,11 +968,40 @@ void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) */ void QGraphicsWebView::inputMethodEvent(QInputMethodEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) QGraphicsItem::inputMethodEvent(ev); } +/*! + \fn void QGraphicsWebView::statusBarMessage(const QString& text) + + This signal is emitted when the statusbar \a text is changed by the page. +*/ + +/*! + \fn void QGraphicsWebView::loadProgress(int progress) + + This signal is emitted every time an element in the web page + completes loading and the overall loading progress advances. + + This signal tracks the progress of all child frames. + + The current value is provided by \a progress and scales from 0 to 100, + which is the default range of QProgressBar. + + \sa loadStarted(), loadFinished() +*/ + +/*! + \fn void QGraphicsWebView::linkClicked(const QUrl &url) + + This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy + property is set to delegate the link handling for the specified \a url. + + \sa QWebPage::linkDelegationPolicy() +*/ + #include "moc_qgraphicswebview.cpp" diff --git a/WebKit/qt/Api/qgraphicswebview.h b/WebKit/qt/Api/qgraphicswebview.h index 43cf59a..f3afb4c 100644 --- a/WebKit/qt/Api/qgraphicswebview.h +++ b/WebKit/qt/Api/qgraphicswebview.h @@ -21,6 +21,7 @@ #define QGraphicsWebView_h #include "qwebkitglobal.h" +#include "qwebpage.h" #include <QtCore/qurl.h> #include <QtGui/qevent.h> #include <QtGui/qgraphicswidget.h> @@ -39,17 +40,14 @@ class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget { Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) - Q_PROPERTY(QString status READ status NOTIFY statusChanged) + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) - Q_PROPERTY(QString html READ toHtml WRITE setHtml) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactivityChanged) + Q_PROPERTY(bool modified READ isModified) public: - QGraphicsWebView(QGraphicsItem* parent = 0); + explicit QGraphicsWebView(QGraphicsItem* parent = 0); ~QGraphicsWebView(); QWebPage* page() const; @@ -64,15 +62,11 @@ public: qreal zoomFactor() const; void setZoomFactor(qreal); - bool isInteractive() const; - void setInteractive(bool); - - qreal progress() const; + bool isModified() const; void load(const QUrl &url); void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray()); - QString toHtml() const; void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); // FIXME: Consider rename to setHtml? void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); @@ -80,7 +74,10 @@ public: QWebHistory* history() const; QWebSettings* settings() const; - QString status() const; + QAction* pageAction(QWebPage::WebAction action) const; + void triggerPageAction(QWebPage::WebAction action, bool checked = false); + + bool findText(const QString& subString, QWebPage::FindFlags options = 0); virtual void setGeometry(const QRectF& rect); virtual void updateGeometry(); @@ -88,6 +85,10 @@ public: virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value); virtual bool event(QEvent*); + virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const; + + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + public Q_SLOTS: void stop(); void back(); @@ -98,13 +99,12 @@ Q_SIGNALS: void loadStarted(); void loadFinished(bool); - void progressChanged(qreal); - void interactivityChanged(); + void loadProgress(int progress); void urlChanged(const QUrl&); void titleChanged(const QString&); void iconChanged(); - void statusChanged(); - void zoomFactorChanged(); + void statusBarMessage(const QString& message); + void linkClicked(const QUrl&); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent*); @@ -133,9 +133,7 @@ protected: virtual bool sceneEvent(QEvent*); private: - Q_PRIVATE_SLOT(d, void _q_doLoadProgress(int progress)) Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) - Q_PRIVATE_SLOT(d, void _q_setStatusBarMessage(const QString& message)) QGraphicsWebViewPrivate* const d; friend class QGraphicsWebViewPrivate; diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp index 6305d10..441bec7 100644 --- a/WebKit/qt/Api/qwebelement.cpp +++ b/WebKit/qt/Api/qwebelement.cpp @@ -99,6 +99,14 @@ public: It is possible to replace the contents of child elements using setPlainText() and setInnerXml(). To replace the element itself and its contents, use setOuterXml(). + + \section1 Examples + + The \l{DOM Traversal Example} shows one way to traverse documents in a running + example. + + The \l{Simple Selector Example} can be used to experiment with the searching + features of this class and provides sample code you can start working with. */ /*! @@ -195,8 +203,7 @@ bool QWebElement::isNull() const \a selectorQuery. If there are no matching elements, an empty list is returned. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} - syntax is used for the query. + \l{Standard CSS2 selector} syntax is used for the query. \note This search is performed recursively. @@ -211,8 +218,7 @@ QWebElementCollection QWebElement::findAll(const QString &selectorQuery) const Returns the first child element that matches the given CSS selector \a selectorQuery. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} - syntax is used for the query. + \l{Standard CSS2 selector} syntax is used for the query. \note This search is performed recursively. @@ -453,6 +459,30 @@ bool QWebElement::hasAttributes() const } /*! + Return the list of attributes for the namespace given as \a namespaceUri. + + \sa attribute(), setAttribute() +*/ +QStringList QWebElement::attributeNames(const QString& namespaceUri) const +{ + if (!m_element) + return QStringList(); + + QStringList attributeNameList; + const NamedNodeMap* const attrs = m_element->attributes(/* read only = */ true); + if (attrs) { + const String namespaceUriString(namespaceUri); // convert QString -> String once + const unsigned attrsCount = attrs->length(); + for (unsigned i = 0; i < attrsCount; ++i) { + const Attribute* const attribute = attrs->attributeItem(i); + if (namespaceUriString == attribute->namespaceURI()) + attributeNameList.append(attribute->localName()); + } + } + return attributeNameList; +} + +/*! Returns true if the element has keyboard input focus; otherwise, returns false \sa setFocus() @@ -1661,22 +1691,6 @@ QList<QWebElement> QWebElementCollection::toList() const QWebElementCollection provides STL style const iterators for fast low-level access to the elements. QWebElementCollection::const_iterator allows you to iterate over a QWebElementCollection. - - The default QWebElementCollection::const_iterator constructors creates an uninitialized iterator. You must initialize - it using a QWebElementCollection function like QWebElementCollection::begin() or QWebElementCollection::end() before you - can start iterating. -*/ - -/*! - \fn QWebElementCollection::const_iterator::const_iterator() - - Constructs an uninitialized iterator. - - Functions like operator*() and operator++() should not be called on - an uninitialized iterator. Use operator=() to assign a value - to it before using it. - - \sa QWebElementCollection::begin() */ /*! @@ -1824,3 +1838,193 @@ QList<QWebElement> QWebElementCollection::toList() const Returns true if the element pointed to by this iterator is greater than or equal to the element pointed to by the \a other iterator. */ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::begin() + + Returns an STL-style iterator pointing to the first element in the collection. + + \sa end() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::end() + + Returns an STL-style iterator pointing to the imaginary element after the + last element in the list. + + \sa begin() +*/ + +/*! + \fn QWebElementCollection::const_iterator QWebElementCollection::constBegin() const + + Returns an STL-style iterator pointing to the first element in the collection. + + \sa end() +*/ + +/*! + \fn QWebElementCollection::const_iterator QWebElementCollection::constEnd() const + + Returns an STL-style iterator pointing to the imaginary element after the + last element in the list. + + \sa begin() +*/ + +/*! + \class QWebElementCollection::iterator + \since 4.6 + \brief The QWebElementCollection::iterator class provides an STL-style iterator for QWebElementCollection. + + QWebElementCollection provides STL style iterators for fast low-level access to the elements. + + QWebElementCollection::iterator allows you to iterate over a QWebElementCollection. +*/ + +/*! + \fn QWebElementCollection::iterator::iterator(const iterator &other) + + Constructs a copy of \a other. +*/ + +/*! + \fn QWebElementCollection::iterator::iterator(const QWebElementCollection *collection, int index) + \internal +*/ + +/*! + \fn const QWebElement QWebElementCollection::iterator::operator*() const + + Returns the current element. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator==(const iterator &other) const + + Returns true if \a other points to the same item as this iterator; + otherwise returns false. + + \sa operator!=() +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator!=(const iterator &other) const + + Returns true if \a other points to a different element than this; + iterator; otherwise returns false. + + \sa operator==() +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator++() + + The prefix ++ operator (\c{++it}) advances the iterator to the next element in the collection + and returns an iterator to the new current element. + + Calling this function on QWebElementCollection::end() leads to undefined results. + + \sa operator--() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator++(int) + + \overload + + The postfix ++ operator (\c{it++}) advances the iterator to the next element in the collection + and returns an iterator to the previously current element. + + Calling this function on QWebElementCollection::end() leads to undefined results. +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator--() + + The prefix -- operator (\c{--it}) makes the preceding element current and returns an + iterator to the new current element. + + Calling this function on QWebElementCollection::begin() leads to undefined results. + + \sa operator++() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator--(int) + + \overload + + The postfix -- operator (\c{it--}) makes the preceding element current and returns + an iterator to the previously current element. +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator+=(int j) + + Advances the iterator by \a j elements. If \a j is negative, the iterator goes backward. + + \sa operator-=(), operator+() +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator-=(int j) + + Makes the iterator go back by \a j elements. If \a j is negative, the iterator goes forward. + + \sa operator+=(), operator-() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator+(int j) const + + Returns an iterator to the element at \a j positions forward from this iterator. If \a j + is negative, the iterator goes backward. + + \sa operator-(), operator+=() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator-(int j) const + + Returns an iterator to the element at \a j positiosn backward from this iterator. + If \a j is negative, the iterator goes forward. + + \sa operator+(), operator-=() +*/ + +/*! + \fn int QWebElementCollection::iterator::operator-(iterator other) const + + Returns the number of elements between the item point to by \a other + and the element pointed to by this iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator<(const iterator &other) const + + Returns true if the element pointed to by this iterator is less than the element pointed to + by the \a other iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator<=(const iterator &other) const + + Returns true if the element pointed to by this iterator is less than or equal to the + element pointed to by the \a other iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator>(const iterator &other) const + + Returns true if the element pointed to by this iterator is greater than the element pointed to + by the \a other iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator>=(const iterator &other) const + + Returns true if the element pointed to by this iterator is greater than or equal to the + element pointed to by the \a other iterator. +*/ diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h index a18d262..3833070 100644 --- a/WebKit/qt/Api/qwebelement.h +++ b/WebKit/qt/Api/qwebelement.h @@ -21,6 +21,7 @@ #define QWEBELEMENT_H #include <QString> +#include <QStringList> #include <QRect> #include <QVariant> #include <QExplicitlySharedDataPointer> @@ -72,6 +73,7 @@ public: void removeAttribute(const QString& name); void removeAttributeNS(const QString& namespaceUri, const QString& name); bool hasAttributes() const; + QStringList attributeNames(const QString& namespaceUri = QString()) const; QStringList classes() const; bool hasClass(const QString& name) const; @@ -177,6 +179,7 @@ public: int count() const; QWebElement at(int i) const; + inline QWebElement operator[](int i) const { return at(i); } inline QWebElement first() const { return at(0); } inline QWebElement last() const { return at(count() - 1); } @@ -185,39 +188,69 @@ public: class const_iterator { public: - int i; - const QWebElementCollection *s; - - inline const_iterator(const QWebElementCollection *collection, int index) : i(index), s(collection) {} - inline const_iterator(const const_iterator &o) : i(o.i), s(o.s) {} + inline const_iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {} + inline const_iterator(const const_iterator& o) : i(o.i), collection(o.collection) {} - inline const QWebElement operator*() const { return s->at(i); } + inline const QWebElement operator*() const { return collection->at(i); } - inline bool operator==(const const_iterator& o) const { return i == o.i && s == o.s; } - inline bool operator!=(const const_iterator& o) const { return i != o.i || s != o.s; } + inline bool operator==(const const_iterator& o) const { return i == o.i && collection == o.collection; } + inline bool operator!=(const const_iterator& o) const { return i != o.i || collection != o.collection; } inline bool operator<(const const_iterator& o) const { return i < o.i; } inline bool operator<=(const const_iterator& o) const { return i <= o.i; } inline bool operator>(const const_iterator& o) const { return i > o.i; } inline bool operator>=(const const_iterator& o) const { return i >= o.i; } - inline const_iterator &operator++() { ++i; return *this; } - inline const_iterator operator++(int) { const_iterator n(s, i); ++i; return n; } - inline const_iterator &operator--() { i--; return *this; } - inline const_iterator operator--(int) { const_iterator n(s, i); i--; return n; } - inline const_iterator &operator+=(int j) { i += j; return *this; } - inline const_iterator &operator-=(int j) { i -= j; return *this; } - inline const_iterator operator+(int j) const { return const_iterator(s, i + j); } - inline const_iterator operator-(int j) const { return const_iterator(s, i - j); } + inline const_iterator& operator++() { ++i; return *this; } + inline const_iterator operator++(int) { const_iterator n(collection, i); ++i; return n; } + inline const_iterator& operator--() { i--; return *this; } + inline const_iterator operator--(int) { const_iterator n(collection, i); i--; return n; } + inline const_iterator& operator+=(int j) { i += j; return *this; } + inline const_iterator& operator-=(int j) { i -= j; return *this; } + inline const_iterator operator+(int j) const { return const_iterator(collection, i + j); } + inline const_iterator operator-(int j) const { return const_iterator(collection, i - j); } inline int operator-(const_iterator j) const { return i - j.i; } private: - inline const_iterator() : i(0), s(0) {} + int i; + const QWebElementCollection* const collection; }; friend class const_iterator; - inline const_iterator begin() const { return const_iterator(this, 0); } - inline const_iterator end() const { return const_iterator(this, count()); } - inline QWebElement operator[](int i) const { return at(i); } + inline const_iterator begin() const { return constBegin(); } + inline const_iterator end() const { return constEnd(); } + inline const_iterator constBegin() const { return const_iterator(this, 0); } + inline const_iterator constEnd() const { return const_iterator(this, count()); }; + + class iterator { + public: + inline iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {} + inline iterator(const iterator& o) : i(o.i), collection(o.collection) {} + + inline QWebElement operator*() const { return collection->at(i); } + + inline bool operator==(const iterator& o) const { return i == o.i && collection == o.collection; } + inline bool operator!=(const iterator& o) const { return i != o.i || collection != o.collection; } + inline bool operator<(const iterator& o) const { return i < o.i; } + inline bool operator<=(const iterator& o) const { return i <= o.i; } + inline bool operator>(const iterator& o) const { return i > o.i; } + inline bool operator>=(const iterator& o) const { return i >= o.i; } + + inline iterator& operator++() { ++i; return *this; } + inline iterator operator++(int) { iterator n(collection, i); ++i; return n; } + inline iterator& operator--() { i--; return *this; } + inline iterator operator--(int) { iterator n(collection, i); i--; return n; } + inline iterator& operator+=(int j) { i += j; return *this; } + inline iterator& operator-=(int j) { i -= j; return *this; } + inline iterator operator+(int j) const { return iterator(collection, i + j); } + inline iterator operator-(int j) const { return iterator(collection, i - j); } + inline int operator-(iterator j) const { return i - j.i; } + private: + int i; + const QWebElementCollection* const collection; + }; + friend class iterator; + inline iterator begin() { return iterator(this, 0); } + inline iterator end() { return iterator(this, count()); } private: QExplicitlySharedDataPointer<QWebElementCollectionPrivate> d; }; diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 606dae4..ef97c3b 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -56,6 +56,7 @@ #include "Scrollbar.h" #include "SelectionController.h" #include "SubstituteData.h" +#include "SVGSMILElement.h" #include "htmlediting.h" #include "markup.h" #include "qt_instance.h" @@ -77,14 +78,7 @@ #include <qpainter.h> #include <qprinter.h> #include <qregion.h> - -#if QT_VERSION < 0x040400 -#include "qwebnetworkinterface.h" -#endif - -#if QT_VERSION >= 0x040400 #include <qnetworkrequest.h> -#endif using namespace WebCore; @@ -93,6 +87,11 @@ QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT int qt_defaultDpi(); QT_END_NAMESPACE +bool QWEBKIT_EXPORT qt_drt_hasDocumentElement(QWebFrame* qframe) +{ + return QWebFramePrivate::core(qframe)->document()->documentElement(); +} + void QWEBKIT_EXPORT qt_drt_setJavaScriptProfilingEnabled(QWebFrame* qframe, bool enabled) { #if ENABLE(JAVASCRIPT_DEBUGGER) @@ -150,6 +149,31 @@ bool QWEBKIT_EXPORT qt_drt_pauseTransitionOfProperty(QWebFrame *qframe, const QS return controller->pauseTransitionAtTime(coreNode->renderer(), propertyName, time); } +// Pause a given SVG animation on the target node at a specific time. +// This method is only intended to be used for testing the SVG animation system. +bool QWEBKIT_EXPORT qt_drt_pauseSVGAnimation(QWebFrame *qframe, const QString &animationId, double time, const QString &elementId) +{ +#if !ENABLE(SVG) + return false; +#else + Frame* frame = QWebFramePrivate::core(qframe); + if (!frame) + return false; + + Document* doc = frame->document(); + Q_ASSERT(doc); + + if (!doc->svgExtensions()) + return false; + + Node* coreNode = doc->getElementById(animationId); + if (!coreNode || !SVGSMILElement::isSMILElement(coreNode)) + return false; + + return doc->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreNode), time); +#endif +} + // Returns the total number of currently running animations (includes both CSS transitions and CSS animations). int QWEBKIT_EXPORT qt_drt_numberOfActiveAnimations(QWebFrame *qframe) { @@ -243,7 +267,7 @@ WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const return frame->view()->verticalScrollbar(); } -void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer layer, const QRegion &clip) +void QWebFramePrivate::renderContentsLayerAbsoluteCoords(GraphicsContext* context, const QRegion& clip) { if (!frame->view() || !frame->contentRenderer()) return; @@ -252,15 +276,42 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l if (vector.isEmpty()) return; - GraphicsContext context(painter); - if (context.paintingDisabled() && !context.updatingControlTints()) + QPainter* painter = context->platformContext(); + + WebCore::FrameView* view = frame->view(); + view->layoutIfNeededRecursive(); + + for (int i = 0; i < vector.size(); ++i) { + const QRect& clipRect = vector.at(i); + + painter->save(); + painter->setClipRect(clipRect, Qt::IntersectClip); + + context->save(); + view->paintContents(context, clipRect); + context->restore(); + + painter->restore(); + } +} + +void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame::RenderLayer layer, const QRegion& clip) +{ + if (!frame->view() || !frame->contentRenderer()) return; + QVector<QRect> vector = clip.rects(); + if (vector.isEmpty()) + return; + + QPainter* painter = context->platformContext(); + WebCore::FrameView* view = frame->view(); view->layoutIfNeededRecursive(); for (int i = 0; i < vector.size(); ++i) { const QRect& clipRect = vector.at(i); + QRect intersectedRect = clipRect.intersected(view->frameRect()); painter->save(); @@ -270,39 +321,41 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l int y = view->y(); if (layer & QWebFrame::ContentsLayer) { - context.save(); + context->save(); int scrollX = view->scrollX(); int scrollY = view->scrollY(); QRect rect = intersectedRect; - context.translate(x, y); + context->translate(x, y); rect.translate(-x, -y); - context.translate(-scrollX, -scrollY); + context->translate(-scrollX, -scrollY); rect.translate(scrollX, scrollY); - context.clip(view->visibleContentRect()); + context->clip(view->visibleContentRect()); - view->paintContents(&context, rect); + view->paintContents(context, rect); - context.restore(); + context->restore(); } if (layer & QWebFrame::ScrollBarLayer && !view->scrollbarsSuppressed() && (view->horizontalScrollbar() || view->verticalScrollbar())) { - context.save(); + context->save(); QRect rect = intersectedRect; - context.translate(x, y); + context->translate(x, y); rect.translate(-x, -y); - view->paintScrollbars(&context, rect); + view->paintScrollbars(context, rect); - context.restore(); + context->restore(); } +#if ENABLE(PAN_SCROLLING) if (layer & QWebFrame::PanIconLayer) - view->paintPanScrollIcon(&context); + view->paintPanScrollIcon(context); +#endif painter->restore(); } @@ -324,7 +377,7 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l the HTML content readily available, you can use setHtml() instead. The page() function returns a pointer to the web page object. See - \l{Elements of QWebView} for an explanation of how web + \l{QWebView}{Elements of QWebView} for an explanation of how web frames are related to a web page and web view. The QWebFrame class also offers methods to retrieve both the URL currently @@ -356,6 +409,19 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l \sa QWebPage */ +/*! + \enum QWebFrame::RenderLayer + + This enum describes the layers available for rendering using \l{QWebFrame::}{render()}. + The layers can be OR-ed together from the following list: + + \value ContentsLayer The web content of the frame + \value ScrollBarLayer The scrollbars of the frame + \value PanIconLayer The icon used when panning the frame + + \value AllLayers Includes all the above layers +*/ + QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData) : QObject(parent) , d(new QWebFramePrivate) @@ -471,7 +537,9 @@ QString QWebFrame::toPlainText() const d->frame->view()->layout(); Element *documentElement = d->frame->document()->documentElement(); - return documentElement->innerText(); + if (documentElement) + return documentElement->innerText(); + return QString(); } /*! @@ -483,7 +551,7 @@ QString QWebFrame::renderTreeDump() const if (d->frame->view() && d->frame->view()->layoutPending()) d->frame->view()->layout(); - return externalRepresentation(d->frame->contentRenderer()); + return externalRepresentation(d->frame); } /*! @@ -655,51 +723,9 @@ QWebPage *QWebFrame::page() const */ void QWebFrame::load(const QUrl &url) { -#if QT_VERSION < 0x040400 - load(QWebNetworkRequest(ensureAbsoluteUrl(url))); -#else load(QNetworkRequest(ensureAbsoluteUrl(url))); -#endif -} - -#if QT_VERSION < 0x040400 -/*! - Loads a network request, \a req, into this frame. - - \note The view remains the same until enough data has arrived to display the new url. -*/ -void QWebFrame::load(const QWebNetworkRequest &req) -{ - if (d->parentFrame()) - d->page->d->insideOpenCall = true; - - QUrl url = ensureAbsoluteUrl(req.url()); - QHttpRequestHeader httpHeader = req.httpHeader(); - QByteArray postData = req.postData(); - - WebCore::ResourceRequest request(url); - - QString method = httpHeader.method(); - if (!method.isEmpty()) - request.setHTTPMethod(method); - - QList<QPair<QString, QString> > values = httpHeader.values(); - for (int i = 0; i < values.size(); ++i) { - const QPair<QString, QString> &val = values.at(i); - request.addHTTPHeaderField(val.first, val.second); - } - - if (!postData.isEmpty()) - request.setHTTPBody(WebCore::FormData::create(postData.constData(), postData.size())); - - d->frame->loader()->load(request, false); - - if (d->parentFrame()) - d->page->d->insideOpenCall = false; } -#else - /*! Loads a network request, \a req, into this frame, using the method specified in \a operation. @@ -734,6 +760,11 @@ void QWebFrame::load(const QNetworkRequest &req, case QNetworkAccessManager::PostOperation: request.setHTTPMethod("POST"); break; +#if QT_VERSION >= 0x040600 + case QNetworkAccessManager::DeleteOperation: + request.setHTTPMethod("DELETE"); + break; +#endif case QNetworkAccessManager::UnknownOperation: // eh? break; @@ -753,7 +784,6 @@ void QWebFrame::load(const QNetworkRequest &req, if (d->parentFrame()) d->page->d->insideOpenCall = false; } -#endif /*! Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative @@ -862,11 +892,13 @@ void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPol d->horizontalScrollBarPolicy = policy; if (d->frame->view()) { d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->updateCanHaveScrollbars(); } } else { d->verticalScrollBarPolicy = policy; if (d->frame->view()) { d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->updateCanHaveScrollbars(); } } } @@ -999,29 +1031,41 @@ void QWebFrame::setScrollPosition(const QPoint &pos) void QWebFrame::render(QPainter* painter, RenderLayer layer, const QRegion& clip) { + GraphicsContext context(painter); + if (context.paintingDisabled() && !context.updatingControlTints()) + return; + if (!clip.isEmpty()) - d->renderPrivate(painter, layer, clip); + d->renderRelativeCoords(&context, layer, clip); else if (d->frame->view()) - d->renderPrivate(painter, layer, QRegion(d->frame->view()->frameRect())); + d->renderRelativeCoords(&context, layer, QRegion(d->frame->view()->frameRect())); } /*! Render the frame into \a painter clipping to \a clip. */ -void QWebFrame::render(QPainter *painter, const QRegion &clip) +void QWebFrame::render(QPainter* painter, const QRegion& clip) { - d->renderPrivate(painter, AllLayers, clip); + GraphicsContext context(painter); + if (context.paintingDisabled() && !context.updatingControlTints()) + return; + + d->renderRelativeCoords(&context, AllLayers, clip); } /*! Render the frame into \a painter. */ -void QWebFrame::render(QPainter *painter) +void QWebFrame::render(QPainter* painter) { if (!d->frame->view()) return; - d->renderPrivate(painter, AllLayers, QRegion(d->frame->view()->frameRect())); + GraphicsContext context(painter); + if (context.paintingDisabled() && !context.updatingControlTints()) + return; + + d->renderRelativeCoords(&context, AllLayers, QRegion(d->frame->view()->frameRect())); } /*! diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h index 08285f8..c2a6e9b 100644 --- a/WebKit/qt/Api/qwebframe.h +++ b/WebKit/qt/Api/qwebframe.h @@ -26,9 +26,7 @@ #include <QtCore/qvariant.h> #include <QtGui/qicon.h> #include <QtScript/qscriptengine.h> -#if QT_VERSION >= 0x040400 #include <QtNetwork/qnetworkaccessmanager.h> -#endif #include "qwebkitglobal.h" QT_BEGIN_NAMESPACE @@ -123,13 +121,9 @@ public: QWebPage *page() const; void load(const QUrl &url); -#if QT_VERSION < 0x040400 - void load(const QWebNetworkRequest &request); -#else void load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray()); -#endif void setHtml(const QString &html, const QUrl &baseUrl = QUrl()); void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index 081e65d..045c70e 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -25,6 +25,7 @@ #include "qwebpage_p.h" #include "EventHandler.h" +#include "GraphicsContext.h" #include "KURL.h" #include "PlatformString.h" #include "qwebelement.h" @@ -81,7 +82,8 @@ public: static WebCore::Frame* core(QWebFrame*); static QWebFrame* kit(WebCore::Frame*); - void renderPrivate(QPainter*, QWebFrame::RenderLayer, const QRegion& clip); + void renderRelativeCoords(WebCore::GraphicsContext*, QWebFrame::RenderLayer, const QRegion& clip); + void renderContentsLayerAbsoluteCoords(WebCore::GraphicsContext*, const QRegion& clip); QWebFrame *q; Qt::ScrollBarPolicy horizontalScrollBarPolicy; diff --git a/WebKit/qt/Api/qwebhistory.cpp b/WebKit/qt/Api/qwebhistory.cpp index f765daa..d852012 100644 --- a/WebKit/qt/Api/qwebhistory.cpp +++ b/WebKit/qt/Api/qwebhistory.cpp @@ -494,22 +494,16 @@ QDataStream& operator<<(QDataStream& target, const QWebHistory& history) { QWebHistoryPrivate* d = history.d; - QByteArray buffer; - QDataStream stream(&buffer, QIODevice::WriteOnly); - int version = DefaultHistoryVersion; - stream << version; - stream << history.count() << history.currentItemIndex(); + target << version; + target << history.count() << history.currentItemIndex(); const WebCore::HistoryItemVector &items = d->lst->entries(); for (unsigned i = 0; i < items.size(); i++) - items[i].get()->saveState(stream, version); - - if (stream.status() != QDataStream::Ok) - buffer = QByteArray(); // make buffer isNull()==true and isEmpty()==true + items[i].get()->saveState(target, version); - return target << buffer; + return target; } /*! @@ -526,18 +520,14 @@ QDataStream& operator>>(QDataStream& source, QWebHistory& history) { QWebHistoryPrivate* d = history.d; - QByteArray buffer; - source >> buffer; - - QDataStream stream(buffer); int version; - stream >> version; + source >> version; if (version == 1) { int count; int currentIndex; - stream >> count >> currentIndex; + source >> count >> currentIndex; history.clear(); // only if there are elements @@ -546,7 +536,7 @@ QDataStream& operator>>(QDataStream& source, QWebHistory& history) WebCore::HistoryItem* nullItem = d->lst->currentItem(); for (int i = 0; i < count; i++) { WTF::PassRefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(); - item->restoreState(stream, version); + item->restoreState(source, version); d->lst->addItem(item); } d->lst->removeItem(nullItem); diff --git a/WebKit/qt/Api/qwebinspector.cpp b/WebKit/qt/Api/qwebinspector.cpp index 4578dc9..f43cbbf 100644 --- a/WebKit/qt/Api/qwebinspector.cpp +++ b/WebKit/qt/Api/qwebinspector.cpp @@ -50,6 +50,7 @@ \section1 Resources + This class acts mostly as a container and a controller for the inspector. Most of the resources needed by the inspector are owned by the associated QWebPage and are allocated the first time that: \list @@ -57,11 +58,6 @@ \o the QWebInspector is shown. \endlist - This class acts mostly as a container and a controller for the inspector. - You can defer the creation and association of the QWebInspector until - the first emission of QWebPage::webInspectorTriggered() to save additional - resources. - \section1 Inspector configuration persistence The inspector allows the user to configure some options through its @@ -188,9 +184,3 @@ void QWebInspectorPrivate::adjustFrontendSize(const QSize& size) frontend->resize(size); } -/*! - \fn void QWebInspector::windowTitleChanged(const QString& newTitle); - - This is emitted to signal that this widget's title changed to \a newTitle. -*/ - diff --git a/WebKit/qt/Api/qwebinspector.h b/WebKit/qt/Api/qwebinspector.h index bb5bd64..a5c1ed5 100644 --- a/WebKit/qt/Api/qwebinspector.h +++ b/WebKit/qt/Api/qwebinspector.h @@ -39,9 +39,6 @@ public: QSize sizeHint() const; bool event(QEvent*); -Q_SIGNALS: - void windowTitleChanged(const QString& newTitle); - protected: void resizeEvent(QResizeEvent* event); void showEvent(QShowEvent* event); diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h index 0885bdc..9e8979f 100644 --- a/WebKit/qt/Api/qwebkitglobal.h +++ b/WebKit/qt/Api/qwebkitglobal.h @@ -40,15 +40,4 @@ # endif #endif -#if QT_VERSION < 0x040400 - #ifndef QT_BEGIN_NAMESPACE - #define QT_BEGIN_NAMESPACE - #endif - - #ifndef QT_END_NAMESPACE - #define QT_END_NAMESPACE - #endif -#endif - - #endif // QWEBKITGLOBAL_H diff --git a/WebKit/qt/Api/qwebnetworkinterface.cpp b/WebKit/qt/Api/qwebnetworkinterface.cpp deleted file mode 100644 index cf99183..0000000 --- a/WebKit/qt/Api/qwebnetworkinterface.cpp +++ /dev/null @@ -1,1315 +0,0 @@ -/* - Copyright (C) 2006 Enrico Ros <enrico.ros@m31engineering.it> - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include <qglobal.h> -#if QT_VERSION < 0x040400 -#include "qwebframe.h" -#include "qwebnetworkinterface.h" -#include "qwebnetworkinterface_p.h" -#include "qwebpage.h" -#include "qcookiejar.h" -#include <qdebug.h> -#include <qfile.h> -#include <qnetworkproxy.h> -#include <qurl.h> -#include <QAuthenticator> -#include <QCoreApplication> -#include <QSslError> - -#include "ResourceHandle.h" -#include "ResourceHandleClient.h" -#include "ResourceHandleInternal.h" -#include "MIMETypeRegistry.h" -#include "CookieJar.h" - -#if 0 -#define DEBUG qDebug -#else -#define DEBUG if (1) {} else qDebug -#endif - -static QWebNetworkInterface *s_default_interface = 0; -static QWebNetworkManager *s_manager = 0; - -using namespace WebCore; - -uint qHash(const HostInfo &info) -{ - return qHash(info.host) + info.port; -} - -static bool operator==(const HostInfo &i1, const HostInfo &i2) -{ - return i1.port == i2.port && i1.host == i2.host; -} - -enum ParserState { - State_Begin, - State_FirstChar, - State_SecondChar -}; - -/* - * Decode URLs without doing any charset conversion. - * - * Most simple approach to do it without any lookahead. - */ -static QByteArray decodePercentEncoding(const QByteArray& input) -{ - int actualLength = 0; - QByteArray tmpVal; - QByteArray output; - ParserState state = State_Begin; - - output.resize(input.length()); - tmpVal.resize(2); - - for (int i = 0; i < input.length(); ++i) - if (state == State_Begin) { - if (input.at(i) == '%') - state = State_FirstChar; - else - output[actualLength++] = input[i]; - } else if (state == State_FirstChar) { - state = State_SecondChar; - tmpVal[0] = input[i]; - } else if (state == State_SecondChar) { - state = State_Begin; - tmpVal[1] = input[i]; - output[actualLength++] = tmpVal.toShort(0, 16); - } - - output.resize(actualLength); - return output; -} - -void QWebNetworkRequestPrivate::init(const WebCore::ResourceRequest &resourceRequest) -{ - KURL url = resourceRequest.url(); - QUrl qurl = QString(url.string()); - init(resourceRequest.httpMethod(), qurl, &resourceRequest); -} - -void QWebNetworkRequestPrivate::init(const QString& method, const QUrl& url, const WebCore::ResourceRequest* resourceRequest) -{ - httpHeader = QHttpRequestHeader(method, url.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority)); - httpHeader.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive")); - setURL(url); - - if (resourceRequest) { - httpHeader.setValue(QLatin1String("User-Agent"), resourceRequest->httpUserAgent()); - const QString scheme = url.scheme().toLower(); - if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) { - QString cookies = QCookieJar::cookieJar()->cookies(resourceRequest->url()); - if (!cookies.isEmpty()) - httpHeader.setValue(QLatin1String("Cookie"), cookies); - } - - - const HTTPHeaderMap& loaderHeaders = resourceRequest->httpHeaderFields(); - HTTPHeaderMap::const_iterator end = loaderHeaders.end(); - for (HTTPHeaderMap::const_iterator it = loaderHeaders.begin(); it != end; ++it) - httpHeader.setValue(it->first, it->second); - - // handle and perform a 'POST' request - if (method == "POST") { - Vector<char> data; - resourceRequest->httpBody()->flatten(data); - postData = QByteArray(data.data(), data.size()); - httpHeader.setValue(QLatin1String("content-length"), QString::number(postData.size())); - } - } -} - -void QWebNetworkRequestPrivate::setURL(const QUrl& u) -{ - url = u; - int port = url.port(); - const QString scheme = u.scheme(); - if (port > 0 && (port != 80 || scheme != "http") && (port != 443 || scheme != "https")) - httpHeader.setValue(QLatin1String("Host"), url.host() + QLatin1Char(':') + QString::number(port)); - else - httpHeader.setValue(QLatin1String("Host"), url.host()); -} - -/*! - \class QWebNetworkRequest - \internal - - The QWebNetworkRequest class represents a request for data from the network with all the - necessary information needed for retrieval. This includes the url, extra HTTP header fields - as well as data for a HTTP POST request. -*/ - -QWebNetworkRequest::QWebNetworkRequest() - : d(new QWebNetworkRequestPrivate) -{ -} - -QWebNetworkRequest::QWebNetworkRequest(const QUrl& url, Method method, const QByteArray& postData) - : d(new QWebNetworkRequestPrivate) -{ - d->init(method == Get ? "GET" : "POST", url); - d->postData = postData; -} - -QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequest &other) - : d(new QWebNetworkRequestPrivate(*other.d)) -{ -} - -QWebNetworkRequest &QWebNetworkRequest::operator=(const QWebNetworkRequest& other) -{ - *d = *other.d; - return *this; -} - -/*! - \internal -*/ -QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequestPrivate& priv) - : d(new QWebNetworkRequestPrivate(priv)) -{ -} - -/*! - \internal -*/ -QWebNetworkRequest::QWebNetworkRequest(const WebCore::ResourceRequest& request) - : d(new QWebNetworkRequestPrivate) -{ - d->init(request); -} - -QWebNetworkRequest::~QWebNetworkRequest() -{ - delete d; -} - -/*! - \internal - The requested URL -*/ -QUrl QWebNetworkRequest::url() const -{ - return d->url; -} - -/*! - \internal - Sets the URL to request. - - Note that setting the URL also sets the "Host" field in the HTTP header. -*/ -void QWebNetworkRequest::setUrl(const QUrl& url) -{ - d->setURL(url); -} - -/*! - \internal - The http request header information. -*/ -QHttpRequestHeader QWebNetworkRequest::httpHeader() const -{ - return d->httpHeader; -} - -void QWebNetworkRequest::setHttpHeader(const QHttpRequestHeader& header) const -{ - d->httpHeader = header; -} - -QString QWebNetworkRequest::httpHeaderField(const QString& key) const -{ - return d->httpHeader.value(key); -} - -void QWebNetworkRequest::setHttpHeaderField(const QString& key, const QString& value) -{ - d->httpHeader.setValue(key, value); -} - -/*! - \internal - Post data sent with HTTP POST requests. -*/ -QByteArray QWebNetworkRequest::postData() const -{ - return d->postData; -} - -void QWebNetworkRequest::setPostData(const QByteArray& data) -{ - d->postData = data; -} - -/*! - \class QWebNetworkJob - \internal - - The QWebNetworkJob class represents a network job, that needs to be - processed by the QWebNetworkInterface. - - This class is only required when implementing a new network layer (or - support for a special protocol) using QWebNetworkInterface. - - QWebNetworkJob objects are created and owned by the QtWebKit library. - Most of it's properties are read-only. - - The job is reference counted. This can be used to ensure that the job doesn't - get deleted while it's still stored in some data structure. -*/ - -/*! - \internal -*/ -QWebNetworkJob::QWebNetworkJob() - : d(new QWebNetworkJobPrivate) -{ -} - -/*! - \internal -*/ -QWebNetworkJob::~QWebNetworkJob() -{ - delete d; - d = 0; -} - -/*! - \internal - The requested URL -*/ -QUrl QWebNetworkJob::url() const -{ - return d->request.url; -} - -/*! - \internal - Post data associated with the job -*/ -QByteArray QWebNetworkJob::postData() const -{ - return d->request.postData; -} - -/*! - \internal - The HTTP request header that should be used to download the job. -*/ -QHttpRequestHeader QWebNetworkJob::httpHeader() const -{ - return d->request.httpHeader; -} - -/*! - \internal - The complete network request that should be used to download the job. -*/ -QWebNetworkRequest QWebNetworkJob::request() const -{ - return QWebNetworkRequest(d->request); -} - -/*! - \internal - The HTTP response header received from the network. -*/ -QHttpResponseHeader QWebNetworkJob::response() const -{ - return d->response; -} - -/*! - \internal - The last error of the Job. -*/ -QString QWebNetworkJob::errorString() const -{ - return d->errorString; -} - -/*! - \internal - Sets the HTTP reponse header. The response header has to be called before - emitting QWebNetworkInterface::started. -*/ -void QWebNetworkJob::setResponse(const QHttpResponseHeader& response) -{ - d->response = response; -} - -void QWebNetworkJob::setErrorString(const QString& errorString) -{ - d->errorString = errorString; -} - -/*! - \internal - returns true if the job has been cancelled by the WebKit framework -*/ -bool QWebNetworkJob::cancelled() const -{ - return !d->resourceHandle; -} - -/*! - \internal - reference the job. -*/ -void QWebNetworkJob::ref() -{ - ++d->ref; -} - -/*! - \internal - derefence the job. - - If the reference count drops to 0 this method also deletes the job. - - Returns false if the reference count has dropped to 0. -*/ -bool QWebNetworkJob::deref() -{ - if (!--d->ref) { - delete this; - return false; - } - return true; -} - -/*! - \internal - Returns the network interface that is associated with this job. -*/ -QWebNetworkInterface *QWebNetworkJob::networkInterface() const -{ - return d->interface; -} - -/*! - \internal - Returns the network interface that is associated with this job. -*/ -QWebFrame *QWebNetworkJob::frame() const -{ - if (!d->resourceHandle) { - ResourceHandleInternal *rhi = d->resourceHandle->getInternal(); - if (rhi) - return rhi->m_frame; - } - return 0; -} - -QWebNetworkJob::JobStatus QWebNetworkJob::status() const -{ - return d->jobStatus; -} - -void QWebNetworkJob::setStatus(const JobStatus& status) -{ - d->jobStatus = status; -} - -/*! - \class QWebNetworkManager - \internal -*/ -QWebNetworkManager::QWebNetworkManager() - : QObject(0) - , m_scheduledWork(false) -{ - connect(this, SIGNAL(scheduleWork()), SLOT(doWork()), Qt::QueuedConnection); -} - -QWebNetworkManager *QWebNetworkManager::self() -{ - // ensure everything's constructed and connected - QWebNetworkInterface::defaultInterface(); - - return s_manager; -} - -bool QWebNetworkManager::add(ResourceHandle* handle, QWebNetworkInterface* interface, JobMode jobMode) -{ - if (!interface) - interface = s_default_interface; - - ASSERT(interface); - - QWebNetworkJob *job = new QWebNetworkJob(); - handle->getInternal()->m_job = job; - job->d->resourceHandle = handle; - job->d->interface = interface; - - job->d->request.init(handle->request()); - - const QString method = handle->getInternal()->m_request.httpMethod(); - if (method != "POST" && method != "GET" && method != "HEAD") { - qWarning("REQUEST: [%s]\n", qPrintable(job->d->request.httpHeader.toString())); - return false; - } - - DEBUG() << "QWebNetworkManager::add:" << job->d->request.httpHeader.toString(); - - if (jobMode == SynchronousJob) { - Q_ASSERT(!m_synchronousJobs.contains(job)); - m_synchronousJobs[job] = 1; - } - - interface->addJob(job); - - return true; -} - -void QWebNetworkManager::cancel(ResourceHandle* handle) -{ - QWebNetworkJob *job = handle->getInternal()->m_job; - if (!job) - return; - DEBUG() << "QWebNetworkManager::cancel:" << job->d->request.httpHeader.toString(); - job->d->resourceHandle = 0; - job->d->interface->cancelJob(job); - handle->getInternal()->m_job = 0; -} - -/*! - \internal -*/ -void QWebNetworkManager::started(QWebNetworkJob* job) -{ - Q_ASSERT(job->d); - Q_ASSERT(job->status() == QWebNetworkJob::JobCreated || - job->status() == QWebNetworkJob::JobRecreated); - - job->setStatus(QWebNetworkJob::JobStarted); - ResourceHandleClient* client = 0; - - if (!job->d->resourceHandle) - return; - - client = job->d->resourceHandle->client(); - if (!client) - return; - - DEBUG() << "ResourceHandleManager::receivedResponse:"; - DEBUG() << job->d->response.toString(); - - QStringList cookies = job->d->response.allValues("Set-Cookie"); - KURL url(job->url()); - - foreach (QString c, cookies) - QCookieJar::cookieJar()->setCookies(url, url, c); - - QString contentType = job->d->response.value("Content-Type"); - QString encoding; - int idx = contentType.indexOf(QLatin1Char(';')); - if (idx > 0) { - QString remainder = contentType.mid(idx + 1).toLower(); - contentType = contentType.left(idx).trimmed(); - - idx = remainder.indexOf("charset"); - if (idx >= 0) { - idx = remainder.indexOf(QLatin1Char('='), idx); - if (idx >= 0) - encoding = remainder.mid(idx + 1).trimmed(); - } - } - if (contentType.isEmpty()) { - // let's try to guess from the extension - QString extension = job->d->request.url.path(); - int index = extension.lastIndexOf(QLatin1Char('.')); - if (index > 0) { - extension = extension.mid(index + 1); - contentType = MIMETypeRegistry::getMIMETypeForExtension(extension); - } - } -// qDebug() << "Content-Type=" << contentType; -// qDebug() << "Encoding=" << encoding; - - - ResourceResponse response(url, contentType, - 0 /* FIXME */, - encoding, - String() /* FIXME */); - - int statusCode = job->d->response.statusCode(); - if (job->url().scheme() != QLatin1String("file")) - response.setHTTPStatusCode(statusCode); - else if (statusCode == 404) - response.setHTTPStatusCode(statusCode); - - /* Fill in the other fields */ - - if (statusCode >= 300 && statusCode < 400) { - // we're on a redirect page! if the 'Location:' field is valid, we redirect - QString location = job->d->response.value("location"); - DEBUG() << "Redirection"; - if (!location.isEmpty()) { - QUrl newUrl = job->d->request.url.resolved(location); - if (job->d->resourceHandle) { - ResourceRequest newRequest = job->d->resourceHandle->request(); - newRequest.setURL(KURL(newUrl)); - if (client) - client->willSendRequest(job->d->resourceHandle, newRequest, response); - } - - QString method; - if (statusCode == 302 || statusCode == 303) { - // this is standard-correct for 303 and practically-correct (no standard-correct) for 302 - // also, it's required for Yahoo's login process for flickr.com which responds to a POST - // with a 302 which must be GET'ed - method = "GET"; - job->d->request.httpHeader.setContentLength(0); - } else - method = job->d->request.httpHeader.method(); - - job->d->request.httpHeader.setRequest(method, - newUrl.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority)); - job->d->request.setURL(newUrl); - job->d->redirected = true; - return; - } - } - - if (client) - client->didReceiveResponse(job->d->resourceHandle, response); - -} - -void QWebNetworkManager::data(QWebNetworkJob* job, const QByteArray& data) -{ - Q_ASSERT(job->status() == QWebNetworkJob::JobStarted || - job->status() == QWebNetworkJob::JobReceivingData); - - job->setStatus(QWebNetworkJob::JobReceivingData); - ResourceHandleClient* client = 0; - - if (!job->d->resourceHandle) - return; - - client = job->d->resourceHandle->client(); - if (!client) - return; - - if (job->d->redirected) - return; // don't emit the "Document has moved here" type of HTML - - DEBUG() << "receivedData" << job->d->request.url.path(); - client->didReceiveData(job->d->resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/); -} - -void QWebNetworkManager::finished(QWebNetworkJob* job, int errorCode) -{ - Q_ASSERT(errorCode == 1 || - job->status() == QWebNetworkJob::JobStarted || - job->status() == QWebNetworkJob::JobReceivingData); - - if (m_synchronousJobs.contains(job)) - m_synchronousJobs.remove(job); - - job->setStatus(QWebNetworkJob::JobFinished); - ResourceHandleClient* client = 0; - if (job->d->resourceHandle) { - client = job->d->resourceHandle->client(); - if (!client) - return; - } else { - job->deref(); - return; - } - - DEBUG() << "receivedFinished" << errorCode << job->url(); - - if (job->d->redirected) { - job->d->redirected = false; - job->setStatus(QWebNetworkJob::JobRecreated); - job->d->interface->addJob(job); - return; - } - - if (job->d->resourceHandle) - job->d->resourceHandle->getInternal()->m_job = 0; - - if (client) { - if (errorCode) { - //FIXME: error setting error was removed from ResourceHandle - client->didFail(job->d->resourceHandle, - ResourceError(job->d->request.url.host(), job->d->response.statusCode(), - job->d->request.url.toString(), job->d->errorString)); - } else - client->didFinishLoading(job->d->resourceHandle); - } - - DEBUG() << "receivedFinished done" << job->d->request.url; - - job->deref(); -} - -void QWebNetworkManager::addHttpJob(QWebNetworkJob* job) -{ - HostInfo hostInfo(job->url()); - WebCoreHttp *httpConnection = m_hostMapping.value(hostInfo); - if (!httpConnection) { - // #### fix custom ports - DEBUG() << " new connection to" << hostInfo.host << hostInfo.port; - httpConnection = new WebCoreHttp(this, hostInfo); - QObject::connect(httpConnection, SIGNAL(connectionClosed(const WebCore::HostInfo&)), - this, SLOT(httpConnectionClosed(const WebCore::HostInfo&))); - - m_hostMapping[hostInfo] = httpConnection; - } - httpConnection->request(job); -} - -void QWebNetworkManager::cancelHttpJob(QWebNetworkJob* job) -{ - WebCoreHttp *httpConnection = m_hostMapping.value(job->url()); - if (httpConnection) - httpConnection->cancel(job); -} - -void QWebNetworkManager::httpConnectionClosed(const WebCore::HostInfo& info) -{ - WebCoreHttp *connection = m_hostMapping.take(info); - connection->deleteLater(); -} - -void QWebNetworkInterfacePrivate::sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray& data) -{ - int error = statusCode >= 400 ? 1 : 0; - if (!job->cancelled()) { - QHttpResponseHeader response; - response.setStatusLine(statusCode); - response.setContentLength(data.length()); - job->setResponse(response); - q->started(job); - if (!data.isEmpty()) - q->data(job, data); - } - q->finished(job, error); -} - -void QWebNetworkInterfacePrivate::parseDataUrl(QWebNetworkJob* job) -{ - QByteArray data = job->url().toString().toLatin1(); - //qDebug() << "handling data url:" << data; - - ASSERT(data.startsWith("data:")); - - // Here's the syntax of data URLs: - // dataurl := "data:" [ mediatype ] [ ";base64" ] "," data - // mediatype := [ type "/" subtype ] *( ";" parameter ) - // data := *urlchar - // parameter := attribute "=" value - QByteArray header; - bool base64 = false; - - int index = data.indexOf(','); - if (index != -1) { - header = data.mid(5, index - 5).toLower(); - //qDebug() << "header=" << header; - data = data.mid(index+1); - //qDebug() << "data=" << data; - - if (header.endsWith(";base64")) { - //qDebug() << "base64"; - base64 = true; - header = header.left(header.length() - 7); - //qDebug() << "mime=" << header; - } - } else - data = QByteArray(); - - if (base64) - data = QByteArray::fromBase64(data); - else - data = decodePercentEncoding(data); - - if (header.isEmpty()) - header = "text/plain;charset=US-ASCII"; - int statusCode = 200; - QHttpResponseHeader response; - response.setContentType(header); - response.setContentLength(data.size()); - job->setResponse(response); - - int error = statusCode >= 400 ? 1 : 0; - q->started(job); - if (!data.isEmpty()) - q->data(job, data); - q->finished(job, error); -} - -void QWebNetworkManager::queueStart(QWebNetworkJob* job) -{ - Q_ASSERT(job->d); - - QMutexLocker locker(&m_queueMutex); - job->ref(); - m_pendingWork.append(new JobWork(job)); - doScheduleWork(); -} - -void QWebNetworkManager::queueData(QWebNetworkJob* job, const QByteArray& data) -{ - ASSERT(job->d); - - QMutexLocker locker(&m_queueMutex); - job->ref(); - m_pendingWork.append(new JobWork(job, data)); - doScheduleWork(); -} - -void QWebNetworkManager::queueFinished(QWebNetworkJob* job, int errorCode) -{ - Q_ASSERT(job->d); - - QMutexLocker locker(&m_queueMutex); - job->ref(); - m_pendingWork.append(new JobWork(job, errorCode)); - doScheduleWork(); -} - -void QWebNetworkManager::doScheduleWork() -{ - if (!m_scheduledWork) { - m_scheduledWork = true; - emit scheduleWork(); - } -} - - -/* - * We will work on a copy of m_pendingWork. While dispatching m_pendingWork - * new work will be added that will be handled at a later doWork call. doWork - * will be called we set m_scheduledWork to false early in this method. - */ -void QWebNetworkManager::doWork() -{ - m_queueMutex.lock(); - m_scheduledWork = false; - bool hasSyncJobs = m_synchronousJobs.size(); - const QHash<QWebNetworkJob*, int> syncJobs = m_synchronousJobs; - m_queueMutex.unlock(); - - foreach (JobWork* work, m_pendingWork) { - if (hasSyncJobs && !syncJobs.contains(work->job)) - continue; - - if (work->workType == JobWork::JobStarted) - started(work->job); - else if (work->workType == JobWork::JobData) { - // This job was not yet started - if (static_cast<int>(work->job->status()) < QWebNetworkJob::JobStarted) - continue; - - data(work->job, work->data); - } else if (work->workType == JobWork::JobFinished) { - // This job was not yet started... we have no idea if data comes by... - // and it won't start in case of errors - if (static_cast<int>(work->job->status()) < QWebNetworkJob::JobStarted && work->errorCode != 1) - continue; - - finished(work->job, work->errorCode); - } - - m_queueMutex.lock(); - m_pendingWork.removeAll(work); - m_queueMutex.unlock(); - - work->job->deref(); - delete work; - } - - m_queueMutex.lock(); - if (hasSyncJobs && !m_synchronousJobs.size()) - doScheduleWork(); - m_queueMutex.unlock(); -} - -/*! - \class QWebNetworkInterface - \internal - - The QWebNetworkInterface class provides an abstraction layer for - WebKit's network interface. It allows to completely replace or - extend the builtin network layer. - - QWebNetworkInterface contains two virtual methods, addJob and - cancelJob that have to be reimplemented when implementing your own - networking layer. - - QWebNetworkInterface can by default handle the http, https, file and - data URI protocols. - -*/ - -static bool gRoutineAdded = false; - -static void gCleanupInterface() -{ - delete s_default_interface; - s_default_interface = 0; -} - -/*! - \internal - Sets a new default interface that will be used by all of WebKit - for downloading data from the internet. -*/ -void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface* defaultInterface) -{ - if (s_default_interface == defaultInterface) - return; - if (s_default_interface) - delete s_default_interface; - s_default_interface = defaultInterface; - if (!gRoutineAdded) { - qAddPostRoutine(gCleanupInterface); - gRoutineAdded = true; - } -} - -/*! - \internal - Returns the default interface that will be used by WebKit. If no - default interface has been set, QtWebkit will create an instance of - QWebNetworkInterface to do the work. -*/ -QWebNetworkInterface *QWebNetworkInterface::defaultInterface() -{ - if (!s_default_interface) - setDefaultInterface(new QWebNetworkInterface); - - return s_default_interface; -} - - -/*! - \internal - Constructs a QWebNetworkInterface object. -*/ -QWebNetworkInterface::QWebNetworkInterface(QObject* parent) - : QObject(parent) -{ - d = new QWebNetworkInterfacePrivate; - d->q = this; - - if (!s_manager) - s_manager = new QWebNetworkManager; -} - -/*! - \internal - Destructs the QWebNetworkInterface object. -*/ -QWebNetworkInterface::~QWebNetworkInterface() -{ - delete d; -} - -/*! - \internal - This virtual method gets called whenever QtWebkit needs to add a - new job to download. - - The QWebNetworkInterface should process this job, by first emitting - the started signal, then emitting data repeatedly as new data for - the Job is available, and finally ending the job with emitting a - finished signal. - - After the finished signal has been emitted, the QWebNetworkInterface - is not allowed to access the job anymore. -*/ -void QWebNetworkInterface::addJob(QWebNetworkJob* job) -{ - QString protocol = job->url().scheme(); - if (protocol == QLatin1String("http") || protocol == QLatin1String("https")) { - QWebNetworkManager::self()->addHttpJob(job); - return; - } - - // "file", "data" and all unhandled stuff go through here - //DEBUG() << "fileRequest"; - DEBUG() << "FileLoader::request" << job->url(); - - if (job->cancelled()) { - d->sendFileData(job, 400, QByteArray()); - return; - } - - QUrl url = job->url(); - if (protocol == QLatin1String("data")) { - d->parseDataUrl(job); - return; - } - - int statusCode = 200; - QByteArray data; - QString path = url.path(); - if (protocol == QLatin1String("qrc")) { - protocol = "file"; - path.prepend(QLatin1Char(':')); - } - - if (!(protocol.isEmpty() || protocol == QLatin1String("file"))) { - statusCode = 404; - } else { - // we simply ignore post data here. - QFile f(path); - DEBUG() << "opening" << QString(url.path()); - - if (f.open(QIODevice::ReadOnly)) { - QHttpResponseHeader response; - response.setStatusLine(200); - job->setResponse(response); - data = f.readAll(); - } else - statusCode = 404; - } - - if (statusCode == 404) { - QHttpResponseHeader response; - response.setStatusLine(404); - job->setResponse(response); - } - - d->sendFileData(job, statusCode, data); -} - -/*! - \internal - This virtual method gets called whenever QtWebkit needs to cancel a - new job. - - The QWebNetworkInterface acknowledge the canceling of the job, by - emitting the finished signal with an error code of 1. After emitting - the finished signal, the interface should not access the job - anymore. -*/ -void QWebNetworkInterface::cancelJob(QWebNetworkJob* job) -{ - QString protocol = job->url().scheme(); - if (protocol == QLatin1String("http") || protocol == QLatin1String("https")) - QWebNetworkManager::self()->cancelHttpJob(job); -} - -/*! - \internal -*/ -void QWebNetworkInterface::started(QWebNetworkJob* job) -{ - Q_ASSERT(s_manager); - s_manager->queueStart(job); -} - -/*! - \internal -*/ -void QWebNetworkInterface::data(QWebNetworkJob* job, const QByteArray& data) -{ - Q_ASSERT(s_manager); - s_manager->queueData(job, data); -} - -/*! - \internal -*/ -void QWebNetworkInterface::finished(QWebNetworkJob* job, int errorCode) -{ - Q_ASSERT(s_manager); - s_manager->queueFinished(job, errorCode); -} - -/*! - \fn void QWebNetworkInterface::sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway); - \internal - - Signal is emitted when an SSL error occurs. -*/ - -/*! - \fn void QWebNetworkInterface::authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth); - \internal - - Signal is emitted when network authentication is required. -*/ - -/*! - \fn void QWebNetworkInterface::authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth); - \internal - - Signal is emitted when proxy authentication is required. -*/ - -///////////////////////////////////////////////////////////////////////////// -WebCoreHttp::WebCoreHttp(QObject* parent, const HostInfo& hi) - : QObject(parent) - , info(hi) - , m_inCancel(false) -{ - for (int i = 0; i < 2; ++i) { - connection[i].http = new QHttp(info.host, (hi.protocol == QLatin1String("https")) ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp, info.port); - connect(connection[i].http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader&)), - this, SLOT(onResponseHeaderReceived(const QHttpResponseHeader&))); - connect(connection[i].http, SIGNAL(readyRead(const QHttpResponseHeader&)), - this, SLOT(onReadyRead())); - connect(connection[i].http, SIGNAL(requestFinished(int, bool)), - this, SLOT(onRequestFinished(int, bool))); - connect(connection[i].http, SIGNAL(done(bool)), - this, SLOT(onDone(bool))); - connect(connection[i].http, SIGNAL(stateChanged(int)), - this, SLOT(onStateChanged(int))); - connect(connection[i].http, SIGNAL(authenticationRequired(const QString&, quint16, QAuthenticator*)), - this, SLOT(onAuthenticationRequired(const QString&, quint16, QAuthenticator*))); - connect(connection[i].http, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), - this, SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); - connect(connection[i].http, SIGNAL(sslErrors(const QList<QSslError>&)), - this, SLOT(onSslErrors(const QList<QSslError>&))); - } -} - -WebCoreHttp::~WebCoreHttp() -{ - connection[0].http->deleteLater(); - connection[1].http->deleteLater(); -} - -void WebCoreHttp::request(QWebNetworkJob* job) -{ - m_pendingRequests.append(job); - scheduleNextRequest(); -} - -void WebCoreHttp::scheduleNextRequest() -{ - int c = 0; - for (; c < 2; ++c) { - if (!connection[c].current) - break; - } - if (c >= 2) - return; - - QWebNetworkJob *job = 0; - while (!job && !m_pendingRequests.isEmpty()) { - job = m_pendingRequests.takeFirst(); - if (job->cancelled()) { - job->networkInterface()->finished(job, 1); - job = 0; - } - } - if (!job) - return; - - QHttp* http = connection[c].http; - - connection[c].current = job; - connection[c].id = -1; -#ifndef QT_NO_NETWORKPROXY - int proxyId = http->setProxy(job->frame()->page()->networkProxy()); -#endif - - QByteArray postData = job->postData(); - if (!postData.isEmpty()) - connection[c].id = http->request(job->httpHeader(), postData); - else - connection[c].id = http->request(job->httpHeader()); - - DEBUG() << "WebCoreHttp::scheduleNextRequest: using connection" << c; - DEBUG() << job->httpHeader().toString(); -// DEBUG() << job->request.toString(); -} - -int WebCoreHttp::getConnection() -{ - QObject* o = sender(); - int c; - if (o == connection[0].http) { - c = 0; - } else { - Q_ASSERT(o == connection[1].http); - c = 1; - } - Q_ASSERT(connection[c].current); - return c; -} - -void WebCoreHttp::onResponseHeaderReceived(const QHttpResponseHeader& resp) -{ - QHttp* http = qobject_cast<QHttp*>(sender()); - if (!http->currentId()) { - qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this - return; - } - int c = getConnection(); - QWebNetworkJob* job = connection[c].current; - DEBUG() << "WebCoreHttp::slotResponseHeaderReceived connection=" << c; - DEBUG() << resp.toString(); - - job->setResponse(resp); - - job->networkInterface()->started(job); -} - -void WebCoreHttp::onReadyRead() -{ - QHttp* http = qobject_cast<QHttp*>(sender()); - if (!http->currentId()) { - qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this - return; - } - int c = getConnection(); - QWebNetworkJob* job = connection[c].current; - Q_ASSERT(http == connection[c].http); - //DEBUG() << "WebCoreHttp::slotReadyRead connection=" << c; - - QByteArray data; - data.resize(http->bytesAvailable()); - http->read(data.data(), data.length()); - job->networkInterface()->data(job, data); -} - -void WebCoreHttp::onRequestFinished(int id, bool error) -{ - int c = getConnection(); - if (connection[c].id != id) - return; - - QWebNetworkJob* job = connection[c].current; - if (!job) { - scheduleNextRequest(); - return; - } - - QHttp* http = connection[c].http; - DEBUG() << "WebCoreHttp::slotFinished connection=" << c << error << job; - if (error) { - DEBUG() << " error: " << http->errorString(); - job->setErrorString(http->errorString()); - } - - if (!error && http->bytesAvailable()) { - QByteArray data; - data.resize(http->bytesAvailable()); - http->read(data.data(), data.length()); - job->networkInterface()->data(job, data); - } - - job->networkInterface()->finished(job, error ? 1 : 0); - connection[c].current = 0; - connection[c].id = -1; - scheduleNextRequest(); -} - -void WebCoreHttp::onDone(bool error) -{ - DEBUG() << "WebCoreHttp::onDone" << error; -} - -void WebCoreHttp::onStateChanged(int state) -{ - DEBUG() << "State changed to" << state << "and connections are" << connection[0].current << connection[1].current; - if (state == QHttp::Closing || state == QHttp::Unconnected) { - if (!m_inCancel && m_pendingRequests.isEmpty() - && !connection[0].current && !connection[1].current) - emit connectionClosed(info); - } -} - -void WebCoreHttp::cancel(QWebNetworkJob* request) -{ - bool doEmit = true; - m_inCancel = true; - for (int i = 0; i < 2; ++i) { - if (request == connection[i].current) { - connection[i].http->abort(); - doEmit = false; - } - } - if (!m_pendingRequests.removeAll(request)) - doEmit = false; - m_inCancel = false; - - if (doEmit) - request->networkInterface()->finished(request, 1); - - if (m_pendingRequests.isEmpty() - && !connection[0].current && !connection[1].current) - emit connectionClosed(info); -} - -void WebCoreHttp::onSslErrors(const QList<QSslError>& errors) -{ - int c = getConnection(); - QWebNetworkJob *job = connection[c].current; - if (job) { - bool continueAnyway = false; - emit job->networkInterface()->sslErrors(job->frame(), job->url(), errors, &continueAnyway); -#ifndef QT_NO_OPENSSL - if (continueAnyway) - connection[c].http->ignoreSslErrors(); -#endif - } -} - -void WebCoreHttp::onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator* auth) -{ - int c = getConnection(); - QWebNetworkJob *job = connection[c].current; - if (job) { - emit job->networkInterface()->authenticate(job->frame(), job->url(), hostname, port, auth); - if (auth->isNull()) - connection[c].http->abort(); - } -} - -void WebCoreHttp::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* auth) -{ - int c = getConnection(); - QWebNetworkJob *job = connection[c].current; - if (job) { - emit job->networkInterface()->authenticateProxy(job->frame(), job->url(), proxy, auth); - if (auth->isNull()) - connection[c].http->abort(); - } -} - -HostInfo::HostInfo(const QUrl& url) - : protocol(url.scheme()) - , host(url.host()) - , port(url.port()) -{ - if (port < 0) { - if (protocol == QLatin1String("http")) - port = 80; - else if (protocol == QLatin1String("https")) - port = 443; - } -} - -#endif diff --git a/WebKit/qt/Api/qwebnetworkinterface.h b/WebKit/qt/Api/qwebnetworkinterface.h deleted file mode 100644 index 7f96155..0000000 --- a/WebKit/qt/Api/qwebnetworkinterface.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QWEBNETWORKINTERFACE_H -#define QWEBNETWORKINTERFACE_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QtNetwork/qhttp.h> -#include <QtCore/qbytearray.h> - -#include "qwebkitglobal.h" - -#if QT_VERSION < 0x040400 - -class QAuthenticator; -class QNetworkProxy; -class QSslError; -class QWebFrame; -class QWebNetworkJobPrivate; -class QWebNetworkInterface; -class QWebObjectPluginConnector; - -namespace WebCore { - class WebCoreHttp; - class ResourceRequest; - class FrameLoaderClientQt; -} - -struct QWebNetworkRequestPrivate; -class QWEBKIT_EXPORT QWebNetworkRequest { -public: - enum Method { - Get, - Post - //Head - }; - - QWebNetworkRequest(); - explicit QWebNetworkRequest(const QUrl &url, Method method = Get, const QByteArray &postData = QByteArray()); - QWebNetworkRequest(const QWebNetworkRequest &other); - - QWebNetworkRequest &operator=(const QWebNetworkRequest &other); - ~QWebNetworkRequest(); - - QUrl url() const; - void setUrl(const QUrl &url); - - QHttpRequestHeader httpHeader() const; - void setHttpHeader(const QHttpRequestHeader &header) const; - - QString httpHeaderField(const QString &key) const; - void setHttpHeaderField(const QString &key, const QString &value); - - QByteArray postData() const; - void setPostData(const QByteArray &data); - -private: - explicit QWebNetworkRequest(const QWebNetworkRequestPrivate &priv); - explicit QWebNetworkRequest(const WebCore::ResourceRequest &request); - friend class QWebNetworkJob; - friend class WebCore::FrameLoaderClientQt; - - QWebNetworkRequestPrivate *d; - friend class QWebObjectPluginConnector; -}; - -class QWEBKIT_EXPORT QWebNetworkJob { -public: - - QUrl url() const; - QByteArray postData() const; - QHttpRequestHeader httpHeader() const; - QWebNetworkRequest request() const; - QString errorString() const; - - QHttpResponseHeader response() const; - void setResponse(const QHttpResponseHeader &response); - void setErrorString(const QString&); - - bool cancelled() const; - - void ref(); - bool deref(); - - QWebNetworkInterface *networkInterface() const; - - QWebFrame *frame() const; - -protected: - enum JobStatus { - JobCreated, - JobRecreated, - JobStarted, - JobReceivingData, - JobFinished - }; - - JobStatus status() const; - void setStatus(const JobStatus&); - -private: - QWebNetworkJob(); - ~QWebNetworkJob(); - - friend class QWebNetworkManager; - friend class QWebObjectPluginConnector; - friend class QWebNetworkJobPrivate; - - QWebNetworkJobPrivate *d; -}; - -class QWebNetworkInterfacePrivate; - -class QWEBKIT_EXPORT QWebNetworkInterface : public QObject { - Q_OBJECT -public: - QWebNetworkInterface(QObject *parent = 0); - ~QWebNetworkInterface(); - - static void setDefaultInterface(QWebNetworkInterface *defaultInterface); - static QWebNetworkInterface *defaultInterface(); - - virtual void addJob(QWebNetworkJob *job); - virtual void cancelJob(QWebNetworkJob *job); - -protected: - void started(QWebNetworkJob*); - void data(QWebNetworkJob*, const QByteArray &data); - void finished(QWebNetworkJob*, int errorCode); - -signals: - void sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway); - void authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth); - void authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth); - -private: - friend class QWebNetworkInterfacePrivate; - friend class WebCore::WebCoreHttp; - QWebNetworkInterfacePrivate *d; -}; - -#endif - -#endif diff --git a/WebKit/qt/Api/qwebnetworkinterface_p.h b/WebKit/qt/Api/qwebnetworkinterface_p.h deleted file mode 100644 index aec104b..0000000 --- a/WebKit/qt/Api/qwebnetworkinterface_p.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QWEBNETWORKINTERFACE_P_H -#define QWEBNETWORKINTERFACE_P_H - -#include "qwebnetworkinterface.h" -#if QT_VERSION < 0x040400 -#include <qthread.h> -#include <qmutex.h> - -namespace WebCore { - struct HostInfo; - class ResourceRequest; -}; -uint qHash(const WebCore::HostInfo &info); -#include <qhash.h> - -namespace WebCore { - class ResourceHandle; -} - -struct QWebNetworkRequestPrivate { - QUrl url; - QHttpRequestHeader httpHeader; - QByteArray postData; - - void init(const WebCore::ResourceRequest &resourceRequest); - void init(const QString &method, const QUrl &url, const WebCore::ResourceRequest *resourceRequest = 0); - void setURL(const QUrl &u); -}; - -class QWebNetworkJobPrivate { -public: - QWebNetworkJobPrivate() - : ref(1) - , resourceHandle(0) - , redirected(false) - , interface(0) - , jobStatus(QWebNetworkJob::JobCreated) - {} - int ref; - - QWebNetworkRequestPrivate request; - QHttpResponseHeader response; - - WebCore::ResourceHandle *resourceHandle; - bool redirected; - - QWebNetworkInterface *interface; - QWebNetworkJob::JobStatus jobStatus; - QString errorString; -}; - -class QWebNetworkManager : public QObject { - Q_OBJECT -public: - enum JobMode { - AsynchronousJob, - SynchronousJob - }; - - static QWebNetworkManager *self(); - - bool add(WebCore::ResourceHandle *resourceHandle, QWebNetworkInterface *interface, JobMode = AsynchronousJob); - void cancel(WebCore::ResourceHandle *resourceHandle); - - void addHttpJob(QWebNetworkJob *job); - void cancelHttpJob(QWebNetworkJob *job); - -protected: - void queueStart(QWebNetworkJob*); - void queueData(QWebNetworkJob*, const QByteArray&); - void queueFinished(QWebNetworkJob*, int errorCode); - -private: - void started(QWebNetworkJob *); - void data(QWebNetworkJob *, const QByteArray &data); - void finished(QWebNetworkJob *, int errorCode); - void doScheduleWork(); - -signals: - void fileRequest(QWebNetworkJob*); - void scheduleWork(); - -private slots: - void httpConnectionClosed(const WebCore::HostInfo &); - void doWork(); - -private: - friend class QWebNetworkInterface; - QWebNetworkManager(); - QHash<WebCore::HostInfo, WebCore::WebCoreHttp *> m_hostMapping; - - struct JobWork { - enum WorkType { - JobStarted, - JobData, - JobFinished - }; - - explicit JobWork(QWebNetworkJob* _job) - : workType(JobStarted) - , errorCode(-1) - , job(_job) - {} - - explicit JobWork(QWebNetworkJob* _job, int _errorCode) - : workType(JobFinished) - , errorCode(_errorCode) - , job(_job) - {} - - explicit JobWork(QWebNetworkJob* _job, const QByteArray& _data) - : workType(JobData) - , errorCode(-1) - , job(_job) - , data(_data) - {} - - const WorkType workType; - int errorCode; - QByteArray data; - QWebNetworkJob* job; - }; - - QMutex m_queueMutex; - bool m_scheduledWork; - QList<JobWork*> m_pendingWork; - QHash<QWebNetworkJob*, int> m_synchronousJobs; -}; - - -namespace WebCore { - - class NetworkLoader; - - struct HostInfo { - HostInfo() {} - HostInfo(const QUrl& url); - QString protocol; - QString host; - int port; - }; - - class WebCoreHttp : public QObject { - Q_OBJECT - public: - WebCoreHttp(QObject* parent, const HostInfo&); - ~WebCoreHttp(); - - void request(QWebNetworkJob* resource); - void cancel(QWebNetworkJob*); - - signals: - void connectionClosed(const WebCore::HostInfo&); - - private slots: - void onResponseHeaderReceived(const QHttpResponseHeader& resp); - void onReadyRead(); - void onRequestFinished(int, bool); - void onDone(bool); - void onStateChanged(int); - void onSslErrors(const QList<QSslError>&); - void onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator*); - void onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator*); - - void scheduleNextRequest(); - - int getConnection(); - - public: - HostInfo info; - private: - QList<QWebNetworkJob*> m_pendingRequests; - struct HttpConnection { - HttpConnection() : http(0), current(0), id(-1) {} - QHttp* http; - QWebNetworkJob* current; - int id; // the QHttp id - }; - HttpConnection connection[2]; - bool m_inCancel; - }; - -} - -class QWebNetworkInterfacePrivate { -public: - void sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray& data); - void parseDataUrl(QWebNetworkJob* job); - - QWebNetworkInterface* q; -}; - -#endif - -#endif diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 0b122b4..ba6b9f3 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -78,6 +78,7 @@ #include "Cache.h" #include "runtime/InitializeThreading.h" #include "PageGroup.h" +#include "QWebPageClient.h" #include <QApplication> #include <QBasicTimer> @@ -101,11 +102,10 @@ #include <QStyle> #include <QSysInfo> #include <QTextCharFormat> -#if QT_VERSION >= 0x040400 #include <QNetworkAccessManager> #include <QNetworkRequest> -#else -#include "qwebnetworkinterface.h" +#if defined(Q_WS_X11) +#include <QX11Info> #endif using namespace WebCore; @@ -138,6 +138,102 @@ QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page) return page->handle()->page->groupName(); } +class QWebPageWidgetClient : public QWebPageClient { +public: + QWebPageWidgetClient(QWidget* view) + : view(view) + { + Q_ASSERT(view); + } + + virtual void scroll(int dx, int dy, const QRect&); + virtual void update(const QRect& dirtyRect); + virtual void setInputMethodEnabled(bool enable); + virtual bool inputMethodEnabled() const; +#if QT_VERSION >= 0x040600 + virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); +#endif + +#ifndef QT_NO_CURSOR + virtual QCursor cursor() const; + virtual void updateCursor(const QCursor& cursor); +#endif + + virtual QPalette palette() const; + virtual int screenNumber() const; + virtual QWidget* ownerWidget() const; + + virtual QObject* pluginParent() const; + + QWidget* view; +}; + +void QWebPageWidgetClient::scroll(int dx, int dy, const QRect& rectToScroll) +{ + view->scroll(qreal(dx), qreal(dy), rectToScroll); +} + +void QWebPageWidgetClient::update(const QRect & dirtyRect) +{ + view->update(dirtyRect); +} + +void QWebPageWidgetClient::setInputMethodEnabled(bool enable) +{ + view->setAttribute(Qt::WA_InputMethodEnabled, enable); +} + +bool QWebPageWidgetClient::inputMethodEnabled() const +{ + return view->testAttribute(Qt::WA_InputMethodEnabled); +} + +#if QT_VERSION >= 0x040600 +void QWebPageWidgetClient::setInputMethodHint(Qt::InputMethodHint hint, bool enable) +{ + if (enable) + view->setInputMethodHints(view->inputMethodHints() | hint); + else + view->setInputMethodHints(view->inputMethodHints() & ~hint); +} +#endif +#ifndef QT_NO_CURSOR +QCursor QWebPageWidgetClient::cursor() const +{ + return view->cursor(); +} + +void QWebPageWidgetClient::updateCursor(const QCursor& cursor) +{ + view->setCursor(cursor); +} +#endif + +QPalette QWebPageWidgetClient::palette() const +{ + return view->palette(); +} + +int QWebPageWidgetClient::screenNumber() const +{ +#if defined(Q_WS_X11) + if (view) + return view->x11Info().screen(); +#endif + + return 0; +} + +QWidget* QWebPageWidgetClient::ownerWidget() const +{ + return view; +} + +QObject* QWebPageWidgetClient::pluginParent() const +{ + return view; +} + // Lookup table mapping QWebPage::WebActions to the associated Editor commands static const char* editorCommandWebActions[] = { @@ -266,11 +362,11 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) #if QT_VERSION < 0x040600 , view(0) #endif + , clickCausedFocus(false) + , viewportSize(QSize(0, 0)) , inspectorFrontend(0) , inspector(0) , inspectorIsInternalOnly(false) - , viewportSize(QSize(0, 0)) - , clickCausedFocus(false) { WebCore::InitializeLoggingChannelsIfNecessary(); JSC::initializeThreading(); @@ -288,11 +384,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) undoStack = 0; #endif mainFrame = 0; -#if QT_VERSION < 0x040400 - networkInterface = 0; -#else networkManager = 0; -#endif pluginFactory = 0; insideOpenCall = false; forwardUnsupportedContent = false; @@ -321,15 +413,6 @@ QWebPagePrivate::~QWebPagePrivate() delete page; } -#if QT_VERSION < 0x040400 -bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type) -{ - if (insideOpenCall - && frame == mainFrame) - return true; - return q->acceptNavigationRequest(frame, request, type); -} -#else bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) { if (insideOpenCall @@ -337,7 +420,6 @@ bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRe return true; return q->acceptNavigationRequest(frame, request, type); } -#endif void QWebPagePrivate::createMainFrame() { @@ -764,13 +846,18 @@ void QWebPagePrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) void QWebPagePrivate::handleSoftwareInputPanel(Qt::MouseButton button) { #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) - if (q->view() && q->view()->testAttribute(Qt::WA_InputMethodEnabled) + Frame* frame = page->focusController()->focusedFrame(); + if (!frame) + return; + + if (client && client->inputMethodEnabled() + && frame->document()->focusedNode() && button == Qt::LeftButton && qApp->autoSipEnabled()) { QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( - q->view()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); + client->ownerWidget()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) { QEvent event(QEvent::RequestSoftwareInputPanel); - QApplication::sendEvent(q->view(), &event); + QApplication::sendEvent(client->ownerWidget(), &event); } } @@ -962,11 +1049,9 @@ void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev) void QWebPagePrivate::focusInEvent(QFocusEvent*) { FocusController *focusController = page->focusController(); - Frame *frame = focusController->focusedFrame(); focusController->setActive(true); - if (frame) - focusController->setFocused(true); - else + focusController->setFocused(true); + if (!focusController->focusedFrame()) focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame)); } @@ -1210,16 +1295,16 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame) granularity = ScrollByPage; direction = ScrollDown; } else if (ev == QKeySequence::MoveToPreviousPage - || (ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier)) { + || ((ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier))) { granularity = ScrollByPage; direction = ScrollUp; } else #endif // QT_NO_SHORTCUT - if (ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier + if ((ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier) || ev->key() == Qt::Key_Home) { granularity = ScrollByDocument; direction = ScrollUp; - } else if (ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier + } else if ((ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier) || ev->key() == Qt::Key_End) { granularity = ScrollByDocument; direction = ScrollDown; @@ -1378,8 +1463,6 @@ QWebInspector* QWebPagePrivate::getOrCreateInspector() if (!inspector) { QWebInspector* insp = new QWebInspector; insp->setPage(q); - insp->connect(q, SIGNAL(webInspectorTriggered(const QWebElement&)), SLOT(show())); - insp->show(); // The inspector is expected to be shown on inspection inspectorIsInternalOnly = true; Q_ASSERT(inspector); // Associated through QWebInspector::setPage(q) @@ -1584,7 +1667,7 @@ InspectorController* QWebPagePrivate::inspectorController() */ /*! - Constructs an empty QWebView with parent \a parent. + Constructs an empty QWebPage with parent \a parent. */ QWebPage::QWebPage(QObject *parent) : QObject(parent) @@ -1607,8 +1690,14 @@ QWebPage::~QWebPage() FrameLoader *loader = d->mainFrame->d->frame->loader(); if (loader) loader->detachFromParent(); - if (d->inspector) - d->inspector->setPage(0); + if (d->inspector) { + // Since we have to delete an internal inspector, + // call setInspector(0) directly to prevent potential crashes + if (d->inspectorIsInternalOnly) + d->setInspector(0); + else + d->inspector->setPage(0); + } delete d; } @@ -1672,6 +1761,15 @@ void QWebPage::setView(QWidget *view) { if (this->view() != view) { d->view = view; + if (!view) { + delete d->client; + d->client = 0; + } else { + if (!d->client) + d->client = new QWebPageWidgetClient(view); + else + static_cast<QWebPageWidgetClient*>(d->client)->view = view; + } setViewportSize(view ? view->size() : QSize(0, 0)); } } @@ -1916,11 +2014,9 @@ void QWebPage::triggerAction(WebAction action, bool) editor->setBaseWritingDirection(RightToLeftWritingDirection); break; case InspectElement: { - QWebElement inspectedElement(QWebElement::enclosingElement(d->hitTestResult.d->innerNonSharedNode.get())); - emit webInspectorTriggered(inspectedElement); - if (!d->hitTestResult.isNull()) { d->getOrCreateInspector(); // Make sure the inspector is created + d->inspector->show(); // The inspector is expected to be shown on inspection d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get()); } break; @@ -2019,11 +2115,7 @@ void QWebPage::setPreferredContentsSize(const QSize &size) const \sa createWindow() */ -#if QT_VERSION >= 0x040400 bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) -#else -bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type) -#endif { Q_UNUSED(frame) if (type == NavigationTypeLinkClicked) { @@ -2111,27 +2203,19 @@ QAction *QWebPage::action(WebAction action) const case Back: text = contextMenuItemTagGoBack(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_ArrowBack); -#endif break; case Forward: text = contextMenuItemTagGoForward(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_ArrowForward); -#endif break; case Stop: text = contextMenuItemTagStop(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_BrowserStop); -#endif break; case Reload: text = contextMenuItemTagReload(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_BrowserReload); -#endif break; case Cut: @@ -2661,6 +2745,17 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) as a result of the user clicking on a "file upload" button in a HTML form where multiple file selection is allowed. + \omitvalue ErrorPageExtension (introduced in Qt 4.6) +*/ + +/*! + \enum QWebPage::ErrorDomain + \since 4.6 + \internal + + \value QtNetwork + \value Http + \value WebKit */ /*! @@ -2711,6 +2806,12 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) */ /*! + \fn QWebPage::ErrorPageExtensionReturn::ErrorPageExtensionReturn() + + Constructs a new error page object. +*/ + +/*! \class QWebPage::ChooseMultipleFilesExtensionOption \since 4.5 \brief The ChooseMultipleFilesExtensionOption class describes the option @@ -2844,35 +2945,6 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFil #endif } -#if QT_VERSION < 0x040400 && !defined qdoc - -void QWebPage::setNetworkInterface(QWebNetworkInterface *interface) -{ - d->networkInterface = interface; -} - -QWebNetworkInterface *QWebPage::networkInterface() const -{ - if (d->networkInterface) - return d->networkInterface; - else - return QWebNetworkInterface::defaultInterface(); -} - -#ifndef QT_NO_NETWORKPROXY -void QWebPage::setNetworkProxy(const QNetworkProxy& proxy) -{ - d->networkProxy = proxy; -} - -QNetworkProxy QWebPage::networkProxy() const -{ - return d->networkProxy; -} -#endif - -#else - /*! Sets the QNetworkAccessManager \a manager responsible for serving network requests for this QWebPage. @@ -2906,8 +2978,6 @@ QNetworkAccessManager *QWebPage::networkAccessManager() const return d->networkManager; } -#endif - /*! Sets the QWebPluginFactory \a factory responsible for creating plugins embedded into this QWebPage. @@ -2955,7 +3025,7 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const Q_UNUSED(url) QString ua = QLatin1String("Mozilla/5.0 (" - // Plastform + // Platform #ifdef Q_WS_MAC "Macintosh" #elif defined Q_WS_QWS @@ -2964,19 +3034,22 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const "Windows" #elif defined Q_WS_X11 "X11" +#elif defined Q_OS_SYMBIAN + "SymbianOS" #else "Unknown" #endif - "; " + // Placeholder for Platform Version + "%1; " // Placeholder for security strength (N or U) - "%1; " + "%2; " // Subplatform" #ifdef Q_OS_AIX "AIX" #elif defined Q_OS_WIN32 - "%2" + "%3" #elif defined Q_OS_DARWIN #ifdef __i386__ || __x86_64__ "Intel Mac OS X" @@ -3028,6 +3101,8 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const "Sun Solaris" #elif defined Q_OS_ULTRIX "DEC Ultrix" +#elif defined Q_WS_S60 + "Series60" #elif defined Q_OS_UNIX "UNIX BSD/SYSV system" #elif defined Q_OS_UNIXWARE @@ -3035,7 +3110,28 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const #else "Unknown" #endif - "; "); + // Placeholder for SubPlatform Version + "%4; "); + + // Platform Version + QString osVer; +#ifdef Q_OS_SYMBIAN + QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); + switch (symbianVersion) { + case QSysInfo::SV_9_2: + osVer = "/9.2"; + break; + case QSysInfo::SV_9_3: + osVer = "/9.3"; + break; + case QSysInfo::SV_9_4: + osVer = "/9.4"; + break; + default: + osVer = "Unknown"; + } +#endif + ua = ua.arg(osVer); QChar securityStrength(QLatin1Char('N')); #if !defined(QT_NO_OPENSSL) @@ -3099,6 +3195,26 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const ua = QString(ua).arg(ver); #endif + // SubPlatform Version + QString subPlatformVer; +#ifdef Q_OS_SYMBIAN + QSysInfo::S60Version s60Version = QSysInfo::s60Version(); + switch (s60Version) { + case QSysInfo::SV_S60_3_1: + subPlatformVer = "/3.1"; + break; + case QSysInfo::SV_S60_3_2: + subPlatformVer = "/3.2"; + break; + case QSysInfo::SV_S60_5_0: + subPlatformVer = "/5.0"; + break; + default: + subPlatformVer = " Unknown"; + } +#endif + ua = ua.arg(subPlatformVer); + // Language QLocale locale; if (view()) @@ -3116,11 +3232,9 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const QString appName = QCoreApplication::applicationName(); if (!appName.isEmpty()) { ua.append(appName); -#if QT_VERSION >= 0x040400 QString appVer = QCoreApplication::applicationVersion(); if (!appVer.isEmpty()) ua.append(QLatin1Char('/') + appVer); -#endif } else { // Qt version ua.append(QLatin1String("Qt/")); @@ -3321,24 +3435,6 @@ quint64 QWebPage::bytesReceived() const */ /*! - \fn void QWebPage::webInspectorTriggered(const QWebElement& inspectedElement); - \since 4.6 - - This signal is emitted when the user triggered an inspection through the - context menu. If a QWebInspector is associated to this page, it should be - visible to the user after this signal has been emitted. - - If still no QWebInspector is associated to this QWebPage after the emission - of this signal, a privately owned inspector will be shown to the user. - - \note \a inspectedElement contains the QWebElement under the context menu. - It is not garanteed to be the same as the focused element in the web - inspector. - - \sa QWebInspector -*/ - -/*! \fn void QWebPage::toolBarVisibilityChangeRequested(bool visible) This signal is emitted whenever the visibility of the toolbar in a web browser @@ -3389,16 +3485,6 @@ quint64 QWebPage::bytesReceived() const */ /*! - \since 4.6 - \fn void QWebPage::networkRequestStarted(QWebFrame* frame, QNetworkRequest* request); - \preliminary - - This signal is emitted when a \a frame of the current page requests a web resource. The application - may want to associate the \a request with the \a frame that initiated it by storing the \a frame - as an attribute of the \a request. -*/ - -/*! \fn QWebPagePrivate* QWebPage::handle() const \internal */ diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index f2bbde0..4766cbd 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -208,20 +208,8 @@ public: QUndoStack *undoStack() const; #endif -#if QT_VERSION < 0x040400 && !defined(qdoc) - void setNetworkInterface(QWebNetworkInterface *interface); - QWebNetworkInterface *networkInterface() const; - - // #### why is this in the page itself? -#ifndef QT_NO_NETWORKPROXY - void setNetworkProxy(const QNetworkProxy& proxy); - QNetworkProxy networkProxy() const; -#endif - -#else void setNetworkAccessManager(QNetworkAccessManager *manager); QNetworkAccessManager *networkAccessManager() const; -#endif void setPluginFactory(QWebPluginFactory *factory); QWebPluginFactory *pluginFactory() const; @@ -329,16 +317,13 @@ Q_SIGNALS: void windowCloseRequested(); void printRequested(QWebFrame *frame); void linkClicked(const QUrl &url); - void webInspectorTriggered(const QWebElement& inspectedElement); void toolBarVisibilityChangeRequested(bool visible); void statusBarVisibilityChangeRequested(bool visible); void menuBarVisibilityChangeRequested(bool visible); -#if QT_VERSION >= 0x040400 void unsupportedContent(QNetworkReply *reply); void downloadRequested(const QNetworkRequest &request); -#endif void microFocusChanged(); void contentsChanged(); @@ -347,17 +332,11 @@ Q_SIGNALS: void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); void restoreFrameStateRequested(QWebFrame* frame); - void networkRequestStarted(QWebFrame* frame, QNetworkRequest* request); - protected: virtual QWebPage *createWindow(WebWindowType type); virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); -#if QT_VERSION >= 0x040400 virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); -#else - virtual bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type); -#endif virtual QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile); virtual void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg); virtual bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg); diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index f0f842d..5d97da4 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.h @@ -151,18 +151,8 @@ public: bool clickCausedFocus; -#if QT_VERSION < 0x040400 - bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type); - - QWebNetworkInterface *networkInterface; -#ifndef QT_NO_NETWORKPROXY - QNetworkProxy networkProxy; -#endif - -#else bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type); QNetworkAccessManager *networkManager; -#endif bool forwardUnsupportedContent; QWebPage::LinkDelegationPolicy linkPolicy; diff --git a/WebKit/qt/Api/qwebplugindatabase.cpp b/WebKit/qt/Api/qwebplugindatabase.cpp index 623895f..758e257 100644 --- a/WebKit/qt/Api/qwebplugindatabase.cpp +++ b/WebKit/qt/Api/qwebplugindatabase.cpp @@ -18,7 +18,7 @@ */ #include "config.h" -#include "qwebplugindatabase.h" +#include "qwebplugindatabase_p.h" #include "PluginDatabase.h" #include "PluginPackage.h" @@ -26,6 +26,7 @@ using namespace WebCore; /*! + \internal \typedef QWebPluginInfo::MimeType \since 4.6 \brief Represents a single MIME type supported by a plugin. @@ -33,6 +34,7 @@ using namespace WebCore; /*! \class QWebPluginInfo + \internal \since 4.6 \brief The QWebPluginInfo class represents a single Netscape plugin. @@ -232,6 +234,7 @@ QWebPluginInfo &QWebPluginInfo::operator=(const QWebPluginInfo& other) /*! \class QWebPluginDatabase + \internal \since 4.6 \brief The QWebPluginDatabase class provides an interface for managing Netscape plugins used by WebKit in QWebPages. diff --git a/WebKit/qt/Api/qwebplugindatabase.h b/WebKit/qt/Api/qwebplugindatabase_p.h index b22c3de..b22c3de 100644 --- a/WebKit/qt/Api/qwebplugindatabase.h +++ b/WebKit/qt/Api/qwebplugindatabase_p.h diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index ffa21e4..9a5ab46 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -22,7 +22,7 @@ #include "qwebpage.h" #include "qwebpage_p.h" -#include "qwebplugindatabase.h" +#include "qwebplugindatabase_p.h" #include "Cache.h" #include "CrossOriginPreflightResultCache.h" @@ -62,8 +62,6 @@ public: QString localStoragePath; QString offlineWebApplicationCachePath; qint64 offlineStorageDefaultQuota; - float printingMinimumShrinkFactor; - float printingMaximumShrinkFactor; void apply(); WebCore::Settings* settings; @@ -81,6 +79,7 @@ static WebGraphicHash* graphics() hash->insert(QWebSettings::MissingPluginGraphic, QPixmap(QLatin1String(":webkit/resources/nullPlugin.png"))); hash->insert(QWebSettings::DefaultFrameIconGraphic, QPixmap(QLatin1String(":webkit/resources/urlIcon.png"))); hash->insert(QWebSettings::TextAreaSizeGripCornerGraphic, QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png"))); + hash->insert(QWebSettings::DeleteButtonGraphic, QPixmap(QLatin1String(":webkit/resources/deleteButton.png"))); } return hash; @@ -176,12 +175,6 @@ void QWebSettingsPrivate::apply() QString storagePath = !localStoragePath.isEmpty() ? localStoragePath : global->localStoragePath; settings->setLocalStorageDatabasePath(storagePath); - float minimumShrinkFactor = printingMinimumShrinkFactor > 0.0f ? printingMinimumShrinkFactor : global->printingMinimumShrinkFactor; - settings->setPrintingMinimumShrinkFactor(minimumShrinkFactor); - - float maximumShrinkFactor = printingMaximumShrinkFactor > 0.0f ? printingMaximumShrinkFactor : global->printingMaximumShrinkFactor; - settings->setPrintingMaximumShrinkFactor(maximumShrinkFactor); - value = attributes.value(QWebSettings::ZoomTextOnly, global->attributes.value(QWebSettings::ZoomTextOnly)); settings->setZoomsTextOnly(value); @@ -206,10 +199,7 @@ void QWebSettingsPrivate::apply() value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls, global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls)); settings->setAllowUniversalAccessFromFileURLs(value); - - value = attributes.value(QWebSettings::SessionStorageEnabled, - global->attributes.value(QWebSettings::SessionStorageEnabled)); - settings->setSessionStorageEnabled(value); + settings->setUsesPageCache(WebCore::pageCache()->capacity()); } else { QList<QWebSettingsPrivate*> settings = *::allSettings(); for (int i = 0; i < settings.count(); ++i) @@ -273,7 +263,7 @@ QWebSettings* QWebSettings::globalSettings() setOfflineStoragePath() with an appropriate file path, and can limit the quota for each application by calling setOfflineStorageDefaultQuota(). - \sa QWebPage::settings(), QWebView::settings(), {Browser} + \sa QWebPage::settings(), QWebView::settings(), {Web Browser} */ /*! @@ -350,9 +340,9 @@ QWebSettings* QWebSettings::globalSettings() web application cache feature is enabled or not. Disabled by default. \value LocalStorageEnabled Specifies whether support for the HTML 5 local storage feature is enabled or not. Disabled by default. + \value LocalStorageDatabaseEnabled \e{This enum value is deprecated.} Use + QWebSettings::LocalStorageEnabled instead. \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls. - \value SessionStorageEnabled Specifies whether support for the HTML 5 - session storage feature is enabled or not. Enabled by default. */ /*! @@ -383,11 +373,8 @@ QWebSettings::QWebSettings() d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false); d->attributes.insert(QWebSettings::LocalStorageEnabled, false); d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false); - d->attributes.insert(QWebSettings::SessionStorageEnabled, true); d->offlineStorageDefaultQuota = 5 * 1024 * 1024; d->defaultTextEncoding = QLatin1String("iso-8859-1"); - d->printingMinimumShrinkFactor = 0.0f; - d->printingMaximumShrinkFactor = 0.0f; } /*! @@ -502,60 +489,6 @@ QString QWebSettings::defaultTextEncoding() const } /*! - \since 4.7 - Specifies minimum shrink fator allowed for printing. If set to 0 a - default value is used. - - When printing, content will be shrunk to reduce page usage, it - will reduced by a factor between printingMinimumShrinkFactor and - printingMaximumShrinkFactor. - - \sa printingMinimumShrinkFactor() - \sa setPrintingMaximumShrinkFactor() - \sa printingMaximumShrinkFactor() -*/ -void QWebSettings::setPrintingMinimumShrinkFactor(float printingMinimumShrinkFactor) -{ - d->printingMinimumShrinkFactor = printingMinimumShrinkFactor; - d->apply(); -} - -/*! - \since 4.7 - returns the minimum shrink factor used for printing. - - \sa setPrintingMinimumShrinkFactor() -*/ -float QWebSettings::printingMinimumShrinkFactor() const -{ - return d->printingMinimumShrinkFactor; -} - -/*! - \since 4.7 - Specifies maximum shrink fator allowed for printing. If set to 0 a - default value is used. - - \sa setPrintingMinimumShrinkFactor() -*/ -void QWebSettings::setPrintingMaximumShrinkFactor(float printingMaximumShrinkFactor) -{ - d->printingMaximumShrinkFactor = printingMaximumShrinkFactor; - d->apply(); -} - -/*! - \since 4.7 - returns the maximum shrink factor used for printing. - - \sa setPrintingMinimumShrinkFactor() -*/ -float QWebSettings::printingMaximumShrinkFactor() const -{ - return d->printingMaximumShrinkFactor; -} - -/*! Sets the path of the icon database to \a path. The icon database is used to store "favicons" associated with web sites. @@ -625,9 +558,9 @@ QIcon QWebSettings::iconForUrl(const QUrl& url) return* icon; } -/*! +/* Returns the plugin database object. -*/ + QWebPluginDatabase *QWebSettings::pluginDatabase() { static QWebPluginDatabase* database = 0; @@ -635,6 +568,7 @@ QWebPluginDatabase *QWebSettings::pluginDatabase() database = new QWebPluginDatabase(); return database; } +*/ /*! Sets \a graphic to be drawn when QtWebKit needs to draw an image of the @@ -710,7 +644,9 @@ void QWebSettings::clearMemoryCaches() */ void QWebSettings::setMaximumPagesInCache(int pages) { + QWebSettingsPrivate* global = QWebSettings::globalSettings()->d; WebCore::pageCache()->setCapacity(qMax(0, pages)); + global->apply(); } /*! diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h index e68ea53..69f3b11 100644 --- a/WebKit/qt/Api/qwebsettings.h +++ b/WebKit/qt/Api/qwebsettings.h @@ -67,14 +67,14 @@ public: LocalStorageDatabaseEnabled = LocalStorageEnabled, #endif LocalContentCanAccessRemoteUrls, - SessionStorageEnabled, DnsPrefetchEnabled }; enum WebGraphic { MissingImageGraphic, MissingPluginGraphic, DefaultFrameIconGraphic, - TextAreaSizeGripCornerGraphic + TextAreaSizeGripCornerGraphic, + DeleteButtonGraphic }; enum FontSize { MinimumFontSize, @@ -103,18 +103,12 @@ public: void setDefaultTextEncoding(const QString &encoding); QString defaultTextEncoding() const; - void setPrintingMinimumShrinkFactor(float printingMinimumShrinkFactor); - float printingMinimumShrinkFactor() const; - - void setPrintingMaximumShrinkFactor(float printingMaximimShrinkFactor); - float printingMaximumShrinkFactor() const; - static void setIconDatabasePath(const QString &location); static QString iconDatabasePath(); static void clearIconDatabase(); static QIcon iconForUrl(const QUrl &url); - static QWebPluginDatabase *pluginDatabase(); + //static QWebPluginDatabase *pluginDatabase(); static void setWebGraphic(WebGraphic type, const QPixmap &graphic); static QPixmap webGraphic(WebGraphic type); diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp index 4fa073d..7bc3168 100644 --- a/WebKit/qt/Api/qwebview.cpp +++ b/WebKit/qt/Api/qwebview.cpp @@ -32,11 +32,8 @@ #include "qprinter.h" #include "qdir.h" #include "qfile.h" -#if defined(Q_WS_X11) -#include <QX11Info> -#endif -class QWebViewPrivate : public QWebPageClient { +class QWebViewPrivate { public: QWebViewPrivate(QWebView *view) : view(view) @@ -46,24 +43,6 @@ public: Q_ASSERT(view); } - virtual void scroll(int dx, int dy, const QRect&); - virtual void update(const QRect& dirtyRect); - virtual void setInputMethodEnabled(bool enable); -#if QT_VERSION >= 0x040600 - virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); -#endif - -#ifndef QT_NO_CURSOR - virtual QCursor cursor() const; - virtual void updateCursor(const QCursor& cursor); -#endif - - virtual QPalette palette() const; - virtual int screenNumber() const; - virtual QWidget* ownerWidget() const; - - virtual QObject* pluginParent() const; - void _q_pageDestroyed(); QWebView *view; @@ -72,66 +51,6 @@ public: QPainter::RenderHints renderHints; }; -void QWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) -{ - view->scroll(qreal(dx), qreal(dy), rectToScroll); -} - -void QWebViewPrivate::update(const QRect & dirtyRect) -{ - view->update(dirtyRect); -} - -void QWebViewPrivate::setInputMethodEnabled(bool enable) -{ - view->setAttribute(Qt::WA_InputMethodEnabled, enable); -} -#if QT_VERSION >= 0x040600 -void QWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable) -{ - if (enable) - view->setInputMethodHints(view->inputMethodHints() | hint); - else - view->setInputMethodHints(view->inputMethodHints() & ~hint); -} -#endif -#ifndef QT_NO_CURSOR -QCursor QWebViewPrivate::cursor() const -{ - return view->cursor(); -} - -void QWebViewPrivate::updateCursor(const QCursor& cursor) -{ - view->setCursor(cursor); -} -#endif - -QPalette QWebViewPrivate::palette() const -{ - return view->palette(); -} - -int QWebViewPrivate::screenNumber() const -{ -#if defined(Q_WS_X11) - if (view) - return view->x11Info().screen(); -#endif - - return 0; -} - -QWidget* QWebViewPrivate::ownerWidget() const -{ - return view; -} - -QObject* QWebViewPrivate::pluginParent() const -{ - return view; -} - void QWebViewPrivate::_q_pageDestroyed() { page = 0; @@ -151,7 +70,7 @@ void QWebViewPrivate::_q_pageDestroyed() It can be used in various applications to display web content live from the Internet. - The image below shows QWebView previewed in \QD with the Trolltech website. + The image below shows QWebView previewed in \QD with a Nokia website. \image qwebview-url.png @@ -251,6 +170,7 @@ QWebView::~QWebView() #else d->page->d->view = 0; #endif + delete d->page->d->client; d->page->d->client = 0; } @@ -296,16 +216,15 @@ void QWebView::setPage(QWebPage* page) d->page = page; if (d->page) { d->page->setView(this); - d->page->d->client = d; // set the page client d->page->setPalette(palette()); // #### connect signals QWebFrame *mainFrame = d->page->mainFrame(); - connect(mainFrame, SIGNAL(titleChanged(const QString&)), - this, SIGNAL(titleChanged(const QString&))); + connect(mainFrame, SIGNAL(titleChanged(QString)), + this, SIGNAL(titleChanged(QString))); connect(mainFrame, SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(mainFrame, SIGNAL(urlChanged(const QUrl &)), - this, SIGNAL(urlChanged(const QUrl &))); + connect(mainFrame, SIGNAL(urlChanged(QUrl)), + this, SIGNAL(urlChanged(QUrl))); connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); @@ -313,10 +232,10 @@ void QWebView::setPage(QWebPage* page) this, SIGNAL(loadProgress(int))); connect(d->page, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool))); - connect(d->page, SIGNAL(statusBarMessage(const QString &)), - this, SIGNAL(statusBarMessage(const QString &))); - connect(d->page, SIGNAL(linkClicked(const QUrl &)), - this, SIGNAL(linkClicked(const QUrl &))); + connect(d->page, SIGNAL(statusBarMessage(QString)), + this, SIGNAL(statusBarMessage(QString))); + connect(d->page, SIGNAL(linkClicked(QUrl)), + this, SIGNAL(linkClicked(QUrl))); connect(d->page, SIGNAL(microFocusChanged()), this, SLOT(updateMicroFocus())); @@ -328,84 +247,11 @@ void QWebView::setPage(QWebPage* page) } /*! - Returns a valid URL from a user supplied \a string if one can be deducted. - In the case that is not possible, an invalid QUrl() is returned. - - \since 4.6 - - Most applications that can browse the web, allow the user to input a URL - in the form of a plain string. This string can be manually typed into - a location bar, obtained from the clipboard, or passed in via command - line arguments. - - When the string is not already a valid URL, a best guess is performed, - making various web related assumptions. - - In the case the string corresponds to a valid file path on the system, - a file:// URL is constructed, using QUrl::fromLocalFile(). - - If that is not the case, an attempt is made to turn the string into a - http:// or ftp:// URL. The latter in the case the string starts with - 'ftp'. The result is then passed through QUrl's tolerant parser, and - in the case or success, a valid QUrl is returned, or else a QUrl(). - - \section1 Examples: - - \list - \o webkit.org becomes http://webkit.org - \o ftp.webkit.org becomes ftp://ftp.webkit.org - \o localhost becomes http://localhost - \o /home/user/test.html becomes file:///home/user/test.html (if exists) - \endlist - - \section2 Tips when dealing with URLs and strings: - - \list - \o When creating a QString from a QByteArray or a char*, always use - QString::fromUtf8(). - \o Do not use QUrl(string), nor QUrl::toString() anywhere where the URL might - be used, such as in the location bar, as those functions loose data. - Instead use QUrl::fromEncoded() and QUrl::toEncoded(), respectively. - \endlist - */ -QUrl QWebView::guessUrlFromString(const QString &string) -{ - QString trimmedString = string.trimmed(); - - // Check the most common case of a valid url with scheme and host first - QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode); - if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) - return url; - - // Absolute files that exists - if (QDir::isAbsolutePath(trimmedString) && QFile::exists(trimmedString)) - return QUrl::fromLocalFile(trimmedString); - - // If the string is missing the scheme or the scheme is not valid prepend a scheme - QString scheme = url.scheme(); - if (scheme.isEmpty() || scheme.contains(QLatin1Char('.')) || scheme == QLatin1String("localhost")) { - // Do not do anything for strings such as "foo", only "foo.com" - int dotIndex = trimmedString.indexOf(QLatin1Char('.')); - if (dotIndex != -1 || trimmedString.startsWith(QLatin1String("localhost"))) { - const QString hostscheme = trimmedString.left(dotIndex).toLower(); - QByteArray scheme = (hostscheme == QLatin1String("ftp")) ? "ftp" : "http"; - trimmedString = QLatin1String(scheme) + QLatin1String("://") + trimmedString; - } - url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode); - } - - if (url.isValid()) - return url; - - return QUrl(); -} - -/*! Loads the specified \a url and displays it. \note The view remains the same until enough data has arrived to display the new \a url. - \sa setUrl(), url(), urlChanged(), guessUrlFromString() + \sa setUrl(), url(), urlChanged(), QUrl::fromUserInput() */ void QWebView::load(const QUrl &url) { @@ -424,19 +270,11 @@ void QWebView::load(const QUrl &url) \sa url(), urlChanged() */ -#if QT_VERSION < 0x040400 && !defined(qdoc) -void QWebView::load(const QWebNetworkRequest &request) -#else void QWebView::load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &body) -#endif { - page()->mainFrame()->load(request -#if QT_VERSION >= 0x040400 - , operation, body -#endif - ); + page()->mainFrame()->load(request, operation, body); } /*! @@ -790,7 +628,6 @@ bool QWebView::event(QEvent *e) if (e->type() == QEvent::ShortcutOverride) { d->page->event(e); #ifndef QT_NO_CURSOR -#if QT_VERSION >= 0x040400 } else if (e->type() == QEvent::CursorChange) { // An unsetCursor will set the cursor to Qt::ArrowCursor. // Thus this cursor change might be a QWidget::unsetCursor() @@ -801,8 +638,7 @@ bool QWebView::event(QEvent *e) // WebCore. // FIXME: Add a QEvent::CursorUnset or similar to Qt. if (cursor().shape() == Qt::ArrowCursor) - d->resetCursor(); -#endif + d->page->d->client->resetCursor(); #endif } else if (e->type() == QEvent::Leave) d->page->event(e); @@ -913,8 +749,12 @@ void QWebView::paintEvent(QPaintEvent *ev) } /*! - This function is called whenever WebKit wants to create a new window of the given \a type, for example as a result of - a JavaScript request to open a document in a new window. + This function is called from the createWindow() method of the associated QWebPage, + each time the page wants to create a new window of the given \a type. This might + be the result, for example, of a JavaScript request to open a document in a new window. + + \note If the createWindow() method of the associated page is reimplemented, this + method is not called, unless explicitly done so in the reimplementation. \sa QWebPage::createWindow() */ @@ -1128,7 +968,7 @@ void QWebView::changeEvent(QEvent *e) /*! \fn void QWebView::statusBarMessage(const QString& text) - This signal is emitted when the statusbar \a text is changed by the page. + This signal is emitted when the status bar \a text is changed by the page. */ /*! diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h index b63a593..d7910d9 100644 --- a/WebKit/qt/Api/qwebview.h +++ b/WebKit/qt/Api/qwebview.h @@ -27,9 +27,7 @@ #include <QtGui/qicon.h> #include <QtGui/qpainter.h> #include <QtCore/qurl.h> -#if QT_VERSION >= 0x040400 #include <QtNetwork/qnetworkaccessmanager.h> -#endif QT_BEGIN_NAMESPACE class QNetworkRequest; @@ -65,16 +63,10 @@ public: QWebPage* page() const; void setPage(QWebPage* page); - static QUrl guessUrlFromString(const QString& string); - void load(const QUrl& url); -#if QT_VERSION < 0x040400 && !defined(qdoc) - void load(const QWebNetworkRequest& request); -#else void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray()); -#endif void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index 67cf7f3..2c2722b 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,1237 @@ +2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Improve the autotests of QtWebkit + https://bugs.webkit.org/show_bug.cgi?id=32216 + + Remove the calls to qWait() of the autotest of QWebView + + * tests/qwebview/tst_qwebview.cpp: + (tst_QWebView::reusePage): + +2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Improve the autotests of QtWebkit + https://bugs.webkit.org/show_bug.cgi?id=32216 + + Refactor tst_qwebframe to remove qWait() and use + the function waitForSignal() from util.h + + * tests/qwebframe/tst_qwebframe.cpp: + +2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Improve the autotests of QtWebkit + https://bugs.webkit.org/show_bug.cgi?id=32216 + + Refactor the test of QGraphicsWebView: + -make waitForSignal() available to all the tests. + -remove QTest::qWait() + + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::crashOnViewlessWebPages): + * tests/util.h: + (waitForSignal): + +2009-12-07 Girish Ramakrishnan <girish@forwardbias.in> + + Reviewed by Simon Hausmann. + + [Qt] Plugins: Force windowless mode when there is no native window handle + + Inject wmode=opaque while instantiating the plugin for the case when the + webpage is not backed by a native window handle. + + https://bugs.webkit.org/show_bug.cgi?id=32059 + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::createPlugin): + +2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Corrects QtLauncher style + + * QtLauncher/main.cpp: + (WebPage::acceptNavigationRequest): + (MainWindow::MainWindow): + (MainWindow::webPage): + (MainWindow::webView): + (MainWindow::changeLocation): + (MainWindow::loadFinished): + (MainWindow::showLinkHover): + (MainWindow::zoomIn): + (MainWindow::zoomOut): + (MainWindow::print): + (MainWindow::setEditable): + (MainWindow::dumpHtml): + (MainWindow::selectElements): + (MainWindow::newWindow): + (MainWindow::setupUI): + (WebPage::createWindow): + (WebPage::createPlugin): + (main): + +2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QtLauncher: add a menu to show or hide the web inspector. + https://bugs.webkit.org/show_bug.cgi?id=32149 + + * QtLauncher/main.cpp: + (WebInspector::WebInspector): + (WebInspector::showEvent): + (WebInspector::hideEvent): + (MainWindow::MainWindow): + (MainWindow::setupUI): + +2009-12-04 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Antti Koivisto. + + Split out the renderPrivate in two methods, one for working on + relative coordinates (relative to the viewport) and one for + working on absolute coordinates. The latter is more effecient + for implementing tiling, as you don't need translate the coords, + and because it avoid clipping to the viewport. + + No behaviour changes, so no new tests. + + * Api/qwebframe.cpp: + (QWebFramePrivate::renderContentsLayerAbsoluteCoords): + (QWebFramePrivate::renderRelativeCoords): + (QWebFrame::render): + * Api/qwebframe_p.h: + +2009-12-04 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Allow removing 'qrc' as a local security origin scheme + + * tests/qwebpage/tst_qwebpage.cpp: + +2009-12-04 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Clean up argument parsing in the QtLauncher + + * QtLauncher/main.cpp: + +2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Prevent the inspector from closing its wrapping widget. + This is not necessary anymore since we now hide the embedded + close button. + https://bugs.webkit.org/show_bug.cgi?id=32149 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::showWindow): + (WebCore::InspectorClientQt::closeWindow): + +2009-12-03 İsmail Dönmez <ismail@namtrac.org> + + Reviewed by Eric Seidel. + + Fix compilation when SVG is disabled. + + * Api/qwebframe.cpp: + (qt_drt_pauseSVGAnimation): + +2009-12-03 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7214236> and http://webkit.org/b/32052 - Implement HTML5 state object history API + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidPushStateWithinPage): + (WebCore::FrameLoaderClientQt::dispatchDidReplaceStateWithinPage): + (WebCore::FrameLoaderClientQt::dispatchDidPopStateWithinPage): + * WebCoreSupport/FrameLoaderClientQt.h: + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::populateSetting): + (WebCore::InspectorClientQt::storeSetting): + (WebCore::variantToSetting): + (WebCore::settingToVariant): + * WebCoreSupport/InspectorClientQt.h: + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebCore::FrameLoaderClientQt::dispatchDidRemoveBackForwardItem): ditto. + (WebCore::FrameLoaderClientQt::dispatchDidChangeBackForwardIndex): ditto. + * WebCoreSupport/FrameLoaderClientQt.h: + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Not reviewed. Try to fix Qt build. + + * Api/qwebframe.cpp: + (qt_drt_pauseSVGAnimation): + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Simon Fraser. + + Add SVG animation test framework with 'snapshot' functionality + https://bugs.webkit.org/show_bug.cgi?id=31897 + + Add API used by the new 'sampleSVGAnimationForElementAtTime' DRT method, + forwarding the call to SVGDocumentExtensions, if SVG is enabled. + + Implemented just like the existing pauseAnimation* methods for CSS animations. + + * Api/qwebframe.cpp: + (qt_drt_pauseSVGAnimation): + +2009-12-01 Daniel Bates <dbates@webkit.org> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=31898 + + Makes QtLauncher default to the http scheme for URLs. + + * QtLauncher/main.cpp: + (MainWindow::MainWindow): + (MainWindow::changeLocation): + (main): + +2009-11-30 Abhinav Mithal <abhinav.mithal@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt][Symbian] Report SymbianOS in user agent string for Symbian + https://bugs.webkit.org/show_bug.cgi?id=31961 + + * Api/qwebpage.cpp: + (QWebPage::userAgentForUrl): + +2009-11-30 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix minor waning in QtWebKit + https://bugs.webkit.org/show_bug.cgi?id=31963 + + * tests/qwebpage/tst_qwebpage.cpp: + (ErrorPage::extension): Remove info wariable as it is + not used. + +2009-11-28 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] SoftwareInputPanelRequest event sent when clicking in newly loaded page + + https://bugs.webkit.org/show_bug.cgi?id=31401 + + Don't set the event unless there is a focused node we can use + for editing afterwards. + + * Api/qwebpage.cpp: + (QWebPagePrivate::handleSoftwareInputPanel): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods): + +2009-11-26 Simon Hausmann <simon.hausmann@nokia.com> + + Rubber-stamped by Holger Freyther. + + Removed unused ICO image plugin handler. + + * Plugins/ICOHandler.cpp: Removed. + * Plugins/ICOHandler.h: Removed. + * Plugins/Plugins.pro: Removed. + +2009-11-12 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Do not show the QWidget when the WebCore::Widget is hidden + https://bugs.webkit.org/show_bug.cgi?id=31203 + + The clipping code was making a QWidget visible even if the + WebCore::Widget was hidden. Fix the bug by calling setVisible + only if the WebCore::Widget Widget::isSelfVisible. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::QtPluginWidget::show): Override WebCore::Widget::show to call handleVisibility + (WebCore::QtPluginWidget::handleVisibility): New method to call setVisible when we are visible + (FrameLoaderClientQt::createPlugin): Hide the QWidget by default + +2009-11-23 David Boddie <dboddie@trolltech.com> + + Reviewed by Simon Hausmann. + + Updated the QWebElement documentation with links to examples and + external resources. + Fixed the project file for the webelement snippet and tidied up the + markers used for quoting the code. + + * Api/qwebelement.cpp: + * docs/webkitsnippets/webelement/main.cpp: + (findAll): + * docs/webkitsnippets/webelement/webelement.pro: + +2009-11-23 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Wrong runtime instance objects of wrapped QObjects may be used if + the wrapped object died before the gc removed the instance. + + https://bugs.webkit.org/show_bug.cgi?id=31681 + + Added a unit-test to verify that wrapping a QObject with the + same identity as a previously but now dead object works. + + * tests/qwebframe/tst_qwebframe.cpp: + +2009-11-19 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Add instantiation tests for QWebInspector. + + * tests/qwebinspector/qwebinspector.pro: Added. + * tests/qwebinspector/tst_qwebinspector.cpp: Added. + (tst_QWebInspector::attachAndDestroy): + * tests/tests.pro: + +2009-11-19 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix QWebInspector destruction problem. + https://bugs.webkit.org/show_bug.cgi?id=31664 + + * Api/qwebpage.cpp: + (QWebPage::~QWebPage): + +2009-11-19 Olivier Goffart <ogoffart@trolltech.com> + + Reviewed by Simon Hausmann. + + [Qt] Normalize signal and slot signatures. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::setPage): + * Api/qwebview.cpp: + (QWebView::setPage): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::setFrame): + * docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp: + (wrapInFunction): + * tests/qwebframe/tst_qwebframe.cpp: + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::modified): + (tst_QWebPage::database): + +2009-11-18 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Remove support for Qt v4.3 or older versions + https://bugs.webkit.org/show_bug.cgi?id=29469 + + * Api/qcookiejar.cpp: Removed. + * Api/qcookiejar.h: Removed. + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::event): + * Api/qwebframe.cpp: + (QWebFrame::load): + * Api/qwebframe.h: + * Api/qwebkitglobal.h: + * Api/qwebnetworkinterface.cpp: Removed. + * Api/qwebnetworkinterface.h: Removed. + * Api/qwebnetworkinterface_p.h: Removed. + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + (QWebPagePrivate::acceptNavigationRequest): + (QWebPage::acceptNavigationRequest): + (QWebPage::action): + (QWebPage::userAgentForUrl): + * Api/qwebpage.h: + * Api/qwebpage_p.h: + * Api/qwebview.cpp: + (QWebView::load): + (QWebView::event): + * Api/qwebview.h: + * QtLauncher/main.cpp: + (MainWindow::print): + (MainWindow::setupUI): + (main): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::download): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): + (WebCore::FrameLoaderClientQt::startDownload): + (WebCore::FrameLoaderClientQt::createPlugin): + +2009-11-18 Shu Chang <Chang.Shu@nokia.com> + + Reviewed by Eric Seidel. + + [Qt] Add support for displaying deleteButton. + https://bugs.webkit.org/show_bug.cgi?id=31560 + + Test: LayoutTests/editing/deleting/5408255.html + + * Api/qwebsettings.cpp: + (graphics): + * Api/qwebsettings.h: + +2009-11-18 Paul Olav Tvete <paul.tvete@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Make the QWebElement::render() test pass when pixmaps aren't 32 bit. + + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::render): + +2009-11-18 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + Clarify and simplify the legal section in the overview documentation, + after review with our legal team. + + * docs/qtwebkit.qdoc: + +2009-11-18 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Add QtLauncher support for opening links in the default browser + + This can be triggered by either the context menu or by clicking a link + while holding down the Alt key. Opening a link in a new windows is + triggered by holding down Shift. + + * QtLauncher/main.cpp: + +2009-11-17 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QGLLauncher does not support drag&drop of local files + https://bugs.webkit.org/show_bug.cgi?id=31057 + + Enable accepting files in QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::QGraphicsWebView): + (QGraphicsWebView::dragEnterEvent): + +2009-11-17 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Kenneth Christiansen. + + [Qt] better test coverage for ErrorPageExtension + https://bugs.webkit.org/show_bug.cgi?id=31583 + + Improved the coverage of current ErrorPageExtension tests by + adding autotests involving frameset and iframes. + + * tests/qwebpage/tst_qwebpage.cpp: + (ErrorPage::extension): Make the ErrorPageExtension + to work for all frames, not only the main frame. + (tst_QWebPage::errorPageExtension): Stop using + the 'frameset.html' resouce in this method since + an autotest specific for frameset's is being added. + (tst_QWebPage::errorPageExtensionInIFrames): Added. + (tst_QWebPage::errorPageExtensionInFrameset): Added. + +2009-11-16 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + API documentation fixes. + + * Api/qgraphicswebview.cpp: Removed duplicate docs. + * Api/qwebelement.cpp: Added missing docs. + * Api/qwebsettings.cpp: Ditto. + +2009-11-14 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Antti Koivisto. + + [Qt] Broken back/forward after using ErrorPageExtension to set error page + https://bugs.webkit.org/show_bug.cgi?id=30573 + + Implemented autotests for covering the back/forward + reset problem involving error pages. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::errorPageExtension): + +2009-11-13 Adam Roben <aroben@apple.com> + + Update for changes to FrameLoaderClient + + Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when + window objects in isolated worlds are cleared + + Reviewed by Dave Hyatt. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld): + * WebCoreSupport/FrameLoaderClientQt.h: + Replaced windowObjectCleared with this function. Does nothing if the + passed-in world is not the mainThreadNormalWorld(). + +2009-11-13 Andras Becsi <becsi.andras@stud.u-szeged.hu> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Enable Page Cache if setMaximumPagesInCache needs it. + This fixes https://bugs.webkit.org/show_bug.cgi?id=31266. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + (QWebSettings::setMaximumPagesInCache): + +2009-11-13 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix initial QWebView focus behavior. + + focusController->setFocused(true) was not always called. + https://bugs.webkit.org/show_bug.cgi?id=31466 + + * Api/qwebpage.cpp: + (QWebPagePrivate::focusInEvent): + +2009-11-13 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + Update documentation for the Qt API + + * Api/qgraphicswebview.cpp: + * Api/qwebelement.cpp: + * Api/qwebframe.cpp: + * Api/qwebsettings.cpp: + * Api/qwebview.cpp: + +2009-11-13 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + Use correct install-path when running qdoc3 + + * docs/docs.pri: + +2009-11-12 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Darin Adler. + + externalRepresentation should take Frame as the argument + https://bugs.webkit.org/show_bug.cgi?id=31393 + + No new tests as this is just a refactoring. + + * Api/qwebframe.cpp: + (QWebFrame::renderTreeDump): + +2009-11-12 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Jan Alonzo. + + [Qt] Various doc fixes + https://bugs.webkit.org/show_bug.cgi?id=31358 + + QWebPage's constructor docs are mentioning "QWebView": + "Constructs an empty QWebView with parent". + + * Api/qwebpage.cpp: + +2009-11-12 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + Custom printing shrink factors + https://bugs.webkit.org/show_bug.cgi?id=29042 + + This reverts commit r49769. The public API for this needs to be reviewed + before its inclusion in Qt. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + (QWebSettings::QWebSettings): + * Api/qwebsettings.h: + +2009-11-11 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Kenneth Christiansen. + + [Qt] Various doc fixes + https://bugs.webkit.org/show_bug.cgi?id=31358 + + Fixed wrong documentation: item's dimensions do fit to Web page + content by default. + + Kenneth agreed to land this as a followup patch to the + just landed documentation patch. + + * Api/qgraphicswebview.cpp: + +2009-11-11 David Boddie <dboddie@trolltech.com> + + Reviewed by Kenneth Christiansen. + + [Qt] Various doc fixes + https://bugs.webkit.org/show_bug.cgi?id=31323 + + Fixed and synchronized QWebView related documentation. + + * Api/qgraphicswebview.cpp: + * Api/qwebview.cpp: + +2009-11-11 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Unreviewed buildbot fix. + + Export a method to the DRT to know if the document has a + document element. + + * Api/qwebframe.cpp: + (qt_drt_hasDocumentElement): + +2009-11-11 Liang QI <liang.qi@nokia.com> + + [Qt] Fix tst_qwebpage and tst_qwebframe compilation on Symbian. + + * tests/qwebframe/qwebframe.pro: + * tests/qwebframe/tst_qwebframe.cpp: + * tests/qwebpage/qwebpage.pro: + * tests/qwebpage/tst_qwebpage.cpp: + +2009-11-11 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Simon Hausmann. + + Fix a crash in the layout test plugins/document-open.html + + * Api/qwebframe.cpp: + (QWebFrame::toPlainText): + +2009-11-11 Warwick Allison <warwick.allison@nokia.com>, Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Regression: Preserve the parent of plugin objects when using + QtWebKit with only a QWebPage. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::createPlugin): Don't reparent + plugins to 0. + * tests/qwebpage/tst_qwebpage.cpp: + (PluginCounterPage::PluginCounterPage): Initialize m_pluginParent to 0. + (PluginCounterPage::~PluginCounterPage): Delete the plugin parent later + (after the page) + (PluginTracerPage::createPlugin): Assign a dummy parent to the plugin. + (PluginTracerPage::PluginTracerPage): Set up the plugin parent. + (tst_QWebPage::createViewlessPlugin): Verify that for viewless pages the + plugin parent remains unchanged. + +2009-11-11 David Boddie <dboddie@trolltech.com> + + [Qt] Doc: Added internal or hidden placeholder documentation. + + * Api/qwebpage.cpp: + +2009-11-11 Martin Smith <msmith@trolltech.com> + + [Qt] doc: Changed Trolltech to Nokia + + * Api/qwebview.cpp: + +2009-11-11 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=31323 + Fix a few compiler warnings + + * tests/qwebframe/tst_qwebframe.cpp: Add extra brackets + to make it explicit where the else case belongs + +2009-11-11 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + Fix enabling of software input panel when activating editable elements + in QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::inputMethodEnabled): Implement method to + query for input method support. + * Api/qwebpage.cpp: + (QWebPageWidgetClient::inputMethodEnabled): Ditto for QWidget. + (QWebPagePrivate::handleSoftwareInputPanel): Don't use view() to + test for input method support. Instead query using QWebPageClient + and send the SIPR event to the ownerWidget() instead of the view(). + The latter is null for QGraphicsWebView. + * tests/qwebpage/tst_qwebpage.cpp: + (EventSpy::EventSpy): + (EventSpy::eventFilter): + (tst_QWebPage::inputMethods): Modify the test to verify that SIPR + events are dispatched when activating focusable content. + +2009-11-10 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Unreviewed documentation fixes. + + Added a few improvements from Jocelyn Turcotte to the + createWindow docs. + + * Api/qwebview.cpp: + +2009-11-10 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Unreviewed documentation fix. + + [Qt] Make qwebpage's createWindow not qwebview dependent. + https://bugs.webkit.org/show_bug.cgi?id=30771 + + Update documentation to make it clear that a reimplementation + of the createWindow method of the associated QWebPage can + result in the QWebView::createWindow method to never be called. + + * Api/qwebview.cpp: + +2009-11-09 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Few classes have virtual functions but non-virtual destructor + https://bugs.webkit.org/show_bug.cgi?id=31269 + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate): Add virtual + destructor. + +2009-11-09 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=30628 + Add an API to get all the attributes from a QWebElement. + + * Api/qwebelement.cpp: + (QWebElement::attributesName): + * Api/qwebelement.h: + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::listAttributes): + +2009-11-09 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + Use explicit parentheses to silence gcc 4.4 -Wparentheses warnings + https://bugs.webkit.org/show_bug.cgi?id=31040 + + * Api/qwebpage.cpp: + (QWebPagePrivate::handleScrolling): + +2009-11-09 Mark Mentovai <mark@chromium.org> + + Reviewed by Dan Bernstein. + + Track "can have scrollbar" state within FrameView independently of the + individual scrollbar states in ScrollView. + + rdar://problem/7215132, https://bugs.webkit.org/show_bug.cgi?id=29167 + REGRESSION (r48064): mint.com loses scrollbars after coming out of + edit mode. + + rdar://problem/7314421, https://bugs.webkit.org/show_bug.cgi?id=30517 + REGRESSION (r48064): Extra scroll bars in GarageBand Lesson Store. + + Test: fast/overflow/scrollbar-restored.html + + * Api/qwebframe.cpp: + (QWebFrame::setScrollBarPolicy): + +2009-11-09 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=30772 + Add a non-const iterator to QWebElementCollection. + Move the two attributes of the iterator to private. + + * Api/qwebelement.h: + (const_iterator::begin): + (const_iterator::end): + (const_iterator::constBegin): + (const_iterator::constEnd): + (const_iterator::iterator::iterator): + (const_iterator::iterator::operator*): + (const_iterator::iterator::operator==): + (const_iterator::iterator::operator!=): + (const_iterator::iterator::operator<): + (const_iterator::iterator::operator<=): + (const_iterator::iterator::operator>): + (const_iterator::iterator::operator>=): + (const_iterator::iterator::operator++): + (const_iterator::iterator::operator--): + (const_iterator::iterator::operator+=): + (const_iterator::iterator::operator-=): + (const_iterator::iterator::operator+): + (const_iterator::iterator::operator-): + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::nonConstIterator): + (tst_QWebElement::constIterator): + +2009-11-09 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Christiansen. + + [Qt] Remove the sessionStorage setting (per Page) + https://bugs.webkit.org/show_bug.cgi?id=31249 + + This setting allows to run sessionStorage on/off on a per page + basis. Remove this prematurely exposed API. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + (QWebSettings::QWebSettings): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::database): + (tst_QWebPage::testOptionalJSObjects): + +2009-11-09 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Remove the QWebPage:webInspectorTriggered signal. + User customization of the communication between QWebPage + and QWebInspector will be properly designed in the next version. + https://bugs.webkit.org/show_bug.cgi?id=30773 + + * Api/qwebinspector.cpp: + * Api/qwebpage.cpp: + (QWebPagePrivate::getOrCreateInspector): + (QWebPage::triggerAction): + * Api/qwebpage.h: + * QtLauncher/main.cpp: + (MainWindow::MainWindow): + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Added a missing re-implementation of QGraphicsItem::inputMethodQuery(). + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::inputMethodQuery): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Provide a dummy re-implementation of QGraphicsLayoutItem::sizeHint(), + similar to QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::sizeHint): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Removed zoomFactoryChanged() signal and added + linkClicked() to QGraphicsWebView, for consistency with + QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::setPage): + (QGraphicsWebView::setZoomFactor): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Added QGraphicsWebView::findText() for convenience and consistency + with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::findText): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Added QGraphicsWebView::pageAction() and triggerPageAction(), for + consistency with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::pageAction): + (QGraphicsWebView::triggerPageAction): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Removed QGraphicsWebView::toHtml() after API review. + + That's consistent with QWebView and also based on the assumption that + toHtml() is called less frequently than setHtml(). + + * Api/qgraphicswebview.cpp: + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Removed the interactive property of QGraphicsWebView. + + There are clearly use-cases for this feature, but it will require + more work to make this fully work with an enum to have fine-grained + control over the interactivity levels. For now it is easy to achieve + in user-code what the boolean property did. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebView::hoverMoveEvent): + (QGraphicsWebView::mouseMoveEvent): + (QGraphicsWebView::mousePressEvent): + (QGraphicsWebView::mouseReleaseEvent): + (QGraphicsWebView::mouseDoubleClickEvent): + (QGraphicsWebView::keyPressEvent): + (QGraphicsWebView::keyReleaseEvent): + (QGraphicsWebView::dragLeaveEvent): + (QGraphicsWebView::dragMoveEvent): + (QGraphicsWebView::dropEvent): + (QGraphicsWebView::wheelEvent): + (QGraphicsWebView::inputMethodEvent): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Make the QGraphicsWebView constructor explicit. + + * Api/qgraphicswebview.h: + +2009-11-05 Shu Chang <Chang.Shu@nokia.com> + + Reviewed by Tor Arne Vestbø. + + Add support for Shift-PageUp and Shift-PageDown key events. + https://bugs.webkit.org/show_bug.cgi?id=31166 + + Test: LayoutTests/editing/selection/shrink-selection-after-shift-pagedown.html + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::handleKeyboardEvent): + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Last Qt 4.5 build fix (*sigh*) + + * tests/qwebpage/tst_qwebpage.cpp: + (inputMethodHints): inputMethodHints() is only used for + Qt 4.6, so guard the whole function. + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Another prospective build fix against Qt 4.5 (build bot) + + Don't compile & run the QGraphicsWebView portion of the + input methods auto test with Qt 4.5. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods_data): + (inputMethodHints): + (inputMethodEnabled): + (tst_QWebPage::inputMethods): + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Prospective build fix against Qt 4.5 (build bot) + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::setInputMethodEnabled): Guard the + use of Qt 4.6 specific API with #ifdefs. + +2009-11-01 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Kenneth Christiansen. + + [Qt] Fix enabling of input method support on QGraphicsWebView. + https://bugs.webkit.org/show_bug.cgi?id=30605 + + Instead of setting the unsupported widget attribute on the + QGraphicsWidget in setInputMethodEnabled() set the + ItemAcceptsInputMethod GraphicsItem flag directly. + + Changed the existing input method auto test to run once + on a QWebView and once on a QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::setInputMethodEnabled): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods_data): + (inputMethodHints): + (inputMethodEnabled): + (tst_QWebPage::inputMethods): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Kenneth Christiansen. + + Added QGraphicsWebView::modified property, for consistency + with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::isModified): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Kenneth Christiansen. + + Removed status and progress properties of QGraphicsWebView. + Added loadProgress and statusBarMessage signals instead, + after API review. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebView::setPage): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] REGRESSION: Allow applications to use their own QWidget bypassing QWebView. + https://bugs.webkit.org/show_bug.cgi?id=30979 + + Decouple QWebViewPrivate from QWebPageClient, and automatically create + QWebPageWidgetClient whenever the view is QWidget based. + + * Api/qwebpage.cpp: + (QWebPageWidgetClient::QWebPageWidgetClient): + (QWebPageWidgetClient::scroll): + (QWebPageWidgetClient::update): + (QWebPageWidgetClient::setInputMethodEnabled): + (QWebPageWidgetClient::setInputMethodHint): + (QWebPageWidgetClient::cursor): + (QWebPageWidgetClient::updateCursor): + (QWebPageWidgetClient::palette): + (QWebPageWidgetClient::screenNumber): + (QWebPageWidgetClient::ownerWidget): + (QWebPageWidgetClient::pluginParent): + (QWebPage::setView): + * Api/qwebview.cpp: + (QWebView::~QWebView): + (QWebView::setPage): + (QWebView::event): + +2009-11-03 Andras Becsi <becsi.andras@stud.u-szeged.hu> + + Reviewed by Simon Hausmann. + + [Qt] Fix build of unit-test after r50454. + + * tests/qwebpage/tst_qwebpage.cpp: + +2009-11-03 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Make QWebPluginDatabase private API for now. + + https://bugs.webkit.org/show_bug.cgi?id=30775 + + * Api/headers.pri: + * Api/qwebplugindatabase.cpp: + * Api/qwebplugindatabase_p.h: Renamed from WebKit/qt/Api/qwebplugindatabase.h. + * Api/qwebsettings.cpp: + * Api/qwebsettings.h: + * QtLauncher/main.cpp: + (MainWindow::setupUI): + * tests/tests.pro: + +2009-11-03 Simon Hausmann <hausmann@webkit.org> + + Rubber-stamped by Tor Arne Vestbø. + + Oops, also remove the API docs of the removed networkRequestStarted() signal. + + * Api/qwebpage.cpp: + +2009-11-03 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Replace the QWebPage::networkRequestStarted() signal with the originatingObject + property set to the QWebFrame that belongs to the request. + + https://bugs.webkit.org/show_bug.cgi?id=29975 + + * Api/qwebpage.h: + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): + (WebCore::FrameLoaderClientQt::startDownload): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::loadFinished): + (TestNetworkManager::createRequest): + (tst_QWebPage::originatingObjectInNetworkRequests): + +2009-11-02 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> + + Reviewed by Adam Barth. + + QWebView crash fix. + + The QWebView should not crash if the stop() method is called from + a function triggered by the loadProgress signal. + + A null pointer protection was added in the ProgressTracker::incrementProgress. + + New autotest was created. + + https://bugs.webkit.org/show_bug.cgi?id=29425 + + * tests/qwebview/tst_qwebview.cpp: + (WebViewCrashTest::WebViewCrashTest): + (WebViewCrashTest::loading): + (tst_QWebView::crashTests): + +2009-11-01 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Eric Seidel. + + Turn on warnings for QtWebKit for gcc + https://bugs.webkit.org/show_bug.cgi?id=30958 + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): Reorder initialization list + to fix compiler warnings. + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::FrameLoaderClientQt): Ditto. + +2009-10-30 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Notify the chrome when the focused node has changed. + https://bugs.webkit.org/show_bug.cgi?id=30832 + + Added stub implementation for new ChromeClient function. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::focusedNodeChanged): + * WebCoreSupport/ChromeClientQt.h: + +2009-10-30 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Remove the QWebInspector::windowTitleChanged signal, + QEvent::WindowTitleChange can be used to achieve the same. + https://bugs.webkit.org/show_bug.cgi?id=30927 + + * Api/qwebinspector.cpp: + * Api/qwebinspector.h: + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::updateWindowTitle): + +2009-10-29 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Implement DELETE HTTP method for XmlHttpRequest + https://bugs.webkit.org/show_bug.cgi?id=30894 + + No new tests as this functionality is already tested by the + xmlhttprequest LayoutTests. As this patch depends on an unreleased + version of the dependent QtNetwork library and the tests will be + enabled later once the dependent library is released (and the + buildbot is updated). + + * Api/qwebframe.cpp: + (QWebFrame::load): + +2009-10-29 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Remove QWebView::guessUrlFromString() and replace its use + with the new QUrl::fromUserInput() if using Qt 4.6 or newer. + + * Api/qwebview.cpp: + * Api/qwebview.h: + * QGVLauncher/main.cpp: + (urlFromUserInput): + (WebPage::applyProxy): + (MainWindow::load): + * QtLauncher/main.cpp: + (urlFromUserInput): + (MainWindow::MainWindow): + (MainWindow::changeLocation): + * tests/qwebview/tst_qwebview.cpp: + +2009-10-28 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Serialize directly to the stream, and not first to an QByteArray, + that is later serialized. That is slower and also uses more bytes. + + * Api/qwebhistory.cpp: + (operator<<): + (operator>>): + 2009-10-28 Shinichiro Hamaji <hamaji@chromium.org> Reviewed by Eric Seidel. diff --git a/WebKit/qt/Plugins/ICOHandler.cpp b/WebKit/qt/Plugins/ICOHandler.cpp deleted file mode 100644 index d7fae07..0000000 --- a/WebKit/qt/Plugins/ICOHandler.cpp +++ /dev/null @@ -1,460 +0,0 @@ -/* - * kimgio import filter for MS Windows .ico files - * - * Distributed under the terms of the LGPL - * Copyright (c) 2000 Malte Starostik <malte@kde.org> - * - */ - -#include "config.h" -#include "ICOHandler.h" - -#include <cstring> -#include <cstdlib> -#include <algorithm> -#include <vector> - -#include <QtGui/QImage> -#include <QtGui/QBitmap> -#include <QtGui/QApplication> -#include <QtCore/QVector> -#include <QtGui/QDesktopWidget> - -namespace -{ - // Global header (see http://www.daubnet.com/formats/ICO.html) - struct IcoHeader - { - enum Type { Icon = 1, Cursor }; - quint16 reserved; - quint16 type; - quint16 count; - }; - - inline QDataStream& operator >>( QDataStream& s, IcoHeader& h ) - { - return s >> h.reserved >> h.type >> h.count; - } - - // Based on qt_read_dib et al. from qimage.cpp - // (c) 1992-2002 Nokia Corporation and/or its subsidiary(-ies). - struct BMP_INFOHDR - { - static const quint32 Size = 40; - quint32 biSize; // size of this struct - quint32 biWidth; // pixmap width - quint32 biHeight; // pixmap height - quint16 biPlanes; // should be 1 - quint16 biBitCount; // number of bits per pixel - enum Compression { RGB = 0 }; - quint32 biCompression; // compression method - quint32 biSizeImage; // size of image - quint32 biXPelsPerMeter; // horizontal resolution - quint32 biYPelsPerMeter; // vertical resolution - quint32 biClrUsed; // number of colors used - quint32 biClrImportant; // number of important colors - }; - const quint32 BMP_INFOHDR::Size; - - QDataStream& operator >>( QDataStream &s, BMP_INFOHDR &bi ) - { - s >> bi.biSize; - if ( bi.biSize == BMP_INFOHDR::Size ) - { - s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount; - s >> bi.biCompression >> bi.biSizeImage; - s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter; - s >> bi.biClrUsed >> bi.biClrImportant; - } - return s; - } - -#if 0 - QDataStream &operator<<( QDataStream &s, const BMP_INFOHDR &bi ) - { - s << bi.biSize; - s << bi.biWidth << bi.biHeight; - s << bi.biPlanes; - s << bi.biBitCount; - s << bi.biCompression; - s << bi.biSizeImage; - s << bi.biXPelsPerMeter << bi.biYPelsPerMeter; - s << bi.biClrUsed << bi.biClrImportant; - return s; - } -#endif - - // Header for every icon in the file - struct IconRec - { - unsigned char width; - unsigned char height; - quint16 colors; - quint16 hotspotX; - quint16 hotspotY; - quint32 size; - quint32 offset; - }; - - inline QDataStream& operator >>( QDataStream& s, IconRec& r ) - { - return s >> r.width >> r.height >> r.colors - >> r.hotspotX >> r.hotspotY >> r.size >> r.offset; - } - - struct LessDifference - { - LessDifference( unsigned s, unsigned c ) - : size( s ), colors( c ) {} - - bool operator ()( const IconRec& lhs, const IconRec& rhs ) const - { - // closest size match precedes everything else - if ( std::abs( int( lhs.width - size ) ) < - std::abs( int( rhs.width - size ) ) ) return true; - else if ( std::abs( int( lhs.width - size ) ) > - std::abs( int( rhs.width - size ) ) ) return false; - else if ( colors == 0 ) - { - // high/true color requested - if ( lhs.colors == 0 ) return true; - else if ( rhs.colors == 0 ) return false; - else return lhs.colors > rhs.colors; - } - else - { - // indexed icon requested - if ( lhs.colors == 0 && rhs.colors == 0 ) return false; - else if ( lhs.colors == 0 ) return false; - else return std::abs( int( lhs.colors - colors ) ) < - std::abs( int( rhs.colors - colors ) ); - } - } - unsigned size; - unsigned colors; - }; - - bool loadFromDIB( QDataStream& stream, const IconRec& rec, QImage& icon ) - { - BMP_INFOHDR header; - stream >> header; - if ( stream.atEnd() || header.biSize != BMP_INFOHDR::Size || - header.biSize > rec.size || - header.biCompression != BMP_INFOHDR::RGB || - ( header.biBitCount != 1 && header.biBitCount != 4 && - header.biBitCount != 8 && header.biBitCount != 24 && - header.biBitCount != 32 ) ) return false; - - unsigned paletteSize, paletteEntries; - - if (header.biBitCount > 8) - { - paletteEntries = 0; - paletteSize = 0; - } - else - { - paletteSize = (1 << header.biBitCount); - paletteEntries = paletteSize; - if (header.biClrUsed && header.biClrUsed < paletteSize) - paletteEntries = header.biClrUsed; - } - - // Always create a 32-bit image to get the mask right - // Note: this is safe as rec.width, rec.height are bytes - icon = QImage( rec.width, rec.height, QImage::Format_ARGB32 ); - if ( icon.isNull() ) return false; - - QVector< QRgb > colorTable( paletteSize ); - - colorTable.fill( QRgb( 0 ) ); - for ( unsigned i = 0; i < paletteEntries; ++i ) - { - unsigned char rgb[ 4 ]; - stream.readRawData( reinterpret_cast< char* >( &rgb ), - sizeof( rgb ) ); - colorTable[ i ] = qRgb( rgb[ 2 ], rgb[ 1 ], rgb[ 0 ] ); - } - - unsigned bpl = ( rec.width * header.biBitCount + 31 ) / 32 * 4; - - unsigned char* buf = new unsigned char[ bpl ]; - for ( unsigned y = rec.height; !stream.atEnd() && y--; ) - { - stream.readRawData( reinterpret_cast< char* >( buf ), bpl ); - unsigned char* pixel = buf; - QRgb* p = reinterpret_cast< QRgb* >( icon.scanLine( y ) ); - switch ( header.biBitCount ) - { - case 1: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = colorTable[ - ( pixel[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ]; - break; - case 4: - for ( unsigned x = 0; x < rec.width; ++x ) - if ( x & 1 ) *p++ = colorTable[ pixel[ x / 2 ] & 0x0f ]; - else *p++ = colorTable[ pixel[ x / 2 ] >> 4 ]; - break; - case 8: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = colorTable[ pixel[ x ] ]; - break; - case 24: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = qRgb( pixel[ 3 * x + 2 ], - pixel[ 3 * x + 1 ], - pixel[ 3 * x ] ); - break; - case 32: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = qRgba( pixel[ 4 * x + 2 ], - pixel[ 4 * x + 1 ], - pixel[ 4 * x ], - pixel[ 4 * x + 3] ); - break; - } - } - delete[] buf; - - if ( header.biBitCount < 32 ) - { - // Traditional 1-bit mask - bpl = ( rec.width + 31 ) / 32 * 4; - buf = new unsigned char[ bpl ]; - for ( unsigned y = rec.height; y--; ) - { - stream.readRawData( reinterpret_cast< char* >( buf ), bpl ); - QRgb* p = reinterpret_cast< QRgb* >( icon.scanLine( y ) ); - for ( unsigned x = 0; x < rec.width; ++x, ++p ) - if ( ( ( buf[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ) ) - *p &= RGB_MASK; - } - delete[] buf; - } - return true; - } -} - -ICOHandler::ICOHandler() -{ -} - -bool ICOHandler::canRead() const -{ - return canRead(device()); -} - -bool ICOHandler::read(QImage *outImage) -{ - - qint64 offset = device()->pos(); - - QDataStream stream( device() ); - stream.setByteOrder( QDataStream::LittleEndian ); - IcoHeader header; - stream >> header; - if ( stream.atEnd() || !header.count || - ( header.type != IcoHeader::Icon && header.type != IcoHeader::Cursor) ) - return false; - - unsigned requestedSize = 32; - unsigned requestedColors = QApplication::desktop()->depth() > 8 ? 0 : QApplication::desktop()->depth(); - int requestedIndex = -1; -#if 0 - if ( io->parameters() ) - { - QStringList params = QString(io->parameters()).split( ';', QString::SkipEmptyParts ); - QMap< QString, QString > options; - for ( QStringList::ConstIterator it = params.begin(); - it != params.end(); ++it ) - { - QStringList tmp = (*it).split( '=', QString::SkipEmptyParts ); - if ( tmp.count() == 2 ) options[ tmp[ 0 ] ] = tmp[ 1 ]; - } - if ( options[ "index" ].toUInt() ) - requestedIndex = options[ "index" ].toUInt(); - if ( options[ "size" ].toUInt() ) - requestedSize = options[ "size" ].toUInt(); - if ( options[ "colors" ].toUInt() ) - requestedColors = options[ "colors" ].toUInt(); - } -#endif - - typedef std::vector< IconRec > IconList; - IconList icons; - for ( unsigned i = 0; i < header.count; ++i ) - { - if ( stream.atEnd() ) - return false; - IconRec rec; - stream >> rec; - icons.push_back( rec ); - } - IconList::const_iterator selected; - if (requestedIndex >= 0) { - selected = std::min( icons.begin() + requestedIndex, icons.end() ); - } else { - selected = std::min_element( icons.begin(), icons.end(), - LessDifference( requestedSize, requestedColors ) ); - } - if ( stream.atEnd() || selected == icons.end() || - offset + selected->offset > device()->size() ) - return false; - - device()->seek( offset + selected->offset ); - QImage icon; - if ( loadFromDIB( stream, *selected, icon ) ) - { -#ifndef QT_NO_IMAGE_TEXT - icon.setText( "X-Index", 0, QString::number( selected - icons.begin() ) ); - if ( header.type == IcoHeader::Cursor ) - { - icon.setText( "X-HotspotX", 0, QString::number( selected->hotspotX ) ); - icon.setText( "X-HotspotY", 0, QString::number( selected->hotspotY ) ); - } -#endif - *outImage = icon; - return true; - } - return false; -} - -bool ICOHandler::write(const QImage &/*image*/) -{ -#if 0 - if (image.isNull()) - return; - - QByteArray dibData; - QDataStream dib(dibData, QIODevice::ReadWrite); - dib.setByteOrder(QDataStream::LittleEndian); - - QImage pixels = image; - QImage mask; - if (io->image().hasAlphaBuffer()) - mask = image.createAlphaMask(); - else - mask = image.createHeuristicMask(); - mask.invertPixels(); - for ( int y = 0; y < pixels.height(); ++y ) - for ( int x = 0; x < pixels.width(); ++x ) - if ( mask.pixel( x, y ) == 0 ) pixels.setPixel( x, y, 0 ); - - if (!qt_write_dib(dib, pixels)) - return; - - uint hdrPos = dib.device()->at(); - if (!qt_write_dib(dib, mask)) - return; - memmove(dibData.data() + hdrPos, dibData.data() + hdrPos + BMP_WIN + 8, dibData.size() - hdrPos - BMP_WIN - 8); - dibData.resize(dibData.size() - BMP_WIN - 8); - - QDataStream ico(device()); - ico.setByteOrder(QDataStream::LittleEndian); - IcoHeader hdr; - hdr.reserved = 0; - hdr.type = Icon; - hdr.count = 1; - ico << hdr.reserved << hdr.type << hdr.count; - IconRec rec; - rec.width = image.width(); - rec.height = image.height(); - if (image.numColors() <= 16) - rec.colors = 16; - else if (image.depth() <= 8) - rec.colors = 256; - else - rec.colors = 0; - rec.hotspotX = 0; - rec.hotspotY = 0; - rec.dibSize = dibData.size(); - ico << rec.width << rec.height << rec.colors - << rec.hotspotX << rec.hotspotY << rec.dibSize; - rec.dibOffset = ico.device()->at() + sizeof(rec.dibOffset); - ico << rec.dibOffset; - - BMP_INFOHDR dibHeader; - dib.device()->at(0); - dib >> dibHeader; - dibHeader.biHeight = image.height() << 1; - dib.device()->at(0); - dib << dibHeader; - - ico.writeRawBytes(dibData.data(), dibData.size()); - return true; -#endif - return false; -} - -QByteArray ICOHandler::name() const -{ - return "ico"; -} - -bool ICOHandler::canRead(QIODevice *device) -{ - if (!device) { - qWarning("ICOHandler::canRead() called with no device"); - return false; - } - - const qint64 oldPos = device->pos(); - - char head[8]; - qint64 readBytes = device->read(head, sizeof(head)); - const bool readOk = readBytes == sizeof(head); - - if (device->isSequential()) { - while (readBytes > 0) - device->ungetChar(head[readBytes-- - 1]); - } else { - device->seek(oldPos); - } - - if ( !readOk ) - return false; - - return head[2] == '\001' && head[3] == '\000' && // type should be 1 - ( head[6] == 16 || head[6] == 32 || head[6] == 64 ) && // width can only be one of those - ( head[7] == 16 || head[7] == 32 || head[7] == 64 ); // same for height -} - -class ICOPlugin : public QImageIOPlugin -{ -public: - QStringList keys() const; - Capabilities capabilities(QIODevice *device, const QByteArray &format) const; - QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const; -}; - -QStringList ICOPlugin::keys() const -{ - return QStringList() << "ico" << "ICO"; -} - -QImageIOPlugin::Capabilities ICOPlugin::capabilities(QIODevice *device, const QByteArray &format) const -{ - if (format == "ico" || format == "ICO") - return Capabilities(CanRead); - if (!format.isEmpty()) - return 0; - if (!device->isOpen()) - return 0; - - Capabilities cap; - if (device->isReadable() && ICOHandler::canRead(device)) - cap |= CanRead; - return cap; -} - -QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format) const -{ - QImageIOHandler *handler = new ICOHandler; - handler->setDevice(device); - handler->setFormat(format); - return handler; -} - -Q_EXPORT_STATIC_PLUGIN(ICOPlugin) -Q_EXPORT_PLUGIN2(qtwebico, ICOPlugin) diff --git a/WebKit/qt/Plugins/ICOHandler.h b/WebKit/qt/Plugins/ICOHandler.h deleted file mode 100644 index 4f1f1d6..0000000 --- a/WebKit/qt/Plugins/ICOHandler.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ico.h - kimgio import filter for MS Windows .ico files - * - * Distributed under the terms of the LGPL - * Copyright (c) 2000 Malte Starostik <malte@kde.org> - * - */ - -// You can use QImageIO::setParameters() to request a specific -// Icon out of an .ico file: -// -// Options consist of a name=value pair and are separated by a semicolon. -// Available options are: -// size=<size> select the icon that most closely matches <size> (pixels) -// default: 32 -// colors=<num> select the icon that has <num> colors (or comes closest) -// default: 1 << display depth or 0 (RGB) if display depth > 8 -// index=<index> select the indexth icon from the file. If this option -// is present, the size and colors options will be ignored. -// default: none -// If both size and colors are given, size takes precedence. -// -// The old format is still supported: -// the parameters consist of a single string in the form -// "<size>[:<colors>]" which correspond to the options above -// -// If an icon was returned (i.e. the file is valid and the index option -// if present was not out of range), the icon's index within the .ico -// file is returned in the text tag "X-Index" of the image. -// If the icon is in fact a cursor, its hotspot coordinates are returned -// in the text tags "X-HotspotX" and "X-HotspotY". - -#ifndef _ICOHANDLER_H_ -#define _ICOHANDLER_H_ - -#include <QtGui/QImageIOPlugin> - -class ICOHandler : public QImageIOHandler -{ -public: - ICOHandler(); - - bool canRead() const; - bool read(QImage *image); - bool write(const QImage &image); - - QByteArray name() const; - - static bool canRead(QIODevice *device); -}; - -#endif diff --git a/WebKit/qt/Plugins/Plugins.pro b/WebKit/qt/Plugins/Plugins.pro deleted file mode 100644 index a9b4f82..0000000 --- a/WebKit/qt/Plugins/Plugins.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = lib -TARGET = qtwebico -CONFIG += plugin -HEADERS += ICOHandler.h -SOURCES += ICOHandler.cpp - -include(../../WebKit.pri) - -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols -unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions - -target.path = $$[QT_INSTALL_PLUGINS]/imageformats -INSTALLS += target - diff --git a/WebKit/qt/QGVLauncher/main.cpp b/WebKit/qt/QGVLauncher/main.cpp index 3632a33..2021cb6 100644 --- a/WebKit/qt/QGVLauncher/main.cpp +++ b/WebKit/qt/QGVLauncher/main.cpp @@ -50,6 +50,20 @@ #include <qwebsettings.h> #include <qwebview.h> +static QUrl urlFromUserInput(const QString& string) +{ + QString input(string); + QFileInfo fi(input); + if (fi.exists() && fi.isRelative()) + input = fi.absoluteFilePath(); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + return QUrl::fromUserInput(input); +#else + return QUrl(input); +#endif +} + class WebView : public QGraphicsWebView { Q_OBJECT Q_PROPERTY(qreal yRotation READ yRotation WRITE setYRotation) @@ -93,7 +107,7 @@ public: private: void applyProxy() { - QUrl proxyUrl = QWebView::guessUrlFromString(qgetenv("http_proxy")); + QUrl proxyUrl = urlFromUserInput(qgetenv("http_proxy")); if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) { int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080; @@ -278,7 +292,7 @@ public: void load(const QString& url) { - QUrl deducedUrl = guessUrlFromString(url); + QUrl deducedUrl = urlFromUserInput(url); if (!deducedUrl.isValid()) deducedUrl = QUrl("http://" + url + "/"); @@ -287,16 +301,6 @@ public: scene->webView()->setFocus(Qt::OtherFocusReason); } - QUrl guessUrlFromString(const QString& string) - { - QString input(string); - QFileInfo fi(input); - if (fi.exists() && fi.isRelative()) - input = fi.absoluteFilePath(); - - return QWebView::guessUrlFromString(input); - } - QWebPage* page() const { return scene->webView()->page(); diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp index e3c6116..2286712 100644 --- a/WebKit/qt/QtLauncher/main.cpp +++ b/WebKit/qt/QtLauncher/main.cpp @@ -30,18 +30,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <qwebpage.h> -#include <qwebview.h> -#include <qwebframe.h> -#include <qwebsettings.h> -#include <qwebplugindatabase.h> -#include <qwebelement.h> -#include <qwebinspector.h> - #include <QtGui> -#include <QDebug> #include <QtNetwork/QNetworkProxy> -#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER) +#include <QtNetwork/QNetworkRequest> +#if !defined(QT_NO_PRINTER) #include <QPrintPreviewDialog> #endif @@ -49,17 +41,78 @@ #include <QtUiTools/QUiLoader> #endif -#include <QVector> -#include <QTextStream> +#include <QDebug> #include <QFile> +#include <QTextStream> +#include <QVector> + #include <cstdio> +#include <qwebelement.h> +#include <qwebframe.h> +#include <qwebinspector.h> +#include <qwebpage.h> +#include <qwebsettings.h> +#include <qwebview.h> + #ifndef NDEBUG void QWEBKIT_EXPORT qt_drt_garbageCollector_collect(); #endif -class WebPage : public QWebPage +static QUrl urlFromUserInput(const QString& input) { +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + return QUrl::fromUserInput(input); +#else + return QUrl(input); +#endif +} + +class WebView : public QWebView { + Q_OBJECT +public: + WebView(QWidget* parent) : QWebView(parent) {} + +protected: + virtual void contextMenuEvent(QContextMenuEvent* event) + { + QMenu* menu = page()->createStandardContextMenu(); + + QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); + + if (!r.linkUrl().isEmpty()) { + QAction* newTabAction = menu->addAction(tr("Open in Default &Browser"), this, SLOT(openUrlInDefaultBrowser())); + newTabAction->setData(r.linkUrl()); + menu->insertAction(menu->actions().at(2), newTabAction); + } + + menu->exec(mapToGlobal(event->pos())); + delete menu; + } + + virtual void mousePressEvent(QMouseEvent* event) + { + mouseButtons = event->buttons(); + keyboardModifiers = event->modifiers(); + + QWebView::mousePressEvent(event); + } + +public slots: + void openUrlInDefaultBrowser(const QUrl &url = QUrl()) + { + if (QAction* action = qobject_cast<QAction*>(sender())) + QDesktopServices::openUrl(action->data().toUrl()); + else + QDesktopServices::openUrl(url); + } + +public: + Qt::MouseButtons mouseButtons; + Qt::KeyboardModifiers keyboardModifiers; +}; + +class WebPage : public QWebPage { public: WebPage(QWidget *parent) : QWebPage(parent) {} @@ -72,13 +125,49 @@ public: return false; } virtual bool extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output); + + + virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type) + { + WebView* webView = static_cast<WebView*>(view()); + if (webView->keyboardModifiers & Qt::ShiftModifier) { + QWebPage* page = createWindow(QWebPage::WebBrowserWindow); + page->mainFrame()->load(request); + return false; + } + if (webView->keyboardModifiers & Qt::AltModifier) { + webView->openUrlInDefaultBrowser(request.url()); + return false; + } + + return QWebPage::acceptNavigationRequest(frame, request, type); + } }; -class MainWindow : public QMainWindow -{ +class WebInspector : public QWebInspector { Q_OBJECT public: - MainWindow(QString url = QString()): currentZoom(100) { + WebInspector(QWidget* parent) : QWebInspector(parent) {} +signals: + void visibleChanged(bool nowVisible); +protected: + void showEvent(QShowEvent* event) + { + QWebInspector::showEvent(event); + emit visibleChanged(true); + } + void hideEvent(QHideEvent* event) + { + QWebInspector::hideEvent(event); + emit visibleChanged(false); + } +}; + +class MainWindow : public QMainWindow { + Q_OBJECT +public: + MainWindow(QString url = QString()): currentZoom(100) + { setAttribute(Qt::WA_DeleteOnClose); if (qgetenv("QTLAUNCHER_USE_ARGB_VISUALS").toInt() == 1) setAttribute(Qt::WA_TranslucentBackground); @@ -86,7 +175,7 @@ public: QSplitter* splitter = new QSplitter(Qt::Vertical, this); setCentralWidget(splitter); - view = new QWebView(splitter); + view = new WebView(splitter); WebPage* page = new WebPage(view); view->setPage(page); connect(view, SIGNAL(loadFinished(bool)), @@ -97,16 +186,16 @@ public: this, SLOT(showLinkHover(const QString&, const QString&))); connect(view->page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); - inspector = new QWebInspector(splitter); + inspector = new WebInspector(splitter); inspector->setPage(page); inspector->hide(); connect(this, SIGNAL(destroyed()), inspector, SLOT(deleteLater())); - connect(page, SIGNAL(webInspectorTriggered(const QWebElement&)), inspector, SLOT(show())); setupUI(); // set the proxy to the http_proxy env variable - if present - QUrl proxyUrl = view->guessUrlFromString(qgetenv("http_proxy")); + QUrl proxyUrl = urlFromUserInput(qgetenv("http_proxy")); + if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) { int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080; page->networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort)); @@ -116,11 +205,12 @@ public: if (fi.exists() && fi.isRelative()) url = fi.absoluteFilePath(); - QUrl qurl = view->guessUrlFromString(url); + QUrl qurl = urlFromUserInput(url); + if (qurl.scheme().isEmpty()) + qurl = QUrl("http://" + url + "/"); if (qurl.isValid()) { urlEdit->setText(qurl.toEncoded()); view->load(qurl); - } // the zoom values are chosen to be like in Mozilla Firefox 3 @@ -129,27 +219,33 @@ public: zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; } - QWebPage* webPage() const { + QWebPage* webPage() const + { return view->page(); } - QWebView* webView() const { + QWebView* webView() const + { return view; } protected slots: - void changeLocation() { + void changeLocation() + { QString string = urlEdit->text(); - QUrl url = view->guessUrlFromString(string); - if (!url.isValid()) + QUrl url = urlFromUserInput(string); + if (url.scheme().isEmpty()) url = QUrl("http://" + string + "/"); - urlEdit->setText(url.toEncoded()); - view->load(url); - view->setFocus(Qt::OtherFocusReason); + if (url.isValid()) { + urlEdit->setText(url.toEncoded()); + view->load(url); + view->setFocus(Qt::OtherFocusReason); + } } - void loadFinished() { + void loadFinished() + { urlEdit->setText(view->url().toString()); QUrl::FormattingOptions opts; @@ -166,7 +262,8 @@ protected slots: urlModel.setStringList(urlList); } - void showLinkHover(const QString &link, const QString &toolTip) { + void showLinkHover(const QString &link, const QString &toolTip) + { statusBar()->showMessage(link); #ifndef QT_NO_TOOLTIP if (!toolTip.isEmpty()) @@ -174,22 +271,24 @@ protected slots: #endif } - void zoomIn() { + void zoomIn() + { int i = zoomLevels.indexOf(currentZoom); Q_ASSERT(i >= 0); if (i < zoomLevels.count() - 1) currentZoom = zoomLevels[i + 1]; - view->setZoomFactor(qreal(currentZoom)/100.0); + view->setZoomFactor(qreal(currentZoom) / 100.0); } - void zoomOut() { + void zoomOut() + { int i = zoomLevels.indexOf(currentZoom); Q_ASSERT(i >= 0); if (i > 0) currentZoom = zoomLevels[i - 1]; - view->setZoomFactor(qreal(currentZoom)/100.0); + view->setZoomFactor(qreal(currentZoom) / 100.0); } void resetZoom() @@ -203,8 +302,9 @@ protected slots: view->page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, b); } - void print() { -#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER) + void print() + { +#if !defined(QT_NO_PRINTER) QPrintPreviewDialog dlg(this); connect(&dlg, SIGNAL(paintRequested(QPrinter *)), view, SLOT(print(QPrinter *))); @@ -228,11 +328,13 @@ protected slots: } } - void setEditable(bool on) { + void setEditable(bool on) + { view->page()->setContentEditable(on); formatMenuAction->setVisible(on); } + /* void dumpPlugins() { QList<QWebPluginInfo> plugins = QWebSettings::pluginDatabase()->plugins(); foreach (const QWebPluginInfo plugin, plugins) { @@ -242,12 +344,15 @@ protected slots: } } } + */ - void dumpHtml() { + void dumpHtml() + { qDebug() << "HTML: " << view->page()->mainFrame()->toHtml(); } - void selectElements() { + void selectElements() + { bool ok; QString str = QInputDialog::getText(this, "Select elements", "Choose elements", QLineEdit::Normal, "a", &ok); @@ -262,8 +367,9 @@ protected slots: public slots: - void newWindow(const QString &url = QString()) { - MainWindow *mw = new MainWindow(url); + void newWindow(const QString &url = QString()) + { + MainWindow* mw = new MainWindow(url); mw->show(); } @@ -273,7 +379,8 @@ private: int currentZoom; // create the status bar, tool bar & menu - void setupUI() { + void setupUI() + { progress = new QProgressBar(this); progress->setRange(0, 100); progress->setMinimumSize(100, 20); @@ -289,26 +396,24 @@ private: urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy()); connect(urlEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); - QCompleter *completer = new QCompleter(this); + QCompleter* completer = new QCompleter(this); urlEdit->setCompleter(completer); completer->setModel(&urlModel); - QToolBar *bar = addToolBar("Navigation"); + QToolBar* bar = addToolBar("Navigation"); bar->addAction(view->pageAction(QWebPage::Back)); bar->addAction(view->pageAction(QWebPage::Forward)); bar->addAction(view->pageAction(QWebPage::Reload)); bar->addAction(view->pageAction(QWebPage::Stop)); bar->addWidget(urlEdit); - QMenu *fileMenu = menuBar()->addMenu("&File"); - QAction *newWindow = fileMenu->addAction("New Window", this, SLOT(newWindow())); -#if QT_VERSION >= 0x040400 + QMenu* fileMenu = menuBar()->addMenu("&File"); + QAction* newWindow = fileMenu->addAction("New Window", this, SLOT(newWindow())); fileMenu->addAction(tr("Print"), this, SLOT(print()), QKeySequence::Print); -#endif QAction* screenshot = fileMenu->addAction("Screenshot", this, SLOT(screenshot())); fileMenu->addAction("Close", this, SLOT(close())); - QMenu *editMenu = menuBar()->addMenu("&Edit"); + QMenu* editMenu = menuBar()->addMenu("&Edit"); editMenu->addAction(view->pageAction(QWebPage::Undo)); editMenu->addAction(view->pageAction(QWebPage::Redo)); editMenu->addSeparator(); @@ -316,30 +421,30 @@ private: editMenu->addAction(view->pageAction(QWebPage::Copy)); editMenu->addAction(view->pageAction(QWebPage::Paste)); editMenu->addSeparator(); - QAction *setEditable = editMenu->addAction("Set Editable", this, SLOT(setEditable(bool))); + QAction* setEditable = editMenu->addAction("Set Editable", this, SLOT(setEditable(bool))); setEditable->setCheckable(true); - QMenu *viewMenu = menuBar()->addMenu("&View"); + QMenu* viewMenu = menuBar()->addMenu("&View"); viewMenu->addAction(view->pageAction(QWebPage::Stop)); viewMenu->addAction(view->pageAction(QWebPage::Reload)); viewMenu->addSeparator(); - QAction *zoomIn = viewMenu->addAction("Zoom &In", this, SLOT(zoomIn())); - QAction *zoomOut = viewMenu->addAction("Zoom &Out", this, SLOT(zoomOut())); - QAction *resetZoom = viewMenu->addAction("Reset Zoom", this, SLOT(resetZoom())); - QAction *zoomTextOnly = viewMenu->addAction("Zoom Text Only", this, SLOT(toggleZoomTextOnly(bool))); + QAction* zoomIn = viewMenu->addAction("Zoom &In", this, SLOT(zoomIn())); + QAction* zoomOut = viewMenu->addAction("Zoom &Out", this, SLOT(zoomOut())); + QAction* resetZoom = viewMenu->addAction("Reset Zoom", this, SLOT(resetZoom())); + QAction* zoomTextOnly = viewMenu->addAction("Zoom Text Only", this, SLOT(toggleZoomTextOnly(bool))); zoomTextOnly->setCheckable(true); zoomTextOnly->setChecked(false); viewMenu->addSeparator(); viewMenu->addAction("Dump HTML", this, SLOT(dumpHtml())); - viewMenu->addAction("Dump plugins", this, SLOT(dumpPlugins())); + //viewMenu->addAction("Dump plugins", this, SLOT(dumpPlugins())); - QMenu *formatMenu = new QMenu("F&ormat", this); + QMenu* formatMenu = new QMenu("F&ormat", this); formatMenuAction = menuBar()->addMenu(formatMenu); formatMenuAction->setVisible(false); formatMenu->addAction(view->pageAction(QWebPage::ToggleBold)); formatMenu->addAction(view->pageAction(QWebPage::ToggleItalic)); formatMenu->addAction(view->pageAction(QWebPage::ToggleUnderline)); - QMenu *writingMenu = formatMenu->addMenu(tr("Writing Direction")); + QMenu* writingMenu = formatMenu->addMenu(tr("Writing Direction")); writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionDefault)); writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionLeftToRight)); writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionRightToLeft)); @@ -362,17 +467,21 @@ private: view->pageAction(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I)); view->pageAction(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U)); - QMenu *toolsMenu = menuBar()->addMenu("&Tools"); + QMenu* toolsMenu = menuBar()->addMenu("&Tools"); toolsMenu->addAction("Select elements...", this, SLOT(selectElements())); + QAction* showInspectorAction = toolsMenu->addAction("Show inspector", inspector, SLOT(setVisible(bool))); + showInspectorAction->setCheckable(true); + showInspectorAction->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("F12"))); + showInspectorAction->connect(inspector, SIGNAL(visibleChanged(bool)), SLOT(setChecked(bool))); } - QWebView *view; - QLineEdit *urlEdit; - QProgressBar *progress; - QWebInspector* inspector; + QWebView* view; + QLineEdit* urlEdit; + QProgressBar* progress; + WebInspector* inspector; - QAction *formatMenuAction; + QAction* formatMenuAction; QStringList urlList; QStringListModel urlModel; @@ -389,14 +498,14 @@ bool WebPage::extension(Extension extension, const ExtensionOption *option, Exte return true; } -QWebPage *WebPage::createWindow(QWebPage::WebWindowType) +QWebPage* WebPage::createWindow(QWebPage::WebWindowType) { - MainWindow *mw = new MainWindow; + MainWindow* mw = new MainWindow; mw->show(); return mw->webPage(); } -QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +QObject* WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) { Q_UNUSED(url); Q_UNUSED(paramNames); @@ -410,8 +519,7 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS #endif } -class URLLoader : public QObject -{ +class URLLoader : public QObject { Q_OBJECT public: URLLoader(QWebView* view, const QString& inputFileName) @@ -492,14 +600,12 @@ int launcherMain(const QApplication& app) int main(int argc, char **argv) { QApplication app(argc, argv); - QString url = QString("%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); + QString defaultUrl = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); QWebSettings::setMaximumPagesInCache(4); app.setApplicationName("QtLauncher"); -#if QT_VERSION >= 0x040400 app.setApplicationVersion("0.1"); -#endif QWebSettings::setObjectCacheCapacities((16*1024*1024) / 8, (16*1024*1024) / 8, 16*1024*1024); @@ -521,21 +627,28 @@ int main(int argc, char **argv) exit(0); } MainWindow* window = new MainWindow; - QWebView *view = window->webView(); + QWebView* view = window->webView(); URLLoader loader(view, listFile); QObject::connect(view, SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext())); loader.loadNext(); window->show(); launcherMain(app); } else { - if (args.count() > 1) - url = args.at(1); - - MainWindow* window = new MainWindow(url); + MainWindow* window = 0; + + // Look though the args for something we can open + for (int i = 1; i < args.count(); i++) { + if (!args.at(i).startsWith("-")) { + if (!window) + window = new MainWindow(args.at(i)); + else + window->newWindow(args.at(i)); + } + } - // Opens every given urls in new windows - for (int i = 2; i < args.count(); i++) - window->newWindow(args.at(i)); + // If not, just open the default URL + if (!window) + window = new MainWindow(defaultUrl); window->show(); launcherMain(app); diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index 26cf6f6..eb7ac9a 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -141,6 +141,11 @@ void ChromeClientQt::takeFocus(FocusDirection) } +void ChromeClientQt::focusedNodeChanged(WebCore::Node*) +{ +} + + Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features) { QWebPage *newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow); diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h index 196c4fc..939fe04 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -63,6 +63,8 @@ namespace WebCore { virtual bool canTakeFocus(FocusDirection); virtual void takeFocus(FocusDirection); + virtual void focusedNodeChanged(Node*); + virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&); virtual void show(); diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 34241f0..3091a43 100644 --- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -407,28 +407,38 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) case VK_LEFT: if (kevent->shiftKey()) frame->editor()->command("MoveLeftAndModifySelection").execute(); - else frame->editor()->command("MoveLeft").execute(); + else + frame->editor()->command("MoveLeft").execute(); break; case VK_RIGHT: if (kevent->shiftKey()) frame->editor()->command("MoveRightAndModifySelection").execute(); - else frame->editor()->command("MoveRight").execute(); + else + frame->editor()->command("MoveRight").execute(); break; case VK_UP: if (kevent->shiftKey()) frame->editor()->command("MoveUpAndModifySelection").execute(); - else frame->editor()->command("MoveUp").execute(); + else + frame->editor()->command("MoveUp").execute(); break; case VK_DOWN: if (kevent->shiftKey()) frame->editor()->command("MoveDownAndModifySelection").execute(); - else frame->editor()->command("MoveDown").execute(); + else + frame->editor()->command("MoveDown").execute(); break; case VK_PRIOR: // PageUp - frame->editor()->command("MovePageUp").execute(); + if (kevent->shiftKey()) + frame->editor()->command("MovePageUpAndModifySelection").execute(); + else + frame->editor()->command("MovePageUp").execute(); break; case VK_NEXT: // PageDown - frame->editor()->command("MovePageDown").execute(); + if (kevent->shiftKey()) + frame->editor()->command("MovePageDownAndModifySelection").execute(); + else + frame->editor()->command("MovePageDown").execute(); break; case VK_TAB: return; diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 8749ada..3c30ab5 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -1,9 +1,10 @@ /* * Copyright (C) 2006 Zack Rusin <zack@kde.org> * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2008 Collabora Ltd. All rights reserved. * Coypright (C) 2008 Holger Hans Peter Freyther + * Coypright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> * * All rights reserved. * @@ -53,8 +54,9 @@ #include "QNetworkReplyHandler.h" #include "ResourceHandleInternal.h" #include "ResourceHandle.h" -#include "Settings.h" +#include "ScriptController.h" #include "ScriptString.h" +#include "Settings.h" #include "QWebPageClient.h" #include "qwebpage.h" @@ -68,14 +70,10 @@ #include <QCoreApplication> #include <QDebug> -#if QT_VERSION >= 0x040400 #include <QGraphicsScene> #include <QGraphicsWidget> #include <QNetworkRequest> #include <QNetworkReply> -#else -#include "qwebnetworkinterface_p.h" -#endif #include "qwebhistory_p.h" static bool dumpFrameLoaderCallbacks = false; @@ -145,9 +143,9 @@ namespace WebCore FrameLoaderClientQt::FrameLoaderClientQt() : m_frame(0) , m_webFrame(0) + , m_firstData(false) , m_pluginView(0) , m_hasSentResponseToPlugin(false) - , m_firstData(false) , m_loadError (ResourceError()) { } @@ -176,8 +174,8 @@ void FrameLoaderClientQt::setFrame(QWebFrame* webFrame, Frame* frame) m_webFrame->page(), SIGNAL(loadFinished(bool))); connect(this, SIGNAL(loadFinished(bool)), m_webFrame, SIGNAL(loadFinished(bool))); - connect(this, SIGNAL(titleChanged(const QString&)), - m_webFrame, SIGNAL(titleChanged(const QString&))); + connect(this, SIGNAL(titleChanged(QString)), + m_webFrame, SIGNAL(titleChanged(QString))); } QWebFrame* FrameLoaderClientQt::webFrame() const @@ -307,6 +305,29 @@ void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage() m_webFrame->page()->d->updateNavigationActions(); } +void FrameLoaderClientQt::dispatchDidPushStateWithinPage() +{ + if (dumpFrameLoaderCallbacks) + printf("%s - dispatchDidPushStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); + + notImplemented(); +} + +void FrameLoaderClientQt::dispatchDidReplaceStateWithinPage() +{ + if (dumpFrameLoaderCallbacks) + printf("%s - dispatchDidReplaceStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); + + notImplemented(); +} + +void FrameLoaderClientQt::dispatchDidPopStateWithinPage() +{ + if (dumpFrameLoaderCallbacks) + printf("%s - dispatchDidPopStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); + + notImplemented(); +} void FrameLoaderClientQt::dispatchWillClose() { @@ -600,8 +621,11 @@ bool FrameLoaderClientQt::canHandleRequest(const WebCore::ResourceRequest&) cons return true; } -void FrameLoaderClientQt::windowObjectCleared() +void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) { + if (world != mainThreadNormalWorld()) + return; + if (dumpFrameLoaderCallbacks) printf("%s - didClearWindowObjectForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); @@ -789,7 +813,6 @@ WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoad void FrameLoaderClientQt::download(WebCore::ResourceHandle* handle, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) { -#if QT_VERSION >= 0x040400 if (!m_webFrame) return; @@ -802,7 +825,6 @@ void FrameLoaderClientQt::download(WebCore::ResourceHandle* handle, const WebCor else reply->abort(); } -#endif } void FrameLoaderClientQt::assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest& request) @@ -955,11 +977,7 @@ void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction fu void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>, const WebCore::String&) { Q_ASSERT(m_webFrame); -#if QT_VERSION < 0x040400 - QWebNetworkRequest r(request); -#else - QNetworkRequest r(request.toNetworkRequest()); -#endif + QNetworkRequest r(request.toNetworkRequest(m_webFrame)); QWebPage* page = m_webFrame->page(); if (!page->d->acceptNavigationRequest(0, r, QWebPage::NavigationType(action.type()))) { @@ -980,11 +998,7 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunc void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>) { Q_ASSERT(m_webFrame); -#if QT_VERSION < 0x040400 - QWebNetworkRequest r(request); -#else - QNetworkRequest r(request.toNetworkRequest()); -#endif + QNetworkRequest r(request.toNetworkRequest(m_webFrame)); QWebPage*page = m_webFrame->page(); if (!page->d->acceptNavigationRequest(m_webFrame, r, QWebPage::NavigationType(action.type()))) { @@ -1009,12 +1023,10 @@ void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::Resourc void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request) { -#if QT_VERSION >= 0x040400 if (!m_webFrame) return; - emit m_webFrame->page()->downloadRequested(request.toNetworkRequest()); -#endif + emit m_webFrame->page()->downloadRequested(request.toNetworkRequest(m_webFrame)); } PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, @@ -1131,9 +1143,25 @@ public: QRegion clipRegion = QRegion(clipRect); platformWidget()->setMask(clipRegion); + handleVisibility(); + } + + virtual void show() + { + Widget::show(); + handleVisibility(); + } + +private: + void handleVisibility() + { + if (!isVisible()) + return; + // if setMask is set with an empty QRegion, no clipping will // be performed, so in that case we hide the platformWidget - platformWidget()->setVisible(!clipRegion.isEmpty()); + QRegion mask = platformWidget()->mask(); + platformWidget()->setVisible(!mask.isEmpty()); } }; @@ -1234,23 +1262,21 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, #endif // QT_NO_STYLE_STYLESHEET } -#if QT_VERSION >= 0x040400 if (!object) { QWebPluginFactory* factory = m_webFrame->page()->pluginFactory(); if (factory) object = factory->create(mimeType, qurl, params, values); } -#endif if (object) { QWidget* widget = qobject_cast<QWidget*>(object); if (widget) { - QWidget* parentWidget; + QWidget* parentWidget = 0; if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QWidget*>(m_webFrame->page()->d->client->pluginParent()); - else - parentWidget = 0; // The plug-in won't be fully functional because the QWebView doesn't exist. - widget->setParent(parentWidget); + if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. + widget->setParent(parentWidget); + widget->hide(); RefPtr<QtPluginWidget> w = adoptRef(new QtPluginWidget()); w->setPlatformWidget(widget); // Make sure it's invisible until properly placed into the layout @@ -1260,13 +1286,12 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, #if QT_VERSION >= 0x040600 QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(object); if (graphicsWidget) { - QGraphicsObject* parentWidget; + QGraphicsObject* parentWidget = 0; if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QGraphicsObject*>(m_webFrame->page()->d->client->pluginParent()); - else - parentWidget = 0; // The plug-in won't be fully functional because the QWebView doesn't exist. graphicsWidget->hide(); - graphicsWidget->setParentItem(parentWidget); + if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. + graphicsWidget->setParentItem(parentWidget); RefPtr<QtPluginGraphicsWidget> w = QtPluginGraphicsWidget::create(graphicsWidget); // Make sure it's invisible until properly placed into the layout w->setFrameRect(IntRect(0, 0, 0, 0)); @@ -1276,8 +1301,23 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, // FIXME: make things work for widgetless plugins as well delete object; } else { // NPAPI Plugins + Vector<String> params = paramNames; + Vector<String> values = paramValues; + if (mimeType == "application/x-shockwave-flash") { + QWebPageClient* client = m_webFrame->page()->d->client; + if (!client || !qobject_cast<QWidget*>(client->pluginParent())) { + // inject wmode=opaque when there is no client or the client is not a QWebView + size_t wmodeIndex = params.find("wmode"); + if (wmodeIndex == -1) { + params.append("wmode"); + values.append("opaque"); + } else + values[wmodeIndex] = "opaque"; + } + } + RefPtr<PluginView> pluginView = PluginView::create(m_frame, pluginSize, element, url, - paramNames, paramValues, mimeType, loadManually); + params, values, mimeType, loadManually); return pluginView; } diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index fe7590d..32b9caa 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -103,6 +103,9 @@ namespace WebCore { virtual void dispatchDidCancelClientRedirect(); virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); @@ -199,7 +202,7 @@ namespace WebCore { virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType); virtual String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 12f405c..d5683c4 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -50,8 +50,8 @@ namespace WebCore { static const QLatin1String settingStoragePrefix("Qt/QtWebKit/QWebInspector/"); static const QLatin1String settingStorageTypeSuffix(".type"); -static InspectorController::Setting variantToSetting(const QVariant& qvariant); -static QVariant settingToVariant(const InspectorController::Setting& icSetting); +static String variantToSetting(const QVariant& qvariant); +static QVariant settingToVariant(const String& value); class InspectorClientWebPage : public QWebPage { Q_OBJECT @@ -113,16 +113,11 @@ void InspectorClientQt::showWindow() updateWindowTitle(); m_inspectedWebPage->d->inspectorController()->setWindowVisible(true, true); - // We don't allow the inspector to ask for widget visibility itself because showWindow is - // not always called when we want. - // Inspecting an element or calling QWebInspector::show() should already have made the - // widget visible. } void InspectorClientQt::closeWindow() { - if (m_inspectedWebPage->d->inspector) - m_inspectedWebPage->d->inspector->close(); + m_inspectedWebPage->d->inspectorController()->setWindowVisible(false); } void InspectorClientQt::attachWindow() @@ -166,11 +161,10 @@ void InspectorClientQt::updateWindowTitle() if (m_inspectedWebPage->d->inspector) { QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2").arg(m_inspectedURL); m_inspectedWebPage->d->inspector->setWindowTitle(caption); - emit m_inspectedWebPage->d->inspector->windowTitleChanged(caption); } } -void InspectorClientQt::populateSetting(const String& key, InspectorController::Setting& setting) +void InspectorClientQt::populateSetting(const String& key, String* setting) { QSettings qsettings; if (qsettings.status() == QSettings::AccessError) { @@ -184,10 +178,10 @@ void InspectorClientQt::populateSetting(const String& key, InspectorController:: QString storedValueType = qsettings.value(settingKey + settingStorageTypeSuffix).toString(); QVariant storedValue = qsettings.value(settingKey); storedValue.convert(QVariant::nameToType(storedValueType.toAscii().data())); - setting = variantToSetting(storedValue); + *setting = variantToSetting(storedValue); } -void InspectorClientQt::storeSetting(const String& key, const InspectorController::Setting& setting) +void InspectorClientQt::storeSetting(const String& key, const String& setting) { QSettings qsettings; if (qsettings.status() == QSettings::AccessError) { @@ -202,70 +196,24 @@ void InspectorClientQt::storeSetting(const String& key, const InspectorControlle qsettings.setValue(settingKey + settingStorageTypeSuffix, QVariant::typeToName(valueToStore.type())); } -void InspectorClientQt::removeSetting(const String&) +static String variantToSetting(const QVariant& qvariant) { - notImplemented(); -} - -static InspectorController::Setting variantToSetting(const QVariant& qvariant) -{ - InspectorController::Setting retVal; + String retVal; switch (qvariant.type()) { case QVariant::Bool: - retVal.set(qvariant.toBool()); - break; - case QVariant::Double: - retVal.set(qvariant.toDouble()); - break; - case QVariant::Int: - retVal.set((long)qvariant.toInt()); - break; + retVal = qvariant.toBool() ? "true" : "false"; case QVariant::String: - retVal.set(qvariant.toString()); - break; - case QVariant::StringList: { - QStringList qsList = qvariant.toStringList(); - int listCount = qsList.count(); - Vector<String> vector(listCount); - for (int i = 0; i < listCount; ++i) - vector[i] = qsList[i]; - retVal.set(vector); - break; - } + retVal = qvariant.toString(); } return retVal; } -static QVariant settingToVariant(const InspectorController::Setting& icSetting) +static QVariant settingToVariant(const String& setting) { QVariant retVal; - - switch (icSetting.type()) { - case InspectorController::Setting::StringType: - retVal.setValue(static_cast<QString>(icSetting.string())); - break; - case InspectorController::Setting::StringVectorType: { - const Vector<String>& vector = icSetting.stringVector(); - Vector<String>::const_iterator iter; - QStringList qsList; - for (iter = vector.begin(); iter != vector.end(); ++iter) - qsList << *iter; - retVal.setValue(qsList); - break; - } - case InspectorController::Setting::DoubleType: - retVal.setValue(icSetting.doubleValue()); - break; - case InspectorController::Setting::IntegerType: - retVal.setValue((int)icSetting.integerValue()); - break; - case InspectorController::Setting::BooleanType: - retVal.setValue(icSetting.booleanValue()); - break; - } - + retVal.setValue(static_cast<QString>(setting)); return retVal; } diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h index ccf8b69..923bab4 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.h +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h @@ -66,9 +66,8 @@ namespace WebCore { virtual void hideHighlight(); virtual void inspectedURLChanged(const String& newURL); - virtual void populateSetting(const String& key, InspectorController::Setting&); - virtual void storeSetting(const String& key, const InspectorController::Setting&); - virtual void removeSetting(const String& key); + virtual void populateSetting(const String& key, String* value); + virtual void storeSetting(const String& key, const String& value); virtual void inspectorWindowObjectCleared(); diff --git a/WebKit/qt/docs/docs.pri b/WebKit/qt/docs/docs.pri index 4a8c165..804817b 100644 --- a/WebKit/qt/docs/docs.pri +++ b/WebKit/qt/docs/docs.pri @@ -1,9 +1,9 @@ include(../../../WebKit.pri) unix { - QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/tools/qdoc3/qdoc3 + QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/bin/qdoc3 } else { - QDOC = $$(QTDIR)\tools\qdoc3\release\qdoc3.exe + QDOC = $$(QTDIR)\bin\qdoc3.exe } unix { diff --git a/WebKit/qt/docs/qtwebkit.qdoc b/WebKit/qt/docs/qtwebkit.qdoc index 09dfae5..411762a 100644 --- a/WebKit/qt/docs/qtwebkit.qdoc +++ b/WebKit/qt/docs/qtwebkit.qdoc @@ -25,13 +25,10 @@ Qt Commercial Edition licensees that wish to distribute applications that use the QtWebKit module need to be aware of their obligations under the - GNU Lesser General Public License (LGPL). + GNU Library General Public License (LGPL). Developers using the Open Source Edition can choose to redistribute - the module under the appropriate version of the GNU LGPL; version 2.1 - for applications and libraries licensed under the GNU GPL version 2, - or version 3 for applications and libraries licensed under the GNU - GPL version 2. + the module under the appropriate version of the GNU LGPL. \legalese WebKit is licensed under the GNU Library General Public License. diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp index 0ba1cad..a6b6620 100644 --- a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp +++ b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp @@ -10,7 +10,7 @@ void wrapInFunction() QWebInspector *inspector = new QWebInspector; inspector->setPage(page); - connect(page, SIGNAL(webInspectorTriggered(const QWebElement&)), inspector, SLOT(show())); + connect(page, SIGNAL(webInspectorTriggered(QWebElement)), inspector, SLOT(show())); //! [0] } diff --git a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp index d437a6f..2707ffb 100644 --- a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp +++ b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp @@ -22,7 +22,6 @@ #include <qwebview.h> #include <qwebframe.h> #include <qwebelement.h> -#include <qdebug.h> static QWebFrame *frame; @@ -53,9 +52,10 @@ static void findAll() </p> */ +//! [FindAll intro] QList<QWebElement> allSpans = document.findAll("span"); QList<QWebElement> introSpans = document.findAll("p.intro span"); -//! [FindAll] +//! [FindAll intro] //! [FindAll] } int main(int argc, char *argv[]) diff --git a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro index f9b403b..8ca4b59 100644 --- a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro +++ b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro @@ -1,5 +1,8 @@ TEMPLATE = app CONFIG -= app_bundle +CONFIG(QTDIR_build) { + QT += webkit +} SOURCES = main.cpp include(../../../../../WebKit.pri) QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR diff --git a/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp index 4bdb7f5..657e09f 100644 --- a/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -17,36 +17,13 @@ Boston, MA 02110-1301, USA. */ +#include "../util.h" #include <QtTest/QtTest> - #include <QGraphicsView> #include <qgraphicswebview.h> #include <qwebpage.h> #include <qwebframe.h> -/** - * Starts an event loop that runs until the given signal is received. - * Optionally the event loop - * can return earlier on a timeout. - * - * \return \p true if the requested signal was received - * \p false on timeout - */ -static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) -{ - QEventLoop loop; - QObject::connect(obj, signal, &loop, SLOT(quit())); - QTimer timer; - QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); - if (timeout > 0) { - QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.setSingleShot(true); - timer.start(timeout); - } - loop.exec(); - return timeoutSpy.isEmpty(); -} - class tst_QGraphicsWebView : public QObject { Q_OBJECT @@ -63,21 +40,17 @@ void tst_QGraphicsWebView::qgraphicswebview() item.title(); item.icon(); item.zoomFactor(); - item.isInteractive(); - item.progress(); - item.toHtml(); item.history(); item.settings(); - item.status(); item.page(); item.setPage(0); item.page(); item.setUrl(QUrl()); item.setZoomFactor(0); - item.setInteractive(true); item.load(QUrl()); item.setHtml(QString()); item.setContent(QByteArray()); + item.isModified(); } class WebPage : public QWebPage @@ -117,7 +90,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); view.resize(600, 480); webView->resize(view.geometry().size()); - QTest::qWait(200); + QCoreApplication::processEvents(); view.show(); page->mainFrame()->setHtml(QString("data:text/html," @@ -126,7 +99,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() "<frame src=\"data:text/html,bar\">" "</frameset>")); - QVERIFY(::waitForSignal(page, SIGNAL(loadFinished(bool)))); + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); } QTEST_MAIN(tst_QGraphicsWebView) diff --git a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp index cf83fe8..e9dae18 100644 --- a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp +++ b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp @@ -68,9 +68,12 @@ private slots: void simpleCollection(); void attributes(); void attributesNS(); + void listAttributes(); void classes(); void namespaceURI(); void iteration(); + void nonConstIterator(); + void constIterator(); void foreachManipulation(); void emptyCollection(); void appendCollection(); @@ -185,6 +188,29 @@ void tst_QWebElement::attributesNS() QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("true")); } +void tst_QWebElement::listAttributes() +{ + QString content = "<html xmlns=\"http://www.w3.org/1999/xhtml\" " + "xmlns:svg=\"http://www.w3.org/2000/svg\">" + "<body><svg:svg foo=\"\" svg:bar=\"\">" + "</svg:svg></body></html>"; + + m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); + + QWebElement svg = m_mainFrame->findFirstElement("svg"); + QVERIFY(!svg.isNull()); + + QVERIFY(svg.attributeNames().contains("foo")); + QVERIFY(svg.attributeNames("http://www.w3.org/2000/svg").contains("bar")); + + svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true"); + QVERIFY(svg.attributeNames().contains("foo")); + QStringList attributes = svg.attributeNames("http://www.w3.org/2000/svg"); + QCOMPARE(attributes.size(), 2); + QVERIFY(attributes.contains("bar")); + QVERIFY(attributes.contains("foobar")); +} + void tst_QWebElement::classes() { m_mainFrame->setHtml("<body><p class=\"a b c d a c\">Test"); @@ -305,6 +331,37 @@ void tst_QWebElement::iteration() QCOMPARE(paras.at(1), paras.last()); } +void tst_QWebElement::nonConstIterator() +{ + QString html = "<body><p>first para</p><p>second para</p></body>"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + (*it).encloseWith("<div>"); + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + +void tst_QWebElement::constIterator() +{ + QString html = "<body><p>first para</p><p>second para</p></body>"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + const QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::const_iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + void tst_QWebElement::foreachManipulation() { QString html = "<body><p>first para</p><p>second para</p></body>"; @@ -938,7 +995,10 @@ void tst_QWebElement::render() QImage testImage(resource.width(), resource.height(), QImage::Format_ARGB32); QPainter painter0(&testImage); painter0.fillRect(imageRect, Qt::white); - painter0.drawImage(0, 0, resource); + // render() uses pixmaps internally, and pixmaps might have bit depths + // other than 32, giving different pixel values due to rounding. + QPixmap pix = QPixmap::fromImage(resource); + painter0.drawPixmap(0, 0, pix); painter0.end(); QImage image1(resource.width(), resource.height(), QImage::Format_ARGB32); diff --git a/WebKit/qt/tests/qwebframe/qwebframe.pro b/WebKit/qt/tests/qwebframe/qwebframe.pro index 0e540e5..b8734cd 100644 --- a/WebKit/qt/tests/qwebframe/qwebframe.pro +++ b/WebKit/qt/tests/qwebframe/qwebframe.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebframe.cpp RESOURCES += qwebframe.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/resources\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/resources\\\" symbian { TARGET.UID3 = 0xA000E53D diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 7cc62b0..7c13fd0 100644 --- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -38,35 +38,9 @@ #endif #include "../util.h" -//TESTED_CLASS= -//TESTED_FILES= - -// Task 160192 -/** - * Starts an event loop that runs until the given signal is received. - Optionally the event loop - * can return earlier on a timeout. - * - * \return \p true if the requested signal was received - * \p false on timeout - */ -static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0) -{ - QEventLoop loop; - QObject::connect(obj, signal, &loop, SLOT(quit())); - QTimer timer; - QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); - if (timeout > 0) { - QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.setSingleShot(true); - timer.start(timeout); - } - loop.exec(); - return timeoutSpy.isEmpty(); -} - -/* Mostly a test for the JavaScript related parts of QWebFrame */ - +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif struct CustomType { QString string; @@ -600,6 +574,7 @@ private slots: void render(); void scrollPosition(); void evaluateWillCauseRepaint(); + void qObjectWrapperWithSameIdentity(); private: QString evalJS(const QString&s) { @@ -2238,7 +2213,7 @@ protected: virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData) { QString url = request.url().toString(); - if (op == QNetworkAccessManager::GetOperation) + if (op == QNetworkAccessManager::GetOperation) { if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/") return new FakeReply(request, this); #ifndef QT_NO_OPENSSL @@ -2249,6 +2224,7 @@ protected: return reply; } #endif + } return QNetworkAccessManager::createRequest(op, request, outgoingData); } @@ -2265,19 +2241,19 @@ void tst_QWebFrame::requestedUrl() page.setNetworkAccessManager(networkManager); frame->setUrl(QUrl("qrc:/test1.html")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 1); QCOMPARE(frame->requestedUrl(), QUrl("qrc:/test1.html")); QCOMPARE(frame->url(), QUrl("qrc:/test2.html")); frame->setUrl(QUrl("qrc:/non-existent.html")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 2); QCOMPARE(frame->requestedUrl(), QUrl("qrc:/non-existent.html")); QCOMPARE(frame->url(), QUrl("qrc:/non-existent.html")); frame->setUrl(QUrl("http://abcdef.abcdef")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 3); QCOMPARE(frame->requestedUrl(), QUrl("http://abcdef.abcdef/")); QCOMPARE(frame->url(), QUrl("http://abcdef.abcdef/")); @@ -2286,9 +2262,9 @@ void tst_QWebFrame::requestedUrl() qRegisterMetaType<QList<QSslError> >("QList<QSslError>"); qRegisterMetaType<QNetworkReply* >("QNetworkReply*"); - QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&))); + QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>))); frame->setUrl(QUrl("qrc:/fake-ssl-error.html")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy2.count(), 1); QCOMPARE(frame->requestedUrl(), QUrl("qrc:/fake-ssl-error.html")); QCOMPARE(frame->url(), QUrl("qrc:/fake-ssl-error.html")); @@ -2346,7 +2322,7 @@ void tst_QWebFrame::setHtmlWithResource() // in few seconds, the image should be completey loaded QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); frame->setHtml(html); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 1); QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1); @@ -2365,7 +2341,7 @@ void tst_QWebFrame::setHtmlWithResource() // in few seconds, the CSS should be completey loaded frame->setHtml(html2); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.size(), 2); QWebElement p = frame->documentElement().findAll("p").at(0); @@ -2383,7 +2359,7 @@ void tst_QWebFrame::setHtmlWithBaseURL() QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); frame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath())); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 1); QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1); @@ -2494,15 +2470,15 @@ void tst_QWebFrame::popupFocus() combo->hidePopup(); QTRY_VERIFY(view.hasFocus() && !combo->view()->hasFocus()); // Focus should be back on the WebView - // triple the flashing time, should at least blink twice already - int delay = qApp->cursorFlashTime() * 3; + // double the flashing time, should at least blink once already + int delay = qApp->cursorFlashTime() * 2; // focus the lineedit and check if it blinks QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(200, 25)); m_popupTestView = &view; view.installEventFilter( this ); QTest::qWait(delay); - QVERIFY2(m_popupTestPaintCount >= 4, + QVERIFY2(m_popupTestPaintCount >= 3, "The input field should have a blinking caret"); } @@ -2646,7 +2622,7 @@ void tst_QWebFrame::hasSetFocus() QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); m_page->mainFrame()->setHtml(html); - QTest::qWait(200); + waitForSignal(m_page->mainFrame(), SIGNAL(loadFinished(bool)), 200); QCOMPARE(loadSpy.size(), 1); QList<QWebFrame*> children = m_page->mainFrame()->childFrames(); @@ -2656,7 +2632,7 @@ void tst_QWebFrame::hasSetFocus() "</body></html>"); frame->setHtml(innerHtml); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(loadSpy.size(), 2); m_page->mainFrame()->setFocus(); @@ -2743,16 +2719,51 @@ void tst_QWebFrame::evaluateWillCauseRepaint() view.setHtml(html); view.show(); - QTest::qWait(200); + QTest::qWaitForWindowShown(&view); view.page()->mainFrame()->evaluateJavaScript( "document.getElementById('junk').style.display = 'none';"); - ::waitForSignal(view.page(), SIGNAL(repaintRequested( const QRect &))); - - QTest::qWait(2000); + ::waitForSignal(view.page(), SIGNAL(repaintRequested(QRect))); } +class TestFactory : public QObject +{ + Q_OBJECT +public: + TestFactory() + : obj(0), counter(0) + {} + + Q_INVOKABLE QObject* getNewObject() + { + delete obj; + obj = new QObject(this); + obj->setObjectName(QLatin1String("test") + QString::number(++counter)); + return obj; + + } + + QObject* obj; + int counter; +}; + +void tst_QWebFrame::qObjectWrapperWithSameIdentity() +{ + m_view->setHtml("<script>function triggerBug() { document.getElementById('span1').innerText = test.getNewObject().objectName; }</script>" + "<body><span id='span1'>test</span></body>"); + + QWebFrame* mainFrame = m_view->page()->mainFrame(); + QCOMPARE(mainFrame->toPlainText(), QString("test")); + + mainFrame->addToJavaScriptWindowObject("test", new TestFactory, QScriptEngine::ScriptOwnership); + + mainFrame->evaluateJavaScript("triggerBug();"); + QCOMPARE(mainFrame->toPlainText(), QString("test1")); + + mainFrame->evaluateJavaScript("triggerBug();"); + QCOMPARE(mainFrame->toPlainText(), QString("test2")); +} QTEST_MAIN(tst_QWebFrame) #include "tst_qwebframe.moc" diff --git a/WebKit/qt/tests/qwebinspector/qwebinspector.pro b/WebKit/qt/tests/qwebinspector/qwebinspector.pro new file mode 100644 index 0000000..520887e --- /dev/null +++ b/WebKit/qt/tests/qwebinspector/qwebinspector.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = tst_qwebinspector +include(../../../../WebKit.pri) +SOURCES += tst_qwebinspector.cpp +QT += testlib network +QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR diff --git a/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp b/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp new file mode 100644 index 0000000..12cd630 --- /dev/null +++ b/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp @@ -0,0 +1,68 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <QtTest/QtTest> + +#include <qdir.h> +#include <qwebinspector.h> +#include <qwebpage.h> +#include <qwebsettings.h> + +class tst_QWebInspector : public QObject { + Q_OBJECT + +private slots: + void attachAndDestroy(); +}; + +void tst_QWebInspector::attachAndDestroy() +{ + { // External inspector + manual destruction of page first + QWebPage* page = new QWebPage(); + page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + QWebInspector* inspector = new QWebInspector(); + inspector->setPage(page); + page->updatePositionDependentActions(QPoint(0, 0)); + page->triggerAction(QWebPage::InspectElement); + + delete page; + delete inspector; + } + { // External inspector + manual destruction of inspector first + QWebPage* page = new QWebPage(); + page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + QWebInspector* inspector = new QWebInspector(); + inspector->setPage(page); + page->updatePositionDependentActions(QPoint(0, 0)); + page->triggerAction(QWebPage::InspectElement); + + delete inspector; + delete page; + } + { // Internal inspector + QWebPage page; + page.settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + page.updatePositionDependentActions(QPoint(0, 0)); + page.triggerAction(QWebPage::InspectElement); + } +} + +QTEST_MAIN(tst_QWebInspector) + +#include "tst_qwebinspector.moc" diff --git a/WebKit/qt/tests/qwebpage/qwebpage.pro b/WebKit/qt/tests/qwebpage/qwebpage.pro index 6b28efd..7853b28 100644 --- a/WebKit/qt/tests/qwebpage/qwebpage.pro +++ b/WebKit/qt/tests/qwebpage/qwebpage.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebpage.cpp RESOURCES += tst_qwebpage.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\" symbian { TARGET.UID3 = 0xA000E53E diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 0cf85ee..2a52631 100644 --- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -21,6 +21,9 @@ #include <QtTest/QtTest> +#include <qgraphicsscene.h> +#include <qgraphicsview.h> +#include <qgraphicswebview.h> #include <qwebelement.h> #include <qwebpage.h> #include <qwidget.h> @@ -37,6 +40,10 @@ #include <QPushButton> #include <QDir> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + // Will try to wait for the condition while allowing event processing #define QTRY_COMPARE(__expr, __expected) \ do { \ @@ -78,6 +85,22 @@ static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) return timeoutSpy.isEmpty(); } +class EventSpy : public QObject, public QList<QEvent::Type> +{ + Q_OBJECT +public: + EventSpy(QObject* objectToSpy) + { + objectToSpy->installEventFilter(this); + } + + virtual bool eventFilter(QObject* receiver, QEvent* event) + { + append(event->type()); + return false; + } +}; + class tst_QWebPage : public QObject { Q_OBJECT @@ -120,15 +143,20 @@ private slots: void testOptionalJSObjects(); void testEnablePersistentStorage(); void consoleOutput(); + void inputMethods_data(); void inputMethods(); void defaultTextEncoding(); void errorPageExtension(); + void errorPageExtensionInIFrames(); + void errorPageExtensionInFrameset(); void crashTests_LazyInitializationOfMainFrame(); void screenshot_data(); void screenshot(); + void originatingObjectInNetworkRequests(); + private: QWebView* m_view; QWebPage* m_page; @@ -234,7 +262,6 @@ void tst_QWebPage::loadFinished() { qRegisterMetaType<QWebFrame*>("QWebFrame*"); qRegisterMetaType<QNetworkRequest*>("QNetworkRequest*"); - QSignalSpy spyNetworkRequestStarted(m_page, SIGNAL(networkRequestStarted(QWebFrame*, QNetworkRequest*))); QSignalSpy spyLoadStarted(m_view, SIGNAL(loadStarted())); QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); @@ -245,7 +272,6 @@ void tst_QWebPage::loadFinished() QTest::qWait(3000); - QVERIFY(spyNetworkRequestStarted.count() > 1); QVERIFY(spyLoadStarted.count() > 1); QVERIFY(spyLoadFinished.count() > 1); @@ -346,9 +372,11 @@ public: TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {} QList<QUrl> requestedUrls; + QList<QNetworkRequest> requests; protected: virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { + requests.append(request); requestedUrls.append(request.url()); return QNetworkAccessManager::createRequest(op, request, outgoingData); } @@ -422,7 +450,7 @@ void tst_QWebPage::modified() m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fourth page")); QVERIFY(m_page->history()->count() == 2); m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fifth page")); - QVERIFY(::waitForSignal(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)))); + QVERIFY(::waitForSignal(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)))); } void tst_QWebPage::contextMenuCrash() @@ -450,7 +478,6 @@ void tst_QWebPage::database() QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024); m_page->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); - m_page->settings()->setAttribute(QWebSettings::SessionStorageEnabled, true); m_page->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); QString dbFileName = path + "Databases.db"; @@ -459,7 +486,7 @@ void tst_QWebPage::database() QFile::remove(dbFileName); qRegisterMetaType<QWebFrame*>("QWebFrame*"); - QSignalSpy spy(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame *, QString))); + QSignalSpy spy(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString))); m_view->setHtml(QString("<html><head><script>var db; db=openDatabase('testdb', '1.0', 'test database API', 50000); </script></head><body><div></div></body></html>"), QUrl("http://www.myexample.com")); QTRY_COMPARE(spy.count(), 1); m_page->mainFrame()->evaluateJavaScript("var db2; db2=openDatabase('testdb', '1.0', 'test database API', 50000);"); @@ -637,20 +664,41 @@ class PluginCounterPage : public QWebPage { public: int m_count; QPointer<QObject> m_widget; - PluginCounterPage(QObject* parent = 0) : QWebPage(parent), m_count(0), m_widget(0) + QObject* m_pluginParent; + PluginCounterPage(QObject* parent = 0) + : QWebPage(parent) + , m_count(0) + , m_widget(0) + , m_pluginParent(0) { settings()->setAttribute(QWebSettings::PluginsEnabled, true); } + ~PluginCounterPage() + { + if (m_pluginParent) + m_pluginParent->deleteLater(); + } }; template<class T> class PluginTracerPage : public PluginCounterPage { public: - PluginTracerPage(QObject* parent = 0) : PluginCounterPage(parent) {} + PluginTracerPage(QObject* parent = 0) + : PluginCounterPage(parent) + { + // this is a dummy parent object for the created plugin + m_pluginParent = new T; + } virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) { m_count++; - return m_widget = new T(); + m_widget = new T; + // need a cast to the specific type, as QObject::setParent cannot be called, + // because it is not virtual. Instead it is necesary to call QWidget::setParent, + // which also takes a QWidget* instead of a QObject*. Therefore we need to + // upcast to T*, which is a QWidget. + static_cast<T*>(m_widget.data())->setParent(static_cast<T*>(m_pluginParent)); + return m_widget; } }; @@ -716,6 +764,8 @@ void tst_QWebPage::createViewlessPlugin() page->mainFrame()->setHtml(content); QCOMPARE(page->m_count, 1); QVERIFY(page->m_widget); + QVERIFY(page->m_pluginParent); + QVERIFY(page->m_widget->parent() == page->m_pluginParent); delete page; } @@ -1262,28 +1312,101 @@ void tst_QWebPage::frameAt() frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos()); } +void tst_QWebPage::inputMethods_data() +{ + QTest::addColumn<QString>("viewType"); + QTest::newRow("QWebView") << "QWebView"; +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QTest::newRow("QGraphicsWebView") << "QGraphicsWebView"; +#endif +} + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) +static Qt::InputMethodHints inputMethodHints(QObject* object) +{ + if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object)) + return o->inputMethodHints(); + if (QWidget* w = qobject_cast<QWidget*>(object)) + return w->inputMethodHints(); + return Qt::InputMethodHints(); +} +#endif + +static bool inputMethodEnabled(QObject* object) +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object)) + return o->flags() & QGraphicsItem::ItemAcceptsInputMethod; +#endif + if (QWidget* w = qobject_cast<QWidget*>(object)) + return w->testAttribute(Qt::WA_InputMethodEnabled); + return false; +} + void tst_QWebPage::inputMethods() { - m_view->page()->mainFrame()->setHtml("<html><body>" \ + QFETCH(QString, viewType); + QWebPage* page = new QWebPage; + QObject* view = 0; + QObject* container = 0; + if (viewType == "QWebView") { + QWebView* wv = new QWebView; + wv->setPage(page); + view = wv; + container = view; + } +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + else if (viewType == "QGraphicsWebView") { + QGraphicsWebView* wv = new QGraphicsWebView; + wv->setPage(page); + view = wv; + + QGraphicsView* gv = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(gv); + gv->setScene(scene); + scene->addItem(wv); + wv->setGeometry(QRect(0, 0, 500, 500)); + + container = gv; + } +#endif + else + QVERIFY2(false, "Unknown view type"); + + page->mainFrame()->setHtml("<html><body>" \ "<input type='text' id='input1' style='font-family: serif' value='' maxlength='20'/><br>" \ "<input type='password'/>" \ "</body></html>"); - m_view->page()->mainFrame()->setFocus(); + page->mainFrame()->setFocus(); + + EventSpy viewEventSpy(container); - QWebElementCollection inputs = m_view->page()->mainFrame()->documentElement().findAll("input"); + QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input"); QMouseEvent evpres(QEvent::MouseButtonPress, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evpres); + page->event(&evpres); QMouseEvent evrel(QEvent::MouseButtonRelease, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evrel); + page->event(&evrel); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); +#endif + viewEventSpy.clear(); + + page->event(&evpres); + page->event(&evrel); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QVERIFY(viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); +#endif //ImMicroFocus - QVariant variant = m_view->page()->inputMethodQuery(Qt::ImMicroFocus); + QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus); QRect focusRect = variant.toRect(); QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft())); //ImFont - variant = m_view->page()->inputMethodQuery(Qt::ImFont); + variant = page->inputMethodQuery(Qt::ImFont); QFont font = variant.value<QFont>(); QCOMPARE(QString("-webkit-serif"), font.family()); @@ -1292,45 +1415,45 @@ void tst_QWebPage::inputMethods() //Insert text. { QInputMethodEvent eventText("QtWebKit", inputAttributes); - QSignalSpy signalSpy(m_view->page(), SIGNAL(microFocusChanged())); - m_view->page()->event(&eventText); + QSignalSpy signalSpy(page, SIGNAL(microFocusChanged())); + page->event(&eventText); QCOMPARE(signalSpy.count(), 0); } { QInputMethodEvent eventText("", inputAttributes); eventText.setCommitString(QString("QtWebKit"), 0, 0); - m_view->page()->event(&eventText); + page->event(&eventText); } #if QT_VERSION >= 0x040600 //ImMaximumTextLength - variant = m_view->page()->inputMethodQuery(Qt::ImMaximumTextLength); + variant = page->inputMethodQuery(Qt::ImMaximumTextLength); QCOMPARE(20, variant.toInt()); //Set selection inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant()); QInputMethodEvent eventSelection("",inputAttributes); - m_view->page()->event(&eventSelection); + page->event(&eventSelection); //ImAnchorPosition - variant = m_view->page()->inputMethodQuery(Qt::ImAnchorPosition); + variant = page->inputMethodQuery(Qt::ImAnchorPosition); int anchorPosition = variant.toInt(); QCOMPARE(anchorPosition, 3); //ImCursorPosition - variant = m_view->page()->inputMethodQuery(Qt::ImCursorPosition); + variant = page->inputMethodQuery(Qt::ImCursorPosition); int cursorPosition = variant.toInt(); QCOMPARE(cursorPosition, 5); //ImCurrentSelection - variant = m_view->page()->inputMethodQuery(Qt::ImCurrentSelection); + variant = page->inputMethodQuery(Qt::ImCurrentSelection); QString selectionValue = variant.value<QString>(); QCOMPARE(selectionValue, QString("eb")); #endif //ImSurroundingText - variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText); + variant = page->inputMethodQuery(Qt::ImSurroundingText); QString value = variant.value<QString>(); QCOMPARE(value, QString("QtWebKit")); @@ -1341,29 +1464,46 @@ void tst_QWebPage::inputMethods() QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant()); attributes.append(newSelection); QInputMethodEvent event("composition", attributes); - m_view->page()->event(&event); + page->event(&event); } // A ongoing composition should not change the surrounding text before it is committed. - variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText); + variant = page->inputMethodQuery(Qt::ImSurroundingText); value = variant.value<QString>(); QCOMPARE(value, QString("QtWebKit")); #endif //ImhHiddenText QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evpresPassword); + page->event(&evpresPassword); QMouseEvent evrelPassword(QEvent::MouseButtonRelease, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evrelPassword); + page->event(&evrelPassword); - QVERIFY(m_view->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(inputMethodEnabled(view)); #if QT_VERSION >= 0x040600 - QVERIFY(m_view->inputMethodHints() & Qt::ImhHiddenText); + QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText); + + page->event(&evpres); + page->event(&evrel); + QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText)); +#endif + + page->mainFrame()->setHtml("<html><body><p>nothing to input here"); + viewEventSpy.clear(); + + QWebElement para = page->mainFrame()->findFirstElement("p"); + { + QMouseEvent evpres(QEvent::MouseButtonPress, para.geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + page->event(&evpres); + QMouseEvent evrel(QEvent::MouseButtonRelease, para.geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + page->event(&evrel); + } - m_view->page()->event(&evpres); - m_view->page()->event(&evrel); - QVERIFY(!(m_view->inputMethodHints() & Qt::ImhHiddenText)); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); #endif + + delete container; } // import a little DRT helper function to trigger the garbage collector @@ -1394,10 +1534,17 @@ void tst_QWebPage::protectBindingsRuntimeObjectsFromCollector() void tst_QWebPage::localURLSchemes() { int i = QWebSecurityOrigin::localSchemes().size(); + QWebSecurityOrigin::removeLocalScheme("file"); QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i); QWebSecurityOrigin::addLocalScheme("file"); QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i); + + QWebSecurityOrigin::removeLocalScheme("qrc"); + QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i - 1); + QWebSecurityOrigin::addLocalScheme("qrc"); + QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i); + QString myscheme = "myscheme"; QWebSecurityOrigin::addLocalScheme(myscheme); QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i + 1); @@ -1438,11 +1585,6 @@ void tst_QWebPage::testOptionalJSObjects() QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", true), true); QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false); QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", false), true); - - QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false); - QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", true), true); - QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false); - QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", false), true); } void tst_QWebPage::testEnablePersistentStorage() @@ -1508,15 +1650,10 @@ public: virtual bool extension(Extension, const ExtensionOption* option, ExtensionReturn* output) { - const ErrorPageExtensionOption* info = static_cast<const ErrorPageExtensionOption*>(option); ErrorPageExtensionReturn* errorPage = static_cast<ErrorPageExtensionReturn*>(output); - if (info->frame == mainFrame()) { - errorPage->content = "data:text/html,error"; - return true; - } - - return false; + errorPage->content = "data:text/html,error"; + return true; } }; @@ -1527,11 +1664,10 @@ void tst_QWebPage::errorPageExtension() QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); - page->mainFrame()->load(QUrl("qrc:///frametest/index.html")); + m_view->setUrl(QUrl("data:text/html,foo")); QTRY_COMPARE(spyLoadFinished.count(), 1); page->mainFrame()->setUrl(QUrl("http://non.existent/url")); - QTest::qWait(2000); QTRY_COMPARE(spyLoadFinished.count(), 2); QCOMPARE(page->mainFrame()->toPlainText(), QString("data:text/html,error")); QCOMPARE(page->history()->count(), 2); @@ -1539,6 +1675,53 @@ void tst_QWebPage::errorPageExtension() QCOMPARE(page->history()->canGoBack(), true); QCOMPARE(page->history()->canGoForward(), false); + page->triggerAction(QWebPage::Back); + QTest::qWait(2000); + QCOMPARE(page->history()->canGoBack(), false); + QCOMPARE(page->history()->canGoForward(), true); + + page->triggerAction(QWebPage::Forward); + QTest::qWait(2000); + QCOMPARE(page->history()->canGoBack(), true); + QCOMPARE(page->history()->canGoForward(), false); + + page->triggerAction(QWebPage::Back); + QTest::qWait(2000); + QCOMPARE(page->history()->canGoBack(), false); + QCOMPARE(page->history()->canGoForward(), true); + QCOMPARE(page->history()->currentItem().url(), QUrl("data:text/html,foo")); + + m_view->setPage(0); +} + +void tst_QWebPage::errorPageExtensionInIFrames() +{ + ErrorPage* page = new ErrorPage; + m_view->setPage(page); + + m_view->setHtml(QString("data:text/html," + "<h1>h1</h1>" + "<iframe src='data:text/html,<p/>p'></iframe>" + "<iframe src='non-existent.html'></iframe>")); + QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); + QTRY_COMPARE(spyLoadFinished.count(), 1); + + QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("data:text/html,error")); + + m_view->setPage(0); +} + +void tst_QWebPage::errorPageExtensionInFrameset() +{ + ErrorPage* page = new ErrorPage; + m_view->setPage(page); + + m_view->load(QUrl("qrc:///frametest/index.html")); + + QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); + QTRY_COMPARE(spyLoadFinished.count(), 1); + QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("data:text/html,error")); + m_view->setPage(0); } @@ -1609,5 +1792,27 @@ void tst_QWebPage::screenshot() QDir::setCurrent(QApplication::applicationDirPath()); } +void tst_QWebPage::originatingObjectInNetworkRequests() +{ + TestNetworkManager* networkManager = new TestNetworkManager(m_page); + m_page->setNetworkAccessManager(networkManager); + networkManager->requests.clear(); + + m_view->setHtml(QString("data:text/html,<frameset cols=\"25%,75%\"><frame src=\"data:text/html," + "<head><meta http-equiv='refresh' content='1'></head>foo \">" + "<frame src=\"data:text/html,bar\"></frameset>"), QUrl()); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QCOMPARE(networkManager->requests.count(), 2); + + QList<QWebFrame*> childFrames = m_page->mainFrame()->childFrames(); + QCOMPARE(childFrames.count(), 2); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + for (int i = 0; i < 2; ++i) + QVERIFY(qobject_cast<QWebFrame*>(networkManager->requests.at(i).originatingObject()) == childFrames.at(i)); +#endif +} + QTEST_MAIN(tst_QWebPage) #include "tst_qwebpage.moc" diff --git a/WebKit/qt/tests/qwebview/data/frame_a.html b/WebKit/qt/tests/qwebview/data/frame_a.html new file mode 100644 index 0000000..9ff68f1 --- /dev/null +++ b/WebKit/qt/tests/qwebview/data/frame_a.html @@ -0,0 +1,2 @@ +<a href="http://google.com" target="frame_b"><img src="" width=100 height=100 alt="Google"></a> +<a href="http://yahoo.com" target="frame_b"><img src="" width=100 height=100 alt="Yahoo"></a> diff --git a/WebKit/qt/tests/qwebview/data/index.html b/WebKit/qt/tests/qwebview/data/index.html new file mode 100644 index 0000000..c53ad09 --- /dev/null +++ b/WebKit/qt/tests/qwebview/data/index.html @@ -0,0 +1,4 @@ +<frameset cols="25%,75%"> + <frame src="frame_a.html" name="frame_a"> + <frame src="frame_b.html" name="frame_b"> +</frameset> diff --git a/WebKit/qt/tests/qwebview/qwebview.pro b/WebKit/qt/tests/qwebview/qwebview.pro index e67bb7a..735537b 100644 --- a/WebKit/qt/tests/qwebview/qwebview.pro +++ b/WebKit/qt/tests/qwebview/qwebview.pro @@ -4,6 +4,7 @@ include(../../../../WebKit.pri) SOURCES += tst_qwebview.cpp QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR +RESOURCES += tst_qwebview.qrc DEFINES += SRCDIR=\\\"$$PWD/\\\" symbian { diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/WebKit/qt/tests/qwebview/tst_qwebview.cpp index 9204223..bd2f185 100644 --- a/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -20,6 +20,7 @@ */ #include <qtest.h> +#include "../util.h" #include <qpainter.h> #include <qwebview.h> @@ -41,12 +42,12 @@ public slots: private slots: void renderHints(); - void guessUrlFromString_data(); - void guessUrlFromString(); void getWebKitVersion(); void reusePage_data(); void reusePage(); + + void crashTests(); }; // This will be called before the first test function is executed. @@ -105,68 +106,6 @@ void tst_QWebView::renderHints() QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); } -void tst_QWebView::guessUrlFromString_data() -{ - QTest::addColumn<QString>("string"); - QTest::addColumn<QUrl>("guessUrlFromString"); - - // Null - QTest::newRow("null") << QString() << QUrl(); - - // File - QDirIterator it(QDir::homePath()); - QString fileString; - int c = 0; - while (it.hasNext()) { - it.next(); - QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.filePath() << QUrl::fromLocalFile(it.filePath()); - } - - // basic latin1 - QTest::newRow("unicode-0") << QString::fromUtf8("å.com/") << QUrl::fromEncoded(QString::fromUtf8("http://å.com/").toUtf8(), QUrl::TolerantMode); - // unicode - QTest::newRow("unicode-1") << QString::fromUtf8("λ.com/") << QUrl::fromEncoded(QString::fromUtf8("http://λ.com/").toUtf8(), QUrl::TolerantMode); - - // no scheme - QTest::newRow("add scheme-0") << "webkit.org" << QUrl("http://webkit.org"); - QTest::newRow("add scheme-1") << "www.webkit.org" << QUrl("http://www.webkit.org"); - QTest::newRow("add scheme-2") << "ftp.webkit.org" << QUrl("ftp://ftp.webkit.org"); - QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit"); - - // QUrl's tolerant parser should already handle this - QTest::newRow("not-encoded-0") << "http://webkit.org/test page.html" << QUrl("http://webkit.org/test%20page.html"); - - // Make sure the :80, i.e. port doesn't screw anything up - QUrl portUrl("http://webkit.org"); - portUrl.setPort(80); - QTest::newRow("port-0") << "webkit.org:80" << portUrl; - QTest::newRow("port-1") << "http://webkit.org:80" << portUrl; - - // mailto doesn't have a ://, but is valid - QUrl mailto("ben@meyerhome.net"); - mailto.setScheme("mailto"); - QTest::newRow("mailto") << "mailto:ben@meyerhome.net" << mailto; - - // misc - QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost"); - QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80"); - QTest::newRow("spaces-0") << " http://webkit.org/test page.html " << QUrl("http://webkit.org/test%20page.html"); - - // FYI: The scheme in the resulting url user - QUrl authUrl("user:pass@domain.com"); - QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl; -} - -// public static QUrl guessUrlFromString(QString const& string) -void tst_QWebView::guessUrlFromString() -{ - QFETCH(QString, string); - QFETCH(QUrl, guessUrlFromString); - - QUrl url = QWebView::guessUrlFromString(string); - QCOMPARE(url, guessUrlFromString); -} - void tst_QWebView::getWebKitVersion() { QVERIFY(qWebKitVersion().toDouble() > 0); @@ -193,18 +132,18 @@ void tst_QWebView::reusePage() mainFrame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath())); if (html.contains("</embed>")) { // some reasonable time for the PluginStream to feed test.swf to flash and start painting - QTest::qWait(2000); + waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000); } view1->show(); - QTest::qWait(2000); + QTest::qWaitForWindowShown(view1); delete view1; QVERIFY(page != 0); // deleting view must not have deleted the page, since it's not a child of view QWebView *view2 = new QWebView; view2->setPage(page); view2->show(); // in Windowless mode, you should still be able to see the plugin here - QTest::qWait(2000); + QTest::qWaitForWindowShown(view2); delete view2; delete page; // must not crash @@ -212,6 +151,46 @@ void tst_QWebView::reusePage() QDir::setCurrent(QApplication::applicationDirPath()); } +// Class used in crashTests +class WebViewCrashTest : public QObject { + Q_OBJECT + QWebView* m_view; +public: + bool m_executed; + + + WebViewCrashTest(QWebView* view) + : m_view(view) + , m_executed(false) + { + view->connect(view, SIGNAL(loadProgress(int)), this, SLOT(loading(int))); + } + +private slots: + void loading(int progress) + { + if (progress >= 20 && progress < 90) { + QVERIFY(!m_executed); + m_view->stop(); + m_executed = true; + } + } +}; + + +// Should not crash. +void tst_QWebView::crashTests() +{ + // Test if loading can be stopped in loadProgress handler without crash. + // Test page should have frames. + QWebView view; + WebViewCrashTest tester(&view); + QUrl url("qrc:///data/index.html"); + view.load(url); + QTRY_VERIFY(tester.m_executed); // If fail it means that the test wasn't executed. +} + + QTEST_MAIN(tst_QWebView) #include "tst_qwebview.moc" diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.qrc b/WebKit/qt/tests/qwebview/tst_qwebview.qrc new file mode 100644 index 0000000..ede34a9 --- /dev/null +++ b/WebKit/qt/tests/qwebview/tst_qwebview.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>data/index.html</file> + <file>data/frame_a.html</file> +</qresource> +</RCC> + diff --git a/WebKit/qt/tests/tests.pro b/WebKit/qt/tests/tests.pro index 81cc8f3..b967ca9 100644 --- a/WebKit/qt/tests/tests.pro +++ b/WebKit/qt/tests/tests.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebplugindatabase qwebview qwebhistory +SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebview qwebhistory qwebinspector greaterThan(QT_MINOR_VERSION, 4): SUBDIRS += benchmarks/painting/tst_painting.pro benchmarks/loading/tst_loading.pro diff --git a/WebKit/qt/tests/util.h b/WebKit/qt/tests/util.h index 7f7e613..15af262 100644 --- a/WebKit/qt/tests/util.h +++ b/WebKit/qt/tests/util.h @@ -18,6 +18,33 @@ */ // Functions and macros that really need to be in QTestLib +#include <QEventLoop> +#include <QSignalSpy> +#include <QTimer> + +/** + * Starts an event loop that runs until the given signal is received. + * Optionally the event loop + * can return earlier on a timeout. + * + * \return \p true if the requested signal was received + * \p false on timeout + */ +static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) +{ + QEventLoop loop; + QObject::connect(obj, signal, &loop, SLOT(quit())); + QTimer timer; + QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); + if (timeout > 0) { + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + } + loop.exec(); + return timeoutSpy.isEmpty(); +} + // Will try to wait for the condition while allowing event processing #define QTRY_VERIFY(__expr) \ do { \ @@ -45,4 +72,3 @@ } \ QCOMPARE(__expr, __expected); \ } while(0) - diff --git a/WebKit/win/AccessibleBase.cpp b/WebKit/win/AccessibleBase.cpp index 55cbab3..47b8369 100644 --- a/WebKit/win/AccessibleBase.cpp +++ b/WebKit/win/AccessibleBase.cpp @@ -190,11 +190,9 @@ HRESULT STDMETHODCALLTYPE AccessibleBase::get_accDescription(VARIANT vChild, BST if (FAILED(hr)) return hr; - // TODO: Description, for SELECT subitems, should be a string describing - // the position of the item in its group and of the group in the list (see - // Firefox). - if (*description = BString(wrapper(childObj)->description()).release()) + if (*description = BString(childObj->descriptionForMSAA()).release()) return S_OK; + return S_FALSE; } @@ -211,6 +209,13 @@ HRESULT STDMETHODCALLTYPE AccessibleBase::get_accRole(VARIANT vChild, VARIANT* p if (FAILED(hr)) return hr; + String roleString = childObj->stringRoleForMSAA(); + if (!roleString.isEmpty()) { + V_VT(pvRole) = VT_BSTR; + V_BSTR(pvRole) = BString(roleString).release(); + return S_OK; + } + pvRole->vt = VT_I4; pvRole->lVal = wrapper(childObj)->role(); return S_OK; @@ -232,7 +237,7 @@ HRESULT STDMETHODCALLTYPE AccessibleBase::get_accState(VARIANT vChild, VARIANT* pvState->vt = VT_I4; pvState->lVal = 0; - if (childObj->isAnchor()) + if (childObj->isLinked()) pvState->lVal |= STATE_SYSTEM_LINKED; if (childObj->isHovered()) @@ -514,26 +519,12 @@ HRESULT STDMETHODCALLTYPE AccessibleBase::accDoDefaultAction(VARIANT vChild) // AccessibleBase String AccessibleBase::name() const { - return m_object->title(); + return m_object->nameForMSAA(); } String AccessibleBase::value() const { - return m_object->stringValue(); -} - -String AccessibleBase::description() const -{ - String desc = m_object->accessibilityDescription(); - if (desc.isNull()) - return desc; - - // From the Mozilla MSAA implementation: - // "Signal to screen readers that this description is speakable and is not - // a formatted positional information description. Don't localize the - // 'Description: ' part of this string, it will be parsed out by assistive - // technologies." - return "Description: " + desc; + return m_object->stringValueForMSAA(); } static long MSAARole(AccessibilityRole role) diff --git a/WebKit/win/AccessibleBase.h b/WebKit/win/AccessibleBase.h index c69c57d..3b6bce8 100644 --- a/WebKit/win/AccessibleBase.h +++ b/WebKit/win/AccessibleBase.h @@ -95,7 +95,6 @@ protected: virtual WebCore::String name() const; virtual WebCore::String value() const; - virtual WebCore::String description() const; virtual long role() const; HRESULT getAccessibilityObjectForChild(VARIANT vChild, WebCore::AccessibilityObject*&) const; diff --git a/WebKit/win/CFDictionaryPropertyBag.cpp b/WebKit/win/CFDictionaryPropertyBag.cpp index 32457f1..f4fb5b3 100644 --- a/WebKit/win/CFDictionaryPropertyBag.cpp +++ b/WebKit/win/CFDictionaryPropertyBag.cpp @@ -33,7 +33,7 @@ // CFDictionaryPropertyBag ----------------------------------------------- CFDictionaryPropertyBag::CFDictionaryPropertyBag() -: m_refCount(1) +: m_refCount(0) { gClassCount++; gClassNameCount.add("CFDictionaryPropertyBag"); @@ -45,10 +45,9 @@ CFDictionaryPropertyBag::~CFDictionaryPropertyBag() gClassNameCount.remove("CFDictionaryPropertyBag"); } -CFDictionaryPropertyBag* CFDictionaryPropertyBag::createInstance() +COMPtr<CFDictionaryPropertyBag> CFDictionaryPropertyBag::createInstance() { - CFDictionaryPropertyBag* instance = new CFDictionaryPropertyBag(); - return instance; + return new CFDictionaryPropertyBag; } void CFDictionaryPropertyBag::setDictionary(CFMutableDictionaryRef dictionary) diff --git a/WebKit/win/CFDictionaryPropertyBag.h b/WebKit/win/CFDictionaryPropertyBag.h index 23763b3..3cac464 100644 --- a/WebKit/win/CFDictionaryPropertyBag.h +++ b/WebKit/win/CFDictionaryPropertyBag.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,42 +23,37 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CFDictionaryPropertyBag_H -#define CFDictionaryPropertyBag_H +#ifndef CFDictionaryPropertyBag_h +#define CFDictionaryPropertyBag_h -#include <CoreFoundation/CoreFoundation.h> +#include <WebCore/COMPtr.h> #include <wtf/RetainPtr.h> -class CFDictionaryPropertyBag : public IPropertyBag -{ -public: - static CFDictionaryPropertyBag* createInstance(); -protected: - CFDictionaryPropertyBag(); - ~CFDictionaryPropertyBag(); +typedef struct __CFDictionary* CFMutableDictionaryRef; +class CFDictionaryPropertyBag : public IPropertyBag { public: - // IUnknown - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); - virtual ULONG STDMETHODCALLTYPE AddRef(void); - virtual ULONG STDMETHODCALLTYPE Release(void); + static COMPtr<CFDictionaryPropertyBag> createInstance(); - // IPropertyBag - virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read( - /* [in] */ LPCOLESTR pszPropName, - /* [out][in] */ VARIANT *pVar, - /* [in] */ IErrorLog *pErrorLog); - - virtual HRESULT STDMETHODCALLTYPE Write( - /* [in] */ LPCOLESTR pszPropName, - /* [in] */ VARIANT *pVar); + // IUnknown + virtual ULONG STDMETHODCALLTYPE AddRef(); + virtual ULONG STDMETHODCALLTYPE Release(); void setDictionary(CFMutableDictionaryRef dictionary); CFMutableDictionaryRef dictionary() const; private: + CFDictionaryPropertyBag(); + ~CFDictionaryPropertyBag(); + + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void** ppvObject); + + // IPropertyBag + virtual HRESULT STDMETHODCALLTYPE Read(LPCOLESTR pszPropName, VARIANT*, IErrorLog*); + virtual HRESULT STDMETHODCALLTYPE Write(LPCOLESTR pszPropName, VARIANT*); + RetainPtr<CFMutableDictionaryRef> m_dictionary; ULONG m_refCount; }; -#endif
\ No newline at end of file +#endif // CFDictionaryPropertyBag_h diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog index 6253010..95705a9 100644 --- a/WebKit/win/ChangeLog +++ b/WebKit/win/ChangeLog @@ -1,3 +1,997 @@ +2009-12-10 Jon Honeycutt <jhoneycutt@apple.com> + + Pass more information about a plug-in to the PluginHalterDelegate + + Reviewed by Adam Roben. + + * Interfaces/IWebPluginHalterDelegate.idl: + Add new parameters. + + * WebCoreSupport/WebPluginHalterClient.cpp: + (WebPluginHalterClient::shouldHaltPlugin): + Update for new parameters. Pass them when making the delegate call. + + * WebCoreSupport/WebPluginHalterClient.h: + Update for new parameters. + +2009-12-09 Brent Fulgham <bfulgham@webkit.org> + + Revert incorrect commit-box update r51911. + It mistakenly set the selectAll implementation in the + deslectAll method. + + * WebFrame.cpp: + (WebFrame::deselectAll): + +2009-12-09 Brent Fulgham <bfulgham@webkit.org> + + Reviewed by Darin Adler. + + Provide an implementation for 'selectAll' + https://bugs.webkit.org/show_bug.cgi?id=32296 + + * WebFrame.cpp: + (WebFrame::selectAll): Implement "SelectAll" command. + +2009-12-09 Brent Fulgham <bfulgham@webkit.org> + + Reviewed by Darin Adler. + + Provide an implementation for 'selectAll' + https://bugs.webkit.org/show_bug.cgi?id=32296 + + * WebFrame.cpp: + (WebFrame::selectAll): Implement "SelectAll" command. + +2009-12-08 Chris Marrin <cmarrin@apple.com> + + Reviewed by Adam Roben. + + Delay load DLLs for accelerated compositing + https://bugs.webkit.org/show_bug.cgi?id=31856 + + If the DLLs (d3d9 and QuartzCore). are not present it + turns off accelerated compositing and avoids calling + any of the functions in the DLLs. + + * WebView.cpp: + * WebView.h: + +2009-12-08 Adam Roben <aroben@apple.com> + + Windows build fix + + * Interfaces/WebKit.idl: Touched this to force Interfaces.vcproj to rebuild. + +2009-12-08 John Sullivan <sullivan@apple.com> + + Reviewed by Dan Bernstein + + Split two-clause assertions into two separate assertions. + + * DOMHTMLClasses.cpp: + (DOMHTMLInputElement::isTextField): + Split a two-clause assertion into two separate assertions. + (DOMHTMLInputElement::rectOnScreen): + Added the two assertions here that all other functions in this group shared. + (DOMHTMLInputElement::selectedRange): + Split a two-clause assertion into two separate assertions. + (DOMHTMLInputElement::setAutofilled): + Split a two-clause assertion into two separate assertions. + (DOMHTMLInputElement::isAutofilled): + Split a two-clause assertion into two separate assertions. + +2009-12-08 Nikolas Zimmermann <nzimmermann@rim.com> + + Rubber-stamped by Maciej Stachowiak. + + Turn on (SVG) Filters for Win. + https://bugs.webkit.org/show_bug.cgi?id=32224 + + * WebKit.vcproj/WebKit.vcproj: + +2009-12-08 John Sullivan <sullivan@apple.com> + + Add isAutofilled getter to match existing setter. + + Reviewed by Ada Chan. + + * DOMHTMLClasses.cpp: + (DOMHTMLInputElement::isAutofilled): + Implemented new cover function. + + * DOMHTMLClasses.h: + Declared new cover function. + + * Interfaces/DOMPrivate.idl: + Declared new interface. + +2009-12-07 Gavin Barraclough <barraclough@apple.com> + + Reviewed by NOBODY (Windows build fix part III). + + * WebView.cpp: + (WebView::stringByEvaluatingJavaScriptFromString): + +2009-12-07 Gavin Barraclough <barraclough@apple.com> + + Reviewed by NOBODY (Windows build fix part II). + + * WebView.cpp: + (WebView::stringByEvaluatingJavaScriptFromString): + +2009-12-03 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7214236> and http://webkit.org/b/32052 - Implement HTML5 state object history API + + * Interfaces/IWebFrameLoadDelegatePrivate2.idl: + * WebCoreSupport/WebFrameLoaderClient.cpp: + (WebFrameLoaderClient::dispatchDidPushStateWithinPage): + (WebFrameLoaderClient::dispatchDidReplaceStateWithinPage): + (WebFrameLoaderClient::dispatchDidPopStateWithinPage): + * WebCoreSupport/WebFrameLoaderClient.h: + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebCoreSupport/WebInspectorClient.cpp: + (WebInspectorClient::attachWindow): + (WebInspectorClient::detachWindow): + (WebInspectorClient::showWindowWithoutNotifications): + * WebCoreSupport/WebInspectorClient.h: + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * WebCoreSupport/WebFrameLoaderClient.cpp: + (WebFrameLoaderClient::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebFrameLoaderClient::dispatchDidRemoveBackForwardItem): ditto. + (WebFrameLoaderClient::dispatchDidChangeBackForwardIndex): ditto. + * WebCoreSupport/WebFrameLoaderClient.h: + +2009-12-02 Timothy Hatcher <timothy@apple.com> + + Move setValueForUser to the end of the DOMHTMLInputElement interface + so it is fine for binary compatibility. + + Directed by Steve Falkenburg. + + * Interfaces/DOMHTML.idl: + +2009-12-02 Timothy Hatcher <timothy@apple.com> + + Expose setValueForUser for the COM DOMHTMLInputElement. + + <rdar://problem/6760590> Would like a way to detect a login form AutoFill from JavaScript + + Reviewed by Dan Bernstein. + + * DOMHTMLClasses.cpp: + (DOMHTMLInputElement::setValueForUser): + * Interfaces/DOMHTML.idl: + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Not reviewed. Try to fix windows build. + + * WebFrame.cpp: + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Simon Fraser. + + Add SVG animation test framework with 'snapshot' functionality + https://bugs.webkit.org/show_bug.cgi?id=31897 + + Add API used by the new 'sampleSVGAnimationForElementAtTime' DRT method, + forwarding the call to SVGDocumentExtensions, if SVG is enabled. + + Implemented just like the existing pauseAnimation* methods for CSS animations. + + * Interfaces/IWebFramePrivate.idl: + * WebFrame.cpp: + (WebFrame::pauseSVGAnimation): + * WebFrame.h: + +2009-11-30 Adam Roben <aroben@apple.com> + + Fix double-free of BSTRs passed to WebNavigationData::createInstance + + WebFrameLoaderClient::updateGlobalHistory was converting + WebCore::Strings to WebCore::BStrings, then passing them to + WebNavigationData::createInstance. But the latter function takes BSTR + parameters and adopts them into WebCore::BStrings. So the end result + was that two WebCore::BStrings would end up freeing each underlying + BSTR. + + The fix is to only convert to WebCore::BString inside + WebNavigationData. + + Fixes <http://webkit.org/b/31998> <rdar://problem/7383452> REGRESSION + (r49564): Crash in updateGlobalHistory when running Javascript iBench + test + + I couldn't find a way to reproduce this in DumpRenderTree. + + Reviewed by Steve Falkenburg. + + * WebCoreSupport/WebFrameLoaderClient.cpp: + (WebFrameLoaderClient::updateGlobalHistory): Pass WebCore::Strings to + WebNavigationData::createInstance. + + * WebNavigationData.cpp: + (WebNavigationData::WebNavigationData): + (WebNavigationData::createInstance): + * WebNavigationData.h: + Changed to take const WebCore::String&s instead of BSTRs and to + convert the Strings to BStrings at this level. + +2009-11-30 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Adam Roben. + + WebKit clients that don't implement didClearWindowObjectForFrameInScriptWorld should fall back to didClearWindowObject + https://bugs.webkit.org/show_bug.cgi?id=31986 + + * WebFrame.cpp: + (WebFrame::dispatchDidClearWindowObjectInWorld): Fall back if E_NOTIMPL returned. + +2009-11-24 Chris Marrin <cmarrin@apple.com> + + Another Windows build fix + + Got rid of d3d.lib and d3dx9.lib dependency. Not needed until + we turn on ACCELERATED_COMPOSITING + + * WebKit.vcproj/WebKit.vcproj: + +2009-11-24 Chris Marrin <cmarrin@apple.com> + + Fixed Windows build + + Got rid of QuartzCore.lib dependency. Not needed until + we turn on ACCELERATED_COMPOSITING + + * WebKit.vcproj/WebKit.vcproj: + +2009-11-24 Chris Marrin <cmarrin@apple.com> + + Reviewed by Simon Fraser. + + Implement accelerated compositing + https://bugs.webkit.org/show_bug.cgi?id=27314 + + This is the WebKit side of the implementation. It plumbs the root layer + from WebCore. It also makes changes to WebView which places the + backing store of the page into the root compositing layer so it is + properly composited with all the other layers. This deals with resizing, + scrolling, and incremental repaint of the page. + + * WebCoreSupport/WebChromeClient.cpp: + (WebChromeClient::attachRootGraphicsLayer): + (WebChromeClient::scheduleCompositingLayerSync): + * WebCoreSupport/WebChromeClient.h: + (WebChromeClient::setNeedsOneShotDrawingSynchronization): + * WebKit.vcproj/WebKit.vcproj: + * WebView.cpp: + (WebView::WebView): + (WebView::close): + (WebView::repaint): + (WebView::scrollBackingStore): + (WebView::paint): + (WebViewWndProc): + (WebView::setRootChildLayer): + (WebView::setAcceleratedCompositing): + (WebView::setRootLayerContents): + * WebView.h: + (WebView::isAcceleratedCompositing): + (WebView::resizeLayerWindow): + (WebView::layerWindowBecameVisible): + (WebView::setRootLayerNeedsDisplay): + +2009-11-23 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + Include "config.h" to meet Coding Style Guidelines + https://bugs.webkit.org/show_bug.cgi?id=31792 + + * GEN_DOMObject.cpp: + * WebScriptObject.cpp: + +2009-11-21 Jon Honeycutt <jhoneycutt@apple.com> + + Windows build fix. Unreviewed. + + * Interfaces/IWebSerializedJSValue.idl: + +2009-11-20 Jon Honeycutt <jhoneycutt@apple.com> + + DOMElement::tagName() is unimplemented + + https://bugs.webkit.org/show_bug.cgi?id=31746 + + Reviewed by Darin Adler. + + * DOMCoreClasses.cpp: + (DOMElement::tagName): + Create a BString from the element's tag name, and release its BSTR + into result. + +2009-11-20 Jon Honeycutt <jhoneycutt@apple.com> + + DOMNode::childNodes() is unimplemented + + https://bugs.webkit.org/show_bug.cgi?id=31745 + + Reviewed by Darin Adler. + + * DOMCoreClasses.cpp: + (DOMNode::childNodes): + Create a DOMNodeList from the node's child nodes. + +2009-11-20 Dave Hyatt <hyatt@apple.com> + + Reviewed by Jon Honeycutt. + + Change WebSerializedJSValue on Windows to have a zero-argument createInstance call. Move the + serialization into a separate serialize() function that can be called after the object has been + created. + + Fix a typo in serialize() caused when fixing build bustage (put a ! back in). + + * Interfaces/IWebSerializedJSValue.idl: + * WebSerializedJSValue.cpp: + (WebSerializedJSValue::WebSerializedJSValue): + (WebSerializedJSValue::createInstance): + (WebSerializedJSValue::serialize): + (WebSerializedJSValue::deserialize): + * WebSerializedJSValue.h: + +2009-11-20 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Dave Hyatt. + + Another go at the Windows Build Fix - this is a couple steps of it, + so a little more involved than most build fixes. + + * Interfaces/IWebSerializedJSValue.idl: + * Interfaces/JavaScriptCoreAPITypes.idl: + * WebKit.vcproj/Interfaces.vcproj: + * WebSerializedJSValue.cpp: + (WebSerializedJSValue::deserialize): + * WebSerializedJSValue.h: + +2009-11-20 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Dave Hyatt. + + Build fix for Windows - only declare JSContextRef once, instead + of in two different idl files. Create a new file to hold the + definition of JSContextRef. + + * Interfaces/IWebFrameLoadDelegate.idl: + * Interfaces/IWebSerializedJSValue.idl: + * Interfaces/JavaScriptCoreAPITypes.idl: Added. + * Interfaces/WebKit.idl: + * WebKit.vcproj/Interfaces.vcproj: + +2009-11-20 Dave Hyatt <hyatt@apple.com> + + Reviewed by Oliver Hunt and Jon Honeycutt. + + Add support for WebSerializedJSValue to WebKit. This object wraps the SerializedScriptValue functionality in WebCore + and exposes the ability to do JS value serialization/deserialization to WebKit clients. + + * Interfaces/IWebSerializedJSValue.idl: Added. + * Interfaces/WebKit.idl: + * WebKit.vcproj/WebKit.vcproj: + * WebSerializedJSValue.cpp: Added. + (WebSerializedJSValue::WebSerializedJSValue): + (WebSerializedJSValue::~WebSerializedJSValue): + (WebSerializedJSValue::createInstance): + (WebSerializedJSValue::AddRef): + (WebSerializedJSValue::Release): + (WebSerializedJSValue::QueryInterface): + (WebSerializedJSValue::deserialize): + * WebSerializedJSValue.h: Added. + +2009-11-19 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=31690 + Make SocketStreamHandleCFNet work on Windows + + * WebDownloadCFNet.cpp: + (WebDownload::init): + (WebDownload::initWithRequest): + (WebDownload::initToResumeWithBundle): + Update for loaderRunLoop() now being in its own header. + +2009-11-19 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/7035231> + Support closed caption in <video> element + + * WebCoreLocalizedStrings.cpp: + (WebCore::localizedMediaControlElementString): + (WebCore::localizedMediaControlElementHelpText): + Add accessibility help strings for media controller closed caption button. + +2009-11-18 Michelangelo De Simone <micdesim@gmail.com> + + Reviewed by Darin Adler. + + Fix for <https://bugs.webkit.org/show_bug.cgi?id=27959>. + Support for validationMessage attribute, as per HTML5 specs. + + * WebCoreLocalizedStrings.cpp: + (WebCore::validationMessageValueMissingText): + (WebCore::validationMessageTypeMismatchText): + (WebCore::validationMessagePatternMismatchText): + (WebCore::validationMessageTooLongText): + (WebCore::validationMessageRangeUnderflowText): + (WebCore::validationMessageRangeOverflowText): + (WebCore::validationMessageStepMismatchText): + +2009-11-18 Daniel Bates <dbates@webkit.org> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=31186 + + Changes associated with renaming RenderTextControl::isUserEdited. + + * DOMHTMLClasses.cpp: + (DOMHTMLInputElement::isUserEdited): Formerly named isUserEdited. + (DOMHTMLTextAreaElement::isUserEdited): Ditto. + +2009-11-12 Jon Honeycutt <jhoneycutt@apple.com> + + Implement DOMHTMLInputElement::replaceCharactersInRange(). + + https://bugs.webkit.org/show_bug.cgi?id=31492 + + Reviewed by Dan Bernstein. + + * DOMHTMLClasses.cpp: + (DOMHTMLInputElement::replaceCharactersInRange): + Get the text of the input field. Replace the given range with the + replacement text, and set this new string as the input element's value. + Select from index to the end of the field. This matches the + implementation in the Obj-C bindings. + +2009-11-12 Jon Honeycutt <jhoneycutt@apple.com> + + DOMHTMLOptionElement is missing some functionality. + + https://bugs.webkit.org/show_bug.cgi?id=31491 + + Reviewed by Dan Bernstein. + + * DOMHTMLClasses.cpp: + (DOMHTMLOptionElement::text): + Cast m_element to an HTMLOptionElement, and call its text() function. + (DOMHTMLOptionElement::label): + Ditto, for label(). + +2009-11-12 Jon Honeycutt <jhoneycutt@apple.com> + + DOMHTMLSelectElement is missing some implementation. + + https://bugs.webkit.org/show_bug.cgi?id=31489 + + Reviewed by Dan Bernstein. + + * DOMHTMLClasses.cpp: + (DOMHTMLSelectElement::options): + Cast m_element to an HTMLSelectElement. If it has no options, return + E_FAIL. Otherwise, create a DOMHTMLOptionsCollection to wrap the + options, and return it. + (DOMHTMLSelectElement::activateItemAtIndex): + If the index is out of bounds, return E_FAIL. Otherwise, select the + item. + +2009-11-12 Jon Honeycutt <jhoneycutt@apple.com> + + DOMHTMLOptionsCollection is missing some implementation. + + https://bugs.webkit.org/show_bug.cgi?id=31488 + + Reviewed by Dan Bernstein. + + * DOMHTMLClasses.cpp: + (DOMHTMLOptionsCollection::DOMHTMLOptionsCollection): + Initialize m_collection. + (DOMHTMLOptionsCollection::createInstance): + Create a DOMHTMLOptionsCollection. If we fail to query for + IDOMHTMLOptionsCollection, delete it, and return 0. Otherwise, return + the result. + (DOMHTMLOptionsCollection::length): + (DOMHTMLOptionsCollection::item): + Create a DOMNode for the WebCore Node. If this is 0, return E_FAIL. + (DOMHTMLOptionsCollection::namedItem): + Correct the signature of this function. + + * DOMHTMLClasses.h: + Declare DOMHTMLOptionsCollection::createInstance(). Correct the + signature of namedItem() to match IDOMHTMLOptionsCollection. Add a + member to DOMHTMLOptionsCollection to hold the WebCore object. + +2009-11-12 Jon Honeycutt <jhoneycutt@apple.com> + + DOMHTMLInputElement::rectOnScreen() returns the wrong rect + + https://bugs.webkit.org/show_bug.cgi?id=31487 + + Reviewed by Darin Adler. + + * DOMHTMLClasses.cpp: + (DOMHTMLInputElement::rectOnScreen): + Return the rect on screen, not the rect in the window. + +2009-11-17 Brent Fulgham <bfulgham@webkit.org> + + Reviewed by NOBODY - Build Fix. + + Correct build error in Debug_Cairo target after @49705. + + * WebKit.vcproj/WebKit.vcproj: Revise JavaScriptCore.lib + dependency to have proper "_debug" suffix needed by + the Debug_Cairo target. + +2009-11-17 Brian Weinstein <bweinstein@apple.com> + + Reviewed by NOBODY - Build Fix. + + Touch files to try to fix the build. + + * Interfaces/IWebInspector.idl: + * Interfaces/WebKit.idl: + * WebKit.vcproj/Interfaces.vcproj: + +2009-11-17 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Web Inspector: Make DRT show web inspector for tests in inspector/ folder. + - Updated DRT to show/close inspector for all tests under /inspector + - Introduced LayoutTestController::setTimelineProfilingEnabled and + WebInspector::setTimelineProfilingEnabled beside setJavaScriptProfilingEnabled + - Removed reload on each inspector test + - Renamed fast/inspector to fast/inspector-support in order not to trigger + inspector for those. + - Reimplemented timeline tests in order to get rid of reload there. + - Moved tests that don't require harness into the fast group. + + https://bugs.webkit.org/show_bug.cgi?id=31472 + + * Interfaces/IWebInspector.idl: + * WebInspector.cpp: + (WebInspector::isTimelineProfilingEnabled): + (WebInspector::setTimelineProfilingEnabled): + * WebInspector.h: + +2009-11-13 Adam Roben <aroben@apple.com> + + Build fix + + * Interfaces/WebKit.idl: Touch this to force interfaces to rebuild. + +2009-11-13 Adam Roben <aroben@apple.com> + + Tell the WebFrameLoadDelegate when window objects in isolated worlds + are cleared + + Fixes <http://webkit.org/b/31124>. + + Reviewed by Dave Hyatt. + + * Interfaces/IWebFrameLoadDelegatePrivate2.idl: Added + didClearWindowObjectForFrameInScriptWorld. + + * WebFrame.cpp: + (WebFrame::dispatchDidClearWindowObjectInWorld): + * WebFrame.h: + Replaced windowObjectCleared with this function. If the delegate + implements IWebFrameLoadDelegatePrivate2, call + didClearWindowObjectForFrameInScriptWorld. Otherwise, if the passed-in + world is the mainThreadNormalWorld(), call + didClearWindowObjectForFrame. + + * WebScriptWorld.cpp: + (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in + existence. + (WebScriptWorld::WebScriptWorld): Add ourselves to allWorlds(). + (WebScriptWorld::~WebScriptWorld): Remove ourselves from allWorlds(). + (WebScriptWorld::standardWorld): Added this non-COM getter for the + standard world, which the COM getter now calls through to. + (WebScriptWorld::findOrCreateWorld): Added. Returns the existing + WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't + already exist. + + * WebScriptWorld.h: Added new standardWorld overload, made one + overload of createInstance private, and added findOrCreateWorld. + +2009-11-13 Adam Roben <aroben@apple.com> + + Build fix + + * Interfaces/WebKit.idl: Un-sort the #includes again. Apparently they + are order-dependent! + +2009-11-13 Adam Roben <aroben@apple.com> + + Touch WebKit.idl to fix the Windows build + + * Interfaces/WebKit.idl: Sorted #includes. + +2009-11-13 Adam Roben <aroben@apple.com> + + Finish replacing worldIDs with world objects + + The only remaining use of worldIDs was in a method only used by DRT + for the isolated worlds tests. + + Fixes <http://webkit.org/b/31414> Replace worldIDs with world objects + + Reviewed by Mark Rowe. + + * Interfaces/IWebFramePrivate.idl: + * WebFrame.cpp: + (WebFrame::stringByEvaluatingJavaScriptInScriptWorld): + * WebFrame.h: + Renamed from stringByEvaluatingJavaScriptInIsolatedWorld. Now takes an + IWebScriptWorld instead of a worldID, so we don't need to maintain a + map of worldID -> world anymore. + +2009-11-12 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Darin Adler. + + externalRepresentation should take Frame as the argument + https://bugs.webkit.org/show_bug.cgi?id=31393 + + No new tests as this is just a refactoring. + + * WebFrame.cpp: + (WebFrame::renderTreeAsExternalRepresentation): + +2009-11-12 Adam Roben <aroben@apple.com> + + Replace worldIDs with world objects + + WebScriptWorld is the new object that represents a world. The only + place worldID is still used is in + IWebFramePrivate::stringByEvaluatingJavaScriptInIsolatedWorld, but + that will change soon. + + Part of <http://webkit.org/b/31414> Implement new SPI for dealing with + user scripts/stylesheets and isolated worlds + + Reviewed by Sam Weinig. + + * ForEachCoClass.h: Added WebScriptWorld. + + * Interfaces/IWebFramePrivate.idl: Replaced contextForWorldID with + contextForWorld. + + * Interfaces/IWebScriptWorld.idl: Added. + + * Interfaces/IWebViewPrivate.idl: Changed the user script/stylesheet + functions to take an IWebScriptWorld instead of a worldID. + + * Interfaces/WebKit.idl: Added WebScriptWorld. + + * WebFrame.cpp: + (WebFrame::contextForWorld): Renamed from contextForWorldID. Now takes + an IWebScriptWorld. + (WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld): Moved the + bizarre world caching/creation logic that DRT depends on here from the + findWorld function in ScriptController.cpp. Updated to use + ScriptController::executeScriptInWorld instead of + ScriptController::executeScriptInIsolatedWorld. + + * WebFrame.h: Replaced contextForWorldID with contextForWorld. + + * WebScriptWorld.cpp: Added. + (WebScriptWorld::WebScriptWorld): + (WebScriptWorld::~WebScriptWorld): + (WebScriptWorld::createInstance): + (WebScriptWorld::AddRef): + (WebScriptWorld::Release): + (WebScriptWorld::QueryInterface): + Standard COM class implementations. + + (WebScriptWorld::standardWorld): Returns a shared instance that represents + WebCore's mainThreadNormalWorld(). + + * WebScriptWorld.h: Added. + (WebScriptWorld::world): Simple getter. + + * WebKit.vcproj/Interfaces.vcproj: Added IWebScriptWorld.idl. + + * WebKit.vcproj/WebKit.vcproj: Added WebScriptWorld. + + * WebKitClassFactory.cpp: Added WebScriptWorld. + + * WebView.cpp: + (WebView::addUserScriptToGroup): + (WebView::addUserStyleSheetToGroup): + (WebView::removeUserScriptFromGroup): + (WebView::removeUserStyleSheetFromGroup): + (WebView::removeUserScriptsFromGroup): + (WebView::removeUserStyleSheetsFromGroup): + * WebView.h: + Changed these functions to take an IWebScriptWorld instead of a worldID. + +2009-11-12 Adam Roben <aroben@apple.com> + + Small clean-up in WebView's user content functions + + Preparation for <http://webkit.org/b/31414> Implement new SPI for + dealing with user scripts/stylesheets and isolated worlds + + Reviewed by Dave Hyatt. + + * WebView.cpp: + (toString): + (toKURL): + Added these helper functions to convert BSTRs to WebCore types. + + (toStringVector): + (WebView::addUserScriptToGroup): + (WebView::addUserStyleSheetToGroup): + (WebView::removeUserScriptFromGroup): + (WebView::removeUserStyleSheetFromGroup): + (WebView::removeUserScriptsFromGroup): + (WebView::removeUserStyleSheetsFromGroup): + (WebView::removeAllUserContentFromGroup): + Use the new helper functions. + +2009-11-11 Beth Dakin <bdakin@apple.com> + + Build fix. No review needed. + + * WebKitGraphics.cpp: + (WebDrawText): + +2009-11-10 Daniel Bates <dbates@webkit.org> + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=30754 + + Modified WebDropSource::QueryContinueDrag so as to not call EventHandler::dragSourceMovedTo. + + * WebDropSource.cpp: + (WebDropSource::QueryContinueDrag): Removed call to EventHandler::dragSourceMovedTo. + +2009-11-10 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Dan Bernstein. + + https://bugs.webkit.org/show_bug.cgi?id=31312 + Decouple authentication panel callbacks from ResourceHandle + + * WebCoreSupport/WebFrameLoaderClient.cpp: + (WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge): + * WebURLAuthenticationChallenge.cpp: + (WebURLAuthenticationChallenge::initWithAuthenticationChallenge): + (WebURLAuthenticationChallenge::sender): + * WebURLAuthenticationChallengeSender.cpp: + (WebURLAuthenticationChallengeSender::WebURLAuthenticationChallengeSender): + (WebURLAuthenticationChallengeSender::createInstance): + (WebURLAuthenticationChallengeSender::authenticationClient): + * WebURLAuthenticationChallengeSender.h: + * WebURLAuthenticationChallengeSenderCFNet.cpp: + (WebURLAuthenticationChallengeSender::cancelAuthenticationChallenge): + (WebURLAuthenticationChallengeSender::continueWithoutCredentialForAuthenticationChallenge): + (WebURLAuthenticationChallengeSender::useCredential): + Adjusted for WebCore changes. + +2009-11-10 Brian Weinstein <bweinstein@apple.com> + + Reviewed by NOBODY - Build Fix. + + Updated fillRoundedRect to take a ColorSpace argument. + + * WebCoreSupport/WebDragClient.cpp: + (WebDragClient::createDragImageForLink): + +2009-11-08 Janne Koskinen <janne.p.koskinen@digia.com> + + Reviewed by Holger Freyther. + + ResourceRequest to be class instead of struct + https://bugs.webkit.org/show_bug.cgi?id=30670 + + Started as a compilation fix for Symbian where the compiler makes a distinction between + class and struct in function argument signatures. + Changed forward declaration of ResourceRequest to have class in the forward + declaration instead of struct. + + * WebDownload.h: + +2009-11-05 Adam Roben <aroben@apple.com> + + Make CFDictionaryPropertyBag::createInstance return a COMPtr + + I also cleaned up CFDictionaryPropertyBag's class declaration a little + while I was at it. + + Part of <http://webkit.org/b/25294> <rdar://problem/6803127> All + WebKit/win classes should return COMPtrs from their static constructor + members + + Reviewed by Steve Falkenburg. + + * CFDictionaryPropertyBag.cpp: + (CFDictionaryPropertyBag::CFDictionaryPropertyBag): Changed to + initialize m_refCount to 0. m_refCount gets increased to 1 by + createInstance. + (CFDictionaryPropertyBag::createInstance): Changed to return a COMPtr. + + * CFDictionaryPropertyBag.h: + - Updated copyright years + - Fixed header guard to match current style + - Replaced #include of CoreFoundation.h with forward-declaration of + CFMutableDictionaryRef + - Added #include of COMPtr.h + - Fixed opening brace placement in class declaration + - Made createInstance return a COMPtr + - Made constructor/destructor private + - Made QueryInterface and IPropertyBag functions private + - Removed unnecessary parameter names and MIDL comments + + * WebCache.cpp: + (WebCache::statistics): Updated for change to + CFDictionaryPropertyBag::createInstance. Now uses releaseRef to place + the IPropertyBag pointers into the s array. + + * WebCoreSupport/WebFrameLoaderClient.cpp: + (WebFrameLoaderClient::dispatchDidFailToStartPlugin): + * WebDatabaseManager.cpp: + (WebDatabaseManager::dispatchDidModifyDatabase): + * WebFrame.cpp: + (WebFrame::createJavaAppletWidget): + Updated for change to CFDictionaryPropertyBag::createInstance. + + * WebHistory.cpp: Removed releaseUserInfo, which is no longer needed. + That function was also doing an unnecessary call to setDictionary(0). + (createUserInfoFromArray): + (createUserInfoFromHistoryItem): + Changed to return COMPtr. + + (WebHistory::loadFromURL): Updated for change to + CFDictionaryPropertyBag::createInstance. + + (WebHistory::removeAllItems): Updated for change to + CFDictionaryPropertyBag::createInstance, which fixed a leak! We had + forgotten to call releaseUserInfo here. + + (WebHistory::removeItem): + (WebHistory::addItem): + (WebHistory::visitedURL): + * WebIconDatabase.cpp: + (postDidAddIconNotification): + Updated for change to CFDictionaryPropertyBag::createInstance. + + * WebKitClassFactory.cpp: + (releaseRefFromCreateInstance): Added this overloaded function + template to abstract away the difference between createInstance + functions that return a ref'd pointer and createInstance functions + that return a COMPtr. + (WebKitClassFactory::CreateInstance): Changed to use + releaseRefFromCreateInstance. + +2009-11-03 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Steve Falkenburg. + + WebActionModifierFlagsKey should return an unsigned, because + flags imply a bitmask, and that is what other classes expect from + it. + + * WebActionPropertyBag.cpp: + (WebActionPropertyBag::Read): + +2009-11-02 Eric Carlson <eric.carlson@apple.com> + + Reviewed by John Sullivan and Mark Rowe. + + <rdar://problem/7356733> Voiceover does not read correct media controller time values + + * WebCoreLocalizedStrings.cpp: + (WebCore::localizedMediaTimeDescription): + +2009-10-29 Jon Honeycutt <jhoneycutt@apple.com> + + MSAA: Accessibility of headings is not correct + + https://bugs.webkit.org/show_bug.cgi?id=30937 + + Reviewed by Alice Liu. + + * AccessibleBase.cpp: + (AccessibleBase::get_accDescription): + Call the object's descriptionForMSAA(). Moved the comment to the + WebCore file. + (AccessibleBase::get_accRole): + If the object has a string role, return that. Otherwise, return the + integer role. + + * AccessibleBase.h: + Removed description(), as this was moved to WebCore. + +2009-10-29 Jon Honeycutt <jhoneycutt@apple.com> + + MSAA: Accessibility of links is wrong + + https://bugs.webkit.org/show_bug.cgi?id=30928 + + Reviewed by Darin Adler. + + * AccessibleBase.cpp: + (AccessibleBase::get_accState): + Check whether the element is linked, instead of whether the node is an + anchor, so the child "linkable" elements of anchor elements will also + be "linked". + (AccessibleBase::name): + Return the name for MSAA. + (AccessibleBase::value): + Return the string value for MSAA. + +2009-10-30 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Notify the chrome when the focused node has changed. + https://bugs.webkit.org/show_bug.cgi?id=30832 + + Added stub implementation for new ChromeClient function. + + * WebCoreSupport/WebChromeClient.cpp: + (WebChromeClient::focusedNodeChanged): + * WebCoreSupport/WebChromeClient.h: + +2009-10-30 Roland Steiner <rolandsteiner@chromium.org> + + Reviewed by Eric Seidel. + + Remove ENABLE_RUBY guards as discussed with Dave Hyatt and Maciej Stachowiak. + + Bug 28420 - Implement HTML5 <ruby> rendering + (https://bugs.webkit.org/show_bug.cgi?id=28420) + + No new tests (no functional change). + + * WebKit.vcproj/WebKit.vcproj: + +2009-10-29 Mark Rowe <mrowe@apple.com> + + Rubber-stamped by Dan Bernstein. + + <http://webkit.org/b/30938> REGRESSION(r50233): Windows nightlies crash on launch due to changes + to IWebFramePrivate vtable ordering + + * Interfaces/IWebFramePrivate.idl: Move the newly-added method to the end of the interface so that + it doesn't affect the ordering of the vtable. + 2009-10-28 Steve Falkenburg <sfalken@apple.com> Reviewed by Sam "Horatio" Weinig. diff --git a/WebKit/win/DOMCoreClasses.cpp b/WebKit/win/DOMCoreClasses.cpp index f4018c6..8ea7c84 100644 --- a/WebKit/win/DOMCoreClasses.cpp +++ b/WebKit/win/DOMCoreClasses.cpp @@ -150,10 +150,16 @@ HRESULT STDMETHODCALLTYPE DOMNode::parentNode( } HRESULT STDMETHODCALLTYPE DOMNode::childNodes( - /* [retval][out] */ IDOMNodeList** /*result*/) + /* [retval][out] */ IDOMNodeList** result) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!m_node) + return E_FAIL; + + if (!result) + return E_POINTER; + + *result = DOMNodeList::createInstance(m_node->childNodes().get()); + return *result ? S_OK : E_FAIL; } HRESULT STDMETHODCALLTYPE DOMNode::firstChild( @@ -828,10 +834,16 @@ HRESULT STDMETHODCALLTYPE DOMElement::lineBoxRects( // IDOMElement ---------------------------------------------------------------- HRESULT STDMETHODCALLTYPE DOMElement::tagName( - /* [retval][out] */ BSTR* /*result*/) + /* [retval][out] */ BSTR* result) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!m_element) + return E_FAIL; + + if (!result) + return E_POINTER; + + *result = BString(m_element->tagName()).release(); + return S_OK; } HRESULT STDMETHODCALLTYPE DOMElement::getAttribute( diff --git a/WebKit/win/DOMHTMLClasses.cpp b/WebKit/win/DOMHTMLClasses.cpp index 9ce6004..4889ba9 100644 --- a/WebKit/win/DOMHTMLClasses.cpp +++ b/WebKit/win/DOMHTMLClasses.cpp @@ -39,6 +39,7 @@ #include <WebCore/HTMLInputElement.h> #include <WebCore/HTMLNames.h> #include <WebCore/HTMLOptionElement.h> +#include <WebCore/HTMLOptionsCollection.h> #include <WebCore/HTMLSelectElement.h> #include <WebCore/HTMLTextAreaElement.h> #include <WebCore/IntRect.h> @@ -134,11 +135,34 @@ HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::QueryInterface(REFIID riid, // DOMHTMLOptionsCollection --------------------------------------------------- +DOMHTMLOptionsCollection::DOMHTMLOptionsCollection(WebCore::HTMLOptionsCollection* collection) + : m_collection(collection) +{ +} + +IDOMHTMLOptionsCollection* DOMHTMLOptionsCollection::createInstance(WebCore::HTMLOptionsCollection* collection) +{ + if (!collection) + return 0; + + IDOMHTMLOptionsCollection* optionsCollection = 0; + DOMHTMLOptionsCollection* newCollection = new DOMHTMLOptionsCollection(collection); + if (FAILED(newCollection->QueryInterface(IID_IDOMHTMLOptionsCollection, (void**)&optionsCollection))) { + delete newCollection; + return 0; + } + + return optionsCollection; +} + HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::length( - /* [retval][out] */ unsigned int* /*result*/) + /* [retval][out] */ unsigned int* result) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!result) + return E_POINTER; + + *result = m_collection->length(); + return S_OK; } HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::setLength( @@ -149,16 +173,20 @@ HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::setLength( } HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::item( - /* [in] */ unsigned int /*index*/, - /* [retval][out] */ IDOMNode** /*result*/) + /* [in] */ unsigned int index, + /* [retval][out] */ IDOMNode** result) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!result) + return E_POINTER; + + *result = DOMNode::createInstance(m_collection->item(index)); + + return *result ? S_OK : E_FAIL; } HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::namedItem( /* [in] */ BSTR /*name*/, - /* [retval][out] */ IDOMNode* /*result*/) + /* [retval][out] */ IDOMNode** /*result*/) { ASSERT_NOT_REACHED(); return E_NOTIMPL; @@ -667,10 +695,22 @@ HRESULT STDMETHODCALLTYPE DOMHTMLSelectElement::form( } HRESULT STDMETHODCALLTYPE DOMHTMLSelectElement::options( - /* [retval][out] */ IDOMHTMLOptionsCollection** /*result*/) + /* [retval][out] */ IDOMHTMLOptionsCollection** result) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!result) + return E_POINTER; + + *result = 0; + + ASSERT(m_element); + ASSERT(m_element->hasTagName(selectTag)); + HTMLSelectElement* selectElement = static_cast<HTMLSelectElement*>(m_element); + + if (!selectElement->options()) + return E_FAIL; + + *result = DOMHTMLOptionsCollection::createInstance(selectElement->options().get()); + return S_OK; } HRESULT STDMETHODCALLTYPE DOMHTMLSelectElement::disabled( @@ -761,10 +801,17 @@ HRESULT STDMETHODCALLTYPE DOMHTMLSelectElement::remove( // DOMHTMLSelectElement - IFormsAutoFillTransitionSelect ---------------------- HRESULT STDMETHODCALLTYPE DOMHTMLSelectElement::activateItemAtIndex( - /* [in] */ int /*index*/) + /* [in] */ int index) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + ASSERT(m_element); + ASSERT(m_element->hasTagName(selectTag)); + HTMLSelectElement* selectElement = static_cast<HTMLSelectElement*>(m_element); + + if (index >= selectElement->length()) + return E_FAIL; + + selectElement->setSelectedIndex(index); + return S_OK; } // DOMHTMLOptionElement - IUnknown -------------------------------------------- @@ -805,10 +852,19 @@ HRESULT STDMETHODCALLTYPE DOMHTMLOptionElement::setDefaultSelected( } HRESULT STDMETHODCALLTYPE DOMHTMLOptionElement::text( - /* [retval][out] */ BSTR* /*result*/) + /* [retval][out] */ BSTR* result) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!result) + return E_POINTER; + + *result = 0; + + ASSERT(m_element); + ASSERT(m_element->hasTagName(optionTag)); + HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(m_element); + + *result = BString(optionElement->text()).release(); + return S_OK; } HRESULT STDMETHODCALLTYPE DOMHTMLOptionElement::index( @@ -833,10 +889,19 @@ HRESULT STDMETHODCALLTYPE DOMHTMLOptionElement::setDisabled( } HRESULT STDMETHODCALLTYPE DOMHTMLOptionElement::label( - /* [retval][out] */ BSTR* /*result*/) + /* [retval][out] */ BSTR* result) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!result) + return E_POINTER; + + *result = 0; + + ASSERT(m_element); + ASSERT(m_element->hasTagName(optionTag)); + HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(m_element); + + *result = BString(optionElement->label()).release(); + return S_OK; } HRESULT STDMETHODCALLTYPE DOMHTMLOptionElement::setLabel( @@ -1160,7 +1225,17 @@ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::setValue( inputElement->setValue(String((UChar*) value, SysStringLen(value))); return S_OK; } - + +HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::setValueForUser( + /* [in] */ BSTR value) +{ + ASSERT(m_element); + ASSERT(m_element->hasTagName(inputTag)); + HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element); + inputElement->setValueForUser(String(static_cast<UChar*>(value), SysStringLen(value))); + return S_OK; +} + HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::select( void) { ASSERT(m_element && m_element->hasTagName(inputTag)); @@ -1216,7 +1291,8 @@ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::selectionEnd( HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::isTextField( /* [retval][out] */ BOOL* result) { - ASSERT(m_element && m_element->hasTagName(inputTag)); + ASSERT(m_element); + ASSERT(m_element->hasTagName(inputTag)); HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element); *result = inputElement->isTextField() ? TRUE : FALSE; return S_OK; @@ -1225,36 +1301,51 @@ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::isTextField( HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::rectOnScreen( /* [retval][out] */ LPRECT rect) { + ASSERT(m_element); + ASSERT(m_element->hasTagName(inputTag)); rect->left = rect->top = rect->right = rect->bottom = 0; RenderObject* renderer = m_element->renderer(); FrameView* view = m_element->document()->view(); if (!renderer || !view) return E_FAIL; - IntRect coreRect = renderer->absoluteBoundingBoxRect(); - coreRect.setLocation(view->contentsToWindow(coreRect.location())); + IntRect coreRect = view->contentsToScreen(renderer->absoluteBoundingBoxRect()); rect->left = coreRect.x(); rect->top = coreRect.y(); rect->right = coreRect.right(); rect->bottom = coreRect.bottom(); + return S_OK; } HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::replaceCharactersInRange( - /* [in] */ int /*startTarget*/, - /* [in] */ int /*endTarget*/, - /* [in] */ BSTR /*replacementString*/, - /* [in] */ int /*index*/) + /* [in] */ int startTarget, + /* [in] */ int endTarget, + /* [in] */ BSTR replacementString, + /* [in] */ int index) { - ASSERT_NOT_REACHED(); - return E_NOTIMPL; + if (!replacementString) + return E_POINTER; + + ASSERT(m_element); + ASSERT(m_element->hasTagName(inputTag)); + HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element); + + String newValue = inputElement->value(); + String webCoreReplacementString(static_cast<UChar*>(replacementString), SysStringLen(replacementString)); + newValue.replace(startTarget, endTarget - startTarget, webCoreReplacementString); + inputElement->setValue(newValue); + inputElement->setSelectionRange(index, newValue.length()); + + return S_OK; } HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::selectedRange( /* [out] */ int* start, /* [out] */ int* end) { - ASSERT(m_element && m_element->hasTagName(inputTag)); + ASSERT(m_element); + ASSERT(m_element->hasTagName(inputTag)); HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element); *start = inputElement->selectionStart(); *end = inputElement->selectionEnd(); @@ -1264,12 +1355,23 @@ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::selectedRange( HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::setAutofilled( /* [in] */ BOOL filled) { - ASSERT(m_element && m_element->hasTagName(inputTag)); + ASSERT(m_element); + ASSERT(m_element->hasTagName(inputTag)); HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element); inputElement->setAutofilled(!!filled); return S_OK; } +HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::isAutofilled( + /* [retval][out] */ BOOL* result) +{ + ASSERT(m_element); + ASSERT(m_element->hasTagName(inputTag)); + HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element); + *result = inputElement->isAutofilled() ? TRUE : FALSE; + return S_OK; +} + // DOMHTMLInputElement -- IFormPromptAdditions ------------------------------------ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::isUserEdited( @@ -1284,7 +1386,7 @@ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::isUserEdited( if (FAILED(isTextField(&textField)) || !textField) return S_OK; RenderObject* renderer = m_element->renderer(); - if (renderer && toRenderTextControl(renderer)->isUserEdited()) + if (renderer && toRenderTextControl(renderer)->lastChangeWasUserEdit()) *result = TRUE; return S_OK; } @@ -1481,7 +1583,7 @@ HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::isUserEdited( *result = FALSE; ASSERT(m_element); RenderObject* renderer = m_element->renderer(); - if (renderer && toRenderTextControl(renderer)->isUserEdited()) + if (renderer && toRenderTextControl(renderer)->lastChangeWasUserEdit()) *result = TRUE; return S_OK; } diff --git a/WebKit/win/DOMHTMLClasses.h b/WebKit/win/DOMHTMLClasses.h index ddc3dd1..f520c3c 100644 --- a/WebKit/win/DOMHTMLClasses.h +++ b/WebKit/win/DOMHTMLClasses.h @@ -34,6 +34,7 @@ namespace WebCore { class HTMLCollection; + class HTMLOptionsCollection; } class DOMHTMLCollection : public DOMObject, public IDOMHTMLCollection @@ -99,6 +100,9 @@ protected: class DOMHTMLOptionsCollection : public DOMObject, public IDOMHTMLOptionsCollection { +public: + static IDOMHTMLOptionsCollection* createInstance(WebCore::HTMLOptionsCollection*); + // IUnknown virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); virtual ULONG STDMETHODCALLTYPE AddRef(void) { return DOMObject::AddRef(); } @@ -149,7 +153,12 @@ class DOMHTMLOptionsCollection : public DOMObject, public IDOMHTMLOptionsCollect virtual HRESULT STDMETHODCALLTYPE namedItem( /* [in] */ BSTR name, - /* [retval][out] */ IDOMNode *result); + /* [retval][out] */ IDOMNode **result); + +private: + DOMHTMLOptionsCollection(WebCore::HTMLOptionsCollection*); + + RefPtr<WebCore::HTMLOptionsCollection> m_collection; }; class DOMHTMLDocument : public DOMDocument, public IDOMHTMLDocument @@ -2011,9 +2020,15 @@ public: virtual HRESULT STDMETHODCALLTYPE setAutofilled( /* [in] */ BOOL filled); + virtual HRESULT STDMETHODCALLTYPE isAutofilled( + /* [retval][out] */ BOOL *result); + // IFormPromptAdditions virtual HRESULT STDMETHODCALLTYPE isUserEdited( /* [retval][out] */ BOOL *result); + + virtual HRESULT STDMETHODCALLTYPE setValueForUser( + /* [in] */ BSTR value); }; class DOMHTMLTextAreaElement : public DOMHTMLElement, public IDOMHTMLTextAreaElement, public IFormPromptAdditions diff --git a/WebKit/win/ForEachCoClass.h b/WebKit/win/ForEachCoClass.h index 26f4a6c..39f8e32 100644 --- a/WebKit/win/ForEachCoClass.h +++ b/WebKit/win/ForEachCoClass.h @@ -63,6 +63,7 @@ macro(WebCoreStatistics) \ macro(WebCookieManager) \ macro(WebWorkersPrivate) \ + macro(WebScriptWorld) \ // end of macro // Everything below this point is deprecated. Please do not use. diff --git a/WebKit/win/GEN_DOMObject.cpp b/WebKit/win/GEN_DOMObject.cpp index bb108a4..c8d0e3c 100644 --- a/WebKit/win/GEN_DOMObject.cpp +++ b/WebKit/win/GEN_DOMObject.cpp @@ -26,10 +26,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "WebKitDLL.h" - +#include "config.h" #include "GEN_DOMObject.h" +#include "WebKitDLL.h" + #include <wtf/Assertions.h> // DOMObject ------------------------------------------------------------ diff --git a/WebKit/win/Interfaces/DOMHTML.idl b/WebKit/win/Interfaces/DOMHTML.idl index 6c276aa..7ccb682 100644 --- a/WebKit/win/Interfaces/DOMHTML.idl +++ b/WebKit/win/Interfaces/DOMHTML.idl @@ -800,6 +800,11 @@ interface IDOMHTMLInputElement : IDOMElement // attribute long selectionEnd; HRESULT setSelectionEnd([in] long end); HRESULT selectionEnd([out, retval] long* end); + + /* + - (void)setValueForUser:(NSString *)value; + */ + HRESULT setValueForUser([in] BSTR value); } /* diff --git a/WebKit/win/Interfaces/DOMPrivate.idl b/WebKit/win/Interfaces/DOMPrivate.idl index 7210943..3365565 100644 --- a/WebKit/win/Interfaces/DOMPrivate.idl +++ b/WebKit/win/Interfaces/DOMPrivate.idl @@ -51,9 +51,8 @@ interface IDOMElementPrivate : IUnknown /* All the methods in this category are used by Safari forms autofill and should not be used for any other purpose. - They are stopgap measures until we finish transitioning form controls to not use NSView. Each one should become - replaceable by public DOM API, and when that happens Safari will switch to implementations using that public API, - and these will be deleted. + Each one should eventually be replaced by public DOM API, and when that happens Safari will switch to implementations + using that public API, and these will be deleted. @interface DOMHTMLInputElement(FormsAutoFillTransition) */ @@ -89,6 +88,11 @@ interface IFormsAutoFillTransition : IUnknown - (void)_setAutofilled:(BOOL)filled; */ HRESULT setAutofilled([in] BOOL filled); + + /* + - (BOOL)_isAutofilled; + */ + HRESULT isAutofilled([out, retval] BOOL* result); } /* diff --git a/WebKit/win/Interfaces/IWebFrameLoadDelegate.idl b/WebKit/win/Interfaces/IWebFrameLoadDelegate.idl index 66ac241..9847151 100644 --- a/WebKit/win/Interfaces/IWebFrameLoadDelegate.idl +++ b/WebKit/win/Interfaces/IWebFrameLoadDelegate.idl @@ -29,18 +29,9 @@ import "ocidl.idl"; import "IWebScriptObject.idl"; import "IWebView.idl"; import "IWebFrame.idl"; +import "JavaScriptCoreAPITypes.idl"; #endif -cpp_quote("// this is done to get midl to treat the JavaScriptCore API types as pointer types") -cpp_quote("#if 0") -typedef void* JSContextRef; -typedef void* JSObjectRef; -cpp_quote("#else") -cpp_quote("typedef struct OpaqueJSValue* JSObjectRef;") -cpp_quote("typedef const struct OpaqueJSContext* JSContextRef;") -cpp_quote("#endif") - - interface IWebError; interface IWebFrame; interface IWebScriptObject; diff --git a/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl b/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl index d646528..7e07c55 100644 --- a/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl +++ b/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl @@ -31,8 +31,9 @@ import "IWebView.idl"; #endif interface IWebFrame; -interface IWebView; +interface IWebScriptWorld; interface IWebSecurityOrigin; +interface IWebView; [ object, @@ -45,4 +46,10 @@ interface IWebFrameLoadDelegatePrivate2 : IWebFrameLoadDelegatePrivate HRESULT didDisplayInsecureContent([in] IWebView* sender); HRESULT didRunInsecureContent([in] IWebView* sender, [in] IWebSecurityOrigin* origin); + + HRESULT didClearWindowObjectForFrameInScriptWorld([in] IWebView* webView, [in] IWebFrame* frame, [in] IWebScriptWorld*); + + HRESULT didPushStateWithinPageForFrame([in] IWebView* webView, [in] IWebFrame* frame); + HRESULT didReplaceStateWithinPageForFrame([in] IWebView* webView, [in] IWebFrame* frame); + HRESULT didPopStateWithinPageForFrame([in] IWebView* webView, [in] IWebFrame* frame); } diff --git a/WebKit/win/Interfaces/IWebFramePrivate.idl b/WebKit/win/Interfaces/IWebFramePrivate.idl index d56239b..3ba71c8 100755 --- a/WebKit/win/Interfaces/IWebFramePrivate.idl +++ b/WebKit/win/Interfaces/IWebFramePrivate.idl @@ -32,6 +32,7 @@ import "IWebFrame.idl"; interface IWebFrame; interface IWebIconFetcher; interface IWebIconFetcherDelegate; +interface IWebScriptWorld; typedef enum { WebFrameLoadTypeStandard, @@ -57,7 +58,6 @@ typedef enum { interface IWebFramePrivate : IUnknown { HRESULT renderTreeAsExternalRepresentation([out, retval] BSTR* result); - HRESULT counterValueForElementById([in] BSTR id, [out, retval] BSTR* result); HRESULT scrollOffset([out, retval] SIZE* offset); // FIXME: This shouldn't be needed once IWebDocumentView is implemented. @@ -89,13 +89,16 @@ interface IWebFramePrivate : IUnknown HRESULT pauseAnimation([in] BSTR animationName, [in] IDOMNode* node, [in] double secondsFromNow, [out, retval] BOOL* animationWasRunning); HRESULT pauseTransition([in] BSTR propertyName, [in] IDOMNode* node, [in] double secondsFromNow, [out, retval] BOOL* transitionWasRunning); + HRESULT pauseSVGAnimation([in] BSTR elementId, [in] IDOMNode* node, [in] double secondsFromNow, [out, retval] BOOL* animationWasRunning); HRESULT numberOfActiveAnimations([out, retval] UINT* number); HRESULT isDisplayingStandaloneImage([out, retval] BOOL* result); HRESULT allowsFollowingLink([in] BSTR url, [out, retval] BOOL* result); - HRESULT stringByEvaluatingJavaScriptInIsolatedWorld([in] unsigned worldID, [in] OLE_HANDLE jsGlobalObject, [in] BSTR script, [out, retval] BSTR* result); + [local] HRESULT stringByEvaluatingJavaScriptInScriptWorld([in] IWebScriptWorld*, [in] JSObjectRef globalObject, [in] BSTR script, [out, retval] BSTR* result); + + [local] JSGlobalContextRef globalContextForScriptWorld([in] IWebScriptWorld*); - [local] JSGlobalContextRef contextForWorldID([in] unsigned worldID); + HRESULT counterValueForElementById([in] BSTR id, [out, retval] BSTR* result); } diff --git a/WebKit/win/Interfaces/IWebInspector.idl b/WebKit/win/Interfaces/IWebInspector.idl index e31376c..4523205 100644 --- a/WebKit/win/Interfaces/IWebInspector.idl +++ b/WebKit/win/Interfaces/IWebInspector.idl @@ -54,4 +54,7 @@ interface IWebInspector : IUnknown HRESULT isJavaScriptProfilingEnabled(BOOL* isProfilingEnabled); HRESULT setJavaScriptProfilingEnabled(BOOL enabled); + + HRESULT isTimelineProfilingEnabled(BOOL* isEnabled); + HRESULT setTimelineProfilingEnabled(BOOL enabled); } diff --git a/WebKit/win/Interfaces/IWebPluginHalterDelegate.idl b/WebKit/win/Interfaces/IWebPluginHalterDelegate.idl index f79e304..e113da8 100644 --- a/WebKit/win/Interfaces/IWebPluginHalterDelegate.idl +++ b/WebKit/win/Interfaces/IWebPluginHalterDelegate.idl @@ -39,5 +39,5 @@ interface IWebView; ] interface IWebPluginHalterDelegate : IUnknown { - HRESULT shouldHaltPlugin([in] IWebView* webView, [in] IDOMNode*, [out, retval] BOOL* result); + HRESULT shouldHaltPlugin([in] IWebView* webView, [in] IDOMNode*, [in] BOOL isWindowed, [in] BSTR pluginName, [out, retval] BOOL* result); } diff --git a/WebKit/win/Interfaces/IWebScriptWorld.idl b/WebKit/win/Interfaces/IWebScriptWorld.idl new file mode 100644 index 0000000..255255c --- /dev/null +++ b/WebKit/win/Interfaces/IWebScriptWorld.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 DO_NO_IMPORTS +import "oaidl.idl"; +import "ocidl.idl"; +#endif + +[ + object, + oleautomation, + uuid(EBD45575-8184-4f22-B849-A5FE88336055), + pointer_default(unique) +] +interface IWebScriptWorld : IUnknown { + HRESULT standardWorld([out, retval] IWebScriptWorld**); +} diff --git a/WebKit/win/Interfaces/IWebSerializedJSValue.idl b/WebKit/win/Interfaces/IWebSerializedJSValue.idl new file mode 100644 index 0000000..eddef62 --- /dev/null +++ b/WebKit/win/Interfaces/IWebSerializedJSValue.idl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 DO_NO_IMPORTS +import "oaidl.idl"; +import "ocidl.idl"; +import "JavaScriptCoreAPITypes.idl"; +#endif + +[ + object, + oleautomation, + uuid(13B3F50A-C996-61A7-2247-3DCC88FB0B84), + pointer_default(unique) +] +interface IWebSerializedJSValue : IUnknown { + [local] HRESULT serialize([in] JSContextRef context, [in] JSValueRef value, [out, retval] JSValueRef* exception); + [local] HRESULT deserialize([in] JSContextRef context, [out, retval] JSValueRef* value); +} diff --git a/WebKit/win/Interfaces/IWebViewPrivate.idl b/WebKit/win/Interfaces/IWebViewPrivate.idl index d95f92b..1c8cea2 100644 --- a/WebKit/win/Interfaces/IWebViewPrivate.idl +++ b/WebKit/win/Interfaces/IWebViewPrivate.idl @@ -184,18 +184,17 @@ interface IWebViewPrivate : IUnknown */ HRESULT MIMETypeForExtension([in] BSTR extension, [out, retval] BSTR* mimeType); - // For the following functions, 0 < worldID < UINT_MAX. - HRESULT addUserScriptToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url, + HRESULT addUserScriptToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url, [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist, [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist, [in] WebUserScriptInjectionTime injectionTime); - HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url, + HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url, [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist, [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist); - HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url); - HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url); - HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] unsigned worldID); - HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] unsigned worldID); + HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url); + HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url); + HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*); + HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*); HRESULT removeAllUserContentFromGroup([in] BSTR groupName); HRESULT setPluginHalterDelegate([in] IWebPluginHalterDelegate* d); diff --git a/WebKit/win/Interfaces/JavaScriptCoreAPITypes.idl b/WebKit/win/Interfaces/JavaScriptCoreAPITypes.idl new file mode 100755 index 0000000..f2ef1f1 --- /dev/null +++ b/WebKit/win/Interfaces/JavaScriptCoreAPITypes.idl @@ -0,0 +1,40 @@ +/*
+ * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 DO_NO_IMPORTS
+import "oaidl.idl";
+import "ocidl.idl";
+#endif
+
+cpp_quote("// this is done to get midl to treat the JavaScriptCore API types as pointer types")
+cpp_quote("#if 0")
+typedef void* JSContextRef;
+typedef void* JSObjectRef;
+typedef void* JSValueRef;
+cpp_quote("#else")
+cpp_quote("typedef const struct OpaqueJSValue* JSValueRef;")
+cpp_quote("typedef struct OpaqueJSValue* JSObjectRef;")
+cpp_quote("typedef const struct OpaqueJSContext* JSContextRef;")
+cpp_quote("#endif")
+
diff --git a/WebKit/win/Interfaces/WebKit.idl b/WebKit/win/Interfaces/WebKit.idl index cdd24b3..7b308db 100644 --- a/WebKit/win/Interfaces/WebKit.idl +++ b/WebKit/win/Interfaces/WebKit.idl @@ -24,7 +24,7 @@ */ cpp_quote("/*") -cpp_quote(" * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.") +cpp_quote(" * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.") cpp_quote(" *") cpp_quote(" * Redistribution and use in source and binary forms, with or without") cpp_quote(" * modification, are permitted provided that the following conditions") @@ -56,6 +56,7 @@ import "oaidl.idl"; import "ocidl.idl"; #include "WebScrollbarTypes.idl" +#include "JavaScriptCoreAPITypes.idl" #include "IWebScriptObject.idl" #include "DOMCSS.idl" #include "DOMCore.idl" @@ -113,9 +114,11 @@ import "ocidl.idl"; #include "IWebResource.idl" #include "IWebResourceLoadDelegate.idl" #include "IWebResourceLoadDelegatePrivate.idl" +#include "IWebScriptWorld.idl" #include "IWebScrollBarDelegatePrivate.idl" #include "IWebScrollBarPrivate.idl" #include "IWebSecurityOrigin.idl" +#include "IWebSerializedJSValue.idl" #include "IWebTextRenderer.idl" #include "IWebUIDelegate.idl" #include "IWebUIDelegate2.idl" @@ -271,4 +274,14 @@ library WebKit coclass WebWorkersPrivate{ [default] interface IWebWorkersPrivate; } + + [uuid(D3C301EE-D59A-49c0-A43A-9EA01CDB1590)] + coclass WebScriptWorld { + [default] interface IWebScriptWorld; + } + + [uuid(13C45703-A3B3-8797-276B-75632F6165C3)] + coclass WebSerializedJSValue { + [default] interface IWebSerializedJSValue; + } } diff --git a/WebKit/win/WebActionPropertyBag.cpp b/WebKit/win/WebActionPropertyBag.cpp index 31252a5..c2b9e10 100644 --- a/WebKit/win/WebActionPropertyBag.cpp +++ b/WebKit/win/WebActionPropertyBag.cpp @@ -142,7 +142,7 @@ HRESULT STDMETHODCALLTYPE WebActionPropertyBag::Read(LPCOLESTR pszPropName, VARI } if (isEqual(pszPropName, WebActionModifierFlagsKey)) { if (const UIEventWithKeyState* keyEvent = findEventWithKeyState(const_cast<Event*>(m_action.event()))) { - int modifiers = 0; + unsigned modifiers = 0; if (keyEvent->ctrlKey()) modifiers |= MK_CONTROL; @@ -151,8 +151,8 @@ HRESULT STDMETHODCALLTYPE WebActionPropertyBag::Read(LPCOLESTR pszPropName, VARI if (keyEvent->altKey()) modifiers |= MK_ALT; - V_VT(pVar) = VT_I4; - V_I4(pVar) = modifiers; + V_VT(pVar) = VT_UI4; + V_UI4(pVar) = modifiers; return S_OK; } } diff --git a/WebKit/win/WebCache.cpp b/WebKit/win/WebCache.cpp index c7351b0..d82fc43 100644 --- a/WebKit/win/WebCache.cpp +++ b/WebKit/win/WebCache.cpp @@ -129,9 +129,9 @@ HRESULT STDMETHODCALLTYPE WebCache::statistics( value.adoptCF(CFNumberCreate(0, kCFNumberIntType, &stat.scripts.count)); CFDictionaryAddValue(dictionary.get(), scriptsKey, value.get()); - CFDictionaryPropertyBag* propBag = CFDictionaryPropertyBag::createInstance(); + COMPtr<CFDictionaryPropertyBag> propBag = CFDictionaryPropertyBag::createInstance(); propBag->setDictionary(dictionary.get()); - s[0] = propBag; + s[0] = propBag.releaseRef(); dictionary.adoptCF(CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); @@ -153,7 +153,7 @@ HRESULT STDMETHODCALLTYPE WebCache::statistics( propBag = CFDictionaryPropertyBag::createInstance(); propBag->setDictionary(dictionary.get()); - s[1] = propBag; + s[1] = propBag.releaseRef(); dictionary.adoptCF(CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); @@ -175,7 +175,7 @@ HRESULT STDMETHODCALLTYPE WebCache::statistics( propBag = CFDictionaryPropertyBag::createInstance(); propBag->setDictionary(dictionary.get()); - s[2] = propBag; + s[2] = propBag.releaseRef(); dictionary.adoptCF(CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); @@ -197,7 +197,7 @@ HRESULT STDMETHODCALLTYPE WebCache::statistics( propBag = CFDictionaryPropertyBag::createInstance(); propBag->setDictionary(dictionary.get()); - s[3] = propBag; + s[3] = propBag.releaseRef(); return S_OK; } diff --git a/WebKit/win/WebCoreLocalizedStrings.cpp b/WebKit/win/WebCoreLocalizedStrings.cpp index 03d03e7..9ee22db 100644 --- a/WebKit/win/WebCoreLocalizedStrings.cpp +++ b/WebKit/win/WebCoreLocalizedStrings.cpp @@ -151,6 +151,10 @@ String WebCore::localizedMediaControlElementString(const String& name) return String(LPCTSTR_UI_STRING("fast forward", "accessibility role description for fast forward button")); if (name == "SeekBackButton") return String(LPCTSTR_UI_STRING("fast reverse", "accessibility role description for fast reverse button")); + if (name == "ShowClosedCaptionsButton") + return String(LPCTSTR_UI_STRING("show closed captions", "accessibility role description for show closed captions button")); + if (name == "HideClosedCaptionsButton") + return String(LPCTSTR_UI_STRING("hide closed captions", "accessibility role description for hide closed captions button")); ASSERT_NOT_REACHED(); return String(); @@ -190,6 +194,10 @@ String WebCore::localizedMediaControlElementHelpText(const String& name) return String(LPCTSTR_UI_STRING("seek quickly forward", "accessibility help text for fast forward button")); if (name == "FullscreenButton") return String(LPCTSTR_UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button")); + if (name == "ShowClosedCaptionsButton") + return String(LPCTSTR_UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button")); + if (name == "HideClosedCaptionsButton") + return String(LPCTSTR_UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button")); ASSERT_NOT_REACHED(); return String(); @@ -198,7 +206,7 @@ String WebCore::localizedMediaControlElementHelpText(const String& name) String WebCore::localizedMediaTimeDescription(float time) { if (!isfinite(time)) - return String(LPCTSTR_UI_STRING("indefinite time", "string for an indefinite movie time")); + return String(LPCTSTR_UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value")); int seconds = (int)fabsf(time); int days = seconds / (60 * 60 * 24); @@ -207,27 +215,34 @@ String WebCore::localizedMediaTimeDescription(float time) seconds %= 60; if (days) { - static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("date.format.for.days", "string for days, hours, minutes & seconds")); + static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day")); RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), days, hours, minutes, seconds)); return result.get(); } if (hours) { - static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("date.format.for.hours", "string for hours, minutes & seconds")); + static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes")); RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), hours, minutes, seconds)); return result.get(); } if (minutes) { - static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("date.format.for.minutes", "string for minutes & seconds")); + static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds")); RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), minutes, seconds)); return result.get(); } - static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("date.format.for.seconds", "string for seconds")); + static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds")); RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), seconds)); return result.get(); } #endif // ENABLE(VIDEO) +String WebCore::validationMessageValueMissingText() { return String(LPCTSTR_UI_STRING("value missing", "Validation message for required form control elements that have no value")); } +String WebCore::validationMessageTypeMismatchText() { return String(LPCTSTR_UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type")); } +String WebCore::validationMessagePatternMismatchText() { return String(LPCTSTR_UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern")); } +String WebCore::validationMessageTooLongText() { return String(LPCTSTR_UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length")); } +String WebCore::validationMessageRangeUnderflowText() { return String(LPCTSTR_UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum")); } +String WebCore::validationMessageRangeOverflowText() { return String(LPCTSTR_UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum")); } +String WebCore::validationMessageStepMismatchText() { return String(LPCTSTR_UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute")); } diff --git a/WebKit/win/WebCoreSupport/WebChromeClient.cpp b/WebKit/win/WebCoreSupport/WebChromeClient.cpp index 0bae1ae..6e82caf 100644 --- a/WebKit/win/WebCoreSupport/WebChromeClient.cpp +++ b/WebKit/win/WebCoreSupport/WebChromeClient.cpp @@ -156,6 +156,10 @@ void WebChromeClient::takeFocus(FocusDirection direction) } } +void WebChromeClient::focusedNodeChanged(Node*) +{ +} + static COMPtr<IPropertyBag> createWindowFeaturesPropertyBag(const WindowFeatures& features) { HashMap<String, COMVariant> map; @@ -750,6 +754,19 @@ void WebChromeClient::requestGeolocationPermissionForFrame(Frame*, Geolocation*) notImplemented(); } +#if USE(ACCELERATED_COMPOSITING) +void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer) +{ + m_webView->setRootChildLayer(graphicsLayer ? graphicsLayer->platformLayer() : 0); +} + +void WebChromeClient::scheduleCompositingLayerSync() +{ + m_webView->setRootLayerNeedsDisplay(); +} + +#endif + COMPtr<IWebUIDelegate> WebChromeClient::uiDelegate() { COMPtr<IWebUIDelegate> delegate; diff --git a/WebKit/win/WebCoreSupport/WebChromeClient.h b/WebKit/win/WebCoreSupport/WebChromeClient.h index d01e47d..e0c59ae 100644 --- a/WebKit/win/WebCoreSupport/WebChromeClient.h +++ b/WebKit/win/WebCoreSupport/WebChromeClient.h @@ -55,6 +55,8 @@ public: virtual bool canTakeFocus(WebCore::FocusDirection); virtual void takeFocus(WebCore::FocusDirection); + virtual void focusedNodeChanged(WebCore::Node*); + virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&); virtual void show(); @@ -130,6 +132,17 @@ public: virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; } +#if USE(ACCELERATED_COMPOSITING) + // Pass 0 as the GraphicsLayer to detatch the root layer. + virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*); + // Sets a flag to specify that the next time content is drawn to the window, + // the changes appear on the screen in synchrony with updates to GraphicsLayers. + virtual void setNeedsOneShotDrawingSynchronization() { } + // Sets a flag to specify that the view needs to be updated, so we need + // to do an eager layout before the drawing. + virtual void scheduleCompositingLayerSync(); +#endif + virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const {} virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*); diff --git a/WebKit/win/WebCoreSupport/WebDragClient.cpp b/WebKit/win/WebCoreSupport/WebDragClient.cpp index 8451bd6..773e392 100644 --- a/WebKit/win/WebCoreSupport/WebDragClient.cpp +++ b/WebKit/win/WebCoreSupport/WebDragClient.cpp @@ -295,7 +295,7 @@ DragImageRef WebDragClient::createDragImageForLink(KURL& url, const String& inLa static const Color backgroundColor(140, 140, 140); static const IntSize radii(DRAG_LABEL_RADIUS, DRAG_LABEL_RADIUS); IntRect rect(0, 0, imageSize.width(), imageSize.height()); - context.fillRoundedRect(rect, radii, radii, radii, radii, backgroundColor); + context.fillRoundedRect(rect, radii, radii, radii, radii, backgroundColor, DeviceColorSpace); // Draw the text static const Color topColor(0, 0, 0, 255); //original alpha = 0.75 diff --git a/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp b/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp index cb3aed0..b927c72 100644 --- a/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp @@ -143,7 +143,7 @@ bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader* loader, un void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge& challenge) { #if USE(CFNETWORK) - ASSERT(challenge.sourceHandle()); + ASSERT(challenge.authenticationClient()); WebView* webView = m_webFrame->webView(); COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate; @@ -155,7 +155,7 @@ void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoa // If the ResourceLoadDelegate doesn't exist or fails to handle the call, we tell the ResourceHandle // to continue without credential - this is the best approximation of Mac behavior - challenge.sourceHandle()->receivedRequestToContinueWithoutCredential(challenge); + challenge.authenticationClient()->receivedRequestToContinueWithoutCredential(challenge); #else notImplemented(); #endif @@ -306,6 +306,47 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() frameLoadDelegate->didChangeLocationWithinPageForFrame(webView, m_webFrame); } +void WebFrameLoaderClient::dispatchDidPushStateWithinPage() +{ + WebView* webView = m_webFrame->webView(); + COMPtr<IWebFrameLoadDelegatePrivate> frameLoadDelegatePriv; + if (FAILED(webView->frameLoadDelegatePrivate(&frameLoadDelegatePriv)) || !frameLoadDelegatePriv) + return; + + COMPtr<IWebFrameLoadDelegatePrivate2> frameLoadDelegatePriv2(Query, frameLoadDelegatePriv); + if (!frameLoadDelegatePriv2) + return; + + frameLoadDelegatePriv2->didPushStateWithinPageForFrame(webView, m_webFrame); +} + +void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage() +{ + WebView* webView = m_webFrame->webView(); + COMPtr<IWebFrameLoadDelegatePrivate> frameLoadDelegatePriv; + if (FAILED(webView->frameLoadDelegatePrivate(&frameLoadDelegatePriv)) || !frameLoadDelegatePriv) + return; + + COMPtr<IWebFrameLoadDelegatePrivate2> frameLoadDelegatePriv2(Query, frameLoadDelegatePriv); + if (!frameLoadDelegatePriv2) + return; + + frameLoadDelegatePriv2->didReplaceStateWithinPageForFrame(webView, m_webFrame); +} + +void WebFrameLoaderClient::dispatchDidPopStateWithinPage() +{ + WebView* webView = m_webFrame->webView(); + COMPtr<IWebFrameLoadDelegatePrivate> frameLoadDelegatePriv; + if (FAILED(webView->frameLoadDelegatePrivate(&frameLoadDelegatePriv)) || !frameLoadDelegatePriv) + return; + + COMPtr<IWebFrameLoadDelegatePrivate2> frameLoadDelegatePriv2(Query, frameLoadDelegatePriv); + if (!frameLoadDelegatePriv2) + return; + + frameLoadDelegatePriv2->didPopStateWithinPageForFrame(webView, m_webFrame); +} void WebFrameLoaderClient::dispatchWillClose() { WebView* webView = m_webFrame->webView(); @@ -500,14 +541,11 @@ void WebFrameLoaderClient::updateGlobalHistory() webView->historyDelegate(&historyDelegate); if (historyDelegate) { - BString url(loader->urlForHistory()); - BString title(loader->title()); - BString redirectSource(loader->clientRedirectSourceForHistory()); COMPtr<IWebURLResponse> urlResponse(AdoptCOM, WebURLResponse::createInstance(loader->response())); COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(loader->originalRequestCopy())); COMPtr<IWebNavigationData> navigationData(AdoptCOM, WebNavigationData::createInstance( - url, title, urlRequest.get(), urlResponse.get(), loader->substituteData().isValid(), redirectSource)); + loader->urlForHistory(), loader->title(), urlRequest.get(), urlResponse.get(), loader->substituteData().isValid(), loader->clientRedirectSourceForHistory())); historyDelegate->didNavigateWithNavigationData(webView, navigationData.get(), m_webFrame); return; @@ -759,7 +797,7 @@ void WebFrameLoaderClient::dispatchDidFailToStartPlugin(const PluginView* plugin } } - COMPtr<CFDictionaryPropertyBag> userInfoBag(AdoptCOM, CFDictionaryPropertyBag::createInstance()); + COMPtr<CFDictionaryPropertyBag> userInfoBag = CFDictionaryPropertyBag::createInstance(); userInfoBag->setDictionary(userInfo.get()); int errorCode = 0; diff --git a/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h b/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h index 21599bc..f1fb5f7 100644 --- a/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h +++ b/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h @@ -65,6 +65,9 @@ public: virtual void dispatchDidCancelClientRedirect(); virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); diff --git a/WebKit/win/WebCoreSupport/WebInspectorClient.cpp b/WebKit/win/WebCoreSupport/WebInspectorClient.cpp index 75a76f2..0dd6e58 100644 --- a/WebKit/win/WebCoreSupport/WebInspectorClient.cpp +++ b/WebKit/win/WebCoreSupport/WebInspectorClient.cpp @@ -233,7 +233,7 @@ void WebInspectorClient::attachWindow() if (m_attached) return; - m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(true)); + m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, "true"); closeWindowWithoutNotifications(); showWindowWithoutNotifications(); @@ -244,7 +244,7 @@ void WebInspectorClient::detachWindow() if (!m_attached) return; - m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(false)); + m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, "false"); closeWindowWithoutNotifications(); showWindowWithoutNotifications(); @@ -350,8 +350,8 @@ void WebInspectorClient::showWindowWithoutNotifications() ASSERT(m_inspectedWebViewHwnd); // If no preference is set - default to an attached window. This is important for inspector LayoutTests. - InspectorController::Setting shouldAttach = m_inspectedWebView->page()->inspectorController()->setting(inspectorStartsAttachedName); - m_shouldAttachWhenShown = shouldAttach.type() == InspectorController::Setting::BooleanType ? shouldAttach.booleanValue() : true; + String shouldAttach = m_inspectedWebView->page()->inspectorController()->setting(inspectorStartsAttachedName); + m_shouldAttachWhenShown = shouldAttach != "false"; if (!m_shouldAttachWhenShown) { // Put the Inspector's WebView inside our window and show it. diff --git a/WebKit/win/WebCoreSupport/WebInspectorClient.h b/WebKit/win/WebCoreSupport/WebInspectorClient.h index 8965e87..3f65b0a 100644 --- a/WebKit/win/WebCoreSupport/WebInspectorClient.h +++ b/WebKit/win/WebCoreSupport/WebInspectorClient.h @@ -66,9 +66,8 @@ public: virtual void inspectedURLChanged(const WebCore::String& newURL); - virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&); - virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&); - virtual void removeSetting(const WebCore::String& key); + virtual void populateSetting(const WebCore::String& key, WebCore::String* value); + virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); virtual void inspectorWindowObjectCleared(); diff --git a/WebKit/win/WebCoreSupport/WebPluginHalterClient.cpp b/WebKit/win/WebCoreSupport/WebPluginHalterClient.cpp index 78daf8d..995b05d 100644 --- a/WebKit/win/WebCoreSupport/WebPluginHalterClient.cpp +++ b/WebKit/win/WebCoreSupport/WebPluginHalterClient.cpp @@ -32,7 +32,7 @@ #include <WebCore/Node.h> #include <wtf/Assertions.h> -using WebCore::Node; +using namespace WebCore; WebPluginHalterClient::WebPluginHalterClient(WebView* webView) : m_webView(webView) @@ -40,7 +40,7 @@ WebPluginHalterClient::WebPluginHalterClient(WebView* webView) ASSERT_ARG(webView, webView); } -bool WebPluginHalterClient::shouldHaltPlugin(WebCore::Node* n) const +bool WebPluginHalterClient::shouldHaltPlugin(Node* n, bool isWindowed, const String& pluginName) const { ASSERT_ARG(n, n); @@ -51,7 +51,7 @@ bool WebPluginHalterClient::shouldHaltPlugin(WebCore::Node* n) const COMPtr<IDOMNode> domNode(AdoptCOM, DOMNode::createInstance(n)); BOOL shouldHalt; - if (FAILED(d->shouldHaltPlugin(m_webView, domNode.get(), &shouldHalt))) + if (FAILED(d->shouldHaltPlugin(m_webView, domNode.get(), isWindowed, BString(pluginName), &shouldHalt))) return false; return shouldHalt; diff --git a/WebKit/win/WebCoreSupport/WebPluginHalterClient.h b/WebKit/win/WebCoreSupport/WebPluginHalterClient.h index 7d05fe9..da3d28a 100644 --- a/WebKit/win/WebCoreSupport/WebPluginHalterClient.h +++ b/WebKit/win/WebCoreSupport/WebPluginHalterClient.h @@ -30,6 +30,7 @@ namespace WebCore { class Node; + class String; } class WebView; @@ -38,7 +39,7 @@ class WebPluginHalterClient : public WebCore::PluginHalterClient { public: WebPluginHalterClient(WebView* webView); - virtual bool shouldHaltPlugin(WebCore::Node* n) const; + virtual bool shouldHaltPlugin(WebCore::Node* n, bool isWindowed, const WebCore::String& pluginName) const; virtual bool enabled() const; private: diff --git a/WebKit/win/WebDatabaseManager.cpp b/WebKit/win/WebDatabaseManager.cpp index a531997..989f33c 100644 --- a/WebKit/win/WebDatabaseManager.cpp +++ b/WebKit/win/WebDatabaseManager.cpp @@ -364,7 +364,7 @@ void WebDatabaseManager::dispatchDidModifyDatabase(SecurityOrigin* origin, const RetainPtr<CFStringRef> str(AdoptCF, databaseName.createCFString()); CFDictionarySetValue(userInfo.get(), databaseNameKey, str.get()); - COMPtr<CFDictionaryPropertyBag> userInfoBag(AdoptCOM, CFDictionaryPropertyBag::createInstance()); + COMPtr<CFDictionaryPropertyBag> userInfoBag = CFDictionaryPropertyBag::createInstance(); userInfoBag->setDictionary(userInfo.get()); notifyCenter->postNotificationName(databaseDidModifyOriginName, securityOrigin.get(), userInfoBag.get()); diff --git a/WebKit/win/WebDownload.h b/WebKit/win/WebDownload.h index 58c13e9..71aebfe 100644 --- a/WebKit/win/WebDownload.h +++ b/WebKit/win/WebDownload.h @@ -38,7 +38,7 @@ namespace WebCore { class KURL; class ResourceHandle; - struct ResourceRequest; + class ResourceRequest; class ResourceResponse; } diff --git a/WebKit/win/WebDownloadCFNet.cpp b/WebKit/win/WebDownloadCFNet.cpp index 144a6a5..d1ff23d 100644 --- a/WebKit/win/WebDownloadCFNet.cpp +++ b/WebKit/win/WebDownloadCFNet.cpp @@ -48,6 +48,7 @@ #include <WebCore/AuthenticationCF.h> #include <WebCore/BString.h> #include <WebCore/CredentialStorage.h> +#include <WebCore/LoaderRunLoopCF.h> #include <WebCore/ResourceError.h> #include <WebCore/ResourceHandle.h> #include <WebCore/ResourceRequest.h> @@ -116,7 +117,7 @@ void WebDownload::init(const KURL& url, IWebDownloadDelegate* delegate) m_download.adoptCF(CFURLDownloadCreate(0, cfRequest, &client)); CFURLDownloadScheduleWithCurrentMessageQueue(m_download.get()); - CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), ResourceHandle::loaderRunLoop(), kCFRunLoopDefaultMode); + CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), loaderRunLoop(), kCFRunLoopDefaultMode); LOG(Download, "WebDownload - Initialized download of url %s in WebDownload %p", url.string().utf8().data(), this); } @@ -154,7 +155,7 @@ HRESULT STDMETHODCALLTYPE WebDownload::initWithRequest( } CFURLDownloadScheduleWithCurrentMessageQueue(m_download.get()); - CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), ResourceHandle::loaderRunLoop(), kCFRunLoopDefaultMode); + CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), loaderRunLoop(), kCFRunLoopDefaultMode); LOG(Download, "WebDownload - initWithRequest complete, started download of url %s", webRequest->resourceRequest().url().string().utf8().data()); return S_OK; @@ -200,7 +201,7 @@ HRESULT STDMETHODCALLTYPE WebDownload::initToResumeWithBundle( m_destination = String(); CFURLDownloadScheduleWithCurrentMessageQueue(m_download.get()); - CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), ResourceHandle::loaderRunLoop(), kCFRunLoopDefaultMode); + CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), loaderRunLoop(), kCFRunLoopDefaultMode); LOG(Download, "WebDownload - initWithRequest complete, resumed download of bundle %s", String(bundlePath, SysStringLen(bundlePath)).ascii().data()); return S_OK; diff --git a/WebKit/win/WebDropSource.cpp b/WebKit/win/WebDropSource.cpp index 5c26b37..294c337 100644 --- a/WebKit/win/WebDropSource.cpp +++ b/WebKit/win/WebDropSource.cpp @@ -107,9 +107,7 @@ STDMETHODIMP WebDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyS if (fEscapePressed || !(grfKeyState & (MK_LBUTTON|MK_RBUTTON))) { m_dropped = !fEscapePressed; return fEscapePressed? DRAGDROP_S_CANCEL : DRAGDROP_S_DROP; - } else if (Page* page = m_webView->page()) - if (Frame* frame = page->mainFrame()) - frame->eventHandler()->dragSourceMovedTo(generateMouseEvent(m_webView.get(), true)); + } return S_OK; } diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp index 0a1f6d0..9063fde 100644 --- a/WebKit/win/WebFrame.cpp +++ b/WebKit/win/WebFrame.cpp @@ -29,29 +29,30 @@ #include "WebFrame.h" #include "CFDictionaryPropertyBag.h" -#include "COMPtr.h" #include "COMPropertyBag.h" -#include "DefaultPolicyDelegate.h" +#include "COMPtr.h" #include "DOMCoreClasses.h" +#include "DefaultPolicyDelegate.h" #include "HTMLFrameOwnerElement.h" #include "MarshallingHelpers.h" #include "WebActionPropertyBag.h" #include "WebChromeClient.h" +#include "WebDataSource.h" #include "WebDocumentLoader.h" #include "WebDownload.h" -#include "WebError.h" -#include "WebMutableURLRequest.h" #include "WebEditorClient.h" +#include "WebError.h" #include "WebFramePolicyListener.h" #include "WebHistory.h" +#include "WebHistoryItem.h" #include "WebIconFetcher.h" #include "WebKit.h" #include "WebKitStatisticsPrivate.h" +#include "WebMutableURLRequest.h" #include "WebNotificationCenter.h" -#include "WebView.h" -#include "WebDataSource.h" -#include "WebHistoryItem.h" +#include "WebScriptWorld.h" #include "WebURLResponse.h" +#include "WebView.h" #pragma warning( push, 0 ) #include <WebCore/BString.h> #include <WebCore/Cache.h> @@ -91,6 +92,7 @@ #include <WebCore/RenderView.h> #include <WebCore/RenderTreeAsText.h> #include <WebCore/Settings.h> +#include <WebCore/SVGSMILElement.h> #include <WebCore/TextIterator.h> #include <WebCore/JSDOMBinding.h> #include <WebCore/ScriptController.h> @@ -118,6 +120,7 @@ extern "C" { using namespace WebCore; using namespace HTMLNames; +using namespace std; using JSC::JSGlobalObject; using JSC::JSLock; @@ -490,14 +493,17 @@ JSGlobalContextRef STDMETHODCALLTYPE WebFrame::globalContext() return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()); } -JSGlobalContextRef STDMETHODCALLTYPE WebFrame::contextForWorldID( - /* [in] */ unsigned worldID) +JSGlobalContextRef WebFrame::globalContextForScriptWorld(IWebScriptWorld* iWorld) { Frame* coreFrame = core(this); if (!coreFrame) return 0; - return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec()); + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return 0; + + return toGlobalRef(coreFrame->script()->globalObject(world->world())->globalExec()); } HRESULT STDMETHODCALLTYPE WebFrame::loadRequest( @@ -820,7 +826,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::renderTreeAsExternalRepresentation( if (!coreFrame) return E_FAIL; - *result = BString(externalRepresentation(coreFrame->contentRenderer())).release(); + *result = BString(externalRepresentation(coreFrame)).release(); return S_OK; } @@ -980,7 +986,14 @@ HRESULT STDMETHODCALLTYPE WebFrame::selectedString( HRESULT STDMETHODCALLTYPE WebFrame::selectAll() { - return E_NOTIMPL; + Frame* coreFrame = core(this); + if (!coreFrame) + return E_FAIL; + + if (!coreFrame->editor()->command("SelectAll").execute()) + return E_FAIL; + + return S_OK; } HRESULT STDMETHODCALLTYPE WebFrame::deselectAll() @@ -1151,6 +1164,34 @@ HRESULT WebFrame::pauseTransition(BSTR propertyName, IDOMNode* node, double seco return S_OK; } +HRESULT WebFrame::pauseSVGAnimation(BSTR elementId, IDOMNode* node, double secondsFromNow, BOOL* animationWasRunning) +{ + if (!node || !animationWasRunning) + return E_POINTER; + + *animationWasRunning = FALSE; + + Frame* frame = core(this); + if (!frame) + return E_FAIL; + + Document* document = frame->document(); + if (!document || !document->svgExtensions()) + return E_FAIL; + + COMPtr<DOMNode> domNode(Query, node); + if (!domNode || !SVGSMILElement::isSMILElement(domNode->node())) + return E_FAIL; + +#if ENABLE(SVG) + *animationWasRunning = document->accessSVGExtensions()->sampleAnimationAtTime(String(elementId, SysStringLen(elementId)), static_cast<SVGSMILElement*>(domNode->node()), secondsFromNow); +#else + *animationWasRunning = FALSE; +#endif + + return S_OK; +} + HRESULT WebFrame::numberOfActiveAnimations(UINT* number) { if (!number) @@ -1691,7 +1732,7 @@ PassRefPtr<Widget> WebFrame::createJavaAppletWidget(const IntSize& pluginSize, H if (FAILED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) return pluginView; - COMPtr<CFDictionaryPropertyBag> userInfoBag(AdoptCOM, CFDictionaryPropertyBag::createInstance()); + COMPtr<CFDictionaryPropertyBag> userInfoBag = CFDictionaryPropertyBag::createInstance(); ResourceError resourceError(String(WebKitErrorDomain), WebKitErrorJavaUnavailable, String(), String()); COMPtr<IWebError> error(AdoptCOM, WebError::createInstance(resourceError, userInfoBag.get())); @@ -1712,7 +1753,7 @@ String WebFrame::overrideMediaType() const return String(); } -void WebFrame::windowObjectCleared() +void WebFrame::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) { Frame* coreFrame = core(this); ASSERT(coreFrame); @@ -1722,14 +1763,22 @@ void WebFrame::windowObjectCleared() return; COMPtr<IWebFrameLoadDelegate> frameLoadDelegate; - if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate))) { - JSContextRef context = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()); - JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld())); - ASSERT(windowObject); + if (FAILED(d->webView->frameLoadDelegate(&frameLoadDelegate))) + return; - if (FAILED(frameLoadDelegate->didClearWindowObject(d->webView, context, windowObject, this))) - frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject); - } + COMPtr<IWebFrameLoadDelegatePrivate2> delegatePrivate(Query, frameLoadDelegate); + if (delegatePrivate && delegatePrivate->didClearWindowObjectForFrameInScriptWorld(d->webView, this, WebScriptWorld::findOrCreateWorld(world).get()) != E_NOTIMPL) + return; + + if (world != mainThreadNormalWorld()) + return; + + JSContextRef context = toRef(coreFrame->script()->globalObject(world)->globalExec()); + JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(world)); + ASSERT(windowObject); + + if (FAILED(frameLoadDelegate->didClearWindowObject(d->webView, context, windowObject, this))) + frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject); } void WebFrame::documentElementAvailable() @@ -2169,18 +2218,20 @@ HRESULT STDMETHODCALLTYPE WebFrame::isDescendantOfFrame( return S_OK; } -HRESULT STDMETHODCALLTYPE WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld( - /* [in] */ unsigned int worldID, - /* [in] */ OLE_HANDLE jsGlobalObject, - /* [in] */ BSTR script, - /* [retval][out] */ BSTR* evaluationResult) +HRESULT WebFrame::stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld* iWorld, JSObjectRef globalObjectRef, BSTR script, BSTR* evaluationResult) { if (!evaluationResult) return E_POINTER; *evaluationResult = 0; + if (!iWorld) + return E_POINTER; + + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return E_INVALIDARG; + Frame* coreFrame = core(this); - JSObjectRef globalObjectRef = reinterpret_cast<JSObjectRef>(jsGlobalObject); String string = String(script, SysStringLen(script)); // Start off with some guess at a frame and a global object, we'll try to do better...! @@ -2194,7 +2245,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld( // Get the frame frome the global object we've settled on. Frame* frame = anyWorldGlobalObject->impl()->frame(); ASSERT(frame->document()); - JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue(); + JSValue result = frame->script()->executeScriptInWorld(world->world(), string, true).jsValue(); if (!frame) // In case the script removed our frame from the page. return S_OK; diff --git a/WebKit/win/WebFrame.h b/WebKit/win/WebFrame.h index d0f6adf..91b8e14 100644 --- a/WebKit/win/WebFrame.h +++ b/WebKit/win/WebFrame.h @@ -240,6 +240,7 @@ public: virtual HRESULT STDMETHODCALLTYPE pauseAnimation(BSTR animationName, IDOMNode*, double secondsFromNow, BOOL* animationWasRunning); virtual HRESULT STDMETHODCALLTYPE pauseTransition(BSTR propertyName, IDOMNode*, double secondsFromNow, BOOL* transitionWasRunning); + virtual HRESULT STDMETHODCALLTYPE pauseSVGAnimation(BSTR elementId, IDOMNode*, double secondsFromNow, BOOL* animationWasRunning); virtual HRESULT STDMETHODCALLTYPE numberOfActiveAnimations(UINT*); virtual HRESULT STDMETHODCALLTYPE isDisplayingStandaloneImage(BOOL*); @@ -248,14 +249,8 @@ public: /* [in] */ BSTR url, /* [retval][out] */ BOOL* result); - virtual HRESULT STDMETHODCALLTYPE stringByEvaluatingJavaScriptInIsolatedWorld( - /* [in] */ unsigned int worldID, - /* [in] */ OLE_HANDLE jsGlobalObject, - /* [in] */ BSTR script, - /* [retval][out] */ BSTR* evaluationResult); - - virtual /* [local] */ JSGlobalContextRef STDMETHODCALLTYPE contextForWorldID( - /* [in] */ unsigned worldID); + virtual HRESULT STDMETHODCALLTYPE stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld*, JSObjectRef globalObjectRef, BSTR script, BSTR* evaluationResult); + virtual JSGlobalContextRef STDMETHODCALLTYPE globalContextForScriptWorld(IWebScriptWorld*); // IWebDocumentText virtual HRESULT STDMETHODCALLTYPE supportsTextEncoding( @@ -318,7 +313,7 @@ public: virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); virtual WebCore::String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; diff --git a/WebKit/win/WebHistory.cpp b/WebKit/win/WebHistory.cpp index deb75e5..5383a0c 100644 --- a/WebKit/win/WebHistory.cpp +++ b/WebKit/win/WebHistory.cpp @@ -96,7 +96,7 @@ static bool areEqualOrClose(double d1, double d2) return (diff < .000001 && diff > -.000001); } -static CFDictionaryPropertyBag* createUserInfoFromArray(BSTR notificationStr, CFArrayRef arrayItem) +static COMPtr<CFDictionaryPropertyBag> createUserInfoFromArray(BSTR notificationStr, CFArrayRef arrayItem) { RetainPtr<CFMutableDictionaryRef> dictionary(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); @@ -104,28 +104,19 @@ static CFDictionaryPropertyBag* createUserInfoFromArray(BSTR notificationStr, CF RetainPtr<CFStringRef> key(AdoptCF, MarshallingHelpers::BSTRToCFStringRef(notificationStr)); CFDictionaryAddValue(dictionary.get(), key.get(), arrayItem); - CFDictionaryPropertyBag* result = CFDictionaryPropertyBag::createInstance(); + COMPtr<CFDictionaryPropertyBag> result = CFDictionaryPropertyBag::createInstance(); result->setDictionary(dictionary.get()); return result; } -static CFDictionaryPropertyBag* createUserInfoFromHistoryItem(BSTR notificationStr, IWebHistoryItem* item) +static COMPtr<CFDictionaryPropertyBag> createUserInfoFromHistoryItem(BSTR notificationStr, IWebHistoryItem* item) { // reference counting of item added to the array is managed by the CFArray value callbacks RetainPtr<CFArrayRef> itemList(AdoptCF, CFArrayCreate(0, (const void**) &item, 1, &MarshallingHelpers::kIUnknownArrayCallBacks)); - CFDictionaryPropertyBag* info = createUserInfoFromArray(notificationStr, itemList.get()); + COMPtr<CFDictionaryPropertyBag> info = createUserInfoFromArray(notificationStr, itemList.get()); return info; } -static void releaseUserInfo(CFDictionaryPropertyBag* userInfo) -{ - // free the dictionary - userInfo->setDictionary(0); - int result = userInfo->Release(); - (void)result; - ASSERT(result == 0); // make sure no one else holds a reference to the userInfo. -} - // WebHistory ----------------------------------------------------------------- WebHistory::WebHistory() @@ -264,9 +255,8 @@ HRESULT STDMETHODCALLTYPE WebHistory::loadFromURL( goto exit; if (CFArrayGetCount(discardedItems.get()) > 0) { - CFDictionaryPropertyBag* userInfo = createUserInfoFromArray(getNotificationString(kWebHistoryItemsDiscardedWhileLoadingNotification), discardedItems.get()); - hr = postNotification(kWebHistoryItemsDiscardedWhileLoadingNotification, userInfo); - releaseUserInfo(userInfo); + COMPtr<CFDictionaryPropertyBag> userInfo = createUserInfoFromArray(getNotificationString(kWebHistoryItemsDiscardedWhileLoadingNotification), discardedItems.get()); + hr = postNotification(kWebHistoryItemsDiscardedWhileLoadingNotification, userInfo.get()); if (FAILED(hr)) goto exit; } @@ -465,8 +455,8 @@ HRESULT STDMETHODCALLTYPE WebHistory::removeAllItems( void) PageGroup::removeAllVisitedLinks(); - CFDictionaryPropertyBag* userInfo = createUserInfoFromArray(getNotificationString(kWebHistoryAllItemsRemovedNotification), allItems.get()); - return postNotification(kWebHistoryAllItemsRemovedNotification, userInfo); + COMPtr<CFDictionaryPropertyBag> userInfo = createUserInfoFromArray(getNotificationString(kWebHistoryAllItemsRemovedNotification), allItems.get()); + return postNotification(kWebHistoryAllItemsRemovedNotification, userInfo.get()); } HRESULT STDMETHODCALLTYPE WebHistory::orderedLastVisitedDays( @@ -644,10 +634,9 @@ HRESULT WebHistory::removeItem(IWebHistoryItem* entry) if (FAILED(hr)) return hr; - CFDictionaryPropertyBag* userInfo = createUserInfoFromHistoryItem( + COMPtr<CFDictionaryPropertyBag> userInfo = createUserInfoFromHistoryItem( getNotificationString(kWebHistoryItemsRemovedNotification), entry); - hr = postNotification(kWebHistoryItemsRemovedNotification, userInfo); - releaseUserInfo(userInfo); + hr = postNotification(kWebHistoryItemsRemovedNotification, userInfo.get()); return hr; } @@ -695,10 +684,9 @@ HRESULT WebHistory::addItem(IWebHistoryItem* entry, bool discardDuplicate, bool* CFDictionarySetValue(m_entriesByURL.get(), urlString.get(), entry); - CFDictionaryPropertyBag* userInfo = createUserInfoFromHistoryItem( + COMPtr<CFDictionaryPropertyBag> userInfo = createUserInfoFromHistoryItem( getNotificationString(kWebHistoryItemsAddedNotification), entry); - hr = postNotification(kWebHistoryItemsAddedNotification, userInfo); - releaseUserInfo(userInfo); + hr = postNotification(kWebHistoryItemsAddedNotification, userInfo.get()); if (added) *added = true; @@ -754,10 +742,9 @@ void WebHistory::visitedURL(const KURL& url, const String& title, const String& COMPtr<WebHistoryItem> item(Query, entry); item->historyItem()->setRedirectURLs(0); - CFDictionaryPropertyBag* userInfo = createUserInfoFromHistoryItem( + COMPtr<CFDictionaryPropertyBag> userInfo = createUserInfoFromHistoryItem( getNotificationString(kWebHistoryItemsAddedNotification), entry); - postNotification(kWebHistoryItemsAddedNotification, userInfo); - releaseUserInfo(userInfo); + postNotification(kWebHistoryItemsAddedNotification, userInfo.get()); } HRESULT WebHistory::itemForURLString( diff --git a/WebKit/win/WebIconDatabase.cpp b/WebKit/win/WebIconDatabase.cpp index 315db9e..9b87c2b 100644 --- a/WebKit/win/WebIconDatabase.cpp +++ b/WebKit/win/WebIconDatabase.cpp @@ -358,7 +358,7 @@ static void postDidAddIconNotification(const String& pageURL, WebIconDatabase* i RetainPtr<CFStringRef> url(AdoptCF, pageURL.createCFString()); CFDictionaryAddValue(dictionary.get(), WebIconDatabase::iconDatabaseNotificationUserInfoURLKey(), url.get()); - COMPtr<CFDictionaryPropertyBag> userInfo(AdoptCOM, CFDictionaryPropertyBag::createInstance()); + COMPtr<CFDictionaryPropertyBag> userInfo = CFDictionaryPropertyBag::createInstance(); userInfo->setDictionary(dictionary.get()); IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal(); diff --git a/WebKit/win/WebInspector.cpp b/WebKit/win/WebInspector.cpp index 97587f9..e4ac32b 100644 --- a/WebKit/win/WebInspector.cpp +++ b/WebKit/win/WebInspector.cpp @@ -272,3 +272,38 @@ HRESULT STDMETHODCALLTYPE WebInspector::evaluateInFrontend(ULONG callId, BSTR b page->inspectorController()->evaluateForTestInFrontend(callId, script); return S_OK; } + +HRESULT STDMETHODCALLTYPE WebInspector::isTimelineProfilingEnabled(BOOL* isEnabled) +{ + if (!isEnabled) + return E_POINTER; + + *isEnabled = FALSE; + + if (!m_webView) + return S_OK; + + Page* page = m_webView->page(); + if (!page) + return S_OK; + + *isEnabled = page->inspectorController()->timelineAgent() != 0; + return S_OK; +} + +HRESULT STDMETHODCALLTYPE WebInspector::setTimelineProfilingEnabled(BOOL enabled) +{ + if (!m_webView) + return S_OK; + + Page* page = m_webView->page(); + if (!page) + return S_OK; + + if (enabled) + page->inspectorController()->startTimelineProfiler(); + else + page->inspectorController()->stopTimelineProfiler(); + + return S_OK; +} diff --git a/WebKit/win/WebInspector.h b/WebKit/win/WebInspector.h index 4f9bedb..053a593 100644 --- a/WebKit/win/WebInspector.h +++ b/WebKit/win/WebInspector.h @@ -59,9 +59,12 @@ public: virtual HRESULT STDMETHODCALLTYPE isJavaScriptProfilingEnabled(BOOL* isProfilingEnabled); virtual HRESULT STDMETHODCALLTYPE setJavaScriptProfilingEnabled(BOOL); - + virtual HRESULT STDMETHODCALLTYPE evaluateInFrontend(ULONG callId, BSTR script); + virtual HRESULT STDMETHODCALLTYPE isTimelineProfilingEnabled(BOOL* isEnabled); + virtual HRESULT STDMETHODCALLTYPE setTimelineProfilingEnabled(BOOL); + private: WebInspector(WebView*); ~WebInspector(); diff --git a/WebKit/win/WebKit.vcproj/Interfaces.vcproj b/WebKit/win/WebKit.vcproj/Interfaces.vcproj index 75c7c11..ca9b2a4 100644 --- a/WebKit/win/WebKit.vcproj/Interfaces.vcproj +++ b/WebKit/win/WebKit.vcproj/Interfaces.vcproj @@ -1324,6 +1324,26 @@ </FileConfiguration>
</File>
<File
+ RelativePath="..\Interfaces\IWebScriptWorld.idl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="..\Interfaces\IWebScrollBarDelegatePrivate.idl"
>
<FileConfiguration
@@ -1663,6 +1683,26 @@ />
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\Interfaces\JavaScriptCoreAPITypes.idl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ />
+ </FileConfiguration>
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/WebKit/win/WebKit.vcproj/WebKit.vcproj b/WebKit/win/WebKit.vcproj/WebKit.vcproj index 121f773..5846813 100644 --- a/WebKit/win/WebKit.vcproj/WebKit.vcproj +++ b/WebKit/win/WebKit.vcproj/WebKit.vcproj @@ -40,7 +40,7 @@ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(WebKitOutputDir)\include\WebKit";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\private";"$(WebKitLibrariesDir)\Include";"$(WebKitLibrariesDir)\Include\private";"$(WebKitOutputDir)\Include\WebCore";"$(WebKitLibrariesDir)\Include\WebCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\Include\WebCore\ForwardingHeaders";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\private\JavaScriptCore";"$(WebKitLibrariesDir)\Include\JavaScriptCore";"$(WebKitLibrariesDir)\Include\private\JavaScriptCore";"$(WebKitOutputDir)\Include\icu";"$(WebKitLibrariesDir)\Include\icu";"$(WebKitLibrariesDir)\include\pthreads";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(ProjectDir)\..";"$(ProjectDir)";"$(ProjectDir)\..\WebCoreSupport";"$(IntDir)\include";"$(WebKitOutputDir)\obj\WebKit\DerivedSources""
- PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_RUBY;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
+ PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_FILTERS;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="WebKitPrefix.h"
DisableSpecificWarnings="4819"
@@ -117,7 +117,7 @@ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(WebKitOutputDir)\include\WebKit";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\private";"$(WebKitLibrariesDir)\Include";"$(WebKitLibrariesDir)\Include\private";"$(WebKitOutputDir)\Include\WebCore";"$(WebKitLibrariesDir)\Include\WebCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\Include\WebCore\ForwardingHeaders";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\private\JavaScriptCore";"$(WebKitLibrariesDir)\Include\JavaScriptCore";"$(WebKitLibrariesDir)\Include\private\JavaScriptCore";"$(WebKitOutputDir)\Include\icu";"$(WebKitLibrariesDir)\Include\icu";"$(WebKitLibrariesDir)\include\pthreads";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(ProjectDir)\..";"$(ProjectDir)";"$(ProjectDir)\..\WebCoreSupport";"$(IntDir)\include";"$(WebKitOutputDir)\obj\WebKit\DerivedSources""
- PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_RUBY;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
+ PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_FILTERS;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="WebKitPrefix.h"
DisableSpecificWarnings="4819"
@@ -193,7 +193,7 @@ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(WebKitOutputDir)\include\WebKit";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\private";"$(WebKitLibrariesDir)\Include";"$(WebKitLibrariesDir)\Include\private";"$(WebKitOutputDir)\Include\WebCore";"$(WebKitLibrariesDir)\Include\WebCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\Include\WebCore\ForwardingHeaders";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\private\JavaScriptCore";"$(WebKitLibrariesDir)\Include\JavaScriptCore";"$(WebKitLibrariesDir)\Include\private\JavaScriptCore";"$(WebKitOutputDir)\Include\icu";"$(WebKitLibrariesDir)\Include\icu";"$(WebKitLibrariesDir)\include\pthreads";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(ProjectDir)\..";"$(ProjectDir)";"$(ProjectDir)\..\WebCoreSupport";"$(IntDir)\include";"$(WebKitOutputDir)\obj\WebKit\DerivedSources""
- PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_RUBY;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
+ PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_FILTERS;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="WebKitPrefix.h"
Detect64BitPortabilityProblems="false"
@@ -215,7 +215,7 @@ Name="VCLinkerTool"
AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuin$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib JavaScriptCore$(WebKitDLLConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib WebKitSystemInterface$(WebKitConfigSuffix).lib msimg32.lib QTMovieWin$(WebKitConfigSuffix).lib crypt32.lib iphlpapi.lib winmm.lib rpcrt4.lib comsuppw.lib"
OutputFile="$(OutDir)\$(ProjectName)$(WebKitDLLConfigSuffix).dll"
- AdditionalLibraryDirectories=""
+ AdditionalLibraryDirectories="$(DXSDK_DIR)\Lib\x86"
ModuleDefinitionFile="WebKit$(WebKitDLLConfigSuffix).def"
DelayLoadDLLs="comdlg32.dll;usp10.dll;comctl32.dll;version.dll;libxslt$(LibraryConfigSuffix).dll;SQLite3$(LibraryConfigSuffix).dll;msimg32.dll;QTMovieWin$(WebKitConfigSuffix).dll;iphlpapi.dll;rpcrt4.dll"
/>
@@ -270,7 +270,7 @@ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(WebKitOutputDir)\include\WebKit";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\private";"$(WebKitLibrariesDir)\Include";"$(WebKitLibrariesDir)\Include\private";"$(WebKitOutputDir)\Include\WebCore";"$(WebKitLibrariesDir)\Include\WebCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\Include\WebCore\ForwardingHeaders";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\private\JavaScriptCore";"$(WebKitLibrariesDir)\Include\JavaScriptCore";"$(WebKitLibrariesDir)\Include\private\JavaScriptCore";"$(WebKitOutputDir)\Include\icu";"$(WebKitLibrariesDir)\Include\icu";"$(WebKitLibrariesDir)\include\pthreads";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(ProjectDir)\..";"$(ProjectDir)";"$(ProjectDir)\..\WebCoreSupport";"$(IntDir)\include";"$(WebKitOutputDir)\obj\WebKit\DerivedSources""
- PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_RUBY;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
+ PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_FILTERS;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="WebKitPrefix.h"
DisableSpecificWarnings="4819"
@@ -289,7 +289,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuin$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CFLite_Debug.lib JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib msimg32.lib crypt32.lib iphlpapi.lib winmm.lib rpcrt4.lib comsuppw.lib"
+ AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuin$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CFLite_Debug.lib JavaScriptCore$(WebKitConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib msimg32.lib crypt32.lib iphlpapi.lib winmm.lib rpcrt4.lib comsuppw.lib"
OutputFile="$(OutDir)\$(ProjectName)$(WebKitDLLConfigSuffix).dll"
AdditionalLibraryDirectories=""
ModuleDefinitionFile="WebKit_Cairo$(WebKitDLLConfigSuffix).def"
@@ -350,7 +350,7 @@ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(WebKitOutputDir)\include\WebKit";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\private";"$(WebKitLibrariesDir)\Include";"$(WebKitLibrariesDir)\Include\private";"$(WebKitOutputDir)\Include\WebCore";"$(WebKitLibrariesDir)\Include\WebCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\Include\WebCore\ForwardingHeaders";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\private\JavaScriptCore";"$(WebKitLibrariesDir)\Include\JavaScriptCore";"$(WebKitLibrariesDir)\Include\private\JavaScriptCore";"$(WebKitOutputDir)\Include\icu";"$(WebKitLibrariesDir)\Include\icu";"$(WebKitLibrariesDir)\include\pthreads";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(ProjectDir)\..";"$(ProjectDir)";"$(ProjectDir)\..\WebCoreSupport";"$(IntDir)\include";"$(WebKitOutputDir)\obj\WebKit\DerivedSources""
- PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_RUBY;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
+ PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_FILTERS;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="WebKitPrefix.h"
DisableSpecificWarnings="4819"
@@ -426,7 +426,7 @@ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(WebKitOutputDir)\include\WebKit";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\private";"$(WebKitLibrariesDir)\Include";"$(WebKitLibrariesDir)\Include\private";"$(WebKitOutputDir)\Include\WebCore";"$(WebKitLibrariesDir)\Include\WebCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\Include\WebCore\ForwardingHeaders";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\private\JavaScriptCore";"$(WebKitLibrariesDir)\Include\JavaScriptCore";"$(WebKitLibrariesDir)\Include\private\JavaScriptCore";"$(WebKitOutputDir)\Include\icu";"$(WebKitLibrariesDir)\Include\icu";"$(WebKitLibrariesDir)\include\pthreads";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitOutputDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility";"$(ProjectDir)\..";"$(ProjectDir)";"$(ProjectDir)\..\WebCoreSupport";"$(IntDir)\include";"$(WebKitOutputDir)\obj\WebKit\DerivedSources""
- PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_RUBY;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
+ PreprocessorDefinitions="_USRDLL;WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;ENABLE_CHANNEL_MESSAGING;ENABLE_DATABASE;ENABLE_DATAGRID;ENABLE_DOM_STORAGE;ENABLE_FILTERS;ENABLE_ICONDATABASE;ENABLE_OFFLINE_WEB_APPLICATIONS;ENABLE_SHARED_WORKERS;ENABLE_SVG;ENABLE_SVG_ANIMATION;ENABLE_SVG_AS_IMAGE;ENABLE_SVG_FONTS;ENABLE_SVG_FOREIGN_OBJECT;ENABLE_SVG_USE;ENABLE_VIDEO;ENABLE_WEB_SOCKETS;ENABLE_WORKERS;ENABLE_XPATH;ENABLE_XSLT"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="WebKitPrefix.h"
Detect64BitPortabilityProblems="false"
@@ -722,6 +722,14 @@ >
</File>
<File
+ RelativePath="..\WebScriptWorld.h"
+ >
+ </File>
+ <File
+ RelativePath="..\WebSerializedJSValue.h"
+ >
+ </File>
+ <File
RelativePath="..\WebKitStatistics.h"
>
</File>
@@ -790,6 +798,10 @@ >
</File>
<File
+ RelativePath="..\WebScriptWorld.h"
+ >
+ </File>
+ <File
RelativePath="..\WebScrollBar.h"
>
</File>
@@ -1090,6 +1102,14 @@ >
</File>
<File
+ RelativePath="..\WebScriptWorld.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebSerializedJSValue.cpp"
+ >
+ </File>
+ <File
RelativePath="..\WebKitStatistics.cpp"
>
</File>
@@ -1122,6 +1142,10 @@ >
</File>
<File
+ RelativePath="..\WebScriptWorld.cpp"
+ >
+ </File>
+ <File
RelativePath="..\WebScrollBar.cpp"
>
</File>
diff --git a/WebKit/win/WebKitClassFactory.cpp b/WebKit/win/WebKitClassFactory.cpp index c2143b5..b233a5c 100644 --- a/WebKit/win/WebKitClassFactory.cpp +++ b/WebKit/win/WebKitClassFactory.cpp @@ -27,8 +27,8 @@ #include "WebKitDLL.h" #include "WebKitClassFactory.h" -#include "ForEachCoClass.h" #include "CFDictionaryPropertyBag.h" +#include "ForEachCoClass.h" #include "WebArchive.h" #include "WebCache.h" #include "WebCookieManager.h" @@ -42,11 +42,12 @@ #include "WebIconDatabase.h" #include "WebJavaScriptCollector.h" #include "WebKit.h" -#include "WebScrollBar.h" #include "WebKitStatistics.h" #include "WebMutableURLRequest.h" #include "WebNotificationCenter.h" #include "WebPreferences.h" +#include "WebScriptWorld.h" +#include "WebScrollBar.h" #include "WebTextRenderer.h" #include "WebURLCredential.h" #include "WebURLProtectionSpace.h" @@ -126,6 +127,19 @@ ULONG STDMETHODCALLTYPE WebKitClassFactory::Release(void) return newRef; } +// FIXME: Remove these functions once all createInstance() functions return COMPtr. +template <typename T> +static T* releaseRefFromCreateInstance(T* object) +{ + return object; +} + +template <typename T> +static T* releaseRefFromCreateInstance(COMPtr<T> object) +{ + return object.releaseRef(); +} + // IClassFactory -------------------------------------------------------------- HRESULT STDMETHODCALLTYPE WebKitClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject) @@ -138,7 +152,7 @@ HRESULT STDMETHODCALLTYPE WebKitClassFactory::CreateInstance(IUnknown* pUnkOuter #define INITIALIZE_IF_CLASS(cls) \ if (IsEqualGUID(m_targetClass, CLSID_##cls)) \ - unknown = static_cast<I##cls*>(cls::createInstance()); \ + unknown = static_cast<I##cls*>(releaseRefFromCreateInstance(cls::createInstance())); \ else \ // end of macro diff --git a/WebKit/win/WebKitGraphics.cpp b/WebKit/win/WebKitGraphics.cpp index 9727ee6..03fe903 100644 --- a/WebKit/win/WebKitGraphics.cpp +++ b/WebKit/win/WebKitGraphics.cpp @@ -114,7 +114,7 @@ void WebDrawText(WebTextRenderInfo* info) // Set shadow setting if (info->structSize == sizeof(WebTextRenderInfo) && (info->shadowOffset.cx || info->shadowOffset.cy || info->shadowBlur || info->shadowColor)) - context.setShadow(info->shadowOffset, info->shadowBlur, info->shadowColor); + context.setShadow(info->shadowOffset, info->shadowBlur, info->shadowColor, DeviceColorSpace); WebCoreDrawTextAtPoint(context, drawString, info->pt, makeFont(*(info->description)), info->color, info->underlinedIndex); context.restore(); diff --git a/WebKit/win/WebKitPrefix.cpp b/WebKit/win/WebKitPrefix.cpp index 193e9f6..e82b88d 100644 --- a/WebKit/win/WebKitPrefix.cpp +++ b/WebKit/win/WebKitPrefix.cpp @@ -27,4 +27,3 @@ */ #include "WebKitPrefix.h" - diff --git a/WebKit/win/WebNavigationData.cpp b/WebKit/win/WebNavigationData.cpp index 1ae3fe5..1ea028c 100644 --- a/WebKit/win/WebNavigationData.cpp +++ b/WebKit/win/WebNavigationData.cpp @@ -27,8 +27,7 @@ #include "WebKitDLL.h" #include "WebNavigationData.h" -#include <WebCore/BString.h> -using WebCore::BString; +using namespace WebCore; // IUnknown ------------------------------------------------------------------- @@ -62,19 +61,18 @@ ULONG STDMETHODCALLTYPE WebNavigationData::Release(void) // WebNavigationData ------------------------------------------------------------------- -WebNavigationData::WebNavigationData(BSTR url, BSTR title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, BSTR clientRedirectSource) +WebNavigationData::WebNavigationData(const String& url, const String& title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, const String& clientRedirectSource) : m_refCount(0) + , m_url(url) + , m_title(title) , m_request(request) , m_response(response) , m_hasSubstituteData(hasSubstituteData) + , m_clientRedirectSource(clientRedirectSource) { gClassCount++; gClassNameCount.add("WebNavigationData"); - - m_url.adoptBSTR(url); - m_title.adoptBSTR(title); - m_clientRedirectSource.adoptBSTR(clientRedirectSource); } WebNavigationData::~WebNavigationData() @@ -83,7 +81,7 @@ WebNavigationData::~WebNavigationData() gClassNameCount.remove("WebNavigationData"); } -WebNavigationData* WebNavigationData::createInstance(BSTR url, BSTR title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, BSTR clientRedirectSource) +WebNavigationData* WebNavigationData::createInstance(const String& url, const String& title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, const String& clientRedirectSource) { WebNavigationData* instance = new WebNavigationData(url, title, request, response, hasSubstituteData, clientRedirectSource); instance->AddRef(); diff --git a/WebKit/win/WebNavigationData.h b/WebKit/win/WebNavigationData.h index 0443fd7..d00912c 100644 --- a/WebKit/win/WebNavigationData.h +++ b/WebKit/win/WebNavigationData.h @@ -33,9 +33,9 @@ class WebNavigationData : public IWebNavigationData { public: - static WebNavigationData* createInstance(BSTR, BSTR, IWebURLRequest*, IWebURLResponse*, bool, BSTR); + static WebNavigationData* createInstance(const WebCore::String& url, const WebCore::String& title, IWebURLRequest*, IWebURLResponse*, bool hasSubstituteData, const WebCore::String& clientRedirectSource); private: - WebNavigationData(BSTR url, BSTR title, IWebURLRequest*, IWebURLResponse*, bool hasSubstituteData, BSTR clientRedirectSource); + WebNavigationData(const WebCore::String& url, const WebCore::String& title, IWebURLRequest*, IWebURLResponse*, bool hasSubstituteData, const WebCore::String& clientRedirectSource); ~WebNavigationData(); public: diff --git a/WebKit/win/WebScriptObject.cpp b/WebKit/win/WebScriptObject.cpp index 55d92e7..9306eb1 100644 --- a/WebKit/win/WebScriptObject.cpp +++ b/WebKit/win/WebScriptObject.cpp @@ -23,10 +23,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "WebKitDLL.h" - +#include "config.h" #include "WebScriptObject.h" +#include "WebKitDLL.h" + #include <wtf/Assertions.h> // WebScriptObject ------------------------------------------------------------ diff --git a/WebKit/win/WebScriptWorld.cpp b/WebKit/win/WebScriptWorld.cpp new file mode 100644 index 0000000..03eede7 --- /dev/null +++ b/WebKit/win/WebScriptWorld.cpp @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 "WebKitDLL.h" +#include "WebScriptWorld.h" + +#include <WebCore/JSDOMBinding.h> +#include <WebCore/ScriptController.h> + +using namespace WebCore; + +typedef HashMap<DOMWrapperWorld*, WebScriptWorld*> WorldMap; +static WorldMap& allWorlds() +{ + static WorldMap& map = *new WorldMap; + return map; +} + +inline WebScriptWorld::WebScriptWorld(PassRefPtr<DOMWrapperWorld> world) + : m_refCount(0) + , m_world(world) +{ + ASSERT_ARG(world, m_world); + + ASSERT_ARG(world, !allWorlds().contains(m_world.get())); + allWorlds().add(m_world.get(), this); + + ++gClassCount; + gClassNameCount.add("WebScriptWorld"); +} + +WebScriptWorld::~WebScriptWorld() +{ + ASSERT(allWorlds().contains(m_world.get())); + allWorlds().remove(m_world.get()); + + --gClassCount; + gClassNameCount.remove("WebScriptWorld"); +} + +WebScriptWorld* WebScriptWorld::standardWorld() +{ + static WebScriptWorld* standardWorld = createInstance(mainThreadNormalWorld()).releaseRef(); + return standardWorld; +} + +COMPtr<WebScriptWorld> WebScriptWorld::createInstance() +{ + return createInstance(ScriptController::createWorld()); +} + +COMPtr<WebScriptWorld> WebScriptWorld::createInstance(PassRefPtr<DOMWrapperWorld> world) +{ + return new WebScriptWorld(world); +} + +COMPtr<WebScriptWorld> WebScriptWorld::findOrCreateWorld(DOMWrapperWorld* world) +{ + if (world == mainThreadNormalWorld()) + return standardWorld(); + + if (WebScriptWorld* existingWorld = allWorlds().get(world)) + return existingWorld; + + return createInstance(world); +} + +ULONG WebScriptWorld::AddRef() +{ + return ++m_refCount; +} + +ULONG WebScriptWorld::Release() +{ + ULONG newRefCount = --m_refCount; + if (!newRefCount) + delete this; + return newRefCount; +} + +HRESULT WebScriptWorld::QueryInterface(REFIID riid, void** ppvObject) +{ + if (!ppvObject) + return E_POINTER; + *ppvObject = 0; + + if (IsEqualIID(riid, __uuidof(WebScriptWorld))) + *ppvObject = this; + else if (IsEqualIID(riid, __uuidof(IWebScriptWorld))) + *ppvObject = static_cast<IWebScriptWorld*>(this); + else if (IsEqualIID(riid, IID_IUnknown)) + *ppvObject = static_cast<IUnknown*>(this); + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; +} + +HRESULT WebScriptWorld::standardWorld(IWebScriptWorld** outWorld) +{ + if (!outWorld) + return E_POINTER; + + *outWorld = standardWorld(); + (*outWorld)->AddRef(); + return S_OK; +} diff --git a/WebKit/win/WebScriptWorld.h b/WebKit/win/WebScriptWorld.h new file mode 100644 index 0000000..b800225 --- /dev/null +++ b/WebKit/win/WebScriptWorld.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 WebScriptWorld_h +#define WebScriptWorld_h + +#include <WebCore/COMPtr.h> + +namespace WebCore { + class DOMWrapperWorld; +} + +class WebScriptWorld : public Noncopyable, public IWebScriptWorld { +public: + static WebScriptWorld* standardWorld(); + static COMPtr<WebScriptWorld> createInstance(); + + static COMPtr<WebScriptWorld> findOrCreateWorld(WebCore::DOMWrapperWorld*); + + virtual ULONG STDMETHODCALLTYPE AddRef(); + virtual ULONG STDMETHODCALLTYPE Release(); + + WebCore::DOMWrapperWorld* world() const { return m_world.get(); } + +private: + static COMPtr<WebScriptWorld> createInstance(PassRefPtr<WebCore::DOMWrapperWorld>); + + WebScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>); + ~WebScriptWorld(); + + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void** ppvObject); + virtual HRESULT STDMETHODCALLTYPE standardWorld(IWebScriptWorld**); + + ULONG m_refCount; + RefPtr<WebCore::DOMWrapperWorld> m_world; +}; + +#endif // WebScriptWorld_h diff --git a/WebKit/win/WebSerializedJSValue.cpp b/WebKit/win/WebSerializedJSValue.cpp new file mode 100644 index 0000000..307df90 --- /dev/null +++ b/WebKit/win/WebSerializedJSValue.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 "WebKitDLL.h" +#include "WebSerializedJSValue.h" + +#include <WebCore/SerializedScriptValue.h> + +using namespace WebCore; + +WebSerializedJSValue::WebSerializedJSValue() + : m_refCount(0) +{ + ++gClassCount; + gClassNameCount.add("WebSerializedJSValue"); +} + +WebSerializedJSValue::~WebSerializedJSValue() +{ + --gClassCount; + gClassNameCount.remove("WebSerializedJSValue"); +} + +COMPtr<WebSerializedJSValue> WebSerializedJSValue::createInstance() +{ + return new WebSerializedJSValue(); +} + +ULONG WebSerializedJSValue::AddRef() +{ + return ++m_refCount; +} + +ULONG WebSerializedJSValue::Release() +{ + ULONG newRefCount = --m_refCount; + if (!newRefCount) + delete this; + return newRefCount; +} + +HRESULT WebSerializedJSValue::QueryInterface(REFIID riid, void** ppvObject) +{ + if (!ppvObject) + return E_POINTER; + *ppvObject = 0; + + if (IsEqualIID(riid, __uuidof(WebSerializedJSValue))) + *ppvObject = this; + else if (IsEqualIID(riid, __uuidof(IWebSerializedJSValue))) + *ppvObject = static_cast<IWebSerializedJSValue*>(this); + else if (IsEqualIID(riid, IID_IUnknown)) + *ppvObject = static_cast<IUnknown*>(this); + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; +} + +HRESULT WebSerializedJSValue::serialize(JSContextRef sourceContext, JSValueRef value, JSValueRef* exception) +{ + ASSERT_ARG(value, value); + ASSERT_ARG(sourceContext, sourceContext); + + if (!value || !sourceContext) + return E_POINTER; + + m_value = SerializedScriptValue::create(sourceContext, value, exception); + + return S_OK; +} + +HRESULT WebSerializedJSValue::deserialize(JSContextRef destinationContext, JSValueRef* outValue) +{ + if (!outValue) + return E_POINTER; + + if (!m_value) + *outValue = 0; + else + *outValue = m_value->deserialize(destinationContext, 0); + + return S_OK; +} diff --git a/WebKit/win/WebSerializedJSValue.h b/WebKit/win/WebSerializedJSValue.h new file mode 100644 index 0000000..d39323c --- /dev/null +++ b/WebKit/win/WebSerializedJSValue.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 WebSerializedJSValue_h +#define WebSerializedJSValue_h + +#include <WebCore/COMPtr.h> + +typedef const struct OpaqueJSContext* JSContextRef; +typedef const struct OpaqueJSValue* JSValueRef; + +namespace WebCore { + class SerializedScriptValue; +} + +class WebSerializedJSValue : public Noncopyable, public IWebSerializedJSValue { +public: + static COMPtr<WebSerializedJSValue> createInstance(); + + virtual ULONG STDMETHODCALLTYPE AddRef(); + virtual ULONG STDMETHODCALLTYPE Release(); + + virtual HRESULT STDMETHODCALLTYPE serialize(JSContextRef, JSValueRef value, JSValueRef* exception); + virtual HRESULT STDMETHODCALLTYPE deserialize(JSContextRef, JSValueRef* result); + +private: + WebSerializedJSValue(); + ~WebSerializedJSValue(); + + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void** ppvObject); + + ULONG m_refCount; + RefPtr<WebCore::SerializedScriptValue> m_value; +}; + +#endif // WebSerializedJSValue_h diff --git a/WebKit/win/WebURLAuthenticationChallenge.cpp b/WebKit/win/WebURLAuthenticationChallenge.cpp index 7c37501..c711450 100644 --- a/WebKit/win/WebURLAuthenticationChallenge.cpp +++ b/WebKit/win/WebURLAuthenticationChallenge.cpp @@ -172,7 +172,7 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::initWithAuthenticationC return E_NOINTERFACE; #if USE(CFNETWORK) - m_authenticationChallenge = AuthenticationChallenge(webChallenge->authenticationChallenge().cfURLAuthChallengeRef(), webSender->resourceHandle()); + m_authenticationChallenge = AuthenticationChallenge(webChallenge->authenticationChallenge().cfURLAuthChallengeRef(), webSender->authenticationClient()); return S_OK; #else @@ -220,8 +220,8 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::sender( /* [out, retval] */ IWebURLAuthenticationChallengeSender** sender) { if (!m_sender) { - ResourceHandle* handle = m_authenticationChallenge.sourceHandle(); - m_sender.adoptRef(WebURLAuthenticationChallengeSender::createInstance(handle)); + AuthenticationClient* client = m_authenticationChallenge.authenticationClient(); + m_sender.adoptRef(WebURLAuthenticationChallengeSender::createInstance(client)); } return m_sender.copyRefTo(sender); diff --git a/WebKit/win/WebURLAuthenticationChallengeSender.cpp b/WebKit/win/WebURLAuthenticationChallengeSender.cpp index 4d4d4cd..1257d41 100644 --- a/WebKit/win/WebURLAuthenticationChallengeSender.cpp +++ b/WebKit/win/WebURLAuthenticationChallengeSender.cpp @@ -34,18 +34,18 @@ #include "WebURLCredential.h" #pragma warning(push, 0) -#include <WebCore/ResourceHandle.h> +#include <WebCore/AuthenticationClient.h> #pragma warning(pop) using namespace WebCore; // WebURLAuthenticationChallengeSender ---------------------------------------------------------------- -WebURLAuthenticationChallengeSender::WebURLAuthenticationChallengeSender(PassRefPtr<ResourceHandle> handle) +WebURLAuthenticationChallengeSender::WebURLAuthenticationChallengeSender(PassRefPtr<AuthenticationClient> client) : m_refCount(0) - , m_handle(handle) + , m_client(client) { - ASSERT(m_handle); + ASSERT(m_client); gClassCount++; gClassNameCount.add("WebURLAuthenticationChallengeSender"); } @@ -56,9 +56,9 @@ WebURLAuthenticationChallengeSender::~WebURLAuthenticationChallengeSender() gClassNameCount.remove("WebURLAuthenticationChallengeSender"); } -WebURLAuthenticationChallengeSender* WebURLAuthenticationChallengeSender::createInstance(PassRefPtr<WebCore::ResourceHandle> handle) +WebURLAuthenticationChallengeSender* WebURLAuthenticationChallengeSender::createInstance(PassRefPtr<WebCore::AuthenticationClient> client) { - WebURLAuthenticationChallengeSender* instance = new WebURLAuthenticationChallengeSender(handle); + WebURLAuthenticationChallengeSender* instance = new WebURLAuthenticationChallengeSender(client); instance->AddRef(); return instance; } @@ -97,8 +97,8 @@ ULONG STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::Release(void) // WebURLAuthenticationChallengeSender ---------------------------------------------------------------- -ResourceHandle* WebURLAuthenticationChallengeSender::resourceHandle() const +AuthenticationClient* WebURLAuthenticationChallengeSender::authenticationClient() const { - return m_handle.get(); + return m_client.get(); } diff --git a/WebKit/win/WebURLAuthenticationChallengeSender.h b/WebKit/win/WebURLAuthenticationChallengeSender.h index cfb8cc3..5ccd0c5 100644 --- a/WebKit/win/WebURLAuthenticationChallengeSender.h +++ b/WebKit/win/WebURLAuthenticationChallengeSender.h @@ -32,16 +32,16 @@ #include <wtf/RefPtr.h> namespace WebCore { - class ResourceHandle; + class AuthenticationClient; } class DECLSPEC_UUID("5CACD637-F82F-491F-947A-5DCA38AA0FEA") WebURLAuthenticationChallengeSender : public IWebURLAuthenticationChallengeSender { public: - static WebURLAuthenticationChallengeSender* createInstance(PassRefPtr<WebCore::ResourceHandle>); + static WebURLAuthenticationChallengeSender* createInstance(PassRefPtr<WebCore::AuthenticationClient>); private: - WebURLAuthenticationChallengeSender(PassRefPtr<WebCore::ResourceHandle>); + WebURLAuthenticationChallengeSender(PassRefPtr<WebCore::AuthenticationClient>); ~WebURLAuthenticationChallengeSender(); public: // IUnknown @@ -60,12 +60,12 @@ public: /* [in] */ IWebURLCredential* credential, /* [in] */ IWebURLAuthenticationChallenge* challenge); - WebCore::ResourceHandle* resourceHandle() const; + WebCore::AuthenticationClient* authenticationClient() const; private: ULONG m_refCount; - RefPtr<WebCore::ResourceHandle> m_handle; + RefPtr<WebCore::AuthenticationClient> m_client; }; #endif diff --git a/WebKit/win/WebURLAuthenticationChallengeSenderCFNet.cpp b/WebKit/win/WebURLAuthenticationChallengeSenderCFNet.cpp index 21f79e0..f756391 100644 --- a/WebKit/win/WebURLAuthenticationChallengeSenderCFNet.cpp +++ b/WebKit/win/WebURLAuthenticationChallengeSenderCFNet.cpp @@ -34,7 +34,7 @@ #include "WebURLCredential.h" #pragma warning(push, 0) -#include <WebCore/ResourceHandle.h> +#include <WebCore/AuthenticationClient.h> #pragma warning(pop) using namespace WebCore; @@ -48,7 +48,7 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::cancelAuthenticat if (!webChallenge) return E_FAIL; - m_handle->receivedCancellation(webChallenge->authenticationChallenge()); + m_client->receivedCancellation(webChallenge->authenticationChallenge()); return S_OK; } @@ -59,7 +59,7 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::continueWithoutCr if (!webChallenge) return E_FAIL; - m_handle->receivedRequestToContinueWithoutCredential(webChallenge->authenticationChallenge()); + m_client->receivedRequestToContinueWithoutCredential(webChallenge->authenticationChallenge()); return S_OK; } @@ -75,6 +75,6 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::useCredential( if (!credential || FAILED(credential->QueryInterface(__uuidof(WebURLCredential), (void**)&webCredential))) return E_FAIL; - m_handle->receivedCredential(webChallenge->authenticationChallenge(), webCredential->credential()); + m_client->receivedCredential(webChallenge->authenticationChallenge(), webCredential->credential()); return S_OK; } diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp index e2f3fae..d98d390 100644 --- a/WebKit/win/WebView.cpp +++ b/WebKit/win/WebView.cpp @@ -31,17 +31,17 @@ #include "DOMCoreClasses.h" #include "MarshallingHelpers.h" #include "SoftLinking.h" +#include "WebBackForwardList.h" +#include "WebChromeClient.h" +#include "WebContextMenuClient.h" +#include "WebCoreTextRenderer.h" #include "WebDatabaseManager.h" #include "WebDocumentLoader.h" #include "WebDownload.h" +#include "WebDragClient.h" #include "WebEditorClient.h" #include "WebElementPropertyBag.h" #include "WebFrame.h" -#include "WebBackForwardList.h" -#include "WebChromeClient.h" -#include "WebContextMenuClient.h" -#include "WebCoreTextRenderer.h" -#include "WebDragClient.h" #include "WebIconDatabase.h" #include "WebInspector.h" #include "WebInspectorClient.h" @@ -52,6 +52,7 @@ #include "WebNotificationCenter.h" #include "WebPluginHalterClient.h" #include "WebPreferences.h" +#include "WebScriptWorld.h" #include "WindowsTouch.h" #pragma warning( push, 0 ) #include <WebCore/ApplicationCacheStorage.h> @@ -270,7 +271,6 @@ static const int maxToolTipWidth = 250; static const int delayBeforeDeletingBackingStoreMsec = 5000; static ATOM registerWebView(); -static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); static void initializeStaticObservers(); @@ -294,34 +294,37 @@ enum { bool WebView::s_allowSiteSpecificHacks = false; WebView::WebView() -: m_refCount(0) -, m_hostWindow(0) -, m_viewWindow(0) -, m_mainFrame(0) -, m_page(0) -, m_hasCustomDropTarget(false) -, m_useBackForwardList(true) -, m_userAgentOverridden(false) -, m_zoomMultiplier(1.0f) -, m_mouseActivated(false) -, m_dragData(0) -, m_currentCharacterCode(0) -, m_isBeingDestroyed(false) -, m_paintCount(0) -, m_hasSpellCheckerDocumentTag(false) -, m_smartInsertDeleteEnabled(false) -, m_didClose(false) -, m_inIMEComposition(0) -, m_toolTipHwnd(0) -, m_closeWindowTimer(this, &WebView::closeWindowTimerFired) -, m_topLevelParent(0) -, m_deleteBackingStoreTimerActive(false) -, m_transparent(false) -, m_selectTrailingWhitespaceEnabled(false) -, m_lastPanX(0) -, m_lastPanY(0) -, m_xOverpan(0) -, m_yOverpan(0) + : m_refCount(0) + , m_hostWindow(0) + , m_viewWindow(0) + , m_mainFrame(0) + , m_page(0) + , m_hasCustomDropTarget(false) + , m_useBackForwardList(true) + , m_userAgentOverridden(false) + , m_zoomMultiplier(1.0f) + , m_mouseActivated(false) + , m_dragData(0) + , m_currentCharacterCode(0) + , m_isBeingDestroyed(false) + , m_paintCount(0) + , m_hasSpellCheckerDocumentTag(false) + , m_smartInsertDeleteEnabled(false) + , m_didClose(false) + , m_inIMEComposition(0) + , m_toolTipHwnd(0) + , m_closeWindowTimer(this, &WebView::closeWindowTimerFired) + , m_topLevelParent(0) + , m_deleteBackingStoreTimerActive(false) + , m_transparent(false) + , m_selectTrailingWhitespaceEnabled(false) + , m_lastPanX(0) + , m_lastPanY(0) + , m_xOverpan(0) + , m_yOverpan(0) +#if USE(ACCELERATED_COMPOSITING) + , m_isAcceleratedCompositing(false) +#endif { JSC::initializeThreading(); @@ -617,6 +620,10 @@ HRESULT STDMETHODCALLTYPE WebView::close() m_didClose = true; +#if USE(ACCELERATED_COMPOSITING) + setAcceleratedCompositing(false); +#endif + WebNotificationCenter::defaultCenterInternal()->postNotificationName(_bstr_t(WebViewWillCloseNotification).GetBSTR(), static_cast<IWebView*>(this), 0); if (m_uiDelegatePrivate) @@ -676,6 +683,11 @@ HRESULT STDMETHODCALLTYPE WebView::close() void WebView::repaint(const WebCore::IntRect& windowRect, bool contentChanged, bool immediate, bool repaintContentOnly) { +#if USE(ACCELERATED_COMPOSITING) + if (isAcceleratedCompositing()) + setRootLayerNeedsDisplay(); +#endif + if (!repaintContentOnly) { RECT rect = windowRect; ::InvalidateRect(m_viewWindow, &rect, false); @@ -794,7 +806,6 @@ void WebView::scrollBackingStore(FrameView* frameView, int dx, int dy, const Int // Clean up. ::DeleteDC(bitmapDC); ::ReleaseDC(m_viewWindow, windowDC); - } // This emulates the Mac smarts for painting rects intelligently. This is very @@ -927,18 +938,25 @@ void WebView::paint(HDC dc, LPARAM options) // Update our backing store if needed. updateBackingStore(frameView, bitmapDC, backingStoreCompletelyDirty, windowsToPaint); - // Now we blit the updated backing store - IntRect windowDirtyRect = rcPaint; - - // Apply the same heuristic for this update region too. - Vector<IntRect> blitRects; - if (region && regionType == COMPLEXREGION) - getUpdateRects(region.get(), windowDirtyRect, blitRects); - else - blitRects.append(windowDirtyRect); +#if USE(ACCELERATED_COMPOSITING) + if (!isAcceleratedCompositing()) { +#endif + // Now we blit the updated backing store + IntRect windowDirtyRect = rcPaint; + + // Apply the same heuristic for this update region too. + Vector<IntRect> blitRects; + if (region && regionType == COMPLEXREGION) + getUpdateRects(region.get(), windowDirtyRect, blitRects); + else + blitRects.append(windowDirtyRect); - for (unsigned i = 0; i < blitRects.size(); ++i) - paintIntoWindow(bitmapDC, hdc, blitRects[i]); + for (unsigned i = 0; i < blitRects.size(); ++i) + paintIntoWindow(bitmapDC, hdc, blitRects[i]); +#if USE(ACCELERATED_COMPOSITING) + } else + updateRootLayerContents(); +#endif ::DeleteDC(bitmapDC); @@ -1805,7 +1823,7 @@ bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown) return frame->eventHandler()->keyEvent(keyEvent); } -static bool registerWebViewWindowClass() +bool WebView::registerWebViewWindowClass() { static bool haveRegisteredWindowClass = false; if (haveRegisteredWindowClass) @@ -1849,7 +1867,7 @@ static HWND findTopLevelParent(HWND window) return 0; } -static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK WebView::WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT lResult = 0; LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0); @@ -1941,22 +1959,31 @@ static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L if (lParam != 0) { webView->deleteBackingStore(); +#if USE(ACCELERATED_COMPOSITING) + if (webView->isAcceleratedCompositing()) + webView->resizeLayerRenderer(); +#endif if (Frame* coreFrame = core(mainFrameImpl)) coreFrame->view()->resize(LOWORD(lParam), HIWORD(lParam)); } break; case WM_SHOWWINDOW: lResult = DefWindowProc(hWnd, message, wParam, lParam); - if (wParam == 0) + if (wParam == 0) { // The window is being hidden (e.g., because we switched tabs). // Null out our backing store. webView->deleteBackingStore(); + } +#if USE(ACCELERATED_COMPOSITING) + else if (webView->isAcceleratedCompositing()) + webView->layerRendererBecameVisible(); +#endif break; case WM_SETFOCUS: { COMPtr<IWebUIDelegate> uiDelegate; COMPtr<IWebUIDelegatePrivate> uiDelegatePrivate; - if (SUCCEEDED(webView->uiDelegate(&uiDelegate)) && uiDelegate && - SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegatePrivate, (void**) &uiDelegatePrivate)) && uiDelegatePrivate) + if (SUCCEEDED(webView->uiDelegate(&uiDelegate)) && uiDelegate + && SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegatePrivate, (void**) &uiDelegatePrivate)) && uiDelegatePrivate) uiDelegatePrivate->webViewReceivedFocus(webView); FocusController* focusController = webView->page()->focusController(); @@ -1975,8 +2002,8 @@ static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L COMPtr<IWebUIDelegate> uiDelegate; COMPtr<IWebUIDelegatePrivate> uiDelegatePrivate; HWND newFocusWnd = reinterpret_cast<HWND>(wParam); - if (SUCCEEDED(webView->uiDelegate(&uiDelegate)) && uiDelegate && - SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegatePrivate, (void**) &uiDelegatePrivate)) && uiDelegatePrivate) + if (SUCCEEDED(webView->uiDelegate(&uiDelegate)) && uiDelegate + && SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegatePrivate, (void**) &uiDelegatePrivate)) && uiDelegatePrivate) uiDelegatePrivate->webViewLostFocus(webView, (OLE_HANDLE)(ULONG64)newFocusWnd); FocusController* focusController = webView->page()->focusController(); @@ -2040,7 +2067,11 @@ static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L RECT windowRect; ::GetClientRect(hWnd, &windowRect); ::InvalidateRect(hWnd, &windowRect, false); - } +#if USE(ACCELERATED_COMPOSITING) + if (webView->isAcceleratedCompositing()) + webView->setRootLayerNeedsDisplay(); +#endif + } break; case WM_MOUSEACTIVATE: webView->setMouseActivated(true); @@ -2055,9 +2086,9 @@ static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L if (lpMsg->message == WM_KEYDOWN) keyCode = (UINT) lpMsg->wParam; } - if (SUCCEEDED(webView->uiDelegate(&uiDelegate)) && uiDelegate && - SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegatePrivate, (void**) &uiDelegatePrivate)) && uiDelegatePrivate && - SUCCEEDED(uiDelegatePrivate->webViewGetDlgCode(webView, keyCode, &dlgCode))) + if (SUCCEEDED(webView->uiDelegate(&uiDelegate)) && uiDelegate + && SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegatePrivate, (void**) &uiDelegatePrivate)) && uiDelegatePrivate + && SUCCEEDED(uiDelegatePrivate->webViewGetDlgCode(webView, keyCode, &dlgCode))) return dlgCode; handled = false; break; @@ -2876,7 +2907,8 @@ HRESULT STDMETHODCALLTYPE WebView::stringByEvaluatingJavaScriptFromString( return E_FAIL; else if (scriptExecutionResult.isString()) { JSLock lock(JSC::SilenceAssertionsOnly); - *result = BString(String(scriptExecutionResult.getString())); + JSC::ExecState* exec = coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec(); + *result = BString(String(scriptExecutionResult.getString(exec))); } return S_OK; @@ -5469,6 +5501,16 @@ HRESULT WebView::setCanStartPlugins(BOOL canStartPlugins) return S_OK; } +static String toString(BSTR bstr) +{ + return String(bstr, SysStringLen(bstr)); +} + +static KURL toKURL(BSTR bstr) +{ + return KURL(KURL(), toString(bstr)); +} + static PassOwnPtr<Vector<String> > toStringVector(unsigned patternsCount, BSTR* patterns) { // Convert the patterns into a Vector. @@ -5476,17 +5518,21 @@ static PassOwnPtr<Vector<String> > toStringVector(unsigned patternsCount, BSTR* return 0; Vector<String>* patternsVector = new Vector<String>; for (unsigned i = 0; i < patternsCount; ++i) - patternsVector->append(String(patterns[i], SysStringLen(patterns[i]))); + patternsVector->append(toString(patterns[i])); return patternsVector; } -HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, +HRESULT WebView::addUserScriptToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url, unsigned whitelistCount, BSTR* whitelist, unsigned blacklistCount, BSTR* blacklist, WebUserScriptInjectionTime injectionTime) { - String group(groupName, SysStringLen(groupName)); - if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max()) + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return E_POINTER; + + String group = toString(groupName); + if (group.isEmpty()) return E_INVALIDARG; PageGroup* pageGroup = PageGroup::pageGroup(group); @@ -5494,19 +5540,23 @@ HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR sou if (!pageGroup) return E_FAIL; - pageGroup->addUserScriptToWorld(worldID, String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))), + pageGroup->addUserScriptToWorld(world->world(), toString(source), toKURL(url), toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist), injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd); return S_OK; } -HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, +HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url, unsigned whitelistCount, BSTR* whitelist, unsigned blacklistCount, BSTR* blacklist) { - String group(groupName, SysStringLen(groupName)); - if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max()) + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return E_POINTER; + + String group = toString(groupName); + if (group.isEmpty()) return E_INVALIDARG; PageGroup* pageGroup = PageGroup::pageGroup(group); @@ -5514,16 +5564,20 @@ HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR if (!pageGroup) return E_FAIL; - pageGroup->addUserStyleSheetToWorld(worldID, String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))), + pageGroup->addUserStyleSheetToWorld(world->world(), toString(source), toKURL(url), toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist)); return S_OK; } -HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url) +HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url) { - String group(groupName, SysStringLen(groupName)); - if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max()) + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return E_POINTER; + + String group = toString(groupName); + if (group.isEmpty()) return E_INVALIDARG; PageGroup* pageGroup = PageGroup::pageGroup(group); @@ -5531,15 +5585,19 @@ HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BST if (!pageGroup) return E_FAIL; - pageGroup->removeUserScriptFromWorld(worldID, KURL(KURL(), String(url, SysStringLen(url)))); + pageGroup->removeUserScriptFromWorld(world->world(), toKURL(url)); return S_OK; } -HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url) +HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url) { - String group(groupName, SysStringLen(groupName)); - if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max()) + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return E_POINTER; + + String group = toString(groupName); + if (group.isEmpty()) return E_INVALIDARG; PageGroup* pageGroup = PageGroup::pageGroup(group); @@ -5547,15 +5605,19 @@ HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, if (!pageGroup) return E_FAIL; - pageGroup->removeUserStyleSheetFromWorld(worldID, KURL(KURL(), String(url, SysStringLen(url)))); + pageGroup->removeUserStyleSheetFromWorld(world->world(), toKURL(url)); return S_OK; } -HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, unsigned worldID) +HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld* iWorld) { - String group(groupName, SysStringLen(groupName)); - if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max()) + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return E_POINTER; + + String group = toString(groupName); + if (group.isEmpty()) return E_INVALIDARG; PageGroup* pageGroup = PageGroup::pageGroup(group); @@ -5563,14 +5625,18 @@ HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, unsigned worldID) if (!pageGroup) return E_FAIL; - pageGroup->removeUserScriptsFromWorld(worldID); + pageGroup->removeUserScriptsFromWorld(world->world()); return S_OK; } -HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID) +HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld* iWorld) { - String group(groupName, SysStringLen(groupName)); - if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max()) + COMPtr<WebScriptWorld> world(Query, iWorld); + if (!world) + return E_POINTER; + + String group = toString(groupName); + if (group.isEmpty()) return E_INVALIDARG; PageGroup* pageGroup = PageGroup::pageGroup(group); @@ -5578,13 +5644,13 @@ HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID if (!pageGroup) return E_FAIL; - pageGroup->removeUserStyleSheetsFromWorld(worldID); + pageGroup->removeUserStyleSheetsFromWorld(world->world()); return S_OK; } HRESULT WebView::removeAllUserContentFromGroup(BSTR groupName) { - String group(groupName, SysStringLen(groupName)); + String group = toString(groupName); if (group.isEmpty()) return E_INVALIDARG; @@ -5663,6 +5729,70 @@ void WebView::downloadURL(const KURL& url) download->start(); } +#if USE(ACCELERATED_COMPOSITING) +void WebView::setRootChildLayer(WebCore::PlatformLayer* layer) +{ + setAcceleratedCompositing(layer ? true : false); + if (m_layerRenderer) + m_layerRenderer->setRootChildLayer(layer); +} + +void WebView::setAcceleratedCompositing(bool accelerated) +{ + if (m_isAcceleratedCompositing == accelerated || !WKCACFLayerRenderer::acceleratedCompositingAvailable()) + return; + + if (accelerated) { + m_layerRenderer = WKCACFLayerRenderer::create(); + if (m_layerRenderer) { + m_isAcceleratedCompositing = true; + + // Create the root layer + ASSERT(m_viewWindow); + m_layerRenderer->setHostWindow(m_viewWindow); + updateRootLayerContents(); + } + } else { + m_layerRenderer = 0; + m_isAcceleratedCompositing = false; + } +} + +void WebView::updateRootLayerContents() +{ + if (!m_backingStoreBitmap || !m_layerRenderer) + return; + + // Get the backing store into a CGImage + BITMAP bitmap; + GetObject(m_backingStoreBitmap.get(), sizeof(bitmap), &bitmap); + int bmSize = bitmap.bmWidthBytes * bitmap.bmHeight; + RetainPtr<CFDataRef> data(AdoptCF, + CFDataCreateWithBytesNoCopy( + 0, static_cast<UInt8*>(bitmap.bmBits), + bmSize, kCFAllocatorNull)); + RetainPtr<CGDataProviderRef> cgData(AdoptCF, CGDataProviderCreateWithCFData(data.get())); + RetainPtr<CGColorSpaceRef> space(AdoptCF, CGColorSpaceCreateDeviceRGB()); + RetainPtr<CGImageRef> backingStoreImage(AdoptCF, CGImageCreate(bitmap.bmWidth, bitmap.bmHeight, + 8, bitmap.bmBitsPixel, + bitmap.bmWidthBytes, space.get(), + kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, + cgData.get(), 0, false, + kCGRenderingIntentDefault)); + + // Hand the CGImage to CACF for compositing + m_layerRenderer->setRootContents(backingStoreImage.get()); + + // Set the frame and scroll position + Frame* coreFrame = core(m_mainFrame); + if (!coreFrame) + return; + FrameView* frameView = coreFrame->view(); + + m_layerRenderer->setScrollFrame(frameView->layoutWidth(), frameView->layoutHeight(), + frameView->scrollX(), frameView->scrollY()); +} +#endif HRESULT STDMETHODCALLTYPE WebView::setPluginHalterDelegate(IWebPluginHalterDelegate* d) { diff --git a/WebKit/win/WebView.h b/WebKit/win/WebView.h index b4c1239..4bdc98f 100644 --- a/WebKit/win/WebView.h +++ b/WebKit/win/WebView.h @@ -34,6 +34,8 @@ #include <WebCore/IntRect.h> #include <WebCore/Timer.h> #include <WebCore/WindowMessageListener.h> +#include <WebCore/WKCACFLayer.h> +#include <WebCore/WKCACFLayerRenderer.h> #include <wtf/HashSet.h> #include <wtf/OwnPtr.h> @@ -740,17 +742,17 @@ public: virtual HRESULT STDMETHODCALLTYPE setCanStartPlugins( /* [in] */ BOOL canStartPlugins); - virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, + virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url, unsigned whitelistCount, BSTR* whitelist, unsigned blacklistCount, BSTR* blacklist, WebUserScriptInjectionTime); - virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, + virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url, unsigned whitelistCount, BSTR* whitelist, unsigned blacklistCount, BSTR* blacklist); - virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url); - virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url); - virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, unsigned worldID); - virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID); + virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url); + virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url); + virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld*); + virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld*); virtual HRESULT STDMETHODCALLTYPE removeAllUserContentFromGroup(BSTR groupName); virtual HRESULT STDMETHODCALLTYPE setPluginHalterDelegate(IWebPluginHalterDelegate*); @@ -861,6 +863,11 @@ public: void downloadURL(const WebCore::KURL&); +#if USE(ACCELERATED_COMPOSITING) + void setRootLayerNeedsDisplay() { if (m_layerRenderer) m_layerRenderer->setNeedsDisplay(); } + void setRootChildLayer(WebCore::PlatformLayer* layer); +#endif + private: void setZoomMultiplier(float multiplier, bool isTextOnly); float zoomMultiplier(bool isTextOnly); @@ -885,6 +892,9 @@ private: DWORD m_lastDropEffect; protected: + static bool registerWebViewWindowClass(); + static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + HIMC getIMMContext(); void releaseIMMContext(HIMC); static bool allowSiteSpecificHacks() { return s_allowSiteSpecificHacks; } @@ -970,6 +980,17 @@ protected: long m_lastPanY; long m_xOverpan; long m_yOverpan; + +#if USE(ACCELERATED_COMPOSITING) + bool isAcceleratedCompositing() const { return m_isAcceleratedCompositing; } + void setAcceleratedCompositing(bool); + void updateRootLayerContents(); + void resizeLayerRenderer() { m_layerRenderer->resize(); } + void layerRendererBecameVisible() { m_layerRenderer->createRenderer(); } + + OwnPtr<WebCore::WKCACFLayerRenderer> m_layerRenderer; + bool m_isAcceleratedCompositing; +#endif }; #endif diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog index f2cc27f..e6ed389 100644 --- a/WebKit/wx/ChangeLog +++ b/WebKit/wx/ChangeLog @@ -1,3 +1,155 @@ +2009-12-08 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + [wx] Mac plugins support. + + https://bugs.webkit.org/show_bug.cgi?id=32236 + + * WebKitSupport/FrameLoaderClientWx.cpp: + (WebCore::FrameLoaderClientWx::createPlugin): + (WebCore::FrameLoaderClientWx::redirectDataToPlugin): + * WebView.cpp: + (wxWebView::Create): + +2009-12-03 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7214236> and http://webkit.org/b/32052 - Implement HTML5 state object history API + + * WebKitSupport/FrameLoaderClientWx.cpp: + (WebCore::FrameLoaderClientWx::dispatchDidPushStateWithinPage): + (WebCore::FrameLoaderClientWx::dispatchDidReplaceStateWithinPage): + (WebCore::FrameLoaderClientWx::dispatchDidPopStateWithinPage): + * WebKitSupport/FrameLoaderClientWx.h: + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebKitSupport/InspectorClientWx.cpp: + (WebCore::InspectorClientWx::populateSetting): + (WebCore::InspectorClientWx::storeSetting): + * WebKitSupport/InspectorClientWx.h: + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * WebKitSupport/FrameLoaderClientWx.cpp: + (WebCore::FrameLoaderClientWx::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebCore::FrameLoaderClientWx::dispatchDidRemoveBackForwardItem): ditto. + (WebCore::FrameLoaderClientWx::dispatchDidChangeBackForwardIndex): ditto. + * WebKitSupport/FrameLoaderClientWx.h: + +2009-11-23 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + Include "config.h" to meet Coding Style Guidelines + https://bugs.webkit.org/show_bug.cgi?id=31792 + + * WebKitSupport/DragClientWx.cpp: + +2009-11-18 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + Enable wx plugin support using the Windows implementation as a base. + + https://bugs.webkit.org/show_bug.cgi?id=31636 + + * WebKitSupport/FrameLoaderClientWx.cpp: + (WebCore::FrameLoaderClientWx::FrameLoaderClientWx): + (WebCore::FrameLoaderClientWx::finishedLoading): + (WebCore::FrameLoaderClientWx::committedLoad): + (WebCore::FrameLoaderClientWx::createPlugin): + (WebCore::FrameLoaderClientWx::redirectDataToPlugin): + (WebCore::FrameLoaderClientWx::shouldUsePluginDocument): + * WebKitSupport/FrameLoaderClientWx.h: + * WebView.cpp: + (wxWebView::Create): + +2009-11-13 Kevin Ollivier <kevino@theolliviers.com> + + wx build fix after r50923 change to externalRepresentation. + + * WebFrame.cpp: + (wxWebFrame::GetExternalRepresentation): + +2009-11-13 Adam Roben <aroben@apple.com> + + Update for changes to FrameLoaderClient + + Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when + window objects in isolated worlds are cleared + + Reviewed by Dave Hyatt. + + * WebKitSupport/FrameLoaderClientWx.cpp: + (WebCore::FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld): + * WebKitSupport/FrameLoaderClientWx.h: + Replaced windowObjectCleared with this function. Does nothing if the + passed-in world is not the mainThreadNormalWorld(). + +2009-11-10 Robin Dunn <robin@alldunn.com> + + Reviewed by Kevin Ollivier. + + Add sanity checks to RunScript to ensure it doesn't run when the document hasn't yet + loaded nor when JavaScript is disabled. + + https://bugs.webkit.org/show_bug.cgi?id=31309 + + * WebFrame.cpp: + (wxWebFrame::RunScript): + +2009-11-04 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + Fix an assert on shutdown when wxWebView has captured the mouse, + and make sure wxWebView's right click handling is only active when + the WebCore popup menu is used. + + https://bugs.webkit.org/show_bug.cgi?id=31131 + + * WebView.cpp: + (wxWebView::~wxWebView): + (wxWebView::OnContextMenuEvents): + (wxWebView::OnMenuSelectEvents): + +2009-11-04 Vadim Zeitlin <vadim@wxwidgets.org> + + Reviewed by Eric Seidel. + + [wx] Small cleanup: avoid unnecessary wxString::mb_str() calls. + + * WebFrame.cpp: + (wxWebFrame::SetPageSource): + (wxWebFrame::LoadURL): + +2009-10-30 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Notify the chrome when the focused node has changed. + https://bugs.webkit.org/show_bug.cgi?id=30832 + + Added stub implementation for new ChromeClient function. + + * WebKitSupport/ChromeClientWx.cpp: + (WebCore::ChromeClientWx::focusedNodeChanged): + * WebKitSupport/ChromeClientWx.h: + 2009-10-23 Kevin Ollivier <kevino@theolliviers.com> wx build fix. Update the globalObject calls after changes. diff --git a/WebKit/wx/WebFrame.cpp b/WebKit/wx/WebFrame.cpp index 9018d37..bd983f6 100644 --- a/WebKit/wx/WebFrame.cpp +++ b/WebKit/wx/WebFrame.cpp @@ -146,9 +146,9 @@ wxString wxWebFrame::GetPageSource() void wxWebFrame::SetPageSource(const wxString& source, const wxString& baseUrl) { if (m_impl->frame && m_impl->frame->loader()) { - WebCore::KURL url(WebCore::KURL(), static_cast<const char*>(baseUrl.mb_str(wxConvUTF8))); + WebCore::KURL url(WebCore::KURL(), baseUrl); - wxCharBuffer charBuffer(source.mb_str(wxConvUTF8)); + const wxCharBuffer charBuffer(source.utf8_str()); const char* contents = charBuffer; WTF::PassRefPtr<WebCore::SharedBuffer> sharedBuffer = WebCore::SharedBuffer::create(contents, strlen(contents)); @@ -181,16 +181,25 @@ wxString wxWebFrame::GetExternalRepresentation() if (m_impl->frame->view() && m_impl->frame->view()->layoutPending()) m_impl->frame->view()->layout(); - return externalRepresentation(m_impl->frame->contentRenderer()); + return externalRepresentation(m_impl->frame); } wxString wxWebFrame::RunScript(const wxString& javascript) { wxString returnValue = wxEmptyString; - if (m_impl->frame) { - JSC::JSValue result = m_impl->frame->script()->executeScript(javascript, true).jsValue(); - if (result) - returnValue = wxString(result.toString(m_impl->frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec()).UTF8String().c_str(), wxConvUTF8); + if (m_impl->frame && m_impl->frame->loader()) { + bool hasLoaded = m_impl->frame->loader()->frameHasLoaded(); + wxASSERT_MSG(hasLoaded, wxT("Document must be loaded before calling RunScript.")); + if (hasLoaded) { + WebCore::ScriptController* controller = m_impl->frame->script(); + bool jsEnabled = controller->isEnabled(); + wxASSERT_MSG(jsEnabled, wxT("RunScript requires JavaScript to be enabled.")); + if (jsEnabled) { + JSC::JSValue result = controller->executeScript(javascript, true).jsValue(); + if (result) + returnValue = wxString(result.toString(m_impl->frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec()).UTF8String().c_str(), wxConvUTF8); + } + } } return returnValue; } @@ -206,7 +215,7 @@ bool wxWebFrame::FindString(const wxString& string, bool forward, bool caseSensi void wxWebFrame::LoadURL(const wxString& url) { if (m_impl->frame && m_impl->frame->loader()) { - WebCore::KURL kurl = WebCore::KURL(WebCore::KURL(), static_cast<const char*>(url.mb_str(wxConvUTF8)), WebCore::UTF8Encoding()); + WebCore::KURL kurl = WebCore::KURL(WebCore::KURL(), url, WebCore::UTF8Encoding()); // NB: This is an ugly fix, but CURL won't load sub-resources if the // protocol is omitted; sadly, it will not emit an error, either, so // there's no way for us to catch this problem the correct way yet. diff --git a/WebKit/wx/WebKitSupport/ChromeClientWx.cpp b/WebKit/wx/WebKitSupport/ChromeClientWx.cpp index 629463f..17f6f43 100644 --- a/WebKit/wx/WebKitSupport/ChromeClientWx.cpp +++ b/WebKit/wx/WebKitSupport/ChromeClientWx.cpp @@ -111,6 +111,9 @@ void ChromeClientWx::takeFocus(FocusDirection) notImplemented(); } +void ChromeClientWx::focusedNodeChanged(Node*) +{ +} Page* ChromeClientWx::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures&) { diff --git a/WebKit/wx/WebKitSupport/ChromeClientWx.h b/WebKit/wx/WebKitSupport/ChromeClientWx.h index 07f70a8..bd4f1ec 100644 --- a/WebKit/wx/WebKitSupport/ChromeClientWx.h +++ b/WebKit/wx/WebKitSupport/ChromeClientWx.h @@ -54,6 +54,8 @@ public: virtual bool canTakeFocus(FocusDirection); virtual void takeFocus(FocusDirection); + virtual void focusedNodeChanged(Node*); + virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&); virtual Page* createModalDialog(Frame*, const FrameLoadRequest&); virtual void show(); diff --git a/WebKit/wx/WebKitSupport/DragClientWx.cpp b/WebKit/wx/WebKitSupport/DragClientWx.cpp index dcccc34..fb6905b 100644 --- a/WebKit/wx/WebKitSupport/DragClientWx.cpp +++ b/WebKit/wx/WebKitSupport/DragClientWx.cpp @@ -23,7 +23,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "DragClientWx.h" + #include "NotImplemented.h" #include <stdio.h> diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp index 568cf42..fbb4ec3 100644 --- a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp +++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp @@ -37,11 +37,13 @@ #include "FrameLoaderTypes.h" #include "FrameView.h" #include "FrameTree.h" +#include "PluginView.h" #include "HTMLFormElement.h" #include "HTMLFrameOwnerElement.h" #include "NotImplemented.h" #include "Page.h" #include "PlatformString.h" +#include "PluginView.h" #include "ProgressTracker.h" #include "RenderPart.h" #include "ResourceError.h" @@ -80,7 +82,10 @@ inline int wxNavTypeFromWebNavType(NavigationType type){ } FrameLoaderClientWx::FrameLoaderClientWx() - : m_webFrame(0) + : m_frame(0) + , m_pluginView(0) + , m_hasSentResponseToPlugin(false) + , m_webFrame(0) { } @@ -257,6 +262,20 @@ void FrameLoaderClientWx::dispatchDidChangeLocationWithinPage() notImplemented(); } +void FrameLoaderClientWx::dispatchDidPushStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidReplaceStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidPopStateWithinPage() +{ + notImplemented(); +} void FrameLoaderClientWx::dispatchWillClose() { @@ -408,7 +427,11 @@ void FrameLoaderClientWx::didChangeTitle(DocumentLoader *l) void FrameLoaderClientWx::finishedLoading(DocumentLoader*) { - notImplemented(); + if (m_pluginView) { + m_pluginView->didFinishLoading(); + m_pluginView = 0; + m_hasSentResponseToPlugin = false; + } } @@ -579,9 +602,25 @@ void FrameLoaderClientWx::committedLoad(WebCore::DocumentLoader* loader, const c { if (!m_webFrame) return; - FrameLoader* fl = loader->frameLoader(); - fl->setEncoding(m_response.textEncodingName(), false); - fl->addData(data, length); + if (!m_pluginView) { + FrameLoader* fl = loader->frameLoader(); + fl->setEncoding(m_response.textEncodingName(), false); + fl->addData(data, length); + } + + // We re-check here as the plugin can have been created + if (m_pluginView) { + if (!m_hasSentResponseToPlugin) { + m_pluginView->didReceiveResponse(loader->response()); + // didReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in + // setting up this stream can cause the main document load to be cancelled, setting m_pluginView + // to null + if (!m_pluginView) + return; + m_hasSentResponseToPlugin = true; + } + m_pluginView->didReceiveData(data, length); + } } WebCore::ResourceError FrameLoaderClientWx::cancelledError(const WebCore::ResourceRequest& request) @@ -812,16 +851,21 @@ ObjectContentType FrameLoaderClientWx::objectContentType(const KURL& url, const return ObjectContentType(); } -PassRefPtr<Widget> FrameLoaderClientWx::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) +PassRefPtr<Widget> FrameLoaderClientWx::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { - notImplemented(); +#if __WXMSW__ || __WXMAC__ + RefPtr<PluginView> pv = PluginView::create(m_frame, size, element, url, paramNames, paramValues, mimeType, loadManually); + if (pv->status() == PluginStatusLoadedSuccessfully) + return pv; +#endif return 0; } void FrameLoaderClientWx::redirectDataToPlugin(Widget* pluginWidget) { - notImplemented(); - return; + ASSERT(!m_pluginView); + m_pluginView = static_cast<PluginView*>(pluginWidget); + m_hasSentResponseToPlugin = false; } ResourceError FrameLoaderClientWx::pluginWillHandleLoadError(const ResourceResponse& response) @@ -843,8 +887,11 @@ String FrameLoaderClientWx::overrideMediaType() const return String(); } -void FrameLoaderClientWx::windowObjectCleared() +void FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) { + if (world != mainThreadNormalWorld()) + return; + if (m_webView) { wxWebViewWindowObjectClearedEvent wkEvent(m_webView); Frame* coreFrame = m_webView->GetMainFrame()->GetFrame(); @@ -897,4 +944,11 @@ void FrameLoaderClientWx::transitionToCommittedForNewPage() m_frame->createView(size, backgroundColor, transparent, IntSize(), false); } +bool FrameLoaderClientWx::shouldUsePluginDocument(const String &mimeType) const +{ + // NOTE: Plugin Documents are used for viewing PDFs, etc. inline, and should + // not be used for pages with plugins in them. + return false; +} + } diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h index ed11974..0c29941 100644 --- a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h +++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h @@ -31,7 +31,9 @@ #include "FrameLoaderClient.h" #include "FrameLoader.h" #include "KURL.h" +#include "PluginView.h" #include "ResourceResponse.h" +#include "HTMLPlugInElement.h" class wxWebFrame; class wxWebView; @@ -94,6 +96,9 @@ namespace WebCore { virtual void dispatchDidCancelClientRedirect(); virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); @@ -205,17 +210,21 @@ namespace WebCore { virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType); virtual String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; virtual void registerForIconNotification(bool listen = true); + + virtual bool shouldUsePluginDocument(const String &mimeType) const; private: wxWebFrame *m_webFrame; Frame* m_frame; wxWebView *m_webView; + PluginView* m_pluginView; + bool m_hasSentResponseToPlugin; ResourceResponse m_response; bool m_firstData; }; diff --git a/WebKit/wx/WebKitSupport/InspectorClientWx.cpp b/WebKit/wx/WebKitSupport/InspectorClientWx.cpp index d55ad04..ff21ae0 100644 --- a/WebKit/wx/WebKitSupport/InspectorClientWx.cpp +++ b/WebKit/wx/WebKitSupport/InspectorClientWx.cpp @@ -105,17 +105,12 @@ void InspectorClientWx::inspectedURLChanged(const String& newURL) notImplemented(); } -void InspectorClientWx::populateSetting(const String& key, InspectorController::Setting& setting) +void InspectorClientWx::populateSetting(const String& key, String* setting) { notImplemented(); } -void InspectorClientWx::storeSetting(const String& key, const InspectorController::Setting& setting) -{ - notImplemented(); -} - -void InspectorClientWx::removeSetting(const String& key) +void InspectorClientWx::storeSetting(const String& key, const String& setting) { notImplemented(); } diff --git a/WebKit/wx/WebKitSupport/InspectorClientWx.h b/WebKit/wx/WebKitSupport/InspectorClientWx.h index 182df1b..f905817 100644 --- a/WebKit/wx/WebKitSupport/InspectorClientWx.h +++ b/WebKit/wx/WebKitSupport/InspectorClientWx.h @@ -60,10 +60,9 @@ public: virtual void inspectedURLChanged(const String& newURL); - virtual void populateSetting(const String& key, InspectorController::Setting&); - virtual void storeSetting(const String& key, const InspectorController::Setting&); - virtual void removeSetting(const String& key); - + virtual void populateSetting(const String& key, String* value); + virtual void storeSetting(const String& key, const String& value); + virtual void inspectorWindowObjectCleared(); }; diff --git a/WebKit/wx/WebView.cpp b/WebKit/wx/WebView.cpp index 1b27cde..2c752de 100644 --- a/WebKit/wx/WebView.cpp +++ b/WebKit/wx/WebView.cpp @@ -257,7 +257,6 @@ BEGIN_EVENT_TABLE(wxWebView, wxWindow) EVT_SIZE(wxWebView::OnSize) EVT_MOUSE_EVENTS(wxWebView::OnMouseEvents) EVT_CONTEXT_MENU(wxWebView::OnContextMenuEvents) - EVT_MENU(wxID_ANY, wxWebView::OnMenuSelectEvents) EVT_KEY_DOWN(wxWebView::OnKeyEvents) EVT_KEY_UP(wxWebView::OnKeyEvents) EVT_CHAR(wxWebView::OnKeyEvents) @@ -339,6 +338,10 @@ bool wxWebView::Create(wxWindow* parent, int id, const wxPoint& position, settings->setDatabasesEnabled(true); #endif +#if __WXMSW__ || __WXMAC__ + settings->setPluginsEnabled(true); +#endif + m_isInitialized = true; return true; @@ -348,6 +351,9 @@ wxWebView::~wxWebView() { m_beingDestroyed = true; + while (HasCapture()) + ReleaseMouse(); + if (m_mainFrame && m_mainFrame->GetFrame()) m_mainFrame->GetFrame()->loader()->detachFromParent(); @@ -646,6 +652,7 @@ void wxWebView::OnMouseEvents(wxMouseEvent& event) void wxWebView::OnContextMenuEvents(wxContextMenuEvent& event) { + Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxWebView::OnMenuSelectEvents), NULL, this); m_impl->page->contextMenuController()->clearContextMenu(); wxPoint localEventPoint = ScreenToClient(event.GetPosition()); @@ -675,10 +682,18 @@ void wxWebView::OnContextMenuEvents(wxContextMenuEvent& event) return; PopupMenu(menuWx, localEventPoint); + + Disconnect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxWebView::OnMenuSelectEvents), NULL, this); } void wxWebView::OnMenuSelectEvents(wxCommandEvent& event) { + // we shouldn't hit this unless there's a context menu showing + WebCore::ContextMenu* coreMenu = m_impl->page->contextMenuController()->contextMenu(); + ASSERT(coreMenu); + if (!coreMenu) + return; + WebCore::ContextMenuItem* item = WebCore::ContextMenu::itemWithId (event.GetId()); if (!item) return; |