diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-03 11:38:10 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-03 11:38:10 +0000 |
commit | c4c01f7ef5c32e52abd09e6b826f82746282411f (patch) | |
tree | 3c34f4f13644d7831800b15a8206c2f50b711a7a | |
parent | ab0eb293ec91e528e6f6e64474687ef07127a718 (diff) | |
download | chromium_src-c4c01f7ef5c32e52abd09e6b826f82746282411f.zip chromium_src-c4c01f7ef5c32e52abd09e6b826f82746282411f.tar.gz chromium_src-c4c01f7ef5c32e52abd09e6b826f82746282411f.tar.bz2 |
Cleanup in webkit/glue/
- make more methods const
- remove unneeded #includes
BUG=7210
Review URL: http://codereview.chromium.org/19535
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9080 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/autofill_form.h | 3 | ||||
-rw-r--r-- | webkit/glue/back_forward_list_client_impl.cc | 3 | ||||
-rw-r--r-- | webkit/glue/back_forward_list_client_impl.h | 2 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.h | 2 | ||||
-rw-r--r-- | webkit/glue/cpp_bound_class.cc | 44 | ||||
-rw-r--r-- | webkit/glue/cpp_bound_class.h | 16 | ||||
-rw-r--r-- | webkit/glue/image_decoder.cc | 14 | ||||
-rw-r--r-- | webkit/glue/image_decoder.h | 2 | ||||
-rw-r--r-- | webkit/glue/resource_fetcher.h | 6 |
9 files changed, 45 insertions, 47 deletions
diff --git a/webkit/glue/autofill_form.h b/webkit/glue/autofill_form.h index 91a530cb..6a300a7 100644 --- a/webkit/glue/autofill_form.h +++ b/webkit/glue/autofill_form.h @@ -8,9 +8,6 @@ #include <string> #include <vector> -#include "base/time.h" -#include "webkit/glue/autofill_form.h" - namespace WebCore { class HTMLFormElement; } diff --git a/webkit/glue/back_forward_list_client_impl.cc b/webkit/glue/back_forward_list_client_impl.cc index 3e144bf..99149d1 100644 --- a/webkit/glue/back_forward_list_client_impl.cc +++ b/webkit/glue/back_forward_list_client_impl.cc @@ -26,7 +26,8 @@ void BackForwardListClientImpl::SetCurrentHistoryItem( current_item_ = item; } -WebCore::HistoryItem* BackForwardListClientImpl::GetPreviousHistoryItem() { +WebCore::HistoryItem* BackForwardListClientImpl::GetPreviousHistoryItem() + const { return previous_item_.get(); } diff --git a/webkit/glue/back_forward_list_client_impl.h b/webkit/glue/back_forward_list_client_impl.h index 0a46376..1a26c35 100644 --- a/webkit/glue/back_forward_list_client_impl.h +++ b/webkit/glue/back_forward_list_client_impl.h @@ -20,7 +20,7 @@ class BackForwardListClientImpl : public WebCore::BackForwardListClient { ~BackForwardListClientImpl(); void SetCurrentHistoryItem(WebCore::HistoryItem* item); - WebCore::HistoryItem* GetPreviousHistoryItem(); + WebCore::HistoryItem* GetPreviousHistoryItem() const; private: // WebCore::BackForwardListClient methods: diff --git a/webkit/glue/chrome_client_impl.h b/webkit/glue/chrome_client_impl.h index 226c93c..8ac4916 100644 --- a/webkit/glue/chrome_client_impl.h +++ b/webkit/glue/chrome_client_impl.h @@ -25,7 +25,7 @@ public: ChromeClientImpl(WebViewImpl* webview); virtual ~ChromeClientImpl(); - WebViewImpl* webview() { return webview_; } + WebViewImpl* webview() const { return webview_; } virtual void chromeDestroyed(); diff --git a/webkit/glue/cpp_bound_class.cc b/webkit/glue/cpp_bound_class.cc index 3abb406..23ef80a 100644 --- a/webkit/glue/cpp_bound_class.cc +++ b/webkit/glue/cpp_bound_class.cc @@ -44,7 +44,7 @@ struct CppNPObject { // // An NPClass associates static functions of CppNPObject with the - // function pointers used by the JS runtime. + // function pointers used by the JS runtime. static NPClass np_class_; // Allocate a new NPObject with the specified class. @@ -64,21 +64,21 @@ struct CppNPObject { // If the given method is exposed by the C++ class associated with this // NPObject, invokes it with the given args and returns a result. Otherwise, // returns "undefined" (in the JavaScript sense). Called by the JS runtime. - static bool invoke(NPObject *obj, NPIdentifier ident, - const NPVariant *args, uint32_t arg_count, + static bool invoke(NPObject *obj, NPIdentifier ident, + const NPVariant *args, uint32_t arg_count, NPVariant *result); // If the given property is exposed by the C++ class associated with this // NPObject, returns its value. Otherwise, returns "undefined" (in the // JavaScript sense). Called by the JS runtime. - static bool getProperty(NPObject *obj, NPIdentifier ident, + static bool getProperty(NPObject *obj, NPIdentifier ident, NPVariant *result); // If the given property is exposed by the C++ class associated with this - // NPObject, sets its value. Otherwise, does nothing. Called by the JS + // NPObject, sets its value. Otherwise, does nothing. Called by the JS // runtime. - static bool setProperty(NPObject *obj, NPIdentifier ident, - const NPVariant *value); + static bool setProperty(NPObject *obj, NPIdentifier ident, + const NPVariant *value); }; // Build CppNPObject's static function pointers into an NPClass, for use @@ -109,33 +109,33 @@ NPClass CppNPObject::np_class_ = { delete obj; } -/* static */ bool CppNPObject::hasMethod(NPObject* np_obj, +/* static */ bool CppNPObject::hasMethod(NPObject* np_obj, NPIdentifier ident) { CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); return obj->bound_class->HasMethod(ident); } -/* static */ bool CppNPObject::hasProperty(NPObject* np_obj, +/* static */ bool CppNPObject::hasProperty(NPObject* np_obj, NPIdentifier ident) { CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); return obj->bound_class->HasProperty(ident); } -/* static */ bool CppNPObject::invoke(NPObject* np_obj, NPIdentifier ident, - const NPVariant* args, uint32_t arg_count, +/* static */ bool CppNPObject::invoke(NPObject* np_obj, NPIdentifier ident, + const NPVariant* args, uint32_t arg_count, NPVariant* result) { CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); return obj->bound_class->Invoke(ident, args, arg_count, result); } -/* static */ bool CppNPObject::getProperty(NPObject* np_obj, - NPIdentifier ident, +/* static */ bool CppNPObject::getProperty(NPObject* np_obj, + NPIdentifier ident, NPVariant* result) { CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); return obj->bound_class->GetProperty(ident, result); } -/* static */ bool CppNPObject::setProperty(NPObject* np_obj, +/* static */ bool CppNPObject::setProperty(NPObject* np_obj, NPIdentifier ident, const NPVariant* value) { CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); @@ -147,7 +147,7 @@ CppBoundClass::~CppBoundClass() { delete i->second; // Unregister objects we created and bound to a frame. - for (BoundObjectList::iterator i = bound_objects_.begin(); + for (BoundObjectList::iterator i = bound_objects_.begin(); i != bound_objects_.end(); ++i) { #if USE(V8) _NPN_UnregisterObject(*i); @@ -156,17 +156,17 @@ CppBoundClass::~CppBoundClass() { } } -bool CppBoundClass::HasMethod(NPIdentifier ident) { +bool CppBoundClass::HasMethod(NPIdentifier ident) const { return (methods_.find(ident) != methods_.end()); } -bool CppBoundClass::HasProperty(NPIdentifier ident) { +bool CppBoundClass::HasProperty(NPIdentifier ident) const { return (properties_.find(ident) != properties_.end()); } -bool CppBoundClass::Invoke(NPIdentifier ident, +bool CppBoundClass::Invoke(NPIdentifier ident, const NPVariant* args, - size_t arg_count, + size_t arg_count, NPVariant* result) { MethodList::const_iterator method = methods_.find(ident); Callback* callback; @@ -193,7 +193,7 @@ bool CppBoundClass::Invoke(NPIdentifier ident, return true; } -bool CppBoundClass::GetProperty(NPIdentifier ident, NPVariant* result) { +bool CppBoundClass::GetProperty(NPIdentifier ident, NPVariant* result) const { PropertyList::const_iterator prop = properties_.find(ident); if (prop == properties_.end()) { VOID_TO_NPVARIANT(*result); @@ -230,10 +230,10 @@ void CppBoundClass::BindProperty(std::string name, CppVariant* prop) { properties_[ident] = prop; } -bool CppBoundClass::IsMethodRegistered(std::string name) { +bool CppBoundClass::IsMethodRegistered(std::string name) const { // NPUTF8 is a typedef for char, so this cast is safe. NPIdentifier ident = NPN_GetStringIdentifier((const NPUTF8*)name.c_str()); - MethodList::iterator callback = methods_.find(ident); + MethodList::const_iterator callback = methods_.find(ident); return (callback != methods_.end()); } diff --git a/webkit/glue/cpp_bound_class.h b/webkit/glue/cpp_bound_class.h index 7c64512..86008f2 100644 --- a/webkit/glue/cpp_bound_class.h +++ b/webkit/glue/cpp_bound_class.h @@ -3,7 +3,7 @@ // found in the LICENSE file. /* - CppBoundClass class: + CppBoundClass class: This base class serves as a parent for C++ classes designed to be bound to JavaScript objects. @@ -53,12 +53,12 @@ class CppBoundClass { // Used by a test. Returns true if a method with name |name| exists, // regardless of whether a fallback is registered. - bool IsMethodRegistered(std::string name); - + bool IsMethodRegistered(std::string name) const; + protected: // Bind the Javascript method called |name| to the C++ callback |callback|. void BindCallback(std::string name, Callback* callback); - + // A wrapper for BindCallback, to simplify the common case of binding a // method on the current object. Though not verified here, |method| // must be a method of this CppBoundClass subclass. @@ -107,7 +107,7 @@ class CppBoundClass { // Some fields are protected because some tests depend on accessing them, // but otherwise they should be considered private. - + typedef std::map<NPIdentifier, CppVariant*> PropertyList; typedef std::map<NPIdentifier, Callback*> MethodList; // These maps associate names with property and method pointers to be @@ -121,11 +121,11 @@ class CppBoundClass { private: // NPObject callbacks. friend struct CppNPObject; - bool HasMethod(NPIdentifier ident); + bool HasMethod(NPIdentifier ident) const; bool Invoke(NPIdentifier ident, const NPVariant* args, size_t arg_count, NPVariant* result); - bool HasProperty(NPIdentifier ident); - bool GetProperty(NPIdentifier ident, NPVariant* result); + bool HasProperty(NPIdentifier ident) const; + bool GetProperty(NPIdentifier ident, NPVariant* result) const; bool SetProperty(NPIdentifier ident, const NPVariant* value); // A list of all NPObjects we created and bound in BindToJavascript(), so we diff --git a/webkit/glue/image_decoder.cc b/webkit/glue/image_decoder.cc index 9b4f294..b67e0bb 100644 --- a/webkit/glue/image_decoder.cc +++ b/webkit/glue/image_decoder.cc @@ -33,15 +33,15 @@ ImageDecoder::ImageDecoder(const gfx::Size& desired_icon_size) ImageDecoder::~ImageDecoder() { } -SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) { - +SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const { + // What's going on here? ImageDecoder is only used by ImageResourceFetcher, // which is only used (but extensively) by WebViewImpl. On the Mac we're using // CoreGraphics, but right now WebViewImpl uses SkBitmaps everywhere. For now, // this is a convenient bottleneck to convert from CGImageRefs to SkBitmaps, // but in the future we will need to replumb to get CGImageRefs (or whatever // the native type is) everywhere, directly. - + #if defined(OS_WIN) || defined(OS_LINUX) WebCore::ImageSourceSkia source; #elif defined(OS_MACOSX) @@ -63,18 +63,18 @@ SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) { WebCore::NativeImagePtr frame0 = source.createFrameAtIndex(0); if (!frame0) return SkBitmap(); - + #if defined(OS_WIN) || defined(OS_LINUX) return *reinterpret_cast<SkBitmap*>(frame0); #elif defined(OS_MACOSX) // BitmapImage releases automatically, but we're bypassing it so we'll need // to do the releasing. RetainPtr<CGImageRef> image(AdoptCF, frame0); - + SkBitmap result; result.setConfig(SkBitmap::kARGB_8888_Config, CGImageGetWidth(image.get()), CGImageGetHeight(image.get())); - + RetainPtr<CGColorSpace> cg_color(AdoptCF, CGColorSpaceCreateDeviceRGB()); // The last parameter is a total guess. Feel free to adjust it if images draw // incorrectly. TODO(avi): Verify byte ordering; it should be possible to @@ -93,7 +93,7 @@ SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) { CGImageGetWidth(image.get()), CGImageGetHeight(image.get())); CGContextDrawImage(context.get(), rect, image.get()); - + return result; #endif } diff --git a/webkit/glue/image_decoder.h b/webkit/glue/image_decoder.h index 6f83c2e..dd1401d 100644 --- a/webkit/glue/image_decoder.h +++ b/webkit/glue/image_decoder.h @@ -26,7 +26,7 @@ class ImageDecoder { // Call this function to decode the image. If successful, the decoded image // will be returned. Otherwise, an empty bitmap will be returned. - SkBitmap Decode(const unsigned char* data, size_t size); + SkBitmap Decode(const unsigned char* data, size_t size) const; private: // Size will be empty to get the largest possible size. diff --git a/webkit/glue/resource_fetcher.h b/webkit/glue/resource_fetcher.h index 91d08a1..b20d186 100644 --- a/webkit/glue/resource_fetcher.h +++ b/webkit/glue/resource_fetcher.h @@ -48,18 +48,18 @@ class ResourceFetcher : public WebCore::ResourceHandleClient { // Stop the request and don't call the callback. void Cancel(); - bool completed() { return completed_; } + bool completed() const { return completed_; } // ResourceHandleClient methods virtual void didReceiveResponse(WebCore::ResourceHandle* resource_handle, const WebCore::ResourceResponse& response); - virtual void didReceiveData(WebCore::ResourceHandle* resource_handle, + virtual void didReceiveData(WebCore::ResourceHandle* resource_handle, const char* data, int length, int total_length); virtual void didFinishLoading(WebCore::ResourceHandle* resource_handle); - virtual void didFail(WebCore::ResourceHandle* resource_handle, + virtual void didFail(WebCore::ResourceHandle* resource_handle, const WebCore::ResourceError& error); protected: |