Commit dd7e173a authored by hyatt@apple.com's avatar hyatt@apple.com

https://bugs.webkit.org/show_bug.cgi?id=28984, remove the remote stylesheet loader on Mac/Qt.

Make sure the other code path (now used by everybody) can handle data URLs.

Reviewed by Adam Roben.

As per the post on webkit-dev, the ability to work remotely isn't working properly anyway (it doesn't
hold up the pending sheet count, so you'd just FOUC on every Web page), and it's extremely unlikely
that anybody is relying on this support.
        
Tor Arne agreed it was ok to disable (he enabled it on the Qt side), and only Mac/Qt were using this
code.

* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::userStyleSheet):
* dom/Document.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::begin):
* loader/UserStyleSheetLoader.cpp: Removed.
* loader/UserStyleSheetLoader.h: Removed.
* page/Frame.cpp:
(WebCore::Frame::reapplyStyles):
* page/Frame.h:
* page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
(WebCore::Page::userStyleSheet):
* page/mac/FrameMac.mm:
* page/qt/FrameQt.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48075 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e67bded8
2009-09-04 Dave Hyatt <hyatt@apple.com>
Reviewed by Adam Roben.
https://bugs.webkit.org/show_bug.cgi?id=28984, remove the remote stylesheet loader on Mac/Qt.
Make sure the other code path (now used by everybody) can handle data URLs.
As per the post on webkit-dev, the ability to work remotely isn't working properly anyway (it doesn't
hold up the pending sheet count, so you'd just FOUC on every Web page), and it's extremely unlikely
that anybody is relying on this support.
Tor Arne agreed it was ok to disable (he enabled it on the Qt side), and only Mac/Qt were using this
code.
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::userStyleSheet):
* dom/Document.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::begin):
* loader/UserStyleSheetLoader.cpp: Removed.
* loader/UserStyleSheetLoader.h: Removed.
* page/Frame.cpp:
(WebCore::Frame::reapplyStyles):
* page/Frame.h:
* page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
(WebCore::Page::userStyleSheet):
* page/mac/FrameMac.mm:
* page/qt/FrameQt.cpp:
2009-09-04 Mikhail Naganov <mnaganov@chromium.org>
Reviewed by Timothy Hatcher.
......@@ -1057,7 +1057,6 @@ SOURCES += \
loader/archive/ArchiveFactory.cpp \
loader/archive/ArchiveResource.cpp \
loader/archive/ArchiveResourceCollection.cpp \
loader/UserStyleSheetLoader.cpp \
loader/Cache.cpp \
loader/CachedCSSStyleSheet.cpp \
loader/CachedFont.cpp \
......@@ -1772,7 +1771,6 @@ HEADERS += \
loader/TextDocument.h \
loader/TextResourceDecoder.h \
loader/ThreadableLoader.h \
loader/UserStyleSheetLoader.h \
loader/WorkerThreadableLoader.h \
page/animation/AnimationBase.h \
page/animation/AnimationController.h \
......
......@@ -1122,7 +1122,6 @@
65DF326109D1E199000BE325 /* UserAgentStyleSheetsData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581AF09D14EE6000E61D7 /* UserAgentStyleSheetsData.cpp */; };
65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
72626E020EF022FE00A07E20 /* FontFastPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72626E010EF022FE00A07E20 /* FontFastPath.cpp */; };
7284ADDD0E6FEB31002EEFBD /* UserStyleSheetLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7284ADDB0E6FEB31002EEFBD /* UserStyleSheetLoader.cpp */; };
7284ADDE0E6FEB31002EEFBD /* UserStyleSheetLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7284ADDC0E6FEB31002EEFBD /* UserStyleSheetLoader.h */; };
75793E830D0CE0B3007FC0AC /* MessageEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75793E800D0CE0B3007FC0AC /* MessageEvent.cpp */; };
75793E840D0CE0B3007FC0AC /* MessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793E810D0CE0B3007FC0AC /* MessageEvent.h */; };
......@@ -6294,7 +6293,6 @@
65F80697054D9F86008BF776 /* BlockExceptions.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BlockExceptions.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
72626E010EF022FE00A07E20 /* FontFastPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFastPath.cpp; sourceTree = "<group>"; };
7284ADDB0E6FEB31002EEFBD /* UserStyleSheetLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserStyleSheetLoader.cpp; sourceTree = "<group>"; };
7284ADDC0E6FEB31002EEFBD /* UserStyleSheetLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserStyleSheetLoader.h; sourceTree = "<group>"; };
75793E800D0CE0B3007FC0AC /* MessageEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = MessageEvent.cpp; path = dom/MessageEvent.cpp; sourceTree = SOURCE_ROOT; };
75793E810D0CE0B3007FC0AC /* MessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MessageEvent.h; path = dom/MessageEvent.h; sourceTree = SOURCE_ROOT; };
......@@ -14379,7 +14377,6 @@
0B90561D0F257E930095FF6A /* ThreadableLoader.cpp */,
0B9056170F2578BE0095FF6A /* ThreadableLoader.h */,
0B9056180F2578BE0095FF6A /* ThreadableLoaderClient.h */,
7284ADDB0E6FEB31002EEFBD /* UserStyleSheetLoader.cpp */,
7284ADDC0E6FEB31002EEFBD /* UserStyleSheetLoader.h */,
0B9056F60F2685F30095FF6A /* WorkerThreadableLoader.cpp */,
0B9056F70F2685F30095FF6A /* WorkerThreadableLoader.h */,
......@@ -19537,7 +19534,6 @@
B2C3DA4C0D006C1D00EF6F26 /* UnicodeRange.cpp in Sources */,
D086FE9909D53AAB005BC74D /* UnlinkCommand.cpp in Sources */,
65DF326109D1E199000BE325 /* UserAgentStyleSheetsData.cpp in Sources */,
7284ADDD0E6FEB31002EEFBD /* UserStyleSheetLoader.cpp in Sources */,
15C7708E100D3C6B005BA267 /* ValidityState.cpp in Sources */,
93309E1D099E64920056E581 /* visible_units.cpp in Sources */,
93309E1F099E64920056E581 /* VisiblePosition.cpp in Sources */,
......@@ -1865,26 +1865,12 @@ String Document::userAgent(const KURL& url) const
return frame() ? frame()->loader()->userAgent(url) : String();
}
#if FRAME_LOADS_USER_STYLESHEET
void Document::setUserStyleSheet(const String& sheet)
{
if (m_usersheet != sheet) {
m_usersheet = sheet;
updateStyleSelector();
}
}
#endif
String Document::userStyleSheet() const
{
#if FRAME_LOADS_USER_STYLESHEET
return m_usersheet;
#else
Page* page = this->page();
if (!page)
return String();
return page->userStyleSheet();
#endif
}
CSSStyleSheet* Document::elementSheet()
......
......@@ -37,15 +37,6 @@
#include "Timer.h"
#include <wtf/HashCountedSet.h>
// FIXME: We should move Mac off of the old Frame-based user stylesheet loading
// code and onto the new code in Page. We can't do that until the code in Page
// supports non-file: URLs, however.
#if PLATFORM(MAC) || PLATFORM(QT)
#define FRAME_LOADS_USER_STYLESHEET 1
#else
#define FRAME_LOADS_USER_STYLESHEET 0
#endif
namespace WebCore {
class Attr;
......@@ -446,10 +437,6 @@ public:
virtual String userAgent(const KURL&) const;
#if FRAME_LOADS_USER_STYLESHEET
void setUserStyleSheet(const String& sheet);
#endif
String userStyleSheet() const;
CSSStyleSheet* elementSheet();
......@@ -921,10 +908,6 @@ private:
RefPtr<DocumentType> m_docType;
mutable RefPtr<DOMImplementation> m_implementation;
#if FRAME_LOADS_USER_STYLESHEET
String m_usersheet;
#endif
// Track the number of currently loading top-level stylesheets. Sheets
// loaded using the @import directive are not included in this count.
// We use this count of pending sheets to detect when we can begin attaching
......
......@@ -954,12 +954,6 @@ void FrameLoader::begin(const KURL& url, bool dispatch, SecurityOrigin* origin)
document->parseDNSPrefetchControlHeader(dnsPrefetchControl);
}
#if FRAME_LOADS_USER_STYLESHEET
KURL userStyleSheet = settings ? settings->userStyleSheetLocation() : KURL();
if (!userStyleSheet.isEmpty())
m_frame->setUserStyleSheetLocation(userStyleSheet);
#endif
restoreDocumentState();
document->implicitOpen();
......
/*
* Copyright (C) 2004, 2005, 2006, 2007, 2008 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.
* 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "UserStyleSheetLoader.h"
#include "CachedCSSStyleSheet.h"
#include "DocLoader.h"
#include "Frame.h"
using namespace WebCore;
UserStyleSheetLoader::UserStyleSheetLoader(PassRefPtr<Document> document, const String& url)
: m_document(document)
, m_cachedSheet(m_document->docLoader()->requestUserCSSStyleSheet(url, ""))
{
if (m_cachedSheet) {
m_document->addPendingSheet();
m_cachedSheet->addClient(this);
}
}
UserStyleSheetLoader::~UserStyleSheetLoader()
{
if (m_cachedSheet) {
if (!m_cachedSheet->isLoaded())
m_document->removePendingSheet();
m_cachedSheet->removeClient(this);
}
}
void UserStyleSheetLoader::setCSSStyleSheet(const String& /*URL*/, const String& /*charset*/, const CachedCSSStyleSheet* sheet)
{
m_document->removePendingSheet();
if (Frame* frame = m_document->frame())
frame->setUserStyleSheet(sheet->sheetText());
}
/*
* Copyright (C) 2004, 2005, 2006, 2007, 2008 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.
* 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 UserStyleSheetLoader_h
#define UserStyleSheetLoader_h
#include "CachedResourceClient.h"
#include "CachedResourceHandle.h"
#include "Document.h"
namespace WebCore {
class CachedCSSStyleSheet;
class String;
// This class is deprecated and should not be used in any new code. User
// stylesheet loading should instead happen through Page.
class UserStyleSheetLoader : CachedResourceClient {
public:
UserStyleSheetLoader(PassRefPtr<Document>, const String& url);
~UserStyleSheetLoader();
private:
virtual void setCSSStyleSheet(const String& URL, const String& charset, const CachedCSSStyleSheet* sheet);
RefPtr<Document> m_document;
CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
};
} // namespace WebCore
#endif // UserStyleSheetLoader_h
......@@ -86,10 +86,6 @@
#include "runtime_root.h"
#endif
#if FRAME_LOADS_USER_STYLESHEET
#include "UserStyleSheetLoader.h"
#endif
#if ENABLE(SVG)
#include "SVGDocument.h"
#include "SVGDocumentExtensions.h"
......@@ -825,14 +821,6 @@ void Frame::reapplyStyles()
// We should probably eventually move it into its own function.
m_doc->docLoader()->setAutoLoadImages(m_page && m_page->settings()->loadsImagesAutomatically());
#if FRAME_LOADS_USER_STYLESHEET
const KURL userStyleSheetLocation = m_page ? m_page->settings()->userStyleSheetLocation() : KURL();
if (!userStyleSheetLocation.isEmpty())
setUserStyleSheetLocation(userStyleSheetLocation);
else
setUserStyleSheet(String());
#endif
// FIXME: It's not entirely clear why the following is needed.
// The document automatically does this as required when you set the style sheet.
// But we had problems when this code was removed. Details are in
......
......@@ -80,10 +80,6 @@ namespace WebCore {
class VisibleSelection;
class Widget;
#if FRAME_LOADS_USER_STYLESHEET
class UserStyleSheetLoader;
#endif
template <typename T> class Timer;
class Frame : public RefCounted<Frame> {
......@@ -145,11 +141,6 @@ namespace WebCore {
Settings* settings() const; // can be NULL
#if FRAME_LOADS_USER_STYLESHEET
void setUserStyleSheetLocation(const KURL&);
void setUserStyleSheet(const String& styleSheetData);
#endif
void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize);
bool inViewSourceMode() const;
......@@ -371,11 +362,6 @@ namespace WebCore {
bool m_needsReapplyStyles;
bool m_isDisconnected;
bool m_excludeFromTextSearch;
#if FRAME_LOADS_USER_STYLESHEET
OwnPtr<UserStyleSheetLoader> m_userStyleSheetLoader;
#endif
};
} // namespace WebCore
......
......@@ -21,6 +21,7 @@
#include "config.h"
#include "Page.h"
#include "Base64.h"
#include "CSSStyleSelector.h"
#include "Chrome.h"
#include "ChromeClient.h"
......@@ -439,26 +440,40 @@ void Page::willMoveOffscreen()
void Page::userStyleSheetLocationChanged()
{
#if !FRAME_LOADS_USER_STYLESHEET
// FIXME: We should provide a way to load other types of URLs than just
// file: (e.g., http:, data:).
if (m_settings->userStyleSheetLocation().isLocalFile())
m_userStyleSheetPath = m_settings->userStyleSheetLocation().fileSystemPath();
// FIXME: Eventually we will move to a model of just being handed the sheet
// text instead of loading the URL ourselves.
KURL url = m_settings->userStyleSheetLocation();
if (url.isLocalFile())
m_userStyleSheetPath = url.fileSystemPath();
else
m_userStyleSheetPath = String();
m_didLoadUserStyleSheet = false;
m_userStyleSheet = String();
m_userStyleSheetModificationTime = 0;
#endif
// Data URLs with base64-encoded UTF-8 style sheets are common. We can process them
// synchronously and avoid using a loader.
if (url.protocolIs("data") && url.string().startsWith("data:text/css;charset=utf-8;base64,")) {
m_didLoadUserStyleSheet = true;
const unsigned prefixLength = 35;
Vector<char> encodedData(url.string().length() - prefixLength);
for (unsigned i = prefixLength; i < url.string().length(); ++i)
encodedData[i - prefixLength] = static_cast<char>(url.string()[i]);
Vector<char> styleSheetAsUTF8;
if (base64Decode(encodedData, styleSheetAsUTF8)) {
m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8.data());
return;
}
}
}
const String& Page::userStyleSheet() const
{
if (m_userStyleSheetPath.isEmpty()) {
ASSERT(m_userStyleSheet.isEmpty());
if (m_userStyleSheetPath.isEmpty())
return m_userStyleSheet;
}
time_t modTime;
if (!getFileModificationTime(m_userStyleSheetPath, modTime)) {
......
......@@ -28,7 +28,6 @@
#import "config.h"
#import "Frame.h"
#import "Base64.h"
#import "BlockExceptions.h"
#import "ColorMac.h"
#import "Cursor.h"
......@@ -53,7 +52,6 @@
#import "RenderTableCell.h"
#import "Scrollbar.h"
#import "SimpleFontData.h"
#import "UserStyleSheetLoader.h"
#import "WebCoreViewFactory.h"
#import "visible_units.h"
......@@ -533,33 +531,4 @@ DragImageRef Frame::dragImageForSelection()
return selectionImage();
}
void Frame::setUserStyleSheetLocation(const KURL& url)
{
m_userStyleSheetLoader.clear();
// Data URLs with base64-encoded UTF-8 style sheets are common. We can process them
// synchronously and avoid using a loader.
if (url.protocolIs("data") && url.string().startsWith("data:text/css;charset=utf-8;base64,")) {
const unsigned prefixLength = 35;
Vector<char> encodedData(url.string().length() - prefixLength);
for (unsigned i = prefixLength; i < url.string().length(); ++i)
encodedData[i - prefixLength] = static_cast<char>(url.string()[i]);
Vector<char> styleSheetAsUTF8;
if (base64Decode(encodedData, styleSheetAsUTF8)) {
m_doc->setUserStyleSheet(String::fromUTF8(styleSheetAsUTF8.data()));
return;
}
}
if (m_doc->docLoader())
m_userStyleSheetLoader.set(new UserStyleSheetLoader(m_doc, url.string()));
}
void Frame::setUserStyleSheet(const String& styleSheet)
{
m_userStyleSheetLoader.clear();
m_doc->setUserStyleSheet(styleSheet);
}
} // namespace WebCore
......@@ -33,21 +33,5 @@ DragImageRef Frame::dragImageForSelection()
return 0;
}
void Frame::setUserStyleSheetLocation(const KURL& url)
{
delete m_userStyleSheetLoader;
m_userStyleSheetLoader = 0;
if (m_doc && m_doc->docLoader())
m_userStyleSheetLoader = new UserStyleSheetLoader(m_doc, url.string());
}
void Frame::setUserStyleSheet(const String& styleSheet)
{
delete m_userStyleSheetLoader;
m_userStyleSheetLoader = 0;
if (m_doc)
m_doc->setUserStyleSheet(styleSheet);
}
}
// vim: ts=4 sw=4 et
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment