Commit 22601712 authored by weinig's avatar weinig
Browse files

Reviewed by Eric.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9768
          Split XSLImportRule out of XSLStyleSheet.* into separate 
          files (one class per file).

        * WebCore.xcodeproj/project.pbxproj:
        * xml/XSLImportRule.cpp: Added.
        (WebCore::XSLImportRule::XSLImportRule):
        (WebCore::XSLImportRule::parentStyleSheet):
        (WebCore::XSLImportRule::loadSheet):
        * xml/XSLImportRule.h: Added.
        * xml/XSLStyleSheet.cpp:
        * xml/XSLStyleSheet.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15201 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 10c1e341
2006-07-07 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Eric.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9768
Split XSLImportRule out of XSLStyleSheet.* into separate
files (one class per file).
* WebCore.xcodeproj/project.pbxproj:
* xml/XSLImportRule.cpp: Added.
(WebCore::XSLImportRule::XSLImportRule):
(WebCore::XSLImportRule::parentStyleSheet):
(WebCore::XSLImportRule::loadSheet):
* xml/XSLImportRule.h: Added.
* xml/XSLStyleSheet.cpp:
* xml/XSLStyleSheet.h:
2006-07-07 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
......
......@@ -332,6 +332,8 @@
85031B4F0A44EFC700F992E0 /* UIEventWithKeyState.h in Headers */ = {isa = PBXBuildFile; fileRef = 85031B390A44EFC700F992E0 /* UIEventWithKeyState.h */; };
85031B500A44EFC700F992E0 /* WheelEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85031B3A0A44EFC700F992E0 /* WheelEvent.cpp */; };
85031B510A44EFC700F992E0 /* WheelEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 85031B3B0A44EFC700F992E0 /* WheelEvent.h */; };
85217E020A5ECD4700DB8D00 /* XSLImportRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85217E000A5ECD4700DB8D00 /* XSLImportRule.cpp */; };
85217E030A5ECD4700DB8D00 /* XSLImportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 85217E010A5ECD4700DB8D00 /* XSLImportRule.h */; };
854FE7300A2297BE0058D7AD /* NodeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 854FE7260A2297BE0058D7AD /* NodeFilter.cpp */; };
854FE7310A2297BE0058D7AD /* NodeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 854FE7270A2297BE0058D7AD /* NodeFilter.h */; };
854FE7320A2297BE0058D7AD /* NodeFilterCondition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 854FE7280A2297BE0058D7AD /* NodeFilterCondition.cpp */; };
......@@ -2008,6 +2010,8 @@
85031B390A44EFC700F992E0 /* UIEventWithKeyState.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = UIEventWithKeyState.h; sourceTree = "<group>"; };
85031B3A0A44EFC700F992E0 /* WheelEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = WheelEvent.cpp; sourceTree = "<group>"; };
85031B3B0A44EFC700F992E0 /* WheelEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WheelEvent.h; sourceTree = "<group>"; };
85217E000A5ECD4700DB8D00 /* XSLImportRule.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = XSLImportRule.cpp; sourceTree = "<group>"; };
85217E010A5ECD4700DB8D00 /* XSLImportRule.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = XSLImportRule.h; sourceTree = "<group>"; };
854FE7260A2297BE0058D7AD /* NodeFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = NodeFilter.cpp; sourceTree = "<group>"; };
854FE7270A2297BE0058D7AD /* NodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NodeFilter.h; sourceTree = "<group>"; };
854FE7280A2297BE0058D7AD /* NodeFilterCondition.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = NodeFilterCondition.cpp; sourceTree = "<group>"; };
......@@ -5154,6 +5158,8 @@
A833C7F60A2CF1D800D57664 /* xmlattrs.in */,
E1F0424409839389006694EA /* xmlhttprequest.cpp */,
E1F0424509839389006694EA /* xmlhttprequest.h */,
85217E000A5ECD4700DB8D00 /* XSLImportRule.cpp */,
85217E010A5ECD4700DB8D00 /* XSLImportRule.h */,
BC06F24906D18A7E004A6FA3 /* XSLStyleSheet.cpp */,
BC06F24A06D18A7E004A6FA3 /* XSLStyleSheet.h */,
BC06F24B06D18A7E004A6FA3 /* XSLTProcessor.cpp */,
......@@ -6401,6 +6407,7 @@
ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */,
ABDDFE7C0A5C6E7000A3E11D /* RenderPopupMenu.h in Headers */,
ABDDFE7D0A5C6E7000A3E11D /* RenderPopupMenuMac.h in Headers */,
85217E030A5ECD4700DB8D00 /* XSLImportRule.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -7263,6 +7270,7 @@
ABDDFE790A5C6E7000A3E11D /* RenderMenuList.cpp in Sources */,
ABDDFE7B0A5C6E7000A3E11D /* RenderPopupMenu.cpp in Sources */,
ABDDFE7E0A5C6E7000A3E11D /* RenderPopupMenuMac.mm in Sources */,
85217E020A5ECD4700DB8D00 /* XSLImportRule.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
/**
* This file is part of the XSL implementation.
*
* Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "XSLImportRule.h"
#ifdef KHTML_XSLT
#include "CachedXSLStyleSheet.h"
#include "DocLoader.h"
#include "XSLStyleSheet.h"
namespace WebCore {
XSLImportRule::XSLImportRule(StyleBase* parent, const String& href)
: StyleBase(parent)
, m_strHref(href)
, m_cachedSheet(0)
, m_loading(false)
{
}
XSLImportRule::~XSLImportRule()
{
if (m_styleSheet)
m_styleSheet->setParent(0);
if (m_cachedSheet)
m_cachedSheet->deref(this);
}
XSLStyleSheet* XSLImportRule::parentStyleSheet() const
{
return (parent() && parent()->isXSLStyleSheet()) ? static_cast<XSLStyleSheet*>(parent()) : 0;
}
void XSLImportRule::setStyleSheet(const String& url, const String& sheet)
{
if (m_styleSheet)
m_styleSheet->setParent(0);
m_styleSheet = new XSLStyleSheet(this, url);
XSLStyleSheet* parent = parentStyleSheet();
if (parent)
m_styleSheet->setOwnerDocument(parent->ownerDocument());
m_styleSheet->parseString(sheet);
m_loading = false;
checkLoaded();
}
bool XSLImportRule::isLoading()
{
return (m_loading || (m_styleSheet && m_styleSheet->isLoading()));
}
void XSLImportRule::loadSheet()
{
DocLoader* docLoader = 0;
StyleBase* root = this;
StyleBase* parent;
while ((parent = root->parent()))
root = parent;
if (root->isXSLStyleSheet())
docLoader = static_cast<XSLStyleSheet*>(root)->docLoader();
String absHref = m_strHref;
XSLStyleSheet* parentSheet = parentStyleSheet();
if (!parentSheet->href().isNull())
// use parent styleheet's URL as the base URL
absHref = KURL(parentSheet->href().deprecatedString(),m_strHref.deprecatedString()).url();
// Check for a cycle in our import chain. If we encounter a stylesheet
// in our parent chain with the same URL, then just bail.
for (parent = static_cast<StyleBase*>(this)->parent(); parent; parent = parent->parent()) {
if (absHref == parent->baseURL())
return;
}
m_cachedSheet = docLoader->requestXSLStyleSheet(absHref);
if (m_cachedSheet) {
m_cachedSheet->ref(this);
// If the imported sheet is in the cache, then setStyleSheet gets called,
// and the sheet even gets parsed (via parseString). In this case we have
// loaded (even if our subresources haven't), so if we have a stylesheet after
// checking the cache, then we've clearly loaded.
if (!m_styleSheet)
m_loading = true;
}
}
} // namespace WebCore
#endif // KHTML_XSLT
/*
* This file is part of the XSL implementation.
*
* Copyright (C) 2004, 2006 Apple Computer, Inc.
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef XSLImportRule_H
#define XSLImportRule_H
#ifdef KHTML_XSLT
#include "CachedObjectClient.h"
#include "StyleBase.h"
#include "XSLStyleSheet.h"
namespace WebCore {
class CachedXSLStyleSheet;
class XSLImportRule : public CachedObjectClient, public StyleBase {
public:
XSLImportRule(StyleBase* parent, const String& href);
virtual ~XSLImportRule();
String href() const { return m_strHref; }
XSLStyleSheet* styleSheet() const { return m_styleSheet.get(); }
virtual bool isImportRule() { return true; }
XSLStyleSheet* parentStyleSheet() const;
// from CachedObjectClient
virtual void setStyleSheet(const String& url, const String& sheet);
bool isLoading();
void loadSheet();
protected:
String m_strHref;
RefPtr<XSLStyleSheet> m_styleSheet;
CachedXSLStyleSheet* m_cachedSheet;
bool m_loading;
};
} // namespace WebCore
#endif // KHTML_XSLT
#endif // XSLImportRule_H
......@@ -24,18 +24,20 @@
#ifdef KHTML_XSLT
#include "CachedXSLStyleSheet.h"
#include "DocLoader.h"
#include "HTMLDocument.h"
#include "Document.h"
#include "Node.h"
#include "XSLImportRule.h"
#include "loader.h"
#include "xml_tokenizer.h"
#include <libxml/uri.h>
#include <libxslt/xsltutils.h>
namespace WebCore {
#define IS_BLANK_NODE(n) \
(((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
namespace WebCore {
XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& href)
: StyleSheet(parentRule, href)
......@@ -193,11 +195,6 @@ void XSLStyleSheet::loadChildSheet(const DeprecatedString& href)
childRule->loadSheet();
}
XSLStyleSheet* XSLImportRule::parentStyleSheet() const
{
return (parent() && parent()->isXSLStyleSheet()) ? static_cast<XSLStyleSheet*>(parent()) : 0;
}
xsltStylesheetPtr XSLStyleSheet::compileStyleSheet()
{
// FIXME: Hook up error reporting for the stylesheet compilation process.
......@@ -261,82 +258,6 @@ void XSLStyleSheet::markAsProcessed()
m_stylesheetDocTaken = true;
}
// ----------------------------------------------------------------------------------------------
XSLImportRule::XSLImportRule(StyleBase* parent, const String &href)
: StyleBase(parent)
{
m_strHref = href;
m_cachedSheet = 0;
m_loading = false;
}
XSLImportRule::~XSLImportRule()
{
if (m_styleSheet)
m_styleSheet->setParent(0);
if (m_cachedSheet)
m_cachedSheet->deref(this);
}
void XSLImportRule::setStyleSheet(const String& url, const String& sheet)
{
if (m_styleSheet)
m_styleSheet->setParent(0);
m_styleSheet = new XSLStyleSheet(this, url);
XSLStyleSheet* parent = parentStyleSheet();
if (parent)
m_styleSheet->setOwnerDocument(parent->ownerDocument());
} // namespace WebCore
m_styleSheet->parseString(sheet);
m_loading = false;
checkLoaded();
}
bool XSLImportRule::isLoading()
{
return (m_loading || (m_styleSheet && m_styleSheet->isLoading()));
}
void XSLImportRule::loadSheet()
{
DocLoader* docLoader = 0;
StyleBase* root = this;
StyleBase* parent;
while ((parent = root->parent()))
root = parent;
if (root->isXSLStyleSheet())
docLoader = static_cast<XSLStyleSheet*>(root)->docLoader();
String absHref = m_strHref;
XSLStyleSheet* parentSheet = parentStyleSheet();
if (!parentSheet->href().isNull())
// use parent styleheet's URL as the base URL
absHref = KURL(parentSheet->href().deprecatedString(),m_strHref.deprecatedString()).url();
// Check for a cycle in our import chain. If we encounter a stylesheet
// in our parent chain with the same URL, then just bail.
for (parent = static_cast<StyleBase*>(this)->parent(); parent; parent = parent->parent())
if (absHref == parent->baseURL())
return;
m_cachedSheet = docLoader->requestXSLStyleSheet(absHref);
if (m_cachedSheet) {
m_cachedSheet->ref(this);
// If the imported sheet is in the cache, then setStyleSheet gets called,
// and the sheet even gets parsed (via parseString). In this case we have
// loaded (even if our subresources haven't), so if we have a stylesheet after
// checking the cache, then we've clearly loaded.
if (!m_styleSheet)
m_loading = true;
}
}
}
#endif
#endif // KHTML_XSLT
......@@ -25,22 +25,19 @@
#ifdef KHTML_XSLT
#include "CachedObjectClient.h"
#include "StyleSheet.h"
#include <libxml/parser.h>
#include <libxslt/transform.h>
namespace WebCore {
class CachedXSLStyleSheet;
class DocLoader;
class Document;
class XSLImportRule;
class XSLStyleSheet : public StyleSheet
{
class XSLStyleSheet : public StyleSheet {
public:
XSLStyleSheet(Node *parentNode, const String& href = String(), bool embedded = false);
XSLStyleSheet(Node* parentNode, const String& href = String(), bool embedded = false);
XSLStyleSheet(XSLImportRule* parentImport, const String& href = String());
~XSLStyleSheet();
......@@ -80,31 +77,8 @@ protected:
bool m_stylesheetDocTaken;
};
class XSLImportRule : public CachedObjectClient, public StyleBase
{
public:
XSLImportRule(StyleBase* parent, const String& href);
virtual ~XSLImportRule();
String href() const { return m_strHref; }
XSLStyleSheet* styleSheet() const { return m_styleSheet.get(); }
virtual bool isImportRule() { return true; }
XSLStyleSheet* parentStyleSheet() const;
// from CachedObjectClient
virtual void setStyleSheet(const String& url, const String &sheet);
bool isLoading();
void loadSheet();
protected:
String m_strHref;
RefPtr<XSLStyleSheet> m_styleSheet;
CachedXSLStyleSheet* m_cachedSheet;
bool m_loading;
};
} // namespace WebCore
#endif // KHTML_XSLT
}
#endif
#endif
#endif // XSLStyleSheet_H
Supports Markdown
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