[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
pfeldman at chromium.org
pfeldman at chromium.org
Wed Dec 22 14:37:40 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 651516a80bb99be1e82388b44596be68fc33aa66
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Oct 14 13:03:06 2010 +0000
2010-10-14 Pavel Feldman <pfeldman at chromium.org>
Not reviewed. Re-landing r69757.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69761 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 13dca94..58d43d0 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1111,8 +1111,8 @@ SET(WebCore_SOURCES
inspector/InspectorInstrumentation.cpp
inspector/InspectorProfilerAgent.cpp
inspector/InspectorResource.cpp
+ inspector/InspectorResourceAgent.cpp
inspector/InspectorStyleSheet.cpp
- inspector/InspectorUtilities.cpp
inspector/InspectorValues.cpp
inspector/InspectorStorageAgent.cpp
inspector/InspectorTimelineAgent.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a3e5e17..6688d43 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-14 Pavel Feldman <pfeldman at chromium.org>
+
+ Not reviewed. Re-landing r69757.
+
2010-10-14 Pavel Podivilov <podivilov at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index a9a2933..b13a890 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1832,14 +1832,14 @@ webcore_sources += \
WebCore/inspector/InspectorProfilerAgent.h \
WebCore/inspector/InspectorResource.cpp \
WebCore/inspector/InspectorResource.h \
+ WebCore/inspector/InspectorResourceAgent.cpp \
+ WebCore/inspector/InspectorResourceAgent.h \
WebCore/inspector/InspectorStorageAgent.cpp \
WebCore/inspector/InspectorStorageAgent.h \
WebCore/inspector/InspectorStyleSheet.cpp \
WebCore/inspector/InspectorStyleSheet.h \
WebCore/inspector/InspectorTimelineAgent.cpp \
WebCore/inspector/InspectorTimelineAgent.h \
- WebCore/inspector/InspectorUtilities.cpp \
- WebCore/inspector/InspectorUtilities.h \
WebCore/inspector/InspectorValues.cpp \
WebCore/inspector/InspectorValues.h \
WebCore/inspector/InspectorWorkerResource.h \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 920e754..b6fb076 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1933,14 +1933,14 @@
'inspector/InspectorProfilerAgent.h',
'inspector/InspectorResource.cpp',
'inspector/InspectorResource.h',
+ 'inspector/InspectorResourceAgent.cpp',
+ 'inspector/InspectorResourceAgent.h',
'inspector/InspectorStorageAgent.cpp',
'inspector/InspectorStorageAgent.h',
'inspector/InspectorStyleSheet.cpp',
'inspector/InspectorStyleSheet.h',
'inspector/InspectorTimelineAgent.cpp',
'inspector/InspectorTimelineAgent.h',
- 'inspector/InspectorUtilities.cpp',
- 'inspector/InspectorUtilities.h',
'inspector/InspectorValues.cpp',
'inspector/InspectorValues.h',
'inspector/InspectorWorkerResource.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 90230e8..4d54920 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1001,10 +1001,10 @@ SOURCES += \
inspector/InspectorInstrumentation.cpp \
inspector/InspectorProfilerAgent.cpp \
inspector/InspectorResource.cpp \
+ inspector/InspectorResourceAgent.cpp \
inspector/InspectorStorageAgent.cpp \
inspector/InspectorStyleSheet.cpp \
inspector/InspectorTimelineAgent.cpp \
- inspector/InspectorUtilities.cpp \
inspector/InspectorValues.cpp \
inspector/ScriptBreakpoint.cpp \
inspector/TimelineRecordFactory.cpp \
@@ -1878,10 +1878,10 @@ HEADERS += \
inspector/InspectorInstrumentation.h \
inspector/InspectorProfilerAgent.h \
inspector/InspectorResource.h \
+ inspector/InspectorResourceAgent.h \
inspector/InspectorStorageAgent.h \
inspector/InspectorStyleSheet.h \
inspector/InspectorTimelineAgent.h \
- inspector/InspectorUtilities.h \
inspector/ScriptGCEventListener.h \
inspector/TimelineRecordFactory.h \
loader/appcache/ApplicationCacheGroup.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 84ac78f..7237809 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -63239,35 +63239,35 @@
>
</File>
<File
- RelativePath="..\inspector\InspectorStorageAgent.cpp"
+ RelativePath="..\inspector\InspectorResourceAgent.cpp"
>
</File>
<File
- RelativePath="..\inspector\InspectorStorageAgent.h"
+ RelativePath="..\inspector\InspectorResourceAgent.h"
>
</File>
<File
- RelativePath="..\inspector\InspectorStyleSheet.cpp"
+ RelativePath="..\inspector\InspectorStorageAgent.cpp"
>
</File>
<File
- RelativePath="..\inspector\InspectorStyleSheet.h"
+ RelativePath="..\inspector\InspectorStorageAgent.h"
>
</File>
<File
- RelativePath="..\inspector\InspectorTimelineAgent.cpp"
+ RelativePath="..\inspector\InspectorStyleSheet.cpp"
>
</File>
<File
- RelativePath="..\inspector\InspectorTimelineAgent.h"
+ RelativePath="..\inspector\InspectorStyleSheet.h"
>
</File>
<File
- RelativePath="..\inspector\InspectorUtilities.cpp"
+ RelativePath="..\inspector\InspectorTimelineAgent.cpp"
>
</File>
<File
- RelativePath="..\inspector\InspectorUtilities.h"
+ RelativePath="..\inspector\InspectorTimelineAgent.h"
>
</File>
<File
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index a41de85..e10bef0 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1520,8 +1520,8 @@
82AB1744124B99EC00C5069D /* InspectorCSSAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 82AB1742124B99EC00C5069D /* InspectorCSSAgent.h */; };
82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82AB176F125C826700C5069D /* InspectorStyleSheet.cpp */; };
82AB1774125C826700C5069D /* InspectorStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = 82AB1770125C826700C5069D /* InspectorStyleSheet.h */; };
- 82AB1775125C826700C5069D /* InspectorUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82AB1771125C826700C5069D /* InspectorUtilities.cpp */; };
- 82AB1776125C826700C5069D /* InspectorUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 82AB1772125C826700C5069D /* InspectorUtilities.h */; };
+ 82AB1775125C826700C5069D /* InspectorResourceAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82AB1771125C826700C5069D /* InspectorResourceAgent.cpp */; };
+ 82AB1776125C826700C5069D /* InspectorResourceAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 82AB1772125C826700C5069D /* InspectorResourceAgent.h */; };
82B658981189E39200E052A1 /* InspectorCSSStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 82B658971189E39200E052A1 /* InspectorCSSStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
82B6589A1189E47600E052A1 /* InspectorCSSStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82B658991189E47600E052A1 /* InspectorCSSStore.cpp */; };
82E3D8DE122EA0D1003AE5BC /* CSSPropertySourceData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82E3D8DC122EA0D1003AE5BC /* CSSPropertySourceData.cpp */; };
@@ -7615,8 +7615,8 @@
82AB1742124B99EC00C5069D /* InspectorCSSAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCSSAgent.h; sourceTree = "<group>"; };
82AB176F125C826700C5069D /* InspectorStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorStyleSheet.cpp; sourceTree = "<group>"; };
82AB1770125C826700C5069D /* InspectorStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorStyleSheet.h; sourceTree = "<group>"; };
- 82AB1771125C826700C5069D /* InspectorUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorUtilities.cpp; sourceTree = "<group>"; };
- 82AB1772125C826700C5069D /* InspectorUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorUtilities.h; sourceTree = "<group>"; };
+ 82AB1771125C826700C5069D /* InspectorResourceAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorResourceAgent.cpp; sourceTree = "<group>"; };
+ 82AB1772125C826700C5069D /* InspectorResourceAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorResourceAgent.h; sourceTree = "<group>"; };
82B658971189E39200E052A1 /* InspectorCSSStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCSSStore.h; sourceTree = "<group>"; };
82B658991189E47600E052A1 /* InspectorCSSStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCSSStore.cpp; sourceTree = "<group>"; };
82E3D8DC122EA0D1003AE5BC /* CSSPropertySourceData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPropertySourceData.cpp; sourceTree = "<group>"; };
@@ -12192,14 +12192,14 @@
9F0D6B2D121BFEBA006C0288 /* InspectorProfilerAgent.h */,
41F062000F5F0B6600A07EAC /* InspectorResource.cpp */,
41F061FF0F5F0B6600A07EAC /* InspectorResource.h */,
+ 82AB1771125C826700C5069D /* InspectorResourceAgent.cpp */,
+ 82AB1772125C826700C5069D /* InspectorResourceAgent.h */,
7AB0B1BE1211A62200A76940 /* InspectorStorageAgent.cpp */,
7AB0B1BF1211A62200A76940 /* InspectorStorageAgent.h */,
82AB176F125C826700C5069D /* InspectorStyleSheet.cpp */,
82AB1770125C826700C5069D /* InspectorStyleSheet.h */,
754133A9102E00F400075D00 /* InspectorTimelineAgent.cpp */,
754133A7102E00E800075D00 /* InspectorTimelineAgent.h */,
- 82AB1771125C826700C5069D /* InspectorUtilities.cpp */,
- 82AB1772125C826700C5069D /* InspectorUtilities.h */,
4F3289B311A42AAB005ABE7E /* InspectorValues.cpp */,
4F3289B411A42AAB005ABE7E /* InspectorValues.h */,
F375CC061150D300008DDB81 /* InspectorWorkerResource.h */,
@@ -19663,10 +19663,10 @@
20D629271253690B00081543 /* InspectorInstrumentation.h in Headers */,
9F0D6B2F121BFEBA006C0288 /* InspectorProfilerAgent.h in Headers */,
41F062010F5F0B6600A07EAC /* InspectorResource.h in Headers */,
+ 82AB1776125C826700C5069D /* InspectorResourceAgent.h in Headers */,
7AB0B1C11211A62200A76940 /* InspectorStorageAgent.h in Headers */,
82AB1774125C826700C5069D /* InspectorStyleSheet.h in Headers */,
754133A8102E00E800075D00 /* InspectorTimelineAgent.h in Headers */,
- 82AB1776125C826700C5069D /* InspectorUtilities.h in Headers */,
4F3289B611A42AAB005ABE7E /* InspectorValues.h in Headers */,
F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */,
49EECDEC10503C2400099FAB /* Int16Array.h in Headers */,
@@ -22231,10 +22231,10 @@
20D629261253690B00081543 /* InspectorInstrumentation.cpp in Sources */,
9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */,
41F062020F5F0B6600A07EAC /* InspectorResource.cpp in Sources */,
+ 82AB1775125C826700C5069D /* InspectorResourceAgent.cpp in Sources */,
7AB0B1C01211A62200A76940 /* InspectorStorageAgent.cpp in Sources */,
82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */,
754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */,
- 82AB1775125C826700C5069D /* InspectorUtilities.cpp in Sources */,
4F3289B511A42AAB005ABE7E /* InspectorValues.cpp in Sources */,
49EECDEB10503C2400099FAB /* Int16Array.cpp in Sources */,
49EECDE810503C2400099FAB /* Int32Array.cpp in Sources */,
diff --git a/WebCore/inspector/InspectorCSSAgent.cpp b/WebCore/inspector/InspectorCSSAgent.cpp
index a6be896..e0fab85 100644
--- a/WebCore/inspector/InspectorCSSAgent.cpp
+++ b/WebCore/inspector/InspectorCSSAgent.cpp
@@ -40,7 +40,6 @@
#include "HTMLHeadElement.h"
#include "InspectorDOMAgent.h"
#include "InspectorFrontend.h"
-#include "InspectorUtilities.h"
#include "InspectorValues.h"
#include "Node.h"
#include "StyleSheetList.h"
diff --git a/WebCore/inspector/InspectorResource.cpp b/WebCore/inspector/InspectorResource.cpp
index 4019994..6bc3cfb 100644
--- a/WebCore/inspector/InspectorResource.cpp
+++ b/WebCore/inspector/InspectorResource.cpp
@@ -40,6 +40,7 @@
#include "DocumentLoader.h"
#include "Frame.h"
#include "InspectorFrontend.h"
+#include "InspectorResourceAgent.h"
#include "InspectorValues.h"
#include "ResourceLoadTiming.h"
#include "ResourceRequest.h"
@@ -348,44 +349,6 @@ void InspectorResource::releaseScriptObject(InspectorFrontend* frontend)
frontend->removeResource(m_identifier);
}
-CachedResource* InspectorResource::cachedResource() const
-{
- // Try hard to find a corresponding CachedResource. During preloading, CachedResourceLoader may not have the resource in document resources set yet,
- // but Inspector will already try to fetch data that is only available via CachedResource (and it won't update once the resource is added,
- // because m_changes will not have the appropriate bits set).
- if (!m_frame)
- return 0;
- const String& url = m_requestURL.string();
- CachedResource* cachedResource = m_frame->document()->cachedResourceLoader()->cachedResource(url);
- if (!cachedResource)
- cachedResource = cache()->resourceForURL(url);
- return cachedResource;
-}
-
-InspectorResource::Type InspectorResource::cachedResourceType() const
-{
- CachedResource* cachedResource = this->cachedResource();
-
- if (!cachedResource)
- return Other;
-
- switch (cachedResource->type()) {
- case CachedResource::ImageResource:
- return Image;
- case CachedResource::FontResource:
- return Font;
- case CachedResource::CSSStyleSheet:
-#if ENABLE(XSLT)
- case CachedResource::XSLStyleSheet:
-#endif
- return Stylesheet;
- case CachedResource::Script:
- return Script;
- default:
- return Other;
- }
-}
-
InspectorResource::Type InspectorResource::type() const
{
if (!m_overrideContent.isNull())
@@ -397,18 +360,18 @@ InspectorResource::Type InspectorResource::type() const
#endif
ASSERT(m_loader);
- if (equalIgnoringFragmentIdentifier(m_requestURL, m_loader->requestURL())) {
- InspectorResource::Type resourceType = cachedResourceType();
- if (resourceType == Other)
- return Doc;
-
- return resourceType;
- }
if (m_loader->frameLoader() && equalIgnoringFragmentIdentifier(m_requestURL, m_loader->frameLoader()->iconURL()))
return Image;
- return cachedResourceType();
+ if (!m_frame)
+ return Other;
+
+ InspectorResource::Type resourceType = InspectorResourceAgent::cachedResourceType(m_frame->document(), m_requestURL);
+ if (equalIgnoringFragmentIdentifier(m_requestURL, m_loader->requestURL()) && resourceType == Other)
+ return Doc;
+
+ return resourceType;
}
void InspectorResource::setOverrideContent(const String& data, Type type)
@@ -423,15 +386,10 @@ String InspectorResource::sourceString() const
if (!m_overrideContent.isNull())
return String(m_overrideContent);
- String textEncodingName;
- RefPtr<SharedBuffer> buffer = resourceData(&textEncodingName);
- if (!buffer)
+ String result;
+ if (!InspectorResourceAgent::resourceContent(m_frame->document(), m_requestURL, &result))
return String();
-
- TextEncoding encoding(textEncodingName);
- if (!encoding.isValid())
- encoding = WindowsLatin1Encoding();
- return encoding.decode(buffer->data(), buffer->size());
+ return result;
}
String InspectorResource::sourceBytes() const
@@ -442,40 +400,13 @@ String InspectorResource::sourceBytes() const
String overrideContent = m_overrideContent;
data.append(overrideContent.characters(), overrideContent.length());
base64Encode(data, out);
- } else {
- String textEncodingName;
- RefPtr<SharedBuffer> data = resourceData(&textEncodingName);
- if (!data)
- return String();
- base64Encode(data->buffer(), out);
+ return String(out.data(), out.size());
}
- return String(out.data(), out.size());
-}
-PassRefPtr<SharedBuffer> InspectorResource::resourceData(String* textEncodingName) const
-{
- if (m_loader && equalIgnoringFragmentIdentifier(m_requestURL, m_loader->requestURL())) {
- *textEncodingName = m_frame->document()->inputEncoding();
- return m_loader->mainResourceData();
- }
-
- CachedResource* cachedResource = this->cachedResource();
- if (!cachedResource)
- return 0;
-
- if (cachedResource->isPurgeable()) {
- // If the resource is purgeable then make it unpurgeable to get
- // get its data. This might fail, in which case we return an
- // empty String.
- // FIXME: should we do something else in the case of a purged
- // resource that informs the user why there is no data in the
- // inspector?
- if (!cachedResource->makePurgeable(false))
- return 0;
- }
-
- *textEncodingName = cachedResource->encoding();
- return cachedResource->data();
+ String result;
+ if (!InspectorResourceAgent::resourceContentBase64(m_frame->document(), m_requestURL, &result))
+ return String();
+ return result;
}
void InspectorResource::startTiming()
diff --git a/WebCore/inspector/InspectorResource.h b/WebCore/inspector/InspectorResource.h
index 909075e..dccf3b2 100644
--- a/WebCore/inspector/InspectorResource.h
+++ b/WebCore/inspector/InspectorResource.h
@@ -98,10 +98,8 @@ namespace WebCore {
#endif
void setOverrideContent(const String& data, Type);
-
String sourceString() const;
String sourceBytes() const;
- PassRefPtr<SharedBuffer> resourceData(String* textEncodingName) const;
bool isSameLoader(DocumentLoader* loader) const { return loader == m_loader; }
void markMainResource() { m_isMainResource = true; }
@@ -162,9 +160,6 @@ namespace WebCore {
InspectorResource(unsigned long identifier, DocumentLoader*, const KURL& requestURL);
Type type() const;
- Type cachedResourceType() const;
- CachedResource* cachedResource() const;
-
#if ENABLE(WEB_SOCKETS)
void markWebSocket() { m_isWebSocket = true; }
#endif
diff --git a/WebCore/inspector/InspectorResourceAgent.cpp b/WebCore/inspector/InspectorResourceAgent.cpp
new file mode 100644
index 0000000..e39c518
--- /dev/null
+++ b/WebCore/inspector/InspectorResourceAgent.cpp
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2010 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 "InspectorResourceAgent.h"
+
+#include "Base64.h"
+#include "Cache.h"
+#include "CachedResource.h"
+#include "CachedResourceLoader.h"
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "KURL.h"
+#include "SharedBuffer.h"
+#include "TextEncoding.h"
+
+#include <wtf/RefPtr.h>
+
+#if ENABLE(INSPECTOR)
+
+namespace WebCore {
+
+bool InspectorResourceAgent::resourceContent(Document* document, const KURL& url, String* result)
+{
+ if (!document)
+ return false;
+
+ String textEncodingName;
+ RefPtr<SharedBuffer> buffer = InspectorResourceAgent::resourceData(document, url, &textEncodingName);
+
+ if (buffer) {
+ TextEncoding encoding(textEncodingName);
+ if (!encoding.isValid())
+ encoding = WindowsLatin1Encoding();
+ *result = encoding.decode(buffer->data(), buffer->size());
+ return true;
+ }
+
+ return false;
+}
+
+bool InspectorResourceAgent::resourceContentBase64(Document* document, const KURL& url, String* result)
+{
+ Vector<char> out;
+ String textEncodingName;
+ RefPtr<SharedBuffer> data = InspectorResourceAgent::resourceData(document, url, &textEncodingName);
+ if (!data) {
+ *result = String();
+ return false;
+ }
+
+ base64Encode(data->buffer(), out);
+ *result = String(out.data(), out.size());
+ return true;
+}
+
+PassRefPtr<SharedBuffer> InspectorResourceAgent::resourceData(Document* document, const KURL& url, String* textEncodingName)
+{
+ FrameLoader* frameLoader = document->frame()->loader();
+ DocumentLoader* loader = frameLoader->documentLoader();
+ if (equalIgnoringFragmentIdentifier(url, loader->url())) {
+ *textEncodingName = document->inputEncoding();
+ return frameLoader->documentLoader()->mainResourceData();
+ }
+
+ CachedResource* cachedResource = InspectorResourceAgent::cachedResource(document, url);
+ if (!cachedResource)
+ return 0;
+
+ if (cachedResource->isPurgeable()) {
+ // If the resource is purgeable then make it unpurgeable to get
+ // get its data. This might fail, in which case we return an
+ // empty String.
+ // FIXME: should we do something else in the case of a purged
+ // resource that informs the user why there is no data in the
+ // inspector?
+ if (!cachedResource->makePurgeable(false))
+ return 0;
+ }
+
+ *textEncodingName = cachedResource->encoding();
+ return cachedResource->data();
+}
+
+InspectorResource::Type InspectorResourceAgent::cachedResourceType(Document* document, const KURL& url)
+{
+ CachedResource* cachedResource = InspectorResourceAgent::cachedResource(document, url);
+ if (!cachedResource)
+ return InspectorResource::Other;
+
+ switch (cachedResource->type()) {
+ case CachedResource::ImageResource:
+ return InspectorResource::Image;
+ case CachedResource::FontResource:
+ return InspectorResource::Font;
+ case CachedResource::CSSStyleSheet:
+#if ENABLE(XSLT)
+ case CachedResource::XSLStyleSheet:
+#endif
+ return InspectorResource::Stylesheet;
+ case CachedResource::Script:
+ return InspectorResource::Script;
+ default:
+ return InspectorResource::Other;
+ }
+}
+
+CachedResource* InspectorResourceAgent::cachedResource(Document* document, const KURL& url)
+{
+ const String& urlString = url.string();
+ CachedResource* cachedResource = document->cachedResourceLoader()->cachedResource(urlString);
+ if (!cachedResource)
+ cachedResource = cache()->resourceForURL(urlString);
+ return cachedResource;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorResourceAgent.h b/WebCore/inspector/InspectorResourceAgent.h
new file mode 100644
index 0000000..3bffd2f
--- /dev/null
+++ b/WebCore/inspector/InspectorResourceAgent.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 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 InspectorResourceAgent_h
+#define InspectorResourceAgent_h
+
+#include "InspectorResource.h"
+
+#include <wtf/PassRefPtr.h>
+
+#if ENABLE(INSPECTOR)
+
+namespace WTF {
+class String;
+}
+
+namespace WebCore {
+
+class CachedResource;
+class Document;
+class KURL;
+class SharedBuffer;
+
+class InspectorResourceAgent {
+public:
+ static bool resourceContent(Document*, const KURL&, String* result);
+ static bool resourceContentBase64(Document*, const KURL&, String* result);
+ static PassRefPtr<SharedBuffer> resourceData(Document*, const KURL&, String* textEncodingName);
+ static InspectorResource::Type cachedResourceType(Document*, const KURL&);
+ static CachedResource* cachedResource(Document*, const KURL&);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
+
+#endif // !defined(InspectorResourceAgent_h)
diff --git a/WebCore/inspector/InspectorStyleSheet.cpp b/WebCore/inspector/InspectorStyleSheet.cpp
index eb25fc4..9ee1f51 100644
--- a/WebCore/inspector/InspectorStyleSheet.cpp
+++ b/WebCore/inspector/InspectorStyleSheet.cpp
@@ -38,7 +38,7 @@
#include "Element.h"
#include "HTMLHeadElement.h"
#include "InspectorCSSAgent.h"
-#include "InspectorUtilities.h"
+#include "InspectorResourceAgent.h"
#include "InspectorValues.h"
#include "Node.h"
#include "StyleSheetList.h"
@@ -468,7 +468,7 @@ bool InspectorStyleSheet::resourceStyleSheetText(String* result) const
if (!m_pageStyleSheet)
return false;
- return InspectorUtilities::resourceContentForURL(m_pageStyleSheet->finalURL(), ownerDocument(), result);
+ return InspectorResourceAgent::resourceContent(ownerDocument(), m_pageStyleSheet->finalURL(), result);
}
bool InspectorStyleSheet::inlineStyleSheetText(String* result) const
diff --git a/WebCore/inspector/InspectorUtilities.cpp b/WebCore/inspector/InspectorUtilities.cpp
deleted file mode 100644
index 3d6b0d7..0000000
--- a/WebCore/inspector/InspectorUtilities.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2010 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 "InspectorUtilities.h"
-
-#include "Cache.h"
-#include "CachedResource.h"
-#include "CachedResourceLoader.h"
-#include "Document.h"
-#include "DocumentLoader.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "KURL.h"
-#include "SharedBuffer.h"
-#include "TextEncoding.h"
-
-#include <wtf/RefPtr.h>
-
-#if ENABLE(INSPECTOR)
-
-namespace WebCore {
-
-// static
-bool InspectorUtilities::resourceContentForURL(const KURL& url, Document* frameDocument, String* result)
-{
- if (!frameDocument)
- return false;
-
- String textEncodingName;
- RefPtr<SharedBuffer> buffer;
- if (equalIgnoringFragmentIdentifier(url, frameDocument->frame()->loader()->documentLoader()->requestURL())) {
- textEncodingName = frameDocument->inputEncoding();
- buffer = frameDocument->frame()->loader()->provisionalDocumentLoader()->mainResourceData();
- } else {
- const String& urlString = url.string();
- CachedResource* cachedResource = frameDocument->cachedResourceLoader()->cachedResource(urlString);
- if (!cachedResource)
- cachedResource = cache()->resourceForURL(urlString);
-
- ASSERT(cachedResource); // FIXME(apavlov): This might be too aggressive.
-
- bool isUnpurgeable = true;
- if (cachedResource->isPurgeable()) {
- // If the resource is purgeable then make it unpurgeable to get
- // its data. This might fail, in which case we return an
- // empty String.
- if (!cachedResource->makePurgeable(false))
- isUnpurgeable = false;
- }
- if (isUnpurgeable) {
- textEncodingName = cachedResource->encoding();
- buffer = cachedResource->data();
- }
- }
-
- if (buffer) {
- TextEncoding encoding(textEncodingName);
- if (!encoding.isValid())
- encoding = WindowsLatin1Encoding();
- *result = encoding.decode(buffer->data(), buffer->size());
- return true;
- }
-
- return false;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorUtilities.h b/WebCore/inspector/InspectorUtilities.h
deleted file mode 100644
index 2837426..0000000
--- a/WebCore/inspector/InspectorUtilities.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef InspectorUtilities_h
-#define InspectorUtilities_h
-
-#include "PlatformString.h"
-
-#if ENABLE(INSPECTOR)
-
-namespace WebCore {
-
-class CSSStyleDeclaration;
-class CSSStyleRule;
-class CSSStyleSheet;
-class Document;
-class KURL;
-class StyleBase;
-
-class InspectorUtilities {
-public:
- static bool resourceContentForURL(const KURL& url, Document* frameDocument, String* result);
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(INSPECTOR)
-
-#endif // !defined(InspectorUtilities_h)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list