Source/WebCore: Most of the functions in CachedResourceClient are specific
to a single type of CachedResource. Move these callbacks into
separate subclasses of CachedResourceClient, and leave only
the common callback (notifyFinished) in the base class.
https://bugs.webkit.org/show_bug.cgi?id=69790
Reviewed by Adam Barth.
No new tests, no functionality changed intended.
* css/CSSFontFaceSource.h:
* css/CSSImageValue.h:
* css/CSSImportRule.h:
* dom/ProcessingInstruction.cpp:
* dom/ProcessingInstruction.h:
* html/HTMLLinkElement.h:
* html/ImageDocument.h:
* loader/ImageLoader.h:
* loader/cache/CachedCSSStyleSheet.cpp:
* loader/cache/CachedCSSStyleSheet.h:
* loader/cache/CachedFont.cpp:
* loader/cache/CachedFont.h:
* loader/cache/CachedImage.cpp:
* loader/cache/CachedImage.h:
* loader/cache/CachedResourceClient.h:
* loader/cache/CachedXSLStyleSheet.cpp:
* loader/cache/CachedXSLStyleSheet.h:
* platform/chromium/ClipboardChromium.h:
* platform/gtk/ClipboardGtk.h:
* platform/mac/ClipboardMac.h:
* platform/qt/ClipboardQt.h:
* platform/win/ClipboardWin.h:
* rendering/RenderObject.cpp:
* rendering/RenderObject.h:
* svg/SVGFEImageElement.h:
* svg/SVGFontFaceUriElement.h:
* xml/XSLImportRule.h:
Source/WebKit/mac: Use a CachedImageClient instead of CachedResourceClient
in WebHTMLView.
https://bugs.webkit.org/show_bug.cgi?id=69790
Reviewed by Adam Barth.
* WebView/WebHTMLView.mm:
(promisedDataClient):
Source/WebKit2: Use a CachedImageClient instead of CachedResourceClient
in WebDragClientMac.
https://bugs.webkit.org/show_bug.cgi?id=69790
Reviewed by Adam Barth.
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(promisedDataClient):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@97113 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/loader/ImageLoader.h b/Source/WebCore/loader/ImageLoader.h
index 9bf7624..e85f1d1 100644
--- a/Source/WebCore/loader/ImageLoader.h
+++ b/Source/WebCore/loader/ImageLoader.h
@@ -23,7 +23,7 @@
#ifndef ImageLoader_h
#define ImageLoader_h
-#include "CachedResourceClient.h"
+#include "CachedImage.h"
#include "CachedResourceHandle.h"
#include <wtf/text/AtomicString.h>
@@ -33,7 +33,7 @@
class ImageLoadEventSender;
class RenderImageResource;
-class ImageLoader : public CachedResourceClient {
+class ImageLoader : public CachedImageClient {
public:
ImageLoader(Element*);
virtual ~ImageLoader();
diff --git a/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp b/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp
index 53a04fb..a4d075d 100644
--- a/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp
+++ b/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp
@@ -28,8 +28,8 @@
#include "CachedCSSStyleSheet.h"
#include "MemoryCache.h"
-#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
+#include "CachedStyleSheetClient.h"
#include "HTTPParsers.h"
#include "TextResourceDecoder.h"
#include "SharedBuffer.h"
@@ -53,7 +53,7 @@
void CachedCSSStyleSheet::didAddClient(CachedResourceClient *c)
{
if (!isLoading())
- c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this);
+ static_cast<CachedStyleSheetClient*>(c)->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this);
}
void CachedCSSStyleSheet::allClientsRemoved()
@@ -113,7 +113,7 @@
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient *c = w.next())
- c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this);
+ static_cast<CachedStyleSheetClient*>(c)->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this);
}
void CachedCSSStyleSheet::error(CachedResource::Status status)
diff --git a/Source/WebCore/loader/cache/CachedFont.cpp b/Source/WebCore/loader/cache/CachedFont.cpp
index 72358a3..1d89718 100644
--- a/Source/WebCore/loader/cache/CachedFont.cpp
+++ b/Source/WebCore/loader/cache/CachedFont.cpp
@@ -80,7 +80,7 @@
void CachedFont::didAddClient(CachedResourceClient* c)
{
if (!isLoading())
- c->fontLoaded(this);
+ static_cast<CachedFontClient*>(c)->fontLoaded(this);
}
void CachedFont::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
@@ -194,7 +194,7 @@
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient *c = w.next())
- c->fontLoaded(this);
+ static_cast<CachedFontClient*>(c)->fontLoaded(this);
}
diff --git a/Source/WebCore/loader/cache/CachedFont.h b/Source/WebCore/loader/cache/CachedFont.h
index 6d28853..637f010 100644
--- a/Source/WebCore/loader/cache/CachedFont.h
+++ b/Source/WebCore/loader/cache/CachedFont.h
@@ -27,6 +27,7 @@
#define CachedFont_h
#include "CachedResource.h"
+#include "CachedResourceClient.h"
#include "FontOrientation.h"
#include "FontRenderingMode.h"
#include "FontWidthVariant.h"
@@ -34,7 +35,6 @@
namespace WebCore {
-class CachedResourceClient;
class CachedResourceLoader;
class FontPlatformData;
class SVGDocument;
@@ -80,6 +80,12 @@
friend class MemoryCache;
};
+class CachedFontClient : public CachedResourceClient {
+public:
+ virtual ~CachedFontClient() { }
+ virtual void fontLoaded(CachedFont*) { }
+};
+
}
#endif
diff --git a/Source/WebCore/loader/cache/CachedImage.cpp b/Source/WebCore/loader/cache/CachedImage.cpp
index 438c9fd..d3e08a2 100644
--- a/Source/WebCore/loader/cache/CachedImage.cpp
+++ b/Source/WebCore/loader/cache/CachedImage.cpp
@@ -100,7 +100,7 @@
}
if (m_image && !m_image->isNull())
- c->imageChanged(this);
+ static_cast<CachedImageClient*>(c)->imageChanged(this);
CachedResource::didAddClient(c);
}
@@ -230,7 +230,7 @@
{
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient* c = w.next())
- c->imageChanged(this, changeRect);
+ static_cast<CachedImageClient*>(c)->imageChanged(this, changeRect);
}
void CachedImage::checkShouldPaintBrokenImage()
@@ -373,7 +373,7 @@
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient* c = w.next()) {
- if (c->willRenderImage(this))
+ if (static_cast<CachedImageClient*>(c)->willRenderImage(this))
return false;
}
diff --git a/Source/WebCore/loader/cache/CachedImage.h b/Source/WebCore/loader/cache/CachedImage.h
index e0f46fb..6855c8c 100644
--- a/Source/WebCore/loader/cache/CachedImage.h
+++ b/Source/WebCore/loader/cache/CachedImage.h
@@ -24,6 +24,7 @@
#define CachedImage_h
#include "CachedResource.h"
+#include "CachedResourceClient.h"
#include "ImageObserver.h"
#include "IntRect.h"
#include "Timer.h"
@@ -103,6 +104,21 @@
bool m_shouldPaintBrokenImage;
};
+class CachedImageClient : public CachedResourceClient {
+public:
+ virtual ~CachedImageClient() { }
+
+ // Called whenever a frame of an image changes, either because we got more data from the network or
+ // because we are animating. If not null, the IntRect is the changed rect of the image.
+ virtual void imageChanged(CachedImage*, const IntRect* = 0) { }
+
+ // Called to find out if this client wants to actually display the image. Used to tell when we
+ // can halt animation. Content nodes that hold image refs for example would not render the image,
+ // but RenderImages would (assuming they have visibility: visible and their render tree isn't hidden
+ // e.g., in the b/f cache or in a background tab).
+ virtual bool willRenderImage(CachedImage*) { return false; }
+};
+
}
#endif
diff --git a/Source/WebCore/loader/cache/CachedResourceClient.h b/Source/WebCore/loader/cache/CachedResourceClient.h
index 1c56f13..6a10c70 100644
--- a/Source/WebCore/loader/cache/CachedResourceClient.h
+++ b/Source/WebCore/loader/cache/CachedResourceClient.h
@@ -29,43 +29,16 @@
#include <wtf/Forward.h>
namespace WebCore {
+class CachedResource;
- class CachedCSSStyleSheet;
- class CachedFont;
- class CachedResource;
- class CachedImage;
- class Image;
- class IntRect;
- class KURL;
-
- /**
- * @internal
- *
- * a client who wants to load stylesheets, images or scripts from the web has to
- * inherit from this class and overload one of the 3 functions
- *
- */
- class CachedResourceClient {
- WTF_MAKE_FAST_ALLOCATED;
- public:
- virtual ~CachedResourceClient() { }
-
- // Called whenever a frame of an image changes, either because we got more data from the network or
- // because we are animating. If not null, the IntRect is the changed rect of the image.
- virtual void imageChanged(CachedImage*, const IntRect* = 0) { };
-
- // Called to find out if this client wants to actually display the image. Used to tell when we
- // can halt animation. Content nodes that hold image refs for example would not render the image,
- // but RenderImages would (assuming they have visibility: visible and their render tree isn't hidden
- // e.g., in the b/f cache or in a background tab).
- virtual bool willRenderImage(CachedImage*) { return false; }
-
- virtual void setCSSStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* charset */, const CachedCSSStyleSheet*) { }
- virtual void setXSLStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* sheet */) { }
- virtual void fontLoaded(CachedFont*) {};
- virtual void notifyFinished(CachedResource*) { }
- };
-
+class CachedResourceClient {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ virtual ~CachedResourceClient() { }
+ virtual void notifyFinished(CachedResource*) { }
+protected:
+ CachedResourceClient() { }
+};
}
#endif
diff --git a/Source/WebCore/loader/cache/CachedStyleSheetClient.h b/Source/WebCore/loader/cache/CachedStyleSheetClient.h
new file mode 100644
index 0000000..bdd215d
--- /dev/null
+++ b/Source/WebCore/loader/cache/CachedStyleSheetClient.h
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
+ Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ Copyright (C) 2011 Google Inc. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ This class provides all functionality needed for loading images, style sheets and html
+ pages from the web. It has a memory cache for these objects.
+ */
+
+#ifndef CachedStyleSheetClient_h
+#define CachedStyleSheetClient_h
+
+#include "CachedResourceClient.h"
+#include <wtf/FastAllocBase.h>
+#include <wtf/Forward.h>
+
+namespace WebCore {
+class CachedCSSStyleSheet;
+
+class CachedStyleSheetClient : public CachedResourceClient {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ virtual ~CachedStyleSheetClient() { }
+ virtual void setCSSStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* charset */, const CachedCSSStyleSheet*) { }
+ virtual void setXSLStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* sheet */) { }
+};
+}
+
+#endif // CachedStyleSheetClient_h
diff --git a/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp b/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp
index 62e5048..e3aac89 100644
--- a/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp
+++ b/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp
@@ -27,8 +27,8 @@
#include "config.h"
#include "CachedXSLStyleSheet.h"
-#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
+#include "CachedStyleSheetClient.h"
#include "SharedBuffer.h"
#include "TextResourceDecoder.h"
#include <wtf/Vector.h>
@@ -49,7 +49,7 @@
void CachedXSLStyleSheet::didAddClient(CachedResourceClient* c)
{
if (!isLoading())
- c->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet);
+ static_cast<CachedStyleSheetClient*>(c)->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet);
}
void CachedXSLStyleSheet::setEncoding(const String& chs)
@@ -84,7 +84,7 @@
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient *c = w.next())
- c->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet);
+ static_cast<CachedStyleSheetClient*>(c)->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet);
}
void CachedXSLStyleSheet::error(CachedResource::Status status)