diff options
Diffstat (limited to 'WebCore')
76 files changed, 974 insertions, 229 deletions
diff --git a/WebCore/Android.derived.jscbindings.mk b/WebCore/Android.derived.jscbindings.mk index d7ca0a4..cc7ba28 100644 --- a/WebCore/Android.derived.jscbindings.mk +++ b/WebCore/Android.derived.jscbindings.mk @@ -289,6 +289,7 @@ $(patsubst %.h,%.cpp,$(GEN)): $(intermediates)/loader/appcache/%.cpp : $(interme # page GEN := \ $(intermediates)/page/JSBarInfo.h \ + $(intermediates)/page/JSConnection.h \ $(intermediates)/page/JSConsole.h \ $(intermediates)/page/JSCoordinates.h \ $(intermediates)/page/JSDOMSelection.h \ diff --git a/WebCore/Android.derived.v8bindings.mk b/WebCore/Android.derived.v8bindings.mk index a9f403a..e3bd4ca 100644 --- a/WebCore/Android.derived.v8bindings.mk +++ b/WebCore/Android.derived.v8bindings.mk @@ -281,6 +281,7 @@ $(patsubst %.h,%.cpp,$(GEN)): $(intermediates)/bindings/%.cpp : $(intermediates) # page GEN := \ $(intermediates)/bindings/V8BarInfo.h \ + $(intermediates)/bindings/V8Connection.h \ $(intermediates)/bindings/V8Console.h \ $(intermediates)/bindings/V8Coordinates.h \ $(intermediates)/bindings/V8DOMSelection.h \ diff --git a/WebCore/Android.mk b/WebCore/Android.mk index 0ab375b..19e3fd2 100644 --- a/WebCore/Android.mk +++ b/WebCore/Android.mk @@ -326,6 +326,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ \ page/BarInfo.cpp \ page/Chrome.cpp \ + page/Connection.cpp \ page/Console.cpp \ page/ContextMenuController.cpp \ page/DOMSelection.cpp \ @@ -517,7 +518,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/network/ResourceRequestBase.cpp \ platform/network/ResourceResponseBase.cpp \ \ - platform/network/android/Cookie.cpp \ + platform/network/android/CookieJarAndroid.cpp \ platform/network/android/NetworkStateNotifierAndroid.cpp \ platform/network/android/ResourceHandleAndroid.cpp \ platform/network/android/ResourceRequestAndroid.cpp \ diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 81abb2d..1e9ec41 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -35,6 +35,85 @@ * bridge/jni/jsc/JavaInstanceJSC.cpp: Copied from WebCore/bridge/jni/jni_instance.cpp. * bridge/jni/jsc/JavaInstanceJSC.h: Copied from WebCore/bridge/jni/jni_instance.h. +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * GNUmakefile.am: + * WebCore.base.exp: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * WebCoreSources.bkl: + * page/Geolocation.cpp: + (WebCore::createGeopositionFromGeolocationPosition): + (WebCore::createPositionErrorFromGeolocationError): + (WebCore::Geolocation::Geolocation): + (WebCore::Geolocation::~Geolocation): + (WebCore::Geolocation::disconnectFrame): + (WebCore::Geolocation::lastPosition): + (WebCore::Geolocation::startRequest): + (WebCore::Geolocation::fatalErrorOccurred): + (WebCore::Geolocation::requestTimedOut): + (WebCore::Geolocation::clearWatch): + (WebCore::Geolocation::handleError): + (WebCore::Geolocation::positionChanged): + (WebCore::Geolocation::makeSuccessCallbacks): + (WebCore::Geolocation::errorOccurred): + (WebCore::Geolocation::geolocationServicePositionChanged): + (WebCore::Geolocation::geolocationServiceErrorOccurred): + (WebCore::Geolocation::startUpdating): + (WebCore::Geolocation::stopUpdating): + * page/Geolocation.h: + * page/GeolocationController.cpp: Added. + (WebCore::GeolocationController::GeolocationController): + (WebCore::GeolocationController::~GeolocationController): + (WebCore::GeolocationController::addObserver): + (WebCore::GeolocationController::removeObserver): + (WebCore::GeolocationController::positionChanged): + (WebCore::GeolocationController::errorOccurred): + (WebCore::GeolocationController::lastPosition): + * page/GeolocationController.h: Added. + * page/GeolocationControllerClient.h: Added. + (WebCore::GeolocationControllerClient::~GeolocationControllerClient): + * page/GeolocationError.h: Added. + (WebCore::GeolocationError::): + (WebCore::GeolocationError::create): + (WebCore::GeolocationError::code): + (WebCore::GeolocationError::message): + * page/GeolocationPosition.h: Added. + (WebCore::GeolocationPosition::create): + (WebCore::GeolocationPosition::timestamp): + (WebCore::GeolocationPosition::latitude): + (WebCore::GeolocationPosition::longitude): + (WebCore::GeolocationPosition::accuracy): + (WebCore::GeolocationPosition::altitude): + (WebCore::GeolocationPosition::altitudeAccuracy): + (WebCore::GeolocationPosition::heading): + (WebCore::GeolocationPosition::speed): + (WebCore::GeolocationPosition::canProvideAltitude): + (WebCore::GeolocationPosition::canProvideAltitudeAccuracy): + (WebCore::GeolocationPosition::canProvideHeading): + (WebCore::GeolocationPosition::canProvideSpeed): + (WebCore::GeolocationPosition::GeolocationPosition): + * page/Geoposition.h: + (WebCore::Geoposition::create): + * page/Page.cpp: + (WebCore::Page::Page): + * page/Page.h: + (WebCore::Page::geolocationController): + * svg/graphics/SVGImage.cpp: + (WebCore::SVGImage::dataChanged): + 2009-12-10 Alexey Proskuryakov <ap@apple.com> Reviewed by Darin Adler. diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am index d3a9003..a04c123 100644 --- a/WebCore/GNUmakefile.am +++ b/WebCore/GNUmakefile.am @@ -1348,6 +1348,11 @@ webcore_sources += \ WebCore/page/FrameView.h \ WebCore/page/Geolocation.cpp \ WebCore/page/Geolocation.h \ + WebCore/page/GeolocationController.cpp \ + WebCore/page/GeolocationController.h \ + WebCore/page/GeolocationControllerClient.h \ + WebCore/page/GeolocationError.h \ + WebCore/page/GeolocationPosition.h \ WebCore/page/Geoposition.h \ WebCore/page/HaltablePlugin.h \ WebCore/page/History.cpp \ diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp index 8df5524..c29629a 100644 --- a/WebCore/WebCore.base.exp +++ b/WebCore/WebCore.base.exp @@ -292,6 +292,7 @@ __ZN7WebCore14ResourceHandle12releaseProxyEv __ZN7WebCore14ResourceHandle20forceContentSniffingEv __ZN7WebCore14ResourceLoader14cancelledErrorEv __ZN7WebCore14ResourceLoader19setShouldBufferDataEb +__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE __ZN7WebCore14SecurityOrigin16createFromStringERKNS_6StringE __ZN7WebCore14SecurityOrigin18setLocalLoadPolicyENS0_15LocalLoadPolicyE __ZN7WebCore14SecurityOrigin18shouldHideReferrerERKNS_4KURLERKNS_6StringE @@ -414,6 +415,7 @@ __ZN7WebCore21JavaScriptDebugServer23recompileAllJSFunctionsEPNS_5TimerIS0_EE __ZN7WebCore21JavaScriptDebugServer6sharedEv __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb __ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent +__ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKNS_6StringEPNS_14SVGSMILElementEd __ZN7WebCore21SerializedScriptValue11deserializeEPK15OpaqueJSContextPPK13OpaqueJSValue __ZN7WebCore21SerializedScriptValue6createEPK15OpaqueJSContextPK13OpaqueJSValuePS6_ __ZN7WebCore21SerializedScriptValueD1Ev @@ -495,7 +497,7 @@ __ZN7WebCore4Page6goBackEv __ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE __ZN7WebCore4Page9goForwardEv __ZN7WebCore4Page9initGroupEv -__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientEPNS_18PluginHalterClientE +__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientEPNS_18PluginHalterClientEPNS_27GeolocationControllerClientE __ZN7WebCore4PageD1Ev __ZN7WebCore4coreEP20NSURLProtectionSpace __ZN7WebCore5Cache11setDisabledEb @@ -601,8 +603,10 @@ __ZN7WebCore7cookiesEPKNS_8DocumentERKNS_4KURLE __ZN7WebCore7nsColorERKNS_5ColorE __ZN7WebCore8Document11createRangeEv __ZN7WebCore8Document13removeMarkersENS_14DocumentMarker10MarkerTypeE +__ZN7WebCore8Document13svgExtensionsEv __ZN7WebCore8Document14setFocusedNodeEN3WTF10PassRefPtrINS_4NodeEEE __ZN7WebCore8Document17getFocusableNodesERN3WTF6VectorINS1_6RefPtrINS_4NodeEEELm0EEE +__ZN7WebCore8Document19accessSVGExtensionsEv __ZN7WebCore8Document22createDocumentFragmentEv __ZN7WebCore8Document23renderedRectsForMarkersENS_14DocumentMarker10MarkerTypeE __ZN7WebCore8Document24setShouldCreateRenderersEb @@ -627,9 +631,9 @@ __ZN7WebCore8Settings20setCursiveFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings20setFantasyFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings20setJavaScriptEnabledEb __ZN7WebCore8Settings20setXSSAuditorEnabledEb +__ZN7WebCore8Settings21setShowRepaintCounterEb __ZN7WebCore8Settings21setStandardFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings21setWebSecurityEnabledEb -__ZN7WebCore8Settings21setShowRepaintCounterEb __ZN7WebCore8Settings22setLocalStorageEnabledEb __ZN7WebCore8Settings22setSansSerifFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings22setShowsURLsInToolTipsEb @@ -961,9 +965,9 @@ __ZNK7WebCore8Document31displayStringModifiedByEncodingERKNS_6StringE __ZNK7WebCore8Document4bodyEv __ZNK7WebCore8Document6domainEv __ZNK7WebCore8IntPointcv8_NSPointEv +__ZNK7WebCore8Position10downstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb __ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb -__ZNK7WebCore8Position10downstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore8Position8upstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore9DOMWindow27pendingUnloadEventListenersEv __ZNK7WebCore9FloatRectcv7_NSRectEv @@ -982,10 +986,6 @@ __ZTVN7WebCore12ChromeClientE __ZTVN7WebCore17FileChooserClientE __ZTVN7WebCore17FrameLoaderClientE __ZTVN7WebCore25HistoryPropertyListWriterE -__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE -__ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKNS_6StringEPNS_14SVGSMILElementEd -__ZN7WebCore8Document19accessSVGExtensionsEv -__ZN7WebCore8Document13svgExtensionsEv _filenameByFixingIllegalCharacters _hasCaseInsensitiveSubstring _hasCaseInsensitiveSuffix diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi index 4a37c79..0115a41 100644 --- a/WebCore/WebCore.gypi +++ b/WebCore/WebCore.gypi @@ -1785,6 +1785,11 @@ 'page/FrameView.h', 'page/Geolocation.cpp', 'page/Geolocation.h', + 'page/GeolocationController.cpp' + 'page/GeolocationController.h' + 'page/GeolocationControllerClient.h' + 'page/GeolocationError.h' + 'page/GeolocationPosition.h' 'page/Geoposition.h', 'page/HaltablePlugin.h', 'page/History.cpp', diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro index bfeee61..474c143 100644 --- a/WebCore/WebCore.pro +++ b/WebCore/WebCore.pro @@ -1160,6 +1160,7 @@ SOURCES += \ page/FrameTree.cpp \ page/FrameView.cpp \ page/Geolocation.cpp \ + page/GeolocationController.cpp \ page/History.cpp \ page/Location.cpp \ page/MouseEventWithHitTestResults.cpp \ diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj index 09945f5..db19ea3 100644 --- a/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/WebCore/WebCore.vcproj/WebCore.vcproj @@ -20645,6 +20645,26 @@ <File
RelativePath="..\page\Geolocation.cpp"
>
+ RelativePath="..\page\GeolocationController.cpp" + > + </File> + <File + RelativePath="..\page\GeolocationController.h" + > + </File> + <File + RelativePath="..\page\GeolocationControllerClient.h" + > + </File> + <File + RelativePath="..\page\GeolocationError.h" + > + </File> + <File + RelativePath="..\page\GeolocationPosition.h" + > + </File> + <File </File>
<File
RelativePath="..\page\Geolocation.h"
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj index 5c9981f..3635ae7 100644 --- a/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/WebCore/WebCore.xcodeproj/project.pbxproj @@ -4189,6 +4189,11 @@ BC53C6080DA56C570021EB5D /* Gradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53C6070DA56C570021EB5D /* Gradient.cpp */; }; BC53C60B0DA56CF10021EB5D /* GradientCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53C60A0DA56CF10021EB5D /* GradientCG.cpp */; }; BC53C6920DA591140021EB5D /* CSSGradientValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53C6910DA591140021EB5D /* CSSGradientValue.h */; }; + BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */; }; + BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */; }; + BC56CB2310D5AC8000A77C64 /* GeolocationControllerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */; }; + BC56CB2410D5AC8000A77C64 /* GeolocationError.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */; }; + BC56CB2510D5AC8000A77C64 /* GeolocationPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */; }; BC5823F50C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */; }; BC5825F30C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */; }; BC588AF00BFA6CF900EE679E /* HTMLParserErrorCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */; }; @@ -9356,6 +9361,11 @@ BC53C6070DA56C570021EB5D /* Gradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gradient.cpp; sourceTree = "<group>"; }; BC53C60A0DA56CF10021EB5D /* GradientCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GradientCG.cpp; sourceTree = "<group>"; }; BC53C6910DA591140021EB5D /* CSSGradientValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGradientValue.h; sourceTree = "<group>"; }; + BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationController.cpp; sourceTree = "<group>"; }; + BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationController.h; sourceTree = "<group>"; }; + BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationControllerClient.h; sourceTree = "<group>"; }; + BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationError.h; sourceTree = "<group>"; }; + BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationPosition.h; sourceTree = "<group>"; }; BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElementCustom.cpp; sourceTree = "<group>"; }; BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleDeclarationCustom.cpp; sourceTree = "<group>"; }; BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLParserErrorCodes.h; sourceTree = "<group>"; }; @@ -11275,6 +11285,11 @@ FE80D7B70E9C1F25000D6F75 /* Geolocation.cpp */, FE80D7B80E9C1F25000D6F75 /* Geolocation.h */, FE80D7B90E9C1F25000D6F75 /* Geolocation.idl */, + BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */, + BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */, + BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */, + BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */, + BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */, FE80D7BB0E9C1F25000D6F75 /* Geoposition.h */, FE80D7BC0E9C1F25000D6F75 /* Geoposition.idl */, 7693BACE106C2DCA007B0823 /* HaltablePlugin.h */, @@ -18244,6 +18259,10 @@ 7ADE722610CBBB9B006B3B3A /* ContextMenuSelectionHandler.h in Headers */, 0C3F1F5B10C8871200D72CE1 /* WebGLUniformLocation.h in Headers */, 0C45342810CDBBFA00869157 /* JSWebGLUniformLocation.h in Headers */, + BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */, + BC56CB2310D5AC8000A77C64 /* GeolocationControllerClient.h in Headers */, + BC56CB2410D5AC8000A77C64 /* GeolocationError.h in Headers */, + BC56CB2510D5AC8000A77C64 /* GeolocationPosition.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -20401,6 +20420,7 @@ 599D1E3210C97D6E00E0EF12 /* jni_utility_private.cpp in Sources */, 0C3F1F5A10C8871200D72CE1 /* WebGLUniformLocation.cpp in Sources */, 0C45342710CDBBFA00869157 /* JSWebGLUniformLocation.cpp in Sources */, + BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WebCore/WebCoreSources.bkl b/WebCore/WebCoreSources.bkl index cd94ae6..d44e593 100644 --- a/WebCore/WebCoreSources.bkl +++ b/WebCore/WebCoreSources.bkl @@ -777,6 +777,7 @@ This file contains the list of files needed to build WebCore. page/FrameTree.cpp page/FrameView.cpp page/Geolocation.cpp + page/GeolocationController.cpp page/History.cpp page/Location.cpp page/MouseEventWithHitTestResults.cpp diff --git a/WebCore/bindings/v8/ChildThreadDOMData.h b/WebCore/bindings/v8/ChildThreadDOMData.h index 173a5e8..dfb85e8 100644 --- a/WebCore/bindings/v8/ChildThreadDOMData.h +++ b/WebCore/bindings/v8/ChildThreadDOMData.h @@ -39,9 +39,6 @@ namespace WebCore { class ChildThreadDOMData : public DOMData { public: ChildThreadDOMData(); -#if PLATFORM(ANDROID) - virtual ~ChildThreadDOMData() { } -#endif DOMDataStore& getStore(); diff --git a/WebCore/bindings/v8/DOMData.cpp b/WebCore/bindings/v8/DOMData.cpp index 54bcc55..ec9a938 100644 --- a/WebCore/bindings/v8/DOMData.cpp +++ b/WebCore/bindings/v8/DOMData.cpp @@ -44,6 +44,10 @@ DOMData::DOMData() { } +DOMData::~DOMData() +{ +} + DOMData* DOMData::getCurrent() { if (WTF::isMainThread()) diff --git a/WebCore/bindings/v8/DOMData.h b/WebCore/bindings/v8/DOMData.h index 7bf9f91..4947e82 100644 --- a/WebCore/bindings/v8/DOMData.h +++ b/WebCore/bindings/v8/DOMData.h @@ -45,9 +45,7 @@ namespace WebCore { class DOMData : public Noncopyable { public: DOMData(); -#if PLATFORM(ANDROID) - virtual ~DOMData() { } -#endif + virtual ~DOMData(); static DOMData* getCurrent(); virtual DOMDataStore& getStore() = 0; diff --git a/WebCore/bindings/v8/DOMObjectsInclude.h b/WebCore/bindings/v8/DOMObjectsInclude.h index 6ed14be..bded7f2 100644 --- a/WebCore/bindings/v8/DOMObjectsInclude.h +++ b/WebCore/bindings/v8/DOMObjectsInclude.h @@ -229,6 +229,7 @@ #endif // SVG #if PLATFORM(ANDROID) +#include "Connection.h" // TODO: Upstream TOUCH_EVENTS guard. #if ENABLE(TOUCH_EVENTS) #include "Touch.h" diff --git a/WebCore/bindings/v8/V8GCController.cpp b/WebCore/bindings/v8/V8GCController.cpp index e08cf66..b478636 100644 --- a/WebCore/bindings/v8/V8GCController.cpp +++ b/WebCore/bindings/v8/V8GCController.cpp @@ -239,16 +239,6 @@ bool operator<(const GrouperItem& a, const GrouperItem& b) typedef Vector<GrouperItem> GrouperList; -#if PLATFORM(ANDROID) -// Android's implementation of std::sort seems unable to do the necessary -// template matching to pick up operator< for GrouperItem, so we have to -// manually pass a comparison function. -static bool compareGrouperItem(const GrouperItem& a, const GrouperItem& b) -{ - return a < b; -} -#endif - class ObjectGrouperVisitor : public DOMWrapperMap<Node>::Visitor { public: ObjectGrouperVisitor() @@ -295,11 +285,7 @@ public: void applyGrouping() { // Group by sorting by the group id. -#if PLATFORM(ANDROID) - std::sort(m_grouper.begin(), m_grouper.end(), compareGrouperItem); -#else std::sort(m_grouper.begin(), m_grouper.end()); -#endif // FIXME Should probably work in iterators here, but indexes were easier for my simple mind. for (size_t i = 0; i < m_grouper.size(); ) { diff --git a/WebCore/bindings/v8/V8Index.cpp b/WebCore/bindings/v8/V8Index.cpp index 9686dc6..ea13d2f 100644 --- a/WebCore/bindings/v8/V8Index.cpp +++ b/WebCore/bindings/v8/V8Index.cpp @@ -447,6 +447,7 @@ #include "V8PositionError.h" #if PLATFORM(ANDROID) +#include "V8Connection.h" // TODO: Upstream these guards to webkit.org #if ENABLE(TOUCH_EVENTS) #include "V8Touch.h" diff --git a/WebCore/bindings/v8/V8Index.h b/WebCore/bindings/v8/V8Index.h index d786aab..a3aebdf 100644 --- a/WebCore/bindings/v8/V8Index.h +++ b/WebCore/bindings/v8/V8Index.h @@ -512,6 +512,8 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); #else #define DOM_OBJECT_TOUCH_EVENT_TYPES(V) #endif +#define DOM_OBJECT_CONNECTION_TYPES(V) \ + V(CONNECTION, Connection) #endif #if PLATFORM(ANDROID) @@ -535,6 +537,7 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); DOM_OBJECT_INSPECTOR_TYPES(V) \ DOM_OBJECT_GEOLOCATION_TYPES(V) \ DOM_OBJECT_TOUCH_EVENT_TYPES(V) \ + DOM_OBJECT_CONNECTION_TYPES(V) \ DOM_OBJECT_VOIDCALLBACK_TYPES(V) #endif diff --git a/WebCore/config.h b/WebCore/config.h index 8fbed4f..6fa1f40 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -80,7 +80,6 @@ #define WEBCORE_NAVIGATOR_VENDOR "Google Inc." // This must be defined before we include FastMalloc.h, below. #define USE_SYSTEM_MALLOC 1 -#define ANDROID_MOBILE // change can be merged back to WebKit.org for MOBILE #define LOG_DISABLED 1 #include <wtf/Assertions.h> // Central place to set which optional features Android uses. diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 85966d7..69b326a 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -371,9 +371,6 @@ Document::Document(Frame* frame, bool isXHTML) , m_hasOpenDatabases(false) #endif , m_usingGeolocation(false) -#ifdef ANDROID_MOBILE - , mExtraLayoutDelay(0) -#endif #if ENABLE(WML) , m_containsWMLContent(false) #endif @@ -431,6 +428,7 @@ Document::Document(Frame* frame, bool isXHTML) m_processingLoadEvent = false; m_startTime = currentTime(); m_overMinimumLayoutThreshold = false; + m_extraLayoutDelay = 0; initSecurityContext(); initDNSPrefetch(); @@ -1880,13 +1878,13 @@ bool Document::shouldScheduleLayout() int Document::minimumLayoutDelay() { if (m_overMinimumLayoutThreshold) - return 0; + return m_extraLayoutDelay; int elapsed = elapsedTime(); m_overMinimumLayoutThreshold = elapsed > cLayoutScheduleThreshold; // We'll want to schedule the timer to fire at the minimum layout threshold. - return max(0, cLayoutScheduleThreshold - elapsed); + return max(0, cLayoutScheduleThreshold - elapsed) + m_extraLayoutDelay; } int Document::elapsedTime() const @@ -2259,7 +2257,8 @@ void Document::processMetadataSettings(const String& content) String key(buffer.substring(keyBegin, keyEnd - keyBegin)); String value(buffer.substring(valueBegin, valueEnd - valueBegin)); - frame()->settings()->setMetadataSettings(key, value); + if (frame()) + frame()->settings()->setMetadataSettings(key, value); } } #endif diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index 3d0582c..f2125b1 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -523,6 +523,10 @@ public: void setParsing(bool); bool parsing() const { return m_bParsing; } int minimumLayoutDelay(); + + // This method is used by Android. + void setExtraLayoutDelay(int delay) { m_extraLayoutDelay = delay; } + bool shouldScheduleLayout(); int elapsedTime() const; @@ -815,11 +819,6 @@ public: void updateFocusAppearanceSoon(); void cancelFocusAppearanceUpdate(); -#ifdef ANDROID_MOBILE - void setExtraLayoutDelay(int delay) { mExtraLayoutDelay = delay; } - int extraLayoutDelay() { return mExtraLayoutDelay; } -#endif - // FF method for accessing the selection added for compatability. DOMSelection* getSelection() const; @@ -1091,9 +1090,11 @@ private: typedef std::pair<Vector<DocumentMarker>, Vector<IntRect> > MarkerMapVectorPair; typedef HashMap<RefPtr<Node>, MarkerMapVectorPair*> MarkerMap; MarkerMap m_markers; + #if !PLATFORM(ANDROID) mutable AXObjectCache* m_axObjectCache; #endif + Timer<Document> m_updateFocusAppearanceTimer; Element* m_cssTarget; @@ -1103,6 +1104,10 @@ private: HashSet<RefPtr<HistoryItem> > m_associatedHistoryItems; double m_startTime; bool m_overMinimumLayoutThreshold; + // This is used to increase the minimum delay between re-layouts. It is set + // using setExtraLayoutDelay to modify the minimum delay used at different + // points during the lifetime of the Document. + int m_extraLayoutDelay; Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon; Timer<Document> m_executeScriptSoonTimer; @@ -1195,10 +1200,6 @@ private: bool m_usingGeolocation; -#ifdef ANDROID_MOBILE - int mExtraLayoutDelay; -#endif - #if ENABLE(WML) bool m_containsWMLContent; #endif diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp index 163424d..acfe51f 100644 --- a/WebCore/html/HTMLInputElement.cpp +++ b/WebCore/html/HTMLInputElement.cpp @@ -340,11 +340,11 @@ bool HTMLInputElement::stepMismatch() const // double's fractional part size is DBL_MAN_DIG-bit. If the current // value is greater than step*2^DBL_MANT_DIG, the following fmod() makes // no sense. - if (doubleValue / pow(2, DBL_MANT_DIG) > step) + if (doubleValue / pow(2.0, DBL_MANT_DIG) > step) return false; double remainder = fmod(doubleValue, step); // Accepts errors in lower 7-bit. - double acceptableError = step / pow(2, DBL_MANT_DIG - 7); + double acceptableError = step / pow(2.0, DBL_MANT_DIG - 7); return acceptableError < remainder && remainder < (step - acceptableError); } // Non-RANGE types should be rejected by getAllowedValueStep(). diff --git a/WebCore/html/HTMLTextAreaElement.cpp b/WebCore/html/HTMLTextAreaElement.cpp index 8d8208d..0e8350c 100644 --- a/WebCore/html/HTMLTextAreaElement.cpp +++ b/WebCore/html/HTMLTextAreaElement.cpp @@ -95,7 +95,7 @@ bool HTMLTextAreaElement::saveFormControlState(String& result) const void HTMLTextAreaElement::restoreFormControlState(const String& state) { - setDefaultValue(state); + setValue(state); } void HTMLTextAreaElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) diff --git a/WebCore/html/HTMLTokenizer.cpp b/WebCore/html/HTMLTokenizer.cpp index 3ca6958..a552442 100644 --- a/WebCore/html/HTMLTokenizer.cpp +++ b/WebCore/html/HTMLTokenizer.cpp @@ -1849,11 +1849,7 @@ void HTMLTokenizer::timerFired(Timer<HTMLTokenizer>*) printf("Beginning timer write at time %d\n", m_doc->elapsedTime()); #endif -#ifdef ANDROID_MOBILE - if (m_doc->view() && m_doc->view()->layoutPending() && !m_doc->minimumLayoutDelay() && !m_doc->extraLayoutDelay()) { -#else if (m_doc->view() && m_doc->view()->layoutPending() && !m_doc->minimumLayoutDelay()) { -#endif // Restart the timer and let layout win. This is basically a way of ensuring that the layout // timer has higher priority than our timer. m_timer.startOneShot(0); diff --git a/WebCore/loader/CachedImage.cpp b/WebCore/loader/CachedImage.cpp index a91f126..780d7ee 100644 --- a/WebCore/loader/CachedImage.cpp +++ b/WebCore/loader/CachedImage.cpp @@ -252,7 +252,7 @@ inline void CachedImage::createImage() } #endif m_image = BitmapImage::create(this); -#if PLATFORM(SGL) +#if PLATFORM(ANDROID) m_image->setURL(url()); #endif } diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 4a6ca3d..e07ee92 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -1743,12 +1743,7 @@ void FrameLoader::setFirstPartyForCookies(const KURL& url) // This does the same kind of work that didOpenURL does, except it relies on the fact // that a higher level already checked that the URLs match and the scrolling is the right thing to do. -#if PLATFORM(ANDROID) -// TODO: Upstream to webkit.org -void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* stateObject, bool isNewNavigation, bool suppressAddToHistory) -#else void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* stateObject, bool isNewNavigation) -#endif { // If we have a state object, we cannot also be a new navigation. ASSERT(!stateObject || (stateObject && !isNewNavigation)); @@ -1756,12 +1751,7 @@ void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* sta // Update the data source's request with the new URL to fake the URL change m_frame->document()->setURL(url); documentLoader()->replaceRequestURLForSameDocumentNavigation(url); -#if PLATFORM(ANDROID) - // TODO: Upstream to webkit.org - if (isNewNavigation && !shouldTreatURLAsSameAsCurrent(url) && !stateObject && !suppressAddToHistory) { -#else if (isNewNavigation && !shouldTreatURLAsSameAsCurrent(url) && !stateObject) { -#endif // NB: must happen after replaceRequestURLForSameDocumentNavigation(), since we add // based on the current request. Must also happen before we openURL and displace the // scroll position, since adding the BF item will save away scroll state. @@ -3478,14 +3468,7 @@ void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequ return; bool isRedirect = m_quickRedirectComing || policyChecker()->loadType() == FrameLoadTypeRedirectWithLockedBackForwardList; -#ifdef ANDROID_USER_GESTURE - // Do not add history items for a fragment scroll not initiated by the - // user. http://bugs.webkit.org/show_bug.cgi?id=30224 - bool isUserInitiated = isProcessingUserGesture() || request.getUserGesture(); - loadInSameDocument(request.url(), 0, !isRedirect, !isUserInitiated); -#else loadInSameDocument(request.url(), 0, !isRedirect); -#endif } bool FrameLoader::shouldScrollToAnchor(bool isFormSubmission, FrameLoadType loadType, const KURL& url) @@ -3773,12 +3756,7 @@ void FrameLoader::navigateWithinDocument(HistoryItem* item) history()->setCurrentItem(item); // loadInSameDocument() actually changes the URL and notifies load delegates of a "fake" load -#if PLATFORM(ANDROID) - // TODO: Upstream to webkit.org - loadInSameDocument(item->url(), item->stateObject(), false, false); -#else loadInSameDocument(item->url(), item->stateObject(), false); -#endif // Restore user view state from the current history item here since we don't do a normal load. // Even though we just manually set the current history item, this ASSERT verifies nothing diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h index 03a1175..875736f 100644 --- a/WebCore/loader/FrameLoader.h +++ b/WebCore/loader/FrameLoader.h @@ -439,12 +439,7 @@ private: Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer); -#if PLATFORM(ANDROID) - // TODO: Upstream to webkit.org - void loadInSameDocument(const KURL&, SerializedScriptValue* stateObject, bool isNewNavigation, bool suppressAddToHistory); -#else void loadInSameDocument(const KURL&, SerializedScriptValue* stateObject, bool isNewNavigation); -#endif void provisionalLoadStarted(); diff --git a/WebCore/platform/network/android/Cookie.cpp b/WebCore/page/Connection.cpp index 3d10e4a..ffbb838 100644 --- a/WebCore/platform/network/android/Cookie.cpp +++ b/WebCore/page/Connection.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007, The Android Open Source Project + * Copyright 2010, The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,33 +25,15 @@ #include "config.h" -#include "CookieClient.h" -#include "JavaSharedClient.h" +#include "Connection.h" -using namespace android; +#include "NetworkStateNotifier.h" namespace WebCore { -class Document; - -void setCookies(Document*, const KURL& url, const String& value) -{ - if (JavaSharedClient::GetCookieClient()) - JavaSharedClient::GetCookieClient()->setCookies(url, value); -} - -String cookies(const Document* , const KURL& url) +Connection::ConnectionType Connection::type() const { - if (JavaSharedClient::GetCookieClient()) - return JavaSharedClient::GetCookieClient()->cookies(url); - return String(); + return networkStateNotifier().type(); } -bool cookiesEnabled(const Document* ) -{ - if (JavaSharedClient::GetCookieClient()) - return JavaSharedClient::GetCookieClient()->cookiesEnabled(); - return false; -} - -} +};
\ No newline at end of file diff --git a/WebCore/page/Connection.h b/WebCore/page/Connection.h new file mode 100644 index 0000000..837a36f --- /dev/null +++ b/WebCore/page/Connection.h @@ -0,0 +1,54 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR 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 Connection_h +#define Connection_h + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Connection : public RefCounted<Connection> { +public: + enum ConnectionType { + Unknown = 0, + Ethernet = 1, + WiFi = 2, + Cell_2G = 3, + Cell_3G = 4, + }; + + static PassRefPtr<Connection> create() { return adoptRef(new Connection()); } + + ConnectionType type() const; + +private: + Connection() { } +}; + +} // namespace WebCore + +#endif // Connection_h diff --git a/WebCore/page/Connection.idl b/WebCore/page/Connection.idl new file mode 100644 index 0000000..b4cfbd1 --- /dev/null +++ b/WebCore/page/Connection.idl @@ -0,0 +1,38 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR 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. + */ + + module core { + + interface Connection { + readonly attribute unsigned short type; + + const unsigned short UNKNOWN = 0; + const unsigned short ETHERNET = 1; + const unsigned short WIFI = 2; + const unsigned short CELL_2G = 3; + const unsigned short CELL_3G = 4; + }; + +} diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp index b338017..b533bad 100644 --- a/WebCore/page/FrameView.cpp +++ b/WebCore/page/FrameView.cpp @@ -1151,11 +1151,7 @@ void FrameView::scheduleRelayout() m_frame->ownerRenderer()->setNeedsLayoutAndPrefWidthsRecalc(); #endif -#ifdef ANDROID_MOBILE - int delay = m_frame->document()->minimumLayoutDelay() + m_frame->document()->extraLayoutDelay(); -#else int delay = m_frame->document()->minimumLayoutDelay(); -#endif if (m_layoutTimer.isActive() && m_delayedLayout && !delay) unscheduleRelayout(); if (m_layoutTimer.isActive()) @@ -1209,11 +1205,7 @@ void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot) } } } else { -#ifdef ANDROID_MOBILE - int delay = m_frame->document()->minimumLayoutDelay() + m_frame->document()->extraLayoutDelay(); -#else int delay = m_frame->document()->minimumLayoutDelay(); -#endif m_layoutRoot = relayoutRoot; m_delayedLayout = delay != 0; m_layoutTimer.startOneShot(delay * 0.001); diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index 5fbad47..f0578a8 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -39,10 +39,45 @@ #include "SQLValue.h" #include <wtf/CurrentTime.h> +#if ENABLE(CLIENT_BASED_GEOLOCATION) +#include "Coordinates.h" +#include "GeolocationController.h" +#include "GeolocationError.h" +#include "GeolocationPosition.h" +#include "Geoposition.h" +#include "PositionError.h" +#endif + namespace WebCore { static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +static PassRefPtr<Geoposition> createGeoposition(GeolocationPosition* position) +{ + RefPtr<Coordinates> coordinates = Coordinates::create(position->latitude(), position->longitude(), position->canProvideAltitude(), position->altitude(), + position->accuracy(), position->canProvideAltitudeAccuracy(), position->altitudeAccuracy(), + position->canProvideHeading(), position->heading(), position->canProvideSpeed(), position->speed()); + return Geoposition::create(coordinates.release(), position->timestamp()); +} + +static PassRefPtr<PositionError> createPositionError(GeolocationError* error) +{ + PositionError::ErrorCode code = PositionError::POSITION_UNAVAILABLE; + switch (error->code()) { + case GeolocationError::PermissionDenied: + code = PositionError::PERMISSION_DENIED; + break; + case GeolocationError::PositionUnavailable: + code = PositionError::POSITION_UNAVAILABLE; + break; + } + + return PositionError::create(code, error->message()); +} +#endif + Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) : m_geolocation(geolocation) , m_successCallback(successCallback) @@ -305,7 +340,9 @@ String* CachedPositionManager::s_databaseFile = 0; Geolocation::Geolocation(Frame* frame) : EventListener(GeolocationEventListenerType) , m_frame(frame) +#if !ENABLE(CLIENT_BASED_GEOLOCATION) , m_service(GeolocationService::create(this)) +#endif , m_allowGeolocation(Unknown) , m_shouldClearCache(false) , m_cachedPositionManager(new CachedPositionManager) @@ -327,7 +364,7 @@ Geolocation::~Geolocation() void Geolocation::disconnectFrame() { - m_service->stopUpdating(); + stopUpdating(); if (m_frame && m_frame->document()) m_frame->document()->setUsingGeolocation(false); m_frame = 0; @@ -335,6 +372,24 @@ void Geolocation::disconnectFrame() delete m_cachedPositionManager; } +Geoposition* Geolocation::lastPosition() +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + if (!m_frame) + return 0; + + Page* page = m_frame->page(); + if (!page) + return 0; + + m_lastPosition = createGeoposition(page->geolocationController()->lastPosition()); +#else + m_lastPosition = m_service->lastPosition(); +#endif + + return m_lastPosition.get(); +} + void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options); @@ -391,7 +446,7 @@ void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier) m_watchers.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestTimedOut(GeoNotifier* notifier) @@ -400,7 +455,7 @@ void Geolocation::requestTimedOut(GeoNotifier* notifier) m_oneShots.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestReturnedCachedPosition(GeoNotifier* notifier) @@ -408,11 +463,11 @@ void Geolocation::requestReturnedCachedPosition(GeoNotifier* notifier) // If this is a one-shot request, stop it. m_oneShots.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); // Otherwise, if the watch still exists, start the service to get updates. if (m_watchers.contains(notifier)) { - if (notifier->hasZeroTimeout() || m_service->startUpdating(notifier->m_options.get())) + if (notifier->hasZeroTimeout() || startUpdating(notifier->m_options.get())) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, "Failed to start Geolocation service")); @@ -436,7 +491,7 @@ void Geolocation::clearWatch(int watchId) m_watchers.remove(watchId); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::suspend() @@ -497,7 +552,6 @@ void Geolocation::sendPosition(Vector<RefPtr<GeoNotifier> >& notifiers, Geoposit RefPtr<GeoNotifier> notifier = *it; ASSERT(notifier->m_successCallback); - notifier->m_timer.stop(); notifier->m_successCallback->handleEvent(position); } } @@ -554,7 +608,7 @@ void Geolocation::handleError(PositionError* error) sendError(watchersCopy, error); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestPermission() @@ -575,12 +629,11 @@ void Geolocation::requestPermission() page->chrome()->requestGeolocationPermissionForFrame(m_frame, this); } -void Geolocation::geolocationServicePositionChanged(GeolocationService* service) +void Geolocation::positionChanged(PassRefPtr<Geoposition> newPosition) { - ASSERT_UNUSED(service, service == m_service); - ASSERT(m_service->lastPosition()); + m_currentPosition = newPosition; - m_cachedPositionManager->setCachedPosition(m_service->lastPosition()); + m_cachedPositionManager->setCachedPosition(m_currentPosition.get()); // Stop all currently running timers. stopTimers(); @@ -599,7 +652,7 @@ void Geolocation::geolocationServicePositionChanged(GeolocationService* service) void Geolocation::makeSuccessCallbacks() { - ASSERT(m_service->lastPosition()); + ASSERT(m_currentPosition); ASSERT(isAllowed()); Vector<RefPtr<GeoNotifier> > oneShotsCopy; @@ -613,23 +666,85 @@ void Geolocation::makeSuccessCallbacks() // further callbacks to these notifiers. m_oneShots.clear(); - sendPosition(oneShotsCopy, m_service->lastPosition()); - sendPosition(watchersCopy, m_service->lastPosition()); + sendPosition(oneShotsCopy, m_currentPosition.get()); + sendPosition(watchersCopy, m_currentPosition.get()); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); +} + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +void Geolocation::setPosition(GeolocationPosition* position) +{ + positionChanged(createGeoposition(position)); +} + +void Geolocation::setError(GeolocationError* error) +{ + RefPtr<PositionError> positionError = createPositionError(error); + handleError(positionError.get()); +} + +#else + +void Geolocation::geolocationServicePositionChanged(GeolocationService* service) +{ + ASSERT_UNUSED(service, service == m_service); + ASSERT(m_service->lastPosition()); + + positionChanged(m_service->lastPosition()); } void Geolocation::geolocationServiceErrorOccurred(GeolocationService* service) { ASSERT(service->lastError()); - + // Note that we do not stop timers here. For one-shots, the request is // cleared in handleError. For watchers, the spec requires that the timer is // not cleared. handleError(service->lastError()); } +#endif + +bool Geolocation::startUpdating(PositionOptions* options) +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + // FIXME: Pass options to client. + UNUSED_PARAM(options); + + if (!m_frame) + return false; + + Page* page = m_frame->page(); + if (!page) + return false; + + page->geolocationController()->addObserver(this); + return true; +#else + return m_service->startUpdating(options); +#endif +} + +void Geolocation::stopUpdating() +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + if (!m_frame) + return; + + Page* page = m_frame->page(); + if (!page) + return; + + page->geolocationController()->removeObserver(this); +#else + m_service->stopUpdating(); +#endif + +} + bool Geolocation::operator==(const EventListener& listener) { if (listener.type() != GeolocationEventListenerType) diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index fd9d560..5b5feb5 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -48,8 +48,16 @@ namespace WebCore { class Frame; class CachedPositionManager; - -class Geolocation : public GeolocationServiceClient, public EventListener { +#if ENABLE(CLIENT_BASED_GEOLOCATION) +class GeolocationPosition; +class GeolocationError; +#endif + +class Geolocation : public EventListener +#if !ENABLE(CLIENT_BASED_GEOLOCATION) + , public GeolocationServiceClient +#endif +{ public: static PassRefPtr<Geolocation> create(Frame* frame) { return adoptRef(new Geolocation(frame)); } @@ -57,7 +65,7 @@ public: void disconnectFrame(); - Geoposition* lastPosition() const { return m_service->lastPosition(); } + Geoposition* lastPosition(); void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); @@ -73,6 +81,11 @@ public: void setShouldClearCache(bool shouldClearCache) { m_shouldClearCache = shouldClearCache; } bool shouldClearCache() const { return m_shouldClearCache; } +#if ENABLE(CLIENT_BASED_GEOLOCATION) + void setPostion(GeolocationPosition*); + void setError(GeolocationError*); +#endif + static void setDatabasePath(String); private: @@ -126,14 +139,20 @@ private: void stopTimersForWatchers(); void stopTimers(); + void positionChanged(PassRefPtr<Geoposition>); void makeSuccessCallbacks(); void handleError(PositionError*); void requestPermission(); + bool startUpdating(PositionOptions*); + void stopUpdating(); + +#if !ENABLE(CLIENT_BASED_GEOLOCATION) // GeolocationServiceClient virtual void geolocationServicePositionChanged(GeolocationService*); virtual void geolocationServiceErrorOccurred(GeolocationService*); +#endif PassRefPtr<GeoNotifier> startRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); @@ -151,7 +170,11 @@ private: GeoNotifierSet m_oneShots; Watchers m_watchers; Frame* m_frame; +#if !ENABLE(CLIENT_BASED_GEOLOCATION) OwnPtr<GeolocationService> m_service; +#endif + RefPtr<Geoposition> m_lastPosition; + RefPtr<Geoposition> m_currentPosition; enum { Unknown, diff --git a/WebCore/page/GeolocationController.cpp b/WebCore/page/GeolocationController.cpp new file mode 100644 index 0000000..44eba6e --- /dev/null +++ b/WebCore/page/GeolocationController.cpp @@ -0,0 +1,85 @@ +/* + * 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 "GeolocationController.h" + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "GeolocationControllerClient.h" + +namespace WebCore { + +GeolocationController::GeolocationController(Page* page, GeolocationControllerClient* client) + : m_page(page) + , m_client(client) +{ +} + +GeolocationController::~GeolocationController() +{ +} + +void GeolocationController::addObserver(Geolocation* observer) +{ + ASSERT(!m_observers.contains(observer)); + + bool wasEmpty = m_observers.isEmpty(); + m_observers.add(observer); + if (wasEmpty) + m_client->startUpdating(); +} + +void GeolocationController::removeObserver(Geolocation* observer) +{ + ASSERT(m_observers.contains(observer)); + + m_observers.remove(observer); + if (m_observers.isEmpty()) + m_client->stopUpdating(); +} + +void GeolocationController::positionChanged(GeolocationPosition* position) +{ + HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end(); + for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it) + (*it)->setPosition(position); +} + +void GeolocationController::errorOccurred(GeolocationError* error) +{ + HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end(); + for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it) + (*it)->setError(error); +} + +GeolocationPosition* GeolocationController::lastPosition() +{ + return m_client->lastPosition(); +} + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) diff --git a/WebCore/page/GeolocationController.h b/WebCore/page/GeolocationController.h new file mode 100644 index 0000000..80f9ca8 --- /dev/null +++ b/WebCore/page/GeolocationController.h @@ -0,0 +1,67 @@ +/* + * 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 GeolocationController_h +#define GeolocationController_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "Geolocation.h" +#include <wtf/HashSet.h> +#include <wtf/Noncopyable.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationControllerClient; +class GeolocationError; +class GeolocationPosition; +class Page; + +class GeolocationController : public Noncopyable { +public: + GeolocationController(Page*, GeolocationControllerClient*); + ~GeolocationController(); + + void addObserver(Geolocation*); + void removeObserver(Geolocation*); + + void positionChanged(GeolocationPosition*); + void errorOccurred(GeolocationError*); + + GeolocationPosition* lastPosition(); + +private: + Page* m_page; + GeolocationControllerClient* m_client; + + HashSet<RefPtr<Geolocation> > m_observers; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationController_h diff --git a/WebCore/page/GeolocationControllerClient.h b/WebCore/page/GeolocationControllerClient.h new file mode 100644 index 0000000..830c64b --- /dev/null +++ b/WebCore/page/GeolocationControllerClient.h @@ -0,0 +1,45 @@ +/* + * 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 GeolocationControllerClient_h +#define GeolocationControllerClient_h + +namespace WebCore { + +class GeolocationPosition; + +class GeolocationControllerClient { +public: + virtual void startUpdating() = 0; + virtual void stopUpdating() = 0; + virtual GeolocationPosition* lastPosition() = 0; + +protected: + virtual ~GeolocationControllerClient() { } +}; + +} // namespace WebCore + +#endif // GeolocationControllerClient_h diff --git a/WebCore/page/GeolocationError.h b/WebCore/page/GeolocationError.h new file mode 100644 index 0000000..9761ca6 --- /dev/null +++ b/WebCore/page/GeolocationError.h @@ -0,0 +1,60 @@ +/* + * 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 GeolocationError_h +#define GeolocationError_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationError : public RefCounted<GeolocationError> { +public: + enum ErrorCode { + PermissionDenied, + PositionUnavailable + }; + + static PassRefPtr<GeolocationError> create(ErrorCode code, const String& message) { return adoptRef(new GeolocationError(code, message)); } + + ErrorCode code() const { return m_code; } + const String& message() const { return m_message; } + +private: + GeolocationError(ErrorCode code, const String& message); + + ErrorCode m_code; + String m_message; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationError_h diff --git a/WebCore/page/GeolocationPosition.h b/WebCore/page/GeolocationPosition.h new file mode 100644 index 0000000..c31e9c4 --- /dev/null +++ b/WebCore/page/GeolocationPosition.h @@ -0,0 +1,110 @@ +/* + * 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 GeolocationPosition_h +#define GeolocationPosition_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationPosition : public RefCounted<GeolocationPosition> { +public: + static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy)); } + + static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed)); } + + double timestamp() const { return m_timestamp; } + + double latitude() const { return m_latitude; } + double longitude() const { return m_longitude; } + double accuracy() const { return m_accuracy; } + double altitude() const { return m_altitude; } + double altitudeAccuracy() const { return m_altitudeAccuracy; } + double heading() const { return m_heading; } + double speed() const { return m_speed; } + + bool canProvideAltitude() const { return m_canProvideAltitude; } + bool canProvideAltitudeAccuracy() const { return m_canProvideAltitudeAccuracy; } + bool canProvideHeading() const { return m_canProvideHeading; } + bool canProvideSpeed() const { return m_canProvideSpeed; } + +private: + GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy) + : m_timestamp(timestamp) + , m_latitude(latitude) + , m_longitude(longitude) + , m_accuracy(accuracy) + , m_altitude(0) + , m_altitudeAccuracy(0) + , m_heading(0) + , m_speed(0) + , m_canProvideAltitude(false) + , m_canProvideAltitudeAccuracy(false) + , m_canProvideHeading(false) + , m_canProvideSpeed(false) + { + } + + GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) + : m_timestamp(timestamp) + , m_latitude(latitude) + , m_longitude(longitude) + , m_accuracy(accuracy) + , m_altitude(altitude) + , m_altitudeAccuracy(altitudeAccuracy) + , m_heading(heading) + , m_speed(speed) + , m_canProvideAltitude(providesAltitude) + , m_canProvideAltitudeAccuracy(providesAltitudeAccuracy) + , m_canProvideHeading(providesHeading) + , m_canProvideSpeed(providesSpeed) + { + } + + double m_timestamp; + + double m_latitude; + double m_longitude; + double m_accuracy; + double m_altitude; + double m_altitudeAccuracy; + double m_heading; + double m_speed; + + bool m_canProvideAltitude; + bool m_canProvideAltitudeAccuracy; + bool m_canProvideHeading; + bool m_canProvideSpeed; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationPosition_h diff --git a/WebCore/page/Geoposition.h b/WebCore/page/Geoposition.h index f3c703b..8b215b1 100644 --- a/WebCore/page/Geoposition.h +++ b/WebCore/page/Geoposition.h @@ -37,8 +37,11 @@ typedef int ExceptionCode; class Geoposition : public RefCounted<Geoposition> { public: - static PassRefPtr<Geoposition> create(PassRefPtr<Coordinates> coordinates, DOMTimeStamp timestamp) { return adoptRef(new Geoposition(coordinates, timestamp)); } - + static PassRefPtr<Geoposition> create(PassRefPtr<Coordinates> coordinates, DOMTimeStamp timestamp) + { + return adoptRef(new Geoposition(coordinates, timestamp)); + } + DOMTimeStamp timestamp() const { return m_timestamp; } Coordinates* coords() const { return m_coordinates.get(); } diff --git a/WebCore/page/Navigator.cpp b/WebCore/page/Navigator.cpp index a4193fc..8563a0e 100644 --- a/WebCore/page/Navigator.cpp +++ b/WebCore/page/Navigator.cpp @@ -24,6 +24,9 @@ #include "Navigator.h" #include "CookieJar.h" +#if PLATFORM(ANDROID) +#include "Connection.h" +#endif #include "ExceptionCode.h" #include "Frame.h" #include "FrameLoader.h" @@ -155,6 +158,15 @@ Geolocation* Navigator::geolocation() const return m_geolocation.get(); } +#if PLATFORM(ANDROID) +Connection* Navigator::connection() const +{ + if (!m_connection) + m_connection = Connection::create(); + return m_connection.get(); +} +#endif + #if ENABLE(DOM_STORAGE) void Navigator::getStorageUpdates() { diff --git a/WebCore/page/Navigator.h b/WebCore/page/Navigator.h index 107082b..9967fba 100644 --- a/WebCore/page/Navigator.h +++ b/WebCore/page/Navigator.h @@ -27,6 +27,9 @@ namespace WebCore { +#if PLATFORM(ANDROID) + class Connection; +#endif class Frame; class Geolocation; class MimeTypeArray; @@ -57,6 +60,10 @@ namespace WebCore { // This is used for GC marking. Geolocation* optionalGeolocation() const { return m_geolocation.get(); } +#if PLATFORM(ANDROID) + Connection* connection() const; +#endif + #if ENABLE(DOM_STORAGE) // Relinquishes the storage lock, if one exists. void getStorageUpdates(); @@ -71,6 +78,9 @@ namespace WebCore { mutable RefPtr<PluginArray> m_plugins; mutable RefPtr<MimeTypeArray> m_mimeTypes; mutable RefPtr<Geolocation> m_geolocation; +#if PLATFORM(ANDROID) + mutable RefPtr<Connection> m_connection; +#endif }; } diff --git a/WebCore/page/Navigator.idl b/WebCore/page/Navigator.idl index 99b22af..f3079de 100644 --- a/WebCore/page/Navigator.idl +++ b/WebCore/page/Navigator.idl @@ -39,6 +39,9 @@ module window { readonly attribute boolean onLine; + // ANDROID-only for now, upstreaming in progress. + readonly attribute Connection connection; + #if defined(ENABLE_GEOLOCATION) && ENABLE_GEOLOCATION readonly attribute Geolocation geolocation; #endif diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index c4f33d6..1a035a5 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -77,6 +77,10 @@ #include "WMLPageState.h" #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) +#include "GeolocationController.h" +#endif + namespace WebCore { static HashSet<Page*>* allPages; @@ -101,7 +105,7 @@ static void networkStateChanged() frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false)); } -Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient) +Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient, GeolocationControllerClient* geolocationControllerClient) : m_chrome(new Chrome(this, chromeClient)) , m_dragCaretController(new SelectionController(0, true)) #if ENABLE(DRAG_SUPPORT) @@ -114,6 +118,9 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi #if ENABLE(INSPECTOR) , m_inspectorController(new InspectorController(this, inspectorClient)) #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + , m_geolocationController(new GeolocationController(this, geolocationControllerClient)) +#endif , m_settings(new Settings(this)) , m_progress(new ProgressTracker) , m_backForwardList(BackForwardList::create(this)) @@ -148,6 +155,10 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi #if !ENABLE(INSPECTOR) UNUSED_PARAM(inspectorClient); #endif +#if !ENABLE(CLIENT_BASED_GEOLOCATION) + UNUSED_PARAM(geolocationControllerClient); +#endif + if (!allPages) { allPages = new HashSet<Page*>; diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h index 4886464..40d96a7 100644 --- a/WebCore/page/Page.h +++ b/WebCore/page/Page.h @@ -54,6 +54,8 @@ namespace WebCore { class EditorClient; class FocusController; class Frame; + class GeolocationController; + class GeolocationControllerClient; class HaltablePlugin; class InspectorClient; class InspectorController; @@ -85,7 +87,7 @@ namespace WebCore { public: static void setNeedsReapplyStyles(); - Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*, PluginHalterClient*); + Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*, PluginHalterClient*, GeolocationControllerClient*); ~Page(); RenderTheme* theme() const { return m_theme.get(); }; @@ -144,6 +146,9 @@ namespace WebCore { #if ENABLE(INSPECTOR) InspectorController* inspectorController() const { return m_inspectorController.get(); } #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + GeolocationController* geolocationController() const { return m_geolocationController.get(); } +#endif Settings* settings() const { return m_settings.get(); } ProgressTracker* progress() const { return m_progress.get(); } @@ -250,6 +255,9 @@ namespace WebCore { #if ENABLE(INSPECTOR) OwnPtr<InspectorController> m_inspectorController; #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + OwnPtr<GeolocationController> m_geolocationController; +#endif OwnPtr<Settings> m_settings; OwnPtr<ProgressTracker> m_progress; diff --git a/WebCore/platform/Timer.cpp b/WebCore/platform/Timer.cpp index 4804540..ea3effd 100644 --- a/WebCore/platform/Timer.cpp +++ b/WebCore/platform/Timer.cpp @@ -37,11 +37,6 @@ #include <wtf/HashSet.h> #include <wtf/Vector.h> -#if PLATFORM(ANDROID) -#include "stl_iterator_base.h" -#include "heap.h" -#endif - using namespace std; namespace WebCore { diff --git a/WebCore/platform/android/GeolocationServiceAndroid.cpp b/WebCore/platform/android/GeolocationServiceAndroid.cpp index 43a8f5f..3ffb9b9 100644 --- a/WebCore/platform/android/GeolocationServiceAndroid.cpp +++ b/WebCore/platform/android/GeolocationServiceAndroid.cpp @@ -28,6 +28,7 @@ #include "GeolocationServiceBridge.h" #include "Geoposition.h" +#include "PlatformBridge.h" #include "PositionError.h" #include "PositionOptions.h" @@ -83,8 +84,13 @@ bool GeolocationServiceAndroid::startUpdating(PositionOptions* options) if (options->enableHighAccuracy()) m_javaBridge->setEnableGps(true); - if (!haveJavaBridge) - m_javaBridge->start(); + // We need only start the service when it's first created. + if (!haveJavaBridge) { + // If the browser is paused, don't start the service. It will be started + // when we get the call to resume. + if (!PlatformBridge::isWebViewPaused()) + m_javaBridge->start(); + } return true; } diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index 9adb314..a73abab 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -50,6 +50,10 @@ public: // KeyGenerator static WTF::Vector<String> getSupportedKeyStrengthList(); static String getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL&); + // Cookies + static void setCookies(const KURL&, const String& value); + static String cookies(const KURL&); + static bool cookiesEnabled(); // These ids need to be in sync with the constants in BrowserFrame.java enum rawResId { NoDomain = 1, @@ -67,6 +71,9 @@ public: static void immediateRepaint(const FrameView* view); #endif // USE(ACCELERATED_COMPOSITING) + // Whether the WebView is paused. + static bool isWebViewPaused(); }; + } #endif // PlatformBridge_h diff --git a/WebCore/platform/graphics/BitmapImage.h b/WebCore/platform/graphics/BitmapImage.h index a07daf2..0031df6 100644 --- a/WebCore/platform/graphics/BitmapImage.h +++ b/WebCore/platform/graphics/BitmapImage.h @@ -148,7 +148,7 @@ public: virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE); #endif -#if PLATFORM(SGL) +#if PLATFORM(ANDROID) virtual void setURL(const String& str); #endif diff --git a/WebCore/platform/graphics/FloatPoint.h b/WebCore/platform/graphics/FloatPoint.h index 7d32bcf..45a1e83 100644 --- a/WebCore/platform/graphics/FloatPoint.h +++ b/WebCore/platform/graphics/FloatPoint.h @@ -100,7 +100,7 @@ public: operator BPoint() const; #endif -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) operator SkPoint() const; FloatPoint(const SkPoint&); #endif diff --git a/WebCore/platform/graphics/FloatRect.h b/WebCore/platform/graphics/FloatRect.h index 4b4694f..2dc854d 100644 --- a/WebCore/platform/graphics/FloatRect.h +++ b/WebCore/platform/graphics/FloatRect.h @@ -55,7 +55,7 @@ class wxRect2DDouble; class BRect; #endif -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) struct SkRect; #endif @@ -149,7 +149,7 @@ public: operator BRect() const; #endif -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) FloatRect(const SkRect&); operator SkRect() const; #endif diff --git a/WebCore/platform/graphics/Gradient.cpp b/WebCore/platform/graphics/Gradient.cpp index 77a0d21..204a2b6 100644 --- a/WebCore/platform/graphics/Gradient.cpp +++ b/WebCore/platform/graphics/Gradient.cpp @@ -161,7 +161,7 @@ void Gradient::setGradientSpaceTransform(const TransformationMatrix& gradientSpa setPlatformGradientSpaceTransform(gradientSpaceTransformation); } -#if !PLATFORM(SKIA) +#if !(PLATFORM(SKIA) && !PLATFORM(ANDROID)) void Gradient::setPlatformGradientSpaceTransform(const TransformationMatrix&) { } diff --git a/WebCore/platform/graphics/Gradient.h b/WebCore/platform/graphics/Gradient.h index 7f01251..011a2cd 100644 --- a/WebCore/platform/graphics/Gradient.h +++ b/WebCore/platform/graphics/Gradient.h @@ -46,13 +46,15 @@ typedef QGradient* PlatformGradient; #elif PLATFORM(CAIRO) typedef struct _cairo_pattern cairo_pattern_t; typedef cairo_pattern_t* PlatformGradient; -#elif PLATFORM(ANDROID) && PLATFORM(SGL) +#elif PLATFORM(SKIA) +#if PLATFORM(ANDROID) #include "SkShader.h" typedef class PlatformGradientRec* PlatformGradient; -#elif PLATFORM(SKIA) +#else class SkShader; typedef class SkShader* PlatformGradient; typedef class SkShader* PlatformPattern; +#endif #else typedef void* PlatformGradient; #endif @@ -86,13 +88,11 @@ namespace WebCore { struct ColorStop; const Vector<ColorStop>& getStops() const; #else - -#if PLATFORM(ANDROID) && PLATFORM(SGL) +#if PLATFORM(ANDROID) SkShader* getShader(SkShader::TileMode); #endif PlatformGradient platformGradient(); #endif - struct ColorStop { float stop; float red; diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp index fee05ee..e80004f 100644 --- a/WebCore/platform/graphics/GraphicsContext.cpp +++ b/WebCore/platform/graphics/GraphicsContext.cpp @@ -518,7 +518,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator) generator.fill(this, rect); } -#if !PLATFORM(SKIA) +#if !(PLATFORM(SKIA) && !PLATFORM(ANDROID)) void GraphicsContext::setPlatformFillGradient(Gradient*) { } @@ -536,7 +536,7 @@ void GraphicsContext::setPlatformStrokePattern(Pattern*) } #endif -#if !PLATFORM(CG) && !PLATFORM(SKIA) +#if !PLATFORM(CG) && !(PLATFORM(SKIA) && !PLATFORM(ANDROID)) // Implement this if you want to go ahead and push the drawing mode into your native context // immediately. void GraphicsContext::setPlatformTextDrawingMode(int mode) @@ -544,7 +544,7 @@ void GraphicsContext::setPlatformTextDrawingMode(int mode) } #endif -#if !PLATFORM(QT) && !PLATFORM(CAIRO) && !PLATFORM(SKIA) && !PLATFORM(HAIKU) +#if !PLATFORM(QT) && !PLATFORM(CAIRO) && !(PLATFORM(SKIA) && !PLATFORM(ANDROID)) && !PLATFORM(HAIKU) void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle&) { } diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h index 96a6221..ecf2101 100644 --- a/WebCore/platform/graphics/GraphicsContext.h +++ b/WebCore/platform/graphics/GraphicsContext.h @@ -46,12 +46,6 @@ QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE typedef QPainter PlatformGraphicsContext; -#elif PLATFORM(SGL) -namespace WebCore { -class PlatformGraphicsContext; -} -class SkPaint; -struct SkPoint; #elif PLATFORM(WX) class wxGCDC; class wxWindowDC; @@ -72,7 +66,15 @@ class wxWindowDC; typedef wxWindowDC PlatformGraphicsContext; #endif #elif PLATFORM(SKIA) +#if PLATFORM(ANDROID) +namespace WebCore { +class PlatformGraphicsContext; +} +class SkPaint; +struct SkPoint; +#else typedef class PlatformContextSkia PlatformGraphicsContext; +#endif #elif PLATFORM(HAIKU) class BView; typedef BView PlatformGraphicsContext; @@ -190,7 +192,7 @@ namespace WebCore { void applyFillPattern(); #endif -#if PLATFORM(SGL) +#if PLATFORM(ANDROID) // initialize a paint for bitmaps void setupBitmapPaint(SkPaint*); // initialize a paint for filling @@ -204,7 +206,7 @@ namespace WebCore { bool willFill() const; // returns true if there is a valid (non-transparent) stroke color bool willStroke() const; - + // may return NULL, since we lazily allocate the path. This is the path // that is drawn by drawPath() const SkPath* getCurrPath() const; diff --git a/WebCore/platform/graphics/Image.h b/WebCore/platform/graphics/Image.h index aef6577..f25169b 100644 --- a/WebCore/platform/graphics/Image.h +++ b/WebCore/platform/graphics/Image.h @@ -148,7 +148,7 @@ public: virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE) { return false; } #endif -#if PLATFORM(SGL) +#if PLATFORM(ANDROID) virtual void setURL(const String& str) {} #endif diff --git a/WebCore/platform/graphics/ImageSource.h b/WebCore/platform/graphics/ImageSource.h index 19c7bf7..083c7b0 100644 --- a/WebCore/platform/graphics/ImageSource.h +++ b/WebCore/platform/graphics/ImageSource.h @@ -45,12 +45,14 @@ QT_END_NAMESPACE #elif PLATFORM(CAIRO) struct _cairo_surface; typedef struct _cairo_surface cairo_surface_t; -#elif PLATFORM(ANDROID) && PLATFORM(SGL) +#elif PLATFORM(SKIA) +#if PLATFORM(ANDROID) #include "SkString.h" class SkBitmapRef; class PrivateAndroidImageSourceRec; -#elif PLATFORM(SKIA) +#else class NativeImageSkia; +#endif #elif PLATFORM(HAIKU) class BBitmap; #elif PLATFORM(WINCE) @@ -70,14 +72,14 @@ typedef CGImageRef NativeImagePtr; class ImageDecoderQt; typedef ImageDecoderQt* NativeImageSourcePtr; typedef QPixmap* NativeImagePtr; -#elif PLATFORM(ANDROID) -#if PLATFORM(SGL) +#elif PLATFORM(SKIA) +#if PLATFORM(ANDROID) class String; #ifdef ANDROID_ANIMATED_GIF class ImageDecoder; #endif struct NativeImageSourcePtr { - SkString m_url; + SkString m_url; PrivateAndroidImageSourceRec* m_image; #ifdef ANDROID_ANIMATED_GIF ImageDecoder* m_gifDecoder; @@ -85,7 +87,7 @@ struct NativeImageSourcePtr { }; typedef const Vector<char>* NativeBytePtr; typedef SkBitmapRef* NativeImagePtr; -#elif PLATFORM(SKIA) // ANDROID +#else class ImageDecoder; typedef ImageDecoder* NativeImageSourcePtr; typedef NativeImageSkia* NativeImagePtr; @@ -101,8 +103,6 @@ typedef wxBitmap* NativeImagePtr; #endif #elif PLATFORM(CAIRO) typedef cairo_surface_t* NativeImagePtr; -#elif PLATFORM(SKIA) -typedef NativeImageSkia* NativeImagePtr; #elif PLATFORM(HAIKU) typedef BBitmap* NativeImagePtr; #elif PLATFORM(WINCE) @@ -166,11 +166,9 @@ public: bool frameIsCompleteAtIndex(size_t); // Whether or not the frame is completely decoded. #if PLATFORM(ANDROID) -#if PLATFORM(SGL) void clearURL(); void setURL(const String& url); #endif -#endif private: #if PLATFORM(ANDROID) // FIXME: This is protected only to allow ImageSourceSkia to set ICO decoder diff --git a/WebCore/platform/graphics/IntPoint.h b/WebCore/platform/graphics/IntPoint.h index afbfb46..ab5f3ec 100644 --- a/WebCore/platform/graphics/IntPoint.h +++ b/WebCore/platform/graphics/IntPoint.h @@ -63,7 +63,7 @@ class BPoint; class wxPoint; #endif -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) struct SkPoint; struct SkIPoint; #endif @@ -133,7 +133,7 @@ public: operator wxPoint() const; #endif -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) IntPoint(const SkIPoint&); operator SkIPoint() const; operator SkPoint() const; diff --git a/WebCore/platform/graphics/IntRect.h b/WebCore/platform/graphics/IntRect.h index cd912ff..97b21bc 100644 --- a/WebCore/platform/graphics/IntRect.h +++ b/WebCore/platform/graphics/IntRect.h @@ -57,7 +57,7 @@ class BRect; class wxRect; #endif -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) struct SkRect; struct SkIRect; #endif @@ -155,7 +155,7 @@ public: operator CGRect() const; #endif -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) IntRect(const SkIRect&); operator SkRect() const; operator SkIRect() const; diff --git a/WebCore/platform/graphics/Path.h b/WebCore/platform/graphics/Path.h index fef5ad2..6618fb7 100644 --- a/WebCore/platform/graphics/Path.h +++ b/WebCore/platform/graphics/Path.h @@ -39,9 +39,6 @@ QT_BEGIN_NAMESPACE class QPainterPath; QT_END_NAMESPACE typedef QPainterPath PlatformPath; -#elif PLATFORM(SGL) -class SkPath; -typedef SkPath PlatformPath; #elif PLATFORM(WX) && USE(WXGC) class wxGraphicsPath; typedef wxGraphicsPath PlatformPath; diff --git a/WebCore/platform/graphics/Pattern.h b/WebCore/platform/graphics/Pattern.h index 2f1192c..aa0a357 100644 --- a/WebCore/platform/graphics/Pattern.h +++ b/WebCore/platform/graphics/Pattern.h @@ -39,7 +39,7 @@ typedef CGPatternRef PlatformPatternPtr; #elif PLATFORM(CAIRO) #include <cairo.h> typedef cairo_pattern_t* PlatformPatternPtr; -#elif PLATFORM(SKIA) || PLATFORM(SGL) +#elif PLATFORM(SKIA) class SkShader; typedef SkShader* PlatformPatternPtr; #elif PLATFORM(QT) diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 6901f52..fa012b0 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -337,6 +337,7 @@ void GraphicsLayerAndroid::setOpacity(float opacity) MLOG("(%x) setFinalOpacity: %.2f=>%.2f (%.2f)", this, opacity, clampedOpacity, m_opacity); GraphicsLayer::setOpacity(clampedOpacity); + m_contentLayer->setOpacity(clampedOpacity); askForSync(); } diff --git a/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h index 29ef11c..19bfcd1 100644 --- a/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h +++ b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h @@ -89,6 +89,7 @@ public: void onPrepared(int duration, int width, int height); void onEnded(); void onPosterFetched(SkBitmap*); + void onTimeupdate(int position); private: // Android-specific methods and fields. static MediaPlayerPrivateInterface* create(MediaPlayer* player); @@ -107,6 +108,7 @@ private: float m_currentTime; bool m_paused; + bool m_hasVideo; MediaPlayer::ReadyState m_readyState; MediaPlayer::NetworkState m_networkState; diff --git a/WebCore/platform/graphics/skia/NativeImageSkia.cpp b/WebCore/platform/graphics/skia/NativeImageSkia.cpp index 477be05..2411897 100644 --- a/WebCore/platform/graphics/skia/NativeImageSkia.cpp +++ b/WebCore/platform/graphics/skia/NativeImageSkia.cpp @@ -30,7 +30,7 @@ #include "config.h" -#if PLATFORM(SKIA) +#if !PLATFORM(ANDROID) #include "skia/ext/image_operations.h" #endif @@ -65,10 +65,11 @@ bool NativeImageSkia::hasResizedBitmap(int w, int h) const SkBitmap NativeImageSkia::resizedBitmap(int w, int h) const { -#if PLATFORM(SKIA) +#if !PLATFORM(ANDROID) if (m_resizedImage.width() != w || m_resizedImage.height() != h) m_resizedImage = skia::ImageOperations::Resize(*this, skia::ImageOperations::RESIZE_LANCZOS3, w, h); #endif + return m_resizedImage; } diff --git a/WebCore/platform/graphics/transforms/TransformationMatrix.h b/WebCore/platform/graphics/transforms/TransformationMatrix.h index 33f9afe..802ad3c 100644 --- a/WebCore/platform/graphics/transforms/TransformationMatrix.h +++ b/WebCore/platform/graphics/transforms/TransformationMatrix.h @@ -37,7 +37,7 @@ #include <cairo.h> #elif PLATFORM(QT) #include <QTransform> -#elif PLATFORM(SKIA) || PLATFORM(SGL) +#elif PLATFORM(SKIA) #include <SkMatrix.h> #elif PLATFORM(WX) && USE(WXGC) #include <wx/graphics.h> @@ -301,7 +301,7 @@ public: operator cairo_matrix_t() const; #elif PLATFORM(QT) operator QTransform() const; -#elif PLATFORM(SKIA) || PLATFORM(SGL) +#elif PLATFORM(SKIA) operator SkMatrix() const; #elif PLATFORM(WX) && USE(WXGC) operator wxGraphicsMatrix() const; diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h index 08f4aa2..535efa1 100644 --- a/WebCore/platform/image-decoders/ImageDecoder.h +++ b/WebCore/platform/image-decoders/ImageDecoder.h @@ -36,8 +36,7 @@ #include <wtf/RefPtr.h> #include <wtf/Vector.h> -#if (PLATFORM(SKIA) || PLATFORM(SGL)) -// TODO(benm): ANDROID: Can we define PLATFORM(SKIA) instead of PLATFORM(SGL) before upstreaming? +#if PLATFORM(SKIA) #include "NativeImageSkia.h" #elif PLATFORM(QT) #include <QImage> @@ -58,7 +57,7 @@ namespace WebCore { DisposeOverwriteBgcolor, // Clear frame to transparent DisposeOverwritePrevious, // Clear frame to previous framebuffer contents }; -#if (PLATFORM(SKIA) || PLATFORM(QT) || PLATFORM(SGL)) +#if PLATFORM(SKIA) || PLATFORM(QT) typedef uint32_t PixelData; #else typedef unsigned PixelData; @@ -102,7 +101,7 @@ namespace WebCore { memcpy(getAddr(startX, destY), startAddr, rowBytes); } -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(ANDROID) NativeImageSkia& bitmap() { return m_bitmap; } const NativeImageSkia& bitmap() const { return m_bitmap; } #endif @@ -148,7 +147,7 @@ namespace WebCore { inline PixelData* getAddr(int x, int y) { -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) return m_bitmap.getAddr32(x, y); #elif PLATFORM(QT) return reinterpret_cast<QRgb*>(m_image.scanLine(y)) + x; @@ -173,7 +172,7 @@ namespace WebCore { } } -#if (PLATFORM(SKIA) || PLATFORM(SGL)) +#if PLATFORM(SKIA) NativeImageSkia m_bitmap; #elif PLATFORM(QT) mutable QImage m_image; diff --git a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp index 6acaed5..96342fa 100644 --- a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp +++ b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp @@ -26,8 +26,7 @@ #include "config.h" #include "ImageDecoder.h" - -#if PLATFORM(SGL) +#if PLATFORM(ANDROID) #include "SkBitmapRef.h" #endif @@ -85,7 +84,7 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight) NativeImagePtr RGBA32Buffer::asNewNativeImage() const { -#if PLATFORM(SGL) +#if PLATFORM(ANDROID) return new SkBitmapRef(m_bitmap); #else return new NativeImageSkia(m_bitmap); diff --git a/WebCore/platform/network/NetworkStateNotifier.h b/WebCore/platform/network/NetworkStateNotifier.h index a630ccd..d0463d4 100644 --- a/WebCore/platform/network/NetworkStateNotifier.h +++ b/WebCore/platform/network/NetworkStateNotifier.h @@ -27,6 +27,9 @@ #define NetworkStateNotifier_h #include <wtf/Noncopyable.h> +#if PLATFORM(ANDROID) +#include "Connection.h" +#endif #if PLATFORM(MAC) @@ -54,9 +57,15 @@ public: void setNetworkStateChangedFunction(void (*)()); bool onLine() const { return m_isOnLine; } +#if PLATFORM(ANDROID) + Connection::ConnectionType type() const { return m_type; } +#endif private: bool m_isOnLine; +#if PLATFORM(ANDROID) + Connection::ConnectionType m_type; +#endif void (*m_networkStateChangedFunction)(); void updateState(); @@ -78,12 +87,13 @@ private: HANDLE m_waitHandle; OVERLAPPED m_overlapped; -#elif PLATFORM(ANDROID) -public: - void networkStateChange(bool online); - #elif PLATFORM(CHROMIUM) NetworkStateNotifierPrivate p; + +#elif PLATFORM(ANDROID) +public: + void networkStateChange(bool online); + void networkTypeChange(Connection::ConnectionType type); #endif }; @@ -91,6 +101,9 @@ public: inline NetworkStateNotifier::NetworkStateNotifier() : m_isOnLine(true) +#if PLATFORM(ANDROID) + , m_type(Connection::Unknown) +#endif , m_networkStateChangedFunction(0) { } diff --git a/WebCore/platform/network/ResourceHandle.h b/WebCore/platform/network/ResourceHandle.h index e7f6092..b764add 100644 --- a/WebCore/platform/network/ResourceHandle.h +++ b/WebCore/platform/network/ResourceHandle.h @@ -170,7 +170,7 @@ public: friend LRESULT __stdcall ResourceHandleWndProc(HWND, unsigned message, WPARAM, LPARAM); #endif -#if PLATFORM(QT) || USE(CURL) || USE(SOUP) || defined(ANDROID) +#if PLATFORM(QT) || USE(CURL) || USE(SOUP) || PLATFORM(ANDROID) ResourceHandleInternal* getInternal() { return d.get(); } #endif diff --git a/WebCore/platform/network/ResourceHandleInternal.h b/WebCore/platform/network/ResourceHandleInternal.h index f7135ee..328fc89 100644 --- a/WebCore/platform/network/ResourceHandleInternal.h +++ b/WebCore/platform/network/ResourceHandleInternal.h @@ -133,9 +133,6 @@ namespace WebCore { , m_needsSiteSpecificQuirks(false) , m_currentMacChallenge(nil) #endif -#if PLATFORM(ANDROID) - , m_loader(0) -#endif , m_failureTimer(loader, &ResourceHandle::fireFailure) { const KURL& url = m_request.url(); diff --git a/WebCore/platform/network/android/AuthenticationChallenge.h b/WebCore/platform/network/android/AuthenticationChallenge.h index e272d60..954bfd8 100644 --- a/WebCore/platform/network/android/AuthenticationChallenge.h +++ b/WebCore/platform/network/android/AuthenticationChallenge.h @@ -31,8 +31,6 @@ namespace WebCore { -class ResourceHandle; - class AuthenticationChallenge : public AuthenticationChallengeBase { }; diff --git a/WebCore/platform/network/android/CookieClient.h b/WebCore/platform/network/android/CookieJarAndroid.cpp index be2963e..ba4b5dc 100644 --- a/WebCore/platform/network/android/CookieClient.h +++ b/WebCore/platform/network/android/CookieJarAndroid.cpp @@ -23,24 +23,27 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef COOKIE_CLIENT_H -#define COOKIE_CLIENT_H +#include "config.h" -#include "KURL.h" -#include "PlatformString.h" +#include "CookieJar.h" -using namespace WebCore; +#include "PlatformBridge.h" -namespace android { +namespace WebCore { -class CookieClient { +void setCookies(Document*, const KURL& url, const String& value) +{ + PlatformBridge::setCookies(url, value); +} + +String cookies(const Document*, const KURL& url) +{ + return PlatformBridge::cookies(url); +} -public: - virtual ~CookieClient() {} - virtual void setCookies(const KURL& url, const String& value) = 0; - virtual String cookies(const KURL& url) = 0; - virtual bool cookiesEnabled() = 0; -}; +bool cookiesEnabled(const Document*) +{ + return PlatformBridge::cookiesEnabled(); +} } -#endif diff --git a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp b/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp index 3aa5578..134e206 100644 --- a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp +++ b/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp @@ -39,4 +39,15 @@ void NetworkStateNotifier::networkStateChange(bool online) m_networkStateChangedFunction(); } +void NetworkStateNotifier::networkTypeChange(Connection::ConnectionType type) +{ + if (m_type == type) + return; + + m_type = type; + + if (m_networkStateChangedFunction) + m_networkStateChangedFunction(); +} + } diff --git a/WebCore/rendering/RenderBlockLineLayout.cpp b/WebCore/rendering/RenderBlockLineLayout.cpp index 8517d6d..4d209de 100644 --- a/WebCore/rendering/RenderBlockLineLayout.cpp +++ b/WebCore/rendering/RenderBlockLineLayout.cpp @@ -852,6 +852,8 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i // and text align is auto, or justify or left in LTR, or right in RTL, we // will wrap text around screen width so that it doesn't need to scroll // horizontally when reading a paragraph. + // In case the line height is less than the font size, we skip + // the text wrapping since this will cause text overlapping. const Settings* settings = document()->settings(); bool doTextWrap = settings && settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen; if (doTextWrap) { @@ -862,7 +864,10 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i // width as it may cause text to overlap. bool positioned = isPositioned(); EFloat cssfloat = style()->floating(); + const int lineHeight = style()->computedLineHeight(); + const int fontSize = style()->fontSize(); doTextWrap = autowrap && !positioned && + (fontSize <= lineHeight) && (((dir == LTR && cssfloat != FRIGHT) || (dir == RTL && cssfloat != FLEFT)) && ((ta == TAAUTO) || (ta == JUSTIFY) || diff --git a/WebCore/rendering/RenderPartObject.cpp b/WebCore/rendering/RenderPartObject.cpp index f864c00..8e9118e 100644 --- a/WebCore/rendering/RenderPartObject.cpp +++ b/WebCore/rendering/RenderPartObject.cpp @@ -322,10 +322,15 @@ void RenderPartObject::layout() #ifdef FLATTEN_IFRAME RenderPart::calcWidth(); RenderPart::calcHeight(); + // Calculate the styled dimensions by subtracting the border and padding. + int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight(); + int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom(); + int styleWidth = width() - extraWidth; + int styleHeight = height() - extraHeight; // Some IFrames have a width and/or height of 1 when they are meant to be // hidden. If that is the case, do not try to expand. - if (node()->hasTagName(iframeTag) && widget() && widget()->isFrameView() - && width() > 1 && height() > 1) { + if (node()->hasTagName(iframeTag) && widget() && widget()->isFrameView() && + styleWidth > 1 && styleHeight > 1) { HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node()); bool scrolling = element->scrollingMode() != ScrollbarAlwaysOff; bool widthIsFixed = style()->width().isFixed(); @@ -336,15 +341,11 @@ void RenderPartObject::layout() if (scrolling || !widthIsFixed || !heightIsFixed) { FrameView* view = static_cast<FrameView*>(widget()); RenderView* root = view ? view->frame()->contentRenderer() : NULL; - RenderPart* owner = view->frame()->ownerRenderer(); - if (root && style()->visibility() != HIDDEN - && (!owner || owner->style()->visibility() != HIDDEN)) { + if (root && style()->visibility() != HIDDEN) { // Update the dimensions to get the correct minimum preferred // width updateWidgetPosition(); - int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight(); - int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom(); // Use the preferred width if it is larger and only if // scrollbars are visible or the width style is not fixed. if (scrolling || !widthIsFixed) diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp index c4be11e..5f050a4 100644 --- a/WebCore/svg/graphics/SVGImage.cpp +++ b/WebCore/svg/graphics/SVGImage.cpp @@ -245,7 +245,7 @@ bool SVGImage::dataChanged(bool allDataReceived) // FIXME: If this SVG ends up loading itself, we might leak the world. // The comment said that the Cache code does not know about CachedImages // holding Frames and won't know to break the cycle. But - m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, 0)); + m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, 0, 0)); m_page->settings()->setJavaScriptEnabled(false); m_page->settings()->setPluginsEnabled(false); diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp index 728ff1b..6b81f72 100644 --- a/WebCore/svg/graphics/SVGPaintServer.cpp +++ b/WebCore/svg/graphics/SVGPaintServer.cpp @@ -38,7 +38,7 @@ #include "SVGStyledElement.h" #include "SVGURIReference.h" -#if PLATFORM(SKIA) +#if PLATFORM(SKIA) && !PLATFORM(ANDROID) #include "PlatformContextSkia.h" #endif @@ -184,7 +184,7 @@ void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* p context->strokePath(); } -#if PLATFORM(SKIA) +#if PLATFORM(SKIA) && !PLATFORM(ANDROID) void SVGPaintServer::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const { // FIXME: Move this into the GraphicsContext |