diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 19:28:52 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 19:28:52 +0000 |
commit | 40bc40fc0dc38e86f15732d125e82885d28b268f (patch) | |
tree | 62d79127b8de7fda63aa0110b81ccfe3b46937a7 | |
parent | 4a6b237ac9dad3e6ea43d2a22dbda63bbe5e1fe7 (diff) | |
download | chromium_src-40bc40fc0dc38e86f15732d125e82885d28b268f.zip chromium_src-40bc40fc0dc38e86f15732d125e82885d28b268f.tar.gz chromium_src-40bc40fc0dc38e86f15732d125e82885d28b268f.tar.bz2 |
Exposes WebCore's FontCache through the webkit API
WebCore has a static FontCache that holds handles to platform-specific font data. It exposes a few knobs that might be useful to track or minimize memory usage. This patch exposes an API to experiment with.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/251081
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28021 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/api/public/WebFontCache.h | 56 | ||||
-rw-r--r-- | webkit/api/src/WebFontCache.cpp | 58 | ||||
-rw-r--r-- | webkit/webkit.gyp | 2 |
3 files changed, 116 insertions, 0 deletions
diff --git a/webkit/api/public/WebFontCache.h b/webkit/api/public/WebFontCache.h new file mode 100644 index 0000000..e9e4399 --- /dev/null +++ b/webkit/api/public/WebFontCache.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebFontCache_h +#define WebFontCache_h + +#include "WebCommon.h" + +namespace WebKit { + + // An interface to query and configure WebKit's font cache. + class WebFontCache { + public: + // Returns the number of items in the font data cache. + WEBKIT_API static size_t fontDataCount(); + + // Returns the number of inactive items in the font data cache. + WEBKIT_API static size_t inactiveFontDataCount(); + + // Invalidates and purges all data held in the font data cache. + WEBKIT_API static void invalidate(); + + private: + WebFontCache(); // Not intended to be instanced. + }; + +} // namespace WebKit + +#endif diff --git a/webkit/api/src/WebFontCache.cpp b/webkit/api/src/WebFontCache.cpp new file mode 100644 index 0000000..65ed56d --- /dev/null +++ b/webkit/api/src/WebFontCache.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebFontCache.h" + +#include "FontCache.h" + +using namespace WebCore; + +namespace WebKit { + +// static +size_t WebFontCache::fontDataCount() +{ + return fontCache()->fontDataCount(); +} + +// static +size_t WebFontCache::inactiveFontDataCount() +{ + return fontCache()->inactiveFontDataCount(); +} + +// static +void WebFontCache::invalidate() +{ + fontCache()->invalidate(); +} + +} // namespace WebKit diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index efc5176..b1bdfb2 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -97,6 +97,7 @@ 'api/public/WebFindOptions.h', 'api/public/WebFrame.h', 'api/public/WebFrameClient.h', + 'api/public/WebFontCache.h', 'api/public/WebForm.h', 'api/public/WebHistoryItem.h', 'api/public/WebHTTPBody.h', @@ -189,6 +190,7 @@ 'api/src/WebDataSourceImpl.cpp', 'api/src/WebDataSourceImpl.h', 'api/src/WebDragData.cpp', + 'api/src/WebFontCache.cpp', 'api/src/WebForm.cpp', 'api/src/WebHistoryItem.cpp', 'api/src/WebHTTPBody.cpp', |